Drop use_source_config_var from prebuilt selection

This CL makes this property a no-op from the perspective of prebuilt
selection. The primary user of this was mainline modules, but they have
now switched to RELEASE_APEX_CONTRIBUTIONS_* for prebuilt selection,
both for internal `main` development and in partner drops.

Test: in internal, lunch cf_x86_64_phone-next-userdebug; m nothing; and
verified there was a path to the prebuilt bt apex

Test: in partner workspace, lunch gsi_partner_arm-ap31-userdebug; m
nothing; and verified that there was a path to the prebuilt adservices apex

Bug: 308188211
Change-Id: I124a6dada5c20aca4bdebf70dcbe5bbec28cefbe
This commit is contained in:
Spandan Das 2024-04-18 21:34:12 +00:00
parent 17b9a5b8b4
commit 7e674e69ef
3 changed files with 0 additions and 169 deletions

View file

@ -706,11 +706,6 @@ func (p *Prebuilt) usePrebuilt(ctx BaseMutatorContext, source Module, prebuilt M
return true
}
// If the use_source_config_var property is set then it overrides the prefer property setting.
if configVar := p.properties.Use_source_config_var; configVar != nil {
return !ctx.Config().VendorConfig(proptools.String(configVar.Config_namespace)).Bool(proptools.String(configVar.Var_name))
}
// TODO: use p.Properties.Name and ctx.ModuleDir to override preference
return Bool(p.properties.Prefer)
}

View file

@ -295,158 +295,6 @@ func TestPrebuilts(t *testing.T) {
}`,
prebuilt: []OsType{Android, buildOS},
},
{
name: "prebuilt use_source_config_var={acme, use_source} - no var specified",
modules: `
source {
name: "bar",
}
prebuilt {
name: "bar",
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
srcs: ["prebuilt_file"],
}`,
// When use_source_env is specified then it will use the prebuilt by default if the environment
// variable is not set.
prebuilt: []OsType{Android, buildOS},
},
{
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=false",
modules: `
source {
name: "bar",
}
prebuilt {
name: "bar",
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
srcs: ["prebuilt_file"],
}`,
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
variables.VendorVars = map[string]map[string]string{
"acme": {
"use_source": "false",
},
}
}),
// Setting the environment variable named in use_source_env to false will cause the prebuilt to
// be used.
prebuilt: []OsType{Android, buildOS},
},
{
name: "apex_contributions supersedes any source preferred via use_source_config_var",
modules: `
source {
name: "bar",
}
prebuilt {
name: "bar",
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
srcs: ["prebuilt_file"],
}
apex_contributions {
name: "my_mainline_module_contribution",
api_domain: "apexfoo",
// this metadata module contains prebuilt
contents: ["prebuilt_bar"],
}
all_apex_contributions {
name: "all_apex_contributions",
}
`,
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
variables.VendorVars = map[string]map[string]string{
"acme": {
"use_source": "true",
},
}
variables.BuildFlags = map[string]string{
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contribution",
}
}),
// use_source_config_var indicates that source should be used
// but this is superseded by `my_mainline_module_contribution`
prebuilt: []OsType{Android, buildOS},
},
{
name: "apex_contributions supersedes any prebuilt preferred via use_source_config_var",
modules: `
source {
name: "bar",
}
prebuilt {
name: "bar",
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
srcs: ["prebuilt_file"],
}
apex_contributions {
name: "my_mainline_module_contribution",
api_domain: "apexfoo",
// this metadata module contains source
contents: ["bar"],
}
all_apex_contributions {
name: "all_apex_contributions",
}
`,
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
variables.VendorVars = map[string]map[string]string{
"acme": {
"use_source": "false",
},
}
variables.BuildFlags = map[string]string{
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contribution",
}
}),
// use_source_config_var indicates that prebuilt should be used
// but this is superseded by `my_mainline_module_contribution`
prebuilt: nil,
},
{
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=true",
modules: `
source {
name: "bar",
}
prebuilt {
name: "bar",
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
srcs: ["prebuilt_file"],
}`,
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
variables.VendorVars = map[string]map[string]string{
"acme": {
"use_source": "true",
},
}
}),
// Setting the environment variable named in use_source_env to true will cause the source to be
// used.
prebuilt: nil,
},
{
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=true, no source",
modules: `
prebuilt {
name: "bar",
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
srcs: ["prebuilt_file"],
}`,
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
variables.VendorVars = map[string]map[string]string{
"acme": {
"use_source": "true",
},
}
}),
// Although the environment variable says to use source there is no source available.
prebuilt: []OsType{Android, buildOS},
},
}
fs := MockFS{

View file

@ -1085,18 +1085,6 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
t.Run("prefer", func(t *testing.T) {
testJavaSdkLibraryImport_Preferred(t, "prefer: true,", android.NullFixturePreparer)
})
t.Run("use_source_config_var", func(t *testing.T) {
testJavaSdkLibraryImport_Preferred(t,
"use_source_config_var: {config_namespace: \"acme\", var_name: \"use_source\"},",
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.VendorVars = map[string]map[string]string{
"acme": {
"use_source": "false",
},
}
}))
})
}
// If a module is listed in `mainline_module_contributions, it should be used