diff options
-rw-r--r-- | android/csuite_config.go | 20 | ||||
-rw-r--r-- | python/androidmk.go | 68 | ||||
-rw-r--r-- | python/python.go | 2 | ||||
-rw-r--r-- | rust/androidmk.go | 78 | ||||
-rw-r--r-- | tradefed/Android.bp | 17 | ||||
-rw-r--r-- | tradefed/tradefed_binary.go | 164 |
6 files changed, 67 insertions, 282 deletions
diff --git a/android/csuite_config.go b/android/csuite_config.go index 15c518a07..a5b15331a 100644 --- a/android/csuite_config.go +++ b/android/csuite_config.go @@ -14,11 +14,6 @@ package android -import ( - "fmt" - "io" -) - func init() { RegisterModuleType("csuite_config", CSuiteConfigFactory) } @@ -38,22 +33,21 @@ func (me *CSuiteConfig) GenerateAndroidBuildActions(ctx ModuleContext) { me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath } -func (me *CSuiteConfig) AndroidMk() AndroidMkData { - androidMkData := AndroidMkData{ +func (me *CSuiteConfig) AndroidMkEntries() []AndroidMkEntries { + androidMkEntries := AndroidMkEntries{ Class: "FAKE", Include: "$(BUILD_SYSTEM)/suite_host_config.mk", OutputFile: OptionalPathForPath(me.OutputFilePath), } - androidMkData.Extra = []AndroidMkExtraFunc{ - func(w io.Writer, outputFile Path) { + androidMkEntries.ExtraEntries = []AndroidMkExtraEntriesFunc{ + func(entries *AndroidMkEntries) { if me.properties.Test_config != nil { - fmt.Fprintf(w, "LOCAL_TEST_CONFIG := %s\n", - *me.properties.Test_config) + entries.SetString("LOCAL_TEST_CONFIG", *me.properties.Test_config) } - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := csuite") + entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "csuite") }, } - return androidMkData + return []AndroidMkEntries{androidMkEntries} } func InitCSuiteConfigModule(me *CSuiteConfig) { diff --git a/python/androidmk.go b/python/androidmk.go index 247b80dc0..61cde019c 100644 --- a/python/androidmk.go +++ b/python/androidmk.go @@ -16,84 +16,74 @@ package python import ( "android/soong/android" - "fmt" - "io" "path/filepath" "strings" ) type subAndroidMkProvider interface { - AndroidMk(*Module, *android.AndroidMkData) + AndroidMk(*Module, *android.AndroidMkEntries) } -func (p *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) { +func (p *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) { if p.subAndroidMkOnce == nil { p.subAndroidMkOnce = make(map[subAndroidMkProvider]bool) } if androidmk, ok := obj.(subAndroidMkProvider); ok { if !p.subAndroidMkOnce[androidmk] { p.subAndroidMkOnce[androidmk] = true - androidmk.AndroidMk(p, data) + androidmk.AndroidMk(p, entries) } } } -func (p *Module) AndroidMk() android.AndroidMkData { - ret := android.AndroidMkData{OutputFile: p.installSource} +func (p *Module) AndroidMkEntries() []android.AndroidMkEntries { + entries := android.AndroidMkEntries{OutputFile: p.installSource} - p.subAndroidMk(&ret, p.installer) + p.subAndroidMk(&entries, p.installer) - return ret + return []android.AndroidMkEntries{entries} } -func (p *binaryDecorator) AndroidMk(base *Module, ret *android.AndroidMkData) { - ret.Class = "EXECUTABLES" +func (p *binaryDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) { + entries.Class = "EXECUTABLES" - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { - if len(p.binaryProperties.Test_suites) > 0 { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", - strings.Join(p.binaryProperties.Test_suites, " ")) - } + entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { + entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", p.binaryProperties.Test_suites...) }) - base.subAndroidMk(ret, p.pythonInstaller) + base.subAndroidMk(entries, p.pythonInstaller) } -func (p *testDecorator) AndroidMk(base *Module, ret *android.AndroidMkData) { - ret.Class = "NATIVE_TESTS" +func (p *testDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) { + entries.Class = "NATIVE_TESTS" - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { - if len(p.binaryDecorator.binaryProperties.Test_suites) > 0 { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", - strings.Join(p.binaryDecorator.binaryProperties.Test_suites, " ")) - } + entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { + entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", p.binaryDecorator.binaryProperties.Test_suites...) if p.testConfig != nil { - fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", - p.testConfig.String()) + entries.SetString("LOCAL_FULL_TEST_CONFIG", p.testConfig.String()) } - if !BoolDefault(p.binaryProperties.Auto_gen_config, true) { - fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true") - } + entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true)) + }) - base.subAndroidMk(ret, p.binaryDecorator.pythonInstaller) + base.subAndroidMk(entries, p.binaryDecorator.pythonInstaller) } -func (installer *pythonInstaller) AndroidMk(base *Module, ret *android.AndroidMkData) { +func (installer *pythonInstaller) AndroidMk(base *Module, entries *android.AndroidMkEntries) { // Soong installation is only supported for host modules. Have Make // installation trigger Soong installation. if base.Target().Os.Class == android.Host { - ret.OutputFile = android.OptionalPathForPath(installer.path) + entries.OutputFile = android.OptionalPathForPath(installer.path) } - ret.Required = append(ret.Required, "libc++") - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { + entries.Required = append(entries.Required, "libc++") + entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { path, file := filepath.Split(installer.path.ToMakePath().String()) stem := strings.TrimSuffix(file, filepath.Ext(file)) - fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file)) - fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) - fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) - fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(installer.androidMkSharedLibs, " ")) - fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES := false") + entries.SetString("LOCAL_MODULE_SUFFIX", filepath.Ext(file)) + entries.SetString("LOCAL_MODULE_PATH", path) + entries.SetString("LOCAL_MODULE_STEM", stem) + entries.AddStrings("LOCAL_SHARED_LIBRARIES", installer.androidMkSharedLibs...) + entries.SetBool("LOCAL_CHECK_ELF_FILES", false) }) } diff --git a/python/python.go b/python/python.go index 8b912be17..4e15d3a07 100644 --- a/python/python.go +++ b/python/python.go @@ -185,7 +185,7 @@ func (p *Module) GetSrcsZip() android.Path { var _ PythonDependency = (*Module)(nil) -var _ android.AndroidMkDataProvider = (*Module)(nil) +var _ android.AndroidMkEntriesProvider = (*Module)(nil) func (p *Module) Init() android.Module { diff --git a/rust/androidmk.go b/rust/androidmk.go index 99880a821..428e74925 100644 --- a/rust/androidmk.go +++ b/rust/androidmk.go @@ -15,10 +15,7 @@ package rust import ( - "fmt" - "io" "path/filepath" - "strings" "android/soong/android" ) @@ -26,14 +23,14 @@ import ( type AndroidMkContext interface { Name() string Target() android.Target - subAndroidMk(*android.AndroidMkData, interface{}) + subAndroidMk(*android.AndroidMkEntries, interface{}) } type subAndroidMkProvider interface { - AndroidMk(AndroidMkContext, *android.AndroidMkData) + AndroidMk(AndroidMkContext, *android.AndroidMkEntries) } -func (mod *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) { +func (mod *Module) subAndroidMk(data *android.AndroidMkEntries, obj interface{}) { if mod.subAndroidMkOnce == nil { mod.subAndroidMkOnce = make(map[subAndroidMkProvider]bool) } @@ -45,27 +42,17 @@ func (mod *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) { } } -func (mod *Module) AndroidMk() android.AndroidMkData { - ret := android.AndroidMkData{ +func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries { + ret := android.AndroidMkEntries{ OutputFile: mod.outputFile, Include: "$(BUILD_SYSTEM)/soong_rust_prebuilt.mk", - Extra: []android.AndroidMkExtraFunc{ - func(w io.Writer, outputFile android.Path) { - if len(mod.Properties.AndroidMkRlibs) > 0 { - fmt.Fprintln(w, "LOCAL_RLIB_LIBRARIES := "+strings.Join(mod.Properties.AndroidMkRlibs, " ")) - } - if len(mod.Properties.AndroidMkDylibs) > 0 { - fmt.Fprintln(w, "LOCAL_DYLIB_LIBRARIES := "+strings.Join(mod.Properties.AndroidMkDylibs, " ")) - } - if len(mod.Properties.AndroidMkProcMacroLibs) > 0 { - fmt.Fprintln(w, "LOCAL_PROC_MACRO_LIBRARIES := "+strings.Join(mod.Properties.AndroidMkProcMacroLibs, " ")) - } - if len(mod.Properties.AndroidMkSharedLibs) > 0 { - fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(mod.Properties.AndroidMkSharedLibs, " ")) - } - if len(mod.Properties.AndroidMkStaticLibs) > 0 { - fmt.Fprintln(w, "LOCAL_STATIC_LIBRARIES := "+strings.Join(mod.Properties.AndroidMkStaticLibs, " ")) - } + ExtraEntries: []android.AndroidMkExtraEntriesFunc{ + func(entries *android.AndroidMkEntries) { + entries.AddStrings("LOCAL_RLIB_LIBRARIES", mod.Properties.AndroidMkRlibs...) + entries.AddStrings("LOCAL_DYLIB_LIBRARIES", mod.Properties.AndroidMkDylibs...) + entries.AddStrings("LOCAL_PROC_MACRO_LIBRARIES", mod.Properties.AndroidMkProcMacroLibs...) + entries.AddStrings("LOCAL_SHARED_LIBRARIES", mod.Properties.AndroidMkSharedLibs...) + entries.AddStrings("LOCAL_STATIC_LIBRARIES", mod.Properties.AndroidMkStaticLibs...) }, }, } @@ -74,10 +61,10 @@ func (mod *Module) AndroidMk() android.AndroidMkData { ret.SubName += mod.Properties.SubName - return ret + return []android.AndroidMkEntries{ret} } -func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { +func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { ctx.subAndroidMk(ret, binary.baseCompiler) if binary.distFile.Valid() { @@ -85,31 +72,26 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr } ret.Class = "EXECUTABLES" - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { - fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", binary.unstrippedOutputFile.String()) + ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { + entries.SetPath("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile) }) } -func (test *testDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { +func (test *testDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { test.binaryDecorator.AndroidMk(ctx, ret) ret.Class = "NATIVE_TESTS" ret.SubName = test.getMutatedModuleSubName(ctx.Name()) - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { - if len(test.Properties.Test_suites) > 0 { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", - strings.Join(test.Properties.Test_suites, " ")) - } + ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { + entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test.Properties.Test_suites...) if test.testConfig != nil { - fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", test.testConfig.String()) - } - if !BoolDefault(test.Properties.Auto_gen_config, true) { - fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true") + entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String()) } + entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(test.Properties.Auto_gen_config, true)) }) // TODO(chh): add test data with androidMkWriteTestData(test.data, ctx, ret) } -func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { +func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { ctx.subAndroidMk(ret, library.baseCompiler) if library.rlib() { @@ -126,14 +108,14 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An ret.DistFiles = android.MakeDefaultDistFiles(library.distFile.Path()) } - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { + ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { if !library.rlib() { - fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", library.unstrippedOutputFile.String()) + entries.SetPath("LOCAL_SOONG_UNSTRIPPED_BINARY", library.unstrippedOutputFile) } }) } -func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { +func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { ctx.subAndroidMk(ret, procMacro.baseCompiler) ret.Class = "PROC_MACRO_LIBRARIES" @@ -143,17 +125,17 @@ func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *androi } -func (compiler *baseCompiler) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { +func (compiler *baseCompiler) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { // Soong installation is only supported for host modules. Have Make // installation trigger Soong installation. if ctx.Target().Os.Class == android.Host { ret.OutputFile = android.OptionalPathForPath(compiler.path) } - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { + ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { path, file := filepath.Split(compiler.path.ToMakePath().String()) stem, suffix, _ := android.SplitFileExt(file) - fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) - fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path) - fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) + entries.SetString("LOCAL_MODULE_SUFFIX", suffix) + entries.SetString("LOCAL_MODULE_PATH", path) + entries.SetString("LOCAL_MODULE_STEM", stem) }) } diff --git a/tradefed/Android.bp b/tradefed/Android.bp index f4e8334f0..6e5e5330e 100644 --- a/tradefed/Android.bp +++ b/tradefed/Android.bp @@ -12,20 +12,3 @@ bootstrap_go_package { ], pluginFor: ["soong_build"], } - -bootstrap_go_package { - name: "soong-suite-harness", - pkgPath: "android/soong/suite_harness", - deps: [ - "blueprint", - "blueprint-pathtools", - "blueprint-proptools", - "soong", - "soong-android", - "soong-java", - ], - srcs: [ - "tradefed_binary.go", - ], - pluginFor: ["soong_build"], -} diff --git a/tradefed/tradefed_binary.go b/tradefed/tradefed_binary.go deleted file mode 100644 index 7960fdc88..000000000 --- a/tradefed/tradefed_binary.go +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2018 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package suite_harness - -import ( - "strings" - - "github.com/google/blueprint" - - "android/soong/android" - "android/soong/java" -) - -var pctx = android.NewPackageContext("android/soong/suite_harness") - -func init() { - android.RegisterModuleType("tradefed_binary_host", tradefedBinaryFactory) - - pctx.Import("android/soong/android") -} - -type TradefedBinaryProperties struct { - Short_name string - Full_name string - Version string - Prepend_platform_version_name bool -} - -// tradefedBinaryFactory creates an empty module for the tradefed_binary module type, -// which is a java_binary with some additional processing in tradefedBinaryLoadHook. -func tradefedBinaryFactory() android.Module { - props := &TradefedBinaryProperties{} - module := java.BinaryHostFactory() - module.AddProperties(props) - android.AddLoadHook(module, tradefedBinaryLoadHook(props)) - - return module -} - -const genSuffix = "-gen" - -// tradefedBinaryLoadHook adds extra resources and libraries to tradefed_binary modules. -func tradefedBinaryLoadHook(tfb *TradefedBinaryProperties) func(ctx android.LoadHookContext) { - return func(ctx android.LoadHookContext) { - genName := ctx.ModuleName() + genSuffix - version := tfb.Version - if tfb.Prepend_platform_version_name { - version = ctx.Config().PlatformVersionName() + tfb.Version - } - - // Create a submodule that generates the test-suite-info.properties file - // and copies DynamicConfig.xml if it is present. - ctx.CreateModule(tradefedBinaryGenFactory, - &TradefedBinaryGenProperties{ - Name: &genName, - Short_name: tfb.Short_name, - Full_name: tfb.Full_name, - Version: version, - }) - - props := struct { - Java_resources []string - Libs []string - }{} - - // Add dependencies required by all tradefed_binary modules. - props.Libs = []string{ - "tradefed", - "tradefed-test-framework", - "loganalysis", - "hosttestlib", - "compatibility-host-util", - } - - // Add the files generated by the submodule created above to the resources. - props.Java_resources = []string{":" + genName} - - ctx.AppendProperties(&props) - - } -} - -type TradefedBinaryGenProperties struct { - Name *string - Short_name string - Full_name string - Version string -} - -type tradefedBinaryGen struct { - android.ModuleBase - - properties TradefedBinaryGenProperties - - gen android.Paths -} - -func tradefedBinaryGenFactory() android.Module { - tfg := &tradefedBinaryGen{} - tfg.AddProperties(&tfg.properties) - android.InitAndroidModule(tfg) - return tfg -} - -func (tfg *tradefedBinaryGen) DepsMutator(android.BottomUpMutatorContext) {} - -var tradefedBinaryGenRule = pctx.StaticRule("tradefedBinaryGenRule", blueprint.RuleParams{ - Command: `rm -f $out && touch $out && ` + - `echo "# This file is auto generated by Android.mk. Do not modify." >> $out && ` + - `echo "build_number = $$(cat ${buildNumberFile})" >> $out && ` + - `echo "target_arch = ${arch}" >> $out && ` + - `echo "name = ${name}" >> $out && ` + - `echo "fullname = ${fullname}" >> $out && ` + - `echo "version = ${version}" >> $out`, -}, "buildNumberFile", "arch", "name", "fullname", "version") - -func (tfg *tradefedBinaryGen) GenerateAndroidBuildActions(ctx android.ModuleContext) { - buildNumberFile := ctx.Config().BuildNumberFile(ctx) - outputFile := android.PathForModuleOut(ctx, "test-suite-info.properties") - ctx.Build(pctx, android.BuildParams{ - Rule: tradefedBinaryGenRule, - Output: outputFile, - OrderOnly: android.Paths{buildNumberFile}, - Args: map[string]string{ - "buildNumberFile": buildNumberFile.String(), - "arch": ctx.Config().DevicePrimaryArchType().String(), - "name": tfg.properties.Short_name, - "fullname": tfg.properties.Full_name, - "version": tfg.properties.Version, - }, - }) - - tfg.gen = append(tfg.gen, outputFile) - - dynamicConfig := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "DynamicConfig.xml") - if dynamicConfig.Valid() { - outputFile := android.PathForModuleOut(ctx, strings.TrimSuffix(ctx.ModuleName(), genSuffix)+".dynamic") - ctx.Build(pctx, android.BuildParams{ - Rule: android.Cp, - Input: dynamicConfig.Path(), - Output: outputFile, - }) - - tfg.gen = append(tfg.gen, outputFile) - } -} - -func (tfg *tradefedBinaryGen) Srcs() android.Paths { - return append(android.Paths(nil), tfg.gen...) -} - -var _ android.SourceFileProducer = (*tradefedBinaryGen)(nil) |