Commit graph

228 commits

Author SHA1 Message Date
Treehugger Robot
94d107020a Merge "Fix CI failures, comment out dcla cases temporarily." 2023-03-20 21:35:10 +00:00
Wei Li
4a77c55b81 Fix CI failures, comment out dcla cases temporarily.
Bug: 274473434
Test: CIs
Change-Id: Ia1b8860ac46dad6b9670880613b6559561e37dbf
2023-03-20 18:07:40 +00:00
Wei Li
898918f7c8 Build partition images and SBOM seperately in case the build of SBOM introduces extra dependencies that included in partition images.
Bug: 272358980
Test: build/soong/tests/sbom_test.sh
Test: CIs
Change-Id: I99bd2357344f9a3d5827cf052b69e3e8545241c0
2023-03-16 22:52:35 +00:00
Wei Li
44ac6dad27 Merge "Revert "Revert "Revert "Revert "Add integration test for testing generat...""" 2023-03-16 18:20:48 +00:00
Wei Li
73032c8fa3 Revert "Revert "Revert "Revert "Add integration test for testing generat...""
This reverts commit 1e75eccb18.

Reason for revert: The SBOM generation change has been submitted in aosp/2485540, so its integration test in this change should be ok to submit now.

Change-Id: Idb8c84a871b2a5633bed998eb7483fc91d30e97a
2023-03-15 18:31:38 +00:00
Kevin Han
a2e8ae1771 Merge "Revert "Revert "Revert "Add integration test for testing generat..."" 2023-03-13 21:03:23 +00:00
Kevin Han
1e75eccb18 Revert "Revert "Revert "Add integration test for testing generat..."
Revert submission 2481062-sbom

Reason for revert: b/273332655

Reverted changes: /q/submissionid:2481062-sbom

Change-Id: I9297f585ab426d0b5586a7a77e983e8bafb19f20
2023-03-13 20:57:32 +00:00
Wei Li
601fc0137e Merge "Revert "Revert "Add integration test for testing generated SBOM with .im...""" 2023-03-13 17:43:59 +00:00
Wei Li
cba64e4cf1 Revert "Revert "Add integration test for testing generated SBOM with .im...""
This reverts commit 68101fad40.

Reason for revert: fixed the build error and try to commit again.

Change-Id: Iec8afa95a59dc1c7ce9b48911a85667f2956fbce
2023-03-10 16:21:31 +00:00
Android Culprit Assistant
68101fad40 Revert "Add integration test for testing generated SBOM with .im..."
This revert was created by Android Culprit Assistant. The culprit was identified in the following culprit search session (http://go/aca-get/5b65d203-d364-4ade-aabb-1330fe45236a).

Change-Id: I10231bc624a15a2ba477712b3a5950f5fc9113e8
2023-03-10 06:18:01 +00:00
Spandan Das
68bcbb588a Add an integration test for API export from another bazel package
This test ensures that API export works ok if the api file exists in a
different directory (precisely, package) than the *_api_contribution
target.

Test: tests/run_integration_tests.sh
Change-Id: I1ff171b93773b514a9a081f962606f4c28abe42e
2023-03-10 02:32:18 +00:00
Wei Li
eecee5a695 Add integration test for testing generated SBOM with .img files.
Bug: 266726655
Test: CIs
Change-Id: Iacaaae50125c7f310828c79b7881ac1d83a1f9ed
2023-03-08 13:47:51 -08:00
Yu Liu
525bae7ac4 Merge "Run the dcla comparison test for both pure soong build and mixed build." 2023-03-08 06:20:58 +00:00
Yu Liu
fa3a152de7 Run the dcla comparison test for both pure soong build and mixed build.
Bug: 268337606
Test: Manually run the script.
Change-Id: I7afaf46de2a4575b36be0cf348de7a1b7f90719f
2023-03-02 15:43:36 -08:00
Christopher Parsons
7720f5704c Merge "Add a persistent bazel server between builds" 2023-03-02 14:22:34 +00:00
Christopher Parsons
647b8518ec Merge "Avoid deleting bp2build directory" 2023-03-02 14:22:13 +00:00
Chris Parsons
9402ca881c Add a persistent bazel server between builds
This feature is toggled on with USE_PERSISTENT_BAZEL, which is off by
default. Those that opt-in will have a bazel server running between
builds (with a 3hr default TTL) which will greatly improve analysis on
subsequent builds. (As Bazel maintains a cache of analysis results).

Bug: 266983462
Test: Manual `m nothing` runs (timing with and without the feature)
Test: New integration test
Test: Presubmits
Change-Id: I3af4948baa0c490e9b87c48ffdbe9f67732586c7
2023-03-01 23:30:19 -05:00
Chris Parsons
520e88b740 Avoid deleting bp2build directory
With this CL, we avoid deleting the bp2build directory and regenerating
all BUILD files. Instead, we regenerate BUILD files which have changes
on the filesystem, and delete old BUILD files which should no longer
exist.

This improves incremental Bazel server performance by about ~5 seconds.
Previously, Bazel would have cache misses for regenerated packages, and
would thus need to analyze them even if no meaningful changes took
place.

For ease of implementation, we avoid removing stale (empty) directories
from the bp2build workspace, but this should have no effect on the
build. (These will be removed on next clean)

Test: New integration tests
Test: Manual benchmarking in conjunction with persistent bazel server
Change-Id: I3e489ff403be34040122876012329060a2506366
2023-03-01 23:15:30 -05:00
Yu Liu
e0c4d35cc5 Add a test to compare the DCLA libs across the apexes.
Bug: 268337606
Test: manual run it.
Change-Id: I48525ed4724736594080af757800f0e224852abd
2023-02-25 14:02:36 -08:00
Usta (Tsering) Shrestha
9393264eff fix flakey test
since bp2build runs concurrently, errors can occur in any order

Bug: 265845583
Change-Id: Iea6d26bc73112dc89c963545b3e0fc7e1b7fa349
Test: run test localy multiple times
2023-02-13 20:25:12 +00:00
Usta (Tsering) Shrestha
c4c07b12b6 reduce forest generation to be incremental
Previously, symlink forest generation involved removing the entire
symlink forest and recreating it from scratch. With this change,
a) symlinks which need not change are untouched,
b) symlinks pointing to the wrong location are fixed, and
c) symlinks which should no longer exist are removed.

