Commit graph

38 commits

Author SHA1 Message Date
Liz Kammer
9f52f6ba60 Change openjdk9 specific props in bp2build/Soong
JDK17 is the default java version, adding these props conditionally
openjdk9 is no longer relevant

Test: CI
Change-Id: I5d80fd22f474cedf389d1e295620cfc17bc327a0
2023-10-12 09:57:04 -04:00
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
Zi Wang
734266b633 Use correct module name for java_import in shouldConvertWithBp2build verification
This change makes sure that prebuilt module has correct module name
prefix("prebuilt_") inside method shouldConvertWithBp2build, to avoid
the bp2build conflict issue when a normal module and a prebuilt module
with the same name are both allowlisted.

Test: CI, added unit tests and the steps to reproduce in b/303376793

Bug: 303376793
Bug: 303868211
Change-Id: I4f1126182ec1f52ae6a08046a77204939230edef
2023-10-09 16:51:35 -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
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
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
Zi Wang
dd93636f1e Always drop deps from java_library with no srcs
This is the follow up from aosp/2750763

Test: CI and added unit test

Bug: 285952385
Change-Id: I64703ee4fa742b718ffb43f2af1b6ab43ddeb606
2023-09-15 10:37:16 -07:00
Sam Delmerico
130d75b6b3 export SimpleModuleDoNotConvertBp2build for AIDL
Bug: 298246873
Change-Id: I06ed7bb8fc1139731a2b48440a91aeb7f383efff
2023-09-10 19:05:54 +00:00
Liz Kammer
33dddf5a7e Do not convert resource dirs without resources
Previously we would convert to java_resources when there were no
resources and get an error.

Test: b build //external/libphonenumber/... --config=android
Change-Id: I86f30b993a3ffdb20000f6a4c5261e2c4c74263c
2023-09-08 09:44:00 -04:00
Liz Kammer
65942c8467 Do not convert java libraries with core_platform
Test: go bp2build tests
Change-Id: I2769c0d589c304caeb24a8ecba38a4a5ee6c63e5
2023-09-08 09:43:57 -04:00
Liz Kammer
02914408de Add do not convert for sdk_version unset
When sdk_version is unset, the build with fail with Bazel because
private APIs are do not build with Bazel at this time.

This instead prevents migrating the relevant target to Bazel in bp2build

Test: go tests
Change-Id: I31dabcf143de7933706d1b734ef21467a01b65e9
2023-08-29 20:06:48 -04:00
Alix
289e9c607b support for multiple filegroups and resource_dirs
Test: tests in bp2build and b build //external/emma:emma

Change-Id: I57e60389aec926c55d01818a6a3b1ec33e9c53b8
2023-08-25 16:12:15 +00:00
Alix
b1e5c6a69a Bp2build for errorprone modules that manually enabled/disabled it
Test: go test ./bp2build
Change-Id: Ie60c0959ee9ae8ce86c11a8e85a0bc7592f63df8
2023-07-13 15:50:18 +00:00
Alix
b29a3cd2aa bp2build java_resources that only contain a filegroup
supports filegroup that specifies path property

Bug: 280860624
Test: built libauto_value_plugin
Change-Id: I9ed0b13e055beb92ba8090f6b5e88b9873c9ce61
2023-05-24 18:21:15 +00:00
Romain Jobredeaux
d5fe133077 Provide a resource_prefix_strip for java_resources in bp2build.
Although paths to resource files in a Bazel java_library should be
relative to the package, the directory structure in the resulting jar
will have resources under the full path from the top-level of the
workspace, e.g. if a library in "a/BUILD" has java_resouces as
"res/res.txt" then by default the res.txt file would appear under
"a/res/res.txt".
Fix this by adding a resource_strip_prefix in that case.

