Commit graph

995 commits

Author SHA1 Message Date
Mark Dacek
e0b6329384 Merge "Revert "Revert "Modify symlink_forest to rerun when soong_build has changed.""" into main 2023-10-06 17:34:47 +00:00
Christopher Parsons
f7fe400fbc Merge "Dont write data attrs for cc lib rules" into main 2023-10-06 14:09:07 +00:00
Zi Wang
b0f3ff43e5 Merge "Add support for java_library proto plugin in bp2build" into main 2023-10-05 22:32:53 +00:00
Chris Parsons
7123cc5370 Dont write data attrs for cc lib rules
The data attributes for cc library rules is dropped by their starlark
macros, so serves no real purpose. Furthermore, this unused dependency
proves problematic for allowlist v2, as there are many cases at HEAD
where the corner-case "requires" dependency would otherwise mark a module
as unconvertible.

Fixes: 303307456
Test: New unit test
Test: Manual verification to unblock allowlist v2 `bp2build.sh` runs in
AOSP

Change-Id: I6ca6104b958d2b428fc2ca5b3fa794106571acca
2023-10-05 22:07:28 +00:00
Zi Wang
dbaf6a9dd0 Add support for java_library proto plugin in bp2build
Test: Added unit test and CI

Bug: 303064670
Change-Id: Idb96ac322aafcb6789ea2002b84a6905d5ec488f
2023-10-05 12:53:23 -07:00
Chris Parsons
d078337796 Test changes to prepare for allowlist v2
This implements a number of in-place unit test changes to prepare for
some fundamental changes to bp2build ("allowlist v2"). This will change
bp2build so that rdeps of unconverted or missing modules will not be
converted by bp2build.

Bug: 301312260
Test: Unit tests
Test: Unit tests, with a local copy of allowlist v2 on
Change-Id: I8c8c0a24ba173e213fffcb0f8d7e99845705f4a7
2023-10-05 17:51:44 +00:00
Mark Dacek
b2441c52a4 Revert "Revert "Modify symlink_forest to rerun when soong_build has changed.""
This reverts commit aa5cc2cd6a.

Reason for revert: Fixed the bug in the original draft.
There was an error in how we compared the file's MTime to the
file's contents.

Bug: 300288299
Test: presubmits
Test: build/soong/tests/run_integration_tests.sh

Change-Id: I9e53432c0842c0b9fc13fe20d30ce9af37640c7f
2023-10-05 17:11:50 +00:00
Spandan Das
ee557e4c69 Merge "Create bp2build converter for versioned_ndk_headers" into main 2023-10-05 02:00:55 +00:00
Christopher Parsons
29c559b785 Merge "create, but dont register, bp2build_deps mutator" into main 2023-10-04 21:38:49 +00:00
Treehugger Robot
e88fe1fb92 Merge "Expand regex for likely aidl filegroups" into main 2023-10-04 21:11:18 +00:00
Mark Dacek
4ac292ffd8 Merge "Revert "Modify symlink_forest to rerun when soong_build has changed."" into main 2023-10-03 18:39:46 +00:00
Yu Liu
7a90fcfa45 Merge "Convert java_aconfig_library to bazel." into main 2023-10-03 17:29:26 +00:00
Chris Parsons
5f1b3c7ad8 create, but dont register, bp2build_deps mutator
This is the bulk of the "allowlist v2" feature. It will disable bp2build
generation for modules which have transitive dependencies without a
bazel build definition.

This CL includes this mutator, but doesn't register it as a bp2build
mutator (outside of a few unit tests). This allows us to easily iterate
on completion of this feature and ensure there are no launch blockers
before we finalize the change in AOSP.

Bug: 285631638
Test: Unit tests
Change-Id: Ifb0a079c409ca19b02cafa3fab2efa0d3deebc50
2023-10-03 00:16:30 +00:00
Mark Dacek
aa5cc2cd6a Revert "Modify symlink_forest to rerun when soong_build has changed."
This reverts commit 23a4120c57.

Reason for revert: broke soong_integration