On AOSP on my local machine, this reduces the symlink forest generation
step from 2.5s to 1.1s clean, and 0.6s when a single file is added to
a source directory.

Bug: 257528847
Test: m bp2build, touch `fakefile` under the forest, remove a file
from the source tree, rerun m bp2build. Manually verify the new forest
does not retain the link to the deleted source file, and that fakefile
no longer exists in the forest.

Change-Id: I481371ae487e9419af6a3a4370c552578b07d650
2023-02-07 06:23:43 +00:00
Cole Faust
56080ddc08 Merge "Precompile python sources" 2023-01-30 20:02:27 +00:00
Cole Faust
5c503d1c43 Precompile python sources
This signifigantly improves the startup time of soong-built
python binaries. For example, running
`m apexer && time out/host/linux-x86/bin/apexer` gives
0.734s before this cl, and 0.094s after.

Fixes: 259718110
Test: Presubmits
Change-Id: Ib19e83e2c60c39a849525be117279c318de3afa7
2023-01-27 15:43:38 -08:00
Wei Li
80f1ef15cc Change grep pattern so it can report number of CppCompile actions correctly without being impacted by setting -march on command line twice.
Bug: 266930443
Test: build/soong/tests/apex_cc_module_arch_variant_tests.sh
Change-Id: Ifd74e8cfc86dd94fce632beac049cc81430bfc46
2023-01-27 22:52:20 +00:00
Usta Shrestha
071f6c29a3 for consistency symlink_tree failure = os.Exit(1)
Brings down time taken to fail from 18s to 13s (on aosp branch)

Test: temporarily coded random failure
Bug: N/A
Change-Id: Ib694eec977293f4dd7054e779d1b82b8cace93f6
2023-01-13 14:07:10 -05:00
Treehugger Robot
0ddd60fc1d Merge "Reference deapexer directly in bazel-bin" 2023-01-12 01:01:24 +00:00
Spandan Das
df01030ab5 Merge changes I78639a2d,Iddb0aa1a
* changes:
  Create a smoke test for api_bp2build workspace
  Add a new CreateSoongInjectionDirFiles function
2023-01-11 22:37:27 +00:00
Chris Parsons
41eff2e4b6 Reference deapexer directly in bazel-bin
This keeps this test compatible with a Bazel release change which
affects which files are present in `bazel cquery --output=files` for
py_binary targets. Since the executable will be present in a predictable
location under bazel-bin, we can hardcode that, instead.

We could have alternatively used --output_groups=python_zip_file for
'hermetic' python, but the bp2build-built deapexer target is missing
some dependencies on protobuf.

Bug: 265176532
Test: Manual runs of apex_comparison_tests.sh with the new Bazel release
Change-Id: Ib7021e7e81d1a7bf5ff4d222e2a7947a06d16791
2023-01-11 17:30:55 -05:00
Spandan Das
255648c6d5 Create a smoke test for api_bp2build workspace
This test builds an "empty" filegroup. Running it can be useful to
verify that the api_bp2build workspace has been setup correctly.

Test: TH
Change-Id: I78639a2dcdeb659b2d6fdf6abc85d85c4fb697bf
2023-01-11 03:21:18 +00:00
Wei Li
ad2ac54d65 Add integration test for testing the arch variant passed to cc modules included in APEXES.
Resend aosp/2350557, with minor change on line 65 of apex_cc_module_arch_variant_tests.sh.
The pattern was:
  '.*android_target.*: ([0-9]+)$'
and is changed to:
  '.*opt-ST.*: ([0-9]+)$'
since the Bazel output directory name has been changed.

Bug: 258422889
Test: build/soong/tests/run_integration_tests.sh
Change-Id: Ib114bc0084d8ea2cd232d6478cc81a039b138bc4
2023-01-10 21:38:46 +00:00
Wei Li
2822aaa198 Merge "Revert "Add integration test for testing the arch variant passed to cc modules included in APEXES."" 2023-01-09 17:39:37 +00:00
Usta (Tsering) Shrestha
9955d076f6 Merge "cosmetic: auto-scan test_ functions" 2023-01-09 15:36:40 +00:00
Jingwen Chen
60ba3892df Revert "Add integration test for testing the arch variant passed to cc modules included in APEXES."
This reverts commit 6c588296a2.

Reason for revert: b/264827343

Change-Id: Iba5a4924349a90349a1e56181efb2d368444dfac
2023-01-09 05:32:27 +00:00
Wei Li
fcfc9d3130 Merge "Add integration test for testing the arch variant passed to cc modules included in APEXES." 2023-01-07 06:35:09 +00:00
Wei Li
6c588296a2 Add integration test for testing the arch variant passed to cc modules included in APEXES.
Bug: 258422889
Test: build/soong/tests/run_integration_tests.sh
Change-Id: I0852454e1d18ccd706f5270c0c87f9546cede5bf
2023-01-06 22:40:52 +00:00
Usta Shrestha
a4e0a0f7f6 cosmetic: auto-scan test_ functions
bug: NA
test: manually ran build/soong/run_integration_tests.sh and verified all tests ran
Change-Id: I1a0a2e227888efc2e7fd7f718b8e534e6dbdbcf1
2023-01-06 14:26:56 +00:00
Cole Faust
b85d1a15cc Bp2build support for multiple product configs
Create a
build/bazel/product_config/generated/products/<product_name>/BUILD
file that contains the platform definitions needed for
a particular product. Currently we just create it for the
current lunch target, but the idea is that eventually when
all product config is in starlark, all the products will
have their platform definitions in the tree at once.

