blob: e2a568fade7b2e6d5ca14614f9f4549b69eb1e4f [file] [log] [blame]
Dan Willemsen1e704462016-08-21 15:17:17 -07001// 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
15package build
16
17import (
Jeff Gaston809cc6f2017-05-25 15:44:36 -070018 "fmt"
19 "os"
Joe Onoratod6a29992024-12-06 12:55:41 -080020 "os/exec"
Dan Willemsend9f6fa22016-08-21 15:17:17 -070021 "path/filepath"
Dan Willemsene3336352020-01-02 19:10:38 -080022 "sort"
Dan Willemsen1e704462016-08-21 15:17:17 -070023 "strconv"
24 "strings"
Dan Willemsend9f6fa22016-08-21 15:17:17 -070025 "time"
Dan Willemsenb82471a2018-05-17 16:37:09 -070026
Spandan Das2db59da2023-02-16 18:31:43 +000027 "android/soong/shared"
Nan Zhang17f27672018-12-12 16:01:49 -080028 "android/soong/ui/metrics"
Dan Willemsenb82471a2018-05-17 16:37:09 -070029 "android/soong/ui/status"
Dan Willemsen1e704462016-08-21 15:17:17 -070030)
31
Spandan Das2db59da2023-02-16 18:31:43 +000032const (
33 // File containing the environment state when ninja is executed
Jeongik Cha518f3ea2023-03-19 00:12:39 +090034 ninjaEnvFileName = "ninja.environment"
35 ninjaLogFileName = ".ninja_log"
36 ninjaWeightListFileName = ".ninja_weight_list"
Spandan Das2db59da2023-02-16 18:31:43 +000037)
38
LaMont Jones825f8ff2025-02-12 11:52:00 -080039// Runs ninja with the arguments from the command line, as found in
40// config.NinjaArgs().
41func runNinjaForBuild(ctx Context, config Config) {
42 runNinja(ctx, config, config.NinjaArgs())
43}
44
Jingwen Chen9d1cb492020-11-17 06:52:28 -050045// Constructs and runs the Ninja command line with a restricted set of
46// environment variables. It's important to restrict the environment Ninja runs
47// for hermeticity reasons, and to avoid spurious rebuilds.
LaMont Jones825f8ff2025-02-12 11:52:00 -080048func runNinja(ctx Context, config Config, ninjaArgs []string) {
Nan Zhang17f27672018-12-12 16:01:49 -080049 ctx.BeginTrace(metrics.PrimaryNinja, "ninja")
Dan Willemsend9f6fa22016-08-21 15:17:17 -070050 defer ctx.EndTrace()
51
Jingwen Chen9d1cb492020-11-17 06:52:28 -050052 // Sets up the FIFO status updater that reads the Ninja protobuf output, and
53 // translates it to the soong_ui status output, displaying real-time
54 // progress of the build.
Dan Willemsenb82471a2018-05-17 16:37:09 -070055 fifo := filepath.Join(config.OutDir(), ".ninja_fifo")
Colin Crossb98d3bc2019-03-21 16:02:58 -070056 nr := status.NewNinjaReader(ctx, ctx.Status.StartTool(), fifo)
57 defer nr.Close()
Dan Willemsenb82471a2018-05-17 16:37:09 -070058
LaMont Jonesece626c2024-09-03 11:19:31 -070059 var executable string
60 var args []string
61 switch config.ninjaCommand {
62 case NINJA_N2:
Cole Faust4e58bba2024-08-22 14:27:03 -070063 executable = config.N2Bin()
Cole Faustbee030d2024-01-03 13:45:48 -080064 args = []string{
65 "-d", "trace",
66 // TODO: implement these features, or remove them.
67 //"-d", "keepdepfile",
68 //"-d", "keeprsp",
69 //"-d", "stats",
70 "--frontend-file", fifo,
71 }
LaMont Jonesece626c2024-09-03 11:19:31 -070072 case NINJA_SISO:
73 executable = config.SisoBin()
74 args = []string{
75 "ninja",
76 "--log_dir", config.SoongOutDir(),
77 // TODO: implement these features, or remove them.
78 //"-d", "trace",
79 //"-d", "keepdepfile",
80 //"-d", "keeprsp",
81 //"-d", "stats",
82 //"--frontend-file", fifo,
83 }
84 default:
Taylor Santiago2fa40d02025-01-20 20:36:37 -080085 // NINJA_NINJA or NINJA_NINJAGO.
LaMont Jonesece626c2024-09-03 11:19:31 -070086 executable = config.NinjaBin()
87 args = []string{
88 "-d", "keepdepfile",
89 "-d", "keeprsp",
90 "-d", "stats",
91 "--frontend_file", fifo,
92 "-o", "usesphonyoutputs=yes",
93 "-w", "dupbuild=err",
94 "-w", "missingdepfile=err",
95 }
Cole Faustbee030d2024-01-03 13:45:48 -080096 }
LaMont Jones825f8ff2025-02-12 11:52:00 -080097 args = append(args, ninjaArgs...)
Dan Willemsen1e704462016-08-21 15:17:17 -070098
99 var parallel int
Colin Cross9016b912019-11-11 14:57:42 -0800100 if config.UseRemoteBuild() {
Dan Willemsen1e704462016-08-21 15:17:17 -0700101 parallel = config.RemoteParallel()
102 } else {
103 parallel = config.Parallel()
104 }
105 args = append(args, "-j", strconv.Itoa(parallel))
106 if config.keepGoing != 1 {
107 args = append(args, "-k", strconv.Itoa(config.keepGoing))
108 }
109
110 args = append(args, "-f", config.CombinedNinjaFile())
111
Spandan Das28a6f192024-07-01 21:00:25 +0000112 if !config.BuildBrokenMissingOutputs() {
113 // Missing outputs will be treated as errors.
114 // BUILD_BROKEN_MISSING_OUTPUTS can be used to bypass this check.
LaMont Jonesece626c2024-09-03 11:19:31 -0700115 if config.ninjaCommand != NINJA_N2 {
Cole Faustbee030d2024-01-03 13:45:48 -0800116 args = append(args,
117 "-w", "missingoutfile=err",
118 )
119 }
Spandan Das28a6f192024-07-01 21:00:25 +0000120 }
121
Dan Willemsen269a8c72017-05-03 17:15:47 -0700122 cmd := Command(ctx, config, "ninja", executable, args...)
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500123
124 // Set up the nsjail sandbox Ninja runs in.
Dan Willemsen63663c62019-01-02 12:24:44 -0800125 cmd.Sandbox = ninjaSandbox
Dan Willemsene0879fc2017-08-04 15:06:27 -0700126 if config.HasKatiSuffix() {
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500127 // Reads and executes a shell script from Kati that sets/unsets the
128 // environment Ninja runs in.
Dan Willemsene0879fc2017-08-04 15:06:27 -0700129 cmd.Environment.AppendFromKati(config.KatiEnvFile())
130 }
Dan Willemsen1e704462016-08-21 15:17:17 -0700131
LaMont Jonesece626c2024-09-03 11:19:31 -0700132 // TODO(b/346806126): implement this for the other ninjaCommand values.
133 if config.ninjaCommand == NINJA_NINJA {
134 switch config.NinjaWeightListSource() {
135 case NINJA_LOG:
Cole Faustbee030d2024-01-03 13:45:48 -0800136 cmd.Args = append(cmd.Args, "-o", "usesninjalogasweightlist=yes")
LaMont Jonesece626c2024-09-03 11:19:31 -0700137 case EVENLY_DISTRIBUTED:
138 // pass empty weight list means ninja considers every tasks's weight as 1(default value).
Cole Faustbee030d2024-01-03 13:45:48 -0800139 cmd.Args = append(cmd.Args, "-o", "usesweightlist=/dev/null")
LaMont Jonesece626c2024-09-03 11:19:31 -0700140 case EXTERNAL_FILE:
141 fallthrough
142 case HINT_FROM_SOONG:
143 // The weight list is already copied/generated.
Cole Faustbee030d2024-01-03 13:45:48 -0800144 ninjaWeightListPath := filepath.Join(config.OutDir(), ninjaWeightListFileName)
145 cmd.Args = append(cmd.Args, "-o", "usesweightlist="+ninjaWeightListPath)
146 }
Jeongik Cha0cf44d52023-03-15 00:10:45 +0900147 }
148
Dan Willemsen1e704462016-08-21 15:17:17 -0700149 // Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been
150 // used in the past to specify extra ninja arguments.
Dan Willemsen269a8c72017-05-03 17:15:47 -0700151 if extra, ok := cmd.Environment.Get("NINJA_ARGS"); ok {
152 cmd.Args = append(cmd.Args, strings.Fields(extra)...)
Dan Willemsen1e704462016-08-21 15:17:17 -0700153 }
Dan Willemsen269a8c72017-05-03 17:15:47 -0700154 if extra, ok := cmd.Environment.Get("NINJA_EXTRA_ARGS"); ok {
155 cmd.Args = append(cmd.Args, strings.Fields(extra)...)
Dan Willemsen1e704462016-08-21 15:17:17 -0700156 }
157
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700158 ninjaHeartbeatDuration := time.Minute * 5
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500159 // Get the ninja heartbeat interval from the environment before it's filtered away later.
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700160 if overrideText, ok := cmd.Environment.Get("NINJA_HEARTBEAT_INTERVAL"); ok {
161 // For example, "1m"
162 overrideDuration, err := time.ParseDuration(overrideText)
163 if err == nil && overrideDuration.Seconds() > 0 {
164 ninjaHeartbeatDuration = overrideDuration
165 }
166 }
Dan Willemsene3336352020-01-02 19:10:38 -0800167
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500168 // Filter the environment, as ninja does not rebuild files when environment
169 // variables change.
Dan Willemsene3336352020-01-02 19:10:38 -0800170 //
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500171 // Anything listed here must not change the output of rules/actions when the
172 // value changes, otherwise incremental builds may be unsafe. Vars
173 // explicitly set to stable values elsewhere in soong_ui are fine.
Dan Willemsene3336352020-01-02 19:10:38 -0800174 //
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500175 // For the majority of cases, either Soong or the makefiles should be
176 // replicating any necessary environment variables in the command line of
177 // each action that needs it.
Dan Willemsen260db532020-01-02 20:12:09 -0800178 if cmd.Environment.IsEnvTrue("ALLOW_NINJA_ENV") {
179 ctx.Println("Allowing all environment variables during ninja; incremental builds may be unsafe.")
180 } else {
Dan Willemsene3336352020-01-02 19:10:38 -0800181 cmd.Environment.Allow(append([]string{
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500182 // Set the path to a symbolizer (e.g. llvm-symbolizer) so ASAN-based
183 // tools can symbolize crashes.
Dan Willemsene3336352020-01-02 19:10:38 -0800184 "ASAN_SYMBOLIZER_PATH",
185 "HOME",
186 "JAVA_HOME",
187 "LANG",
188 "LC_MESSAGES",
189 "OUT_DIR",
190 "PATH",
191 "PWD",
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500192 // https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE
Dan Willemsene3336352020-01-02 19:10:38 -0800193 "PYTHONDONTWRITEBYTECODE",
194 "TMPDIR",
195 "USER",
196
197 // TODO: remove these carefully
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500198 // Options for the address sanitizer.
Dan Willemsen7da04292020-01-04 13:58:54 -0800199 "ASAN_OPTIONS",
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500200 // The list of Android app modules to be built in an unbundled manner.
Dan Willemsene3336352020-01-02 19:10:38 -0800201 "TARGET_BUILD_APPS",
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500202 // The variant of the product being built. e.g. eng, userdebug, debug.
Dan Willemsene3336352020-01-02 19:10:38 -0800203 "TARGET_BUILD_VARIANT",
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500204 // The product name of the product being built, e.g. aosp_arm, aosp_flame.
Dan Willemsene3336352020-01-02 19:10:38 -0800205 "TARGET_PRODUCT",
Dan Willemsen5cacfe12020-01-06 12:25:40 -0800206 // b/147197813 - used by art-check-debug-apex-gen
207 "EMMA_INSTRUMENT_FRAMEWORK",
Dan Willemsene3336352020-01-02 19:10:38 -0800208
Dan Willemsene3336352020-01-02 19:10:38 -0800209 // RBE client
Ola Rozenfeld3992e372020-03-19 20:04:13 -0400210 "RBE_compare",
andusyu240660d2022-01-20 14:00:58 -0500211 "RBE_num_local_reruns",
212 "RBE_num_remote_reruns",
Ola Rozenfeld3992e372020-03-19 20:04:13 -0400213 "RBE_exec_root",
214 "RBE_exec_strategy",
215 "RBE_invocation_id",
216 "RBE_log_dir",
Kousik Kumarc3a22d82021-03-17 14:19:27 -0400217 "RBE_num_retries_if_mismatched",
Ola Rozenfeld3992e372020-03-19 20:04:13 -0400218 "RBE_platform",
219 "RBE_remote_accept_cache",
220 "RBE_remote_update_cache",
221 "RBE_server_address",
222 // TODO: remove old FLAG_ variables.
Kousik Kumarade12e72020-01-09 08:52:59 -0800223 "FLAG_compare",
Dan Willemsene3336352020-01-02 19:10:38 -0800224 "FLAG_exec_root",
225 "FLAG_exec_strategy",
226 "FLAG_invocation_id",
227 "FLAG_log_dir",
228 "FLAG_platform",
Kousik Kumar0f095e12020-01-28 10:48:46 -0800229 "FLAG_remote_accept_cache",
230 "FLAG_remote_update_cache",
Dan Willemsene3336352020-01-02 19:10:38 -0800231 "FLAG_server_address",
232
233 // ccache settings
234 "CCACHE_COMPILERCHECK",
235 "CCACHE_SLOPPINESS",
236 "CCACHE_BASEDIR",
237 "CCACHE_CPP2",
John Eckerdal974b0e82020-02-04 15:59:37 +0100238 "CCACHE_DIR",
Yi Kong6adf2582022-04-17 15:01:06 +0800239
240 // LLVM compiler wrapper options
241 "TOOLCHAIN_RUSAGE_OUTPUT",
Cole Faustded79602023-09-05 17:48:11 -0700242
243 // We don't want this build broken flag to cause reanalysis, so allow it through to the
244 // actions.
245 "BUILD_BROKEN_INCORRECT_PARTITION_IMAGES",
LaMont Jonesece626c2024-09-03 11:19:31 -0700246 // Do not do reanalysis just because we changed ninja commands.
247 "SOONG_NINJA",
Cole Faustbee030d2024-01-03 13:45:48 -0800248 "SOONG_USE_N2",
249 "RUST_BACKTRACE",
LaMont Jonesb2ab5272024-08-14 10:08:50 -0700250 "RUST_LOG",
LaMont Jones99f18962024-10-17 11:50:44 -0700251
252 // SOONG_USE_PARTIAL_COMPILE only determines which half of the rule we execute.
LaMont Jones825f8ff2025-02-12 11:52:00 -0800253 // When it transitions true => false, we build phony target "partialcompileclean",
254 // which removes all files that could have been created while it was true.
LaMont Jones99f18962024-10-17 11:50:44 -0700255 "SOONG_USE_PARTIAL_COMPILE",
LaMont Jones8490ffb2024-11-14 16:42:54 -0800256
257 // Directory for ExecutionMetrics
258 "SOONG_METRICS_AGGREGATION_DIR",
Dan Willemsene3336352020-01-02 19:10:38 -0800259 }, config.BuildBrokenNinjaUsesEnvVars()...)...)
260 }
261
262 cmd.Environment.Set("DIST_DIR", config.DistDir())
263 cmd.Environment.Set("SHELL", "/bin/bash")
LaMont Jonesece626c2024-09-03 11:19:31 -0700264 switch config.ninjaCommand {
265 case NINJA_N2:
Cole Faustbee030d2024-01-03 13:45:48 -0800266 cmd.Environment.Set("RUST_BACKTRACE", "1")
LaMont Jonesece626c2024-09-03 11:19:31 -0700267 default:
268 // Only set RUST_BACKTRACE for n2.
Cole Faustbee030d2024-01-03 13:45:48 -0800269 }
Dan Willemsene3336352020-01-02 19:10:38 -0800270
LaMont Jones8490ffb2024-11-14 16:42:54 -0800271 // Set up the metrics aggregation directory.
272 ctx.ExecutionMetrics.SetDir(filepath.Join(config.OutDir(), "soong", "metrics_aggregation"))
273 cmd.Environment.Set("SOONG_METRICS_AGGREGATION_DIR", ctx.ExecutionMetrics.MetricsAggregationDir)
274
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500275 // Print the environment variables that Ninja is operating in.
Dan Willemsene3336352020-01-02 19:10:38 -0800276 ctx.Verboseln("Ninja environment: ")
277 envVars := cmd.Environment.Environ()
278 sort.Strings(envVars)
279 for _, envVar := range envVars {
280 ctx.Verbosef(" %s", envVar)
281 }
282
Spandan Das2db59da2023-02-16 18:31:43 +0000283 // Write the env vars available during ninja execution to a file
284 ninjaEnvVars := cmd.Environment.AsMap()
285 data, err := shared.EnvFileContents(ninjaEnvVars)
286 if err != nil {
287 ctx.Panicf("Could not parse environment variables for ninja run %s", err)
288 }
289 // Write the file in every single run. This is fine because
290 // 1. It is not a dep of Soong analysis, so will not retrigger Soong analysis.
291 // 2. Is is fairly lightweight (~1Kb)
292 ninjaEnvVarsFile := shared.JoinPath(config.SoongOutDir(), ninjaEnvFileName)
293 err = os.WriteFile(ninjaEnvVarsFile, data, 0666)
294 if err != nil {
295 ctx.Panicf("Could not write ninja environment file %s", err)
296 }
297
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500298 // Poll the Ninja log for updates regularly based on the heartbeat
299 // frequency. If it isn't updated enough, then we want to surface the
300 // possibility that Ninja is stuck, to the user.
Jeff Gastona6697e82017-06-13 12:51:50 -0700301 done := make(chan struct{})
302 defer close(done)
303 ticker := time.NewTicker(ninjaHeartbeatDuration)
304 defer ticker.Stop()
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500305 ninjaChecker := &ninjaStucknessChecker{
Jeongik Cha96d62272023-03-17 01:53:11 +0900306 logPath: filepath.Join(config.OutDir(), ninjaLogFileName),
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500307 }
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700308 go func() {
Jeff Gastona6697e82017-06-13 12:51:50 -0700309 for {
310 select {
311 case <-ticker.C:
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500312 ninjaChecker.check(ctx, config)
Jeff Gastona6697e82017-06-13 12:51:50 -0700313 case <-done:
314 return
315 }
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700316 }
317 }()
318
LaMont Jones8490ffb2024-11-14 16:42:54 -0800319 ctx.ExecutionMetrics.Start()
320 defer ctx.ExecutionMetrics.Finish(ctx)
Dan Willemsen7f30c072019-01-02 12:50:49 -0800321 ctx.Status.Status("Starting ninja...")
Colin Cross7b97ecd2019-06-19 13:17:59 -0700322 cmd.RunAndStreamOrFatal()
Dan Willemsen1e704462016-08-21 15:17:17 -0700323}
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700324
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500325// A simple struct for checking if Ninja gets stuck, using timestamps.
326type ninjaStucknessChecker struct {
327 logPath string
328 prevModTime time.Time
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700329}
330
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500331// Check that a file has been modified since the last time it was checked. If
332// the mod time hasn't changed, then assume that Ninja got stuck, and print
333// diagnostics for debugging.
334func (c *ninjaStucknessChecker) check(ctx Context, config Config) {
335 info, err := os.Stat(c.logPath)
336 var newModTime time.Time
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700337 if err == nil {
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500338 newModTime = info.ModTime()
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700339 }
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500340 if newModTime == c.prevModTime {
341 // The Ninja file hasn't been modified since the last time it was
342 // checked, so Ninja could be stuck. Output some diagnostics.
343 ctx.Verbosef("ninja may be stuck; last update to %v was %v. dumping process tree...", c.logPath, newModTime)
Colin Crossa9aa35c2024-01-05 14:03:27 -0800344 ctx.Printf("ninja may be stuck, check %v for list of running processes.",
345 filepath.Join(config.LogsDir(), config.logsPrefix+"soong.log"))
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500346
347 // The "pstree" command doesn't exist on Mac, but "pstree" on Linux
348 // gives more convenient output than "ps" So, we try pstree first, and
349 // ps second
Colin Crossa9aa35c2024-01-05 14:03:27 -0800350 commandText := fmt.Sprintf("pstree -palT %v || ps -ef", os.Getpid())
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500351
352 cmd := Command(ctx, config, "dump process tree", "bash", "-c", commandText)
353 output := cmd.CombinedOutputOrFatal()
354 ctx.Verbose(string(output))
355
356 ctx.Verbosef("done\n")
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700357 }
Jingwen Chen9d1cb492020-11-17 06:52:28 -0500358 c.prevModTime = newModTime
Jeff Gaston809cc6f2017-05-25 15:44:36 -0700359}
Joe Onoratod6a29992024-12-06 12:55:41 -0800360
361// Constructs and runs the Ninja command line to get the inputs of a goal.
Taylor Santiago2fa40d02025-01-20 20:36:37 -0800362// For n2 and siso, this will always run ninja, because they don't have the
Joe Onoratod6a29992024-12-06 12:55:41 -0800363// `-t inputs` command. This command will use the inputs command's -d option,
364// to use the dep file iff ninja was the executor. For other executors, the
365// results will be wrong.
366func runNinjaInputs(ctx Context, config Config, goal string) ([]string, error) {
Taylor Santiago2fa40d02025-01-20 20:36:37 -0800367 var executable string
368 switch config.ninjaCommand {
369 case NINJA_N2, NINJA_SISO:
370 executable = config.PrebuiltBuildTool("ninja")
371 default:
372 executable = config.NinjaBin()
373 }
Joe Onoratod6a29992024-12-06 12:55:41 -0800374
375 args := []string{
376 "-f",
377 config.CombinedNinjaFile(),
378 "-t",
379 "inputs",
380 }
381 // Add deps file arg for ninja
382 // TODO: Update as inputs command is implemented
383 if config.ninjaCommand == NINJA_NINJA && !config.UseABFS() {
384 args = append(args, "-d")
385 }
386 args = append(args, goal)
387
388 // This is just ninja -t inputs, so we won't bother running it in the sandbox,
389 // so use exec.Command, not soong_ui's command.
390 cmd := exec.Command(executable, args...)
391
392 cmd.Stdin = os.Stdin
393 cmd.Stderr = os.Stderr
394
395 out, err := cmd.Output()
396 if err != nil {
397 fmt.Printf("Error getting goal inputs for %s: %s\n", goal, err)
398 return nil, err
399 }
400
401 return strings.Split(strings.TrimSpace(string(out)), "\n"), nil
402}