diff options
author | Dan Willemsen <dwillemsen@google.com> | 2018-05-09 13:45:03 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2018-05-15 00:33:11 +0000 |
commit | f923f2b54cd0ad9f7fecb06f7005030886cb64a5 (patch) | |
tree | 991b3e4c919868029d51b037ab279dd62bd7a6dc /bpfix | |
parent | 5473c9a60a9059667130edb6036b70d24604e276 (diff) | |
download | build_soong-f923f2b54cd0ad9f7fecb06f7005030886cb64a5.tar.gz build_soong-f923f2b54cd0ad9f7fecb06f7005030886cb64a5.tar.bz2 build_soong-f923f2b54cd0ad9f7fecb06f7005030886cb64a5.zip |
Remove the unused `tags` property
And fix up androidmk / bpfix to provide warnings about what to do
instead.
Test: m blueprint_tools (runs the tests, ensures there aren't any tags left)
Change-Id: I1a3ad8600211050420041740207d6957f44463c8
Diffstat (limited to 'bpfix')
-rw-r--r-- | bpfix/bpfix/bpfix.go | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go index 55de9936..ee00907f 100644 --- a/bpfix/bpfix/bpfix.go +++ b/bpfix/bpfix/bpfix.go @@ -50,6 +50,7 @@ type FixRequest struct { rewriteIncorrectAndroidmkAndroidLibraries bool mergeMatchingModuleProperties bool reorderCommonProperties bool + removeTags bool } func NewFixRequest() FixRequest { @@ -63,6 +64,7 @@ func (r FixRequest) AddAll() (result FixRequest) { result.rewriteIncorrectAndroidmkAndroidLibraries = true result.mergeMatchingModuleProperties = true result.reorderCommonProperties = true + result.removeTags = true return result } @@ -180,6 +182,13 @@ func (f *Fixer) fixTreeOnce(config FixRequest) error { return err } } + + if config.removeTags { + err := f.runPatchListMod(removeTags) + if err != nil { + return err + } + } return nil } @@ -352,6 +361,72 @@ func reorderCommonProperties(mod *parser.Module, buf []byte, patchlist *parser.P return nil } +func removeTags(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error { + prop, ok := mod.GetProperty("tags") + if !ok { + return nil + } + list, ok := prop.Value.(*parser.List) + if !ok { + return nil + } + + replaceStr := "" + + for _, item := range list.Values { + str, ok := item.(*parser.String) + if !ok { + replaceStr += fmt.Sprintf("// ERROR: Unable to parse tag %q\n", item) + continue + } + + switch str.Value { + case "optional": + continue + case "debug": + replaceStr += `// WARNING: Module tags are not supported in Soong. + // Add this module to PRODUCT_PACKAGES_DEBUG in your product file if you want to + // force installation for -userdebug and -eng builds. + ` + case "eng": + replaceStr += `// WARNING: Module tags are not supported in Soong. + // Add this module to PRODUCT_PACKAGES_ENG in your product file if you want to + // force installation for -eng builds. + ` + case "tests": + if strings.Contains(mod.Type, "cc_test") || strings.Contains(mod.Type, "cc_library_static") { + continue + } else if strings.Contains(mod.Type, "cc_lib") { + replaceStr += `// WARNING: Module tags are not supported in Soong. + // To make a shared library only for tests, use the "cc_test_library" module + // type. If you don't use gtest, set "gtest: false". + ` + } else if strings.Contains(mod.Type, "cc_bin") { + replaceStr += `// WARNING: Module tags are not supported in Soong. + // For native test binaries, use the "cc_test" module type. Some differences: + // - If you don't use gtest, set "gtest: false" + // - Binaries will be installed into /data/nativetest[64]/<name>/<name> + // - Both 32 & 64 bit versions will be built (as appropriate) + ` + } else if strings.Contains(mod.Type, "java_lib") { + replaceStr += `// WARNING: Module tags are not supported in Soong. + // For JUnit or similar tests, use the "java_test" module type. A dependency on + // Junit will be added by default, if it is using some other runner, set "junit: false". + ` + } else { + replaceStr += `// WARNING: Module tags are not supported in Soong. + // In most cases, tests are now identified by their module type: + // cc_test, java_test, python_test + ` + } + default: + replaceStr += fmt.Sprintf("// WARNING: Unknown module tag %q\n", str.Value) + } + } + + return patchlist.Add(prop.Pos().Offset, prop.End().Offset+2, replaceStr) +} + func mergeMatchingModuleProperties(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error { return mergeMatchingProperties(&mod.Properties, buf, patchlist) } |