Commit graph

40 commits

Author SHA1 Message Date
Jingwen Chen
9c2e3ee54a Move platform constraints to bazel_common_rules.
This enables sharing of platform constraints between platform and kernel builds.

Bug: 304594734

Test: treehugger
Change-Id: I48091eeaf2e529c3f180ba056da3935911868b14
2023-10-11 12:07:44 +00:00
Chris Parsons
0c4de1f234 Handle already existing targets of different name
In other words, if, in bp2build, module "foo" would generate "foo",
and "foo_two", and "foo_two" already exists in a build file,
bp2build should label "foo" as being unconvertible.

Fixes: 301321658
Fixes: 301312582
Bug: 285631638
Test: Unit tests
Test: Verified that `m bp2build` results in bit-for-bit identical
contents for out/soong/bp2build before and after this change.

Change-Id: Icbbdd69fce83579ec9b172d04b2bf1f294698f70
2023-09-21 20:58:25 +00:00
Chris Parsons
4c81ce0307 Refactor some tests to not use bp2build_avail
Bug: 301312260
Test: presubmits
Change-Id: I67ca45f17d11e9b893fae5f6c6df1239ae4220b6
2023-09-21 17:08:09 +00:00
Chris Parsons
cd209035aa Refactor bp2build tests for allowlist v2
Allowlist v2 will change bp2build by automatically disabling rdeps of
unconvertible modules. Many bp2build tests create bp2build stub modules
without an implementation,
This CL changes setup of such tests to also contain a BUILD file with
"stub implementations" of equivalent targets, to keep these test targets
convertible.

To verify this change in-place, this CL removes `bp2build_available:
false` from these dependencies.

This is a test-only change for bp2build tests.

Bug: 285631638
Test: m bp2build
Change-Id: I489480cbc4158a416b7abf57c35a6e2bc2ad6173
2023-09-19 17:04:11 +00:00
Spandan Das
04f9f4cf71 Parameterize cc_stub_suite for api surface
cc_stub_suite now has an additional attribute correponding to the api
surface. This attribute will be used to pass additional args to the stub
generator.

Update bp2build to set the api_surface of the apex stubs. This ensures
that its stubs are generated with "--systemapi --apex"

Test: unit tests
Bug: 298085502
Change-Id: If4c479f85e6e485b5c795a565a0c559f1f013bf5
2023-09-14 17:07:24 +00:00
Sam Delmerico
130d75b6b3 export SimpleModuleDoNotConvertBp2build for AIDL
Bug: 298246873
Change-Id: I06ed7bb8fc1139731a2b48440a91aeb7f383efff
2023-09-10 19:05:54 +00:00
Cole Faust
87c0c33a65 Make bp2build-generated selects() based on product config build settings
...instead of based on constraint settings.

Bug: 269577299
Test: m nothing and ./build/bazel/ci/bp2build.sh
Change-Id: Ib9caec79c92b8fd304e46be841de5612bd1637e3
2023-08-03 10:12:09 -07:00
Sam Delmerico
e860d1429e add apex_available_name variant_version to bp2build unit tests
Bug: 285138555
Test: go test ./bp2build
Change-Id: Ide31e7f651b11857afc4570a891fb94460d8ea54
2023-06-06 15:47:30 -04:00
Spandan Das
a43ae1366e For test apexes, base_apex_name is the api domain
apex_test do not "override" the source apexes that they test. However,
similar to override_apexes, test apexes have the same path
(/apex/<apex_name>) on device. Instead of creating another property,
reuse the existing base_apex_name property. The use case for this will
be for creating selection statements for stub/impl selection.

