Share cFlags, tidyFlags, etc. in a module
* In builder.go, share common flags in a module. * This replaces the sharing of cflags/cppflags/asflags in cc.go. * A unit test in apex_test.go now fails and is commented out. It is a failing test hidden by old optimization in cc.go. * In module.go, expand the reference variable $someflags<n>, or ${someflags<n>} to keep many existing unit tests work as is. * The build.ninja size was reduced from 8.1GB to 6.2GB, for aosp_arm64-eng WITH_TIDY=1 USE_RBE=true, and from 7.5GB to 5.6GB when USE_RBE is 0. Content of build.ninja is also more readable and searchable. Read/write build.ninja times are also reduced, depending on disk I/O speed. Test: make WITH_TIDY=1 Change-Id: I17f96adf4844136d52e5d40f57a19d9e290162b7
This commit is contained in:
@@ -1249,7 +1249,30 @@ func (m *ModuleBase) GetProperties() []interface{} {
|
||||
}
|
||||
|
||||
func (m *ModuleBase) BuildParamsForTests() []BuildParams {
|
||||
return m.buildParams
|
||||
// Expand the references to module variables like $flags[0-9]*,
|
||||
// so we do not need to change many existing unit tests.
|
||||
// This looks like undoing the shareFlags optimization in cc's
|
||||
// transformSourceToObj, and should only affects unit tests.
|
||||
vars := m.VariablesForTests()
|
||||
buildParams := append([]BuildParams(nil), m.buildParams...)
|
||||
for i, _ := range buildParams {
|
||||
newArgs := make(map[string]string)
|
||||
for k, v := range buildParams[i].Args {
|
||||
newArgs[k] = v
|
||||
// Replaces both ${flags1} and $flags1 syntax.
|
||||
if strings.HasPrefix(v, "${") && strings.HasSuffix(v, "}") {
|
||||
if value, found := vars[v[2:len(v)-1]]; found {
|
||||
newArgs[k] = value
|
||||
}
|
||||
} else if strings.HasPrefix(v, "$") {
|
||||
if value, found := vars[v[1:]]; found {
|
||||
newArgs[k] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
buildParams[i].Args = newArgs
|
||||
}
|
||||
return buildParams
|
||||
}
|
||||
|
||||
func (m *ModuleBase) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
|
||||
|
Reference in New Issue
Block a user