Bug: 249685973
Test: Presubmits
Change-Id: I08c82ff28dcf62f09d3b1d2e3186a6b961e12f6e
2023-01-05 12:49:14 -08:00
Joe Onorato
fa5fc26ce2 Move common functions to script_utils.sh
Test: m
Bug: 260003429
Change-Id: Iac401eeaf97c904ea751583bf80091d50526f695
2023-01-03 14:50:36 -08:00
Treehugger Robot
a6d4e15c3a Merge "Allowlist build files in external/python/absl-py" 2022-12-15 20:23:35 +00:00
Sam Delmerico
eddd3c0ba4 add APEX transitive dependency validation
Bug: 218419109
Test: b build //packages/modules/adb/apex:com.android.adbd
Change-Id: I93b0c99d6521e419e52c63271646448f6d708c22
2022-12-13 14:32:19 -05:00
Usta (Tsering) Shrestha
b545f49f06 Merge "scan and run test_ methods" 2022-12-13 15:46:08 +00:00
Cole Faust
de12be3fb1 Allowlist build files in external/python/absl-py
Needed because we import absl-py in our bazel.workspace file.
It only worked before in b, not mixed builds, because b was
run from the real android tree instead of out/soong/workspace.

Bug: 234449134
Bug: 249685973
Test: Presubmits
Change-Id: Ie6985582c55a4a95338fb3a8ff7b13ddb522c391
2022-12-12 12:27:31 -08:00
Vinh Tran
cc1a017240 Change out path to android_target-opt in bazel integration tests
ag/c/platform/build/bazel/+/20584767/15/common.bazelrc#116 defaulted our build to opt compilation mode which affects bazel's output path. This change fixes the tests to reflect that.

Test: ./tests/apex_comparison_tests.sh
Test: ./tests/bp2build_bazel_test.sh
Bug: 253540178
Change-Id: Idc42a2c3173800db0d6155ef3d74e33c15d220d0
Merged-In: Idc42a2c3173800db0d6155ef3d74e33c15d220d0
2022-12-12 12:20:05 -05:00
Usta Shrestha
572ecec696 scan and run test_ methods
Bug: N/A
Test: run bootstrap_test.sh
Change-Id: I3f810277763144d4a6a2f9c1d08bed3a29b7598e
2022-12-09 01:41:49 -05:00
Usta Shrestha
4e17a2e503 cosmetic: getting rid of SC2155 warnings
https://github.com/koalaman/shellcheck/wiki/SC2155

Bug: N/A
Test: bootstrap_test.sh
Change-Id: I3ce7ab2c7b2cf827e32c3cde0dfbcc932fc48039
2022-12-08 01:21:08 -05:00
Wei Li
94bf3158fd Add soong integration test for Bazel-built apexes of 64bit only products.
Bug: 253223400
Test: build/soong/tests/apex_comparison_tests.sh module_arm64only
Change-Id: I3127aa2b8699f0af16c05036cab94a3054ccc5a1
2022-12-05 20:53:25 -08:00
Cole Faust
762c2def20 Revert "Allowlist build files in external/python/absl-py"
Revert submission 2308141-colefaust_run_b_from_out_folder

Reason for revert: Breaks CI due to more instances of the bazel shutdown issue
Reverted Changes:
I51c28e232:Allowlist build files in external/python/absl-py
I9e6530d95:Cd into the bazel workspace instead of using --pac...

Change-Id: Ice47ef2baaef9976546f9562dc7dd9b19b383d59
2022-11-30 05:16:30 +00:00
Cole Faust
93dc19d39d Allowlist build files in external/python/absl-py
Needed because we import absl-py in our bazel.workspace file.
It only worked before in b, not mixed builds, because b was
run from the real android tree instead of out/soong/workspace.

Bug: 234449134
Bug: 249685973
Test: Presubmits
Change-Id: I51c28e23260bed7ca7d4968fd823f52f0d26a0ab
2022-11-28 12:00:00 -08:00
Colin Cross
662d61430f Make PackageVarContext implement PathGlobContext
Make PackageVarContext implement PathGlobContext by implementing
GlobWithDeps.  This will allow calls to ExistentPathForSource
inside a VariableFunc to use optimized glob dependencies instead of
falling back to AddNinjaFileDeps, which is resulting in extra
dependencies from soong_build on top level directories, triggering
extra Soong regenerations.

Remove the fallback path in ExistentPathForSource by making it take
a PathGlobContext, which is now a superset of PathContext.

Rewrite TestNinjaDeps to not rely on the unoptimized glob dependencies
in VariableFuncs and instead call ctx.Config().AddNinjaFileDeps
directly.

Bug: 257079828
Test: test_create_global_include_directory
Change-Id: I48cf189157d78b9252d339dbc9baeb27e4694807
2022-11-04 09:04:02 -07:00
Chris Parsons
b6e9690776 Add groundwork to easily all-enable bazel-mode
This will make it easy to change a "false" boolean to "true" to push
`--bazel-mode` by default for all users.

Users may disable bazel-by-default with BUILD_BROKEN_DISABLE_BAZEL, and
bazel is disabled by default on Darwin hosts (due to lack of test
coverage).