Test: go test ./bp2build
Change-Id: I4b7548e0e0fc920e407e1c5e5c00e87efc6e70c9
2023-05-08 19:04:32 +00:00
Jingwen Chen
a8623da12e bp2build apex: convert canned_fs_config property.
Bug: 275280970
Test: bp2build unit test
Change-Id: Ic6867a640a5079cd206419ddd378d2357093dae6
2023-03-29 04:20:08 +00:00
Liz Kammer
1a1c9df4e7 Propagate testonly for override_apex bp2build
Test: go test bp2build tests
Change-Id: I42c61687223c658237b3e4b0a0d6dd339946a6aa
2023-03-28 11:39:50 -04:00
Sam Delmerico
5f90649036 remove stub dependency on source_library
Since the source_library attribute of _cc_stub_library_shared was a
label attribute, the source library was added as a dependency of the
stub which doesn't always make sense. E.g. it caused validation actions
for the source library to run even when we weren't building the source
library.

This change converts the label attriubte to a string attribute so that
we don't add the dependency.

Bug: 263390551
Change-Id: I19c62d1e14847dff68ab37156452addaa119eaf9
2023-03-16 10:01:22 -04:00
Cole Faust
912bc8862e Use product variables from the overridden apex
override_apex's bp2build converter had a bug where it was looking at
the product variables for the override_apex module itself instead of
for the base module it is overriding.

Fixes: 271424349
Test: go test
Change-Id: If1e2653d3751fa908faf0ab97dfa2e943ebe98ec
2023-03-08 12:29:50 -08:00
Vinh Tran
55225e343d Remove apex_available tag in cc_library_static generated from stubs-providing lib
When a cc library has stubs, its static variant shouldn't be included in an apex to ensure the library with stubs isn't statically linked. See https://cs.android.com/android/platform/superproject/+/master:build/soong/apex/apex.go;l=2804;drc=89b01aeaa9e19377ff547baab791277719b8aaf3

This CL modifies bp2build so that it excludes apex_available tag from the static target if the library has stubs. This way, we can ensure that no apex can depend on the static target which results to static linking.

Test: go test
Bug: 255589949
Change-Id: Iedf248994b808436f2440570b094fd06d6284ae9
2023-01-03 21:44:07 +00:00
Jingwen Chen
c4c34e1eab Convert apex_available (for supported modules) to bazel tags.
The tags will then be read by an aspect applied from apex attributes to
validate that the deps are explicitly opt-in to the appropriate apex.

The semantics of this is the same as the Soong apex_available property.

This also adds the "base_apex_name" attr to override_apex conversion so
that apex_available checks continue to work on the non-Google and non-Go
apex names.

Test: presubmits
Fixes: 218841706
Change-Id: I19b3637da9aa47573b252d74f62b601fbdc3784d
2022-12-01 06:25:25 +00:00
Yu Liu
4c212ce058 Support apex_test.
Bug: 249744489
Test: Manual and unit test.
Change-Id: I866debf7ffee54a0f4649b5e5425a8e3cc3042a1
2022-10-24 10:35:12 -07:00
Vinh Tran
8f5310f90c Default apex's compile_multilib to "first" in bp2build
In Soong, decodeMultilib, used to get multilib to determine the dep variations, return "first" if defaultMultilib is set to "common". apex sets defaultMultilib to "common" which means equivalent compileMultilib in bp2build for apex should be "first" (See new Soong unit tests for more context).

This CL fixes bp2build for apex to be more correct.

Bug: 251559512
Test: go tests
Change-Id: Id1cb4407980fc1fab91822c81326f37fb4adfa0a
2022-10-13 16:59:30 -04:00
Jingwen Chen
34feb1471a apex bp2build: refactor module names to be more meaningful.
Numbered module names weren't obvious.

Test: presubmits
Change-Id: Iee921e2965d1664ed1bccd934ab80f913eff6356
2022-10-06 13:02:30 +00:00
Jingwen Chen
bea58093b4 Share certificate bp2build between android_app and apex.
The certificate module is handled the same in Soong between android apps
and apexes, so share the bp2build code as well.

There are a few changes in this CL:

- If override_apex.certificate is unset, the generated apex also unsets
  it. This prevents the generated apex from using the base apex's
  certificate, which is most likely incorrect (e.g. google variant using
  the cert for the aosp variant). Instead, rely on the default
  certificate handling in the macro.
- If the certificate prop is a string, then it gets generated into
  certificate_name in order to disambiguate. This behavior is identical
  to android_app.

