Merge "Remove the unused tags
property"
This commit is contained in:
@@ -191,8 +191,6 @@ type nameProperties struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type commonProperties struct {
|
type commonProperties struct {
|
||||||
Tags []string
|
|
||||||
|
|
||||||
// emit build rules for this module
|
// emit build rules for this module
|
||||||
Enabled *bool `android:"arch_variant"`
|
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: `
|
in: `
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
LOCAL_MODULE_TAGS := debug
|
LOCAL_MODULE_TAGS := debug
|
||||||
@@ -340,7 +340,41 @@ include $(BUILD_SHARED_LIBRARY)
|
|||||||
|
|
||||||
expected: `
|
expected: `
|
||||||
cc_library_shared {
|
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
|
rewriteIncorrectAndroidmkAndroidLibraries bool
|
||||||
mergeMatchingModuleProperties bool
|
mergeMatchingModuleProperties bool
|
||||||
reorderCommonProperties bool
|
reorderCommonProperties bool
|
||||||
|
removeTags bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFixRequest() FixRequest {
|
func NewFixRequest() FixRequest {
|
||||||
@@ -63,6 +64,7 @@ func (r FixRequest) AddAll() (result FixRequest) {
|
|||||||
result.rewriteIncorrectAndroidmkAndroidLibraries = true
|
result.rewriteIncorrectAndroidmkAndroidLibraries = true
|
||||||
result.mergeMatchingModuleProperties = true
|
result.mergeMatchingModuleProperties = true
|
||||||
result.reorderCommonProperties = true
|
result.reorderCommonProperties = true
|
||||||
|
result.removeTags = true
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,6 +182,13 @@ func (f *Fixer) fixTreeOnce(config FixRequest) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.removeTags {
|
||||||
|
err := f.runPatchListMod(removeTags)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,6 +361,72 @@ func reorderCommonProperties(mod *parser.Module, buf []byte, patchlist *parser.P
|
|||||||
return nil
|
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 {
|
func mergeMatchingModuleProperties(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error {
|
||||||
return mergeMatchingProperties(&mod.Properties, buf, patchlist)
|
return mergeMatchingProperties(&mod.Properties, buf, patchlist)
|
||||||
}
|
}
|
||||||
|
8
cc/cc.go
8
cc/cc.go
@@ -206,10 +206,6 @@ type VendorProperties struct {
|
|||||||
Double_loadable *bool
|
Double_loadable *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnusedProperties struct {
|
|
||||||
Tags []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type ModuleContextIntf interface {
|
type ModuleContextIntf interface {
|
||||||
static() bool
|
static() bool
|
||||||
staticBinary() bool
|
staticBinary() bool
|
||||||
@@ -320,7 +316,6 @@ type Module struct {
|
|||||||
|
|
||||||
Properties BaseProperties
|
Properties BaseProperties
|
||||||
VendorProperties VendorProperties
|
VendorProperties VendorProperties
|
||||||
unused UnusedProperties
|
|
||||||
|
|
||||||
// initialize before calling Init
|
// initialize before calling Init
|
||||||
hod android.HostOrDeviceSupported
|
hod android.HostOrDeviceSupported
|
||||||
@@ -360,7 +355,7 @@ type Module struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) Init() android.Module {
|
func (c *Module) Init() android.Module {
|
||||||
c.AddProperties(&c.Properties, &c.VendorProperties, &c.unused)
|
c.AddProperties(&c.Properties, &c.VendorProperties)
|
||||||
if c.compiler != nil {
|
if c.compiler != nil {
|
||||||
c.AddProperties(c.compiler.compilerProps()...)
|
c.AddProperties(c.compiler.compilerProps()...)
|
||||||
}
|
}
|
||||||
@@ -1475,7 +1470,6 @@ func DefaultsFactory(props ...interface{}) android.Module {
|
|||||||
&BinaryLinkerProperties{},
|
&BinaryLinkerProperties{},
|
||||||
&TestProperties{},
|
&TestProperties{},
|
||||||
&TestBinaryProperties{},
|
&TestBinaryProperties{},
|
||||||
&UnusedProperties{},
|
|
||||||
&StlProperties{},
|
&StlProperties{},
|
||||||
&SanitizeProperties{},
|
&SanitizeProperties{},
|
||||||
&StripProperties{},
|
&StripProperties{},
|
||||||
|
Reference in New Issue
Block a user