Bug: 254628592
Bug: 254084584
Test: Presubmits
Test: Presubmits for aosp/2263623
Change-Id: Iec712119e06ca8ec93028207d88277f879184cc2
2022-11-01 09:53:46 -04:00
Jason Wu
1cb6739c01 Merge "Rollforward "Use proto output instead of jsonproto output for aquery""" 2022-10-28 14:47:52 +00:00
Jason Wu
118fd2b443 Rollforward "Use proto output instead of jsonproto output for aquery""
Test: use m --bazel-mode-dev and mixed_droid.sh
Bug: 233798334

This reverts commit d27e28c2a7.

Change-Id: Ifd37ac449979330529dd25c92a5eca2f5a80827e
2022-10-27 18:41:50 +00:00
Lukacs T. Berki
c541cd27fa Create Bazel symlink forest in a separate process.
This helps with incrementality a lot: the symlink forest must depend on
almost every directory in the source tree so that if a new file is added
or removed from *anywhere*, it is regenerated.

Previously, we couldn't do this without invoking bp2build, which is
quite wasteful because bp2build takes way more time than the symlink
forest creation, even though we do the latter in a very suboptimal way
at the moment.

This means that if a source file is added or removed (which does not
affect globs), we don't pay the cost of bp2build anymore.

Also refactored symlink_forest.go on the side. Too much state was being
passed around in arguments.

This change reimplements aosp/2263423 ; the semantics of not touching an
output file is the exact same as order-only inputs and the latter is a
bit fewer lines of code.

Test: Presubmits.
Change-Id: I565c580df8a01bacf175d56747c3f50743d4a4d4
2022-10-27 08:08:45 +00:00
Jason Wu
d27e28c2a7 Revert "Use proto output instead of jsonproto output for aquery"
This reverts commit 6fe8721e12.

Reason for revert: Broke aosp_kernel-build-tools/linux

Change-Id: I502ec4c275cbc56e1024a42fadf68b308750939d
2022-10-27 05:18:40 +00:00
Jason Wu
6fe8721e12 Use proto output instead of jsonproto output for aquery
Test: use m --bazel-mode-dev and mixed_droid.sh
Bug: 233798334
Change-Id: Ib945359d3d05e6f51afe70432ec380e4e584175b
2022-10-26 17:07:48 -04:00
Joe Onorato
ba29f380d3 Move bazel from being a shell function to being a script at build/bazel/bin/bazel
Bug: 254713799
Test: b build //packages/modules/adb/apex:com.android.adbd
Change-Id: I6a0a89438a46d8252c3e0c24319038b0cf2dbd59
2022-10-24 06:38:11 -07:00
Jingwen Chen
7e11eb8609 Add integration tests for --config=bp2build with $OUT_DIR not named 'out'.
Bug: 251436403
Test: presubmits
Change-Id: Ife12777267ef06ce0efbeb90b303a61cd6ef0cfd
2022-10-13 14:05:27 +00:00
Sam Delmerico
ab558d92f0 Merge "Revert "Revert "run bp2build in mixed_mode_test.sh""" 2022-10-04 13:33:50 +00:00
Sam Delmerico
73d6bcc7bb Revert "Revert "run bp2build in mixed_mode_test.sh""
This reverts commit cb93d29aa9.

Reason for revert: retry this CL with additional changes in topic

Change-Id: Ibbb8926caef05c2177c06cb1c00795d407215f4a
2022-09-30 18:26:03 +00:00
Sam Delmerico
0d08b9ba35 document workaround test_bp2build_generates_all_buildfiles
test_bp2build_generates_all_buildfiles uses the same directory for
--output_base and --sandbox_tmpfs_path. This is required on the build
servers, but causes issues locally. This commit adds a more helpful
error message when this test fails.

Test: build/soong/tests/bp2build_bazel_test.sh
Change-Id: Ib29a7edf456f8ae39bd429ebb367c8115e02c284
2022-09-22 11:43:21 -04:00
Sasha Smundak
8bea267caf Implement bp2build for the package module
* We are interested mostly in the conversion the `default_applicable_licenses`
  attribute, as `default_visibility` cannot be handled until every module's
  `visibility` is handled.
* Several referenced license modules had to be manually enabled for
  conversion, and likewise a few trivial Android.bp containing only
  package and license modules.
* As Bazel allows only a single `package` rule, the package rules in a
  manually converted BUILD.bazel files were removed (in
  external/protobuf and prebuilts/clang/host/linux-x86 trees).
* The converted package rule is emitted before the `load` statements per
  Bazel documentation.

Bug: 190817312
Test: treehugger
Change-Id: If8bf6fee1580177de3bb402923615bcd48923ed2
2022-09-14 13:49:27 -07:00
Romain Jobredeaux
a2595a93fe Merge "Allowlist Kotlin-related libraries." 2022-09-13 13:28:39 +00:00
Romain Jobredeaux
0dfe8d3f7e Allowlist Kotlin-related libraries.
Change-Id: Iaeea811d9ae71b6e57ca79246e0a1691d65ff6f2
Bug: 186462641
Test: Newly allowlisted libs fall under CI
2022-09-08 16:21:42 -04:00
Jingwen Chen
60d8840f65 Update tests to use --config=android.
Bug: 244766775
Test: presubmits
Change-Id: Iaaabd275356c24b3e3713ea1047c134271c4561e
2022-09-08 15:54:32 +00:00
Treehugger Robot
f837a93337 Merge "Revert "add bp2build unit tests for aidl_interface"" 2022-08-30 17:19:13 +00:00
Treehugger Robot
b28effac58 Merge "improve error message when soong test fails early" 2022-08-30 08:04:48 +00:00
Sam Delmerico
105a70418f Revert "add bp2build unit tests for aidl_interface"
This reverts commit 1fa2672be9.

Reason for revert: breaks tradefed branch

Change-Id: I69bba531774031890baece1796df24d5534b93a9
2022-08-29 22:24:10 +00:00
Sam Delmerico
b6d1b03991 improve error message when soong test fails early
apex_comparison_test.sh defines a helper function to clean up state on
exit, but in error conditions the call_bazel function is not always
defined.

Test: added an exit 1 statement below trap
Change-Id: I73b0c56c0a4a2d9ed1d4c0bf38b6ac0ac985e716
2022-08-26 16:24:04 -04:00
Sam Delmerico
1fa2672be9 add bp2build unit tests for aidl_interface
Bug: 229251008
Test: go test ./bp2build -run TestAidlInterface
Change-Id: Ie7214d5578bc21e348410ca91ea42d7a3190eb3d
2022-08-25 14:47:41 -04:00
Sam Delmerico
970b96dd03 set USE_RBE=false in Soong integration tests
RBE is already disabled for this test on CI. Locally, the mock checkout
created for the Soong integration tests does not set up RBE properly, so
we should just disable it explicitly so that the integration tests can
be run locally.

