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 (
|
2018-02-14 22:27:26 +01:00
|
|
|
"io/ioutil"
|
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"
|
2018-02-14 22:27:26 +01:00
|
|
|
"time"
|
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
|
2018-10-21 06:33:41 +02:00
|
|
|
distDir 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
|
|
|
|
|
|
|
// From the arguments
|
2017-11-17 02:55:00 +01:00
|
|
|
parallel int
|
|
|
|
keepGoing int
|
|
|
|
verbose bool
|
|
|
|
checkbuild bool
|
|
|
|
dist bool
|
|
|
|
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
|
2018-05-02 09:06:28 +02:00
|
|
|
katiArgs []string
|
|
|
|
ninjaArgs []string
|
|
|
|
katiSuffix string
|
|
|
|
targetDevice string
|
|
|
|
targetDeviceDir string
|
2018-04-05 07:25:56 +02:00
|
|
|
|
2018-08-28 00:01:03 +02:00
|
|
|
pdkBuild bool
|
|
|
|
|
2019-04-18 18:40:15 +02:00
|
|
|
brokenDupRules bool
|
|
|
|
brokenUsesNetwork bool
|
2018-05-26 01:30:04 +02:00
|
|
|
|
|
|
|
pathReplaced 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
|
|
|
}
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
const srcDirFileCheck = "build/soong/root.bp"
|
|
|
|
|
2019-04-23 02:12:02 +02:00
|
|
|
type BuildAction uint
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Builds all of the modules and their dependencies of a specified directory, relative to the root
|
|
|
|
// directory of the source tree.
|
|
|
|
BUILD_MODULES_IN_A_DIRECTORY BuildAction = iota
|
|
|
|
|
|
|
|
// Builds all of the modules and their dependencies of a list of specified directories. All specified
|
|
|
|
// directories are relative to the root directory of the source tree.
|
|
|
|
BUILD_MODULES_IN_DIRECTORIES
|
2019-06-21 01:35:12 +02:00
|
|
|
|
|
|
|
// Build a list of specified modules. If none was specified, simply build the whole source tree.
|
|
|
|
BUILD_MODULES
|
2019-04-23 02:12:02 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// checkTopDir validates that the current directory is at the root directory of the source tree.
|
|
|
|
func checkTopDir(ctx Context) {
|
|
|
|
if _, err := os.Stat(srcDirFileCheck); err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
ctx.Fatalf("Current working directory must be the source tree. %q not found.", srcDirFileCheck)
|
|
|
|
}
|
|
|
|
ctx.Fatalln("Error verifying tree state:", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2018-10-21 06:33:41 +02:00
|
|
|
if distDir, ok := ret.environ.Get("DIST_DIR"); ok {
|
|
|
|
ret.distDir = filepath.Clean(distDir)
|
|
|
|
} else {
|
|
|
|
ret.distDir = filepath.Join(ret.OutDir(), "dist")
|
|
|
|
}
|
2018-10-17 02:49:25 +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
|
|
|
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
|
|
|
|
2018-10-21 06:33:41 +02:00
|
|
|
// This is handled above too, and set for individual commands later
|
|
|
|
"DIST_DIR",
|
|
|
|
|
2017-04-18 22:56:57 +02:00
|
|
|
// Variables that have caused problems in the past
|
2018-05-01 19:07:50 +02:00
|
|
|
"CDPATH",
|
2017-04-18 22:56:57 +02:00
|
|
|
"DISPLAY",
|
|
|
|
"GREP_OPTIONS",
|
2018-05-01 19:07:50 +02:00
|
|
|
"NDK_ROOT",
|
2018-08-16 00:35:38 +02:00
|
|
|
"POSIXLY_CORRECT",
|
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",
|
2018-07-11 23:49:31 +02:00
|
|
|
|
|
|
|
// Set by envsetup.sh, but shouldn't be used inside the build because envsetup.sh is optional
|
|
|
|
"ANDROID_BUILD_TOP",
|
|
|
|
"ANDROID_HOST_OUT",
|
|
|
|
"ANDROID_PRODUCT_OUT",
|
|
|
|
"ANDROID_HOST_OUT_TESTCASES",
|
|
|
|
"ANDROID_TARGET_OUT_TESTCASES",
|
|
|
|
"ANDROID_TOOLCHAIN",
|
|
|
|
"ANDROID_TOOLCHAIN_2ND_ARCH",
|
|
|
|
"ANDROID_DEV_SCRIPTS",
|
|
|
|
"ANDROID_EMULATOR_PREBUILTS",
|
|
|
|
"ANDROID_PRE_BUILD_PATHS",
|
2018-10-26 07:04:42 +02:00
|
|
|
|
|
|
|
// Only set in multiproduct_kati after config generation
|
|
|
|
"EMPTY_NINJA_FILE",
|
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")
|
|
|
|
|
2018-03-09 04:42:00 +01:00
|
|
|
ret.environ.Set("TMPDIR", absPath(ctx, ret.TempDir()))
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
// Precondition: the current directory is the top of the source tree
|
2019-04-23 02:12:02 +02:00
|
|
|
checkTopDir(ctx)
|
2017-01-20 23:10:01 +01:00
|
|
|
|
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
|
2017-12-20 23:40:39 +01:00
|
|
|
java8Home := filepath.Join("prebuilts/jdk/jdk8", ret.HostPrebuiltTag())
|
|
|
|
java9Home := filepath.Join("prebuilts/jdk/jdk9", ret.HostPrebuiltTag())
|
2017-10-30 21:42:06 +01:00
|
|
|
javaHome := func() string {
|
|
|
|
if override, ok := ret.environ.Get("OVERRIDE_ANDROID_JAVA_HOME"); ok {
|
|
|
|
return override
|
|
|
|
}
|
2018-06-20 07:49:39 +02:00
|
|
|
return java9Home
|
2017-10-30 21:42:06 +01:00
|
|
|
}()
|
|
|
|
absJavaHome := absPath(ctx, javaHome)
|
|
|
|
|
2018-01-08 23:58:46 +01:00
|
|
|
ret.configureLocale(ctx)
|
|
|
|
|
2017-10-30 21:42:06 +01:00
|
|
|
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)
|
2017-12-20 23:40:39 +01:00
|
|
|
ret.environ.Set("ANDROID_JAVA8_HOME", java8Home)
|
|
|
|
ret.environ.Set("ANDROID_JAVA9_HOME", java9Home)
|
2017-10-30 21:42:06 +01:00
|
|
|
ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
|
|
|
|
|
2018-02-14 22:27:26 +01:00
|
|
|
outDir := ret.OutDir()
|
|
|
|
buildDateTimeFile := filepath.Join(outDir, "build_date.txt")
|
|
|
|
var content string
|
|
|
|
if buildDateTime, ok := ret.environ.Get("BUILD_DATETIME"); ok && buildDateTime != "" {
|
|
|
|
content = buildDateTime
|
|
|
|
} else {
|
|
|
|
content = strconv.FormatInt(time.Now().Unix(), 10)
|
|
|
|
}
|
2018-12-13 01:01:49 +01:00
|
|
|
if ctx.Metrics != nil {
|
|
|
|
ctx.Metrics.SetBuildDateTime(content)
|
|
|
|
}
|
2018-02-14 22:27:26 +01:00
|
|
|
err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
|
|
|
|
}
|
|
|
|
ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
|
|
|
|
|
2017-07-11 07:13:00 +02:00
|
|
|
return Config{ret}
|
|
|
|
}
|
|
|
|
|
2019-04-23 02:12:02 +02:00
|
|
|
// NewBuildActionConfig returns a build configuration based on the build action. The arguments are
|
|
|
|
// processed based on the build action and extracts any arguments that belongs to the build action.
|
|
|
|
func NewBuildActionConfig(action BuildAction, dir string, buildDependencies bool, ctx Context, args ...string) Config {
|
|
|
|
return NewConfig(ctx, getConfigArgs(action, dir, buildDependencies, ctx, args)...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// getConfigArgs processes the command arguments based on the build action and creates a set of new
|
|
|
|
// arguments to be accepted by Config.
|
|
|
|
func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx Context, args []string) []string {
|
|
|
|
// The next block of code verifies that the current directory is the root directory of the source
|
|
|
|
// tree. It then finds the relative path of dir based on the root directory of the source tree
|
|
|
|
// and verify that dir is inside of the source tree.
|
|
|
|
checkTopDir(ctx)
|
|
|
|
topDir, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
ctx.Fatalf("Error retrieving top directory: %v", err)
|
|
|
|
}
|
2019-07-03 19:47:34 +02:00
|
|
|
dir, err = filepath.EvalSymlinks(dir)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Fatalf("Unable to evaluate symlink of %s: %v", dir, err)
|
|
|
|
}
|
2019-04-23 02:12:02 +02:00
|
|
|
dir, err = filepath.Abs(dir)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Fatalf("Unable to find absolute path %s: %v", dir, err)
|
|
|
|
}
|
|
|
|
relDir, err := filepath.Rel(topDir, dir)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Fatalf("Unable to find relative path %s of %s: %v", relDir, topDir, err)
|
|
|
|
}
|
|
|
|
// If there are ".." in the path, it's not in the source tree.
|
|
|
|
if strings.Contains(relDir, "..") {
|
|
|
|
ctx.Fatalf("Directory %s is not under the source tree %s", dir, topDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
configArgs := args[:]
|
|
|
|
|
|
|
|
// If the arguments contains GET-INSTALL-PATH, change the target name prefix from MODULES-IN- to
|
|
|
|
// GET-INSTALL-PATH-IN- to extract the installation path instead of building the modules.
|
|
|
|
targetNamePrefix := "MODULES-IN-"
|
|
|
|
if inList("GET-INSTALL-PATH", configArgs) {
|
|
|
|
targetNamePrefix = "GET-INSTALL-PATH-IN-"
|
|
|
|
configArgs = removeFromList("GET-INSTALL-PATH", configArgs)
|
|
|
|
}
|
|
|
|
|
|
|
|
var buildFiles []string
|
|
|
|
var targets []string
|
|
|
|
|
|
|
|
switch action {
|
2019-06-21 01:35:12 +02:00
|
|
|
case BUILD_MODULES:
|
|
|
|
// No additional processing is required when building a list of specific modules or all modules.
|
2019-04-23 02:12:02 +02:00
|
|
|
case BUILD_MODULES_IN_A_DIRECTORY:
|
|
|
|
// If dir is the root source tree, all the modules are built of the source tree are built so
|
|
|
|
// no need to find the build file.
|
|
|
|
if topDir == dir {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
// Find the build file from the directory where the build action was triggered by traversing up
|
|
|
|
// the source tree. If a blank build filename is returned, simply use the directory where the build
|
|
|
|
// action was invoked.
|
|
|
|
buildFile := findBuildFile(ctx, relDir)
|
|
|
|
if buildFile == "" {
|
|
|
|
buildFile = filepath.Join(relDir, "Android.mk")
|
|
|
|
}
|
|
|
|
buildFiles = []string{buildFile}
|
|
|
|
targets = []string{convertToTarget(filepath.Dir(buildFile), targetNamePrefix)}
|
|
|
|
case BUILD_MODULES_IN_DIRECTORIES:
|
|
|
|
newConfigArgs, dirs := splitArgs(configArgs)
|
|
|
|
configArgs = newConfigArgs
|
|
|
|
targets, buildFiles = getTargetsFromDirs(ctx, relDir, dirs, targetNamePrefix)
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is to support building modules without building their dependencies. Soon, this will be
|
|
|
|
// deprecated.
|
|
|
|
if !buildDependencies && len(buildFiles) > 0 {
|
|
|
|
if err := os.Setenv("ONE_SHOT_MAKEFILE", strings.Join(buildFiles, " ")); err != nil {
|
|
|
|
ctx.Fatalf("Unable to set ONE_SHOT_MAKEFILE environment variable: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tidy only override all other specified targets.
|
|
|
|
tidyOnly := os.Getenv("WITH_TIDY_ONLY")
|
|
|
|
if tidyOnly == "true" || tidyOnly == "1" {
|
|
|
|
configArgs = append(configArgs, "tidy_only")
|
|
|
|
} else {
|
|
|
|
configArgs = append(configArgs, targets...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return configArgs
|
|
|
|
}
|
|
|
|
|
|
|
|
// convertToTarget replaces "/" to "-" in dir and pre-append the targetNamePrefix to the target name.
|
|
|
|
func convertToTarget(dir string, targetNamePrefix string) string {
|
|
|
|
return targetNamePrefix + strings.ReplaceAll(dir, "/", "-")
|
|
|
|
}
|
|
|
|
|
|
|
|
// findBuildFile finds a build file (makefile or blueprint file) by looking at dir first. If not
|
|
|
|
// found, go up one level and repeat again until one is found and the path of that build file
|
|
|
|
// relative to the root directory of the source tree is returned. The returned filename of build
|
|
|
|
// file is "Android.mk". If one was not found, a blank string is returned.
|
|
|
|
func findBuildFile(ctx Context, dir string) string {
|
|
|
|
// If the string is empty, assume it is top directory of the source tree.
|
|
|
|
if dir == "" {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
for ; dir != "."; dir = filepath.Dir(dir) {
|
|
|
|
for _, buildFile := range []string{"Android.bp", "Android.mk"} {
|
|
|
|
_, err := os.Stat(filepath.Join(dir, buildFile))
|
|
|
|
if err == nil {
|
|
|
|
// Returning the filename Android.mk as it might be used for ONE_SHOT_MAKEFILE variable.
|
|
|
|
return filepath.Join(dir, "Android.mk")
|
|
|
|
}
|
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
ctx.Fatalf("Error retrieving the build file stats: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// splitArgs iterates over the arguments list and splits into two lists: arguments and directories.
|
|
|
|
func splitArgs(args []string) (newArgs []string, dirs []string) {
|
|
|
|
specialArgs := map[string]bool{
|
|
|
|
"showcommands": true,
|
|
|
|
"snod": true,
|
|
|
|
"dist": true,
|
|
|
|
"checkbuild": true,
|
|
|
|
}
|
|
|
|
|
|
|
|
newArgs = []string{}
|
|
|
|
dirs = []string{}
|
|
|
|
|
|
|
|
for _, arg := range args {
|
|
|
|
// It's a dash argument if it starts with "-" or it's a key=value pair, it's not a directory.
|
|
|
|
if strings.IndexRune(arg, '-') == 0 || strings.IndexRune(arg, '=') != -1 {
|
|
|
|
newArgs = append(newArgs, arg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := specialArgs[arg]; ok {
|
|
|
|
newArgs = append(newArgs, arg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
dirs = append(dirs, arg)
|
|
|
|
}
|
|
|
|
|
|
|
|
return newArgs, dirs
|
|
|
|
}
|
|
|
|
|
|
|
|
// getTargetsFromDirs iterates over the dirs list and creates a list of targets to build. If a
|
|
|
|
// directory from the dirs list does not exist, a fatal error is raised. relDir is related to the
|
|
|
|
// source root tree where the build action command was invoked. Each directory is validated if the
|
|
|
|
// build file can be found and follows the format "dir1:target1,target2,...". Target is optional.
|
|
|
|
func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePrefix string) (targets []string, buildFiles []string) {
|
|
|
|
for _, dir := range dirs {
|
|
|
|
// The directory may have specified specific modules to build. ":" is the separator to separate
|
|
|
|
// the directory and the list of modules.
|
|
|
|
s := strings.Split(dir, ":")
|
|
|
|
l := len(s)
|
|
|
|
if l > 2 { // more than one ":" was specified.
|
|
|
|
ctx.Fatalf("%s not in proper directory:target1,target2,... format (\":\" was specified more than once)", dir)
|
|
|
|
}
|
|
|
|
|
|
|
|
dir = filepath.Join(relDir, s[0])
|
|
|
|
if _, err := os.Stat(dir); err != nil {
|
|
|
|
ctx.Fatalf("couldn't find directory %s", dir)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that if there are any targets specified after ":". Each target is separated by ",".
|
|
|
|
var newTargets []string
|
|
|
|
if l == 2 && s[1] != "" {
|
|
|
|
newTargets = strings.Split(s[1], ",")
|
|
|
|
if inList("", newTargets) {
|
|
|
|
ctx.Fatalf("%s not in proper directory:target1,target2,... format", dir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildFile := findBuildFile(ctx, dir)
|
|
|
|
if buildFile == "" {
|
|
|
|
ctx.Fatalf("Build file not found for %s directory", dir)
|
|
|
|
}
|
|
|
|
buildFileDir := filepath.Dir(buildFile)
|
|
|
|
|
|
|
|
// If there are specified targets, find the build file in the directory. If dir does not
|
|
|
|
// contain the build file, bail out as it is required for one shot build. If there are no
|
|
|
|
// target specified, build all the modules in dir (or the closest one in the dir path).
|
|
|
|
if len(newTargets) > 0 {
|
|
|
|
if buildFileDir != dir {
|
|
|
|
ctx.Fatalf("Couldn't locate a build file from %s directory", dir)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
newTargets = []string{convertToTarget(buildFileDir, targetNamePrefix)}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildFiles = append(buildFiles, buildFile)
|
|
|
|
targets = append(targets, newTargets...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return targets, buildFiles
|
|
|
|
}
|
|
|
|
|
2017-07-11 07:13:00 +02:00
|
|
|
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)
|
2018-10-21 06:33:41 +02:00
|
|
|
} else if arg == "dist" {
|
|
|
|
c.dist = true
|
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 {
|
2018-10-21 06:33:41 +02:00
|
|
|
if arg == "checkbuild" {
|
2017-11-17 02:55:00 +01:00
|
|
|
c.checkbuild = true
|
2017-08-05 00:06:27 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-08 23:58:46 +01:00
|
|
|
func (c *configImpl) configureLocale(ctx Context) {
|
|
|
|
cmd := Command(ctx, Config{c}, "locale", "locale", "-a")
|
|
|
|
output, err := cmd.Output()
|
|
|
|
|
|
|
|
var locales []string
|
|
|
|
if err == nil {
|
|
|
|
locales = strings.Split(string(output), "\n")
|
|
|
|
} else {
|
|
|
|
// If we're unable to list the locales, let's assume en_US.UTF-8
|
|
|
|
locales = []string{"en_US.UTF-8"}
|
|
|
|
ctx.Verbosef("Failed to list locales (%q), falling back to %q", err, locales)
|
|
|
|
}
|
|
|
|
|
|
|
|
// gettext uses LANGUAGE, which is passed directly through
|
|
|
|
|
|
|
|
// For LANG and LC_*, only preserve the evaluated version of
|
|
|
|
// LC_MESSAGES
|
|
|
|
user_lang := ""
|
|
|
|
if lc_all, ok := c.environ.Get("LC_ALL"); ok {
|
|
|
|
user_lang = lc_all
|
|
|
|
} else if lc_messages, ok := c.environ.Get("LC_MESSAGES"); ok {
|
|
|
|
user_lang = lc_messages
|
|
|
|
} else if lang, ok := c.environ.Get("LANG"); ok {
|
|
|
|
user_lang = lang
|
|
|
|
}
|
|
|
|
|
|
|
|
c.environ.UnsetWithPrefix("LC_")
|
|
|
|
|
|
|
|
if user_lang != "" {
|
|
|
|
c.environ.Set("LC_MESSAGES", user_lang)
|
|
|
|
}
|
|
|
|
|
|
|
|
// The for LANG, use C.UTF-8 if it exists (Debian currently, proposed
|
|
|
|
// for others)
|
|
|
|
if inList("C.UTF-8", locales) {
|
|
|
|
c.environ.Set("LANG", "C.UTF-8")
|
2018-08-08 02:21:36 +02:00
|
|
|
} else if inList("C.utf8", locales) {
|
|
|
|
// These normalize to the same thing
|
|
|
|
c.environ.Set("LANG", "C.UTF-8")
|
2018-01-08 23:58:46 +01:00
|
|
|
} else if inList("en_US.UTF-8", locales) {
|
|
|
|
c.environ.Set("LANG", "en_US.UTF-8")
|
|
|
|
} else if inList("en_US.utf8", locales) {
|
|
|
|
// These normalize to the same thing
|
|
|
|
c.environ.Set("LANG", "en_US.UTF-8")
|
|
|
|
} else {
|
|
|
|
ctx.Fatalln("System doesn't support either C.UTF-8 or en_US.UTF-8")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 "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 {
|
2018-09-01 05:25:32 +02:00
|
|
|
return filepath.Clean(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
|
|
|
}
|
|
|
|
return "out"
|
|
|
|
}
|
|
|
|
|
2017-02-05 02:30:44 +01:00
|
|
|
func (c *configImpl) DistDir() string {
|
2018-10-21 06:33:41 +02:00
|
|
|
return c.distDir
|
2017-02-05 02:30:44 +01: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) 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-11-17 02:55:00 +01:00
|
|
|
// Checkbuild returns true if "checkbuild" was one of the build goals, which means that the
|
|
|
|
// user is interested in additional checks at the expense of build time.
|
|
|
|
func (c *configImpl) Checkbuild() bool {
|
|
|
|
return c.checkbuild
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-01-10 02:14:16 +01:00
|
|
|
func (c *configImpl) StartGoma() bool {
|
|
|
|
if !c.UseGoma() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if v, ok := c.environ.Get("NOSTART_GOMA"); ok {
|
|
|
|
v = strings.TrimSpace(v)
|
|
|
|
if v != "" && v != "false" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// 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")
|
|
|
|
}
|
|
|
|
|
2018-09-26 23:58:30 +02:00
|
|
|
func (c *configImpl) KatiBuildNinjaFile() string {
|
|
|
|
return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+katiBuildSuffix+".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
|
|
|
}
|
|
|
|
|
Add a Kati-based packaging step
The idea is that we'd move the installation and packaging tasks over to
it, using data from Soong & the Kati reading Android.mk files.
This would allow us to make more fundamental changes about how we
package things without having to adjust makefiles throughout the tree.
Possible use cases:
* Moving some information from Soong's Android.mk output to a file read
by the packaging step may allow us to read the Android.mk files less
often, speeding up builds.
* Refactoring our current two-stage ASAN builds to run the Kati build
step twice, writing into different object directories, then have a
single packaging step that reads both outputs. Soong already has the
capability of writing out a single ninja file with all the asan
combinations.
* Running two build steps, one building the system-related modules
using a "generic" device configuration, and one building the vendor
modules using a specific device configuration. This could enforce a
GSI/mainline system vs vendor split in a single build invocation.
* If all installation is through this tool, it will be much easier to
track what should no longer be installed on an incremental build,
reducing the need for installclean.
* Changing PRODUCT_PACKAGES should be a much faster operation, which
means we could keep track of local additions to the images. Then
`mma` would be more persistent, instead of installing something once,
then never updating it again.
Eventually we plan on switching from Kati to something Go-based, but
this is a more incremental approach while we clean up everything else.
Currently, this just moves the dist-for-goal handling over to the
packaging step, so that we don't need to read Android.mk files when
DIST_DIR changes, or we switch between dist vs not.
Bug: 116968624
Bug: 117463001
Test: m nothing
Change-Id: Idec5ac6f7c7475397ba0fb65bd3785128a7517df
2018-09-27 00:00:42 +02:00
|
|
|
func (c *configImpl) KatiPackageNinjaFile() string {
|
|
|
|
return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+katiPackageSuffix+".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
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
Add a Kati-based packaging step
The idea is that we'd move the installation and packaging tasks over to
it, using data from Soong & the Kati reading Android.mk files.
This would allow us to make more fundamental changes about how we
package things without having to adjust makefiles throughout the tree.
Possible use cases:
* Moving some information from Soong's Android.mk output to a file read
by the packaging step may allow us to read the Android.mk files less
often, speeding up builds.
* Refactoring our current two-stage ASAN builds to run the Kati build
step twice, writing into different object directories, then have a
single packaging step that reads both outputs. Soong already has the
capability of writing out a single ninja file with all the asan
combinations.
* Running two build steps, one building the system-related modules
using a "generic" device configuration, and one building the vendor
modules using a specific device configuration. This could enforce a
GSI/mainline system vs vendor split in a single build invocation.
* If all installation is through this tool, it will be much easier to
track what should no longer be installed on an incremental build,
reducing the need for installclean.
* Changing PRODUCT_PACKAGES should be a much faster operation, which
means we could keep track of local additions to the images. Then
`mma` would be more persistent, instead of installing something once,
then never updating it again.
Eventually we plan on switching from Kati to something Go-based, but
this is a more incremental approach while we clean up everything else.
Currently, this just moves the dist-for-goal handling over to the
packaging step, so that we don't need to read Android.mk files when
DIST_DIR changes, or we switch between dist vs not.
Bug: 116968624
Bug: 117463001
Test: m nothing
Change-Id: Idec5ac6f7c7475397ba0fb65bd3785128a7517df
2018-09-27 00:00:42 +02:00
|
|
|
func (c *configImpl) KatiPackageMkDir() string {
|
|
|
|
return filepath.Join(c.ProductOut(), "obj", "CONFIG", "kati_packaging")
|
|
|
|
}
|
|
|
|
|
2017-05-19 00:29:04 +02:00
|
|
|
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)
|
|
|
|
}
|
2018-04-05 07:25:56 +02:00
|
|
|
|
|
|
|
func (c *configImpl) SetBuildBrokenDupRules(val bool) {
|
|
|
|
c.brokenDupRules = val
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) BuildBrokenDupRules() bool {
|
|
|
|
return c.brokenDupRules
|
|
|
|
}
|
2018-05-02 09:06:28 +02:00
|
|
|
|
2019-04-09 19:22:43 +02:00
|
|
|
func (c *configImpl) SetBuildBrokenUsesNetwork(val bool) {
|
|
|
|
c.brokenUsesNetwork = val
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) BuildBrokenUsesNetwork() bool {
|
|
|
|
return c.brokenUsesNetwork
|
|
|
|
}
|
|
|
|
|
2018-05-02 09:06:28 +02:00
|
|
|
func (c *configImpl) SetTargetDeviceDir(dir string) {
|
|
|
|
c.targetDeviceDir = dir
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) TargetDeviceDir() string {
|
|
|
|
return c.targetDeviceDir
|
|
|
|
}
|
2018-06-16 06:54:47 +02:00
|
|
|
|
|
|
|
func (c *configImpl) SetPdkBuild(pdk bool) {
|
|
|
|
c.pdkBuild = pdk
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configImpl) IsPdkBuild() bool {
|
|
|
|
return c.pdkBuild
|
|
|
|
}
|