Set OUT_DIR=out with no src_deps.
Some Rust crates with no src_deps have generated files checked in in an
"out" subdirectory and included via a reference to $OUT_DIR, such as
external/rust/crates/userfaultfd-sys.
Astonishingly, some people must be leaving $OUT_DIR set to the default
value of "out", because with $OUT_DIR set to this value, building these
crates would presumably succeed. For everyone else, the build fails
when building one of these crates because it will attempt to load from
the wrong directory. Presumably these crates should be using src_deps
instead (and once that's fixed, we should probably *unset* $OUT_DIR in
rustc invocations to prevent the same thing from happening again), but
for now, fix the build with non-default OUT_DIR by explicitly setting
OUT_DIR to "out" if there are no src_deps.
Change-Id: I09f99424fc01a1e42e910622c77ab8f7312819bd
diff --git a/rust/builder.go b/rust/builder.go
index 4b20e2b..180abf6 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -208,6 +208,9 @@
outDirPrefix = ""
}
envVars = append(envVars, "OUT_DIR="+filepath.Join(outDirPrefix, moduleGenDir.String()))
+ } else {
+ // TODO(pcc): Change this to "OUT_DIR=" after fixing crates to not rely on this value.
+ envVars = append(envVars, "OUT_DIR=out")
}
return envVars