Change-Id: I4d51841756675b3745244d23e13aefda0916614b
2023-10-02 23:40:33 +00:00
Yu Liu
f2b94010c8 Convert java_aconfig_library to bazel.
Bug: 297357579
Test: Unit test and AconfigJavaHostTest
Change-Id: Icf944cc0b2a7382107923d49b2d2ff0eb4113638
2023-10-02 15:04:19 -07:00
Spandan Das
a7da3f0e0b Create bp2build converter for versioned_ndk_headers
This module type is used by a single soong module - `common_libc` in
bionic/libc

Implementation details
- Convert this module type to ndk_headers rule. Bazel's ndk_headers rule
  will have a boolean attribute `run_versioner` to determine if
  verioner should be run on the headers
- Add this module type to the alwaysConvert bp2build list
- Add the converted target for `common_libc` to the deps of
  `ndk_sysroot`. This ensures that unbundled apps link against the
  versioned NDK headers of libc

Test: go test ./bp2build
Test: b build //bionic/libc:common_libc --config=android
Test: for f in $(find bazel-bin/bionic/libc/common_libc.versioned -type f); do cmp $f ${f/bazel-bin\/bionic\/libc\/common_libc.versioned/out\/soong\/ndk\/sysroot\/usr\/include}; done # no diff

Bug: 301169067

Change-Id: I55be202f0589db9bdc743c8be41c9c5afd74c352
2023-10-02 17:35:55 +00:00
Christopher Parsons
aa3e435857 Merge "Treat src=name filegroups as handcrafted targets" into main 2023-10-02 17:35:44 +00:00
Mark Dacek
e20b7589b4 Merge "Modify symlink_forest to rerun when soong_build has changed." into main 2023-10-02 15:36:43 +00:00
MarkDacek
23a4120c57 Modify symlink_forest to rerun when soong_build has changed.
Also remove existing symlink_forest_version functionality.

This remedies issues pertaining to b/300122962 - symlinks not
clearing after a revert

Timing wise - this doesn't present a performance regression
on a clean build. When soong_build changes, it's considerably longer
but no different from the time when symlink_forest_version is changed.

Bug: 300288299
Test: build/soong/tests/symlink_forest_rerun_test.sh
Change-Id: I0e95aac315dfea7ea3b8bb9a3eb0c6408300bd3b
2023-09-29 22:53:07 +00:00
Liz Kammer
79ff08f12c Expand regex for likely aidl filegroups
Test: go test soong tests
Change-Id: Iab7abea8e2d11583cb4a8ecd4b27368f61dd40e0
2023-09-29 12:38:42 -04:00
Chris Parsons
2ef472be7a Treat src=name filegroups as handcrafted targets
This is groundwork for allowlist v2, as such targets are still
effectively referencable via their file syntax; thus, rdep targets of
these filegroups should still be treated as convertible.

Fixes: 302025822
Test: Unit test update
Change-Id: I93445ff75e7c0570530725d086e47c1532833c06
2023-09-28 23:07:00 +00:00
Christopher Parsons
dec9ce6693 Merge "support aidl bp2build changes" into main 2023-09-28 20:19:43 +00:00
Christopher Parsons
e3f7a0d4d6 Merge "Update bp2build tests to use stubbed defs" into main 2023-09-28 17:23:50 +00:00
Cole Faust
6ed1e0fd59 Merge "AVB and selinux support in partitions" into main 2023-09-28 16:38:28 +00:00
Zi Wang
2201343fce Merge "Always drop deps from android_library with no srcs" into main 2023-09-28 16:16:51 +00:00
Treehugger Robot
f51ed265e4 Merge "Make platform_mappings file deterministic" into main 2023-09-28 00:37:51 +00:00
Chris Parsons
8a532b78e5 Update bp2build tests to use stubbed defs
bp2build tests should not use bp2build_available:false test deps,
because, with the "allowlist v2" feature, this will cause these modules
to stop being converted with bp2build. Instead, such test deps should be
"stubbed", which effectively treats them like targets in pre-existing
BUILD files on the filesystem.

