Commit Graph

42 Commits

Author SHA1 Message Date
qctecmdr
ce5f273c26 Merge "ANDROID: build: Remove test_mapping definitions" 2023-08-10 13:43:29 -07:00
John Moon
80a7dcb709 ANDROID: build: Build host and device targets together
Currently, we build host and device targets separately because we
must pass a different config option to each (--config=android_arm64
for device targets and --config=hermetic_cc, the default, for host
targets).

With a transition to using android_filegroup for device targets, we
can obviate away the need for building separately.

Collapse the host and device targets into one build command.

Change-Id: Ib6bbb0ecaa7098f5ef39b88544e8be4463e7979e
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-27 15:26:00 -07:00
John Moon
ba5bcd697e ANDROID: build: Drop --config=stamp
Currently, --config=stamp appears to be causing issues when
traversing git history in some large repos.

To work around this, drop --config=stamp from the command line
options.

Change-Id: I561c5175de620984df0b130b9bd1b7958aa883c1
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-27 14:10:05 -07:00
John Moon
463dfbb7e8 ANDROID: build: Remove test_mapping definitions
Kleaf test_mapping rules are no longer used upstream and were being
skipped in our builds anyway.

Remove the test_mapping rules.

Change-Id: If8689f4572b1d1dce2c8ba03075444fa3af7d86b
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-27 09:25:18 -07:00
qctecmdr
736a29eaf3 Merge "ANDROID: build: Fix menuconfig invocation" 2023-07-26 04:10:54 -07:00
John Moon
c38cee9986 ANDROID: build: Fix output directory layout
With a recent change to the output directory handling from
build_with_bazel.py, some dist directory paths incorrectly used
hyphens instead of underscores.

Fix this issue by mirroring the logic in msm_common.bzl which handles
these paths properly.

Also, run buildifier to fix format of Bazel build files.

