Commit graph

655 commits

Author SHA1 Message Date
Kousik Kumar
c3a22d8ebd Allowlist RBE_num_retries_if_mismatched variable
This variable tells reproxy the number of times an action that
mismatches between local and remote-executions should be run remotely to
determine if the action is inherently non-deterministic.
An action is considered non-deterministic if the number of unique output
digests we get from the remote-run is > 1.

Bug: b/178842439
Change-Id: I0d50eed29b801be67a7ede9b25ce7f4535980f05
2021-03-17 14:22:05 -04:00
Lukacs T. Berki
5f6cb1d6d3 Compile soong_build for debugging if needed.
That is, when SOONG_DELVE= is set.

Test: "m nothing; SOONG_DELVE=port m nothing; m nothing"
Change-Id: I16bd4e54e81b93202573935df134d413feea9bb2
2021-03-17 15:03:14 +01:00
Lukacs T. Berki
d7ce8402d8 Remove GeneratingPrimaryBuilder().
It's replaced with a flag in bootstrap.Args .

Test: "m nothing" (presubmits take a full workday these days)
Change-Id: Ia0bfa2091013e389890e583c559006077806af99
2021-03-17 14:08:50 +01:00
Lukacs T. Berki
d1e3f1ff08 Embed minibp into soong_ui.
This requires linking Blueprint into soong_ui. It lets us avoid the
complicated dance of Ninja files and shell scripts: now the information
as to how soong_build is built is passed directly to Blueprint using a
struct that contains all the information the command line arguments used
to contain.

The ability to run Blueprint from the command line is kept (for now).

Some variables in bootstrap/command.go needed public accessor functions
because soong_build reads them. This will be disentangled by moving the
flag parsing to soong_build.

The presence of the flag definitions in Blueprint means that soong_ui
now also accepts them. This is not a problem in practice because they
are ignored and because soong_ui itself is hidden behind a few layers of
shell scripts.

Test: Presubmits + the new bootstrap_test.sh .
Change-Id: I6dca478f356f56a8aee1e457d71439272351390b
2021-03-17 08:35:52 +01:00
Lukacs T. Berki
21d5c7aaa9 Hard-wire the path to xcrun as /usr/bin/xcrun.
This lets us not leak $PATH to soong_build. It was only needed for
Darwin tests anyway.

Test: Will ask jingwen@ who has a Mac.
Change-Id: I4647e41275b323fe6283580f8f92718c6229f23e
2021-03-11 08:52:39 +01:00
Lukács T. Berki
2373e597ea Merge "Fix the environment of soong_build:" 2021-03-11 07:09:24 +00:00
Colin Cross
75a38ba791 Merge "Revert "Skip old file cleanup for non-full builds."" 2021-03-10 22:53:43 +00:00
Lukacs T. Berki
b4ced9d886 Fix the environment of soong_build:
- Incorporate BAZEL_* variables in soong.environment.available
- Set SOONG_DELVE when requested

Test: Manual.
Change-Id: I3ac675f4876220b788cc48d288b402ac6016c37b
2021-03-10 15:43:06 +01:00
Lukacs T. Berki
73ab928daa Make $PATH available when building soong_build.
This is exclusively used by tests so it's awful, but Darwin builds are
currently broken so let's unbreak them first then start thinking.

