Loading android/module.go +4 −0 Original line number Diff line number Diff line Loading @@ -1425,6 +1425,10 @@ type SourceFileProducer interface { Srcs() Paths } type HostToolProvider interface { HostToolPath() OptionalPath } // Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must // be tagged with `android:"path" to support automatic source module dependency resolution. // Loading android/proto.go +48 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android import ( "strings" "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) Loading @@ -35,21 +36,61 @@ type ProtoFlags struct { SubDir ModuleGenPath OutTypeFlag string OutParams []string Deps Paths } type protoDependencyTag struct { blueprint.BaseDependencyTag name string } var ProtoPluginDepTag = protoDependencyTag{name: "plugin"} func ProtoDeps(ctx BottomUpMutatorContext, p *ProtoProperties) { if String(p.Proto.Plugin) != "" && String(p.Proto.Type) != "" { ctx.ModuleErrorf("only one of proto.type and proto.plugin can be specified.") } if plugin := String(p.Proto.Plugin); plugin != "" { ctx.AddFarVariationDependencies([]blueprint.Variation{ {Mutator: "arch", Variation: ctx.Config().BuildOsVariant}, }, ProtoPluginDepTag, "protoc-gen-"+plugin) } } func GetProtoFlags(ctx ModuleContext, p *ProtoProperties) ProtoFlags { var protoFlags []string var flags []string var deps Paths if len(p.Proto.Local_include_dirs) > 0 { localProtoIncludeDirs := PathsForModuleSrc(ctx, p.Proto.Local_include_dirs) protoFlags = append(protoFlags, JoinWithPrefix(localProtoIncludeDirs.Strings(), "-I")) flags = append(flags, JoinWithPrefix(localProtoIncludeDirs.Strings(), "-I")) } if len(p.Proto.Include_dirs) > 0 { rootProtoIncludeDirs := PathsForSource(ctx, p.Proto.Include_dirs) protoFlags = append(protoFlags, JoinWithPrefix(rootProtoIncludeDirs.Strings(), "-I")) flags = append(flags, JoinWithPrefix(rootProtoIncludeDirs.Strings(), "-I")) } ctx.VisitDirectDepsWithTag(ProtoPluginDepTag, func(dep Module) { if hostTool, ok := dep.(HostToolProvider); !ok || !hostTool.HostToolPath().Valid() { ctx.PropertyErrorf("proto.plugin", "module %q is not a host tool provider", ctx.OtherModuleName(dep)) } else { plugin := String(p.Proto.Plugin) deps = append(deps, hostTool.HostToolPath().Path()) flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+hostTool.HostToolPath().String()) } }) var protoOutFlag string if plugin := String(p.Proto.Plugin); plugin != "" { protoOutFlag = "--" + plugin + "_out" } return ProtoFlags{ Flags: protoFlags, Flags: flags, Deps: deps, OutTypeFlag: protoOutFlag, CanonicalPathFromRoot: proptools.BoolDefault(p.Proto.Canonical_path_from_root, true), Dir: PathForModuleGen(ctx, "proto"), SubDir: PathForModuleGen(ctx, "proto", ctx.ModuleDir()), Loading @@ -61,6 +102,9 @@ type ProtoProperties struct { // Proto generator type. C++: full or lite. Java: micro, nano, stream, or lite. Type *string `android:"arch_variant"` // Proto plugin to use as the generator. Must be a cc_binary_host module. Plugin *string `android:"arch_variant"` // list of directories that will be added to the protoc include paths. Include_dirs []string Loading cc/builder.go +0 −1 Original line number Diff line number Diff line Loading @@ -260,7 +260,6 @@ type builderFlags struct { stripAddGnuDebuglink bool stripUseGnuStrip bool protoDeps android.Paths proto android.ProtoFlags protoC bool protoOptionsFile bool Loading cc/cc.go +4 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,6 @@ type Flags struct { GroupStaticLibs bool proto android.ProtoFlags protoDeps android.Paths protoC bool // Whether to use C instead of C++ protoOptionsFile bool // Whether to look for a .options file next to the .proto } Loading Loading @@ -1594,6 +1593,10 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { return } if depTag == android.ProtoPluginDepTag { return } if dep.Target().Os != ctx.Os() { ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName) return Loading cc/cc_test.go +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ func TestMain(m *testing.M) { func createTestContext(t *testing.T, config android.Config, bp string, os android.OsType) *android.TestContext { ctx := android.NewTestArchContext() ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory)) ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory)) ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory)) ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory)) ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory)) Loading Loading
android/module.go +4 −0 Original line number Diff line number Diff line Loading @@ -1425,6 +1425,10 @@ type SourceFileProducer interface { Srcs() Paths } type HostToolProvider interface { HostToolPath() OptionalPath } // Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must // be tagged with `android:"path" to support automatic source module dependency resolution. // Loading
android/proto.go +48 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android import ( "strings" "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) Loading @@ -35,21 +36,61 @@ type ProtoFlags struct { SubDir ModuleGenPath OutTypeFlag string OutParams []string Deps Paths } type protoDependencyTag struct { blueprint.BaseDependencyTag name string } var ProtoPluginDepTag = protoDependencyTag{name: "plugin"} func ProtoDeps(ctx BottomUpMutatorContext, p *ProtoProperties) { if String(p.Proto.Plugin) != "" && String(p.Proto.Type) != "" { ctx.ModuleErrorf("only one of proto.type and proto.plugin can be specified.") } if plugin := String(p.Proto.Plugin); plugin != "" { ctx.AddFarVariationDependencies([]blueprint.Variation{ {Mutator: "arch", Variation: ctx.Config().BuildOsVariant}, }, ProtoPluginDepTag, "protoc-gen-"+plugin) } } func GetProtoFlags(ctx ModuleContext, p *ProtoProperties) ProtoFlags { var protoFlags []string var flags []string var deps Paths if len(p.Proto.Local_include_dirs) > 0 { localProtoIncludeDirs := PathsForModuleSrc(ctx, p.Proto.Local_include_dirs) protoFlags = append(protoFlags, JoinWithPrefix(localProtoIncludeDirs.Strings(), "-I")) flags = append(flags, JoinWithPrefix(localProtoIncludeDirs.Strings(), "-I")) } if len(p.Proto.Include_dirs) > 0 { rootProtoIncludeDirs := PathsForSource(ctx, p.Proto.Include_dirs) protoFlags = append(protoFlags, JoinWithPrefix(rootProtoIncludeDirs.Strings(), "-I")) flags = append(flags, JoinWithPrefix(rootProtoIncludeDirs.Strings(), "-I")) } ctx.VisitDirectDepsWithTag(ProtoPluginDepTag, func(dep Module) { if hostTool, ok := dep.(HostToolProvider); !ok || !hostTool.HostToolPath().Valid() { ctx.PropertyErrorf("proto.plugin", "module %q is not a host tool provider", ctx.OtherModuleName(dep)) } else { plugin := String(p.Proto.Plugin) deps = append(deps, hostTool.HostToolPath().Path()) flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+hostTool.HostToolPath().String()) } }) var protoOutFlag string if plugin := String(p.Proto.Plugin); plugin != "" { protoOutFlag = "--" + plugin + "_out" } return ProtoFlags{ Flags: protoFlags, Flags: flags, Deps: deps, OutTypeFlag: protoOutFlag, CanonicalPathFromRoot: proptools.BoolDefault(p.Proto.Canonical_path_from_root, true), Dir: PathForModuleGen(ctx, "proto"), SubDir: PathForModuleGen(ctx, "proto", ctx.ModuleDir()), Loading @@ -61,6 +102,9 @@ type ProtoProperties struct { // Proto generator type. C++: full or lite. Java: micro, nano, stream, or lite. Type *string `android:"arch_variant"` // Proto plugin to use as the generator. Must be a cc_binary_host module. Plugin *string `android:"arch_variant"` // list of directories that will be added to the protoc include paths. Include_dirs []string Loading
cc/builder.go +0 −1 Original line number Diff line number Diff line Loading @@ -260,7 +260,6 @@ type builderFlags struct { stripAddGnuDebuglink bool stripUseGnuStrip bool protoDeps android.Paths proto android.ProtoFlags protoC bool protoOptionsFile bool Loading
cc/cc.go +4 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,6 @@ type Flags struct { GroupStaticLibs bool proto android.ProtoFlags protoDeps android.Paths protoC bool // Whether to use C instead of C++ protoOptionsFile bool // Whether to look for a .options file next to the .proto } Loading Loading @@ -1594,6 +1593,10 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { return } if depTag == android.ProtoPluginDepTag { return } if dep.Target().Os != ctx.Os() { ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName) return Loading
cc/cc_test.go +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ func TestMain(m *testing.M) { func createTestContext(t *testing.T, config android.Config, bp string, os android.OsType) *android.TestContext { ctx := android.NewTestArchContext() ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory)) ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory)) ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory)) ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory)) ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory)) Loading