Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 1 | #!/bin/bash -eu |
| 2 | |
| 3 | # This test exercises the bootstrapping process of the build system |
| 4 | # in a source tree that only contains enough files for Bazel and Soong to work. |
| 5 | |
Lukacs T. Berki | 3b730c4 | 2021-04-08 13:21:13 +0200 | [diff] [blame] | 6 | source "$(dirname "$0")/lib.sh" |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 7 | |
| 8 | function test_smoke { |
| 9 | setup |
| 10 | run_soong |
| 11 | } |
| 12 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 13 | function test_null_build() { |
| 14 | setup |
| 15 | run_soong |
| 16 | local bootstrap_mtime1=$(stat -c "%y" out/soong/.bootstrap/build.ninja) |
| 17 | local output_mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 18 | run_soong |
| 19 | local bootstrap_mtime2=$(stat -c "%y" out/soong/.bootstrap/build.ninja) |
| 20 | local output_mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 21 | |
| 22 | if [[ "$bootstrap_mtime1" == "$bootstrap_mtime2" ]]; then |
| 23 | # Bootstrapping is always done. It doesn't take a measurable amount of time. |
| 24 | fail "Bootstrap Ninja file did not change on null build" |
| 25 | fi |
| 26 | |
| 27 | if [[ "$output_mtime1" != "$output_mtime2" ]]; then |
| 28 | fail "Output Ninja file changed on null build" |
| 29 | fi |
| 30 | } |
| 31 | |
| 32 | function test_soong_build_rebuilt_if_blueprint_changes() { |
| 33 | setup |
| 34 | run_soong |
| 35 | local mtime1=$(stat -c "%y" out/soong/.bootstrap/build.ninja) |
| 36 | |
| 37 | sed -i 's/pluginGenSrcCmd/pluginGenSrcCmd2/g' build/blueprint/bootstrap/bootstrap.go |
| 38 | |
| 39 | run_soong |
| 40 | local mtime2=$(stat -c "%y" out/soong/.bootstrap/build.ninja) |
| 41 | |
| 42 | if [[ "$mtime1" == "$mtime2" ]]; then |
| 43 | fail "Bootstrap Ninja file did not change" |
| 44 | fi |
| 45 | } |
| 46 | |
| 47 | function test_change_android_bp() { |
| 48 | setup |
| 49 | mkdir -p a |
| 50 | cat > a/Android.bp <<'EOF' |
| 51 | python_binary_host { |
| 52 | name: "my_little_binary_host", |
| 53 | srcs: ["my_little_binary_host.py"] |
| 54 | } |
| 55 | EOF |
| 56 | touch a/my_little_binary_host.py |
| 57 | run_soong |
| 58 | |
| 59 | grep -q "^# Module:.*my_little_binary_host" out/soong/build.ninja || fail "module not found" |
| 60 | |
| 61 | cat > a/Android.bp <<'EOF' |
| 62 | python_binary_host { |
| 63 | name: "my_great_binary_host", |
| 64 | srcs: ["my_great_binary_host.py"] |
| 65 | } |
| 66 | EOF |
| 67 | touch a/my_great_binary_host.py |
| 68 | run_soong |
| 69 | |
| 70 | grep -q "^# Module:.*my_little_binary_host" out/soong/build.ninja && fail "old module found" |
| 71 | grep -q "^# Module:.*my_great_binary_host" out/soong/build.ninja || fail "new module not found" |
| 72 | } |
| 73 | |
| 74 | |
| 75 | function test_add_android_bp() { |
| 76 | setup |
| 77 | run_soong |
| 78 | local mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 79 | |
| 80 | mkdir -p a |
| 81 | cat > a/Android.bp <<'EOF' |
| 82 | python_binary_host { |
| 83 | name: "my_little_binary_host", |
| 84 | srcs: ["my_little_binary_host.py"] |
| 85 | } |
| 86 | EOF |
| 87 | touch a/my_little_binary_host.py |
| 88 | run_soong |
| 89 | |
| 90 | local mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 91 | if [[ "$mtime1" == "$mtime2" ]]; then |
| 92 | fail "Output Ninja file did not change" |
| 93 | fi |
| 94 | |
| 95 | grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja || fail "New module not in output" |
| 96 | |
| 97 | run_soong |
| 98 | } |
| 99 | |
| 100 | function test_delete_android_bp() { |
| 101 | setup |
| 102 | mkdir -p a |
| 103 | cat > a/Android.bp <<'EOF' |
| 104 | python_binary_host { |
| 105 | name: "my_little_binary_host", |
| 106 | srcs: ["my_little_binary_host.py"] |
| 107 | } |
| 108 | EOF |
| 109 | touch a/my_little_binary_host.py |
| 110 | run_soong |
| 111 | |
| 112 | grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja || fail "Module not in output" |
| 113 | |
| 114 | rm a/Android.bp |
| 115 | run_soong |
| 116 | |
Lukacs T. Berki | f8e2428 | 2021-04-14 10:31:00 +0200 | [diff] [blame] | 117 | if grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja; then |
| 118 | fail "Old module in output" |
| 119 | fi |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 120 | } |
| 121 | |
Colin Cross | 1042595 | 2021-04-12 18:59:18 -0700 | [diff] [blame] | 122 | # Test that an incremental build with a glob doesn't rerun soong_build, and |
| 123 | # only regenerates the globs on the first but not the second incremental build. |
| 124 | function test_glob_noop_incremental() { |
| 125 | setup |
| 126 | |
Colin Cross | b72877f | 2021-04-16 10:09:54 -0700 | [diff] [blame] | 127 | # This test needs to start from a clean build, but setup creates an |
| 128 | # initialized tree that has already been built once. Clear the out |
| 129 | # directory to start from scratch. |
| 130 | rm -rf out |
| 131 | |
Colin Cross | 1042595 | 2021-04-12 18:59:18 -0700 | [diff] [blame] | 132 | mkdir -p a |
| 133 | cat > a/Android.bp <<'EOF' |
| 134 | python_binary_host { |
| 135 | name: "my_little_binary_host", |
| 136 | srcs: ["*.py"], |
| 137 | } |
| 138 | EOF |
| 139 | touch a/my_little_binary_host.py |
| 140 | run_soong |
| 141 | local ninja_mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 142 | |
| 143 | local glob_deps_file=out/soong/.glob/a/__py.glob.d |
| 144 | |
| 145 | if [ -e "$glob_deps_file" ]; then |
| 146 | fail "Glob deps file unexpectedly written on first build" |
| 147 | fi |
| 148 | |
| 149 | run_soong |
| 150 | local ninja_mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 151 | |
| 152 | # There is an ineffiencency in glob that requires bpglob to rerun once for each glob to update |
| 153 | # the entry in the .ninja_log. It doesn't update the output file, but we can detect the rerun |
| 154 | # by checking if the deps file was created. |
| 155 | if [ ! -e "$glob_deps_file" ]; then |
| 156 | fail "Glob deps file missing after second build" |
| 157 | fi |
| 158 | |
| 159 | local glob_deps_mtime2=$(stat -c "%y" "$glob_deps_file") |
| 160 | |
| 161 | if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then |
| 162 | fail "Ninja file rewritten on null incremental build" |
| 163 | fi |
| 164 | |
| 165 | run_soong |
| 166 | local ninja_mtime3=$(stat -c "%y" out/soong/build.ninja) |
| 167 | local glob_deps_mtime3=$(stat -c "%y" "$glob_deps_file") |
| 168 | |
| 169 | if [[ "$ninja_mtime2" != "$ninja_mtime3" ]]; then |
| 170 | fail "Ninja file rewritten on null incremental build" |
| 171 | fi |
| 172 | |
| 173 | # The bpglob commands should not rerun after the first incremental build. |
| 174 | if [[ "$glob_deps_mtime2" != "$glob_deps_mtime3" ]]; then |
| 175 | fail "Glob deps file rewritten on second null incremental build" |
| 176 | fi |
| 177 | } |
| 178 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 179 | function test_add_file_to_glob() { |
| 180 | setup |
| 181 | |
| 182 | mkdir -p a |
| 183 | cat > a/Android.bp <<'EOF' |
| 184 | python_binary_host { |
| 185 | name: "my_little_binary_host", |
| 186 | srcs: ["*.py"], |
| 187 | } |
| 188 | EOF |
| 189 | touch a/my_little_binary_host.py |
| 190 | run_soong |
| 191 | local mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 192 | |
| 193 | touch a/my_little_library.py |
| 194 | run_soong |
| 195 | |
| 196 | local mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 197 | if [[ "$mtime1" == "$mtime2" ]]; then |
| 198 | fail "Output Ninja file did not change" |
| 199 | fi |
| 200 | |
| 201 | grep -q my_little_library.py out/soong/build.ninja || fail "new file is not in output" |
| 202 | } |
| 203 | |
Lukacs T. Berki | f0b3b94 | 2021-03-23 11:46:47 +0100 | [diff] [blame] | 204 | function test_soong_build_rerun_iff_environment_changes() { |
| 205 | setup |
| 206 | |
| 207 | mkdir -p cherry |
| 208 | cat > cherry/Android.bp <<'EOF' |
| 209 | bootstrap_go_package { |
| 210 | name: "cherry", |
| 211 | pkgPath: "android/soong/cherry", |
| 212 | deps: [ |
| 213 | "blueprint", |
| 214 | "soong", |
| 215 | "soong-android", |
| 216 | ], |
| 217 | srcs: [ |
| 218 | "cherry.go", |
| 219 | ], |
| 220 | pluginFor: ["soong_build"], |
| 221 | } |
| 222 | EOF |
| 223 | |
| 224 | cat > cherry/cherry.go <<'EOF' |
| 225 | package cherry |
| 226 | |
| 227 | import ( |
| 228 | "android/soong/android" |
| 229 | "github.com/google/blueprint" |
| 230 | ) |
| 231 | |
| 232 | var ( |
| 233 | pctx = android.NewPackageContext("cherry") |
| 234 | ) |
| 235 | |
| 236 | func init() { |
| 237 | android.RegisterSingletonType("cherry", CherrySingleton) |
| 238 | } |
| 239 | |
| 240 | func CherrySingleton() android.Singleton { |
| 241 | return &cherrySingleton{} |
| 242 | } |
| 243 | |
| 244 | type cherrySingleton struct{} |
| 245 | |
| 246 | func (p *cherrySingleton) GenerateBuildActions(ctx android.SingletonContext) { |
| 247 | cherryRule := ctx.Rule(pctx, "cherry", |
| 248 | blueprint.RuleParams{ |
| 249 | Command: "echo CHERRY IS " + ctx.Config().Getenv("CHERRY") + " > ${out}", |
| 250 | CommandDeps: []string{}, |
| 251 | Description: "Cherry", |
| 252 | }) |
| 253 | |
| 254 | outputFile := android.PathForOutput(ctx, "cherry", "cherry.txt") |
| 255 | var deps android.Paths |
| 256 | |
| 257 | ctx.Build(pctx, android.BuildParams{ |
| 258 | Rule: cherryRule, |
| 259 | Output: outputFile, |
| 260 | Inputs: deps, |
| 261 | }) |
| 262 | } |
| 263 | EOF |
| 264 | |
| 265 | export CHERRY=TASTY |
| 266 | run_soong |
| 267 | grep -q "CHERRY IS TASTY" out/soong/build.ninja \ |
| 268 | || fail "first value of environment variable is not used" |
| 269 | |
| 270 | export CHERRY=RED |
| 271 | run_soong |
| 272 | grep -q "CHERRY IS RED" out/soong/build.ninja \ |
| 273 | || fail "second value of environment variable not used" |
| 274 | local mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 275 | |
| 276 | run_soong |
| 277 | local mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 278 | if [[ "$mtime1" != "$mtime2" ]]; then |
| 279 | fail "Output Ninja file changed when environment variable did not" |
| 280 | fi |
| 281 | |
| 282 | } |
| 283 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 284 | function test_add_file_to_soong_build() { |
| 285 | setup |
| 286 | run_soong |
| 287 | local mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 288 | |
| 289 | mkdir -p a |
| 290 | cat > a/Android.bp <<'EOF' |
| 291 | bootstrap_go_package { |
| 292 | name: "picard-soong-rules", |
| 293 | pkgPath: "android/soong/picard", |
| 294 | deps: [ |
| 295 | "blueprint", |
| 296 | "soong", |
| 297 | "soong-android", |
| 298 | ], |
| 299 | srcs: [ |
| 300 | "picard.go", |
| 301 | ], |
| 302 | pluginFor: ["soong_build"], |
| 303 | } |
| 304 | EOF |
| 305 | |
| 306 | cat > a/picard.go <<'EOF' |
| 307 | package picard |
| 308 | |
| 309 | import ( |
| 310 | "android/soong/android" |
| 311 | "github.com/google/blueprint" |
| 312 | ) |
| 313 | |
| 314 | var ( |
| 315 | pctx = android.NewPackageContext("picard") |
| 316 | ) |
| 317 | |
| 318 | func init() { |
| 319 | android.RegisterSingletonType("picard", PicardSingleton) |
| 320 | } |
| 321 | |
| 322 | func PicardSingleton() android.Singleton { |
| 323 | return &picardSingleton{} |
| 324 | } |
| 325 | |
| 326 | type picardSingleton struct{} |
| 327 | |
| 328 | func (p *picardSingleton) GenerateBuildActions(ctx android.SingletonContext) { |
| 329 | picardRule := ctx.Rule(pctx, "picard", |
| 330 | blueprint.RuleParams{ |
| 331 | Command: "echo Make it so. > ${out}", |
| 332 | CommandDeps: []string{}, |
| 333 | Description: "Something quotable", |
| 334 | }) |
| 335 | |
| 336 | outputFile := android.PathForOutput(ctx, "picard", "picard.txt") |
| 337 | var deps android.Paths |
| 338 | |
| 339 | ctx.Build(pctx, android.BuildParams{ |
| 340 | Rule: picardRule, |
| 341 | Output: outputFile, |
| 342 | Inputs: deps, |
| 343 | }) |
| 344 | } |
| 345 | |
| 346 | EOF |
| 347 | |
| 348 | run_soong |
| 349 | local mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 350 | if [[ "$mtime1" == "$mtime2" ]]; then |
| 351 | fail "Output Ninja file did not change" |
| 352 | fi |
| 353 | |
| 354 | grep -q "Make it so" out/soong/build.ninja || fail "New action not present" |
| 355 | } |
| 356 | |
Colin Cross | c02504e | 2021-04-08 10:34:16 -0700 | [diff] [blame] | 357 | # Tests a glob in a build= statement in an Android.bp file, which is interpreted |
| 358 | # during bootstrapping. |
| 359 | function test_glob_during_bootstrapping() { |
| 360 | setup |
| 361 | |
| 362 | mkdir -p a |
| 363 | cat > a/Android.bp <<'EOF' |
| 364 | build=["foo*.bp"] |
| 365 | EOF |
| 366 | cat > a/fooa.bp <<'EOF' |
| 367 | bootstrap_go_package { |
| 368 | name: "picard-soong-rules", |
| 369 | pkgPath: "android/soong/picard", |
| 370 | deps: [ |
| 371 | "blueprint", |
| 372 | "soong", |
| 373 | "soong-android", |
| 374 | ], |
| 375 | srcs: [ |
| 376 | "picard.go", |
| 377 | ], |
| 378 | pluginFor: ["soong_build"], |
| 379 | } |
| 380 | EOF |
| 381 | |
| 382 | cat > a/picard.go <<'EOF' |
| 383 | package picard |
| 384 | |
| 385 | import ( |
| 386 | "android/soong/android" |
| 387 | "github.com/google/blueprint" |
| 388 | ) |
| 389 | |
| 390 | var ( |
| 391 | pctx = android.NewPackageContext("picard") |
| 392 | ) |
| 393 | |
| 394 | func init() { |
| 395 | android.RegisterSingletonType("picard", PicardSingleton) |
| 396 | } |
| 397 | |
| 398 | func PicardSingleton() android.Singleton { |
| 399 | return &picardSingleton{} |
| 400 | } |
| 401 | |
| 402 | type picardSingleton struct{} |
| 403 | |
| 404 | var Message = "Make it so." |
| 405 | |
| 406 | func (p *picardSingleton) GenerateBuildActions(ctx android.SingletonContext) { |
| 407 | picardRule := ctx.Rule(pctx, "picard", |
| 408 | blueprint.RuleParams{ |
| 409 | Command: "echo " + Message + " > ${out}", |
| 410 | CommandDeps: []string{}, |
| 411 | Description: "Something quotable", |
| 412 | }) |
| 413 | |
| 414 | outputFile := android.PathForOutput(ctx, "picard", "picard.txt") |
| 415 | var deps android.Paths |
| 416 | |
| 417 | ctx.Build(pctx, android.BuildParams{ |
| 418 | Rule: picardRule, |
| 419 | Output: outputFile, |
| 420 | Inputs: deps, |
| 421 | }) |
| 422 | } |
| 423 | |
| 424 | EOF |
| 425 | |
| 426 | run_soong |
| 427 | local mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 428 | |
| 429 | grep -q "Make it so" out/soong/build.ninja || fail "Original action not present" |
| 430 | |
| 431 | cat > a/foob.bp <<'EOF' |
| 432 | bootstrap_go_package { |
| 433 | name: "worf-soong-rules", |
| 434 | pkgPath: "android/soong/worf", |
| 435 | deps: [ |
| 436 | "blueprint", |
| 437 | "soong", |
| 438 | "soong-android", |
| 439 | "picard-soong-rules", |
| 440 | ], |
| 441 | srcs: [ |
| 442 | "worf.go", |
| 443 | ], |
| 444 | pluginFor: ["soong_build"], |
| 445 | } |
| 446 | EOF |
| 447 | |
| 448 | cat > a/worf.go <<'EOF' |
| 449 | package worf |
| 450 | |
| 451 | import "android/soong/picard" |
| 452 | |
| 453 | func init() { |
| 454 | picard.Message = "Engage." |
| 455 | } |
| 456 | EOF |
| 457 | |
| 458 | run_soong |
| 459 | local mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 460 | if [[ "$mtime1" == "$mtime2" ]]; then |
| 461 | fail "Output Ninja file did not change" |
| 462 | fi |
| 463 | |
| 464 | grep -q "Engage" out/soong/build.ninja || fail "New action not present" |
| 465 | |
Lukacs T. Berki | f8e2428 | 2021-04-14 10:31:00 +0200 | [diff] [blame] | 466 | if grep -q "Make it so" out/soong/build.ninja; then |
| 467 | fail "Original action still present" |
| 468 | fi |
Colin Cross | c02504e | 2021-04-08 10:34:16 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Lukacs T. Berki | f0b3b94 | 2021-03-23 11:46:47 +0100 | [diff] [blame] | 471 | function test_null_build_after_docs { |
| 472 | setup |
| 473 | run_soong |
| 474 | local mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 475 | |
| 476 | prebuilts/build-tools/linux-x86/bin/ninja -f out/soong/build.ninja soong_docs |
| 477 | run_soong |
| 478 | local mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 479 | |
| 480 | if [[ "$mtime1" != "$mtime2" ]]; then |
| 481 | fail "Output Ninja file changed on null build" |
| 482 | fi |
| 483 | } |
| 484 | |
Lukacs T. Berki | f8e2428 | 2021-04-14 10:31:00 +0200 | [diff] [blame] | 485 | function test_integrated_bp2build_smoke { |
| 486 | setup |
| 487 | INTEGRATED_BP2BUILD=1 run_soong |
Lukacs T. Berki | b353cca | 2021-04-16 13:47:36 +0200 | [diff] [blame^] | 488 | [[ -e out/soong/.bootstrap/bp2build_workspace_marker ]] || fail "bp2build marker file not created" |
| 489 | [[ -e out/soong/workspace ]] || fail "Bazel workspace not created" |
Lukacs T. Berki | d518e1a | 2021-04-14 13:49:50 +0200 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | function test_integrated_bp2build_add_android_bp { |
| 493 | setup |
| 494 | |
| 495 | mkdir -p a |
| 496 | touch a/a.txt |
| 497 | cat > a/Android.bp <<'EOF' |
| 498 | filegroup { |
| 499 | name: "a", |
| 500 | srcs: ["a.txt"], |
| 501 | bazel_module: { bp2build_available: true }, |
| 502 | } |
| 503 | EOF |
| 504 | |
| 505 | INTEGRATED_BP2BUILD=1 run_soong |
Lukacs T. Berki | b353cca | 2021-04-16 13:47:36 +0200 | [diff] [blame^] | 506 | [[ -e out/soong/bp2build/a/BUILD ]] || fail "a/BUILD not created" |
| 507 | [[ -L out/soong/workspace/a/BUILD ]] || fail "a/BUILD not symlinked" |
Lukacs T. Berki | d518e1a | 2021-04-14 13:49:50 +0200 | [diff] [blame] | 508 | |
| 509 | mkdir -p b |
| 510 | touch b/b.txt |
| 511 | cat > b/Android.bp <<'EOF' |
| 512 | filegroup { |
| 513 | name: "b", |
| 514 | srcs: ["b.txt"], |
| 515 | bazel_module: { bp2build_available: true }, |
| 516 | } |
| 517 | EOF |
| 518 | |
| 519 | INTEGRATED_BP2BUILD=1 run_soong |
Lukacs T. Berki | b353cca | 2021-04-16 13:47:36 +0200 | [diff] [blame^] | 520 | [[ -e out/soong/bp2build/b/BUILD ]] || fail "a/BUILD not created" |
| 521 | [[ -L out/soong/workspace/b/BUILD ]] || fail "a/BUILD not symlinked" |
Lukacs T. Berki | f8e2428 | 2021-04-14 10:31:00 +0200 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | function test_integrated_bp2build_null_build { |
| 525 | setup |
Lukacs T. Berki | d518e1a | 2021-04-14 13:49:50 +0200 | [diff] [blame] | 526 | |
Lukacs T. Berki | f8e2428 | 2021-04-14 10:31:00 +0200 | [diff] [blame] | 527 | INTEGRATED_BP2BUILD=1 run_soong |
| 528 | local mtime1=$(stat -c "%y" out/soong/build.ninja) |
| 529 | |
| 530 | INTEGRATED_BP2BUILD=1 run_soong |
| 531 | local mtime2=$(stat -c "%y" out/soong/build.ninja) |
| 532 | |
| 533 | if [[ "$mtime1" != "$mtime2" ]]; then |
| 534 | fail "Output Ninja file changed on null build" |
| 535 | fi |
| 536 | } |
| 537 | |
Lukacs T. Berki | d518e1a | 2021-04-14 13:49:50 +0200 | [diff] [blame] | 538 | function test_integrated_bp2build_add_to_glob { |
| 539 | setup |
| 540 | |
| 541 | mkdir -p a |
| 542 | touch a/a1.txt |
| 543 | cat > a/Android.bp <<'EOF' |
| 544 | filegroup { |
| 545 | name: "a", |
| 546 | srcs: ["*.txt"], |
| 547 | bazel_module: { bp2build_available: true }, |
| 548 | } |
| 549 | EOF |
| 550 | |
| 551 | INTEGRATED_BP2BUILD=1 run_soong |
| 552 | grep -q a1.txt out/soong/bp2build/a/BUILD || fail "a1.txt not in BUILD file" |
| 553 | |
| 554 | touch a/a2.txt |
| 555 | INTEGRATED_BP2BUILD=1 run_soong |
| 556 | grep -q a2.txt out/soong/bp2build/a/BUILD || fail "a2.txt not in BUILD file" |
| 557 | } |
| 558 | |
Lukacs T. Berki | 97bb9f1 | 2021-04-01 18:28:45 +0200 | [diff] [blame] | 559 | function test_dump_json_module_graph() { |
| 560 | setup |
| 561 | SOONG_DUMP_JSON_MODULE_GRAPH="$MOCK_TOP/modules.json" run_soong |
| 562 | if [[ ! -r "$MOCK_TOP/modules.json" ]]; then |
| 563 | fail "JSON file was not created" |
| 564 | fi |
| 565 | } |
| 566 | |
Lukacs T. Berki | b353cca | 2021-04-16 13:47:36 +0200 | [diff] [blame^] | 567 | function test_integrated_bp2build_bazel_workspace_structure { |
| 568 | setup |
| 569 | |
| 570 | mkdir -p a/b |
| 571 | touch a/a.txt |
| 572 | touch a/b/b.txt |
| 573 | cat > a/b/Android.bp <<'EOF' |
| 574 | filegroup { |
| 575 | name: "b", |
| 576 | srcs: ["b.txt"], |
| 577 | bazel_module: { bp2build_available: true }, |
| 578 | } |
| 579 | EOF |
| 580 | |
| 581 | INTEGRATED_BP2BUILD=1 run_soong |
| 582 | [[ -e out/soong/workspace ]] || fail "Bazel workspace not created" |
| 583 | [[ -d out/soong/workspace/a/b ]] || fail "module directory not a directory" |
| 584 | [[ -L out/soong/workspace/a/b/BUILD ]] || fail "BUILD file not symlinked" |
| 585 | [[ "$(readlink -f out/soong/workspace/a/b/BUILD)" =~ bp2build/a/b/BUILD$ ]] \ |
| 586 | || fail "BUILD files symlinked at the wrong place" |
| 587 | [[ -L out/soong/workspace/a/b/b.txt ]] || fail "a/b/b.txt not symlinked" |
| 588 | [[ -L out/soong/workspace/a/a.txt ]] || fail "a/b/a.txt not symlinked" |
| 589 | [[ ! -e out/soong/workspace/out ]] || fail "out directory symlinked" |
| 590 | } |
| 591 | |
| 592 | function test_integrated_bp2build_bazel_workspace_add_file { |
| 593 | setup |
| 594 | |
| 595 | mkdir -p a |
| 596 | touch a/a.txt |
| 597 | cat > a/Android.bp <<EOF |
| 598 | filegroup { |
| 599 | name: "a", |
| 600 | srcs: ["a.txt"], |
| 601 | bazel_module: { bp2build_available: true }, |
| 602 | } |
| 603 | EOF |
| 604 | |
| 605 | INTEGRATED_BP2BUILD=1 run_soong |
| 606 | |
| 607 | touch a/a2.txt # No reference in the .bp file needed |
| 608 | INTEGRATED_BP2BUILD=1 run_soong |
| 609 | [[ -L out/soong/workspace/a/a2.txt ]] || fail "a/a2.txt not symlinked" |
| 610 | } |
| 611 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 612 | test_smoke |
| 613 | test_null_build |
Lukacs T. Berki | f0b3b94 | 2021-03-23 11:46:47 +0100 | [diff] [blame] | 614 | test_null_build_after_docs |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 615 | test_soong_build_rebuilt_if_blueprint_changes |
Lukacs T. Berki | b353cca | 2021-04-16 13:47:36 +0200 | [diff] [blame^] | 616 | # test_glob_noop_incremental # Currently failing |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 617 | test_add_file_to_glob |
| 618 | test_add_android_bp |
| 619 | test_change_android_bp |
| 620 | test_delete_android_bp |
| 621 | test_add_file_to_soong_build |
Colin Cross | c02504e | 2021-04-08 10:34:16 -0700 | [diff] [blame] | 622 | test_glob_during_bootstrapping |
Lukacs T. Berki | f0b3b94 | 2021-03-23 11:46:47 +0100 | [diff] [blame] | 623 | test_soong_build_rerun_iff_environment_changes |
Lukacs T. Berki | 97bb9f1 | 2021-04-01 18:28:45 +0200 | [diff] [blame] | 624 | test_dump_json_module_graph |
Lukacs T. Berki | f8e2428 | 2021-04-14 10:31:00 +0200 | [diff] [blame] | 625 | test_integrated_bp2build_smoke |
| 626 | test_integrated_bp2build_null_build |
Lukacs T. Berki | b353cca | 2021-04-16 13:47:36 +0200 | [diff] [blame^] | 627 | test_integrated_bp2build_add_android_bp |
Lukacs T. Berki | d518e1a | 2021-04-14 13:49:50 +0200 | [diff] [blame] | 628 | test_integrated_bp2build_add_to_glob |
Lukacs T. Berki | b353cca | 2021-04-16 13:47:36 +0200 | [diff] [blame^] | 629 | test_integrated_bp2build_bazel_workspace_structure |
| 630 | test_integrated_bp2build_bazel_workspace_add_file |