Test: Unit tests
Change-Id: If4325126f5c19a2a8fb83ee09bc3a95a18673fe3
2023-05-04 14:54:45 -04:00
Romain Jobredeaux
2eef2e13e9 Bp2build support for sdk_version and java_version.
This CL adds java_version and sdk_version support to bp2build
converters for
   - java library
   - java binary
   - android library
   - android binary
   - android library import

Although java import doesn't support java_version and sdk_version, the
neverlink java_library wrapper around a java_import must specify a
sdk_version when targetting a device. "none" is used by convention.

Change-Id: I22a69dea2e351858368df69ed6a703b568d613ea
Bug: 215230098
Test: Presubmits
2023-04-11 21:05:48 -04:00
Romain Jobredeaux
eb711b9f7c Support arch variants in java's StaticLibs in bp2build
Test: Presubmits
Bug: 276901800
Change-Id: I6058a726833ef10a5f470946e2d265b20fa547ce
2023-04-04 19:50:13 -04:00
Liz Kammer
2b3f56ed22 Add apex_available aidl + aidl&lang libraries
Test: b build com.android.neuralnetworks com.android.media.swcodec
Change-Id: I008b915b22e4c8c2cf1f0aee6cfdaf17374cb3a9
2023-03-24 15:14:53 -04:00
Alix
f848bf8225 bp2build kotlinCFlags
for java_library, java_binary, android_app & android_library

Change-Id: Ia8dec7e7d497eb41b2d8dcd8c44c3090d1d3b4bd
Bug: 271265771
Test: go test ./bp2build
2023-03-14 13:57:22 +00:00
Romain Jobredeaux
3eaf747ae5 Call ResolveExcludes after arch-based sources computation in java.go
TEST: go test
Change-Id: I93a8ae5e0842dab03f73b0edb32841755d2ea435
2023-03-08 16:34:17 -05:00
Alix
495cc8a6ff arch variant support for libs property
Test: bp2build tests and manually inspected Build file for libprotobuf-java-lite
Bug: 244210934
Change-Id: Id60d859eea2c23fa7a29784faeed5cb050d4193e
2023-01-19 20:42:24 +00:00
Treehugger Robot
6228be4cd4 Merge "support libs for android_library" 2023-01-06 19:30:02 +00:00
Alix
82fb94e91e support libs for android_library
adds support for *-> android_library and android_library->* edges

Change-Id: I41d4e1d1b8106a17e67951d47e67b59ef3170d17
Test: manually inspected build files for libWallpaperPicker & android-suppor-v4
2023-01-05 21:13:57 +00:00
Alix
266bbf2f9c Libs support for * -> java_library_edge with kt sources
Bug: 244210934
Test: bo2build tests and built kotlinx_atomicfu
Change-Id: Id6eac2f104878e4d7902a32e846ef1cc87dd7863
2022-12-15 06:27:59 +00:00
Alix
341484b3da Bp2Build for libs property in java_library
Bp2build for both *->java_library and java_library->* edges.

Change-Id: I2540c9af2ae2fe7677767d507647b1c6669b9bb7
Bug: 244210934
Test: ./bp2build testcase, manually inspected build files for hamcrest-library, hamcrest targets
2022-11-29 19:44:50 +00:00
Alix
8062f4dee7 bp2build for java_library with .kt srcs or common_srcs
java_library modules with .kt srcs or common_srcs will be converted into
module type kt_jvm_library

Test: m bp2build, manually inspected build files for allowlisted modules
Bug: 258688914
Change-Id: I8293a11c8247b4b76358d0991f82c6b61b58adc3
2022-11-15 20:01:29 +00:00
Cole Faust
c843b99b71 Support arch features in bp2build
Bug: 189972518
Test: New soong test
Change-Id: I05d77c8f63ffe6697d8e0300226864658055e116
2022-09-02 15:20:54 -07: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
7c72137338 non-adjacent AIDL filegroup bp2build test java
Add test to ensure that filegroups from other packages are correctly
added as dependencies for java_library. Test copied from aosp/2183478.

