| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 1 | // Copyright 2017 Google Inc. All rights reserved. | 
|  | 2 | // | 
|  | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | // you may not use this file except in compliance with the License. | 
|  | 5 | // You may obtain a copy of the License at | 
|  | 6 | // | 
|  | 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | // | 
|  | 9 | // Unless required by applicable law or agreed to in writing, software | 
|  | 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | // See the License for the specific language governing permissions and | 
|  | 13 | // limitations under the License. | 
|  | 14 |  | 
|  | 15 | package build | 
|  | 16 |  | 
|  | 17 | import ( | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 18 | "bytes" | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 19 | "fmt" | 
| Dan Willemsen | 4e2456b | 2019-10-03 16:45:58 -0700 | [diff] [blame] | 20 | "io/ioutil" | 
|  | 21 | "os" | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 22 | "strings" | 
| Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 23 |  | 
| Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 24 | "android/soong/ui/metrics" | 
| Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 25 | "android/soong/ui/status" | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 26 | ) | 
|  | 27 |  | 
|  | 28 | // DumpMakeVars can be used to extract the values of Make variables after the | 
|  | 29 | // product configurations are loaded. This is roughly equivalent to the | 
|  | 30 | // `get_build_var` bash function. | 
|  | 31 | // | 
|  | 32 | // goals can be used to set MAKECMDGOALS, which emulates passing arguments to | 
|  | 33 | // Make without actually building them. So all the variables based on | 
|  | 34 | // MAKECMDGOALS can be read. | 
|  | 35 | // | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 36 | // vars is the list of variables to read. The values will be put in the | 
|  | 37 | // returned map. | 
| Dan Willemsen | 6f03752 | 2018-10-21 09:20:47 -0700 | [diff] [blame] | 38 | // | 
|  | 39 | // variables controlled by soong_ui directly are now returned without needing | 
|  | 40 | // to call into make, to retain compatibility. | 
| Dan Willemsen | b2e6c2e | 2017-07-13 17:24:44 -0700 | [diff] [blame] | 41 | func DumpMakeVars(ctx Context, config Config, goals, vars []string) (map[string]string, error) { | 
| Dan Willemsen | 6f03752 | 2018-10-21 09:20:47 -0700 | [diff] [blame] | 42 | soongUiVars := map[string]func() string{ | 
|  | 43 | "OUT_DIR":  func() string { return config.OutDir() }, | 
|  | 44 | "DIST_DIR": func() string { return config.DistDir() }, | 
| Dan Willemsen | b6699a1 | 2019-10-07 15:26:26 -0700 | [diff] [blame] | 45 | "TMPDIR":   func() string { return absPath(ctx, config.TempDir()) }, | 
| Dan Willemsen | 6f03752 | 2018-10-21 09:20:47 -0700 | [diff] [blame] | 46 | } | 
|  | 47 |  | 
|  | 48 | makeVars := make([]string, 0, len(vars)) | 
|  | 49 | for _, v := range vars { | 
|  | 50 | if _, ok := soongUiVars[v]; !ok { | 
|  | 51 | makeVars = append(makeVars, v) | 
|  | 52 | } | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | var ret map[string]string | 
|  | 56 | if len(makeVars) > 0 { | 
| Patrice Arruda | ae2694b | 2020-06-04 19:34:41 +0000 | [diff] [blame] | 57 | // It's not safe to use the same TMPDIR as the build, as that can be removed. | 
| Dan Willemsen | 4e2456b | 2019-10-03 16:45:58 -0700 | [diff] [blame] | 58 | tmpDir, err := ioutil.TempDir("", "dumpvars") | 
|  | 59 | if err != nil { | 
|  | 60 | return nil, err | 
|  | 61 | } | 
|  | 62 | defer os.RemoveAll(tmpDir) | 
|  | 63 |  | 
| Patrice Arruda | ae2694b | 2020-06-04 19:34:41 +0000 | [diff] [blame] | 64 | SetupLitePath(ctx, config, tmpDir) | 
| Dan Willemsen | 4e2456b | 2019-10-03 16:45:58 -0700 | [diff] [blame] | 65 |  | 
| Patrice Arruda | ae2694b | 2020-06-04 19:34:41 +0000 | [diff] [blame] | 66 | ret, err = dumpMakeVars(ctx, config, goals, makeVars, false, tmpDir) | 
| Dan Willemsen | 6f03752 | 2018-10-21 09:20:47 -0700 | [diff] [blame] | 67 | if err != nil { | 
|  | 68 | return ret, err | 
|  | 69 | } | 
|  | 70 | } else { | 
|  | 71 | ret = make(map[string]string) | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | for _, v := range vars { | 
|  | 75 | if f, ok := soongUiVars[v]; ok { | 
|  | 76 | ret[v] = f() | 
|  | 77 | } | 
|  | 78 | } | 
|  | 79 |  | 
|  | 80 | return ret, nil | 
| Dan Willemsen | b2e6c2e | 2017-07-13 17:24:44 -0700 | [diff] [blame] | 81 | } | 
|  | 82 |  | 
| Patrice Arruda | ae2694b | 2020-06-04 19:34:41 +0000 | [diff] [blame] | 83 | func dumpMakeVars(ctx Context, config Config, goals, vars []string, write_soong_vars bool, tmpDir string) (map[string]string, error) { | 
| Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 84 | ctx.BeginTrace(metrics.RunKati, "dumpvars") | 
| Dan Willemsen | d9f6fa2 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 85 | defer ctx.EndTrace() | 
|  | 86 |  | 
| Cole Faust | 64955b3 | 2023-02-16 12:53:32 -0800 | [diff] [blame] | 87 | tool := ctx.Status.StartTool() | 
|  | 88 | if write_soong_vars { | 
|  | 89 | // only print this when write_soong_vars is true so that it's not printed when using | 
|  | 90 | // the get_build_var command. | 
|  | 91 | tool.Status("Running product configuration...") | 
|  | 92 | } | 
|  | 93 | defer tool.Finish() | 
|  | 94 |  | 
| Dan Willemsen | b2e6c2e | 2017-07-13 17:24:44 -0700 | [diff] [blame] | 95 | cmd := Command(ctx, config, "dumpvars", | 
|  | 96 | config.PrebuiltBuildTool("ckati"), | 
|  | 97 | "-f", "build/make/core/config.mk", | 
|  | 98 | "--color_warnings", | 
| Dan Willemsen | 0c51851 | 2018-01-09 02:09:52 -0800 | [diff] [blame] | 99 | "--kati_stats", | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 100 | "dump-many-vars", | 
| Dan Willemsen | b2e6c2e | 2017-07-13 17:24:44 -0700 | [diff] [blame] | 101 | "MAKECMDGOALS="+strings.Join(goals, " ")) | 
|  | 102 | cmd.Environment.Set("CALLED_FROM_SETUP", "true") | 
| Dan Willemsen | b2e6c2e | 2017-07-13 17:24:44 -0700 | [diff] [blame] | 103 | if write_soong_vars { | 
|  | 104 | cmd.Environment.Set("WRITE_SOONG_VARIABLES", "true") | 
|  | 105 | } | 
|  | 106 | cmd.Environment.Set("DUMP_MANY_VARS", strings.Join(vars, " ")) | 
| Patrice Arruda | ae2694b | 2020-06-04 19:34:41 +0000 | [diff] [blame] | 107 | if tmpDir != "" { | 
|  | 108 | cmd.Environment.Set("TMPDIR", tmpDir) | 
|  | 109 | } | 
| Dan Willemsen | b2e6c2e | 2017-07-13 17:24:44 -0700 | [diff] [blame] | 110 | cmd.Sandbox = dumpvarsSandbox | 
| Dan Willemsen | 0c51851 | 2018-01-09 02:09:52 -0800 | [diff] [blame] | 111 | output := bytes.Buffer{} | 
|  | 112 | cmd.Stdout = &output | 
|  | 113 | pipe, err := cmd.StderrPipe() | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 114 | if err != nil { | 
| Dan Willemsen | 0c51851 | 2018-01-09 02:09:52 -0800 | [diff] [blame] | 115 | ctx.Fatalln("Error getting output pipe for ckati:", err) | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 116 | } | 
| Dan Willemsen | 0c51851 | 2018-01-09 02:09:52 -0800 | [diff] [blame] | 117 | cmd.StartOrFatal() | 
|  | 118 | // TODO: error out when Stderr contains any content | 
| Cole Faust | 64955b3 | 2023-02-16 12:53:32 -0800 | [diff] [blame] | 119 | status.KatiReader(tool, pipe) | 
| Dan Willemsen | 0c51851 | 2018-01-09 02:09:52 -0800 | [diff] [blame] | 120 | cmd.WaitOrFatal() | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 121 |  | 
|  | 122 | ret := make(map[string]string, len(vars)) | 
| Dan Willemsen | 0c51851 | 2018-01-09 02:09:52 -0800 | [diff] [blame] | 123 | for _, line := range strings.Split(output.String(), "\n") { | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 124 | if len(line) == 0 { | 
|  | 125 | continue | 
|  | 126 | } | 
|  | 127 |  | 
|  | 128 | if key, value, ok := decodeKeyValue(line); ok { | 
|  | 129 | if value, ok = singleUnquote(value); ok { | 
|  | 130 | ret[key] = value | 
|  | 131 | ctx.Verboseln(key, value) | 
|  | 132 | } else { | 
|  | 133 | return nil, fmt.Errorf("Failed to parse make line: %q", line) | 
|  | 134 | } | 
|  | 135 | } else { | 
|  | 136 | return nil, fmt.Errorf("Failed to parse make line: %q", line) | 
|  | 137 | } | 
|  | 138 | } | 
| Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 139 | if ctx.Metrics != nil { | 
|  | 140 | ctx.Metrics.SetMetadataMetrics(ret) | 
|  | 141 | } | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 142 |  | 
|  | 143 | return ret, nil | 
|  | 144 | } | 
|  | 145 |  | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 146 | // Variables to print out in the top banner | 
|  | 147 | var BannerVars = []string{ | 
|  | 148 | "PLATFORM_VERSION_CODENAME", | 
|  | 149 | "PLATFORM_VERSION", | 
| Spandan Das | c576383 | 2022-11-08 18:42:16 +0000 | [diff] [blame] | 150 | "PRODUCT_INCLUDE_TAGS", | 
| Sam Delmerico | 98a7329 | 2023-02-21 11:50:29 -0500 | [diff] [blame] | 151 | "PRODUCT_SOURCE_ROOT_DIRS", | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 152 | "TARGET_PRODUCT", | 
|  | 153 | "TARGET_BUILD_VARIANT", | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 154 | "TARGET_BUILD_APPS", | 
| Martin Stjernholm | 0880233 | 2020-06-04 17:00:01 +0100 | [diff] [blame] | 155 | "TARGET_BUILD_UNBUNDLED", | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 156 | "TARGET_ARCH", | 
|  | 157 | "TARGET_ARCH_VARIANT", | 
|  | 158 | "TARGET_CPU_VARIANT", | 
|  | 159 | "TARGET_2ND_ARCH", | 
|  | 160 | "TARGET_2ND_ARCH_VARIANT", | 
|  | 161 | "TARGET_2ND_CPU_VARIANT", | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 162 | "HOST_OS", | 
|  | 163 | "HOST_OS_EXTRA", | 
|  | 164 | "HOST_CROSS_OS", | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 165 | "BUILD_ID", | 
|  | 166 | "OUT_DIR", | 
| Paul Duffin | 39abf8f | 2021-09-24 14:58:27 +0100 | [diff] [blame] | 167 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 168 | } | 
|  | 169 |  | 
|  | 170 | func Banner(make_vars map[string]string) string { | 
|  | 171 | b := &bytes.Buffer{} | 
|  | 172 |  | 
|  | 173 | fmt.Fprintln(b, "============================================") | 
|  | 174 | for _, name := range BannerVars { | 
|  | 175 | if make_vars[name] != "" { | 
|  | 176 | fmt.Fprintf(b, "%s=%s\n", name, make_vars[name]) | 
|  | 177 | } | 
|  | 178 | } | 
|  | 179 | fmt.Fprint(b, "============================================") | 
|  | 180 |  | 
|  | 181 | return b.String() | 
|  | 182 | } | 
|  | 183 |  | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 184 | func runMakeProductConfig(ctx Context, config Config) { | 
|  | 185 | // Variables to export into the environment of Kati/Ninja | 
|  | 186 | exportEnvVars := []string{ | 
|  | 187 | // So that we can use the correct TARGET_PRODUCT if it's been | 
| Dan Willemsen | a2a8ecb | 2019-07-29 15:14:11 -0700 | [diff] [blame] | 188 | // modified by a buildspec.mk | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 189 | "TARGET_PRODUCT", | 
| Dan Willemsen | 02781d5 | 2017-05-12 19:28:13 -0700 | [diff] [blame] | 190 | "TARGET_BUILD_VARIANT", | 
| Dan Willemsen | 04a16c7 | 2017-05-25 22:18:57 -0700 | [diff] [blame] | 191 | "TARGET_BUILD_APPS", | 
| Martin Stjernholm | 0880233 | 2020-06-04 17:00:01 +0100 | [diff] [blame] | 192 | "TARGET_BUILD_UNBUNDLED", | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 193 |  | 
|  | 194 | // compiler wrappers set up by make | 
|  | 195 | "CC_WRAPPER", | 
|  | 196 | "CXX_WRAPPER", | 
| Ramy Medhat | 9a90fe5 | 2020-04-13 13:21:23 -0400 | [diff] [blame] | 197 | "RBE_WRAPPER", | 
| Yoshisato Yanagisawa | 13fd3ff | 2017-04-05 11:05:31 +0900 | [diff] [blame] | 198 | "JAVAC_WRAPPER", | 
| Ramy Medhat | 8ea054a | 2020-01-27 14:19:44 -0500 | [diff] [blame] | 199 | "R8_WRAPPER", | 
|  | 200 | "D8_WRAPPER", | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 201 |  | 
|  | 202 | // ccache settings | 
|  | 203 | "CCACHE_COMPILERCHECK", | 
|  | 204 | "CCACHE_SLOPPINESS", | 
|  | 205 | "CCACHE_BASEDIR", | 
|  | 206 | "CCACHE_CPP2", | 
| Yi Kong | 6adf258 | 2022-04-17 15:01:06 +0800 | [diff] [blame] | 207 |  | 
|  | 208 | // LLVM compiler wrapper options | 
|  | 209 | "TOOLCHAIN_RUSAGE_OUTPUT", | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 210 | } | 
|  | 211 |  | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 212 | allVars := append(append([]string{ | 
|  | 213 | // Used to execute Kati and Ninja | 
|  | 214 | "NINJA_GOALS", | 
|  | 215 | "KATI_GOALS", | 
| Dan Willemsen | 02781d5 | 2017-05-12 19:28:13 -0700 | [diff] [blame] | 216 |  | 
|  | 217 | // To find target/product/<DEVICE> | 
|  | 218 | "TARGET_DEVICE", | 
| Dan Willemsen | 3d60b11 | 2018-04-04 22:25:56 -0700 | [diff] [blame] | 219 |  | 
| Dan Willemsen | 6ab79db | 2018-05-02 00:06:28 -0700 | [diff] [blame] | 220 | // So that later Kati runs can find BoardConfig.mk faster | 
|  | 221 | "TARGET_DEVICE_DIR", | 
|  | 222 |  | 
| Dan Willemsen | 3d60b11 | 2018-04-04 22:25:56 -0700 | [diff] [blame] | 223 | // Whether --werror_overriding_commands will work | 
|  | 224 | "BUILD_BROKEN_DUP_RULES", | 
| Dan Willemsen | b58f120 | 2018-06-21 10:12:53 -0700 | [diff] [blame] | 225 |  | 
| Dan Willemsen | 25e6f09 | 2019-04-09 10:22:43 -0700 | [diff] [blame] | 226 | // Whether to enable the network during the build | 
|  | 227 | "BUILD_BROKEN_USES_NETWORK", | 
|  | 228 |  | 
| Dan Willemsen | e333635 | 2020-01-02 19:10:38 -0800 | [diff] [blame] | 229 | // Extra environment variables to be exported to ninja | 
|  | 230 | "BUILD_BROKEN_NINJA_USES_ENV_VARS", | 
|  | 231 |  | 
| Spandan Das | a3639e6 | 2021-05-25 19:14:02 +0000 | [diff] [blame] | 232 | // Used to restrict write access to source tree | 
|  | 233 | "BUILD_BROKEN_SRC_DIR_IS_WRITABLE", | 
|  | 234 | "BUILD_BROKEN_SRC_DIR_RW_ALLOWLIST", | 
|  | 235 |  | 
| Dan Willemsen | b58f120 | 2018-06-21 10:12:53 -0700 | [diff] [blame] | 236 | // Not used, but useful to be in the soong.log | 
| Steven Moreland | 0002028 | 2019-03-07 09:27:27 -0800 | [diff] [blame] | 237 | "BOARD_VNDK_VERSION", | 
| Jihoon Kang | 3690485 | 2022-08-12 23:02:09 +0000 | [diff] [blame] | 238 | "TARGET_BUILD_TYPE", | 
|  | 239 | "HOST_ARCH", | 
|  | 240 | "HOST_2ND_ARCH", | 
|  | 241 | "HOST_CROSS_ARCH", | 
|  | 242 | "HOST_CROSS_2ND_ARCH", | 
|  | 243 | "HOST_BUILD_TYPE", | 
|  | 244 | "PRODUCT_SOONG_NAMESPACES", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 245 |  | 
|  | 246 | "DEFAULT_WARNING_BUILD_MODULE_TYPES", | 
|  | 247 | "DEFAULT_ERROR_BUILD_MODULE_TYPES", | 
| Logan Chien | f9cf9ac | 2019-09-20 11:37:30 -0700 | [diff] [blame] | 248 | "BUILD_BROKEN_PREBUILT_ELF_FILES", | 
| Inseob Kim | 822fdca | 2019-10-11 14:55:33 +0900 | [diff] [blame] | 249 | "BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW", | 
| Inseob Kim | 0a7c819 | 2023-08-18 18:16:26 +0900 | [diff] [blame] | 250 | "BUILD_BROKEN_VENDOR_SEAPP_USES_COREDOMAIN", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 251 | "BUILD_BROKEN_USES_BUILD_COPY_HEADERS", | 
|  | 252 | "BUILD_BROKEN_USES_BUILD_EXECUTABLE", | 
|  | 253 | "BUILD_BROKEN_USES_BUILD_FUZZ_TEST", | 
|  | 254 | "BUILD_BROKEN_USES_BUILD_HEADER_LIBRARY", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 255 | "BUILD_BROKEN_USES_BUILD_HOST_EXECUTABLE", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 256 | "BUILD_BROKEN_USES_BUILD_HOST_JAVA_LIBRARY", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 257 | "BUILD_BROKEN_USES_BUILD_HOST_PREBUILT", | 
|  | 258 | "BUILD_BROKEN_USES_BUILD_HOST_SHARED_LIBRARY", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 259 | "BUILD_BROKEN_USES_BUILD_HOST_STATIC_LIBRARY", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 260 | "BUILD_BROKEN_USES_BUILD_JAVA_LIBRARY", | 
|  | 261 | "BUILD_BROKEN_USES_BUILD_MULTI_PREBUILT", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 262 | "BUILD_BROKEN_USES_BUILD_NATIVE_TEST", | 
|  | 263 | "BUILD_BROKEN_USES_BUILD_NOTICE_FILE", | 
|  | 264 | "BUILD_BROKEN_USES_BUILD_PACKAGE", | 
|  | 265 | "BUILD_BROKEN_USES_BUILD_PHONY_PACKAGE", | 
|  | 266 | "BUILD_BROKEN_USES_BUILD_PREBUILT", | 
|  | 267 | "BUILD_BROKEN_USES_BUILD_RRO_PACKAGE", | 
|  | 268 | "BUILD_BROKEN_USES_BUILD_SHARED_LIBRARY", | 
| Dan Willemsen | 368e556 | 2019-04-17 14:44:33 -0700 | [diff] [blame] | 269 | "BUILD_BROKEN_USES_BUILD_STATIC_JAVA_LIBRARY", | 
|  | 270 | "BUILD_BROKEN_USES_BUILD_STATIC_LIBRARY", | 
| Dan Willemsen | 051133b | 2017-07-14 11:29:29 -0700 | [diff] [blame] | 271 | }, exportEnvVars...), BannerVars...) | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 272 |  | 
| Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 273 | makeVars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true, "") | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 274 | if err != nil { | 
|  | 275 | ctx.Fatalln("Error dumping make vars:", err) | 
|  | 276 | } | 
|  | 277 |  | 
| Sasha Smundak | c0c9ef9 | 2019-01-23 09:52:57 -0800 | [diff] [blame] | 278 | env := config.Environment() | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 279 | // Print the banner like make does | 
| Sasha Smundak | c0c9ef9 | 2019-01-23 09:52:57 -0800 | [diff] [blame] | 280 | if !env.IsEnvTrue("ANDROID_QUIET_BUILD") { | 
| Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 281 | fmt.Fprintln(ctx.Writer, Banner(makeVars)) | 
| Sasha Smundak | c0c9ef9 | 2019-01-23 09:52:57 -0800 | [diff] [blame] | 282 | } | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 283 |  | 
|  | 284 | // Populate the environment | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 285 | for _, name := range exportEnvVars { | 
| Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 286 | if makeVars[name] == "" { | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 287 | env.Unset(name) | 
|  | 288 | } else { | 
| Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 289 | env.Set(name, makeVars[name]) | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 290 | } | 
|  | 291 | } | 
|  | 292 |  | 
| Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 293 | config.SetKatiArgs(strings.Fields(makeVars["KATI_GOALS"])) | 
|  | 294 | config.SetNinjaArgs(strings.Fields(makeVars["NINJA_GOALS"])) | 
|  | 295 | config.SetTargetDevice(makeVars["TARGET_DEVICE"]) | 
|  | 296 | config.SetTargetDeviceDir(makeVars["TARGET_DEVICE_DIR"]) | 
| Spandan Das | a3639e6 | 2021-05-25 19:14:02 +0000 | [diff] [blame] | 297 | config.sandboxConfig.SetSrcDirIsRO(makeVars["BUILD_BROKEN_SRC_DIR_IS_WRITABLE"] == "false") | 
|  | 298 | config.sandboxConfig.SetSrcDirRWAllowlist(strings.Fields(makeVars["BUILD_BROKEN_SRC_DIR_RW_ALLOWLIST"])) | 
| Dan Willemsen | 3d60b11 | 2018-04-04 22:25:56 -0700 | [diff] [blame] | 299 |  | 
| Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 300 | config.SetBuildBrokenDupRules(makeVars["BUILD_BROKEN_DUP_RULES"] == "true") | 
|  | 301 | config.SetBuildBrokenUsesNetwork(makeVars["BUILD_BROKEN_USES_NETWORK"] == "true") | 
|  | 302 | config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(makeVars["BUILD_BROKEN_NINJA_USES_ENV_VARS"])) | 
| Spandan Das | c576383 | 2022-11-08 18:42:16 +0000 | [diff] [blame] | 303 | config.SetIncludeTags(strings.Fields(makeVars["PRODUCT_INCLUDE_TAGS"])) | 
| Sam Delmerico | 98a7329 | 2023-02-21 11:50:29 -0500 | [diff] [blame] | 304 | config.SetSourceRootDirs(strings.Fields(makeVars["PRODUCT_SOURCE_ROOT_DIRS"])) | 
| Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 305 | } |