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
This commit is contained in:
parent
5473c9a60a
commit
f923f2b54c
|
@ -191,8 +191,6 @@ type nameProperties struct {
|
|||
}
|
||||
|
||||
type commonProperties struct {
|
||||
Tags []string
|
||||
|
||||
// emit build rules for this module
|
||||
Enabled *bool `android:"arch_variant"`
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ cc_library_shared {
|
|||
`,
|
||||
},
|
||||
{
|
||||
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 @@ include $(BUILD_SHARED_LIBRARY)
|
|||
|
||||
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 {
|
||||
}
|
||||
`,
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
8
cc/cc.go
8
cc/cc.go
|
@ -206,10 +206,6 @@ type VendorProperties struct {
|
|||
Double_loadable *bool
|
||||
}
|
||||
|
||||
type UnusedProperties struct {
|
||||
Tags []string
|
||||
}
|
||||
|
||||
type ModuleContextIntf interface {
|
||||
static() bool
|
||||
staticBinary() bool
|
||||
|
@ -320,7 +316,6 @@ type Module struct {
|
|||
|
||||
Properties BaseProperties
|
||||
VendorProperties VendorProperties
|
||||
unused UnusedProperties
|
||||
|
||||
// initialize before calling Init
|
||||
hod android.HostOrDeviceSupported
|
||||
|
@ -360,7 +355,7 @@ type Module struct {
|
|||
}
|
||||
|
||||
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 @@ func DefaultsFactory(props ...interface{}) android.Module {
|
|||
&BinaryLinkerProperties{},
|
||||
&TestProperties{},
|
||||
&TestBinaryProperties{},
|
||||
&UnusedProperties{},
|
||||
&StlProperties{},
|
||||
&SanitizeProperties{},
|
||||
&StripProperties{},
|
||||
|
|
Loading…
Reference in New Issue