Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
// Copyright 2017 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 build
|
|
|
|
|
|
|
|
import (
|
2017-01-20 23:10:01 +01:00
|
|
|
"log"
|
|
|
|
"os"
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
2017-03-30 02:29:06 +02:00
|
|
|
|
|
|
|
"android/soong/shared"
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct{ *configImpl }
|
|
|
|
|
|
|
|
type configImpl struct {
|
|
|
|
// From the environment
|
|
|
|
arguments []string
|
|
|
|
goma bool
|
|
|
|
environ *Environment
|
|
|
|
|
|
|
|
// From the arguments
|
|
|
|
parallel int
|
|
|
|
keepGoing int
|
|
|
|
verbose bool
|
2017-02-05 02:30:44 +01:00
|
|
|
dist bool
|
2017-08-05 00:06:27 +02:00
|
|
|
skipMake bool
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
|
|
|
|
// From the product config
|
2017-05-13 04:28:13 +02:00
|
|
|
katiArgs []string
|
|
|
|
ninjaArgs []string
|
|
|
|
katiSuffix string
|
|
|
|
targetDevice string
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
}
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
const srcDirFileCheck = "build/soong/root.bp"
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func NewConfig(ctx Context, args ...string) Config {
|
|
|
|
ret := &configImpl{
|
|
|
|
environ: OsEnvironment(),
|
|
|
|
}
|
|
|
|
|
2017-07-11 07:13:00 +02:00
|
|
|
// Sane default matching ninja
|
|
|
|
ret.parallel = runtime.NumCPU() + 2
|
|
|
|
ret.keepGoing = 1
|
|
|
|
|
|
|
|
ret.parseArgs(ctx, args)
|
|
|
|
|
2017-03-03 00:49:10 +01:00
|
|
|
// Make sure OUT_DIR is set appropriately
|
2017-05-12 22:50:19 +02:00
|
|
|
if outDir, ok := ret.environ.Get("OUT_DIR"); ok {
|
|
|
|
ret.environ.Set("OUT_DIR", filepath.Clean(outDir))
|
|
|
|
} else {
|
2017-03-03 00:49:10 +01:00
|
|
|
outDir := "out"
|
|
|
|
if baseDir, ok := ret.environ.Get("OUT_DIR_COMMON_BASE"); ok {
|
|
|
|
if wd, err := os.Getwd(); err != nil {
|
|
|
|
ctx.Fatalln("Failed to get working directory:", err)
|
|
|
|
} else {
|
|
|
|
outDir = filepath.Join(baseDir, filepath.Base(wd))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret.environ.Set("OUT_DIR", outDir)
|
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
ret.environ.Unset(
|
|
|
|
// We're already using it
|
|
|
|
"USE_SOONG_UI",
|
|
|
|
|
|
|
|
// We should never use GOROOT/GOPATH from the shell environment
|
|
|
|
"GOROOT",
|
|
|
|
"GOPATH",
|
|
|
|
|
|
|
|
// These should only come from Soong, not the environment.
|
|
|
|
"CLANG",
|
|
|
|
"CLANG_CXX",
|
|
|
|
"CCC_CC",
|
|
|
|
"CCC_CXX",
|
|
|
|
|
|
|
|
// Used by the goma compiler wrapper, but should only be set by
|
|
|
|
// gomacc
|
|
|
|
"GOMACC_PATH",
|
2017-03-03 00:49:10 +01:00
|
|
|
|
|
|
|
// We handle this above
|
|
|
|
"OUT_DIR_COMMON_BASE",
|
2017-04-18 22:56:57 +02:00
|
|
|
|
|
|
|
// Variables that have caused problems in the past
|
|
|
|
"DISPLAY",
|
|
|
|
"GREP_OPTIONS",
|
2017-07-11 23:30:00 +02:00
|
|
|
|
|
|
|
// Drop make flags
|
|
|
|
"MAKEFLAGS",
|
|
|
|
"MAKELEVEL",
|
|
|
|
"MFLAGS",
|
2017-10-30 21:42:06 +01:00
|
|
|
|
|
|
|
// Set in envsetup.sh, reset in makefiles
|
|
|
|
"ANDROID_JAVA_TOOLCHAIN",
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Tell python not to spam the source tree with .pyc files.
|
|
|
|
ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1")
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
// Precondition: the current directory is the top of the source tree
|
|
|
|
if _, err := os.Stat(srcDirFileCheck); err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
log.Fatalf("Current working directory must be the source tree. %q not found", srcDirFileCheck)
|
|
|
|
}
|
|
|
|
log.Fatalln("Error verifying tree state:", err)
|
|
|
|
}
|
|
|
|
|
2017-10-30 21:42:06 +01:00
|
|
|
if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') {
|
|
|
|
log.Println("You are building in a directory whose absolute path contains a space character:")
|
|
|
|
log.Println()
|
|
|
|
log.Printf("%q\n", srcDir)
|
|
|
|
log.Println()
|
|
|
|
log.Fatalln("Directory names containing spaces are not supported")
|
2017-05-13 01:38:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') {
|
|
|
|
log.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
|
|
|
|
log.Println()
|
|
|
|
log.Printf("%q\n", outDir)
|
|
|
|
log.Println()
|
|
|
|
log.Fatalln("Directory names containing spaces are not supported")
|
|
|
|
}
|
|
|
|
|
|
|
|
if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') {
|
|
|
|
log.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
|
|
|
|
log.Println()
|
|
|
|
log.Printf("%q\n", distDir)
|
|
|
|
log.Println()
|
|
|
|
log.Fatalln("Directory names containing spaces are not supported")
|
|
|
|
}
|
|
|
|
|
2017-10-30 21:42:06 +01:00
|
|
|
// Configure Java-related variables, including adding it to $PATH
|
|
|
|
javaHome := func() string {
|
|
|
|
if override, ok := ret.environ.Get("OVERRIDE_ANDROID_JAVA_HOME"); ok {
|
|
|
|
return override
|
|
|
|
}
|
|
|
|
if v, ok := ret.environ.Get("EXPERIMENTAL_USE_OPENJDK9"); ok && v != "" {
|
|
|
|
return filepath.Join("prebuilts/jdk/jdk9", ret.HostPrebuiltTag())
|
|
|
|
}
|
|
|
|
return filepath.Join("prebuilts/jdk/jdk8", ret.HostPrebuiltTag())
|
|
|
|
}()
|
|
|
|
absJavaHome := absPath(ctx, javaHome)
|
|
|
|
|
|
|
|
newPath := []string{filepath.Join(absJavaHome, "bin")}
|
|
|
|
if path, ok := ret.environ.Get("PATH"); ok && path != "" {
|
|
|
|
newPath = append(newPath, path)
|
|
|
|
}
|
|
|
|
ret.environ.Unset("OVERRIDE_ANDROID_JAVA_HOME")
|
|
|
|
ret.environ.Set("JAVA_HOME", absJavaHome)
|
|
|
|
ret.environ.Set("ANDROID_JAVA_HOME", javaHome)
|
|
|
|
ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
|
|
|
|
|
2017-07-11 07:13:00 +02:00
|
|
|
return Config{ret}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) parseArgs(ctx Context, args []string) {
|
|
|
|
for i := 0; i < len(args); i++ {
|
|
|
|
arg := strings.TrimSpace(args[i])
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
if arg == "--make-mode" {
|
|
|
|
} else if arg == "showcommands" {
|
2017-07-11 07:13:00 +02:00
|
|
|
c.verbose = true
|
2017-08-05 00:06:27 +02:00
|
|
|
} else if arg == "--skip-make" {
|
|
|
|
c.skipMake = true
|
2017-10-18 05:35:34 +02:00
|
|
|
} else if len(arg) > 0 && arg[0] == '-' {
|
2017-07-11 07:13:00 +02:00
|
|
|
parseArgNum := func(def int) int {
|
|
|
|
if len(arg) > 2 {
|
|
|
|
p, err := strconv.ParseUint(arg[2:], 10, 31)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Fatalf("Failed to parse %q: %v", arg, err)
|
|
|
|
}
|
|
|
|
return int(p)
|
|
|
|
} else if i+1 < len(args) {
|
|
|
|
p, err := strconv.ParseUint(args[i+1], 10, 31)
|
|
|
|
if err == nil {
|
|
|
|
i++
|
|
|
|
return int(p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return def
|
|
|
|
}
|
|
|
|
|
2017-10-18 05:35:34 +02:00
|
|
|
if len(arg) > 1 && arg[1] == 'j' {
|
2017-07-11 07:13:00 +02:00
|
|
|
c.parallel = parseArgNum(c.parallel)
|
2017-10-18 05:35:34 +02:00
|
|
|
} else if len(arg) > 1 && arg[1] == 'k' {
|
2017-07-11 07:13:00 +02:00
|
|
|
c.keepGoing = parseArgNum(0)
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
} else {
|
|
|
|
ctx.Fatalln("Unknown option:", arg)
|
|
|
|
}
|
2017-07-11 23:17:50 +02:00
|
|
|
} else if k, v, ok := decodeKeyValue(arg); ok && len(k) > 0 {
|
|
|
|
c.environ.Set(k, v)
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
} else {
|
2017-08-05 00:06:27 +02:00
|
|
|
if arg == "dist" {
|
|
|
|
c.dist = true
|
|
|
|
}
|
2017-07-11 07:13:00 +02:00
|
|
|
c.arguments = append(c.arguments, arg)
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lunch configures the environment for a specific product similarly to the
|
|
|
|
// `lunch` bash function.
|
|
|
|
func (c *configImpl) Lunch(ctx Context, product, variant string) {
|
|
|
|
if variant != "eng" && variant != "userdebug" && variant != "user" {
|
|
|
|
ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.environ.Set("TARGET_PRODUCT", product)
|
|
|
|
c.environ.Set("TARGET_BUILD_VARIANT", variant)
|
|
|
|
c.environ.Set("TARGET_BUILD_TYPE", "release")
|
|
|
|
c.environ.Unset("TARGET_BUILD_APPS")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tapas configures the environment to build one or more unbundled apps,
|
|
|
|
// similarly to the `tapas` bash function.
|
|
|
|
func (c *configImpl) Tapas(ctx Context, apps []string, arch, variant string) {
|
|
|
|
if len(apps) == 0 {
|
|
|
|
apps = []string{"all"}
|
|
|
|
}
|
|
|
|
if variant == "" {
|
|
|
|
variant = "eng"
|
|
|
|
}
|
|
|
|
|
|
|
|
if variant != "eng" && variant != "userdebug" && variant != "user" {
|
|
|
|
ctx.Fatalf("Invalid variant %q. Must be one of 'user', 'userdebug' or 'eng'", variant)
|
|
|
|
}
|
|
|
|
|
|
|
|
var product string
|
|
|
|
switch arch {
|
|
|
|
case "armv5":
|
|
|
|
product = "generic_armv5"
|
|
|
|
case "arm", "":
|
|
|
|
product = "aosp_arm"
|
|
|
|
case "arm64":
|
|
|
|
product = "aosm_arm64"
|
|
|
|
case "mips":
|
|
|
|
product = "aosp_mips"
|
|
|
|
case "mips64":
|
|
|
|
product = "aosp_mips64"
|
|
|
|
case "x86":
|
|
|
|
product = "aosp_x86"
|
|
|
|
case "x86_64":
|
|
|
|
product = "aosp_x86_64"
|
|
|
|
default:
|
|
|
|
ctx.Fatalf("Invalid architecture: %q", arch)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.environ.Set("TARGET_PRODUCT", product)
|
|
|
|
c.environ.Set("TARGET_BUILD_VARIANT", variant)
|
|
|
|
c.environ.Set("TARGET_BUILD_TYPE", "release")
|
|
|
|
c.environ.Set("TARGET_BUILD_APPS", strings.Join(apps, " "))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) Environment() *Environment {
|
|
|
|
return c.environ
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) Arguments() []string {
|
|
|
|
return c.arguments
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) OutDir() string {
|
|
|
|
if outDir, ok := c.environ.Get("OUT_DIR"); ok {
|
|
|
|
return outDir
|
|
|
|
}
|
|
|
|
return "out"
|
|
|
|
}
|
|
|
|
|
2017-02-05 02:30:44 +01:00
|
|
|
func (c *configImpl) DistDir() string {
|
|
|
|
if distDir, ok := c.environ.Get("DIST_DIR"); ok {
|
|
|
|
return distDir
|
|
|
|
}
|
|
|
|
return filepath.Join(c.OutDir(), "dist")
|
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func (c *configImpl) NinjaArgs() []string {
|
2017-08-05 00:06:27 +02:00
|
|
|
if c.skipMake {
|
|
|
|
return c.arguments
|
|
|
|
}
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
return c.ninjaArgs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SoongOutDir() string {
|
|
|
|
return filepath.Join(c.OutDir(), "soong")
|
|
|
|
}
|
|
|
|
|
2017-03-30 02:29:06 +02:00
|
|
|
func (c *configImpl) TempDir() string {
|
|
|
|
return shared.TempDirForOutDir(c.SoongOutDir())
|
|
|
|
}
|
|
|
|
|
2017-08-04 21:30:12 +02:00
|
|
|
func (c *configImpl) FileListDir() string {
|
|
|
|
return filepath.Join(c.OutDir(), ".module_paths")
|
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func (c *configImpl) KatiSuffix() string {
|
|
|
|
if c.katiSuffix != "" {
|
|
|
|
return c.katiSuffix
|
|
|
|
}
|
|
|
|
panic("SetKatiSuffix has not been called")
|
|
|
|
}
|
|
|
|
|
2017-02-05 02:30:44 +01:00
|
|
|
func (c *configImpl) Dist() bool {
|
|
|
|
return c.dist
|
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func (c *configImpl) IsVerbose() bool {
|
|
|
|
return c.verbose
|
|
|
|
}
|
|
|
|
|
2017-08-05 00:06:27 +02:00
|
|
|
func (c *configImpl) SkipMake() bool {
|
|
|
|
return c.skipMake
|
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func (c *configImpl) TargetProduct() string {
|
|
|
|
if v, ok := c.environ.Get("TARGET_PRODUCT"); ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
panic("TARGET_PRODUCT is not defined")
|
|
|
|
}
|
|
|
|
|
2017-05-13 04:28:13 +02:00
|
|
|
func (c *configImpl) TargetDevice() string {
|
|
|
|
return c.targetDevice
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SetTargetDevice(device string) {
|
|
|
|
c.targetDevice = device
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) TargetBuildVariant() string {
|
|
|
|
if v, ok := c.environ.Get("TARGET_BUILD_VARIANT"); ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
panic("TARGET_BUILD_VARIANT is not defined")
|
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func (c *configImpl) KatiArgs() []string {
|
|
|
|
return c.katiArgs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) Parallel() int {
|
|
|
|
return c.parallel
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) UseGoma() bool {
|
|
|
|
if v, ok := c.environ.Get("USE_GOMA"); ok {
|
|
|
|
v = strings.TrimSpace(v)
|
|
|
|
if v != "" && v != "false" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoteParallel controls how many remote jobs (i.e., commands which contain
|
2017-03-30 02:29:06 +02:00
|
|
|
// gomacc) are run in parallel. Note the parallelism of all other jobs is
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
// still limited by Parallel()
|
|
|
|
func (c *configImpl) RemoteParallel() int {
|
|
|
|
if v, ok := c.environ.Get("NINJA_REMOTE_NUM_JOBS"); ok {
|
|
|
|
if i, err := strconv.Atoi(v); err == nil {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 500
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SetKatiArgs(args []string) {
|
|
|
|
c.katiArgs = args
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SetNinjaArgs(args []string) {
|
|
|
|
c.ninjaArgs = args
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SetKatiSuffix(suffix string) {
|
|
|
|
c.katiSuffix = suffix
|
|
|
|
}
|
|
|
|
|
2017-08-05 00:06:27 +02:00
|
|
|
func (c *configImpl) LastKatiSuffixFile() string {
|
|
|
|
return filepath.Join(c.OutDir(), "last_kati_suffix")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) HasKatiSuffix() bool {
|
|
|
|
return c.katiSuffix != ""
|
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func (c *configImpl) KatiEnvFile() string {
|
|
|
|
return filepath.Join(c.OutDir(), "env"+c.KatiSuffix()+".sh")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) KatiNinjaFile() string {
|
|
|
|
return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+".ninja")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SoongNinjaFile() string {
|
|
|
|
return filepath.Join(c.SoongOutDir(), "build.ninja")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) CombinedNinjaFile() string {
|
2017-08-05 00:06:27 +02:00
|
|
|
if c.katiSuffix == "" {
|
|
|
|
return filepath.Join(c.OutDir(), "combined.ninja")
|
|
|
|
}
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
return filepath.Join(c.OutDir(), "combined"+c.KatiSuffix()+".ninja")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SoongAndroidMk() string {
|
|
|
|
return filepath.Join(c.SoongOutDir(), "Android-"+c.TargetProduct()+".mk")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) SoongMakeVarsMk() string {
|
|
|
|
return filepath.Join(c.SoongOutDir(), "make_vars-"+c.TargetProduct()+".mk")
|
|
|
|
}
|
|
|
|
|
2017-05-19 00:29:04 +02:00
|
|
|
func (c *configImpl) ProductOut() string {
|
2017-09-08 23:35:43 +02:00
|
|
|
return filepath.Join(c.OutDir(), "target", "product", c.TargetDevice())
|
2017-05-19 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
2017-05-13 04:28:13 +02:00
|
|
|
func (c *configImpl) DevicePreviousProductConfig() string {
|
2017-05-19 00:29:04 +02:00
|
|
|
return filepath.Join(c.ProductOut(), "previous_build_config.mk")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) hostOutRoot() string {
|
2017-09-08 23:35:43 +02:00
|
|
|
return filepath.Join(c.OutDir(), "host")
|
2017-05-19 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) HostOut() string {
|
|
|
|
return filepath.Join(c.hostOutRoot(), c.HostPrebuiltTag())
|
|
|
|
}
|
|
|
|
|
|
|
|
// This probably needs to be multi-valued, so not exporting it for now
|
|
|
|
func (c *configImpl) hostCrossOut() string {
|
|
|
|
if runtime.GOOS == "linux" {
|
|
|
|
return filepath.Join(c.hostOutRoot(), "windows-x86")
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
2017-05-13 04:28:13 +02:00
|
|
|
}
|
|
|
|
|
Add a Go replacement for our top-level Make wrapper
Right now this mostly just copies what Make is doing in
build/core/ninja.mk and build/core/soong.mk. The only major feature it
adds is a rotating log file with some verbose logging.
There is one major functional difference -- you cannot override random
Make variables during the Make phase anymore. The environment variable
is set, and if Make uses ?= or the equivalent, it can still use those
variables. We already made this change for Kati, which also loads all of
the same code and actually does the build, so it has been half-removed
for a while.
The only "UI" this implements is what I'll call "Make Emulation" mode --
it's expected that current command lines will continue working, and
we'll explore alternate user interfaces later.
We're still using Make as a wrapper, but all it does is call into this
single Go program, it won't even load the product configuration. Once
this is default, we can start moving individual users over to using this
directly (still in Make emulation mode), skipping the Make wrapper.
Ideas for the future:
* Generating trace files showing time spent in Make/Kati/Soong/Ninja
(also importing ninja traces into the same stream). I had this working
in a previous version of this patch, but removed it to keep the size
down and focus on the current features.
* More intelligent SIGALRM handling, once we fully remove the Make
wrapper (which hides the SIGALRM)
* Reading the experimental binary output stream from Ninja, so that we
can always save the verbose log even if we're not printing it out to
the console
Test: USE_SOONG_UI=true m -j blueprint_tools
Change-Id: I884327b9a8ae24499eb6c56f6e1ad26df1cfa4e4
2016-08-22 00:17:17 +02:00
|
|
|
func (c *configImpl) HostPrebuiltTag() string {
|
|
|
|
if runtime.GOOS == "linux" {
|
|
|
|
return "linux-x86"
|
|
|
|
} else if runtime.GOOS == "darwin" {
|
|
|
|
return "darwin-x86"
|
|
|
|
} else {
|
|
|
|
panic("Unsupported OS")
|
|
|
|
}
|
|
|
|
}
|
2017-04-27 23:28:00 +02:00
|
|
|
|
2017-10-13 05:20:41 +02:00
|
|
|
func (c *configImpl) PrebuiltBuildTool(name string) string {
|
2017-04-27 23:28:00 +02:00
|
|
|
if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
|
|
|
|
if sanitize := strings.Fields(v); inList("address", sanitize) {
|
2017-10-13 05:20:41 +02:00
|
|
|
asan := filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "asan/bin", name)
|
|
|
|
if _, err := os.Stat(asan); err == nil {
|
|
|
|
return asan
|
|
|
|
}
|
2017-04-27 23:28:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return filepath.Join("prebuilts/build-tools", c.HostPrebuiltTag(), "bin", name)
|
|
|
|
}
|