blob: 88e4161cf27c6a9ea59e344836a46f6d13c592be [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 (
18 "os/exec"
19 "path/filepath"
20)
21
22func runSoongBootstrap(ctx Context, config Config) {
23 cmd := exec.CommandContext(ctx.Context, "./bootstrap.bash")
24 env := config.Environment().Copy()
25 env.Set("BUILDDIR", config.SoongOutDir())
26 cmd.Env = env.Environ()
27 cmd.Stdout = ctx.Stdout()
28 cmd.Stderr = ctx.Stderr()
29 ctx.Verboseln(cmd.Path, cmd.Args)
30 if err := cmd.Run(); err != nil {
31 if e, ok := err.(*exec.ExitError); ok {
32 ctx.Fatalln("soong bootstrap failed with:", e.ProcessState.String())
33 } else {
34 ctx.Fatalln("Failed to run soong bootstrap:", err)
35 }
36 }
37}
38
39func runSoong(ctx Context, config Config) {
40 cmd := exec.CommandContext(ctx.Context, filepath.Join(config.SoongOutDir(), "soong"), "-w", "dupbuild=err")
41 if config.IsVerbose() {
42 cmd.Args = append(cmd.Args, "-v")
43 }
44 env := config.Environment().Copy()
45 env.Set("SKIP_NINJA", "true")
46 cmd.Env = env.Environ()
47 cmd.Stdout = ctx.Stdout()
48 cmd.Stderr = ctx.Stderr()
49 ctx.Verboseln(cmd.Path, cmd.Args)
50 if err := cmd.Run(); err != nil {
51 if e, ok := err.(*exec.ExitError); ok {
52 ctx.Fatalln("soong bootstrap failed with:", e.ProcessState.String())
53 } else {
54 ctx.Fatalln("Failed to run soong bootstrap:", err)
55 }
56 }
57}