Allow running bp2build as part of a regular build.

This is done by setting the INTEGRATED_BP2BUILD environment variable
when invoking the build.

Even though the name of the marker file insinuates that a Bazel
workspace is already created, this is not the case yet.

An issue that remains is that a .d file is not written for the marker
file so it won't be rebuilt if a .bp file changes. Fixing this requires
delicate surgery because writing the .d file is the result of delicate
interplay between Soong and Blueprint.

There are also a number of semi-related fixes:

- The name of soong.environment.{used,available} is now on the command
  line of soong_build (soong_docs is still special cased because its
  command line in the Ninja file is taken from the os.Args of
  soong_build so it's not trivial to remove the --{available,used}_env
  from it
- bp2build writes a separate soong.environment.used file
- I had to call SetAllowMissingDependencies() separately when creating
  the android.Context for bp2build so that bp2build runs in the
  integration tests (it was not obvious how not to do this)
- Fixed a number of integration tests where a command with an expected
  exit code of 1 was used as the last one in a test case, thereby
  breaking the test suite

Test: Presubmits.
Change-Id: Ibeb61c26022cf801dcb98505b4039151b3409873
This commit is contained in:
Lukacs T. Berki
2021-04-14 10:31:00 +02:00
parent 017a1bb7c9
commit f8e2428c5d
3 changed files with 201 additions and 57 deletions

View File

@@ -114,7 +114,9 @@ EOF
rm a/Android.bp
run_soong
grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja && fail "Old module in output"
if grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja; then
fail "Old module in output"
fi
}
function test_add_file_to_glob() {
@@ -404,7 +406,9 @@ EOF
grep -q "Engage" out/soong/build.ninja || fail "New action not present"
grep -q "Make it so" out/soong/build.ninja && fail "Original action still present"
if grep -q "Make it so" out/soong/build.ninja; then
fail "Original action still present"
fi
}
function test_null_build_after_docs {
@@ -421,6 +425,27 @@ function test_null_build_after_docs {
fi
}
function test_integrated_bp2build_smoke {
setup
INTEGRATED_BP2BUILD=1 run_soong
if [[ ! -e out/soong/.bootstrap/bp2build_workspace_marker ]]; then
fail "b2build marker file not created"
fi
}
function test_integrated_bp2build_null_build {
setup
INTEGRATED_BP2BUILD=1 run_soong
local mtime1=$(stat -c "%y" out/soong/build.ninja)
INTEGRATED_BP2BUILD=1 run_soong
local mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime1" != "$mtime2" ]]; then
fail "Output Ninja file changed on null build"
fi
}
function test_dump_json_module_graph() {
setup
SOONG_DUMP_JSON_MODULE_GRAPH="$MOCK_TOP/modules.json" run_soong
@@ -441,3 +466,5 @@ test_add_file_to_soong_build
test_glob_during_bootstrapping
test_soong_build_rerun_iff_environment_changes
test_dump_json_module_graph
test_integrated_bp2build_smoke
test_integrated_bp2build_null_build