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
diff --git a/android/module.go b/android/module.go
index 4797c0c..fba1917 100644
--- a/android/module.go
+++ b/android/module.go
@@ -191,8 +191,6 @@
}
type commonProperties struct {
- Tags []string
-
// emit build rules for this module
Enabled *bool `android:"arch_variant"`
diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go
index 37e2427..a54a4d2 100644
--- a/androidmk/cmd/androidmk/androidmk_test.go
+++ b/androidmk/cmd/androidmk/androidmk_test.go
@@ -331,7 +331,7 @@
`,
},
{
- desc: "Keep LOCAL_MODULE_TAGS non-optional",
+ desc: "Warn for LOCAL_MODULE_TAGS non-optional",
in: `
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := debug
@@ -340,7 +340,41 @@
expected: `
cc_library_shared {
- tags: ["debug"],
+ // 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.
+}
+`,
+ },
+ {
+ desc: "Custom warning for LOCAL_MODULE_TAGS tests",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := debug tests
+include $(BUILD_SHARED_LIBRARY)
+`,
+
+ expected: `
+cc_library_shared {
+ // 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.
+ // 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".
+}
+`,
+ },
+ {
+ desc: "Ignore LOCAL_MODULE_TAGS tests for cc_test",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+include $(BUILD_NATIVE_TEST)
+`,
+
+ expected: `
+cc_test {
}
`,
},
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go
index 55de993..ee00907 100644
--- a/bpfix/bpfix/bpfix.go
+++ b/bpfix/bpfix/bpfix.go
@@ -50,6 +50,7 @@
rewriteIncorrectAndroidmkAndroidLibraries bool
mergeMatchingModuleProperties bool
reorderCommonProperties bool
+ removeTags bool
}
func NewFixRequest() FixRequest {
@@ -63,6 +64,7 @@
result.rewriteIncorrectAndroidmkAndroidLibraries = true
result.mergeMatchingModuleProperties = true
result.reorderCommonProperties = true
+ result.removeTags = true
return result
}
@@ -180,6 +182,13 @@
return err
}
}
+
+ if config.removeTags {
+ err := f.runPatchListMod(removeTags)
+ if err != nil {
+ return err
+ }
+ }
return nil
}
@@ -352,6 +361,72 @@
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)
}
diff --git a/cc/cc.go b/cc/cc.go
index fe337f5..9c3de09 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -206,10 +206,6 @@
Double_loadable *bool
}
-type UnusedProperties struct {
- Tags []string
-}
-
type ModuleContextIntf interface {
static() bool
staticBinary() bool
@@ -320,7 +316,6 @@
Properties BaseProperties
VendorProperties VendorProperties
- unused UnusedProperties
// initialize before calling Init
hod android.HostOrDeviceSupported
@@ -360,7 +355,7 @@
}
func (c *Module) Init() android.Module {
- c.AddProperties(&c.Properties, &c.VendorProperties, &c.unused)
+ c.AddProperties(&c.Properties, &c.VendorProperties)
if c.compiler != nil {
c.AddProperties(c.compiler.compilerProps()...)
}
@@ -1475,7 +1470,6 @@
&BinaryLinkerProperties{},
&TestProperties{},
&TestBinaryProperties{},
- &UnusedProperties{},
&StlProperties{},
&SanitizeProperties{},
&StripProperties{},