Commit graph

40 commits

Author SHA1 Message Date
Spandan Das
08e90c2718 Fixes for run_integration_tests.sh
This script runs some useful integration tests, but is currently broken
at ToT. This CL enables us to rerun this script successfully.

Details
1. Remove the scripts related to bp2build/b/mixed_builds. These modes
   have been/are on the verge of deletion from soong
2. Remove the comparisision scripts for soong and bazel built artifcats,
   for the same reason
3. Add a TARGET_RELEASE to androidmk_test.sh
4. Add a TARGET_PRODUCT to o/s/build.ninja, since the generated .ninja files
   now have a product-specific suffix.
5. Remove a test that checks that globs are not generated in the first
   clean run. We always generate the glob file now (aosp/2893286)

Test: build/soong/tests/run_integration_tests.sh
Change-Id: I39f6706ab2a81a7b1b2e90d43195bc3e2c7a5c08
2024-03-29 19:00:20 +00:00
Liz Kammer
33cc80eb1f Revert "Revert "Restrict plugins to an existing allowlist""
This reverts commit b20a12553e.

Reason for revert: Rollforward with fix

soong-ca-certificates-apex was missing from allowlist

Test: verify fixes CI breakages
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:dfe4a9e4dd088f42ba5e0a3c4f7777c253d378d3)
Merged-In: I00687bd2962dbdaaf55189ca4aa82183264eb8d7
Change-Id: I00687bd2962dbdaaf55189ca4aa82183264eb8d7
2023-05-18 18:20:28 +00:00
Chris Parsons
a3ae007641 Touch soong_build output at the end of main
This fixes an incrementality bug that resulted in superfluous
build.ninja regeneration after a new glob definition is added.

Fixes: 279674820
Test: Treehugger
Test; New integration test in this CL

Change-Id: Ifefe66a0eb1c125e9ad5373d60437a1cb1e6fdec
2023-05-12 13:40:12 +00: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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
Renamed from bootstrap_test.sh (Browse further)