Loading rust/builder.go +1 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,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.srcProviderFiles...) if deps.CrtBegin.Valid() { implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) Loading rust/library.go +1 −0 Original line number Diff line number Diff line Loading @@ -433,6 +433,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa if library.sourceProvider != nil { // Assume the first source from the source provider is the library entry point. srcPath = library.sourceProvider.Srcs()[0] deps.srcProviderFiles = append(deps.srcProviderFiles, library.sourceProvider.Srcs()...) } else { srcPath, _ = srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs) } Loading rust/protobuf.go +10 −8 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ func init() { var _ SourceProvider = (*protobufDecorator)(nil) type ProtobufProperties struct { // List of realtive paths to proto files that will be used to generate the source // List of relative paths to proto files that will be used to generate the source Protos []string `android:"path,arch_variant"` // List of additional flags to pass to aprotoc Loading Loading @@ -80,6 +80,10 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) protoFiles := android.PathsForModuleSrc(ctx, proto.Properties.Protos) if len(protoFiles) == 0 { ctx.PropertyErrorf("protos", "at least one protobuf must be defined.") } // Add exported dependency include paths for _, include := range deps.depIncludePaths { protoFlags.Flags = append(protoFlags.Flags, "-I"+include.String()) Loading @@ -91,7 +95,7 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) stemFile := android.PathForModuleOut(ctx, "mod_"+stem+".rs") // stemFile must be first here as the first path in BaseSourceProvider.OutputFiles is the library entry-point. outputs := android.WritablePaths{stemFile} var outputs android.WritablePaths rule := android.NewRuleBuilder(pctx, ctx) for _, protoFile := range protoFiles { Loading @@ -112,14 +116,12 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) outputs = append(outputs, ruleOutputs...) } rule.Command(). Implicits(outputs.Paths()). Text("printf '" + proto.genModFileContents(ctx, protoNames) + "' >"). Output(stemFile) android.WriteFileRule(ctx, stemFile, proto.genModFileContents(ctx, protoNames)) rule.Build("protoc_"+ctx.ModuleName(), "protoc "+ctx.ModuleName()) proto.BaseSourceProvider.OutputFiles = outputs.Paths() // stemFile must be first here as the first path in BaseSourceProvider.OutputFiles is the library entry-point. proto.BaseSourceProvider.OutputFiles = append(android.Paths{stemFile}, outputs.Paths()...) // mod_stem.rs is the entry-point for our library modules, so this is what we return. return stemFile Loading @@ -145,7 +147,7 @@ func (proto *protobufDecorator) genModFileContents(ctx ModuleContext, protoNames "}") } return strings.Join(lines, "\\n") return strings.Join(lines, "\n") } func (proto *protobufDecorator) setupPlugin(ctx ModuleContext, protoFlags android.ProtoFlags, outDir android.ModuleOutPath) (android.Paths, android.ProtoFlags) { Loading rust/rust.go +2 −1 Original line number Diff line number Diff line Loading @@ -246,6 +246,7 @@ type PathDeps struct { // Paths to generated source files SrcDeps android.Paths srcProviderFiles android.Paths } type RustLibraries []RustLibrary Loading Loading
rust/builder.go +1 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,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.srcProviderFiles...) if deps.CrtBegin.Valid() { implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) Loading
rust/library.go +1 −0 Original line number Diff line number Diff line Loading @@ -433,6 +433,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa if library.sourceProvider != nil { // Assume the first source from the source provider is the library entry point. srcPath = library.sourceProvider.Srcs()[0] deps.srcProviderFiles = append(deps.srcProviderFiles, library.sourceProvider.Srcs()...) } else { srcPath, _ = srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs) } Loading
rust/protobuf.go +10 −8 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ func init() { var _ SourceProvider = (*protobufDecorator)(nil) type ProtobufProperties struct { // List of realtive paths to proto files that will be used to generate the source // List of relative paths to proto files that will be used to generate the source Protos []string `android:"path,arch_variant"` // List of additional flags to pass to aprotoc Loading Loading @@ -80,6 +80,10 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) protoFiles := android.PathsForModuleSrc(ctx, proto.Properties.Protos) if len(protoFiles) == 0 { ctx.PropertyErrorf("protos", "at least one protobuf must be defined.") } // Add exported dependency include paths for _, include := range deps.depIncludePaths { protoFlags.Flags = append(protoFlags.Flags, "-I"+include.String()) Loading @@ -91,7 +95,7 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) stemFile := android.PathForModuleOut(ctx, "mod_"+stem+".rs") // stemFile must be first here as the first path in BaseSourceProvider.OutputFiles is the library entry-point. outputs := android.WritablePaths{stemFile} var outputs android.WritablePaths rule := android.NewRuleBuilder(pctx, ctx) for _, protoFile := range protoFiles { Loading @@ -112,14 +116,12 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) outputs = append(outputs, ruleOutputs...) } rule.Command(). Implicits(outputs.Paths()). Text("printf '" + proto.genModFileContents(ctx, protoNames) + "' >"). Output(stemFile) android.WriteFileRule(ctx, stemFile, proto.genModFileContents(ctx, protoNames)) rule.Build("protoc_"+ctx.ModuleName(), "protoc "+ctx.ModuleName()) proto.BaseSourceProvider.OutputFiles = outputs.Paths() // stemFile must be first here as the first path in BaseSourceProvider.OutputFiles is the library entry-point. proto.BaseSourceProvider.OutputFiles = append(android.Paths{stemFile}, outputs.Paths()...) // mod_stem.rs is the entry-point for our library modules, so this is what we return. return stemFile Loading @@ -145,7 +147,7 @@ func (proto *protobufDecorator) genModFileContents(ctx ModuleContext, protoNames "}") } return strings.Join(lines, "\\n") return strings.Join(lines, "\n") } func (proto *protobufDecorator) setupPlugin(ctx ModuleContext, protoFlags android.ProtoFlags, outDir android.ModuleOutPath) (android.Paths, android.ProtoFlags) { Loading
rust/rust.go +2 −1 Original line number Diff line number Diff line Loading @@ -246,6 +246,7 @@ type PathDeps struct { // Paths to generated source files SrcDeps android.Paths srcProviderFiles android.Paths } type RustLibraries []RustLibrary Loading