Test: build/soong/tests/run_integration_tests.sh
Change-Id: I38875a02b549a9d8c8368d6287c4516518d20e34
2022-08-04 14:09:37 -04:00
Yifan Hong
82799f2b7f Add build/bazel_common_rules to mock bazel directories.
Test: build/soong/tests/run_integration_tests.sh
Change-Id: I647d122b5fc530b5a26bd69c141d3fdc9cca7424
2022-06-28 16:25:56 -07:00
Jingwen Chen
26f0b214ba Rewrite apex_diff_test as regular soong integration tests.
apex_diff_test targets were the last remaining dependents of make_injection. Rewriting them allows us to delete make_injection.

Test: CI
Change-Id: I928d8fe136d709b9f819c00c3127af66e720a7db
2022-06-20 06:42:37 +00:00
Usta Shrestha
2c9a5e3ddd Shellcheck warnings addressed
SC2236: use [[ -n "$var" ]] instead of [[ ! -z "$var" ]]
SC2035: use -- end of options, to accomodate filename w\ hyphens
SC2155: `local -r var=..` for readonly variable shellcheck ignores return value masking
SC2045: prefer glob to iteration over `ls`

Bug: N/A
Test: ran ./run_intergration_tests.sh
Change-Id: Iaf313857ecc417e855afd70c7455841b54b1c363
2022-06-09 15:47:05 -04:00
Jingwen Chen
d4b1dc8b2a bp2build: add support for planting unresolved symlinks in the symlink forest.
In the isDir check, there's a possibility that the Stat check fails
because the path is an unresolved symlink. Verify it with Lstat (which
would succeed, since it doesn't follow links), and treat it like a file
if Lstat succeeds.

Test: new integration test
Fixes: 232370097
Change-Id: I9807ca363a5dbdc20639b489b54627bd2cc1ca60
2022-05-17 12:17:53 +00:00
Lukacs T. Berki
e3487c8848 Add a test for correctness of C++ compilation.
This required the following:

- Adding Platform_base_sdk_extension_version to default soong.variables
- Teaching the symlink tree creation code to understand symlinks
- Making finder.go follow symlinks when requested

Adding yet another knob is unfortunate, but I can't allow that
unconditionally because the Android code base contains a number of
symlinks giving rise to infinite directory trees because they point back
to their parent and this seemed preferable to adding complicated logic
like "follow symlink but if only its fully resolved version does not
point under the source tree".

I could be convinced about the latter, though.

Test: Presubmits.
Change-Id: I453f6b7e5334771f5832c700db00f9d24ed1d82f
2022-05-04 09:12:01 +02:00
Cole Faust
d9932ad053 Always build mk2rbc/rbcrun
Currently, mk2rbc/rbcrun aren't built in certain phases
of the build, which causes the Starlark product configuration
to fail when using get_build_var if a regular build hasn't
been run before.

Bug: 226677850
Test: Manually
Change-Id: If85608eef63be25fddc4d916c82247c13eb0195f
2022-03-29 14:55:17 -07:00
Liz Kammer
0940b89937 Handle arch/cpu variants in mixed builds
Test: mixed_libc.sh
Change-Id: Ib5084060199b8e1a5955bd51bc3fd793bb83a1eb
2022-03-21 11:13:49 -04:00
Yuntao Xu
21be0e26b9 Add tests for converting license in androidmk
1. Added unit tests for license conversions in the androidmk tool, by
using a mocked filesystem;
2. Added integration tests in a shell script with a mocked filesystem.

Bug: 205615944
Test: m androidmk
Test: bash androidmk_test.sh
Test: TreeHugger
Change-Id: Id3d1f914190b52b82aadda7ea019192787b839d6
2021-12-07 11:26:16 -08:00
Cole Faust
fbfd40073d Rename rbc_product_config.sh to rbc_regression_test.sh
Test: Presubmits
Change-Id: I3423b9cc44d972646d89952a310a47147548ddc4
2021-11-23 16:57:16 -08:00
Jingwen Chen
ba6d4ac226 Fix test to use --experimental_platform_in_output_dir.
Bug: 197925723
Test: CI
Change-Id: I89dfb38efe261f008e7aab8d76eb3ff5c18add69
2021-11-09 11:55:36 +00:00
Cole Faust
10bcb4c908 Add rbc product config checks to run_integration_tests.sh
We already have a rbc product config ci postsubmit target,
but we want to add a small presubmit check as well.
run_integration_tests.sh is already run on presubmit, so
add it there.

Test: Presubmits
Change-Id: Id6fc282261507fb49a57b578ce2fdf20855dd6fd
2021-11-04 13:40:24 -07:00
Lukacs T. Berki
90b4334a64 Remove the out/soong/.bootstrap directory.
It's better not to have state hidden in dotfiles (or rather,
dotdirectories) if we can help.

It's questionable whether the "linux-x86" path segment makes sense since
soong_build only ever runs on one operating system, but I didn't want to
rock the boat now.

Drive-by fixed some quoting fixes in rbc-run. Notably, I didn't wrap
`$@` into double quotes because I don't know whether the lack of double
quotes was intended or not.

Also drive-by fixed the fact that "out/soong" was added twice to the
directory name of bpglob. This turned out not to be a problem because
bpglob doesn't need to be explicitly built: if it's needed, it's
declared as an input of the glob files so it'll be built automatically
(at the cost of the first "null build" not actually being a null build)

Test: Presubmits.
Change-Id: I710d8d16cd8212059a0ca1ee95378505303eed83
2021-11-04 09:47:58 +01:00
Colin Cross
34d60c9281 Use --skip-config --soong-only instead of --skip-make
--skip-make is deprecated because of its odd behavior around the
out/.soong.kati_enabled file.  Replace it with --skip-config --soong-only
instead, which will unambigiously skip running kati.

Bug: 204136549
Test: build/soong/tests/run_integration_tests.sh
Test: build/soong/scripts/build-mainline-modules.sh
Test: build/soong/scripts/build-ndk-prebuilts.sh
Change-Id: I629ee7542687aaafd68eea50346b0cf53eafe1ef
2021-10-29 16:34:55 -07:00
Jingwen Chen
3c5083c058 Revert "Fix test to use --experimental_platform_in_output_dir."
Revert submission 1854375-update-bazel-daecf427ec0bf0e963c324783062c4f5b61ff679

