add crate_root property to rust modules

The crate_root property will be used to specify the entry point for a
rustc compilation. This will allow the srcs property to be used to
collect all src inputs to rustc rather than just the entry point.

Bug: 286077158
Test: m libnum_traits
Change-Id: I1a167182305dcc11cc927d562ceed622153111d3
This commit is contained in:
Sam Delmerico
2023-07-13 11:15:37 -04:00
parent b45c844ce7
commit 553edff9dd
4 changed files with 41 additions and 16 deletions

View File

@@ -137,9 +137,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...)
@@ -154,7 +159,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
}