Commit graph

14 commits

Author SHA1 Message Date
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
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
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
Zi Wang
f038cde8df Do not append deps to exports when java_library has only proto srcs
This is to address the comment in aosp/2748099

Test: CI

Bug: 285952385
Change-Id: I0bc8c76e2bc9ee113ced8642e0ab93a95799211c
2023-09-13 10:15:10 -07:00
Zi Wang
774c6eaf10 Bp2build: handle the case where java_library has only proto srcs
java_library doesn't accept deps when there are no srcs because
no compilation happens, but it accepts exports.

The deps from the module are not necessary for compiling the protos,
in which case they are unnecessary as deps on the java_library as well
since they are not be propagated to any dependencies.

So we can put the deps to exports and drop deps here.

Test: CI and added unit test

Bug: 285952385
Change-Id: Ie54a4ac0db592fb96fede64f0e67df309dca9c1d
2023-09-12 10:41:42 -07: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
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
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
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
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
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
Sam Delmerico
7a62909f35 remove unconverted strip_import_prefix property
The requirements for this property changed in aosp/1985613.

Test: go test ./bp2build
Change-Id: If75daf11c857cdd8a54c119e073e327cddf8543d
2022-03-07 16:28:50 +00:00
Sam Delmerico
c768102bce convert java proto libraries with bp2build
Allow java_libraries that depend on protobufs to be converted with
bp2build.

Bug: 215230097
Test: build/bazel/ci/bp2build.sh
Change-Id: I3ce52389e7e4e82755605ee277c1e527a6aebc6b
2022-02-15 21:04:59 +00:00