Reason for revert: introduces 503d56eda2, which conflicts with our current cc_binary->cc_shared_library work
Reverted Changes:
I40a511195:Fix test to use --experimental_platform_in_output_...
I05c2c11f3:Update Bazel to https://github.com/bazelbuild/baze...
Ie772d1665:Set --experimental_platform_in_output_dir.
Id66674d72:Update Bazel to https://github.com/bazelbuild/baze...

Change-Id: I0e5a7548feb13c2f3b4deae1921542b15d23a283
2021-10-13 14:25:41 +00:00
Jingwen Chen
c6ef451e0e Fix test to use --experimental_platform_in_output_dir.
Bug: 197925723
Test: CI
Change-Id: I40a511195ff7cc5fc336d3671bcdccd2364ca432
2021-10-13 02:25:19 +00:00
Lukacs T. Berki
c6012f36e1 Invoke soong_docs from the bootstrap Ninja file.
This makes soong_ui the only place where soong_build is invoked, thus
greatly simplifying the conceptual model of the build.

It comes with the slight limitation that now soong_docs (and queryview
and the JSON module graph) are not Make targets anymore, but I suppose
that's an acceptable loss.

The only place where someone depended on soong_docs from a Makefile is
removed in a separate change.

Test: Presubmits.
Change-Id: I3f9ac327725c15d84de725d05e3cdde1da3dcbe2
2021-09-08 09:31:52 +02:00
Lukacs T. Berki
3a82169a55 Invoke queryview from the bootstrap Ninja file.
It used to be invoked from out/soong/build.ninja, which required two
soong_build invocations one after the other (ne to generate
out/soong/build.ninja, one to generate the queryview workspace). This
was slower and required some shell-quoted-in-ninja-quoted-in-Go .

Test: Presubmits.
Change-Id: Idda79c067606663b66e9f94626fa24f3b5af4114
2021-09-06 17:10:49 +02:00
Lukacs T. Berki
a1b9372ef7 Make running soong_build in alternate modes nicer.
This includes the JSON graph generator and bp2build.

Before:
GENERATE_BAZEL_FILES=1 m nothing
GENERATE_JSON_MODULE_GRAPH=1 m nothing

Now:
m json-module-graph
m bp2build

They can now also be combined with other targets or each other.

The longer-term goal is to run "m queryview" and "m soong_docs" using
the same infrastructure. There are two alternate approaches:

1. Call soong_build from within the main Ninja invocation. This requires
two sequential soong_build invocations and is thus slower.
2. Do everything requested in the same soong_build invocation. This
would be faster, but one AFAIU can't tell Ninja that multiple possible
actions can build the same output so that doesn't work.

(1) is somewhat more desirable because soong_docs seems to be built
from build/make/core/main.mk ; I assume that that can be worked around
although I haven't checked where the output of "m soong_docs" goes.

Test: Presubmits.
Change-Id: If5ba36490d9f3f60733e6d6be9286eb2b67c3ff5
2021-09-06 16:03:51 +02:00
Lukacs T. Berki
a806e4176b Remove bootstrap_go_binary .
blueprint_go_binary is enough.

Test: Presubmits.
Change-Id: Ic95ed8533603dff396740bc1d2a7c60ff2cebf20
2021-09-01 11:55:22 +02:00
Lukacs T. Berki
e571dc3bd0 Print the JSON module graph correctly.
Before, we piggybacked on the implementation of regular soong_build and
wrote a fake build.ninja file to satisfy Ninja.

Now, instead, the JSON module graph is a a separate action in the Ninja
output file. This has the pleasant side effect that one can flip back
and forth between generating the JSON file and regular Soong without
loss of incrementality.

Side cleanup: write .d files in a slightly cleaner way.

Test: Presubmits.
Change-Id: Ia853383567b9dd31c53f3bdf56cfc8d517b498ec
2021-08-27 15:55:51 +02:00
Lukacs T. Berki
1a86bd2dc4 Use combined.ninja for soong_docs null build test.
This requires some explanation: turns out, Ninja uses the $builddir
variable declared in the top-level Ninja file to figure out where the
command log should go. This resulted in a loss of incrementality between
the manual Ninja invocation in test_null_build_after_docs because they
used different Ninja files and therefore different values of $builddir.

The reason why this was not a problem before is that the output files of
the main Ninja file and the bootstrap one were separate, but with that
changing, this will start to matter.

Test: Presubmits.
Change-Id: I28959cc7d659e698c7694a58326c8731eac060eb
2021-08-19 16:29:47 +02:00
Lukacs T. Berki
56ebaf35b3 Separate the files of bp2build and soong_build.
The following files are forked:

- build-globs.ninja
- The glob list files
- .d files for the glob list files
- The output file (build.ninja or the bp2build marker file)

This makes bp2build and soong_build not overwrite each other's files
they need for proper incrementality.

Test: Presubmits.

Change-Id: I69d192cbd36ecd9677f46f3fa095dfce6f872227
2021-08-16 09:15:28 +02:00
Jingwen Chen
f798d5d6f9 Merge "Generate build-globs.ninja when running bp2build." 2021-08-12 14:06:52 +00:00
Jingwen Chen
53dfa408b4 Generate build-globs.ninja when running bp2build.
This fixes null bp2build builds.

When running bp2build, out/soong/.bootstrap/build-globs.ninja wasn't
generated, therefore none of the globs in out/soong/.primary/globs have
actions to generate them. This makes bp2build always re-run on a null
build, because it depends on those non-existent globs in its depfile.

Fix the above by generating a build-globs.ninja file with the globs that
bp2build encounters during conversion, and add tests to verify that null
builds and bp2build -> soong workflows correctly regenerates the
build-globs.ninja file.

Test: soong integration tests for null soong->soong, bp2build->bp2build and bp2build->soong builds.
Fixes: 193650250
Change-Id: Icfbad351dfa85541d1ea451f73e65cac87097926
2021-08-12 10:14:02 +00:00
Rupert Shuttleworth
755ceb01e3 Ensure directories in the Soong output dir have appropriate permissions, so that 'm clean' works.
In particular, Bazel sometimes creates directories whose files cannot be deleted.

