Merge "Remove the out/soong/.bootstrap directory." am: 5a60909cbd am: 53c59a8abb

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1878498

Change-Id: Id41dc693250ab841251802caf25b67aea4fc7e65
This commit is contained in:
Lukács T. Berki
2021-11-04 15:36:09 +00:00
committed by Automerger Merge Worker
7 changed files with 49 additions and 42 deletions

View File

@@ -4,12 +4,26 @@
# that will be passed to rbcrun. # that will be passed to rbcrun.
[[ $# -gt 0 && -f "$1" ]] || { echo "Usage: ${0##*/} product.mk [Additional rbcrun arguments]" >&2; exit 1; } [[ $# -gt 0 && -f "$1" ]] || { echo "Usage: ${0##*/} product.mk [Additional rbcrun arguments]" >&2; exit 1; }
set -eu set -eu
declare -r output_root=${OUT_DIR:-out}
declare -r runner="$output_root/soong/.bootstrap/bin/rbcrun" case $(uname -s) in
declare -r converter="$output_root/soong/.bootstrap/bin/mk2rbc" Linux)
declare -r launcher=$output_root/launchers/run.rbc declare -r os="linux-x86";
declare -r makefile=$1 ;;
shift Darwin)
$converter -mode=write -r --outdir $output_root --launcher=$launcher $makefile declare -r os="darwin-x86";
$runner RBC_OUT="make,global" RBC_DEBUG="${RBC_DEBUG:-}" $@ $launcher ;;
*)
echo "Unknown OS: $(uname -s)" >&2;
exit 1;
;;
esac
declare -r output_root="${OUT_DIR:-out}"
declare -r runner="${output_root}/soong/host/${os}/bin/rbcrun"
declare -r converter="${output_root}/soong/host/${os}/bin/mk2rbc"
declare -r launcher="$output_root/launchers/run.rbc"
declare -r makefile="$1"
shift
"$converter" -mode=write -r --outdir "$output_root" --launcher="$launcher" "$makefile"
"$runner" RBC_OUT="make,global" RBC_DEBUG="${RBC_DEBUG:-}" $@ "$launcher"

View File

