summaryrefslogtreecommitdiff
path: root/rust/binary.go
diff options
context:
space:
mode:
author Sam Delmerico <delmerico@google.com> 2023-09-27 08:10:26 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-09-27 08:10:26 +0000
commitec59517f6ac8bd8a6553292da6ff697d77aa2322 (patch)
tree84da88e98fc6237db62a7585e35e59c3e75c98f6 /rust/binary.go
parentc5b9abba309e4bb65e6ae69c60b44d0f4b59e278 (diff)
parentd46f6c81de667835939041eb52758bfb6645a936 (diff)
Merge changes from topic "reland-rust-sbox-1" into main
* changes: Revert^2 "conditionally escape rule builder command" Revert^4 "allow Ninja variables in RuleBuilder API" Revert^4 "add crate_root property to rust modules" Revert^4 "add rust_toolchain_rustc_prebuilt module type"
Diffstat (limited to 'rust/binary.go')
-rw-r--r--rust/binary.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/rust/binary.go b/rust/binary.go
index 1408ff17b..aee4da699 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -138,9 +138,14 @@ func (binary *binaryDecorator) preferRlib() bool {
func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) buildOutput {
fileName := binary.getStem(ctx) + ctx.toolchain().ExecutableSuffix()
- srcPath, _ := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs)
outputFile := android.PathForModuleOut(ctx, fileName)
ret := buildOutput{outputFile: outputFile}
+ var crateRootPath android.Path
+ if binary.baseCompiler.Properties.Crate_root == nil {
+ crateRootPath, _ = srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs)
+ } else {
+ crateRootPath = android.PathForModuleSrc(ctx, *binary.baseCompiler.Properties.Crate_root)
+ }
flags.RustFlags = append(flags.RustFlags, deps.depFlags...)
flags.LinkFlags = append(flags.LinkFlags, deps.depLinkFlags...)
@@ -155,7 +160,7 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path
}
binary.baseCompiler.unstrippedOutputFile = outputFile
- ret.kytheFile = TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile).kytheFile
+ ret.kytheFile = TransformSrcToBinary(ctx, crateRootPath, deps, flags, outputFile).kytheFile
return ret
}