Test: m clean used to fail after b build //system/timezone/apex:com.android.tzdata, but now it works
Test: Added integration test which fails without this change

Change-Id: I08c8feed21c31ec187fe40be513f7eb4865c8ac3
2021-08-12 05:07:11 -04:00
Jingwen Chen
916322541a Allow //external/bazel-skylib to use existing BUILD files
Bug: 190605804
Test: bp2build-incremental
Change-Id: Ida765465532c0e98d035eef4c703d13fbf554538
2021-08-11 12:19:17 +00:00
Dan Willemsen
4591b6496d Upgrade to golang protobuf api v2
Major operations:
 * Fix the go_package entries to be consistent, as the new tool
   complains when it doesn't have a '/'.
 * Regenerate with the new protoc-gen-go tool.
 * github.com/golang/protobuf -> google.golang.org/protobuf
 * proto.[Un]MarshalText -> prototext.[Un]Marshal

Change-Id: Ie1147bd2457fafb66ba555461b3bf14f0561a25d
2021-07-23 11:12:05 -07:00
Spandan Das
0506361a60 Add errorHints to stdout when read-only file system errors are detected
The source tree will eventually be made ReadOnly, and recipes that write
directly to the source tree will fail. Use a pattern-match approach on
the results of stdout/stderr to provide hints to the user in such a
scenario.

If multiple patterns are found in raw output, print error hint
corresponding to first pattern match. first pattern match is chosen
since the failing function will be at the top of the stack, and hence
will be logged first

Test: Wrote a unit test to assert errorhint is added to output.
Wrote an integration test that writes to a file in the source tree
1. When source_tree is RO, the recipe fails and an error hint is printed
to stdout
2. When source tree is RW, the recipe succeeds and no error hint is
printed

Bug: 174726238
Change-Id: Id67b48f8094cdf8a571c239ae469d60464a1e89c
2021-06-29 00:20:21 +00:00
Jingwen Chen
8c52358ad7 Fix OUT_DIR lookup in mixed builds.
In mixed builds, Bazel operates in <root>/out/soong/workspace, but the real
OUT_DIR is just <root>out/, not <root>/out/soong/workspace/out. This CL
ensures that the correct OUT_DIR is passed to mixed builds's bazel by
making OUT_DIR absolute.

Also add STANDALONE_BAZEL to build_test's Bazel smoke test.

Test: TH
Change-Id: If8b4058d43bf821f5196016f9b0ad38edfe18716
2021-06-01 12:07:40 +00:00
Jingwen Chen
4fabaf52b0 bp2build/b: exit early in GENERATE_BAZEL_FILES=1.
This CL fixes a typo in writeFakeNinjaFile to correctly write
a fake out/soong/build.ninja and its depfile. It also modifies bootstrap
phase to *not* run the main soong build phase (which takes more than a
minute) if GENERATE_BAZEL_FILES=1.

This change has the side effect that `GENERATE_BAZEL_FILES=1 m nothing`
no longer generates the real build.ninja, which is fine because one
shouldn't be using GENERATE_BAZEL_FILES=1 for that anyway (or, use
USE_BAZEL_ANALYSIS=1). This change has no effect on mixed builds.

Time on a change to Soong or any Android.bp files:

Before: bp2build_workspace_marker (~20 seconds) + build.ninja (1 min)
After: bp2build_workspace_marker (~20 seconds)

Time on the second of two consecutive `b build //bionic/...`: 2.070s

Test: TH
Test: Soong integration tests
Change-Id: I43720641815994caba97b8d165d7c3fc254cbd06
2021-05-25 03:42:38 +00:00
Liz Kammer
50d601731b Merge "Dump bazel product config in Soong" 2021-05-20 14:09:18 +00:00
Liz Kammer
09f947d67e Dump bazel product config in Soong
Bug: 187862880
Test: build/bazel/ci/bp2build.sh
Test: build/soong/tests/bp2build_bazel_test.sh
Change-Id: I24b09baad973e25bec4476e1ea4a7692b72b7d20
2021-05-19 17:38:56 -04:00
Rupert Shuttleworth
413a7a97fb Have bp2build generate BUILD.bazel instead of generating BUILD.
Test: TH
Change-Id: I465d29da96dd77c432890a38a56203e291b8ceed
2021-05-18 09:01:36 -04:00
Rupert Shuttleworth
4949557d50 Merge "Generate BUILD files for every directory that has an Android.bp file." 2021-04-21 14:51:28 +00:00
Lukács T. Berki
6b3fb3a12a Merge "Reenable test_glob_noop_incremental." 2021-04-21 14:28:52 +00:00
Rupert Shuttleworth
2a4fc3ecdc Generate BUILD files for every directory that has an Android.bp file.
Test: Added an integration test
Test: bazel build --package_path=out/soong/workspace //bionic/...

Change-Id: Ie34bd23ab3c5428e6c9c9919e5fb6fcb4e709adc
2021-04-21 07:15:50 -04:00
Lukacs T. Berki
b21166e236 Make symlink_forest.go prefer generated files.
Now, if the same file exists in the generated tree and the source tree,
it symlinks in the generated file instead of failing outright.

Drive-by fix: print errors for all conflicts instead of bailing out on
the first one.

Test: Presubmits (including the two new tests)
Change-Id: Ifb5b3fc89b5454d231966bfa4e61c22cd69834f3
2021-04-21 12:24:27 +02:00
Lukacs T. Berki
69ed2a2b9e Reenable test_glob_noop_incremental.
It accidentally got disabled in aosp/1676621 due to a merging mishap.

Test: Presubmits.
Change-Id: I10a090480008c72c2a8390fe30c64f666a177ea3
2021-04-21 12:05:08 +02:00
Christopher Parsons
4e78814200 Merge "Subsume INTEGRATED_BP2BUILD into other env modes" 2021-04-20 23:33:40 +00:00
Chris Parsons
ec1a3dc6f8 Subsume INTEGRATED_BP2BUILD into other env modes
This refactors bazel-build mode determination logic in soong_ui so it's
clearer which of three possible modes are being used in a given
invocation (NO_BAZEL, GENERATE_BUILD_FILES, or MIXED_BUILDS).