Test: added various unit tests.

Bug: 249089160
Fixes: 249089160
Change-Id: I99e18964ff546429a985d0f64dc21e2c69d35d9d
2022-10-03 09:20:47 +00:00
Alix
e06d75be5d Exporting MakeBazelTarget() in testing.go
Since we are putting conversion tests in the same
package as the module being converted from now on

Test: m bp2build
Change-Id: Ied53589d497fef70bfa11d8f6067459c9a50cd72
2022-09-01 16:47:58 +00:00
Sam Delmerico
3177a6e1e0 export common bp2build testing functions
bp2buildTestCase
attrNameToString
runBp2BuildTestCase
makeBazelTargetNoRestrictions

The testing framework defined in the bp2build package can only be used
from within the package because many common testing functions are
private to the package. This prevents modules defined in Soong
plugins (e.g. system/tools/aidl/build) from testing bp2build conversions.

Test: go test ./bp2build
Change-Id: Ia867081327c5181d04687b13c4550e68e6a11f86
2022-08-01 14:49:31 -04:00
Jingwen Chen
b732d7c765 bp2build: convert apex.logging_parent.
Test: CI
Fixes: 235559958

Change-Id: I7b578c67eedb0379603bcf2fc029d03facfbbb0f
2022-06-10 08:38:03 +00:00
Jingwen Chen
81c67d3904 Use prebuilt_etc for prebuilt modules in bp2build test, instead of
pretending with a cc_library.

Test: CI
Change-Id: Ib9a081670e072a0e7378289f677063a978d0a62d
2022-06-08 16:10:19 +00:00
Jingwen Chen
df165c9e85 Only override prebuilts property if the override_apex.prebuilts is
explicitly specified (not nil).

This allows the base apex's prebuilts to be surfaced to the override
apex target.

Discovered when com.google.android.adbd's prebuilts didn't contain its
init.rc module.

Bug: 222588072
Test: CI
Change-Id: I925e98d53f7d9208652c629799ab568521ba7dfe
2022-06-08 16:03:03 +00:00
Jingwen Chen
9b7ebca187 Convert override_apex.package_name with bp2build.
Bug: 216414792
Test: CI and new bazel/bp2build tests
Change-Id: I3974970cdd555b3912798e79e61d61786a4ff677
2022-06-06 10:08:53 +00:00
Wei Li
40f9873612 Convert the property "manifest" properly for override_apex.
1) When it is not set in base apex, default file name should be set explicitly in bp2build converter of apex
2) The manifest file path should be used as-is when base apex and override_apex is in the same Android.bp
3) The manifest file path should be prepended with package of base apex when base apex and override_apex is in different Android.bp

Bug: 216442475
Test: m nothing
Change-Id: Icd3523ebc31d885f67bea02aec05dbfc77671e87
2022-05-23 17:22:35 -07:00
Wei Li
1c66fc74d2 Add bp2build converter for override_apex.
Bug: 216442475
Test: m nothing
Change-Id: I2f106d15c1d235583b8b1a8f0ac4b48162ff4fdd
2022-05-11 22:22:04 -07:00
Wei Li
f034cb4d7b Add bp2build support for property "compressible" of apex module.
Bug: 214466457
Bug: 207551677
Test: b build //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal
Test: b test //build/bazel/tests/apex:build.bazel.examples.apex.minimal_apex
Test: b test //build/bazel/tests/apex:build.bazel.examples.apex.minimal_capex

Change-Id: I6bf12c1b0c52d4486968bb430a67a3c3110766db
2022-01-25 19:42:43 +00:00
Yu Liu
4ae55d17f6 Support multilib in apex.
Bug: b/208325023
Test: Added unit tests, also tested with adbd apex build manually.
Change-Id: I47e04cd4eb5d05227f0a84683dcb66dff00e3514
2022-01-18 10:38:05 -08:00
Liz Kammer
be46fccc40 Use one mutator for all bp2build conversion.
Each conversion required defining a separate mutator, which will each
operate on _all_ modules and requires each to repeat checks whether the
mutator should operator. Instead, we introduce a single mutator and
modules can define a ConvertWithBp2build to implement bp2build
conversion for that module.