Bug: 301312260
Test: m nothing
Change-Id: Ib1ce7c87cd1e98568fdaf2a52a893dafa74ab327
2023-09-27 23:11:26 +00:00
Chris Parsons
2173b5f578 support aidl bp2build changes
- Allowlist an aidl module by package, not name (to support a small
  module name change)
- Implement some unit test framework changes which facilitate better
  aidl bp2build testing
- Support a convenience function to add a load hook for registering a
  module as "has a bazel definition of a given target name"

Bug: 301676937
Test: m bp2build, verified the aidl target was generated before/after
this CL.
Test: Presubmits
Test: Ran bp2build progress and ensured that aidl_interface targets
under frameworks/ continued to appear converted

Change-Id: I62412057d6f61a2ce2bc39488c75af793eb14c94
2023-09-27 21:30:19 +00:00
Cole Faust
b5055394a9 AVB and selinux support in partitions
Bug: 297269187
Test: m bazel_sandwich (updated partition_inspector to show selinux contexts, but still haven't figured out how to show avb information)
Change-Id: I6911c2fc75495f9722887925d8609c9a171901c6
2023-09-27 14:14:14 -07:00
Cole Faust
e136ddac77 Make platform_mappings file deterministic
Fixes: 301473943
Test: presubmits
Change-Id: I24a1fef87c1fb59b5aeb8ac9c05306cddee32399
2023-09-27 14:14:01 -07:00
Romain Jobredeaux
641b62b205 Merge changes from topic "bazel_framework_res" into main
* changes:
  bp2build support for framework-res
  Keep rules_testing BUILD files
2023-09-27 20:52:50 +00:00
Zi Wang
1066479258 Always drop deps from android_library with no srcs
android_library does not accept deps when there are no srcs because
there is no compilation happening. The libs of android_library module
are unnecessary as deps on the android_library since they aren't
being propagated to any dependencies.
So we can drop deps here.

Test: the updated test case and CI

Bug: 302290600

Change-Id: Ib43a1c273a5f3b3e0aa6f29f4e8569ad3487e451
2023-09-27 12:36:36 -07:00
Treehugger Robot
aaf91a48e9 Merge "Fix false positives of go modules in bpbuild-prog" into main 2023-09-27 19:33:56 +00:00
Liz Kammer
15d7b0b0a5 Fix false positives of go modules in bpbuild-prog
Test: b run //build/bazel/scripts/bp2build_progress:bp2build_progress \
  -- report -m tradefed
Change-Id: I5b9ed1333d61013649056920ffe7110e9786b29e
2023-09-27 09:38:41 -04:00
Romain Jobredeaux
832e131725 Merge "Do not convert android_library_import with no aars." into main 2023-09-26 20:08:04 +00:00
Romain Jobredeaux
9c06ef353b bp2build support for framework-res
Change-Id: I5b32a702e02b5f1ec08d5608d766a8a0c08d845c
Bug: 276928228
Bug: 297356405
2023-09-26 15:06:50 -04:00
Treehugger Robot
370e34172f Merge "Generate a ndk_sysroot target in bp2build" into main 2023-09-26 05:16:53 +00:00
Vinh Tran
47faaad254 Add bp2build for rust_protobuf module
We only supported bp2build for rust_protobuf_host because the non-host toolchain for rust is not checked in yet. aosp/2759750 changed a converted module from rust_protobuf_host to rust_protobuf and broke CI.

This CL adds bp2build support for rust_protobuf but makes the target incompatible with android os for now untilnon-host rust toolchain is checked in.

Bug: 301956497
Test: b build //build/make/tools/aconfig:all --config=android
Change-Id: I739896c79f32674000c2603e394f16860a6fc57d
2023-09-25 17:37:59 -04:00
Spandan Das
af72583468 Generate a ndk_sysroot target in bp2build
This target will have a dependency edge to every bp2build equivalent of
Soong's ndk_headers. In b builds, sdk variants will compile against this
aggregated CcInfo providing target

A non monolithic alternative was discarded after conversations in
b/300504837#comment1-5

Contents of bp2build generated target: https://paste.googleplex.com/6643820291686400

Implementation details
- Since there is no equivalent Soong module for ndk_sysroot, hardcode
  bp2build/build_conversion.go to collect all ndk_headers soong modules.
  Add them to `deps` of a ndk_sysroot target
- Create `ndk_sysroot` in build/bazel/rules/cc/BUILD.bazel. This is
  expected to be a temporary location. This will use the
  cc_library_headers macro
- Update SetStubsForDynamicDeps so that sdk variant of rdeps depends on
  //build/bazel/rules/cc:ndk_sysroot. This will provide a CcInfo during
  compilation. Since ndk_sysroot is of type cc_library_headers, it will
  not get packaged into the apk.
- Refactor `goBazelTarget` to a generic `bTarget` so that it is
  representative of the expanded usage by ndk_sysroot

Test: b build //build/bazel/examples/android_app/java/com/app:app_with_sdk_variant_of_jni_deps --config=android (with aosp/2755284)

Bug: 300504837

Change-Id: Ifa427dd78115703ab251b0e1a0b71d3f19e91008
2023-09-25 21:27:19 +00:00
Treehugger Robot
b95a8b33be Merge "Enable/disable optimize for android_test and android_test_helper_app by default." into main 2023-09-25 17:51:14 +00:00
Cole Faust
71aa535721 Merge "Emit a system image target for the current product" into main 2023-09-25 17:08:34 +00:00
Jingwen Chen
65229207d1 Enable/disable optimize for android_test and android_test_helper_app by default.
Follow up to https://android-review.git.corp.google.com/c/platform/build/bazel/+/2727853/comment/f2c5802e_245fd302/

Test: New unit tests, presubmits
Test: `atest-dev HelloWorldTests --roboleaf-mode=dev`

Change-Id: I88efcf72fbcb717d05e71ba50ba7802c3bece816
2023-09-25 15:27:33 +00:00
Zi Wang
7c5b6d5273 Merge "Pass java_library libs and static_libs to java_*_proto_library" into main 2023-09-23 03:45:48 +00:00
Cole Faust
cb193ec471 Emit a system image target for the current product
This system image can be built with bazel instead of make.

Bug: 297269187
Test: m bazel_sandwich
Change-Id: I5fd61a28f664d8310435c3b7e5dbdd89a7ec6159
2023-09-22 14:42:33 -07:00
Romain Jobredeaux
afc5d27ab0 Do not convert android_library_import with no aars.
Bug: 301007952
Change-Id: Ia32d47eeb1a888ea2555d5ca08f56f191c040bc7
2023-09-22 15:52:59 -04:00
Chris Parsons
6666d0f6b1 Switch bp2build mutator to bottom up
This should be no-op, as the underlying mutator has not changed yet.

Some other refactoring is required and done in this CL:

- Delete some old, dead ApiBp2build code
- Fix casting to TopDownMutator when it's not necessary

This change is required to prepare for allowlist v2 work, as only
BottomUp mutators can AddDependency.

Bug: 285631638
Test: m nothing
Test: presubmits
Change-Id: I5212a5f5634cc13056195783e6df37ff8eb000da
2023-09-22 19:19:22 +00:00
Christopher Parsons
68a3d9b33e Merge "Handle already existing targets of different name" into main 2023-09-22 18:52:07 +00:00
Zi Wang
4dbd0e8688 Pass java_library libs and static_libs to java_*_proto_library
If a java_library module has proto srcs, a java_*_proto_library target
will be created for it. Proto sources are generated and then compiled
by a java_library target. We need to pass the libs and static_libs of
the java_library module to this java_library target so that
the compile-time classpath is correct.

Test: updated unit tests and CI

Bug: 301469542
Change-Id: I05b2efce6fda2223e85728b3c4c7b1815d04c3dd
2023-09-22 11:20:06 -07:00
Liz Kammer
596ee5c82d Merge "Do not convert non-unit tests." into main 2023-09-22 14:08:53 +00:00
Spandan Das
7ba007a3c6 Merge "Create a bp2build converter for ndk_headers" into main 2023-09-21 23:11:33 +00:00