Test: go test ./bp2build
Change-Id: Ie39b7182f544fa196870fb7311817e6b6e68817b
2022-08-25 14:47:41 -04:00
Sam Delmerico
97bd127457 convert .aidl srcs for java_library
Test: go test ./bp2build
Test: b build //frameworks/base/services/tests/servicestests/aidl:servicestests-aidl
Test: enable //packages/modules/NetworkStack/common/networkstackclient
    && disable restriction on Android SDK in javaLibraryBp2Build
    && b build //packages/modules/NetworkStack/common/networkstackclient:ipmemorystore-aidl-interfaces-V10-java
Change-Id: Ifb817daf09a3983ea1c84948ed9f02a79f95784b
2022-08-25 14:47:41 -04: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
Sam Delmerico
79985819fe convert java_resources with bp2build
Test: b build --platforms=//build/bazel/platforms:linux_x86
  //external/jarjar:jarjar-binary and try to use on a jar
Change-Id: Id6f4e6937687fd575360fbacaeda55c41922636e
2022-05-10 14:32:52 +00:00
Vinh Tran
3ac6daf47c bp2build converts java_version property to javacopts attribute
This CL also converts `external/rappor` (which already set `java_version` to `1.7`) to be bazelable to testify the changes.

Results from `b build //external/rappor && cat bazel-bin/external/rappor/librappor.jar-0.params`: https://paste.googleplex.com/5518725462622208.

Test: go test ./bp2build/...
Bug: 227618664
Change-Id: I8d370d4639f70fba51e6de6ceb7bcb5ace9ccd91
2022-04-28 18:52:48 -04:00
Sam Delmerico
24da73c032 convert logtags in java srcs
Some java_* modules contain .logtag files in their srcs, but we should
separate these out into their own targets.

Test: enabled QuickSearchBox and build
Change-Id: I595722ca59686d450ff522987a15ce283d3607e0
2022-04-08 14:43:18 +00:00
Sam Delmerico
58614c0414 support errorprone javacflags
Soong has a separate property specifically for errorprone javacflags
that we need to add to the Bazel javacopts.

Test: go test ./bp2build
Change-Id: I5299f45793d2b05a6a71b94dd17ceb797f407846
2022-03-31 14:38:07 +00:00
Sam Delmerico
77267c7d9c add plugins to javaLibraryAttributes
Test: go test ./bp2build
Change-Id: I8e4c3f373c62c60ea5013cd8c585915a366c1f81
2022-03-30 19:19:13 +00:00
Sam Delmerico
c016143602 emulate java_library static_deps with Bazel exports
In Soong, java_library can specify static_deps which are dependencies
that get aggregated into the final jar (akin to static linking). This is
useful because it allows dependencies higher up in the chain to compile
against the APIs exported by transitive dependencies. Bazel does not
support this functionality directly, but it can be emulated via the
exports attribute which makes any targets listed in the attribute public
to targets further up the chain.

Bug: 217236083
Bug: 219908977
Test: b build //external/error_prone:error_prone_core
Test: b build //external/bouncycastle:bouncycastle-host
Test: b build --platforms=//build/bazel/platforms:linux_x86
  //prebuilts/sdk/tools/jetifier/jetifier-standalone:jetifier
Change-Id: I2867e3f816de720a6f4bd9ff7a847d1b0c2da2d6
2022-03-30 18:58:38 +00:00
Wei Li
bafb6d6612 Add the initial implementation of bp2build converter for java_library,
java_library_host, java_binary_host and cc_library_host_shared so
signapk tool can be built with Bazel.

Test: b build //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal
Test: jarsigner -verify -verbose build.bazel.examples.apex.minimal.apex
Bug: 209876137
Bug: 196204358
Bug: 210158864
Bug: 210159074
Bug: 210158872
Change-Id: I855884159d25e69d8f9623792c376da820a1eb4c
2021-12-14 17:23:19 -08:00