Test: bp2build.sh
Bug: 183079158
Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
2021-12-14 09:37:45 -05:00
Jingwen Chen
b07c901e0d bp2build: Fix apex.binaries to be a LabelListAttribute.
apex.binaries accepts a list of module names, which should be resolved to
their fully qualified labels. Bazel treats string_list and label_list
attributes differently, most notably with the latter adding dependency edges.

Test: apex_conversion_test.go
Bug: 209743852
Change-Id: Iafdc5c728e8658cce0e99d42f32e7bb6fe2f3168
2021-12-08 10:10:19 +00:00
Liz Kammer
78cfdaa597 Refactor bp2build tests
Moves to specifying attributes as a map, such at it is possible to add
additional attributes conditionally. This is in particular useful once
supporting the `enabled` property which will add
`target_compatible_with`

Test: go test soong tests
Change-Id: Iade8eed1ce3acb1d1712a9ee3119d9ae59675624
2021-11-15 11:09:05 -05:00
Rupert Shuttleworth
9447e1ee12 Add support for prebuilts attribute to the bp2build APEX converter.
Test: Updated unit test.

Change-Id: I73dfa84d7a55c0b94393ad6257b5f16313422852
2021-07-28 06:03:17 -04:00
Rupert Shuttleworth
6e4950a061 Add some more properties to the bp2build APEX converter (second try)
In particular:

- AndroidManifest
- file_contexts
- key
- certificate
- min_sdk_version
- updatable
- installable
- native_shared_libs
- binaries

Test: Updated unit test

Change-Id: I1c6e8c4b6b24ce487f64e5d37bd594dbb000fe6f
2021-07-27 05:02:50 -04:00
Rupert Shuttleworth
0358478150 Revert "Add some more properties to the bp2build APEX converter."
This reverts commit 69bf4c0d60.

Reason for revert: Possibly broke CI (https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master-bazel&target=bp2build-incremental&lkgb=7266256&fkbb=7237028), rolling back just in case...

Change-Id: I14ebac4f47576a73285d1f724ae4499036e8e678
2021-07-27 02:37:32 +00:00
Rupert Shuttleworth
69bf4c0d60 Add some more properties to the bp2build APEX converter.
In particular:

- AndroidManifest
- file_contexts
- key
- certificate
- min_sdk_version
- updatable
- installable
- native_shared_libs
- binaries

Test: Updated unit test

Change-Id: I9ea13f021d63ec0f75006b3b0b23ec8178c7e9da
2021-07-26 07:32:36 -04:00
Jingwen Chen
f59a8e117e Fix apex bp2build.
apexBundle was missing InitBazelModule for it to have bazel_module properties.

Test: soong unit test
Fixes: 193866723
Change-Id: I5fb38c8b2e8edaecef44162491d399c0223d3fb1
2021-07-16 09:32:49 +00:00
Rupert Shuttleworth
a9d76dd423 Add partial bp2build support for APEX targets (second try).
Test: Added unit test
Change-Id: Icbf0475251aac5d1f13bd35a18f90b6c70f3ae29
2021-07-02 07:36:07 -04:00
Weng Su
7ce730b90c Revert "Add partial bp2build support for APEX targets."
Revert submission 1733232-roboleaf-apex

Reason for revert: b/192523357 Broken build 7512065 on aosp-master on sdk_x86_64-sdk
Reverted Changes:
Ie82c263f6:Add a stub rule for building APEX bundles.
I93e2a25fa:Add partial bp2build support for APEX targets.

Change-Id: I8e836fe7f466e02f3108680f9653412299e929e0
2021-07-01 06:51:11 +00:00
Rupert Shuttleworth
22b606b5f0 Add partial bp2build support for APEX targets.
Test: Added unit test

Change-Id: I93e2a25fa43eec1ffb8fb30c346a9b523195a0fd
2021-06-30 22:20:23 -04:00