Loading cmd/soong_build/main.go +6 −0 Original line number Diff line number Diff line Loading @@ -469,6 +469,12 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) { ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, bp2buildCtx.Context, configuration) ninjaDeps = append(ninjaDeps, extraNinjaDeps...) // Generate out/soong/.bootstrap/build-globs.ninja with the actions to generate flattened globfiles // containing the globs seen during bp2build conversion if blueprintArgs.GlobFile != "" { bootstrap.WriteBuildGlobsNinjaFile(bootstrap.StageMain, bp2buildCtx.Context, blueprintArgs, configuration) } // Add the depfile on the expanded globs in out/soong/.primary/globs ninjaDeps = append(ninjaDeps, bootstrap.GlobFileListFiles(configuration)...) // Run the code-generation phase to convert BazelTargetModules to BUILD files Loading tests/bp2build_bazel_test.sh +94 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,100 @@ source "$(dirname "$0")/lib.sh" readonly GENERATED_BUILD_FILE_NAME="BUILD.bazel" function test_bp2build_null_build() { setup run_bp2build local output_mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) run_bp2build local output_mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) if [[ "$output_mtime1" != "$output_mtime2" ]]; then fail "Output bp2build marker file changed on null build" fi } test_bp2build_null_build function test_bp2build_null_build_with_globs() { setup mkdir -p foo/bar cat > foo/bar/Android.bp <<'EOF' filegroup { name: "globs", srcs: ["*.txt"], } EOF touch foo/bar/a.txt foo/bar/b.txt run_bp2build local output_mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) run_bp2build local output_mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) if [[ "$output_mtime1" != "$output_mtime2" ]]; then fail "Output bp2build marker file changed on null build" fi } test_bp2build_null_build_with_globs function test_soong_after_bp2build_regenerates_build_globs_ninja() { setup mkdir -p foo/bar cat > foo/bar/Android.bp <<'EOF' filegroup { name: "bp2build-files", srcs: ["bp2build.*"], bazel_module: { bp2build_available: true }, } filegroup { name: "soong-files", srcs: ["soong.*"], } EOF touch foo/bar/bp2build.txt foo/bar/soong.txt build_globs_file="out/soong/.bootstrap/build-globs.ninja" # Test: the build-globs file for bp2build should only contain the bp2build-files # glob, whereas the build-globs file for soong should contain both bp2build-files # and soong-files globs. run_bp2build local output_mtime1=$(stat -c "%y" "${build_globs_file}") if ! grep "\"foo/bar/bp2build.*\"" "${build_globs_file}"; then fail "bp2build filegroup globs not found in bp2build's globs file" fi if grep "\"foo/bar/soong.*\"" "${build_globs_file}"; then fail "soong filegroup globs unexpectedly found in bp2build's globs file" fi run_soong local output_mtime2=$(stat -c "%y" "${build_globs_file}") if [[ "$output_mtime1" == "$output_mtime2" ]]; then fail "Output build-globs.ninja file did not change" fi if ! grep "\"foo/bar/bp2build.*\"" "${build_globs_file}"; then fail "bp2build filegroup globs not found in bp2build's globs file" fi if ! grep "\"foo/bar/soong.*\"" "${build_globs_file}"; then fail "soong filegroup globs not found in bp2build's globs file" fi } test_soong_after_bp2build_regenerates_build_globs_ninja function test_bp2build_generates_all_buildfiles { setup create_mock_bazel Loading Loading
cmd/soong_build/main.go +6 −0 Original line number Diff line number Diff line Loading @@ -469,6 +469,12 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) { ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, bp2buildCtx.Context, configuration) ninjaDeps = append(ninjaDeps, extraNinjaDeps...) // Generate out/soong/.bootstrap/build-globs.ninja with the actions to generate flattened globfiles // containing the globs seen during bp2build conversion if blueprintArgs.GlobFile != "" { bootstrap.WriteBuildGlobsNinjaFile(bootstrap.StageMain, bp2buildCtx.Context, blueprintArgs, configuration) } // Add the depfile on the expanded globs in out/soong/.primary/globs ninjaDeps = append(ninjaDeps, bootstrap.GlobFileListFiles(configuration)...) // Run the code-generation phase to convert BazelTargetModules to BUILD files Loading
tests/bp2build_bazel_test.sh +94 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,100 @@ source "$(dirname "$0")/lib.sh" readonly GENERATED_BUILD_FILE_NAME="BUILD.bazel" function test_bp2build_null_build() { setup run_bp2build local output_mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) run_bp2build local output_mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) if [[ "$output_mtime1" != "$output_mtime2" ]]; then fail "Output bp2build marker file changed on null build" fi } test_bp2build_null_build function test_bp2build_null_build_with_globs() { setup mkdir -p foo/bar cat > foo/bar/Android.bp <<'EOF' filegroup { name: "globs", srcs: ["*.txt"], } EOF touch foo/bar/a.txt foo/bar/b.txt run_bp2build local output_mtime1=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) run_bp2build local output_mtime2=$(stat -c "%y" out/soong/.bootstrap/bp2build_workspace_marker) if [[ "$output_mtime1" != "$output_mtime2" ]]; then fail "Output bp2build marker file changed on null build" fi } test_bp2build_null_build_with_globs function test_soong_after_bp2build_regenerates_build_globs_ninja() { setup mkdir -p foo/bar cat > foo/bar/Android.bp <<'EOF' filegroup { name: "bp2build-files", srcs: ["bp2build.*"], bazel_module: { bp2build_available: true }, } filegroup { name: "soong-files", srcs: ["soong.*"], } EOF touch foo/bar/bp2build.txt foo/bar/soong.txt build_globs_file="out/soong/.bootstrap/build-globs.ninja" # Test: the build-globs file for bp2build should only contain the bp2build-files # glob, whereas the build-globs file for soong should contain both bp2build-files # and soong-files globs. run_bp2build local output_mtime1=$(stat -c "%y" "${build_globs_file}") if ! grep "\"foo/bar/bp2build.*\"" "${build_globs_file}"; then fail "bp2build filegroup globs not found in bp2build's globs file" fi if grep "\"foo/bar/soong.*\"" "${build_globs_file}"; then fail "soong filegroup globs unexpectedly found in bp2build's globs file" fi run_soong local output_mtime2=$(stat -c "%y" "${build_globs_file}") if [[ "$output_mtime1" == "$output_mtime2" ]]; then fail "Output build-globs.ninja file did not change" fi if ! grep "\"foo/bar/bp2build.*\"" "${build_globs_file}"; then fail "bp2build filegroup globs not found in bp2build's globs file" fi if ! grep "\"foo/bar/soong.*\"" "${build_globs_file}"; then fail "soong filegroup globs not found in bp2build's globs file" fi } test_soong_after_bp2build_regenerates_build_globs_ninja function test_bp2build_generates_all_buildfiles { setup create_mock_bazel Loading