blob: d017e7006badc4e70f2c0fda8ba7adcd037e1e0b [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) {
Dan Willemsend9f6fa22016-08-21 15:17:17 -070023 ctx.BeginTrace("bootstrap soong")
24 defer ctx.EndTrace()
25
Dan Willemsen1e704462016-08-21 15:17:17 -070026 cmd := exec.CommandContext(ctx.Context, "./bootstrap.bash")
27 env := config.Environment().Copy()
28 env.Set("BUILDDIR", config.SoongOutDir())
29 cmd.Env = env.Environ()
30 cmd.Stdout = ctx.Stdout()
31 cmd.Stderr = ctx.Stderr()
32 ctx.Verboseln(cmd.Path, cmd.Args)
33 if err := cmd.Run(); err != nil {
34 if e, ok := err.(*exec.ExitError); ok {
35 ctx.Fatalln("soong bootstrap failed with:", e.ProcessState.String())
36 } else {
37 ctx.Fatalln("Failed to run soong bootstrap:", err)
38 }
39 }
40}
41
42func runSoong(ctx Context, config Config) {
Dan Willemsend9f6fa22016-08-21 15:17:17 -070043 ctx.BeginTrace("soong")
44 defer ctx.EndTrace()
45
Dan Willemsen1e704462016-08-21 15:17:17 -070046 cmd := exec.CommandContext(ctx.Context, filepath.Join(config.SoongOutDir(), "soong"), "-w", "dupbuild=err")
47 if config.IsVerbose() {
48 cmd.Args = append(cmd.Args, "-v")
49 }
50 env := config.Environment().Copy()
51 env.Set("SKIP_NINJA", "true")
52 cmd.Env = env.Environ()
53 cmd.Stdout = ctx.Stdout()
54 cmd.Stderr = ctx.Stderr()
55 ctx.Verboseln(cmd.Path, cmd.Args)
56 if err := cmd.Run(); err != nil {
57 if e, ok := err.(*exec.ExitError); ok {
58 ctx.Fatalln("soong bootstrap failed with:", e.ProcessState.String())
59 } else {
60 ctx.Fatalln("Failed to run soong bootstrap:", err)
61 }
62 }
63}