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 (
|
2023-09-28 22:56:30 +02:00
|
|
|
"android/soong/ui/metrics"
|
|
|
|
"android/soong/ui/status"
|
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
|
|
|
"crypto/md5"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
2019-01-02 21:21:18 +01:00
|
|
|
"os"
|
|
|
|
"os/user"
|
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"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
var spaceSlashReplacer = strings.NewReplacer("/", "_", " ", "_")
|
|
|
|
|
2018-09-26 23:58:30 +02:00
|
|
|
const katiBuildSuffix = ""
|
|
|
|
const katiCleanspecSuffix = "-cleanspec"
|
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
|
|
|
const katiPackageSuffix = "-package"
|
2018-09-26 23:58:30 +02:00
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// genKatiSuffix creates a filename suffix for kati-generated files so that we
|
|
|
|
// can cache them based on their inputs. Such files include the generated Ninja
|
|
|
|
// files and env.sh environment variable setup files.
|
|
|
|
//
|
|
|
|
// The filename suffix should encode all common changes to Kati inputs.
|
|
|
|
// Currently that includes the TARGET_PRODUCT and kati-processed command line
|
|
|
|
// 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
|
|
|
func genKatiSuffix(ctx Context, config Config) {
|
2020-11-18 08:43:19 +01:00
|
|
|
// Construct the base suffix.
|
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
|
|
|
katiSuffix := "-" + config.TargetProduct()
|
2020-11-18 08:43:19 +01:00
|
|
|
|
|
|
|
// Append kati arguments to the suffix.
|
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 args := config.KatiArgs(); len(args) > 0 {
|
|
|
|
katiSuffix += "-" + spaceSlashReplacer.Replace(strings.Join(args, "_"))
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the suffix is too long, replace it with a md5 hash and write a
|
|
|
|
// file that contains the original suffix.
|
|
|
|
if len(katiSuffix) > 64 {
|
|
|
|
shortSuffix := "-" + fmt.Sprintf("%x", md5.Sum([]byte(katiSuffix)))
|
|
|
|
config.SetKatiSuffix(shortSuffix)
|
|
|
|
|
|
|
|
ctx.Verbosef("Kati ninja suffix too long: %q", katiSuffix)
|
|
|
|
ctx.Verbosef("Replacing with: %q", shortSuffix)
|
|
|
|
|
2018-09-26 23:58:30 +02:00
|
|
|
if err := ioutil.WriteFile(strings.TrimSuffix(config.KatiBuildNinjaFile(), "ninja")+"suf", []byte(katiSuffix), 0777); err != nil {
|
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
|
|
|
ctx.Println("Error writing suffix file:", err)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
config.SetKatiSuffix(katiSuffix)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-26 14:06:24 +02:00
|
|
|
func writeValueIfChanged(ctx Context, config Config, dir string, filename string, value string) {
|
|
|
|
filePath := filepath.Join(dir, filename)
|
|
|
|
previousValue := ""
|
|
|
|
rawPreviousValue, err := ioutil.ReadFile(filePath)
|
|
|
|
if err == nil {
|
|
|
|
previousValue = string(rawPreviousValue)
|
|
|
|
}
|
|
|
|
|
|
|
|
if previousValue != value {
|
|
|
|
if err = ioutil.WriteFile(filePath, []byte(value), 0666); err != nil {
|
|
|
|
ctx.Fatalf("Failed to write: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Base function to construct and run the Kati command line with additional
|
|
|
|
// arguments, and a custom function closure to mutate the environment Kati runs
|
|
|
|
// in.
|
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 runKati(ctx Context, config Config, extraSuffix string, args []string, envFunc func(*Environment)) {
|
2017-04-27 23:28:00 +02:00
|
|
|
executable := config.PrebuiltBuildTool("ckati")
|
2020-11-18 08:43:19 +01:00
|
|
|
// cKati arguments.
|
2018-09-26 23:58:30 +02:00
|
|
|
args = append([]string{
|
2020-11-18 08:43:19 +01:00
|
|
|
// Instead of executing commands directly, generate a 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
|
|
|
"--ninja",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Generate Ninja files in the output directory.
|
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
|
|
|
"--ninja_dir=" + config.OutDir(),
|
2020-11-18 08:43:19 +01:00
|
|
|
// Filename suffix of the generated Ninja file.
|
2018-09-26 23:58:30 +02:00
|
|
|
"--ninja_suffix=" + config.KatiSuffix() + extraSuffix,
|
2020-11-18 08:43:19 +01:00
|
|
|
// Remove common parts at the beginning of a Ninja file, like build_dir,
|
|
|
|
// local_pool and _kati_always_build_. Allows Kati to be run multiple
|
|
|
|
// times, with generated Ninja files combined in a single invocation
|
|
|
|
// using 'include'.
|
2018-09-26 23:58:30 +02:00
|
|
|
"--no_ninja_prelude",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Support declaring phony outputs in AOSP Ninja.
|
2020-04-19 05:25:59 +02:00
|
|
|
"--use_ninja_phony_output",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Regenerate the Ninja file if environment inputs have changed. e.g.
|
|
|
|
// CLI flags, .mk file timestamps, env vars, $(wildcard ..) and some
|
|
|
|
// $(shell ..) results.
|
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
|
|
|
"--regen",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Skip '-include' directives starting with the specified path. Used to
|
|
|
|
// ignore generated .mk files.
|
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
|
|
|
"--ignore_optional_include=" + filepath.Join(config.OutDir(), "%.P"),
|
2020-11-18 08:43:19 +01:00
|
|
|
// Detect the use of $(shell echo ...).
|
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
|
|
|
"--detect_android_echo",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Colorful ANSI-based warning and error messages.
|
2017-02-24 19:53:23 +01:00
|
|
|
"--color_warnings",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Generate all targets, not just the top level requested ones.
|
2017-02-24 19:53:23 +01:00
|
|
|
"--gen_all_targets",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Use the built-in emulator of GNU find for better file finding
|
|
|
|
// performance. Used with $(shell find ...).
|
2018-09-26 23:58:30 +02:00
|
|
|
"--use_find_emulator",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when the find emulator encounters problems.
|
2017-05-30 23:07:45 +02:00
|
|
|
"--werror_find_emulator",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Do not provide any built-in rules.
|
2018-06-16 06:53:18 +02:00
|
|
|
"--no_builtin_rules",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when suffix rules are used.
|
2018-06-16 06:53:18 +02:00
|
|
|
"--werror_suffix_rules",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when a real target depends on a phony target.
|
2019-04-18 18:40:15 +02:00
|
|
|
"--werror_real_to_phony",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Makes real_to_phony checks assume that any top-level or leaf
|
|
|
|
// dependencies that does *not* have a '/' in it is a phony target.
|
|
|
|
"--top_level_phony",
|
|
|
|
// Fail when a phony target contains slashes.
|
2019-04-18 18:40:15 +02:00
|
|
|
"--werror_phony_looks_real",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when writing to a read-only directory.
|
2019-04-18 18:40:15 +02:00
|
|
|
"--werror_writable",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Print Kati's internal statistics, such as the number of variables,
|
|
|
|
// implicit/explicit/suffix rules, and so on.
|
2017-10-13 05:46:34 +02:00
|
|
|
"--kati_stats",
|
2018-09-26 23:58:30 +02:00
|
|
|
}, args...)
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Generate a minimal Ninja file.
|
|
|
|
//
|
|
|
|
// Used for build_test and multiproduct_kati, which runs Kati several
|
|
|
|
// hundred times for different configurations to test file generation logic.
|
|
|
|
// These can result in generating Ninja files reaching ~1GB or more,
|
|
|
|
// resulting in ~hundreds of GBs of writes.
|
|
|
|
//
|
|
|
|
// Since we don't care about executing the Ninja files in these test cases,
|
|
|
|
// generating the Ninja file content wastes time, so skip writing any
|
|
|
|
// information out with --empty_ninja_file.
|
|
|
|
//
|
|
|
|
// From https://github.com/google/kati/commit/87b8da7af2c8bea28b1d8ab17679453d859f96e5
|
2021-06-01 20:43:55 +02:00
|
|
|
if config.EmptyNinjaFile() {
|
2018-10-26 07:04:42 +02:00
|
|
|
args = append(args, "--empty_ninja_file")
|
|
|
|
}
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Apply 'local_pool' to to all rules that don't specify a pool.
|
2019-11-11 23:57:42 +01:00
|
|
|
if config.UseRemoteBuild() {
|
|
|
|
args = append(args, "--default_pool=local_pool")
|
|
|
|
}
|
|
|
|
|
2018-09-26 23:58:30 +02:00
|
|
|
cmd := Command(ctx, config, "ckati", executable, args...)
|
2020-11-18 08:43:19 +01:00
|
|
|
|
|
|
|
// Set up the nsjail sandbox.
|
2018-09-26 23:58:30 +02:00
|
|
|
cmd.Sandbox = katiSandbox
|
2020-11-18 08:43:19 +01:00
|
|
|
|
|
|
|
// Set up stdout and stderr.
|
2018-09-26 23:58:30 +02:00
|
|
|
pipe, err := cmd.StdoutPipe()
|
|
|
|
if err != nil {
|
|
|
|
ctx.Fatalln("Error getting output pipe for ckati:", err)
|
|
|
|
}
|
|
|
|
cmd.Stderr = cmd.Stdout
|
|
|
|
|
2023-04-26 14:06:24 +02:00
|
|
|
var username string
|
2020-11-18 08:43:19 +01:00
|
|
|
// Pass on various build environment metadata to Kati.
|
2023-04-26 14:06:24 +02:00
|
|
|
if usernameFromEnv, ok := cmd.Environment.Get("BUILD_USERNAME"); !ok {
|
|
|
|
username = "unknown"
|
2020-03-10 23:38:57 +01:00
|
|
|
if u, err := user.Current(); err == nil {
|
|
|
|
username = u.Username
|
|
|
|
} else {
|
|
|
|
ctx.Println("Failed to get current user:", err)
|
2019-01-02 21:21:18 +01:00
|
|
|
}
|
2020-03-10 23:38:57 +01:00
|
|
|
cmd.Environment.Set("BUILD_USERNAME", username)
|
2023-04-26 14:06:24 +02:00
|
|
|
} else {
|
|
|
|
username = usernameFromEnv
|
2019-01-02 21:21:18 +01:00
|
|
|
}
|
|
|
|
|
2023-04-26 14:06:24 +02:00
|
|
|
hostname, ok := cmd.Environment.Get("BUILD_HOSTNAME")
|
2023-05-22 23:59:39 +02:00
|
|
|
// Unset BUILD_HOSTNAME during kati run to avoid kati rerun, kati will use BUILD_HOSTNAME from a file.
|
|
|
|
cmd.Environment.Unset("BUILD_HOSTNAME")
|
2023-04-26 14:06:24 +02:00
|
|
|
if !ok {
|
|
|
|
hostname, err = os.Hostname()
|
2019-01-02 21:21:18 +01:00
|
|
|
if err != nil {
|
2020-03-10 23:38:57 +01:00
|
|
|
ctx.Println("Failed to read hostname:", err)
|
|
|
|
hostname = "unknown"
|
2019-01-02 21:21:18 +01:00
|
|
|
}
|
|
|
|
}
|
2023-04-26 14:06:24 +02:00
|
|
|
writeValueIfChanged(ctx, config, config.SoongOutDir(), "build_hostname.txt", hostname)
|
2023-09-28 22:56:30 +02:00
|
|
|
_, ok = cmd.Environment.Get("BUILD_NUMBER")
|
2023-05-22 23:59:39 +02:00
|
|
|
// Unset BUILD_NUMBER during kati run to avoid kati rerun, kati will use BUILD_NUMBER from a file.
|
|
|
|
cmd.Environment.Unset("BUILD_NUMBER")
|
2023-04-26 14:06:24 +02:00
|
|
|
if ok {
|
|
|
|
cmd.Environment.Set("HAS_BUILD_NUMBER", "true")
|
|
|
|
} else {
|
|
|
|
cmd.Environment.Set("HAS_BUILD_NUMBER", "false")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply the caller's function closure to mutate the environment variables.
|
|
|
|
envFunc(cmd.Environment)
|
2019-01-02 21:21:18 +01:00
|
|
|
|
2018-09-26 23:58:30 +02:00
|
|
|
cmd.StartOrFatal()
|
2020-11-18 08:43:19 +01:00
|
|
|
// Set up the ToolStatus command line reader for Kati for a consistent UI
|
|
|
|
// for the user.
|
2018-09-26 23:58:30 +02:00
|
|
|
status.KatiReader(ctx.Status.StartTool(), pipe)
|
|
|
|
cmd.WaitOrFatal()
|
|
|
|
}
|
|
|
|
|
|
|
|
func runKatiBuild(ctx Context, config Config) {
|
2018-12-13 01:01:49 +01:00
|
|
|
ctx.BeginTrace(metrics.RunKati, "kati build")
|
2018-09-26 23:58:30 +02:00
|
|
|
defer ctx.EndTrace()
|
|
|
|
|
|
|
|
args := []string{
|
2020-11-18 08:43:19 +01:00
|
|
|
// Mark the output directory as writable.
|
2018-09-01 05:25:32 +02:00
|
|
|
"--writable", config.OutDir() + "/",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when encountering implicit rules. e.g.
|
|
|
|
// %.foo: %.bar
|
|
|
|
// cp $< $@
|
2020-05-29 00:28:00 +02:00
|
|
|
"--werror_implicit_rules",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Entry point for the Kati Ninja file generation.
|
2017-07-14 02:24:44 +02:00
|
|
|
"-f", "build/make/core/main.mk",
|
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-04-05 07:25:56 +02:00
|
|
|
if !config.BuildBrokenDupRules() {
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when redefining / duplicating a target.
|
2018-04-05 07:25:56 +02:00
|
|
|
args = append(args, "--werror_overriding_commands")
|
|
|
|
}
|
|
|
|
|
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
|
|
|
args = append(args, config.KatiArgs()...)
|
|
|
|
|
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
|
|
|
args = append(args,
|
2020-11-18 08:43:19 +01:00
|
|
|
// Location of the Make vars .mk file generated by Soong.
|
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
|
|
|
"SOONG_MAKEVARS_MK="+config.SoongMakeVarsMk(),
|
2020-11-18 08:43:19 +01:00
|
|
|
// Location of the Android.mk file generated by Soong. This
|
|
|
|
// file contains Soong modules represented as Kati modules,
|
|
|
|
// allowing Kati modules to depend on Soong modules.
|
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
|
|
|
"SOONG_ANDROID_MK="+config.SoongAndroidMk(),
|
2020-11-18 08:43:19 +01:00
|
|
|
// Directory containing outputs for the target device.
|
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
|
|
|
"TARGET_DEVICE_DIR="+config.TargetDeviceDir(),
|
2020-11-18 08:43:19 +01:00
|
|
|
// Directory containing .mk files for packaging purposes, such as
|
|
|
|
// the dist.mk file, containing dist-for-goals data.
|
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
|
|
|
"KATI_PACKAGE_MK_DIR="+config.KatiPackageMkDir())
|
|
|
|
|
2018-10-21 06:33:41 +02:00
|
|
|
runKati(ctx, config, katiBuildSuffix, args, func(env *Environment) {})
|
2019-12-14 03:50:24 +01:00
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// compress and dist the main build ninja file.
|
2020-06-25 20:27:52 +02:00
|
|
|
distGzipFile(ctx, config, config.KatiBuildNinjaFile())
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Cleanup steps.
|
2019-12-14 03:50:24 +01:00
|
|
|
cleanCopyHeaders(ctx, config)
|
2021-03-09 21:02:15 +01:00
|
|
|
cleanOldInstalledFiles(ctx, config)
|
2019-12-14 03:50:24 +01:00
|
|
|
}
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Clean out obsolete header files on the disk that were *not copied* during the
|
|
|
|
// build with BUILD_COPY_HEADERS and LOCAL_COPY_HEADERS.
|
|
|
|
//
|
|
|
|
// These should be increasingly uncommon, as it's a deprecated feature and there
|
|
|
|
// isn't an equivalent feature in Soong.
|
2019-12-14 03:50:24 +01:00
|
|
|
func cleanCopyHeaders(ctx Context, config Config) {
|
|
|
|
ctx.BeginTrace("clean", "clean copy headers")
|
|
|
|
defer ctx.EndTrace()
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Read and parse the list of copied headers from a file in the product
|
|
|
|
// output directory.
|
2019-12-14 03:50:24 +01:00
|
|
|
data, err := ioutil.ReadFile(filepath.Join(config.ProductOut(), ".copied_headers_list"))
|
|
|
|
if err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ctx.Fatalf("Failed to read copied headers list: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
headers := strings.Fields(string(data))
|
|
|
|
if len(headers) < 1 {
|
|
|
|
ctx.Fatal("Failed to parse copied headers list: %q", string(data))
|
|
|
|
}
|
|
|
|
headerDir := headers[0]
|
|
|
|
headers = headers[1:]
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Walk the tree and remove any headers that are not in the list of copied
|
|
|
|
// headers in the current build.
|
2019-12-14 03:50:24 +01:00
|
|
|
filepath.Walk(headerDir,
|
|
|
|
func(path string, info os.FileInfo, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if info.IsDir() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if !inList(path, headers) {
|
|
|
|
ctx.Printf("Removing obsolete header %q", path)
|
|
|
|
if err := os.Remove(path); err != nil {
|
|
|
|
ctx.Fatalf("Failed to remove obsolete header %q: %v", path, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
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
|
|
|
}
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Clean out any previously installed files from the disk that are not installed
|
|
|
|
// in the current build.
|
2020-01-03 22:40:45 +01:00
|
|
|
func cleanOldInstalledFiles(ctx Context, config Config) {
|
|
|
|
ctx.BeginTrace("clean", "clean old installed files")
|
|
|
|
defer ctx.EndTrace()
|
|
|
|
|
|
|
|
// We shouldn't be removing files from one side of the two-step asan builds
|
|
|
|
var suffix string
|
|
|
|
if v, ok := config.Environment().Get("SANITIZE_TARGET"); ok {
|
|
|
|
if sanitize := strings.Fields(v); inList("address", sanitize) {
|
|
|
|
suffix = "_asan"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanOldFiles(ctx, config.ProductOut(), ".installable_files"+suffix)
|
|
|
|
|
|
|
|
cleanOldFiles(ctx, config.HostOut(), ".installable_test_files")
|
|
|
|
}
|
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Generate the Ninja file containing the packaging command lines for the dist
|
|
|
|
// dir.
|
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 runKatiPackage(ctx Context, config Config) {
|
2018-12-13 01:01:49 +01:00
|
|
|
ctx.BeginTrace(metrics.RunKati, "kati package")
|
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
|
|
|
defer ctx.EndTrace()
|
|
|
|
|
|
|
|
args := []string{
|
2020-11-18 08:43:19 +01:00
|
|
|
// Mark the dist dir as writable.
|
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
|
|
|
"--writable", config.DistDir() + "/",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when encountering implicit rules. e.g.
|
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
|
|
|
"--werror_implicit_rules",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when redefining / duplicating a target.
|
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
|
|
|
"--werror_overriding_commands",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Entry point.
|
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
|
|
|
"-f", "build/make/packaging/main.mk",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Directory containing .mk files for packaging purposes, such as
|
|
|
|
// the dist.mk file, containing dist-for-goals data.
|
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
|
|
|
"KATI_PACKAGE_MK_DIR=" + config.KatiPackageMkDir(),
|
|
|
|
}
|
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
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Run Kati against a restricted set of environment variables.
|
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
|
|
|
runKati(ctx, config, katiPackageSuffix, args, func(env *Environment) {
|
|
|
|
env.Allow([]string{
|
|
|
|
// Some generic basics
|
|
|
|
"LANG",
|
|
|
|
"LC_MESSAGES",
|
|
|
|
"PATH",
|
|
|
|
"PWD",
|
|
|
|
"TMPDIR",
|
|
|
|
|
|
|
|
// Tool configs
|
2019-08-21 23:56:13 +02:00
|
|
|
"ASAN_SYMBOLIZER_PATH",
|
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
|
|
|
"JAVA_HOME",
|
|
|
|
"PYTHONDONTWRITEBYTECODE",
|
|
|
|
|
|
|
|
// Build configuration
|
|
|
|
"ANDROID_BUILD_SHELL",
|
|
|
|
"DIST_DIR",
|
|
|
|
"OUT_DIR",
|
2023-04-26 14:06:24 +02:00
|
|
|
"FILE_NAME_TAG",
|
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
|
|
|
}...)
|
|
|
|
|
|
|
|
if config.Dist() {
|
|
|
|
env.Set("DIST", "true")
|
2018-10-21 06:33:41 +02:00
|
|
|
env.Set("DIST_DIR", config.DistDir())
|
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
|
|
|
}
|
|
|
|
})
|
2020-06-25 20:27:52 +02:00
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Compress and dist the packaging Ninja file.
|
2020-06-25 20:27:52 +02:00
|
|
|
distGzipFile(ctx, config, config.KatiPackageNinjaFile())
|
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-02-19 03:12:41 +01:00
|
|
|
|
2020-11-18 08:43:19 +01:00
|
|
|
// Run Kati on the cleanspec files to clean the build.
|
2017-07-25 07:26:54 +02:00
|
|
|
func runKatiCleanSpec(ctx Context, config Config) {
|
2018-12-13 01:01:49 +01:00
|
|
|
ctx.BeginTrace(metrics.RunKati, "kati cleanspec")
|
2017-07-25 07:26:54 +02:00
|
|
|
defer ctx.EndTrace()
|
|
|
|
|
2018-09-26 23:58:30 +02:00
|
|
|
runKati(ctx, config, katiCleanspecSuffix, []string{
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when encountering implicit rules. e.g.
|
2018-09-26 23:58:30 +02:00
|
|
|
"--werror_implicit_rules",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Fail when redefining / duplicating a target.
|
2018-04-05 07:25:56 +02:00
|
|
|
"--werror_overriding_commands",
|
2020-11-18 08:43:19 +01:00
|
|
|
// Entry point.
|
2017-07-25 07:26:54 +02:00
|
|
|
"-f", "build/make/core/cleanbuild.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
|
|
|
"SOONG_MAKEVARS_MK=" + config.SoongMakeVarsMk(),
|
|
|
|
"TARGET_DEVICE_DIR=" + config.TargetDeviceDir(),
|
2018-10-21 06:33:41 +02:00
|
|
|
}, func(env *Environment) {})
|
2017-07-25 07:26:54 +02:00
|
|
|
}
|