Loading android/filegroup.go +20 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,9 @@ package android import ( "io" "strings" "text/template" ) func init() { Loading Loading @@ -69,8 +71,23 @@ func (fg *fileGroup) Srcs() Paths { return append(Paths{}, fg.srcs...) } func (fg *fileGroup) MakeVars(ctx MakeVarsModuleContext) { var androidMkTemplate = template.Must(template.New("filegroup").Parse(` ifdef {{.makeVar}} $(error variable {{.makeVar}} set by soong module is already set in make) endif {{.makeVar}} := {{.value}} .KATI_READONLY := {{.makeVar}} `)) func (fg *fileGroup) AndroidMk() AndroidMkData { return AndroidMkData{ Custom: func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData) { if makeVar := String(fg.properties.Export_to_make_var); makeVar != "" { ctx.StrictRaw(makeVar, strings.Join(fg.srcs.Strings(), " ")) androidMkTemplate.Execute(w, map[string]string{ "makeVar": makeVar, "value": strings.Join(fg.srcs.Strings(), " "), }) } }, } } android/makevars.go +31 −90 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android import ( "bytes" "fmt" "sort" "strconv" "strings" Loading @@ -35,16 +34,43 @@ func androidMakeVarsProvider(ctx MakeVarsContext) { } /////////////////////////////////////////////////////////////////////////////// // BaseMakeVarsContext contains the common functions for other packages to use // to declare make variables type BaseMakeVarsContext interface { // Interface for other packages to use to declare make variables type MakeVarsContext interface { Config() Config DeviceConfig() DeviceConfig AddNinjaFileDeps(deps ...string) ModuleName(module blueprint.Module) string ModuleDir(module blueprint.Module) string ModuleSubDir(module blueprint.Module) string ModuleType(module blueprint.Module) string BlueprintFile(module blueprint.Module) string ModuleErrorf(module blueprint.Module, format string, args ...interface{}) Errorf(format string, args ...interface{}) Failed() bool VisitAllModules(visit func(Module)) VisitAllModulesIf(pred func(Module) bool, visit func(Module)) // Verify the make variable matches the Soong version, fail the build // if it does not. If the make variable is empty, just set it. Strict(name, ninjaStr string) // Check to see if the make variable matches the Soong version, warn if // it does not. If the make variable is empty, just set it. Check(name, ninjaStr string) // These are equivalent to the above, but sort the make and soong // variables before comparing them. They also show the unique entries // in each list when displaying the difference, instead of the entire // string. StrictSorted(name, ninjaStr string) CheckSorted(name, ninjaStr string) // Evaluates a ninja string and returns the result. Used if more // complicated modification needs to happen before giving it to Make. Eval(ninjaStr string) (string, error) // These are equivalent to Strict and Check, but do not attempt to // evaluate the values before writing them to the Makefile. They can // be used when all ninja variables have already been evaluated through Loading Loading @@ -82,48 +108,6 @@ type BaseMakeVarsContext interface { DistForGoalsWithFilename(goals []string, path Path, filename string) } // MakeVarsContext contains the set of functions available for MakeVarsProvider // and SingletonMakeVarsProvider implementations. type MakeVarsContext interface { BaseMakeVarsContext ModuleName(module blueprint.Module) string ModuleDir(module blueprint.Module) string ModuleSubDir(module blueprint.Module) string ModuleType(module blueprint.Module) string BlueprintFile(module blueprint.Module) string ModuleErrorf(module blueprint.Module, format string, args ...interface{}) Errorf(format string, args ...interface{}) VisitAllModules(visit func(Module)) VisitAllModulesIf(pred func(Module) bool, visit func(Module)) // Verify the make variable matches the Soong version, fail the build // if it does not. If the make variable is empty, just set it. Strict(name, ninjaStr string) // Check to see if the make variable matches the Soong version, warn if // it does not. If the make variable is empty, just set it. Check(name, ninjaStr string) // These are equivalent to the above, but sort the make and soong // variables before comparing them. They also show the unique entries // in each list when displaying the difference, instead of the entire // string. StrictSorted(name, ninjaStr string) CheckSorted(name, ninjaStr string) // Evaluates a ninja string and returns the result. Used if more // complicated modification needs to happen before giving it to Make. Eval(ninjaStr string) (string, error) } // MakeVarsModuleContext contains the set of functions available for modules // implementing the ModuleMakeVarsProvider interface. type MakeVarsModuleContext interface { BaseMakeVarsContext } var _ PathContext = MakeVarsContext(nil) type MakeVarsProvider func(ctx MakeVarsContext) Loading Loading @@ -151,14 +135,6 @@ func SingletonmakeVarsProviderAdapter(singleton SingletonMakeVarsProvider) MakeV return func(ctx MakeVarsContext) { singleton.MakeVars(ctx) } } // ModuleMakeVarsProvider is a Module with an extra method to provide extra values to be exported to Make. type ModuleMakeVarsProvider interface { Module // MakeVars uses a MakeVarsModuleContext to provide extra values to be exported to Make. MakeVars(ctx MakeVarsModuleContext) } /////////////////////////////////////////////////////////////////////////////// func makeVarsSingletonFunc() Singleton { Loading Loading @@ -233,45 +209,10 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) { dists = append(dists, mctx.dists...) } ctx.VisitAllModules(func(m Module) { if provider, ok := m.(ModuleMakeVarsProvider); ok { mctx := &makeVarsContext{ SingletonContext: ctx, } provider.MakeVars(mctx) vars = append(vars, mctx.vars...) phonies = append(phonies, mctx.phonies...) dists = append(dists, mctx.dists...) } }) if ctx.Failed() { return } sort.Slice(vars, func(i, j int) bool { return vars[i].name < vars[j].name }) sort.Slice(phonies, func(i, j int) bool { return phonies[i].name < phonies[j].name }) lessArr := func(a, b []string) bool { if len(a) == len(b) { for i := range a { if a[i] < b[i] { return true } } return false } return len(a) < len(b) } sort.Slice(dists, func(i, j int) bool { return lessArr(dists[i].goals, dists[j].goals) || lessArr(dists[i].paths, dists[j].paths) }) outBytes := s.writeVars(vars) if err := pathtools.WriteFileIfChanged(outFile, outBytes, 0666); err != nil { Loading android/prebuilt_build_tool.go +0 −10 Original line number Diff line number Diff line Loading @@ -29,10 +29,6 @@ type prebuiltBuildToolProperties struct { // Extra files that should trigger rules using this tool to rebuild Deps []string `android:"path,arch_variant"` // Create a make variable with the specified name that contains the path to // this prebuilt built tool, relative to the root of the source tree. Export_to_make_var *string } type prebuiltBuildTool struct { Loading Loading @@ -85,12 +81,6 @@ func (t *prebuiltBuildTool) HostToolPath() OptionalPath { return t.toolPath } func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) { if makeVar := String(t.properties.Export_to_make_var); makeVar != "" { ctx.StrictRaw(makeVar, t.toolPath.String()) } } var _ HostToolProvider = &prebuiltBuildTool{} // prebuilt_build_tool is to declare prebuilts to be used during the build, particularly for use Loading cc/gen.go +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import ( ) func init() { pctx.SourcePathVariable("m4Cmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/m4") pctx.HostBinToolVariable("aidlCmd", "aidl-cpp") pctx.HostBinToolVariable("syspropCmd", "sysprop_cpp") } Loading cc/makevars.go +2 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,8 @@ func makeVarsProvider(ctx android.MakeVarsContext) { ctx.Strict("AIDL_CPP", "${aidlCmd}") ctx.Strict("ALLOWED_MANUAL_INTERFACE_PATHS", strings.Join(allowedManualInterfacePaths, " ")) ctx.Strict("M4", "${m4Cmd}") ctx.Strict("RS_GLOBAL_INCLUDES", "${config.RsGlobalIncludes}") ctx.Strict("SOONG_STRIP_PATH", "${stripPath}") Loading Loading
android/filegroup.go +20 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,9 @@ package android import ( "io" "strings" "text/template" ) func init() { Loading Loading @@ -69,8 +71,23 @@ func (fg *fileGroup) Srcs() Paths { return append(Paths{}, fg.srcs...) } func (fg *fileGroup) MakeVars(ctx MakeVarsModuleContext) { var androidMkTemplate = template.Must(template.New("filegroup").Parse(` ifdef {{.makeVar}} $(error variable {{.makeVar}} set by soong module is already set in make) endif {{.makeVar}} := {{.value}} .KATI_READONLY := {{.makeVar}} `)) func (fg *fileGroup) AndroidMk() AndroidMkData { return AndroidMkData{ Custom: func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData) { if makeVar := String(fg.properties.Export_to_make_var); makeVar != "" { ctx.StrictRaw(makeVar, strings.Join(fg.srcs.Strings(), " ")) androidMkTemplate.Execute(w, map[string]string{ "makeVar": makeVar, "value": strings.Join(fg.srcs.Strings(), " "), }) } }, } }
android/makevars.go +31 −90 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android import ( "bytes" "fmt" "sort" "strconv" "strings" Loading @@ -35,16 +34,43 @@ func androidMakeVarsProvider(ctx MakeVarsContext) { } /////////////////////////////////////////////////////////////////////////////// // BaseMakeVarsContext contains the common functions for other packages to use // to declare make variables type BaseMakeVarsContext interface { // Interface for other packages to use to declare make variables type MakeVarsContext interface { Config() Config DeviceConfig() DeviceConfig AddNinjaFileDeps(deps ...string) ModuleName(module blueprint.Module) string ModuleDir(module blueprint.Module) string ModuleSubDir(module blueprint.Module) string ModuleType(module blueprint.Module) string BlueprintFile(module blueprint.Module) string ModuleErrorf(module blueprint.Module, format string, args ...interface{}) Errorf(format string, args ...interface{}) Failed() bool VisitAllModules(visit func(Module)) VisitAllModulesIf(pred func(Module) bool, visit func(Module)) // Verify the make variable matches the Soong version, fail the build // if it does not. If the make variable is empty, just set it. Strict(name, ninjaStr string) // Check to see if the make variable matches the Soong version, warn if // it does not. If the make variable is empty, just set it. Check(name, ninjaStr string) // These are equivalent to the above, but sort the make and soong // variables before comparing them. They also show the unique entries // in each list when displaying the difference, instead of the entire // string. StrictSorted(name, ninjaStr string) CheckSorted(name, ninjaStr string) // Evaluates a ninja string and returns the result. Used if more // complicated modification needs to happen before giving it to Make. Eval(ninjaStr string) (string, error) // These are equivalent to Strict and Check, but do not attempt to // evaluate the values before writing them to the Makefile. They can // be used when all ninja variables have already been evaluated through Loading Loading @@ -82,48 +108,6 @@ type BaseMakeVarsContext interface { DistForGoalsWithFilename(goals []string, path Path, filename string) } // MakeVarsContext contains the set of functions available for MakeVarsProvider // and SingletonMakeVarsProvider implementations. type MakeVarsContext interface { BaseMakeVarsContext ModuleName(module blueprint.Module) string ModuleDir(module blueprint.Module) string ModuleSubDir(module blueprint.Module) string ModuleType(module blueprint.Module) string BlueprintFile(module blueprint.Module) string ModuleErrorf(module blueprint.Module, format string, args ...interface{}) Errorf(format string, args ...interface{}) VisitAllModules(visit func(Module)) VisitAllModulesIf(pred func(Module) bool, visit func(Module)) // Verify the make variable matches the Soong version, fail the build // if it does not. If the make variable is empty, just set it. Strict(name, ninjaStr string) // Check to see if the make variable matches the Soong version, warn if // it does not. If the make variable is empty, just set it. Check(name, ninjaStr string) // These are equivalent to the above, but sort the make and soong // variables before comparing them. They also show the unique entries // in each list when displaying the difference, instead of the entire // string. StrictSorted(name, ninjaStr string) CheckSorted(name, ninjaStr string) // Evaluates a ninja string and returns the result. Used if more // complicated modification needs to happen before giving it to Make. Eval(ninjaStr string) (string, error) } // MakeVarsModuleContext contains the set of functions available for modules // implementing the ModuleMakeVarsProvider interface. type MakeVarsModuleContext interface { BaseMakeVarsContext } var _ PathContext = MakeVarsContext(nil) type MakeVarsProvider func(ctx MakeVarsContext) Loading Loading @@ -151,14 +135,6 @@ func SingletonmakeVarsProviderAdapter(singleton SingletonMakeVarsProvider) MakeV return func(ctx MakeVarsContext) { singleton.MakeVars(ctx) } } // ModuleMakeVarsProvider is a Module with an extra method to provide extra values to be exported to Make. type ModuleMakeVarsProvider interface { Module // MakeVars uses a MakeVarsModuleContext to provide extra values to be exported to Make. MakeVars(ctx MakeVarsModuleContext) } /////////////////////////////////////////////////////////////////////////////// func makeVarsSingletonFunc() Singleton { Loading Loading @@ -233,45 +209,10 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) { dists = append(dists, mctx.dists...) } ctx.VisitAllModules(func(m Module) { if provider, ok := m.(ModuleMakeVarsProvider); ok { mctx := &makeVarsContext{ SingletonContext: ctx, } provider.MakeVars(mctx) vars = append(vars, mctx.vars...) phonies = append(phonies, mctx.phonies...) dists = append(dists, mctx.dists...) } }) if ctx.Failed() { return } sort.Slice(vars, func(i, j int) bool { return vars[i].name < vars[j].name }) sort.Slice(phonies, func(i, j int) bool { return phonies[i].name < phonies[j].name }) lessArr := func(a, b []string) bool { if len(a) == len(b) { for i := range a { if a[i] < b[i] { return true } } return false } return len(a) < len(b) } sort.Slice(dists, func(i, j int) bool { return lessArr(dists[i].goals, dists[j].goals) || lessArr(dists[i].paths, dists[j].paths) }) outBytes := s.writeVars(vars) if err := pathtools.WriteFileIfChanged(outFile, outBytes, 0666); err != nil { Loading
android/prebuilt_build_tool.go +0 −10 Original line number Diff line number Diff line Loading @@ -29,10 +29,6 @@ type prebuiltBuildToolProperties struct { // Extra files that should trigger rules using this tool to rebuild Deps []string `android:"path,arch_variant"` // Create a make variable with the specified name that contains the path to // this prebuilt built tool, relative to the root of the source tree. Export_to_make_var *string } type prebuiltBuildTool struct { Loading Loading @@ -85,12 +81,6 @@ func (t *prebuiltBuildTool) HostToolPath() OptionalPath { return t.toolPath } func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) { if makeVar := String(t.properties.Export_to_make_var); makeVar != "" { ctx.StrictRaw(makeVar, t.toolPath.String()) } } var _ HostToolProvider = &prebuiltBuildTool{} // prebuilt_build_tool is to declare prebuilts to be used during the build, particularly for use Loading
cc/gen.go +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import ( ) func init() { pctx.SourcePathVariable("m4Cmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/m4") pctx.HostBinToolVariable("aidlCmd", "aidl-cpp") pctx.HostBinToolVariable("syspropCmd", "sysprop_cpp") } Loading
cc/makevars.go +2 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,8 @@ func makeVarsProvider(ctx android.MakeVarsContext) { ctx.Strict("AIDL_CPP", "${aidlCmd}") ctx.Strict("ALLOWED_MANUAL_INTERFACE_PATHS", strings.Join(allowedManualInterfacePaths, " ")) ctx.Strict("M4", "${m4Cmd}") ctx.Strict("RS_GLOBAL_INCLUDES", "${config.RsGlobalIncludes}") ctx.Strict("SOONG_STRIP_PATH", "${stripPath}") Loading