From 8982b1c49ec290e5a91a161415d194a26e222bcf Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Mon, 8 Apr 2024 16:54:45 -0700 Subject: [PATCH] Remove "exported" ninja variables There was infrastructure to export ninja variables to bazel. Now that the bazel migration is cancelled, we don't need it anymore. Bug: 315353489 Test: m nothing Change-Id: I298cc2ac7ebd004557be3b30d75f7357cab0b7a0 --- android/Android.bp | 1 - android/config_bp2build.go | 157 ----------------------------- android/defs.go | 6 +- cc/config/arm64_device.go | 32 +++--- cc/config/arm64_linux_host.go | 6 +- cc/config/arm_device.go | 52 +++++----- cc/config/arm_linux_host.go | 21 ++-- cc/config/global.go | 62 ++++-------- cc/config/riscv64_device.go | 12 +-- cc/config/tidy.go | 18 ++-- cc/config/toolchain.go | 7 +- cc/config/x86_64_device.go | 20 +--- cc/config/x86_device.go | 21 ++-- cc/config/x86_linux_bionic_host.go | 11 +- cc/config/x86_linux_host.go | 46 ++++----- cc/ndk_library.go | 2 +- cc/sanitize.go | 24 +---- java/config/config.go | 27 +++-- java/config/droidstubs.go | 8 +- java/config/error_prone.go | 21 ++-- rust/config/arm64_device.go | 2 +- rust/config/arm_device.go | 2 +- rust/config/global.go | 17 ++-- rust/config/x86_64_device.go | 2 +- rust/config/x86_device.go | 2 +- 25 files changed, 166 insertions(+), 413 deletions(-) delete mode 100644 android/config_bp2build.go diff --git a/android/Android.bp b/android/Android.bp index 03619f4b5..bf7804ae5 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -41,7 +41,6 @@ bootstrap_go_package { "buildinfo_prop.go", "config.go", "test_config.go", - "config_bp2build.go", "configured_jars.go", "csuite_config.go", "deapexer.go", diff --git a/android/config_bp2build.go b/android/config_bp2build.go deleted file mode 100644 index 4c2fb5e4a..000000000 --- a/android/config_bp2build.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2021 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package android - -import ( - "strings" - - "github.com/google/blueprint" -) - -// ExportedVariables is a collection of interdependent configuration variables -type ExportedVariables struct { - // Maps containing toolchain variables that are independent of the - // environment variables of the build. - exportedStringVars ExportedStringVariables - exportedStringListVars ExportedStringListVariables - exportedStringListDictVars ExportedStringListDictVariables - - exportedVariableReferenceDictVars ExportedVariableReferenceDictVariables - - /// Maps containing variables that are dependent on the build config. - exportedConfigDependingVars ExportedConfigDependingVariables - - pctx PackageContext -} - -// NewExportedVariables creats an empty ExportedVariables struct with non-nil maps -func NewExportedVariables(pctx PackageContext) ExportedVariables { - return ExportedVariables{ - exportedStringVars: ExportedStringVariables{}, - exportedStringListVars: ExportedStringListVariables{}, - exportedStringListDictVars: ExportedStringListDictVariables{}, - exportedVariableReferenceDictVars: ExportedVariableReferenceDictVariables{}, - exportedConfigDependingVars: ExportedConfigDependingVariables{}, - pctx: pctx, - } -} - -// ExportStringStaticVariable declares a static string variable and exports it to -// Bazel's toolchain. -func (ev ExportedVariables) ExportStringStaticVariable(name string, value string) { - ev.pctx.StaticVariable(name, value) - ev.exportedStringVars.set(name, value) -} - -// ExportStringListStaticVariable declares a static variable and exports it to -// Bazel's toolchain. -func (ev ExportedVariables) ExportStringListStaticVariable(name string, value []string) { - ev.pctx.StaticVariable(name, strings.Join(value, " ")) - ev.exportedStringListVars.set(name, value) -} - -// ExportVariableConfigMethod declares a variable whose value is evaluated at -// runtime via a function with access to the Config and exports it to Bazel's -// toolchain. -func (ev ExportedVariables) ExportVariableConfigMethod(name string, method interface{}) blueprint.Variable { - ev.exportedConfigDependingVars.set(name, method) - return ev.pctx.VariableConfigMethod(name, method) -} - -// ExportSourcePathVariable declares a static "source path" variable and exports -// it to Bazel's toolchain. -func (ev ExportedVariables) ExportSourcePathVariable(name string, value string) { - ev.pctx.SourcePathVariable(name, value) - ev.exportedStringVars.set(name, value) -} - -// ExportVariableFuncVariable declares a variable whose value is evaluated at -// runtime via a function and exports it to Bazel's toolchain. -func (ev ExportedVariables) ExportVariableFuncVariable(name string, f func() string) { - ev.exportedConfigDependingVars.set(name, func(config Config) string { - return f() - }) - ev.pctx.VariableFunc(name, func(PackageVarContext) string { - return f() - }) -} - -// ExportString only exports a variable to Bazel, but does not declare it in Soong -func (ev ExportedVariables) ExportString(name string, value string) { - ev.exportedStringVars.set(name, value) -} - -// ExportStringList only exports a variable to Bazel, but does not declare it in Soong -func (ev ExportedVariables) ExportStringList(name string, value []string) { - ev.exportedStringListVars.set(name, value) -} - -// ExportStringListDict only exports a variable to Bazel, but does not declare it in Soong -func (ev ExportedVariables) ExportStringListDict(name string, value map[string][]string) { - ev.exportedStringListDictVars.set(name, value) -} - -// ExportVariableReferenceDict only exports a variable to Bazel, but does not declare it in Soong -func (ev ExportedVariables) ExportVariableReferenceDict(name string, value map[string]string) { - ev.exportedVariableReferenceDictVars.set(name, value) -} - -// ExportedConfigDependingVariables is a mapping of variable names to functions -// of type func(config Config) string which return the runtime-evaluated string -// value of a particular variable -type ExportedConfigDependingVariables map[string]interface{} - -func (m ExportedConfigDependingVariables) set(k string, v interface{}) { - m[k] = v -} - -// ExportedStringVariables is a mapping of variable names to string values -type ExportedStringVariables map[string]string - -func (m ExportedStringVariables) set(k string, v string) { - m[k] = v -} - -// ExportedStringListVariables is a mapping of variable names to a list of strings -type ExportedStringListVariables map[string][]string - -func (m ExportedStringListVariables) set(k string, v []string) { - m[k] = v -} - -// ExportedStringListDictVariables is a mapping from variable names to a -// dictionary which maps keys to lists of strings -type ExportedStringListDictVariables map[string]map[string][]string - -func (m ExportedStringListDictVariables) set(k string, v map[string][]string) { - m[k] = v -} - -// ExportedVariableReferenceDictVariables is a mapping from variable names to a -// dictionary which references previously defined variables. This is used to -// create a Starlark output such as: -// -// string_var1 = "string1 -// var_ref_dict_var1 = { -// "key1": string_var1 -// } -// -// This type of variable collection must be expanded last so that it recognizes -// previously defined variables. -type ExportedVariableReferenceDictVariables map[string]map[string]string - -func (m ExportedVariableReferenceDictVariables) set(k string, v map[string]string) { - m[k] = v -} diff --git a/android/defs.go b/android/defs.go index dab012d04..a34d30248 100644 --- a/android/defs.go +++ b/android/defs.go @@ -20,8 +20,7 @@ import ( ) var ( - pctx = NewPackageContext("android/soong/android") - exportedVars = NewExportedVariables(pctx) + pctx = NewPackageContext("android/soong/android") cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks", Config.CpPreserveSymlinksFlags) @@ -130,9 +129,6 @@ func init() { pctx.VariableFunc("RBEWrapper", func(ctx PackageVarContext) string { return ctx.Config().RBEWrapper() }) - - exportedVars.ExportStringList("NeverAllowNotInIncludeDir", neverallowNotInIncludeDir) - exportedVars.ExportStringList("NeverAllowNoUseIncludeDir", neverallowNoUseIncludeDir) } // GlobToListFileRule creates a rule that writes a list of files matching a pattern to a file. diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index 10342a3ba..fb81e420f 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -91,16 +91,14 @@ var ( ) func init() { - exportedVars.ExportStringListStaticVariable("Arm64Ldflags", arm64Ldflags) + pctx.StaticVariable("Arm64Ldflags", strings.Join(arm64Ldflags, " ")) - exportedVars.ExportStringList("Arm64Lldflags", arm64Lldflags) pctx.VariableFunc("Arm64Lldflags", func(ctx android.PackageVarContext) string { maxPageSizeFlag := "-Wl,-z,max-page-size=" + ctx.Config().MaxPageSizeSupported() flags := append(arm64Lldflags, maxPageSizeFlag) return strings.Join(flags, " ") }) - exportedVars.ExportStringList("Arm64Cflags", arm64Cflags) pctx.VariableFunc("Arm64Cflags", func(ctx android.PackageVarContext) string { flags := arm64Cflags if ctx.Config().NoBionicPageSizeMacro() { @@ -109,25 +107,21 @@ func init() { return strings.Join(flags, " ") }) - exportedVars.ExportStringListStaticVariable("Arm64Cppflags", arm64Cppflags) + pctx.StaticVariable("Arm64Cppflags", strings.Join(arm64Cppflags, " ")) - exportedVars.ExportVariableReferenceDict("Arm64ArchVariantCflags", arm64ArchVariantCflagsVar) - exportedVars.ExportVariableReferenceDict("Arm64CpuVariantCflags", arm64CpuVariantCflagsVar) - exportedVars.ExportVariableReferenceDict("Arm64CpuVariantLdflags", arm64CpuVariantLdflags) + pctx.StaticVariable("Arm64Armv8ACflags", strings.Join(arm64ArchVariantCflags["armv8-a"], " ")) + pctx.StaticVariable("Arm64Armv8ABranchProtCflags", strings.Join(arm64ArchVariantCflags["armv8-a-branchprot"], " ")) + pctx.StaticVariable("Arm64Armv82ACflags", strings.Join(arm64ArchVariantCflags["armv8-2a"], " ")) + pctx.StaticVariable("Arm64Armv82ADotprodCflags", strings.Join(arm64ArchVariantCflags["armv8-2a-dotprod"], " ")) + pctx.StaticVariable("Arm64Armv9ACflags", strings.Join(arm64ArchVariantCflags["armv9-a"], " ")) - exportedVars.ExportStringListStaticVariable("Arm64Armv8ACflags", arm64ArchVariantCflags["armv8-a"]) - exportedVars.ExportStringListStaticVariable("Arm64Armv8ABranchProtCflags", arm64ArchVariantCflags["armv8-a-branchprot"]) - exportedVars.ExportStringListStaticVariable("Arm64Armv82ACflags", arm64ArchVariantCflags["armv8-2a"]) - exportedVars.ExportStringListStaticVariable("Arm64Armv82ADotprodCflags", arm64ArchVariantCflags["armv8-2a-dotprod"]) - exportedVars.ExportStringListStaticVariable("Arm64Armv9ACflags", arm64ArchVariantCflags["armv9-a"]) + pctx.StaticVariable("Arm64CortexA53Cflags", strings.Join(arm64CpuVariantCflags["cortex-a53"], " ")) + pctx.StaticVariable("Arm64CortexA55Cflags", strings.Join(arm64CpuVariantCflags["cortex-a55"], " ")) + pctx.StaticVariable("Arm64KryoCflags", strings.Join(arm64CpuVariantCflags["kryo"], " ")) + pctx.StaticVariable("Arm64ExynosM1Cflags", strings.Join(arm64CpuVariantCflags["exynos-m1"], " ")) + pctx.StaticVariable("Arm64ExynosM2Cflags", strings.Join(arm64CpuVariantCflags["exynos-m2"], " ")) - exportedVars.ExportStringListStaticVariable("Arm64CortexA53Cflags", arm64CpuVariantCflags["cortex-a53"]) - exportedVars.ExportStringListStaticVariable("Arm64CortexA55Cflags", arm64CpuVariantCflags["cortex-a55"]) - exportedVars.ExportStringListStaticVariable("Arm64KryoCflags", arm64CpuVariantCflags["kryo"]) - exportedVars.ExportStringListStaticVariable("Arm64ExynosM1Cflags", arm64CpuVariantCflags["exynos-m1"]) - exportedVars.ExportStringListStaticVariable("Arm64ExynosM2Cflags", arm64CpuVariantCflags["exynos-m2"]) - - exportedVars.ExportStringListStaticVariable("Arm64FixCortexA53Ldflags", []string{"-Wl,--fix-cortex-a53-843419"}) + pctx.StaticVariable("Arm64FixCortexA53Ldflags", "-Wl,--fix-cortex-a53-843419") } var ( diff --git a/cc/config/arm64_linux_host.go b/cc/config/arm64_linux_host.go index f7d190b0b..438e0e6b6 100644 --- a/cc/config/arm64_linux_host.go +++ b/cc/config/arm64_linux_host.go @@ -61,9 +61,9 @@ var ( ) func init() { - exportedVars.ExportStringListStaticVariable("LinuxBionicArm64Cflags", linuxCrossCflags) - exportedVars.ExportStringListStaticVariable("LinuxBionicArm64Ldflags", linuxCrossLdflags) - exportedVars.ExportStringListStaticVariable("LinuxBionicArm64Lldflags", linuxCrossLldflags) + pctx.StaticVariable("LinuxBionicArm64Cflags", strings.Join(linuxCrossCflags, " ")) + pctx.StaticVariable("LinuxBionicArm64Ldflags", strings.Join(linuxCrossLdflags, " ")) + pctx.StaticVariable("LinuxBionicArm64Lldflags", strings.Join(linuxCrossLldflags, " ")) } // toolchain config for ARM64 Linux CrossHost. Almost everything is the same as the ARM64 Android diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 3284e4b0a..3cb190966 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -35,7 +35,7 @@ var ( armCppflags = []string{ // Revert this after b/322359235 is fixed "-mllvm", "-enable-shrink-wrap=false", - } + } armLdflags = []string{ "-Wl,-m,armelf", @@ -185,43 +185,37 @@ const ( ) func init() { - // Just exported. Not created as a Ninja static variable. - exportedVars.ExportString("ArmClangTriple", clangTriple) + pctx.StaticVariable("ArmLdflags", strings.Join(armLdflags, " ")) + pctx.StaticVariable("ArmLldflags", strings.Join(armLldflags, " ")) - exportedVars.ExportStringListStaticVariable("ArmLdflags", armLdflags) - exportedVars.ExportStringListStaticVariable("ArmLldflags", armLldflags) - - exportedVars.ExportStringListStaticVariable("ArmFixCortexA8LdFlags", armFixCortexA8LdFlags) - exportedVars.ExportStringListStaticVariable("ArmNoFixCortexA8LdFlags", armNoFixCortexA8LdFlags) + pctx.StaticVariable("ArmFixCortexA8LdFlags", strings.Join(armFixCortexA8LdFlags, " ")) + pctx.StaticVariable("ArmNoFixCortexA8LdFlags", strings.Join(armNoFixCortexA8LdFlags, " ")) // Clang cflags - exportedVars.ExportStringListStaticVariable("ArmToolchainCflags", armToolchainCflags) - exportedVars.ExportStringListStaticVariable("ArmCflags", armCflags) - exportedVars.ExportStringListStaticVariable("ArmCppflags", armCppflags) + pctx.StaticVariable("ArmToolchainCflags", strings.Join(armToolchainCflags, " ")) + pctx.StaticVariable("ArmCflags", strings.Join(armCflags, " ")) + pctx.StaticVariable("ArmCppflags", strings.Join(armCppflags, " ")) // Clang ARM vs. Thumb instruction set cflags - exportedVars.ExportStringListStaticVariable("ArmArmCflags", armArmCflags) - exportedVars.ExportStringListStaticVariable("ArmThumbCflags", armThumbCflags) - - exportedVars.ExportVariableReferenceDict("ArmArchVariantCflags", armArchVariantCflagsVar) - exportedVars.ExportVariableReferenceDict("ArmCpuVariantCflags", armCpuVariantCflagsVar) + pctx.StaticVariable("ArmArmCflags", strings.Join(armArmCflags, " ")) + pctx.StaticVariable("ArmThumbCflags", strings.Join(armThumbCflags, " ")) // Clang arch variant cflags - exportedVars.ExportStringListStaticVariable("ArmArmv7ACflags", armArchVariantCflags["armv7-a"]) - exportedVars.ExportStringListStaticVariable("ArmArmv7ANeonCflags", armArchVariantCflags["armv7-a-neon"]) - exportedVars.ExportStringListStaticVariable("ArmArmv8ACflags", armArchVariantCflags["armv8-a"]) - exportedVars.ExportStringListStaticVariable("ArmArmv82ACflags", armArchVariantCflags["armv8-2a"]) + pctx.StaticVariable("ArmArmv7ACflags", strings.Join(armArchVariantCflags["armv7-a"], " ")) + pctx.StaticVariable("ArmArmv7ANeonCflags", strings.Join(armArchVariantCflags["armv7-a-neon"], " ")) + pctx.StaticVariable("ArmArmv8ACflags", strings.Join(armArchVariantCflags["armv8-a"], " ")) + pctx.StaticVariable("ArmArmv82ACflags", strings.Join(armArchVariantCflags["armv8-2a"], " ")) // Clang cpu variant cflags - exportedVars.ExportStringListStaticVariable("ArmGenericCflags", armCpuVariantCflags[""]) - exportedVars.ExportStringListStaticVariable("ArmCortexA7Cflags", armCpuVariantCflags["cortex-a7"]) - exportedVars.ExportStringListStaticVariable("ArmCortexA8Cflags", armCpuVariantCflags["cortex-a8"]) - exportedVars.ExportStringListStaticVariable("ArmCortexA15Cflags", armCpuVariantCflags["cortex-a15"]) - exportedVars.ExportStringListStaticVariable("ArmCortexA32Cflags", armCpuVariantCflags["cortex-a32"]) - exportedVars.ExportStringListStaticVariable("ArmCortexA53Cflags", armCpuVariantCflags["cortex-a53"]) - exportedVars.ExportStringListStaticVariable("ArmCortexA55Cflags", armCpuVariantCflags["cortex-a55"]) - exportedVars.ExportStringListStaticVariable("ArmKraitCflags", armCpuVariantCflags["krait"]) - exportedVars.ExportStringListStaticVariable("ArmKryoCflags", armCpuVariantCflags["kryo"]) + pctx.StaticVariable("ArmGenericCflags", strings.Join(armCpuVariantCflags[""], " ")) + pctx.StaticVariable("ArmCortexA7Cflags", strings.Join(armCpuVariantCflags["cortex-a7"], " ")) + pctx.StaticVariable("ArmCortexA8Cflags", strings.Join(armCpuVariantCflags["cortex-a8"], " ")) + pctx.StaticVariable("ArmCortexA15Cflags", strings.Join(armCpuVariantCflags["cortex-a15"], " ")) + pctx.StaticVariable("ArmCortexA32Cflags", strings.Join(armCpuVariantCflags["cortex-a32"], " ")) + pctx.StaticVariable("ArmCortexA53Cflags", strings.Join(armCpuVariantCflags["cortex-a53"], " ")) + pctx.StaticVariable("ArmCortexA55Cflags", strings.Join(armCpuVariantCflags["cortex-a55"], " ")) + pctx.StaticVariable("ArmKraitCflags", strings.Join(armCpuVariantCflags["krait"], " ")) + pctx.StaticVariable("ArmKryoCflags", strings.Join(armCpuVariantCflags["kryo"], " ")) } var ( diff --git a/cc/config/arm_linux_host.go b/cc/config/arm_linux_host.go index e21c60d63..e7c7bc466 100644 --- a/cc/config/arm_linux_host.go +++ b/cc/config/arm_linux_host.go @@ -14,7 +14,10 @@ package config -import "android/soong/android" +import ( + "android/soong/android" + "strings" +) var ( linuxArmCflags = []string{ @@ -39,15 +42,15 @@ var ( ) func init() { - exportedVars.ExportStringListStaticVariable("LinuxArmCflags", linuxArmCflags) - exportedVars.ExportStringListStaticVariable("LinuxArm64Cflags", linuxArm64Cflags) - exportedVars.ExportStringListStaticVariable("LinuxArmLdflags", linuxArmLdflags) - exportedVars.ExportStringListStaticVariable("LinuxArmLldflags", linuxArmLldflags) - exportedVars.ExportStringListStaticVariable("LinuxArm64Ldflags", linuxArm64Ldflags) - exportedVars.ExportStringListStaticVariable("LinuxArm64Lldflags", linuxArm64Lldflags) + pctx.StaticVariable("LinuxArmCflags", strings.Join(linuxArmCflags, " ")) + pctx.StaticVariable("LinuxArm64Cflags", strings.Join(linuxArm64Cflags, " ")) + pctx.StaticVariable("LinuxArmLdflags", strings.Join(linuxArmLdflags, " ")) + pctx.StaticVariable("LinuxArmLldflags", strings.Join(linuxArmLldflags, " ")) + pctx.StaticVariable("LinuxArm64Ldflags", strings.Join(linuxArm64Ldflags, " ")) + pctx.StaticVariable("LinuxArm64Lldflags", strings.Join(linuxArm64Lldflags, " ")) - exportedVars.ExportStringListStaticVariable("LinuxArmYasmFlags", []string{"-f elf32 -m arm"}) - exportedVars.ExportStringListStaticVariable("LinuxArm64YasmFlags", []string{"-f elf64 -m aarch64"}) + pctx.StaticVariable("LinuxArmYasmFlags", "-f elf32 -m arm") + pctx.StaticVariable("LinuxArm64YasmFlags", "-f elf64 -m aarch64") } diff --git a/cc/config/global.go b/cc/config/global.go index b21d56c2c..08fcb91fa 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -24,8 +24,7 @@ import ( ) var ( - pctx = android.NewPackageContext("android/soong/cc/config") - exportedVars = android.NewExportedVariables(pctx) + pctx = android.NewPackageContext("android/soong/cc/config") // Flags used by lots of devices. Putting them in package static variables // will save bytes in build.ninja so they aren't repeated for every file @@ -401,26 +400,19 @@ var ( VisibilityDefaultFlag = "-fvisibility=default" ) -func ExportStringList(name string, value []string) { - exportedVars.ExportStringList(name, value) -} - func init() { if runtime.GOOS == "linux" { commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=") } - exportedVars.ExportStringListStaticVariable("CommonGlobalConlyflags", commonGlobalConlyflags) - exportedVars.ExportStringListStaticVariable("CommonGlobalAsflags", commonGlobalAsflags) - exportedVars.ExportStringListStaticVariable("DeviceGlobalCppflags", deviceGlobalCppflags) - exportedVars.ExportStringListStaticVariable("DeviceGlobalLdflags", deviceGlobalLdflags) - exportedVars.ExportStringListStaticVariable("DeviceGlobalLldflags", deviceGlobalLldflags) - exportedVars.ExportStringListStaticVariable("HostGlobalCppflags", hostGlobalCppflags) - exportedVars.ExportStringListStaticVariable("HostGlobalLdflags", hostGlobalLdflags) - exportedVars.ExportStringListStaticVariable("HostGlobalLldflags", hostGlobalLldflags) - - // Export the static default CommonGlobalCflags to Bazel. - exportedVars.ExportStringList("CommonGlobalCflags", commonGlobalCflags) + pctx.StaticVariable("CommonGlobalConlyflags", strings.Join(commonGlobalConlyflags, " ")) + pctx.StaticVariable("CommonGlobalAsflags", strings.Join(commonGlobalAsflags, " ")) + pctx.StaticVariable("DeviceGlobalCppflags", strings.Join(deviceGlobalCppflags, " ")) + pctx.StaticVariable("DeviceGlobalLdflags", strings.Join(deviceGlobalLdflags, " ")) + pctx.StaticVariable("DeviceGlobalLldflags", strings.Join(deviceGlobalLldflags, " ")) + pctx.StaticVariable("HostGlobalCppflags", strings.Join(hostGlobalCppflags, " ")) + pctx.StaticVariable("HostGlobalLdflags", strings.Join(hostGlobalLdflags, " ")) + pctx.StaticVariable("HostGlobalLldflags", strings.Join(hostGlobalLldflags, " ")) pctx.VariableFunc("CommonGlobalCflags", func(ctx android.PackageVarContext) string { flags := slices.Clone(commonGlobalCflags) @@ -467,16 +459,10 @@ func init() { return strings.Join(flags, " ") }) - // Export the static default DeviceGlobalCflags to Bazel. - // TODO(187086342): handle cflags that are set in VariableFuncs. - exportedVars.ExportStringList("DeviceGlobalCflags", deviceGlobalCflags) - pctx.VariableFunc("DeviceGlobalCflags", func(ctx android.PackageVarContext) string { return strings.Join(deviceGlobalCflags, " ") }) - // Export the static default NoOverrideGlobalCflags to Bazel. - exportedVars.ExportStringList("NoOverrideGlobalCflags", noOverrideGlobalCflags) pctx.VariableFunc("NoOverrideGlobalCflags", func(ctx android.PackageVarContext) string { flags := noOverrideGlobalCflags if ctx.Config().IsEnvTrue("LLVM_NEXT") { @@ -486,21 +472,11 @@ func init() { return strings.Join(flags, " ") }) - exportedVars.ExportStringListStaticVariable("NoOverride64GlobalCflags", noOverride64GlobalCflags) - exportedVars.ExportStringListStaticVariable("HostGlobalCflags", hostGlobalCflags) - exportedVars.ExportStringListStaticVariable("NoOverrideExternalGlobalCflags", noOverrideExternalGlobalCflags) - exportedVars.ExportStringListStaticVariable("CommonGlobalCppflags", commonGlobalCppflags) - exportedVars.ExportStringListStaticVariable("ExternalCflags", extraExternalCflags) - - exportedVars.ExportString("CStdVersion", CStdVersion) - exportedVars.ExportString("CppStdVersion", CppStdVersion) - exportedVars.ExportString("ExperimentalCStdVersion", ExperimentalCStdVersion) - exportedVars.ExportString("ExperimentalCppStdVersion", ExperimentalCppStdVersion) - - exportedVars.ExportString("VersionScriptFlagPrefix", VersionScriptFlagPrefix) - - exportedVars.ExportString("VisibilityHiddenFlag", VisibilityHiddenFlag) - exportedVars.ExportString("VisibilityDefaultFlag", VisibilityDefaultFlag) + pctx.StaticVariable("NoOverride64GlobalCflags", strings.Join(noOverride64GlobalCflags, " ")) + pctx.StaticVariable("HostGlobalCflags", strings.Join(hostGlobalCflags, " ")) + pctx.StaticVariable("NoOverrideExternalGlobalCflags", strings.Join(noOverrideExternalGlobalCflags, " ")) + pctx.StaticVariable("CommonGlobalCppflags", strings.Join(commonGlobalCppflags, " ")) + pctx.StaticVariable("ExternalCflags", strings.Join(extraExternalCflags, " ")) // Everything in these lists is a crime against abstraction and dependency tracking. // Do not add anything to this list. @@ -515,11 +491,10 @@ func init() { "frameworks/native/opengl/include", "frameworks/av/include", } - exportedVars.ExportStringList("CommonGlobalIncludes", commonGlobalIncludes) pctx.PrefixedExistentPathsForSourcesVariable("CommonGlobalIncludes", "-I", commonGlobalIncludes) - exportedVars.ExportStringStaticVariable("CLANG_DEFAULT_VERSION", ClangDefaultVersion) - exportedVars.ExportStringStaticVariable("CLANG_DEFAULT_SHORT_VERSION", ClangDefaultShortVersion) + pctx.StaticVariable("CLANG_DEFAULT_VERSION", ClangDefaultVersion) + pctx.StaticVariable("CLANG_DEFAULT_SHORT_VERSION", ClangDefaultShortVersion) pctx.StaticVariableWithEnvOverride("ClangBase", "LLVM_PREBUILTS_BASE", ClangDefaultBase) pctx.StaticVariableWithEnvOverride("ClangVersion", "LLVM_PREBUILTS_VERSION", ClangDefaultVersion) @@ -529,7 +504,7 @@ func init() { pctx.StaticVariableWithEnvOverride("ClangShortVersion", "LLVM_RELEASE_VERSION", ClangDefaultShortVersion) pctx.StaticVariable("ClangAsanLibDir", "${ClangBase}/linux-x86/${ClangVersion}/lib/clang/${ClangShortVersion}/lib/linux") - exportedVars.ExportStringListStaticVariable("WarningAllowedProjects", WarningAllowedProjects) + pctx.StaticVariable("WarningAllowedProjects", strings.Join(WarningAllowedProjects, " ")) // These are tied to the version of LLVM directly in external/llvm, so they might trail the host prebuilts // being used for the rest of the build process. @@ -544,7 +519,6 @@ func init() { "frameworks/rs/script_api/include", } pctx.PrefixedExistentPathsForSourcesVariable("RsGlobalIncludes", "-I", rsGlobalIncludes) - exportedVars.ExportStringList("RsGlobalIncludes", rsGlobalIncludes) pctx.VariableFunc("CcWrapper", func(ctx android.PackageVarContext) string { if override := ctx.Config().Getenv("CC_WRAPPER"); override != "" { @@ -562,7 +536,7 @@ func init() { pctx.StaticVariableWithEnvOverride("REAbiLinkerExecStrategy", "RBE_ABI_LINKER_EXEC_STRATEGY", remoteexec.LocalExecStrategy) } -var HostPrebuiltTag = exportedVars.ExportVariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS) +var HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS) func ClangPath(ctx android.PathContext, file string) android.SourcePath { type clangToolKey string diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go index 47f0de1c8..724676ae6 100644 --- a/cc/config/riscv64_device.go +++ b/cc/config/riscv64_device.go @@ -62,15 +62,11 @@ const () func init() { - exportedVars.ExportStringListStaticVariable("Riscv64Ldflags", riscv64Ldflags) - exportedVars.ExportStringListStaticVariable("Riscv64Lldflags", riscv64Lldflags) + pctx.StaticVariable("Riscv64Ldflags", strings.Join(riscv64Ldflags, " ")) + pctx.StaticVariable("Riscv64Lldflags", strings.Join(riscv64Lldflags, " ")) - exportedVars.ExportStringListStaticVariable("Riscv64Cflags", riscv64Cflags) - exportedVars.ExportStringListStaticVariable("Riscv64Cppflags", riscv64Cppflags) - - exportedVars.ExportVariableReferenceDict("Riscv64ArchVariantCflags", riscv64ArchVariantCflagsVar) - exportedVars.ExportVariableReferenceDict("Riscv64CpuVariantCflags", riscv64CpuVariantCflagsVar) - exportedVars.ExportVariableReferenceDict("Riscv64CpuVariantLdflags", riscv64CpuVariantLdflags) + pctx.StaticVariable("Riscv64Cflags", strings.Join(riscv64Cflags, " ")) + pctx.StaticVariable("Riscv64Cppflags", strings.Join(riscv64Cppflags, " ")) } var ( diff --git a/cc/config/tidy.go b/cc/config/tidy.go index b40557a29..46d5d909e 100644 --- a/cc/config/tidy.go +++ b/cc/config/tidy.go @@ -87,7 +87,7 @@ func init() { // The global default tidy checks should include clang-tidy // default checks and tested groups, but exclude known noisy checks. // See https://clang.llvm.org/extra/clang-tidy/checks/list.html - exportedVars.ExportVariableConfigMethod("TidyDefaultGlobalChecks", func(config android.Config) string { + pctx.VariableConfigMethod("TidyDefaultGlobalChecks", func(config android.Config) string { if override := config.Getenv("DEFAULT_GLOBAL_TIDY_CHECKS"); override != "" { return override } @@ -149,7 +149,7 @@ func init() { // There are too many clang-tidy warnings in external and vendor projects, so we only // enable some google checks for these projects. Users can add more checks locally with the // "tidy_checks" list in .bp files, or the "Checks" list in .clang-tidy config files. - exportedVars.ExportVariableConfigMethod("TidyExternalVendorChecks", func(config android.Config) string { + pctx.VariableConfigMethod("TidyExternalVendorChecks", func(config android.Config) string { if override := config.Getenv("DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS"); override != "" { return override } @@ -163,25 +163,21 @@ func init() { }, ",") }) - exportedVars.ExportVariableFuncVariable("TidyGlobalNoChecks", func() string { - return strings.Join(globalNoCheckList, ",") - }) + pctx.StaticVariable("TidyGlobalNoChecks", strings.Join(globalNoCheckList, ",")) - exportedVars.ExportVariableFuncVariable("TidyGlobalNoErrorChecks", func() string { - return strings.Join(globalNoErrorCheckList, ",") - }) + pctx.StaticVariable("TidyGlobalNoErrorChecks", strings.Join(globalNoErrorCheckList, ",")) - exportedVars.ExportStringListStaticVariable("TidyExtraArgFlags", extraArgFlags) + pctx.StaticVariable("TidyExtraArgFlags", strings.Join(extraArgFlags, " ")) // To reduce duplicate warnings from the same header files, // header-filter will contain only the module directory and // those specified by DEFAULT_TIDY_HEADER_DIRS. - exportedVars.ExportVariableConfigMethod("TidyDefaultHeaderDirs", func(config android.Config) string { + pctx.VariableConfigMethod("TidyDefaultHeaderDirs", func(config android.Config) string { return config.Getenv("DEFAULT_TIDY_HEADER_DIRS") }) // Use WTIH_TIDY_FLAGS to pass extra global default clang-tidy flags. - exportedVars.ExportVariableConfigMethod("TidyWithTidyFlags", func(config android.Config) string { + pctx.VariableConfigMethod("TidyWithTidyFlags", func(config android.Config) string { return config.Getenv("WITH_TIDY_FLAGS") }) } diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go index 71e98fe48..7dc990b71 100644 --- a/cc/config/toolchain.go +++ b/cc/config/toolchain.go @@ -16,14 +16,15 @@ package config import ( "fmt" + "strings" "android/soong/android" ) func init() { - exportedVars.ExportStringListStaticVariable("DarwinAvailableLibraries", darwinAvailableLibraries) - exportedVars.ExportStringListStaticVariable("LinuxAvailableLibraries", linuxAvailableLibraries) - exportedVars.ExportStringListStaticVariable("WindowsAvailableLibraries", windowsAvailableLibraries) + pctx.StaticVariable("DarwinAvailableLibraries", strings.Join(darwinAvailableLibraries, " ")) + pctx.StaticVariable("LinuxAvailableLibraries", strings.Join(linuxAvailableLibraries, " ")) + pctx.StaticVariable("WindowsAvailableLibraries", strings.Join(windowsAvailableLibraries, " ")) } type toolchainFactory func(arch android.Arch) Toolchain diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index ca2c2b7b6..171ab4f22 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -97,11 +97,10 @@ var ( ) func init() { - exportedVars.ExportStringListStaticVariable("X86_64ToolchainCflags", []string{"-m64"}) - exportedVars.ExportStringListStaticVariable("X86_64ToolchainLdflags", []string{"-m64"}) + pctx.StaticVariable("X86_64ToolchainCflags", "-m64") + pctx.StaticVariable("X86_64ToolchainLdflags", "-m64") - exportedVars.ExportStringListStaticVariable("X86_64Ldflags", x86_64Ldflags) - exportedVars.ExportStringList("X86_64Lldflags", X86_64Lldflags) + pctx.StaticVariable("X86_64Ldflags", strings.Join(x86_64Ldflags, " ")) pctx.VariableFunc("X86_64Lldflags", func(ctx android.PackageVarContext) string { maxPageSizeFlag := "-Wl,-z,max-page-size=" + ctx.Config().MaxPageSizeSupported() flags := append(X86_64Lldflags, maxPageSizeFlag) @@ -109,7 +108,6 @@ func init() { }) // Clang cflags - exportedVars.ExportStringList("X86_64Cflags", x86_64Cflags) pctx.VariableFunc("X86_64Cflags", func(ctx android.PackageVarContext) string { flags := x86_64Cflags if ctx.Config().NoBionicPageSizeMacro() { @@ -118,18 +116,10 @@ func init() { return strings.Join(flags, " ") }) - exportedVars.ExportStringListStaticVariable("X86_64Cppflags", x86_64Cppflags) + pctx.StaticVariable("X86_64Cppflags", strings.Join(x86_64Cppflags, " ")) // Yasm flags - exportedVars.ExportStringListStaticVariable("X86_64YasmFlags", []string{ - "-f elf64", - "-m amd64", - }) - - // Extended cflags - - exportedVars.ExportStringListDict("X86_64ArchVariantCflags", x86_64ArchVariantCflags) - exportedVars.ExportStringListDict("X86_64ArchFeatureCflags", x86_64ArchFeatureCflags) + pctx.StaticVariable("X86_64YasmFlags", "-f elf64 -m amd64") // Architecture variant cflags for variant, cflags := range x86_64ArchVariantCflags { diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go index 60b833906..4b0041c9e 100644 --- a/cc/config/x86_device.go +++ b/cc/config/x86_device.go @@ -101,25 +101,18 @@ var ( ) func init() { - exportedVars.ExportStringListStaticVariable("X86ToolchainCflags", []string{"-m32"}) - exportedVars.ExportStringListStaticVariable("X86ToolchainLdflags", []string{"-m32"}) + pctx.StaticVariable("X86ToolchainCflags", "-m32") + pctx.StaticVariable("X86ToolchainLdflags", "-m32") - exportedVars.ExportStringListStaticVariable("X86Ldflags", x86Ldflags) - exportedVars.ExportStringListStaticVariable("X86Lldflags", x86Ldflags) + pctx.StaticVariable("X86Ldflags", strings.Join(x86Ldflags, " ")) + pctx.StaticVariable("X86Lldflags", strings.Join(x86Ldflags, " ")) // Clang cflags - exportedVars.ExportStringListStaticVariable("X86Cflags", x86Cflags) - exportedVars.ExportStringListStaticVariable("X86Cppflags", x86Cppflags) + pctx.StaticVariable("X86Cflags", strings.Join(x86Cflags, " ")) + pctx.StaticVariable("X86Cppflags", strings.Join(x86Cppflags, " ")) // Yasm flags - exportedVars.ExportStringListStaticVariable("X86YasmFlags", []string{ - "-f elf32", - "-m x86", - }) - - // Extended cflags - exportedVars.ExportStringListDict("X86ArchVariantCflags", x86ArchVariantCflags) - exportedVars.ExportStringListDict("X86ArchFeatureCflags", x86ArchFeatureCflags) + pctx.StaticVariable("X86YasmFlags", "-f elf32 -m x86") // Architecture variant cflags for variant, cflags := range x86ArchVariantCflags { diff --git a/cc/config/x86_linux_bionic_host.go b/cc/config/x86_linux_bionic_host.go index 99d4ebb7f..515cb2104 100644 --- a/cc/config/x86_linux_bionic_host.go +++ b/cc/config/x86_linux_bionic_host.go @@ -16,6 +16,7 @@ package config import ( "android/soong/android" + "strings" ) var ( @@ -72,13 +73,13 @@ const ( ) func init() { - exportedVars.ExportStringListStaticVariable("LinuxBionicCflags", linuxBionicCflags) - exportedVars.ExportStringListStaticVariable("LinuxBionicLdflags", linuxBionicLdflags) - exportedVars.ExportStringListStaticVariable("LinuxBionicLldflags", linuxBionicLldflags) + pctx.StaticVariable("LinuxBionicCflags", strings.Join(linuxBionicCflags, " ")) + pctx.StaticVariable("LinuxBionicLdflags", strings.Join(linuxBionicLdflags, " ")) + pctx.StaticVariable("LinuxBionicLldflags", strings.Join(linuxBionicLldflags, " ")) // Use the device gcc toolchain for now - exportedVars.ExportStringStaticVariable("LinuxBionicGccVersion", x86_64GccVersion) - exportedVars.ExportSourcePathVariable("LinuxBionicGccRoot", + pctx.StaticVariable("LinuxBionicGccVersion", x86_64GccVersion) + pctx.SourcePathVariable("LinuxBionicGccRoot", "prebuilts/gcc/${HostPrebuiltTag}/x86/x86_64-linux-android-${LinuxBionicGccVersion}") } diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go index 9bc54d6b6..7f22377bf 100644 --- a/cc/config/x86_linux_host.go +++ b/cc/config/x86_linux_host.go @@ -120,40 +120,40 @@ const ( ) func init() { - exportedVars.ExportStringStaticVariable("LinuxGccVersion", linuxGccVersion) - exportedVars.ExportStringStaticVariable("LinuxGlibcVersion", linuxGlibcVersion) + pctx.StaticVariable("LinuxGccVersion", linuxGccVersion) + pctx.StaticVariable("LinuxGlibcVersion", linuxGlibcVersion) // Most places use the full GCC version. A few only use up to the first two numbers. if p := strings.Split(linuxGccVersion, "."); len(p) > 2 { - exportedVars.ExportStringStaticVariable("ShortLinuxGccVersion", strings.Join(p[:2], ".")) + pctx.StaticVariable("ShortLinuxGccVersion", strings.Join(p[:2], ".")) } else { - exportedVars.ExportStringStaticVariable("ShortLinuxGccVersion", linuxGccVersion) + pctx.StaticVariable("ShortLinuxGccVersion", linuxGccVersion) } - exportedVars.ExportSourcePathVariable("LinuxGccRoot", + pctx.SourcePathVariable("LinuxGccRoot", "prebuilts/gcc/linux-x86/host/x86_64-linux-glibc${LinuxGlibcVersion}-${ShortLinuxGccVersion}") - exportedVars.ExportStringListStaticVariable("LinuxGccTriple", []string{"x86_64-linux"}) + pctx.StaticVariable("LinuxGccTriple", "x86_64-linux") - exportedVars.ExportStringListStaticVariable("LinuxCflags", linuxCflags) - exportedVars.ExportStringListStaticVariable("LinuxLdflags", linuxLdflags) - exportedVars.ExportStringListStaticVariable("LinuxLldflags", linuxLldflags) - exportedVars.ExportStringListStaticVariable("LinuxGlibcCflags", linuxGlibcCflags) - exportedVars.ExportStringListStaticVariable("LinuxGlibcLdflags", linuxGlibcLdflags) - exportedVars.ExportStringListStaticVariable("LinuxGlibcLldflags", linuxGlibcLdflags) - exportedVars.ExportStringListStaticVariable("LinuxMuslCflags", linuxMuslCflags) - exportedVars.ExportStringListStaticVariable("LinuxMuslLdflags", linuxMuslLdflags) - exportedVars.ExportStringListStaticVariable("LinuxMuslLldflags", linuxMuslLdflags) + pctx.StaticVariable("LinuxCflags", strings.Join(linuxCflags, " ")) + pctx.StaticVariable("LinuxLdflags", strings.Join(linuxLdflags, " ")) + pctx.StaticVariable("LinuxLldflags", strings.Join(linuxLldflags, " ")) + pctx.StaticVariable("LinuxGlibcCflags", strings.Join(linuxGlibcCflags, " ")) + pctx.StaticVariable("LinuxGlibcLdflags", strings.Join(linuxGlibcLdflags, " ")) + pctx.StaticVariable("LinuxGlibcLldflags", strings.Join(linuxGlibcLdflags, " ")) + pctx.StaticVariable("LinuxMuslCflags", strings.Join(linuxMuslCflags, " ")) + pctx.StaticVariable("LinuxMuslLdflags", strings.Join(linuxMuslLdflags, " ")) + pctx.StaticVariable("LinuxMuslLldflags", strings.Join(linuxMuslLdflags, " ")) - exportedVars.ExportStringListStaticVariable("LinuxX86Cflags", linuxX86Cflags) - exportedVars.ExportStringListStaticVariable("LinuxX8664Cflags", linuxX8664Cflags) - exportedVars.ExportStringListStaticVariable("LinuxX86Ldflags", linuxX86Ldflags) - exportedVars.ExportStringListStaticVariable("LinuxX86Lldflags", linuxX86Ldflags) - exportedVars.ExportStringListStaticVariable("LinuxX8664Ldflags", linuxX8664Ldflags) - exportedVars.ExportStringListStaticVariable("LinuxX8664Lldflags", linuxX8664Ldflags) + pctx.StaticVariable("LinuxX86Cflags", strings.Join(linuxX86Cflags, " ")) + pctx.StaticVariable("LinuxX8664Cflags", strings.Join(linuxX8664Cflags, " ")) + pctx.StaticVariable("LinuxX86Ldflags", strings.Join(linuxX86Ldflags, " ")) + pctx.StaticVariable("LinuxX86Lldflags", strings.Join(linuxX86Ldflags, " ")) + pctx.StaticVariable("LinuxX8664Ldflags", strings.Join(linuxX8664Ldflags, " ")) + pctx.StaticVariable("LinuxX8664Lldflags", strings.Join(linuxX8664Ldflags, " ")) // Yasm flags - exportedVars.ExportStringListStaticVariable("LinuxX86YasmFlags", []string{"-f elf32 -m x86"}) - exportedVars.ExportStringListStaticVariable("LinuxX8664YasmFlags", []string{"-f elf64 -m amd64"}) + pctx.StaticVariable("LinuxX86YasmFlags", "-f elf32 -m x86") + pctx.StaticVariable("LinuxX8664YasmFlags", "-f elf64 -m amd64") } type toolchainLinux struct { diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 39dd41523..25231fdf5 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -225,7 +225,7 @@ var stubLibraryCompilerFlags = []string{ } func init() { - config.ExportStringList("StubLibraryCompilerFlags", stubLibraryCompilerFlags) + pctx.StaticVariable("StubLibraryCompilerFlags", strings.Join(stubLibraryCompilerFlags, " ")) } func addStubLibraryCompilerFlags(flags Flags) Flags { diff --git a/cc/sanitize.go b/cc/sanitize.go index a2c9c58eb..37b3e8521 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -402,30 +402,8 @@ func (t libraryDependencyTag) SkipApexAllowedDependenciesCheck() bool { var _ android.SkipApexAllowedDependenciesCheck = (*libraryDependencyTag)(nil) -var exportedVars = android.NewExportedVariables(pctx) - func init() { - exportedVars.ExportStringListStaticVariable("HostOnlySanitizeFlags", hostOnlySanitizeFlags) - exportedVars.ExportStringList("DeviceOnlySanitizeFlags", deviceOnlySanitizeFlags) - - exportedVars.ExportStringList("MinimalRuntimeFlags", minimalRuntimeFlags) - - // Leave out "-flto" from the slices exported to bazel, as we will use the - // dedicated LTO feature for this. For C Flags and Linker Flags, also leave - // out the cross DSO flag which will be added separately under the correct conditions. - exportedVars.ExportStringList("CfiCFlags", append(cfiCflags[2:], cfiEnableFlag)) - exportedVars.ExportStringList("CfiLdFlags", cfiLdflags[2:]) - exportedVars.ExportStringList("CfiAsFlags", cfiAsflags[1:]) - - exportedVars.ExportString("SanitizeIgnorelistPrefix", sanitizeIgnorelistPrefix) - exportedVars.ExportString("CfiCrossDsoFlag", cfiCrossDsoFlag) - exportedVars.ExportString("CfiBlocklistPath", cfiBlocklistPath) - exportedVars.ExportString("CfiBlocklistFilename", cfiBlocklistFilename) - exportedVars.ExportString("CfiExportsMapPath", cfiExportsMapPath) - exportedVars.ExportString("CfiExportsMapFilename", cfiExportsMapFilename) - exportedVars.ExportString("CfiAssemblySupportFlag", cfiAssemblySupportFlag) - - exportedVars.ExportString("NoSanitizeLinkRuntimeFlag", noSanitizeLinkRuntimeFlag) + pctx.StaticVariable("HostOnlySanitizeFlags", strings.Join(hostOnlySanitizeFlags, " ")) android.RegisterMakeVarsProvider(pctx, cfiMakeVarsProvider) android.RegisterMakeVarsProvider(pctx, hwasanMakeVarsProvider) diff --git a/java/config/config.go b/java/config/config.go index d720046a1..2bb50f62a 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -26,8 +26,7 @@ import ( ) var ( - pctx = android.NewPackageContext("android/soong/java/config") - exportedVars = android.NewExportedVariables(pctx) + pctx = android.NewPackageContext("android/soong/java/config") LegacyCorePlatformBootclasspathLibraries = []string{"legacy.core.platform.api.stubs", "core-lambda-stubs"} LegacyCorePlatformSystemModules = "legacy-core-platform-api-stubs-system-modules" @@ -79,30 +78,30 @@ var ( func init() { pctx.Import("github.com/google/blueprint/bootstrap") - exportedVars.ExportStringStaticVariable("JavacHeapSize", "4096M") - exportedVars.ExportStringStaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}") + pctx.StaticVariable("JavacHeapSize", "4096M") + pctx.StaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}") // ErrorProne can use significantly more memory than javac alone, give it a higher heap // size (b/221480398). - exportedVars.ExportStringStaticVariable("ErrorProneHeapSize", "8192M") - exportedVars.ExportStringStaticVariable("ErrorProneHeapFlags", "-J-Xmx${ErrorProneHeapSize}") + pctx.StaticVariable("ErrorProneHeapSize", "8192M") + pctx.StaticVariable("ErrorProneHeapFlags", "-J-Xmx${ErrorProneHeapSize}") // D8 invocations are shorter lived, so we restrict their JIT tiering relative to R8. // Note that the `-JXX` prefix syntax is specific to the R8/D8 invocation wrappers. - exportedVars.ExportStringListStaticVariable("D8Flags", append([]string{ + pctx.StaticVariable("D8Flags", strings.Join(append([]string{ "-JXmx4096M", "-JXX:+TieredCompilation", "-JXX:TieredStopAtLevel=1", "-JDcom.android.tools.r8.emitRecordAnnotationsInDex", "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex", - }, dexerJavaVmFlagsList...)) - exportedVars.ExportStringListStaticVariable("R8Flags", append([]string{ + }, dexerJavaVmFlagsList...), " ")) + pctx.StaticVariable("R8Flags", strings.Join(append([]string{ "-JXmx4096M", "-JDcom.android.tools.r8.emitRecordAnnotationsInDex", "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex", - }, dexerJavaVmFlagsList...)) + }, dexerJavaVmFlagsList...), " ")) - exportedVars.ExportStringListStaticVariable("CommonJdkFlags", []string{ + pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{ `-Xmaxerrs 9999999`, `-encoding UTF-8`, `-sourcepath ""`, @@ -116,10 +115,10 @@ func init() { // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9 `-XDstringConcat=inline`, - }) + }, " ")) - exportedVars.ExportStringListStaticVariable("JavaVmFlags", javaVmFlagsList) - exportedVars.ExportStringListStaticVariable("JavacVmFlags", javacVmFlagsList) + pctx.StaticVariable("JavaVmFlags", strings.Join(javaVmFlagsList, " ")) + pctx.StaticVariable("JavacVmFlags", strings.Join(javacVmFlagsList, " ")) pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS) diff --git a/java/config/droidstubs.go b/java/config/droidstubs.go index 39eec444c..04a3f96b9 100644 --- a/java/config/droidstubs.go +++ b/java/config/droidstubs.go @@ -58,11 +58,7 @@ const ( ) func init() { - exportedVars.ExportStringList("MetalavaFlags", metalavaFlags) + pctx.StaticVariable("MetalavaAnnotationsFlags", strings.Join(metalavaAnnotationsFlags, " ")) - exportedVars.ExportString("MetalavaAddOpens", MetalavaAddOpens) - - exportedVars.ExportStringListStaticVariable("MetalavaAnnotationsFlags", metalavaAnnotationsFlags) - - exportedVars.ExportStringListStaticVariable("MetalavaAnnotationWarningsFlags", metalavaAnnotationsWarningsFlags) + pctx.StaticVariable("MetalavaAnnotationWarningsFlags", strings.Join(metalavaAnnotationsWarningsFlags, " ")) } diff --git a/java/config/error_prone.go b/java/config/error_prone.go index 5f853c812..767164f70 100644 --- a/java/config/error_prone.go +++ b/java/config/error_prone.go @@ -15,6 +15,7 @@ package config import ( + "android/soong/android" "strings" ) @@ -29,23 +30,23 @@ var ( ) // Wrapper that grabs value of val late so it can be initialized by a later module's init function -func errorProneVar(val *[]string, sep string) func() string { - return func() string { +func errorProneVar(val *[]string, sep string) func(android.PackageVarContext) string { + return func(android.PackageVarContext) string { return strings.Join(*val, sep) } } func init() { - exportedVars.ExportVariableFuncVariable("ErrorProneClasspath", errorProneVar(&ErrorProneClasspath, ":")) - exportedVars.ExportVariableFuncVariable("ErrorProneChecksError", errorProneVar(&ErrorProneChecksError, " ")) - exportedVars.ExportVariableFuncVariable("ErrorProneChecksWarning", errorProneVar(&ErrorProneChecksWarning, " ")) - exportedVars.ExportVariableFuncVariable("ErrorProneChecksDefaultDisabled", errorProneVar(&ErrorProneChecksDefaultDisabled, " ")) - exportedVars.ExportVariableFuncVariable("ErrorProneChecksOff", errorProneVar(&ErrorProneChecksOff, " ")) - exportedVars.ExportVariableFuncVariable("ErrorProneFlags", errorProneVar(&ErrorProneFlags, " ")) - exportedVars.ExportStringListStaticVariable("ErrorProneChecks", []string{ + pctx.VariableFunc("ErrorProneClasspath", errorProneVar(&ErrorProneClasspath, ":")) + pctx.VariableFunc("ErrorProneChecksError", errorProneVar(&ErrorProneChecksError, " ")) + pctx.VariableFunc("ErrorProneChecksWarning", errorProneVar(&ErrorProneChecksWarning, " ")) + pctx.VariableFunc("ErrorProneChecksDefaultDisabled", errorProneVar(&ErrorProneChecksDefaultDisabled, " ")) + pctx.VariableFunc("ErrorProneChecksOff", errorProneVar(&ErrorProneChecksOff, " ")) + pctx.VariableFunc("ErrorProneFlags", errorProneVar(&ErrorProneFlags, " ")) + pctx.StaticVariable("ErrorProneChecks", strings.Join([]string{ "${ErrorProneChecksOff}", "${ErrorProneChecksError}", "${ErrorProneChecksWarning}", "${ErrorProneChecksDefaultDisabled}", - }) + }, " ")) } diff --git a/rust/config/arm64_device.go b/rust/config/arm64_device.go index 6c021c7ae..9850570c2 100644 --- a/rust/config/arm64_device.go +++ b/rust/config/arm64_device.go @@ -54,7 +54,7 @@ func init() { strings.Join(rustFlags, " ")) } - ExportedVars.ExportStringListStaticVariable("DEVICE_ARM64_RUSTC_FLAGS", Arm64RustFlags) + pctx.StaticVariable("DEVICE_ARM64_RUSTC_FLAGS", strings.Join(Arm64RustFlags, " ")) } type toolchainArm64 struct { diff --git a/rust/config/arm_device.go b/rust/config/arm_device.go index a5f4afb92..5394e8a09 100644 --- a/rust/config/arm_device.go +++ b/rust/config/arm_device.go @@ -44,7 +44,7 @@ func init() { strings.Join(rustFlags, " ")) } - ExportedVars.ExportStringListStaticVariable("DEVICE_ARM_RUSTC_FLAGS", ArmRustFlags) + pctx.StaticVariable("DEVICE_ARM_RUSTC_FLAGS", strings.Join(ArmRustFlags, " ")) } type toolchainArm struct { diff --git a/rust/config/global.go b/rust/config/global.go index e28dbaaea..23230492f 100644 --- a/rust/config/global.go +++ b/rust/config/global.go @@ -22,8 +22,7 @@ import ( ) var ( - pctx = android.NewPackageContext("android/soong/rust/config") - ExportedVars = android.NewExportedVariables(pctx) + pctx = android.NewPackageContext("android/soong/rust/config") RustDefaultVersion = "1.76.0" RustDefaultBase = "prebuilts/rust/" @@ -112,17 +111,17 @@ func init() { pctx.StaticVariable("DeviceGlobalLinkFlags", strings.Join(deviceGlobalLinkFlags, " ")) - ExportedVars.ExportStringStaticVariable("RUST_DEFAULT_VERSION", RustDefaultVersion) - ExportedVars.ExportStringListStaticVariable("GLOBAL_RUSTC_FLAGS", GlobalRustFlags) - ExportedVars.ExportStringListStaticVariable("LINUX_HOST_GLOBAL_LINK_FLAGS", LinuxHostGlobalLinkFlags) + pctx.StaticVariable("RUST_DEFAULT_VERSION", RustDefaultVersion) + pctx.StaticVariable("GLOBAL_RUSTC_FLAGS", strings.Join(GlobalRustFlags, " ")) + pctx.StaticVariable("LINUX_HOST_GLOBAL_LINK_FLAGS", strings.Join(LinuxHostGlobalLinkFlags, " ")) - ExportedVars.ExportStringListStaticVariable("DEVICE_GLOBAL_RUSTC_FLAGS", deviceGlobalRustFlags) - ExportedVars.ExportStringListStaticVariable("DEVICE_GLOBAL_LINK_FLAGS", - android.RemoveListFromList(deviceGlobalLinkFlags, []string{ + pctx.StaticVariable("DEVICE_GLOBAL_RUSTC_FLAGS", strings.Join(deviceGlobalRustFlags, " ")) + pctx.StaticVariable("DEVICE_GLOBAL_LINK_FLAGS", + strings.Join(android.RemoveListFromList(deviceGlobalLinkFlags, []string{ // The cc_config flags are retrieved from cc_toolchain by rust rules. "${cc_config.DeviceGlobalLldflags}", "-B${cc_config.ClangBin}", - })) + }), " ")) } func HostPrebuiltTag(config android.Config) string { diff --git a/rust/config/x86_64_device.go b/rust/config/x86_64_device.go index 49f7c772e..fee1923b0 100644 --- a/rust/config/x86_64_device.go +++ b/rust/config/x86_64_device.go @@ -54,7 +54,7 @@ func init() { pctx.StaticVariable("X86_64"+variant+"VariantRustFlags", strings.Join(rustFlags, " ")) } - ExportedVars.ExportStringListStaticVariable("DEVICE_X86_64_RUSTC_FLAGS", x86_64RustFlags) + pctx.StaticVariable("DEVICE_X86_64_RUSTC_FLAGS", strings.Join(x86_64RustFlags, " ")) } type toolchainX86_64 struct { diff --git a/rust/config/x86_device.go b/rust/config/x86_device.go index 2a57e73bb..5d9d88aef 100644 --- a/rust/config/x86_device.go +++ b/rust/config/x86_device.go @@ -56,7 +56,7 @@ func init() { strings.Join(rustFlags, " ")) } - ExportedVars.ExportStringListStaticVariable("DEVICE_X86_RUSTC_FLAGS", x86RustFlags) + pctx.StaticVariable("DEVICE_X86_RUSTC_FLAGS", strings.Join(x86RustFlags, " ")) } type toolchainX86 struct {