@@ -17,10 +17,10 @@ function test_smoke {
function test_null_build() { function test_null_build() {
setup setup
run_soong run_soong
local bootstrap_mtime1=$(stat -c "%y" out/soong/.bootstrap/build.ninja) local bootstrap_mtime1=$(stat -c "%y" out/soong/bootstrap.ninja)
local output_mtime1=$(stat -c "%y" out/soong/build.ninja) local output_mtime1=$(stat -c "%y" out/soong/build.ninja)
run_soong run_soong
local bootstrap_mtime2=$(stat -c "%y" out/soong/.bootstrap/build.ninja) local bootstrap_mtime2=$(stat -c "%y" out/soong/bootstrap.ninja)
local output_mtime2=$(stat -c "%y" out/soong/build.ninja) local output_mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$bootstrap_mtime1" == "$bootstrap_mtime2" ]]; then if [[ "$bootstrap_mtime1" == "$bootstrap_mtime2" ]]; then
@@ -36,12 +36,12 @@ function test_null_build() {
function test_soong_build_rebuilt_if_blueprint_changes() { function test_soong_build_rebuilt_if_blueprint_changes() {
setup setup
run_soong run_soong
local mtime1=$(stat -c "%y" out/soong/.bootstrap/build.ninja) local mtime1=$(stat -c "%y" out/soong/bootstrap.ninja)
sed -i 's/pluginGenSrcCmd/pluginGenSrcCmd2/g' build/blueprint/bootstrap/bootstrap.go sed -i 's/pluginGenSrcCmd/pluginGenSrcCmd2/g' build/blueprint/bootstrap/bootstrap.go
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/.bootstrap/build.ninja) local mtime2=$(stat -c "%y" out/soong/bootstrap.ninja)
if [[ "$mtime1" == "$mtime2" ]]; then if [[ "$mtime1" == "$mtime2" ]]; then
fail "Bootstrap Ninja file did not change" fail "Bootstrap Ninja file did not change"
@@ -541,7 +541,7 @@ EOF
function test_bp2build_smoke { function test_bp2build_smoke {
setup setup
run_soong bp2build run_soong bp2build
[[ -e out/soong/.bootstrap/bp2build_workspace_marker ]] || fail "bp2build marker file not created" [[ -e out/soong/bp2build_workspace_marker ]] || fail "bp2build marker file not created"
[[ -e out/soong/workspace ]] || fail "Bazel workspace not created" [[ -e out/soong/workspace ]] || fail "Bazel workspace not created"
} }
@@ -551,7 +551,7 @@ function test_bp2build_generates_marker_file {
run_soong bp2build run_soong bp2build
if [[ ! -f "./out/soong/.bootstrap/bp2build_workspace_marker" ]]; then if [[ ! -f "./out/soong/bp2build_workspace_marker" ]]; then
fail "Marker file was not generated" fail "Marker file was not generated"
fi fi
} }
@@ -592,10 +592,10 @@ function test_bp2build_null_build {
setup setup
run_soong bp2build run_soong bp2build
local mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
run_soong bp2build run_soong bp2build
local mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$mtime1" != "$mtime2" ]]; then if [[ "$mtime1" != "$mtime2" ]]; then
fail "Output Ninja file changed on null build" fail "Output Ninja file changed on null build"
@@ -626,7 +626,7 @@ EOF
function test_multiple_soong_build_modes() { function test_multiple_soong_build_modes() {
setup setup
run_soong json-module-graph bp2build nothing run_soong json-module-graph bp2build nothing
if [[ ! -f "out/soong/.bootstrap/bp2build_workspace_marker" ]]; then if [[ ! -f "out/soong/bp2build_workspace_marker" ]]; then
fail "bp2build marker file was not generated" fail "bp2build marker file was not generated"
fi fi
@@ -780,11 +780,11 @@ function test_bp2build_back_and_forth_null_build {
fail "Output Ninja file changed when switching to bp2build" fail "Output Ninja file changed when switching to bp2build"
fi fi
local marker_mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local marker_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
run_soong run_soong
local output_mtime3=$(stat -c "%y" out/soong/build.ninja) local output_mtime3=$(stat -c "%y" out/soong/build.ninja)
local marker_mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local marker_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$output_mtime1" != "$output_mtime3" ]]; then if [[ "$output_mtime1" != "$output_mtime3" ]]; then
fail "Output Ninja file changed when switching to regular build from bp2build" fail "Output Ninja file changed when switching to regular build from bp2build"
fi fi
@@ -794,7 +794,7 @@ function test_bp2build_back_and_forth_null_build {
run_soong bp2build run_soong bp2build
local output_mtime4=$(stat -c "%y" out/soong/build.ninja) local output_mtime4=$(stat -c "%y" out/soong/build.ninja)
local marker_mtime3=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local marker_mtime3=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$output_mtime1" != "$output_mtime4" ]]; then if [[ "$output_mtime1" != "$output_mtime4" ]]; then
fail "Output Ninja file changed when switching back to bp2build" fail "Output Ninja file changed when switching back to bp2build"
fi fi

View File

@@ -11,10 +11,10 @@ readonly GENERATED_BUILD_FILE_NAME="BUILD.bazel"
function test_bp2build_null_build() { function test_bp2build_null_build() {
setup setup
run_soong bp2build run_soong bp2build
local output_mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local output_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
run_soong bp2build run_soong bp2build
local output_mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local output_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$output_mtime1" != "$output_mtime2" ]]; then if [[ "$output_mtime1" != "$output_mtime2" ]]; then
fail "Output bp2build marker file changed on null build" fail "Output bp2build marker file changed on null build"
@@ -36,10 +36,10 @@ EOF
touch foo/bar/a.txt foo/bar/b.txt touch foo/bar/a.txt foo/bar/b.txt
run_soong bp2build run_soong bp2build
local output_mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local output_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
run_soong bp2build run_soong bp2build
local output_mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) local output_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$output_mtime1" != "$output_mtime2" ]]; then if [[ "$output_mtime1" != "$output_mtime2" ]]; then
fail "Output bp2build marker file changed on null build" fail "Output bp2build marker file changed on null build"

View File

@@ -784,12 +784,13 @@ func (c *configImpl) PrebuiltOS() string {
panic("Unknown GOOS") panic("Unknown GOOS")
} }
} }
func (c *configImpl) HostToolDir() string { func (c *configImpl) HostToolDir() string {
return filepath.Join(c.SoongOutDir(), "host", c.PrebuiltOS(), "bin") return filepath.Join(c.SoongOutDir(), "host", c.PrebuiltOS(), "bin")
} }
func (c *configImpl) NamedGlobFile(name string) string { func (c *configImpl) NamedGlobFile(name string) string {
return shared.JoinPath(c.SoongOutDir(), ".bootstrap/build-globs."+name+".ninja") return shared.JoinPath(c.SoongOutDir(), "globs-"+name+".ninja")
} }
func (c *configImpl) UsedEnvFile(tag string) string { func (c *configImpl) UsedEnvFile(tag string) string {
@@ -797,7 +798,7 @@ func (c *configImpl) UsedEnvFile(tag string) string {
} }
func (c *configImpl) Bp2BuildMarkerFile() string { func (c *configImpl) Bp2BuildMarkerFile() string {
return shared.JoinPath(c.SoongOutDir(), ".bootstrap/bp2build_workspace_marker") return shared.JoinPath(c.SoongOutDir(), "bp2build_workspace_marker")
} }
func (c *configImpl) SoongDocsHtml() string { func (c *configImpl) SoongDocsHtml() string {

View File

@@ -263,9 +263,9 @@ func runMakeProductConfig(ctx Context, config Config) {
}, exportEnvVars...), BannerVars...) }, exportEnvVars...), BannerVars...)
// We need Roboleaf converter and runner in the mixed mode // We need Roboleaf converter and runner in the mixed mode
runMicrofactory(ctx, config, ".bootstrap/bin/mk2rbc", "android/soong/mk2rbc/cmd", runMicrofactory(ctx, config, "mk2rbc", "android/soong/mk2rbc/cmd",
map[string]string{"android/soong": "build/soong"}) map[string]string{"android/soong": "build/soong"})
runMicrofactory(ctx, config, ".bootstrap/bin/rbcrun", "rbcrun/cmd", runMicrofactory(ctx, config, "rbcrun", "rbcrun/cmd",
map[string]string{"go.starlark.net": "external/starlark-go", "rbcrun": "build/make/tools/rbcrun"}) map[string]string{"go.starlark.net": "external/starlark-go", "rbcrun": "build/make/tools/rbcrun"})
makeVars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true, "") makeVars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true, "")

View File

@@ -292,7 +292,7 @@ func bootstrapBlueprint(ctx Context, config Config) {
var blueprintArgs bootstrap.Args var blueprintArgs bootstrap.Args
blueprintArgs.ModuleListFile = filepath.Join(config.FileListDir(), "Android.bp.list") blueprintArgs.ModuleListFile = filepath.Join(config.FileListDir(), "Android.bp.list")
blueprintArgs.OutFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja") blueprintArgs.OutFile = shared.JoinPath(config.SoongOutDir(), "bootstrap.ninja")
blueprintArgs.EmptyNinjaFile = false blueprintArgs.EmptyNinjaFile = false
blueprintCtx := blueprint.NewContext() blueprintCtx := blueprint.NewContext()
@@ -314,7 +314,7 @@ func bootstrapBlueprint(ctx Context, config Config) {
} }
bootstrapDeps := bootstrap.RunBlueprint(blueprintArgs, bootstrap.DoEverything, blueprintCtx, blueprintConfig) bootstrapDeps := bootstrap.RunBlueprint(blueprintArgs, bootstrap.DoEverything, blueprintCtx, blueprintConfig)
bootstrapDepFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja.d") bootstrapDepFile := shared.JoinPath(config.SoongOutDir(), "bootstrap.ninja.d")
err := deptools.WriteDepFile(bootstrapDepFile, blueprintArgs.OutFile, bootstrapDeps) err := deptools.WriteDepFile(bootstrapDepFile, blueprintArgs.OutFile, bootstrapDeps)
if err != nil { if err != nil {
ctx.Fatalf("Error writing depfile '%s': %s", bootstrapDepFile, err) ctx.Fatalf("Error writing depfile '%s': %s", bootstrapDepFile, err)
@@ -342,11 +342,6 @@ func runSoong(ctx Context, config Config) {
// unused variables were changed? // unused variables were changed?
envFile := filepath.Join(config.SoongOutDir(), availableEnvFile) envFile := filepath.Join(config.SoongOutDir(), availableEnvFile)
dir := filepath.Join(config.SoongOutDir(), ".bootstrap")
if err := os.MkdirAll(dir, 0755); err != nil {
ctx.Fatalf("Cannot mkdir " + dir)
}
buildMode := config.bazelBuildMode() buildMode := config.bazelBuildMode()
integratedBp2Build := buildMode == mixedBuild integratedBp2Build := buildMode == mixedBuild
@@ -457,7 +452,7 @@ func runSoong(ctx Context, config Config) {
targets = append(targets, config.SoongNinjaFile()) targets = append(targets, config.SoongNinjaFile())
} }
ninja("bootstrap", ".bootstrap/build.ninja", targets...) ninja("bootstrap", "bootstrap.ninja", targets...)
var soongBuildMetrics *soong_metrics_proto.SoongBuildMetrics var soongBuildMetrics *soong_metrics_proto.SoongBuildMetrics
if shouldCollectBuildSoongMetrics(config) { if shouldCollectBuildSoongMetrics(config) {
@@ -477,8 +472,7 @@ func runSoong(ctx Context, config Config) {
} }
} }
func runMicrofactory(ctx Context, config Config, relExePath string, pkg string, mapping map[string]string) { func runMicrofactory(ctx Context, config Config, name string, pkg string, mapping map[string]string) {
name := filepath.Base(relExePath)
ctx.BeginTrace(metrics.RunSoong, name) ctx.BeginTrace(metrics.RunSoong, name)
defer ctx.EndTrace() defer ctx.EndTrace()
cfg := microfactory.Config{TrimPath: absPath(ctx, ".")} cfg := microfactory.Config{TrimPath: absPath(ctx, ".")}
@@ -486,7 +480,7 @@ func runMicrofactory(ctx Context, config Config, relExePath string, pkg string,
cfg.Map(pkgPrefix, pathPrefix) cfg.Map(pkgPrefix, pathPrefix)
} }
exePath := filepath.Join(config.SoongOutDir(), relExePath) exePath := filepath.Join(config.SoongOutDir(), name)
dir := filepath.Dir(exePath) dir := filepath.Dir(exePath)
if err := os.MkdirAll(dir, 0777); err != nil { if err := os.MkdirAll(dir, 0777); err != nil {
ctx.Fatalf("cannot create %s: %s", dir, err) ctx.Fatalf("cannot create %s: %s", dir, err)

View File

@@ -63,7 +63,6 @@ func testForDanglingRules(ctx Context, config Config) {
cmd.StartOrFatal() cmd.StartOrFatal()
outDir := config.OutDir() outDir := config.OutDir()
bootstrapDir := filepath.Join(outDir, "soong", ".bootstrap")
modulePathsDir := filepath.Join(outDir, ".module_paths") modulePathsDir := filepath.Join(outDir, ".module_paths")
variablesFilePath := filepath.Join(outDir, "soong", "soong.variables") variablesFilePath := filepath.Join(outDir, "soong", "soong.variables")
@@ -86,8 +85,7 @@ func testForDanglingRules(ctx Context, config Config) {
// Leaf node is not in the out directory. // Leaf node is not in the out directory.
continue continue
} }
if strings.HasPrefix(line, bootstrapDir) || if strings.HasPrefix(line, modulePathsDir) ||
strings.HasPrefix(line, modulePathsDir) ||
line == variablesFilePath || line == variablesFilePath ||
line == dexpreoptConfigFilePath || line == dexpreoptConfigFilePath ||
line == buildDatetimeFilePath { line == buildDatetimeFilePath {