Change-Id: Ia82073f059c54f4a7f523c5bd91afdc755c70df1
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-22 20:40:11 -07:00
Guru Das Srinagesh
8b7b9a3b48 ANDROID: build: Fix menuconfig invocation
Commit 02faddf96a ("ANDROID: build: Add build_opts.txt file to
output") changed the way targets are specified. This broke the
menuconfig invocation, so fix it.

Change-Id: I23610538d1dafe1f80acccfb13684819d27ee25e
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
2023-07-21 18:07:41 -07:00
John Moon
02faddf96a ANDROID: build: Add build_opts.txt file to output
Currently, there's no convenient way to discover which build options
were passed to the kernel build other than examining the output
.config file. That method is somewhat fragile as the mapping between
the CONFIG options we're parsing and the options being set by a
particular build flag could change.

Instead, let's create a new build artifact which writes the build
flags to a file which can be easily consumed later. This will allow
external module (DDK) builds to guarantee a match between the kernel
build and their build.

The output format looks like this (one opt per line):

--kasan
--lto=none
--config=stamp
--user_kmi_symbol_lists=//msm-kernel:android/abi_gki_aarch64_qcom
--ignore_missing_projects

The flags can be pulled into a separate build command line like this:

./tools/bazel build $(xargs -a build_opts.txt) //my_package:my_target

Change-Id: I162c950ff01c99e082945190b50d13b4a139f944
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-18 14:43:22 -07:00
John Moon
87e617465b ANDROID: build: Add --dry-run flag to build_with_bazel.py
Currently, you can run analysis of the Bazel build by passing
--nobuild to the raw Bazel commands, but there's no way to perform
the analysis via the normal build script.

Add a --dry-run command which performs loading and analysis of the
Bazel build but does not actually perform compilation. This is useful
for validating BUILD files and detecting errors in the inputs.

Change-Id: Iec9c1d861dacbe5cd68b648620945f91e966cb89
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-11 21:09:55 -07:00
John Moon
9986dc208d ANDROID: build: Ignore missing repo projects
Currently, the workspace_status_stamp.py script will perform various
operations on all projects defined in the repo manifest.

In some cases, the project directories may not be present. When this
happens, the build currently fails.

A flag was added upstream to ignore missing project directories. Pass
this flag, --ignore_missing_projects, by default.

Change-Id: I38828d2fb16cc64e4b356575429ae78bf1752396
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-06 11:25:45 -07:00
John Moon
afe3c6b09f ANDROID: build: Add msm-kernel user KMI symbol list to build
Currently, if there are any symbols added to
msm-kernel/android/abi_gki_aarch64_qcom, they are not considered when
updating the msm-kernel ABI or when checking the ABI compatibility.

To address this, we added a new flag upstream which allows us to
specify a user KMI list.

Pass this flag by default.

Change-Id: I98ccf20263898c1b00bf73c643015cf96559f568
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-07-06 11:14:39 -07:00
John Moon
2091e7e0a5 ANDROID: build: remove extraneous --config=hermetic_cc
Currently, we pass --config=hermetic_cc to Bazel when building host
targets. With a recent upstream update, this was made the default.

Now, when building, we see this warning:

WARNING: The following configs were expanded more than once: [hermetic_cc].
For repeatable flags, repeats are counted twice and may lead to unexpected behavior.

Remove the warning by simply not passing --config=hermetic_cc.

Change-Id: I09cc008113a7f1ba797a42770f6fa27eb2b1f41c
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-06-22 15:16:13 -07:00
jianzhou
00ba33c673 Revert "ANDROID: build: Add copy of symbol list file to common directory"
This reverts commit 1da282c5e2.

Change-Id: Ic2225089a4e3b1280376141b1670e7645b649ea8
Signed-off-by: jianzhou <quic_jianzhou@quicinc.com>
2023-04-25 22:44:30 -07:00
Guru Das Srinagesh
5106eabcb8 build_with_bazel: Add useropt "--config=stamp"
Add user option "--config=stamp" for all builds. This embeds the string
"g<SHA>" in the Linux banner/version string which is required for VINTF
GKI compliance tests.

Heads-up: This is known to increase incremental build times.

Change-Id: I2345ee9bbc442fe097222f6d991e18886b6e5124
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
2023-04-25 22:43:19 -07:00
John Moon
816738a684 ANDROID: build: Use hermetic toolchain for userspace apps
Currently, the build_with_bazel.py script will query Bazel for
compatible cross-toolchains for use when building userspace apps
which target the device. When building userspace apps for the host,
the build will use whatever compiler is detected on the host.

Now that Kleaf supports using the hermetic toolchain for userspace,
we no longer need to support using an external one. Instead, we can
pass "--config=android_arm64" when building a cross target and
"--config=hermetic_cc" when building a host target.

Update the script to use the hermetic toolchain in both cases.

Change-Id: Iec997dc3cc0d3e9f6242c4754ac858f8a6e7e452
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-03-27 14:06:56 -07:00
Guru Das Srinagesh
db906bd1ec Revert "build_with_bazel: Add useropt "--config=stamp""
This reverts commit 30238f4585 to prevent
the version string arising from consolidate builds from falling afoul of
the 64-character string length limit:

"6.1.15-mainline-qki-consolidate-android14-1-00690-ge2d158dd0514-dirty" exceeds 64 characters

This change will be re-landed when the config file required for VINTF
checks makes it downstream as it is required for those tests to pass.

Change-Id: I2408f37eb16cdd00a06b9c5eaceac1c3cb53f06a
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
2023-03-21 14:01:18 -07:00
John Moon
1da282c5e2 ANDROID: build: Add copy of symbol list file to common directory
Currently, there's no way for our mixed build to use a custom ABI
definition.

To allow this capability, copy the symbol list file to the ACK tree
prior to launching build which will be used to generate ABI definition.

Change-Id: I14067e05da2ab7ec29a1425d6dd311940b671aca
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
Signed-off-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com>
2023-03-17 19:58:50 -07:00
qctecmdr
888ef98cc5 Merge "build_with_bazel: Add menuconfig option" 2023-03-13 15:13:42 -07:00
qctecmdr
fae0dc7172 Merge "build_with_bazel: Add useropt "--config=stamp"" 2023-03-09 12:00:42 -08:00
Guru Das Srinagesh
ebb8377efd build_with_bazel: Add menuconfig option
Enable support for running menuconfig for a given target-variant combo.

Also make the core bazel function accept `bazel_target_opts` which pass
options to the bazel target via "-- <options>".

Change-Id: I4f8c108e553fe748b2709398cc4253b0d2260289
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
2023-03-08 23:25:53 -08:00
Guru Das Srinagesh
30238f4585 build_with_bazel: Add useropt "--config=stamp"
Add user option "--config=stamp" for all builds. This embeds the string
"android14-0" in the Linux banner/version string which is required for
VINTF GKI compliance tests.

Heads-up: This is known to increase incremental build times.

Change-Id: I8ee627830cda8a9a006a166b56a02621fa2ccff3
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
2023-03-08 16:43:04 -08:00
qctecmdr
ac0b09bd61 Merge "Revert "build_with_bazel: Add menuconfig option"" 2023-03-07 19:56:15 -08:00
Maria Yu
07c2a770b2 Revert "build_with_bazel: Add menuconfig option"
This reverts commit 6beedeabcc.
Currently the change cause a vendor build error. And menuconfig
is not yet can be verified due to lack of kernel/build changes.

Change-Id: I4afa7350aae5a9ce8b1a82ac7859f38c4ebe7458
Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>
2023-03-07 17:14:28 +08:00
qctecmdr
eff031af48 Merge "ANDROID: build: Clean up a wider array of legacy files" 2023-03-06 14:27:59 -08:00
John Moon
b4dfaf0b9d ANDROID: build: Clean up a wider array of legacy files
Currently, some legacy build files still exist in the source tree
after a legacy build.sh build. This results in errors like this:

cp: msm-kernel/arch/arm64/configs/vendor/pineapple_tuivm_defconfig: Read-only file system

Expand the pattern match for these files to include target/variant
names that do not have a "-" in them.

Change-Id: I3bc87f321f4f29db7fe77fab884c8d2b46086370
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-03-02 14:58:11 -08:00
Guru Das Srinagesh
6beedeabcc build_with_bazel: Add menuconfig option
Enable support for running menuconfig for a given target-variant combo.

Change-Id: Icf20e4a5826dcd99d75da009f132d0cad5e6296b
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
2023-03-02 10:48:40 -08:00
qctecmdr
4953bd1896 Merge "ANDROID: build: Guarantee dist directory output order" 2023-01-23 16:45:13 -08:00
John Moon
9abecb5d93 ANDROID: build: Add skip flags to Bazel for easier source selection
Currently, there's no way to select sources from Bazel extension
hooks based on projects being skipped.

Add Bazel config_settings to allow users to configure build sources
via command line flags. Automatically provide these flags when
building with build_with_bazel.py.

Change-Id: Ifecb58443b14dfd666b6407725fd3a4c287bae05
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-01-20 15:05:25 -08:00
John Moon
52ff694d7c ANDROID: build: Guarantee dist directory output order
Currently, the base kernel_build rule which outputs artifacts to
"out/msm-kernel-$target-$variant/dist" removes the destination
directory prior to copying build outputs. The ABL build rule also
copies files to that directory, but does not remove the directory
first.

The build_with_bazel.py script queries build rules available for the
current target/variant combo and the returned list does not have any
specific ordering. This leads to the possibility that the ABL dist
rule is run prior to the base kernel_build rule. In that case, the
ABL build outputs are removed and the kernel_build outputs replace
it.

Fix this issue by sorting the build targets based on name length.
This will guarantee that the shortest rule name (the base
kernel_build rule) will be executed first. With that, other build
outputs being copied to that directory will no longer be clobbered.

Change-Id: I8cdbba6c9636d9aab4f801db3d407f0c71a1790c
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-01-18 10:23:25 -08:00
John Moon
8bb27db561 ANDROID: build: Clean up legacy generated files
The legacy build.sh build generates some files in source directories
which cause problems for Bazel. If a user has run a legacy build,
then tries to run a Bazel build, they will encounter an error. The
error occurs because Bazel (by design) cannot overwrite source files.

To avoid these errors, clean up these generated files prior to
starting the Bazel build.

Change-Id: Id2ea294b45588b56418063a1db95c13c71fed617
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2023-01-11 11:51:28 -08:00
qctecmdr
f352f75564 Merge "ANDROID: build: Forbid empty targets/variants" 2023-01-06 18:36:25 -08:00
John Moon
945548ce97 ANDROID: build: Forbid empty targets/variants
Currently, if a user runs ./build_with_bazel.py -t foo "", which
occurs when an empty variable is passed in, the build script will
match targets incorrectly.

Disallow this behavior and force users to pass in a non-empty string
for both the target and variant.

Change-Id: I767486ab6deb88f84e171a0811134c80e003babc
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-12-20 17:24:22 -08:00
John Moon
139e408949 ANDROID: build: Decoding byte strings properly
Currently, build_with_bazel.py will break when run with Python 3 due
to differences in the way Python 2 and 3 encode string types.

Explicitly decode command outputs to utf-8 strings which works
properly for both Python versions.

Change-Id: I921bd591ce16b5b91c76a6bb2a5d0e8626c29c19
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-12-20 17:21:34 -08:00
qctecmdr
705d77d8eb Merge "build: Add --out_dir argument to build_with_bazel.py" 2022-11-30 19:21:16 -08:00
John Moon
4c016f8d92 build: Add --out_dir argument to build_with_bazel.py
Currently, there's no way for a user to specify a custom output
directory when using build_with_bazel.py.

Add a command line argument to allow such usage (similar to the
OUT_DIR environment variable from build.sh).

Change-Id: I44f720c85409fc8ec82a9f4a96d428fab80a7547
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-11-30 17:47:02 -08:00
qctecmdr
69ba5ed381 Merge "build: Fix OSError exception" 2022-11-30 17:33:43 -08:00
John Moon
20ed5f73a6 build: Add logic to use default extensions if none are found
Currently, the Bazel build may fail if symlinks to the Bazel
extension files are not linked to the proper locations.

To make sure the build always works (falling back on default
extensions), configure the script to create the symlinks to the
default files in case they don't exist or are broken symlinks.

Change-Id: Ie385e4ede912d0f40026ef6c78a9c2fb60ca8924
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-11-29 14:11:58 -08:00
John Moon
1a0df71fe8 build: Fix OSError exception
When the Bazel subprocess exits unexpectedly, the wrapper script
gets an OSError exception while cleaning up the processes.

Ignore the OSError exception to make sure all subprocesses are
cleaned up properly.

Change-Id: I7c1062a900e70cfc2d90bd9695254ba80b07721b
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-11-28 13:39:02 -08:00
John Moon
c45c4b798b build: Refactor build_with_bazel.py to discover targets
Currently, the build_with_bazel.py script has an internal list
of targets. As we add/subtract targets, this becomes more difficult
to maintain. It also makes adding extra targets defined by
msm_kernel_extensions.bzl a manual process.

Instead, query the Bazel DAG to dynamically determine the
build targets based on input target name.

Change-Id: Id39889260b8f8af5c0c157ff091ee6e0d253c90f
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-11-14 15:59:51 -08:00
John Moon
8503690aa2 build: Add support for Bazel VM builds
Currently, only legacy build.sh support exists for VM
builds.

Add Bazel support for these builds.

Change-Id: I10b221aa4a6633240b984eff333e15f5cd8b82cd
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-11-14 15:05:22 -08:00
John Moon
8e5c9866a0 build: Add support for custom userspace toolchain
When using build_with_bazel.py, users may want to build extra
userspace cc_binary targets with a different toolchain.

Enable this capability by adding the --userspace_cross_toolchain
option.

Change-Id: I9eaaaa71ba483132fb68124e713a05d2918f9aa1
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-10-27 14:54:31 -07:00
John Moon
473718d3d8 build: Add build_with_bazel.py
The raw Bazel build/run commands are difficult to parse
and users could easily miss building something.

To help improve the UX and efficiency of the build
across platforms/variants, let's add a top-level script
for the kernel platform build.

Change-Id: I16dfad6c90acc882123f6129c1bd02cb3d2131fc
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-10-20 12:01:13 -07:00