Loading rust/binary.go +2 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,8 @@ func (binary *binaryDecorator) nativeCoverage() bool { func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path { fileName := binary.getStem(ctx) + ctx.toolchain().ExecutableSuffix() srcPath := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs) srcPath, paths := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs) deps.SrcDeps = paths outputFile := android.PathForModuleOut(ctx, fileName) binary.unstrippedOutputFile = outputFile Loading rust/builder.go +1 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl implicits = append(implicits, rustLibsToPaths(deps.ProcMacros)...) implicits = append(implicits, deps.StaticLibs...) implicits = append(implicits, deps.SharedLibs...) implicits = append(implicits, deps.SrcDeps...) if deps.CrtBegin.Valid() { implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) } Loading rust/compiler.go +19 −5 Original line number Diff line number Diff line Loading @@ -253,10 +253,24 @@ func (compiler *baseCompiler) relativeInstallPath() string { return String(compiler.Properties.Relative_install_path) } func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) android.Path { srcPaths := android.PathsForModuleSrc(ctx, srcs) if len(srcPaths) != 1 { ctx.PropertyErrorf("srcs", "srcs can only contain one path for rust modules") } return srcPaths[0] func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) (android.Path, android.Paths) { // The srcs can contain strings with prefix ":". // They are dependent modules of this module, with android.SourceDepTag. // They are not the main source file compiled by rustc. numSrcs := 0 srcIndex := 0 for i, s := range srcs { if android.SrcIsModule(s) == "" { numSrcs++ srcIndex = i } } if numSrcs != 1 { ctx.PropertyErrorf("srcs", "srcs can only contain one path for a rust file") } if srcIndex != 0 { ctx.PropertyErrorf("srcs", "main source file must be the first in srcs") } paths := android.PathsForModuleSrc(ctx, srcs) return paths[srcIndex], paths } rust/compiler_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ func TestFeaturesToFlags(t *testing.T) { // Test that we reject multiple source files. func TestEnforceSingleSourceFile(t *testing.T) { singleSrcError := "srcs can only contain one path for rust modules" singleSrcError := "srcs can only contain one path for a rust file" // Test libraries testRustError(t, singleSrcError, ` Loading rust/library.go +2 −1 Original line number Diff line number Diff line Loading @@ -368,7 +368,8 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) F func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path { var outputFile android.WritablePath srcPath := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs) srcPath, paths := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs) deps.SrcDeps = paths flags.RustFlags = append(flags.RustFlags, deps.depFlags...) Loading Loading
rust/binary.go +2 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,8 @@ func (binary *binaryDecorator) nativeCoverage() bool { func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path { fileName := binary.getStem(ctx) + ctx.toolchain().ExecutableSuffix() srcPath := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs) srcPath, paths := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs) deps.SrcDeps = paths outputFile := android.PathForModuleOut(ctx, fileName) binary.unstrippedOutputFile = outputFile Loading
rust/builder.go +1 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl implicits = append(implicits, rustLibsToPaths(deps.ProcMacros)...) implicits = append(implicits, deps.StaticLibs...) implicits = append(implicits, deps.SharedLibs...) implicits = append(implicits, deps.SrcDeps...) if deps.CrtBegin.Valid() { implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) } Loading
rust/compiler.go +19 −5 Original line number Diff line number Diff line Loading @@ -253,10 +253,24 @@ func (compiler *baseCompiler) relativeInstallPath() string { return String(compiler.Properties.Relative_install_path) } func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) android.Path { srcPaths := android.PathsForModuleSrc(ctx, srcs) if len(srcPaths) != 1 { ctx.PropertyErrorf("srcs", "srcs can only contain one path for rust modules") } return srcPaths[0] func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) (android.Path, android.Paths) { // The srcs can contain strings with prefix ":". // They are dependent modules of this module, with android.SourceDepTag. // They are not the main source file compiled by rustc. numSrcs := 0 srcIndex := 0 for i, s := range srcs { if android.SrcIsModule(s) == "" { numSrcs++ srcIndex = i } } if numSrcs != 1 { ctx.PropertyErrorf("srcs", "srcs can only contain one path for a rust file") } if srcIndex != 0 { ctx.PropertyErrorf("srcs", "main source file must be the first in srcs") } paths := android.PathsForModuleSrc(ctx, srcs) return paths[srcIndex], paths }
rust/compiler_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ func TestFeaturesToFlags(t *testing.T) { // Test that we reject multiple source files. func TestEnforceSingleSourceFile(t *testing.T) { singleSrcError := "srcs can only contain one path for rust modules" singleSrcError := "srcs can only contain one path for a rust file" // Test libraries testRustError(t, singleSrcError, ` Loading
rust/library.go +2 −1 Original line number Diff line number Diff line Loading @@ -368,7 +368,8 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) F func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path { var outputFile android.WritablePath srcPath := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs) srcPath, paths := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs) deps.SrcDeps = paths flags.RustFlags = append(flags.RustFlags, deps.depFlags...) Loading