Test: bootstrap tests
Change-Id: I41d2baebf8d560c2cc42db8daa8b936101d453e3
2021-04-20 19:25:48 -04:00
Colin Cross
14d09018eb Merge "Update for sharded globs" 2021-04-20 16:16:40 +00:00
Lukács T. Berki
3784448c9e Merge "Create a synthetic Bazel workspace." 2021-04-20 10:44:08 +00:00
Lukacs T. Berki
b353cca496 Create a synthetic Bazel workspace.
It's under out/soong/workspace and is a symlink forest that merges BUILD
files generated by bp2build and the source tree.

bazel-* symlinks and $OUTDIR are currently ignored.

Test: Presubmits.
Change-Id: If14df23bd0f6a6f2d7d1140f95213f2aee66d652
2021-04-20 10:00:02 +02:00
Lukacs T. Berki
731bb91b8e Propagate errors from integration tests scripts.
Test: Presubmits.
Change-Id: Ie1f83c562a357e472bcaa95a4c1567a3e974d496
2021-04-19 09:28:21 +02:00
Colin Cross
7d9d2405f3 Merge "Fix test_glob_noop_incremental" 2021-04-17 02:22:06 +00:00
Colin Cross
b72877f749 Fix test_glob_noop_incremental
I6a98660cfe6a40bcaa978e8d7544cdffad86a7fa was submitted concurrently
with test_glob_noop_incremental and broke the test by making the
first build incremental.  Add an rm -rf out to make the test start
from a clean build.

Bug: 185591972
Test: tests/bootstrap_test.sh
Change-Id: I529aaf707b2790e5e1022ba9b2637ed7d2435bd5
2021-04-16 10:09:54 -07:00
Lukács T. Berki
86b38024c5 Merge "Colorize the name of the test to be run." 2021-04-16 05:55:05 +00:00
Colin Cross
cb33a00992 Update for sharded globs
Update the path bootstrap_test.sh uses to check for bpglob reruns
to follow the changes made for sharding globs.

Use bootstrap.GlobFileListFiles to get dependencies during bpbuild.

Test: tests/bootstrap_test.sh
Bug: 159845846
Change-Id: Ibaa7c4360881ed6b666a811bf34b19ea0cdcafe9
2021-04-15 11:03:00 -07:00
Colin Cross
9e7cea2c0b Merge "Add test for globs on noop incremental builds" 2021-04-15 16:42:08 +00:00
Lukacs T. Berki
7a51907346 Colorize the name of the test to be run.
Test: Presubmits.
Change-Id: Ie1335f9fb91c199874e37d74d0853e8f441cc294
2021-04-15 18:18:45 +02:00
Lukacs T. Berki
d518e1a407 Make bp2build be more correct.
It now handles adding .bp files and changing globs.

In order to do this, depfiles are now written separately from RunBlueprint.

This is necessary due to the confluence of a number of seemingly
unrelated factors:

1. The glob filelist dependencies are discovered in globSingleton
2. Singletons need to be registered because otherwise singleton module
   types panic
3. Singletons don't work because they require mutators bp2build does not
   run

Due to (1), we would need to run the glob singleton. However, due to (2)
and (3), we can't run singletons and have to run Blueprint with
StopBeforeGeneratingBuildActions, which is when the build actions
writing glob files would be generated. So what happens is:

1. When bp2build is run, the glob singleton is disabled
2. At the end of bp2build, the list of glob files is artifically added
   to the depfile of the workspace marker file
3. When build.ninja is generated, the Ninja file containing the glob
   list file is written by the now-active glob singleton

Test: Presubmits.
Change-Id: I3c5898d8c57c554a93520276c64a952afc912dbe
2021-04-15 13:06:16 +02:00
Lukács T. Berki
3d76d5d6b8 Merge "Allow running bp2build as part of a regular build." 2021-04-15 11:03:51 +00:00
Lukacs T. Berki
686965baeb Speed up Soong integration tests.
This is done by running a build before the first test case, tarring up
$TOP (including out/) then untarring it for every test case instead of
rebuilding soong_build each time.

The speedup is approximately 2x.

Also add some cute ANSI escape sequences and delineation of individual
test cases.

Test: The aforementioned integration tests.
Change-Id: I6a98660cfe6a40bcaa978e8d7544cdffad86a7fa
2021-04-15 08:47:39 +02:00
Lukacs T. Berki
f8e2428c5d 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
2021-04-15 08:46:07 +02:00
Lukacs T. Berki
b448c34bfd Make integration tests clean up after themselves.
Well, this was embarrassing.

Test: These tests.
Change-Id: Id25f9f1f4bd2d2d01d49d11a5af8eb50dd51fe6e
2021-04-14 16:45:22 +02:00
Colin Cross
1042595508 Add test for globs on noop incremental builds
Test that an incremental build with a glob doesn't rerun soong_build, and
only regenerates the globs on the first but not the second incremental build.

Bug: 159845846
Test: tests/bootstrap_test.sh
Change-Id: Ib9e3f2f22422d567253a366d28255e3f39d97ca8
2021-04-12 22:35:46 -07:00
Colin Cross
c02504edd6 Add test for globs used during bootstrapping
bootstrapping can read extra Android.bp files that could affect
soong_build.

Bug: 159845846
Test: bootstrap_test.sh
Change-Id: Ib053ff9c2ee70638419f122a36438a515640e0b4
2021-04-09 09:46:09 -07:00
Lukacs T. Berki
3b730c4bc8 Organize Soong's integration tests:
- Move them into a new directory
- Split tests by theme and add a library file
- Add a shell script that runs them all

Test: Manually ran build/soong/run_integration_tests.sh .
Change-Id: I758b91d679f41aee47d15472cc02547ce89f6386
2021-04-08 13:21:13 +02:00