Test: "m nothing" on Linux (I don't have access to a mac OS machine)
Change-Id: I1ea9ca71a5aff36a3454282a4c87ad368138baaa
2021-03-10 11:02:39 +01:00
Colin Cross
41ad6b632f Revert "Skip old file cleanup for non-full builds."
This reverts commit 6e49493dac.

FULL_BUILD is not set during the config stage, so this never calls
cleanOldInstalledFiles.

Bug: 168105598
Bug: 182008128
Test: manual
Change-Id: I58a54f167763cdb77b3c1bd4f18f519fcaf8751a
2021-03-09 12:04:17 -08:00
Lukacs T. Berki
b14ad7b5dc Run Ninja in a clean environment.
This sandboxes Soong's tests better.

Setting "TOP" is slightly ugly, but doing it properly would conflict
with aosp/1609218.

Test: Manual ("m nothing")
Change-Id: Ie3d3cd17f116a5fe0ad25c670fc5ed9c33f8123b
2021-03-09 10:43:57 +01:00
Lukacs T. Berki
7d613bfe2c Make it possible to debug soong_ui.
This works by setting the SOONG_UI_DELVE= environment variable to the
port on which soong_ui should accept a Delve connection on.

This is achieved by reusing the Delve execution logic between soong_ui
and soong_build.

Test: Manual.
Change-Id: Id2c1d4b6faac1a4a3918c91030ce2239f7daf54f
2021-03-08 08:27:58 +01:00
Paul Duffin
5e85c665d0 Do not ignore error when writing environment file
Test: m nothing
Change-Id: I4281e22ae10a649b51b9fbed7f8c1554f18885b9
2021-03-05 17:46:29 +00:00
Lukács T. Berki
ddebd2c82a Merge "cd to / before running soong_build ." 2021-03-04 07:07:02 +00:00
Petri Gynther
ac22956dcb Rename vendor-ramdisk to vendor_ramdisk
Rename to get consistent ramdisk directory naming in
out/target/product/<name>:
  debug_ramdisk
  ramdisk
  vendor_debug_ramdisk
  vendor_ramdisk

Test: build and inspect out/target/product/<name>
Change-Id: Ib86e6509bd910e8c95bcb6e3f7bb639ebbfe3758
2021-03-03 00:15:54 -08:00
Lukacs T. Berki
7690c09953 cd to / before running soong_build .
This lets one avoid any decisions as to when to chdir there during its
execution and leads to better sandboxing because the pwd doesn't leak to
init() functions anymore.

Test: Manual.
Change-Id: I1560da8ed3a621249426f9e8908aa890c21e13ba
2021-03-03 09:14:22 +01:00
Colin Cross
fdf28ca403 Merge changes I3e6bc9b5,If9f8fb10
* changes:
  Disable TestSendLog on the buildbots
  Remove global state from VNDK apexes
2021-03-03 01:45:02 +00:00
Colin Cross
6cb1128b54 Disable TestSendLog on the buildbots
TestSendLog sometimes hangs on the buildbot, although it has never
been reproduced locally.  The cause appears to be a unix domain
packet that was sent but never received.  Skip the test in short
mode for now, which will leave it manually runnable but not run
it as part of the build.

Fixes: 120596545
Test: m nothing
Change-Id: I3e6bc9b5f1d9c15dc9a7294d98cbd917d0637c44
2021-03-02 12:26:14 -08:00
Lukacs T. Berki
3243aa51eb Move environment staleness check to soong_ui.
Also delete the now-unnecessary soong_env binary.

Test: Manually. Also checked what happens when a used environment
variable changes.

Change-Id: Ib393e7f444e94819198c6cce4bcd8719d9fd9441
2021-03-02 09:32:49 +01:00
Bob Badour
02040de891 Add LOCAL_LICENSE_KINDS to build/soong
Added SPDX-license-identifier-Apache-2.0 to:
  Android.bp
  android/Android.bp
  android/soongconfig/Android.bp
  androidmk/Android.bp
  apex/Android.bp
  bazel/Android.bp
  bp2build/Android.bp
  bpf/Android.bp
  bpfix/Android.bp
  cc/Android.bp
  cc/config/Android.bp
  cc/libbuildversion/Android.bp
  cc/libbuildversion/tests/Android.bp
  cc/ndk_api_coverage_parser/Android.bp
  cc/ndkstubgen/Android.bp
  cc/symbolfile/Android.bp
  cmd/dep_fixer/Android.bp
  cmd/diff_target_files/Android.bp
  cmd/extract_apks/Android.bp
  cmd/extract_jar_packages/Android.bp
  cmd/extract_linker/Android.bp
  cmd/fileslist/Android.bp
  cmd/host_bionic_inject/Android.bp
  cmd/javac_wrapper/Android.bp
  cmd/merge_zips/Android.bp
  cmd/multiproduct_kati/Android.bp
  cmd/path_interposer/Android.bp
  cmd/pom2bp/Android.bp
  cmd/pom2mk/Android.bp
  cmd/sbox/Android.bp
  cmd/soong_build/Android.bp
  cmd/soong_env/Android.bp
  cmd/soong_ui/Android.bp
  cmd/zip2zip/Android.bp
  cmd/zipsync/Android.bp
  cuj/Android.bp
  dexpreopt/Android.bp
  dexpreopt/dexpreopt_gen/Android.bp
  env/Android.bp
  etc/Android.bp
  filesystem/Android.bp
  finder/Android.bp
  finder/cmd/Android.bp
  genrule/Android.bp
  jar/Android.bp
  java/Android.bp
  java/config/Android.bp
  kernel/Android.bp
  linkerconfig/Android.bp
  linkerconfig/proto/Android.bp
  makedeps/Android.bp
  partner/Android.bp
  phony/Android.bp
  python/Android.bp
  python/tests/Android.bp
  remoteexec/Android.bp
  rust/Android.bp
  rust/config/Android.bp
  scripts/Android.bp
  sdk/Android.bp
  sh/Android.bp
  shared/Android.bp
  symbol_inject/Android.bp
  symbol_inject/cmd/Android.bp
  sysprop/Android.bp
  tradefed/Android.bp
  ui/build/Android.bp
  ui/logger/Android.bp
  ui/metrics/Android.bp
  ui/metrics/proc/Android.bp
  ui/status/Android.bp
  ui/terminal/Android.bp
  ui/tracer/Android.bp
  xml/Android.bp
  zip/Android.bp
  zip/cmd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  finder/fs/Android.bp
  third_party/zip/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work

Change-Id: Ia47ca14f16b8c9f84f9d533a07e5b00e2c04e8d4
2021-02-06 04:23:21 +00:00
Jingwen Chen
eb76c4319d bp2build: fix running from clean checkout.
bp2build is a Soong mode that returns as soon as the BUILD files are generated. This causes it not generate the build.ninja file, which the Ninja process executing soong_build itself expects to produce as an output. If there isn't an existing build.ninja file generated from a previous build, GENERATE_BAZEL_FILES=true m nothing will fail.

This CL generates the expected files as a workaround, and also makes GENERATE_BAZEL_FILES=true skip the Kati/Ninja steps in soong_ui since they aren't needed.

Test: rm -rf out/ && GENERATE_BAZEL_FILES=true m nothing && m libc

Fixes: 178683777

Change-Id: I2515ef7961682d2be5f096ed24831cc185165a67
2021-01-29 22:33:25 -05:00
Kousik Kumar
1e4d5f3e67 Add FAILED: prefix to RBE Fatal error message
This error message it currently being
logged to stdout which goes to build.log file . We want it to be logged to
build_error.log file instead so that downstream systems that need to run
based on the error message will continue to work.

Test: Tested by running `m toybox` and ensuring that FAILED: prefix is
at the beginning of the line.

Bug: b/177221705
Change-Id: Ie0c9acee2739acf149384e33804b5fca3273c24f
2021-01-26 14:34:30 -05:00
Treehugger Robot
f9be4e07e1 Merge "Moving $OUT/vendor-ramdisk-debug.cpio.lz4 to intermediate dir" 2021-01-24 14:53:43 +00:00
Yo Chiang
d813f12473 Remove GKI artifacts on installclean
Bug: 177495407
Test: m installclean && GKI prebuilts under OUT dir are removed
Change-Id: I05f888376c7f2b253e9966c1a652063a6c4760d9
2021-01-22 00:16:47 +08:00
Bowgo Tsai
ae205c3e32 Moving $OUT/vendor-ramdisk-debug.cpio.lz4 to intermediate dir
Therefore, no need to remove vendor-ramdisk-debug.cpio.lz4
for installclean as it will not be installed to $OUT dir.

Bug: None
Test: make vendorbootimage_debug
Change-Id: Ib7fb9931c55a9bb24e5ca8c4a80bd72f7233c57f
2021-01-20 16:35:31 +08:00
Jaewoong Jung
6e49493dac Skip old file cleanup for non-full builds.
There are few build targets that don't generate an installed file list,
e.g. product-graph. Skip the old installed file cleanup step so that the
func doesn't complain about a lack of the list file.

Fixes: 168105598
Test: m product-graph
Change-Id: Ib7dce6b801979bb565b74d6355143bac23b84fe6
2021-01-05 16:47:04 -08:00
Jaewoong Jung
18aefc1977 Remove unnecessary snake case variables.
Test: m nothing + TreeHugger
Change-Id: I99f7162944daa6c57c6ae4763261e108bb5cb6b1
2020-12-22 12:38:35 -08:00
Patrice Arruda
175500f016 Merge "Read the proc status file when PID is given for metrics purpose." 2020-12-18 04:14:09 +00:00
Patrice Arruda
04157e186f Read the proc status file when PID is given for metrics purpose.
To measure the MaxRSS memory correctly, read the proc status file
under /proc/<pid>/status and extract the MaxRSS value from it. The
implementation is only available for Linux based distributions.

Bug: b/169453825
Test: go test
Change-Id: I32e3068fee7447f9ef5dfb5a8d8dcb6934e0af23
2020-12-17 14:52:14 -08:00
Patrice Arruda
589826bc1e Add and update comments in ui/metrics/metrics.go.
The metrics.go had missing comments and also did minor code refactoring
to be more in golang best practices.

Bug: b/172917718
Test: m nothing.
Change-Id: Id63e4af3f27b582fc13ef3f988ac5c8707fb9adf
2020-12-15 23:36:01 +00:00
Patrice Arruda
5c58b6410c Remove soong_metrics_proto from the import of the protobuf file.
No needed to define soong_metrics_proto since it is defined in
the Android.bp file.

Bug: b/172917718
Test: m nothing
Change-Id: Ib5f4cd6d06c08660803cf070da544e9c2d1dce1f
2020-12-15 19:41:40 +00:00
Patrice Arruda
48d55ad2db Add setup_tools performance metrics to Soong protobuf file.
The setup_tools metrics has been missing since day one and is
needed to track down slowness of setting up the build system.

Bug: b/175706305
Test: m nothing and ran the printproto command to check that the
      setup_tools field has been set.
Change-Id: Idc8a38fa830e0a906170feeede63435715eaa05b
2020-12-15 19:39:09 +00:00
Treehugger Robot
a767196955 Merge "Add and update comments in ui/metrics/event.go" 2020-12-15 15:58:03 +00:00
Patrice Arruda
8a44a37623 Add and update comments in ui/metrics/event.go
The event.go code was refactored to follow the best practices
of golang code style.

Bug: b/172918681
Test: go test ./ui/metrics
Change-Id: Ic57d7cd576a9b146530ae37f03f4f5679d6cffef
2020-12-15 03:01:24 +00:00
Patrice Arruda
05ab2d0731 Enable bazel profiling in soong_build.
Bazel is executed several times during the execution of soong_build.
For each bazel execution, generate a profile and save under the
BAZEL_METRICS_DIR which is defined in soong_ui.

Bug: b/174479924
Test: * USE_BAZEL_ANALYSIS=1 USE_BAZEL=1 m nothing and checked
        if the cquery and graph build bazel profiles were generated.
      * Verified that the generated bazel profiles were uploaded
        to the local dev metrics pipeline.

Change-Id: I3d20204484dc6c5a1525a5d3eec1d62cfb33535b
2020-12-14 18:48:11 +00:00
Treehugger Robot
8574ae773f Merge "Allow Bazel to write to an external DIST_DIR (outside of OUT_DIR)." 2020-12-11 05:16:32 +00:00
Rupert Shuttleworth
3c9f5ac787 Allow Bazel to write to an external DIST_DIR (outside of OUT_DIR).
Also get Bazel to write real files there (not symlinks) so that the DIST_DIR can be independent.

Test: Manually using e.g. DIST_DIR=/tmp/foo USE_BAZEL=1 m dist
Change-Id: I39d5219500864c9ecc85f356a028e9b5bf2607f4
2020-12-11 01:17:58 +00:00
Patrice Arruda
7d235cc24d Allow uploading a directory of metrics files.
The upload functionality now supports directories to be uploaded
for metrics purpose.

Bug: b/174479728
Test: Wrote unit test case.

Change-Id: I6906be4c1b7fd76ddf6ff7b94e48fe1c4209c59d
2020-12-10 21:48:05 +00:00
Treehugger Robot
5839c91074 Merge "Provide an interface for shared paths between Soong and Soong UI." 2020-12-09 17:31:02 +00:00
Rupert Shuttleworth
0bc9a9ad6b Add dependency checker special case for out/build_date.txt.
Test: Future TH presubmit.
Change-Id: I4f80cf12be4aa1a3040b38ac7c6bed593aefd65e
2020-12-08 23:28:25 +00:00
Patrice Arruda
83842d7235 Provide an interface for shared paths between Soong and Soong UI.
Code refactoring has been done for logs directory logic code since
the bazel metrics directory depends on the log directory. For builds
that did not specify a dist directory, the log directory is under
out directory. With dist, the logs directory is under <dist dir>/logs.
This matters for Android CI builds where the metrics files are
placed under logs directory. With this change, the bazel metrics
directory and corresponding files will be under <dist dir>/logs
directory for Android CI builds.

Bug: b/174479728
Test: * USE_BAZEL=1 m nothing (bazel_metrics dir in out dir)
      * m nothing (bazel_metrics dir deleted)
      * DIST_DIR=/tmp/build USE_BAZEL=1 m nothing dist (bazel_metrics
        is in /tmp/build/logs directory)

Change-Id: Ic9e1ff49a1964fcaaf801bde2c19f33597ca1db4
2020-12-08 20:24:14 +00:00
Rupert Shuttleworth
72f72b42cb Print both the implicit and explicit environment variables when running Bazel.
Test: Manually via USE_BAZEL=1 use_rbe m.
Change-Id: I9f0ac8875b47848fdea4ae97d107e4167c4a7f6e
2020-12-08 06:12:51 +00:00
Rupert Shuttleworth
561f2f2d96 Only print the Bazel command line once.
Test: USE_BAZEL=1 m and USE_BAZEL=1 use_rbe m.
Change-Id: I8413e92d91c906f884628bedac6955575cf86a1c
2020-12-07 09:59:13 +00:00
Rupert Shuttleworth
ead7ef6e3b Use lstat instead of stat to avoid permissions issues when creating symlinks.
Also refactor symlink code slightly and add some more error checking.

Test: Manually.
Change-Id: I75119707cdf497e5690ac57abd814c8f18cab1f8
2020-12-07 04:54:18 +00:00
Treehugger Robot
0ec64e5df7 Merge "Print the full Bazel command line (including env) for debugging purposes." 2020-12-07 04:52:37 +00:00
Rupert Shuttleworth
947ed97367 Print the full Bazel command line (including env) for debugging purposes.
Test: Manually ran USE_BAZEL=1 m and USE_BAZEL=1 use_rbe m and looked at the build output.
Change-Id: Idbfdf8b00458fbd4b684cb0c1b58d6515909293c
2020-12-07 04:50:29 +00:00
Treehugger Robot
840708e45b Merge "Remove obsolete environment variables from ninja.go allowlist." 2020-12-05 02:48:42 +00:00
Rupert Shuttleworth
411996ca50 Remove obsolete environment variables from ninja.go allowlist.
Test: N/A.
Change-Id: I717b31f2b68d2cac72cca33f04cfa3b6078cb8eb
2020-12-04 18:42:29 +00:00
Rupert Shuttleworth
ad532f21ab Allow RBE-related environment variables to be visible during Bazel action execution.
Test: Manually.
Change-Id: I1acfdd5f30b2e08288508da8136029e454316622
2020-12-04 11:27:54 +00:00
Anton Hansson
5e5c48b2b5 Add support for skipping just kati
The existing --skip-make flag disables both the config step and the kati
step in the build. Add support for a --skip-kati flag that skips just
the kati step, and refactor things so that the logic is shared between
these two.

Bug: 174315599
Test: TARGET_PRODUCT=aosp_arm64 soong_ui --make-mode --skip-kati;
      (verify soong.variables is regenerated)
Change-Id: I75b1910fc1c12fcda130e37b7bc4c050131c7b33
2020-12-02 10:39:50 +00:00
Treehugger Robot
d74b9c5728 Merge "Minor cleanup of soong.go." 2020-12-02 08:21:59 +00:00
Treehugger Robot
d8c099e12d Merge "Minor cleanup of build.go." 2020-12-02 02:29:08 +00:00
Rupert Shuttleworth
b7d971012a Minor cleanup of soong.go.
Test: TH presubmit.
Change-Id: Ic5b263aa1320d9f70a6749ed12cbdc477acd3067
2020-12-02 00:56:35 +00:00
Rupert Shuttleworth
eeb5caac78 Minor cleanup of build.go.
Test: TH presubmit.
Change-Id: I3a41130b25d39276162850e417f036f9ce6a2ec0
2020-12-02 00:49:03 +00:00
Treehugger Robot
bd8b0d26b2 Merge "Add and update comments in ui/build/upload.go" 2020-11-30 22:01:38 +00:00
Treehugger Robot
b21906cd70 Merge "Minor cleanup of environment.go." 2020-11-25 03:28:33 +00:00
Rupert Shuttleworth
1f304e674d Minor cleanup of cleanbuild.go (and partially build.go).
Test: TH presubmit.
Change-Id: I439c16687b1877d367ff3d0f27e30c9bac97ef58
2020-11-24 14:50:25 +00:00
Rupert Shuttleworth
80115fa6b0 Minor cleanup of environment.go.
Test: TH presubmit.
Change-Id: I89415d6b1219d2204b4fcce4b3a7456250cd0967
2020-11-24 13:16:30 +00:00
Jingwen Chen
cda22c9bb9 Refactor 'in_make' to mean Kati is not skipped.
In Nougat and before, Make wrote a marker file to indicate that
soong_build was invoked from Make to change certain behaviors of Soong
at build time.
https://cs.android.com/android/platform/superproject/+/android-7.1.2_r36:build/core/soong.mk;l=70-73;drc=ae18638b0406ad107b0882a02a13cdd8b92f2a4e

Things have changed, and now soong_build is invoked from soong_ui, which
supports a --skip-make configuration flag:
https://cs.android.com/android/platform/superproject/+/master:build/soong/ui/build/build.go;l=31-33;drc=680387bf1d3ce7cbc77f535be7c42cec411b1687

Thus, the various remnants of 'EmbeddedInMake' and 'inMake'
configuration are misleading, since soong_build is no longer invoked
from Make. This CL refactors all instances to actually mean that
Kati is enabled (not skipped with --skip-make), and will run after
soong_build finishes, so Kati-specific behavior like the AndroidMk
singleton should run.

Test: TH presubmit

Change-Id: I576ab8e54f99f5c8ddf9feaf9a828019b279e266
2020-11-23 00:29:18 -05:00
Treehugger Robot
5898d56912 Merge "soong_ui ninja.go: comment and refactor." 2020-11-22 20:15:46 +00:00
Jingwen Chen
9d1cb491c3 soong_ui ninja.go: comment and refactor.
On top of improving the comments, I also refactored the status checker
to simplify and clarify its use case to be a ninja stuckness checker,
since it doesn't appear to have other purposes.

Test: TH presubmit
Bug: b/173474588
Change-Id: I2cf51a1ebf16071a24a1c13c06c7b1adf60256de
2020-11-21 07:37:28 -05:00
Jingwen Chen
55e0022fc0 Merge "soong_ui path.go: improve comments." 2020-11-20 04:47:51 +00:00
Jingwen Chen
19362b16c3 Merge "soong_ui kati.go: write more comments." 2020-11-20 04:46:18 +00:00
Jingwen Chen
b1d30d63c5 soong_ui kati.go: write more comments.
This CL also removes --warn_real_to_phony and --warn_phony_looks_real,
since --werror_real_to_phony and --wrror_phony_looks_real are already
specified.

Test: treehugger
Bug: 173474588

Change-Id: Icbb0f53182d1b912c62f8044f52bb79d985bf868
2020-11-18 22:16:08 -05:00
Jingwen Chen
6a9bfa122a soong_ui path.go: improve comments.
Test: th presubmit
Bug: 173587901
Change-Id: Ic30fa88ee84cbc48860a7500223432c720039810
2020-11-18 22:13:23 -05:00
Jingwen Chen
db892410f7 Merge "soong_ui finder.go: improve comments/documentation." 2020-11-18 07:53:56 +00:00
Jingwen Chen
27a8719b0f Merge "Integrate bazelenv.sh environment variables into soong_ui environment." 2020-11-18 04:53:22 +00:00
Jingwen Chen
096a3bf08f soong_ui finder.go: improve comments/documentation.
Test: m
Bug: 173474588
Change-Id: I947a34b3d9a5b2cd36fba293b55860a20a11d40b
2020-11-17 19:48:31 -05:00
Jingwen Chen
7c6089ad95 Integrate bazelenv.sh environment variables into soong_ui environment.
This removes the need to source bazelenv.sh for USE_BAZEL_ANALYSIS, and
unifies mixed builds to use the checked in tools/bazel and bazelrc.

It also unifies all bazel-related output to be in out/bazel.

Without aosp/1502095, this change still requires toplevel_output_directories to be an empty
list, otherwise there'll be this error:

ERROR: Directories specified with toplevel_output_directories should be
ignored and can not be used as sources.

Test: With aosp/1441774: rm -rf out/ && lunch aosp_cf_x86_auto && USE_BAZEL_ANALYSIS=1 m libc && prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-aosp_cf_x86_auto.ninja -t commands libc | grep bazel-out | wc -l # 2 results
Change-Id: I69b217ec88da531415792bb6e04b6a194ca4718d
2020-11-17 18:58:03 -05:00
Jingwen Chen
7a5391a979 soong_ui's bazel.go: document/comment with tiny refactoring.
This patch adds information behind the Bazel USE_BAZEL=1 execution
pipeline.

Test: m
Bug: 173474588
Change-Id: I54bdd26fb14c8a371de0922d193419112e8c3ece
2020-11-17 03:46:23 -05:00
Patrice Arruda
92dc64f9c8 Add and update comments in ui/build/upload.go
Bug: b/172918852
Test: go test .
Change-Id: I63ca307e3935fc5a91a550889601397300ba395e
2020-11-16 16:29:16 -08:00
Jingwen Chen
3a4b58dc5d Set PATH and --action_env=PATH for the Bazel build in soong_ui.
Ensures that Bazel and Ninja are using the same binaries from PATH, such
as `sort` from the linked bug.

Test: USE_BAZEL=1 m
Test: rm out/soong/apex/depsinfo/new-allowed-deps.txt && USE_BAZEL=1 m
Bug: 161074854
Fixes: 161074854
Change-Id: Icc3e717e6d3cfcecfe90f0fb3a94a86485a11918
2020-11-16 04:47:14 -05:00
Patrice Arruda
33e7f6a0ca Remove unnecessary break and default statements in metrics.go file.
break and default statements are not needed inside of a switch
statement.

Bug: b/173028918
Test: USE_BAZEL m nothing
Change-Id: I14aa8cbae3a9b3c859f147c5134600f1e75c6a89
2020-11-13 13:15:09 -08:00
Patrice Arruda
b7cf9ba175 Add tracer to runBazel function.
Added a tracer named "bazel" in runBazel function to capture topline
metrics when running bazel.

Bug: b/173028918
Test: * USE_BAZEL=1 m nothing and checked soong_metrics file using
        printproto command to verify that bazel topline metrics
	were captured.
Change-Id: I5cb0728a4da48545dc701cc79627c318d5d9a29d
2020-11-13 13:14:51 -08:00
Patrice Arruda
18cb70d645 Enable bazel metrics from ninja build.
Generate the bazel profile file that contains the metrics of
executing the ninja build phase of Soong.

Bug: b/173028918
Test: * m nothing and check out dir that there is no bazel_metrics dir.
      * USE_BAZEL=1 m nothing and checked
        out/bazel_metrics/build_bazel_profile.gz existed.
      * m nothing and checked out/bazel_metrics does not exist.
Change-Id: I797d1eecf5c2c260ade8b55dc69c237bfd0fcbd4
2020-11-13 11:37:06 -08:00
Patrice Arruda
af880da0c4 Define the bazel_metrics directory in $OUT.
$OUT/bazel_metrics directory is created in order to dump the
set of bazel profile files being created from a single build
execution. The directory is created from soong_ui.

Bug: b/173028918
Test: * m nothing and check out dir that there is no bazel_metrics dir.
      * USE_BAZEL=1 and checked out/bazel_metrics was created.
      * Ran m nothing and verified that out/bazel_metrics directory is
        deleted to ensure no metrics is uploaded or collected from the
	pipeline.

Change-Id: I1d3c2471065fae6931f35cef7f0f35fd84f76bef
2020-11-13 11:16:21 -08:00
Patrice Arruda
0c1c456643 Define UseBazel in Config
The UseBazel() function will be used in several places to perform
different functionality such as setting up the metrics path.

Bug: b/173028918
Test: m nothing
Change-Id: Ie94073b8f0552ec7528e1cc2f3be74b693dc3135
2020-11-13 11:16:21 -08:00
Jingwen Chen
a26ac3caee Export Ninja file paths to lunch repo rule from bazel.go
This ensures that the lunch repo rule always reads the right Ninja file.

Test: USE_BAZEL=1 m
Test: m

Change-Id: I7f670dd538f46c4dae5ea537b857ff04520b60e7
2020-11-12 08:01:33 +00:00
Rupert Shuttleworth
f8ae317d3e Allow extra startup and build args to be passed to Bazel.
For example: USE_BAZEL=1 BAZEL_STARTUP_ARGS="--batch" m

Test: Manually.
Change-Id: I76fa8e17d4a9ccb8dda9fca049113f434dacabbe
2020-11-10 02:06:30 +00:00
Jingwen Chen
8024c95ecc Add TODO bug number to stop hardcoding 'droid'
Test: N/A
Signed-off-by: Jingwen Chen <jingwen@google.com>
Change-Id: I0d60cc4254b3a358085d89e443bd3bfc33b68ed3
2020-11-09 07:03:56 +00:00
Patrice Arruda
bb42c44e71 Merge "Collect useful resource information of each executed process in soong_ui." 2020-11-05 17:17:43 +00:00
Christopher Parsons
fde53fff96 Merge "After bazel execution, symlink results in out/" 2020-11-05 14:54:47 +00:00
Jingwen Chen
70b7eeed1c Move hardcoded bazel flags from soong_ui to common.bazelrc.
Test: USE_BAZEL=1 m
Signed-off-by: Jingwen Chen <jingwen@google.com>
Change-Id: Ib675dba8bfaf615bf3752a4bb4531b818526f267
2020-11-05 03:31:28 -05:00
Chris Parsons
c09495bf96 After bazel execution, symlink results in out/
This ensures that USE_BAZEL=1 mode has the same directory structure
under out/ as it does without USE_BAZEL=1.

Test: Manually verified building USE_BAZEL=1 aosp_flame with droid and
libc

Change-Id: I27e810772d1bf04bd7930ea122217b93d2fd48b4
2020-11-04 20:56:14 -05:00
Patrice Arruda
ca221f3e6d Collect useful resource information of each executed process in soong_ui.
Collect the resource information of each executed process in soong_ui
for metrics analysis.

Bug: b/169453825
Test: m nothing; "lunch 1" && m
Change-Id: I8c7fe019111921c4c59174d133b85439ec825885
2020-11-04 23:35:43 +00:00
Jingwen Chen
ebb0b574c8 Add dependency on dexpreopt.config to soong_build doc generation.
This was caught while running the soong_build docs action under Bazel as
ninja executor. Since the config file is not an explicit input to the
action, it's not present in Bazel's execution root during action
execution time, leading to a missing file error. To fix it, add the file
as an input to the action, if it's configured in product variables.

New soong_build statement:

build out/soong/docs/soong_build.html: s.writedocs.soongDocs $
        out/.module_paths/Android.bp.list out/soong/soong.variables $
        out/soong/dexpreopt.config | out/soong/.bootstrap/bin/soong_build
    outDir = out/soong/docs

Test: m
Test: USE_BAZEL=1 m
Bug: 161958189
Fixes: 161958189
Change-Id: I2bf264e848bb29ac91f4196fbe9c4ecf3cea8a2c
2020-11-04 01:51:40 -05:00
Treehugger Robot
d3e294d8ac Merge "Add --skip-soong-tests argument to soong_ui and use it in multiproduct_kati" 2020-11-02 21:31:31 +00:00
Colin Cross
00a8a3f746 Add --skip-soong-tests argument to soong_ui and use it in multiproduct_kati
There is no need for multiproduct_kati to run the tests for
every product, they don't vary by product config. --skip-soong-tests
can also be used for local development to run soong_build even if
the tests don't pass.

Bug: 156428456
Test: m --skip-soong-tests nothing
Change-Id: I9c00e3d1b6e51d17bb290339c3f124d4d1c9e69f
2020-10-29 14:22:04 -07:00
Patrice Arruda
e92c30dff1 Capture the build command that executed the build system.
We need to capture the user build command to understand what additional
arguments is passed in to Soong. This data is useful to know which
targets are being executed and have statistics on top build targets
are specified.

Bug: b/169453712
Test: ran "m blueprint_tools", "m nothing", "lunch 1" and checked
      in soong_metrics proto.
Change-Id: I7ab94dcf037211f1abffe6afd012b03ffbf99756
2020-10-29 11:01:32 -07:00
Rupert Shuttleworth
680387bf1d Add code to enable USE_BAZEL=1 m functionality in AOSP.
Test: Manually, but builds currently fail due to a recent change to bazel_handler.go.
Change-Id: I9a45a2c73d1755032b11f6b913c03f83a28f63c5
2020-10-26 09:23:24 +00:00
Treehugger Robot
78386129c0 Merge "Add stats from ninja subprocesses to build.trace.gz" 2020-10-21 22:52:24 +00:00
Treehugger Robot
0aedb1efe1 Merge changes I65a78260,I4b3cbbc3
* changes:
  Rename time to event in Soong metrics system.
  Add resource usage metrics in Soong metrics.proto.
2020-10-21 20:03:04 +00:00
Patrice Arruda
457c5d3426 Rename time to event in Soong metrics system.
Several structs and files are named time which records the total
execution of a traceable event. Soon, resource information of an
executed process is collected during a build event so a more generic
name is applied.

Bug: b/169453825
Test: go test and m nothing. Checked the soong_metrics protobuf.
Change-Id: I65a782603530d51018d6cc1192c18cfeef7566a0
2020-10-21 08:54:56 -07:00
Patrice Arruda
fec3bf2e2c Add resource usage metrics in Soong metrics.proto.
We would like to collect the resource usage of processes such as
kati, soong_build and ninja on the resource usage such as memory
and context switching. This changelist contains the defined fields
in the protobuf file of the resource information to be collected
from interested processes.

Bug: b/169453825
Test: N/A
Change-Id: I4b3cbbc3e7b78900875c10d34d574425f8b11730
2020-10-21 08:54:42 -07:00
Jingwen Chen
17958198a6 Merge "Add symlink_outputs support to Soong." 2020-10-21 08:59:16 +00:00
Treehugger Robot
d9052d177c Merge "Deprecate both USE_GOMA and FORCE_USE_GOMA flags" 2020-10-20 03:21:59 +00:00
Kousik Kumar
b328f6dc85 Deprecate both USE_GOMA and FORCE_USE_GOMA flags
Test:
m USE_GOMA=true GOMA_DIR=$(goma_ctl goma_dir) toybox
m FORCE_USE_GOMA=true GOMA_DIR=$(goma_ctl goma_dir) toybox
both result in error message being printed.

Change-Id: I94ccaf217dba71aca990d88d205bad669a49a2f5
2020-10-19 01:48:23 -04:00
Jingwen Chen
ce679d29ec Add symlink_outputs support to Soong.
This CL adds symlink_outputs to various locations in Soong that creates
actions that creates symlink outputs, and explicitly mark them as such.

Test: m
Bug: 160568334
Change-Id: I322751bada52a9f49011c74731d84761586e03e7
2020-10-19 01:26:50 -04:00
Colin Cross
d888b6b4fc Add stats from ninja subprocesses to build.trace.gz
Propagate the subprocess stats from ninja to build.trace.gz.

There is too much data here to put into separate counters for each
statistic, so put them into args on each duration event for now.

We would like to track max RSS for each subprocess, but the Linux
kernel inherits the max RSS of the ninja process in each subprocess,
which sets a lower bound on the measurable max RSS to the size of
the ninja process.  The ninja process is large due to the multi-GB
build.ninja files.

Bug: 170701554
Test: examine build.trace.gz
Change-Id: I8aaaafe627a57f1a500af098c097c6381c583ba5
2020-10-15 13:46:32 -07:00
Treehugger Robot
a9a427615b Merge "Add odm_dlkm and vendor_dlkm to the installclean list" 2020-10-14 21:37:19 +00:00