Skip to content

Commit f5d72c7

Browse files
cfrantzDrew Macrae
authored andcommitted
[bazel] Fix rust libudev-sys to build under bazel
The libudev-sys crate invokes the compiler directly rather than via the cargo (and bazel) supplied `RUSTC` environment variable. This causes the library to fail when building under bazel. This patch fixes the libudev-sys crate to invoke the compiler via the `RUSTC` variable. This is the same patch as the [PR](dcuddeback/libudev-sys#11) sent to libudev-sys. Signed-off-by: Chris Frantz <cfrantz@google.com>
1 parent e171e56 commit f5d72c7

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

sw/host/opentitanlib/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ opentitantool_derive = {path = "opentitantool_derive"}
3838

3939
[package.metadata.raze.crates.libudev-sys.'0.1.4']
4040
gen_buildrs = true
41+
patches = [
42+
"@//third_party/cargo/patches:libudev-sys-0.1.4.patch"
43+
]
44+
patch_args = ["-p1"]

third_party/cargo/crates.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,12 @@ def raze_fetch_remote_crates():
538538
type = "tar.gz",
539539
sha256 = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324",
540540
strip_prefix = "libudev-sys-0.1.4",
541+
patches = [
542+
"@//third_party/cargo/patches:libudev-sys-0.1.4.patch",
543+
],
544+
patch_args = [
545+
"-p1",
546+
],
541547
build_file = Label("//third_party/cargo/remote:BUILD.libudev-sys-0.1.4.bazel"),
542548
)
543549

third_party/cargo/patches/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright lowRISC contributors.
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
package(default_visibility = ["//visibility:public"])
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/build.rs b/build.rs
2+
index 20cf4a0..3b6adc5 100644
3+
--- a/build.rs
4+
+++ b/build.rs
5+
@@ -25,7 +25,8 @@ fn check_func(function_name: &str) -> bool {
6+
writeln!(&mut test_file, "}}").unwrap();
7+
}
8+
9+
- let output = Command::new("rustc").
10+
+ let rustc = env::var("RUSTC").unwrap();
11+
+ let output = Command::new(rustc).
12+
arg(&test_file_name).
13+
arg("--out-dir").arg(&out_dir).
14+
arg("-l").arg("udev").

0 commit comments

Comments
 (0)