diff options
author | Paul Duffin <paulduffin@google.com> | 2022-11-14 17:35:50 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2022-11-22 16:06:23 +0000 |
commit | c21336e7cd011ccb3bbe0f855f4a4471ffcca5c2 (patch) | |
tree | 7076364875be4ce36b86a2809f87291ee13bdeeb | |
parent | b452cc759f33c232d068fc6006887328a441a950 (diff) | |
download | soong-c21336e7cd011ccb3bbe0f855f4a4471ffcca5c2.tar.gz |
Remove support for unused env vars from sdk snapshot generation
The following environment variables are no longer used when generating
sdk snapshots:
* SOONG_SDK_SNAPSHOT_PREFER - we can control the modules that are
preferred at build time now.
* SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR - this is done as a
post-processing step by the mainline_module_sdks.sh script to avoid
having to regenerate the ninja files for every module.
* SOONG_SDK_SNAPSHOT_VERSION - support for this was removed a long time
ago but was still referenced from dumpvars.go.
Bug: 259095197
Test: m nothing
# Searched for uses of these variables but could not find any
# outside the build.
Change-Id: Id2b32b29ff6f09faffea43292f549ba13acd956d
(cherry picked from commit 82d75ade2a7dd0dbcd483c46e833ce697a443a34)
Merged-In: Id2b32b29ff6f09faffea43292f549ba13acd956d
-rw-r--r-- | sdk/sdk_test.go | 54 | ||||
-rw-r--r-- | sdk/update.go | 54 | ||||
-rw-r--r-- | ui/build/dumpvars.go | 3 |
3 files changed, 1 insertions, 110 deletions
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go index 2f9aee9da..108a664ea 100644 --- a/sdk/sdk_test.go +++ b/sdk/sdk_test.go @@ -409,60 +409,6 @@ java_import { ) }) - t.Run("SOONG_SDK_SNAPSHOT_PREFER=true", func(t *testing.T) { - result := android.GroupFixturePreparers( - preparer, - android.FixtureMergeEnv(map[string]string{ - "SOONG_SDK_SNAPSHOT_PREFER": "true", - }), - ).RunTest(t) - - checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-current.zip") - - CheckSnapshot(t, result, "mysdk", "", - checkAndroidBpContents(` -// This is auto-generated. DO NOT EDIT. - -java_import { - name: "myjavalib", - prefer: true, - visibility: ["//visibility:public"], - apex_available: ["//apex_available:platform"], - jars: ["java/myjavalib.jar"], -} - `), - ) - }) - - t.Run("SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR=module:build_from_source", func(t *testing.T) { - result := android.GroupFixturePreparers( - preparer, - android.FixtureMergeEnv(map[string]string{ - "SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR": "module:build_from_source", - }), - ).RunTest(t) - - checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-current.zip") - - CheckSnapshot(t, result, "mysdk", "", - checkAndroidBpContents(` -// This is auto-generated. DO NOT EDIT. - -java_import { - name: "myjavalib", - prefer: false, - use_source_config_var: { - config_namespace: "module", - var_name: "build_from_source", - }, - visibility: ["//visibility:public"], - apex_available: ["//apex_available:platform"], - jars: ["java/myjavalib.jar"], -} - `), - ) - }) - t.Run("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE=S", func(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJava, diff --git a/sdk/update.go b/sdk/update.go index 92a13fa7f..baa203302 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -34,41 +34,6 @@ import ( // Environment variables that affect the generated snapshot // ======================================================== // -// SOONG_SDK_SNAPSHOT_PREFER -// By default every module in the generated snapshot has prefer: false. Building it -// with SOONG_SDK_SNAPSHOT_PREFER=true will force them to use prefer: true. -// -// SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR -// If set this specifies the Soong config var that can be used to control whether the prebuilt -// modules from the generated snapshot or the original source modules. Values must be a colon -// separated pair of strings, the first of which is the Soong config namespace, and the second -// is the name of the variable within that namespace. -// -// The config namespace and var name are used to set the `use_source_config_var` property. That -// in turn will cause the generated prebuilts to use the soong config variable to select whether -// source or the prebuilt is used. -// e.g. If an sdk snapshot is built using: -// m SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR=acme:build_from_source sdkextensions-sdk -// Then the resulting snapshot will include: -// use_source_config_var: { -// config_namespace: "acme", -// var_name: "build_from_source", -// } -// -// Assuming that the config variable is defined in .mk using something like: -// $(call add_soong_config_namespace,acme) -// $(call add_soong_config_var_value,acme,build_from_source,true) -// -// Then when the snapshot is unpacked in the repository it will have the following behavior: -// m droid - will use the sdkextensions-sdk prebuilts if present. Otherwise, it will use the -// sources. -// m SOONG_CONFIG_acme_build_from_source=true droid - will use the sdkextensions-sdk -// sources, if present. Otherwise, it will use the prebuilts. -// -// This is a temporary mechanism to control the prefer flags and will be removed once a more -// maintainable solution has been implemented. -// TODO(b/174997203): Remove when no longer necessary. -// // SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE // This allows the target build release (i.e. the release version of the build within which // the snapshot will be used) of the snapshot to be specified. If unspecified then it defaults @@ -2019,29 +1984,12 @@ func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModu // Do not add the prefer property if the member snapshot module is a source module type. moduleCtx := ctx.sdkMemberContext - config := moduleCtx.Config() if !memberType.UsesSourceModuleTypeInSnapshot() { - // Set the prefer based on the environment variable. This is a temporary work around to allow a - // snapshot to be created that sets prefer: true. - // TODO(b/174997203): Remove once the ability to select the modules to prefer can be done - // dynamically at build time not at snapshot generation time. - prefer := config.IsEnvTrue("SOONG_SDK_SNAPSHOT_PREFER") - // Set prefer. Setting this to false is not strictly required as that is the default but it does // provide a convenient hook to post-process the generated Android.bp file, e.g. in tests to // check the behavior when a prebuilt is preferred. It also makes it explicit what the default // behavior is for the module. - bpModule.insertAfter("name", "prefer", prefer) - - configVar := config.Getenv("SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR") - if configVar != "" { - parts := strings.Split(configVar, ":") - cfp := android.ConfigVarProperties{ - Config_namespace: proptools.StringPtr(parts[0]), - Var_name: proptools.StringPtr(parts[1]), - } - bpModule.insertAfter("prefer", "use_source_config_var", cfp) - } + bpModule.insertAfter("name", "prefer", false) } variants := selectApexVariantsWhereAvailable(ctx, member.variants) diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go index 285f1569b..45bfe5dfa 100644 --- a/ui/build/dumpvars.go +++ b/ui/build/dumpvars.go @@ -162,10 +162,7 @@ var BannerVars = []string{ "OUT_DIR", "AUX_OS_VARIANT_LIST", "PRODUCT_SOONG_NAMESPACES", - "SOONG_SDK_SNAPSHOT_PREFER", "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", - "SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR", - "SOONG_SDK_SNAPSHOT_VERSION", } func Banner(make_vars map[string]string) string { |