Loading rust/protobuf.go +50 −27 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package rust import ( "fmt" "strconv" "strings" "android/soong/android" Loading Loading @@ -122,9 +123,10 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) // stemFile must be first here as the first path in BaseSourceProvider.OutputFiles is the library entry-point. var outputs android.WritablePaths for i, shard := range android.ShardPaths(protoFiles, 50) { rule := android.NewRuleBuilder(pctx, ctx) for _, protoFile := range protoFiles { for _, protoFile := range shard { // Since we're iterating over the protoFiles already, make sure they're not redeclared in grpcFiles if android.InList(protoFile.String(), grpcFiles.Strings()) { ctx.PropertyErrorf("protos", Loading @@ -144,7 +146,20 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) outputs = append(outputs, ruleOutputs...) } for _, grpcFile := range grpcFiles { ruleName := "protoc" ruleDesc := "protoc" if i > 0 { ruleName += "_" + strconv.Itoa(i+1) ruleDesc += " " + strconv.Itoa(i+1) } rule.Build(ruleName, ruleDesc) } for i, shard := range android.ShardPaths(grpcFiles, 50) { rule := android.NewRuleBuilder(pctx, ctx) for _, grpcFile := range shard { grpcName := strings.TrimSuffix(grpcFile.Base(), ".proto") proto.grpcNames = append(proto.grpcNames, grpcName) Loading @@ -159,6 +174,16 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) outputs = append(outputs, ruleOutputs...) } ruleName := "protoc_grpc" ruleDesc := "protoc grpc" if i > 0 { ruleName += "_" + strconv.Itoa(i+1) ruleDesc += " " + strconv.Itoa(i+1) } rule.Build(ruleName, ruleDesc) } // Check that all proto base filenames are unique as outputs are written to the same directory. baseFilenames := append(proto.protoNames, proto.grpcNames...) if len(baseFilenames) != len(android.FirstUniqueStrings(baseFilenames)) { Loading @@ -168,8 +193,6 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) android.WriteFileRule(ctx, stemFile, proto.genModFileContents()) rule.Build("protoc_"+ctx.ModuleName(), "protoc "+ctx.ModuleName()) // 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()...) Loading Loading
rust/protobuf.go +50 −27 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package rust import ( "fmt" "strconv" "strings" "android/soong/android" Loading Loading @@ -122,9 +123,10 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) // stemFile must be first here as the first path in BaseSourceProvider.OutputFiles is the library entry-point. var outputs android.WritablePaths for i, shard := range android.ShardPaths(protoFiles, 50) { rule := android.NewRuleBuilder(pctx, ctx) for _, protoFile := range protoFiles { for _, protoFile := range shard { // Since we're iterating over the protoFiles already, make sure they're not redeclared in grpcFiles if android.InList(protoFile.String(), grpcFiles.Strings()) { ctx.PropertyErrorf("protos", Loading @@ -144,7 +146,20 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) outputs = append(outputs, ruleOutputs...) } for _, grpcFile := range grpcFiles { ruleName := "protoc" ruleDesc := "protoc" if i > 0 { ruleName += "_" + strconv.Itoa(i+1) ruleDesc += " " + strconv.Itoa(i+1) } rule.Build(ruleName, ruleDesc) } for i, shard := range android.ShardPaths(grpcFiles, 50) { rule := android.NewRuleBuilder(pctx, ctx) for _, grpcFile := range shard { grpcName := strings.TrimSuffix(grpcFile.Base(), ".proto") proto.grpcNames = append(proto.grpcNames, grpcName) Loading @@ -159,6 +174,16 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) outputs = append(outputs, ruleOutputs...) } ruleName := "protoc_grpc" ruleDesc := "protoc grpc" if i > 0 { ruleName += "_" + strconv.Itoa(i+1) ruleDesc += " " + strconv.Itoa(i+1) } rule.Build(ruleName, ruleDesc) } // Check that all proto base filenames are unique as outputs are written to the same directory. baseFilenames := append(proto.protoNames, proto.grpcNames...) if len(baseFilenames) != len(android.FirstUniqueStrings(baseFilenames)) { Loading @@ -168,8 +193,6 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) android.WriteFileRule(ctx, stemFile, proto.genModFileContents()) rule.Build("protoc_"+ctx.ModuleName(), "protoc "+ctx.ModuleName()) // 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()...) Loading