Commit graph

688 commits

Author SHA1 Message Date
Wei Li
2c9e8d6128 Change bp2build converter of module "package".
1) Use attribute name "default_package_metadata" instead of
   "default_applicable_licenses" in packages to better describe its use.
2) Add a filegroup "default_metadata_file" in packages to search for
   METADATA file in each package.
3) Include "default_metadata_file" in each package's
   "default_package_metadata" attribute.

Bug: 275472038
Test: CIs
Change-Id: I645c013c39e3190fd96c4a549d39a331aced16bd
2023-05-09 17:37:04 -07:00
Treehugger Robot
c144c08d2a Merge "Provide a resource_prefix_strip for java_resources in bp2build." 2023-05-05 01:44:03 +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
Cole Faust
9e4c6c9cc7 Merge "Use api_levels_released_versions from starlark" 2023-05-02 21:55:15 +00:00
Yu Liu
bd421e06d1 Merge "libbuildversion should be linked as a whole archive dep as soong does." 2023-05-02 17:34:02 +00:00
Yu Liu
fe978fd2c1 libbuildversion should be linked as a whole archive dep as soong does.
Bug: 278789968
Test: Unit tests and CI
Change-Id: Ic2c44826bdc03b91cc19d93f96096ec6fdf44833
2023-05-02 17:27:44 +00:00
Cole Faust
3486740cc5 Use api_levels_released_versions from starlark
Instead of exporting it to soong_injection.

Bug: 279095899
Test: m nothing
Change-Id: I7b93af233b7450848a475512b5f5682ece773c09
Merged-In: I7b93af233b7450848a475512b5f5682ece773c09
2023-05-02 01:05:07 +00:00
Yu Liu
93893ba061 Fix a bug where CppFlags should have been Cppflags
Bug: 278789968
Test: unit test and manual build
Change-Id: I9abb056e6b820414707247d1b19ba6aabffc26ea
2023-05-01 13:55:53 -07:00
Treehugger Robot
176271a426 Merge "Correct cc_test_library migration" 2023-05-01 14:38:41 +00:00
Spandan Das
5e1525d1de Merge changes Ibbb14b0d,I9aa552e3
* changes:
  Create config_setting per apex_name
  Add a function to create config_setting(s)
2023-04-29 03:52:55 +00:00
Spandan Das
4242f10462 Create config_setting per apex_name
These are created by bp2build in /build/bazel/rules/apex. Eventually
these config_settings should likely be colocated with the source apex
definition.

Another alternative was to make Bazel's apex a macro that generates a
config_setting. I did not pursue this further for now since it requires the
apex_available of every allowlisted cc_library to also be allowlisted.
This might not always be true (e.g. com.android.runtime)

Test: go test ./bp2build
Change-Id: Ibbb14b0d9c1491b3c79b7634a18d9d35b03922c1
2023-04-28 20:37:35 +00:00
Spandan Das
6a448ec1a3 Add a function to create config_setting(s)
The use case for this is creating config_setting(s) specific to an apex
variant and selecting stub/impl in that config_setting. We likely need
only a handful of such config_setting(s), but determining that list
requires iterating the build graph.

Test: go test ./bp2build
Change-Id: I9aa552e3d0bcf67513023c3a7d4bbf8fae464ee4
2023-04-28 19:43:43 +00:00
Cole Faust
c9508aac4c Load starlark files from soong
There are a number of instances where we are exporting information
from soong to bazel via soong_injection. This could be more bazel-centric
if the information was instead held in bzl files, and both bazel and
soong read it from there.

Add a starlark package that will run
//build/bazel/constants_exported_to_soong.bzl at initialization time,
and then results can be retreived with GetStarlarkValue.

Since changes to the starlark files mean that soong has to rerun,
add them as ninja deps.

Unfortunately, the starlark code has to be run at runtime rather than
pregenerating their results, because tests run from intellij wouldn't
go through any pregeneration steps. This means that starlark is run
multiple times during the build, once per test package and once per
primary builder invocation. (currently 3, could be reduced to 2 if we
made the symlink forest generation into its own standalone tool) The
starlark code we have so far in this cl is very fast, roughly half a
millisecond, so it's not a big deal for now, but something to keep an
eye on as we add more starlark constants.

Bug: 279095899
Test: go test
Change-Id: I1e7ca1df1d8d67333cbfc46e8396e229820e4476
2023-04-26 17:18:19 -07:00
Sam Delmerico
75dbca2eae Revert "Revert "mixed builds correctly reference stubs libs""
This reverts commit 1db4348734.

Changes from original:
  - extracted function to add the current version to stub
    versions for bp2build.
  - added libc++ to mixed builds denylist

Reason for revert: re-uploading with fix in topic

Change-Id: Ifa0ed456bf8cb4a7f861d6826263adfedb4fdd9c
2023-04-25 00:25:20 +00:00
Liz Kammer
efc51d9396 Correct cc_test_library migration
Previously we were treating it as a shared library only, but
cc_test_library produces both a static and shared library.

Test: bp2build tests
Change-Id: I293d4246d581212b95765fa8f084301514d00dbf
2023-04-21 15:22:49 -04:00
Trevor Radcliffe
a8b441613a convert hidden visibility flag to feature
in bp2build. The context here is that `-fvisibility=default` should
only be added for CFI if `-fvisibility=hidden` is not already
specified. This will be achieved using toolchain features. Note
that Soong itself never adds `-fvisibility=hidden`. This is only
ever added in the `cflags` property of a bp file.

Bug: 261733820
Test: Unit tests
Change-Id: Ib821e8c30a9cd03d2929b4bd2e771bec7b33fa66
2023-04-20 20:52:41 +00:00
Sam Delmerico
dc0a4021cd Merge "Revert "mixed builds correctly reference stubs libs"" 2023-04-19 19:57:49 +00:00
Usta (Tsering) Shrestha
1db4348734 Revert "mixed builds correctly reference stubs libs"
This reverts commit ca438e6b72.

Reason for revert: ci post-submit failures in aosp-master-bazel of targets mixed-droid-clean and mixed-droid-incremental:
FAILED: ninja: 'out/target/product/generic_arm64/obj/SHARED_LIBRARIES/libc_intermediates/libc.so.toc', needed by 'out/target/product/generic_arm64/obj/EXECUTABLES/updater_intermediates/LINKED/updater', missing and no known rule to make it
12:21:27 ninja failed with: exit status 1

Change-Id: I081b499d23f2568cdf6227c4e3b0278164086b69
2023-04-19 14:02:52 +00:00
Usta (Tsering) Shrestha
cf76125627 Merge "Add aidl.deps prop to include aidl implicit deps explicitly in Android.bp" 2023-04-18 14:18:51 +00:00
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux
fecec28c34 Merge "bp2build: migrate export_{,system_}include_dirs -> *includes for cc_prebuilt_library{,_static,_shared}" 2023-04-17 21:01:21 +00:00
Vinh Tran
2562585878 Add aidl.deps prop to include aidl implicit deps explicitly in Android.bp
In a follow-up CL, we should eventually disallow aidl.include_dirs in cc rules so that the deps are always explicit and compatible with Bazel migration.

Test: go test
Bug: 278059962
Change-Id: Ia786cc8634d03589dc008f10b01e6bb2b9f2c7f0
2023-04-14 19:28:44 -04:00
Treehugger Robot
0c3682be50 Merge "mixed builds correctly reference stubs libs" 2023-04-14 23:07:21 +00:00
Cole Faust
ae31382119 Merge "bp2build support for python_test(_host)" 2023-04-14 20:49:01 +00:00
Romain Jobredeaux
141dcbb6cc Merge "Delete platform mapping specific bp2build code" 2023-04-14 17:34:13 +00:00
Sam Delmerico
ca438e6b72 mixed builds correctly reference stubs libs
Bug: 270408757
Test: go test
Test: m NeuralNetworksTest_shared_partial --bazel-mode-staging
  && verify that Ninja commands link libneuralnetworks via stubs
Change-Id: I19bf5a829cea7fd00c0f82511ad2bddbc40fae4f
2023-04-14 12:42:23 -04:00
MarkDacek
9c094ca153 Fix issue where bazel-force-enabled-modules aren't actually analyzed.
Bug: 273910287
Test: run mixed_mode_test.sh

Change-Id: I309c423b6e7f505ad1db0d9327e7de6b8298dfe9
2023-04-14 02:17:54 +00:00
Cole Faust
d82f036b89 bp2build support for python_test(_host)
There was a request for using b with python tests. bp2build python
tests exactly the same way as python binaries so that they can be
used with `b`.

Bug: None
Test: go test
Change-Id: Id68a6a73572745a4885b3e5bb1b8452e36baa982
2023-04-13 16:10:59 -07:00
Romain Jobredeaux
1a3382c0c2 Delete platform mapping specific bp2build code
Bug: 249685973
Test: Presubmits
Change-Id: Ib76a7659dfe57731100550c2cff4de960be2f1d7
2023-04-13 18:48:00 -04:00
Romain Jobredeaux
a3c029e7d5 Merge "Bp2build support for sdk_version and java_version." 2023-04-13 20:53:07 +00:00
Cole Faust
37d27c4884 Fix crash when missing platform sdk version
Fixes: 277890306
Test: Presubmits
Change-Id: I26658a90856cb057c631bb71ca0cd094ed648cf5
2023-04-12 10:32:18 -07:00
Jingwen Chen
aea34a38ca Merge "Revert^2 "Re-land test tzdata apex with bazel builds."" 2023-04-12 06:50:26 +00: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
Cole Faust
eb644cfb34 Break constant information out of product vars
We don't want rules to load the product variables directly, because
then they won't be able to transition on them.

Break constant information that is safe to load outside of the
product vars file, so that we can make the product vars file have
more restricted visibility later.

Bug: 269577299
Test: m nothing
Change-Id: I848bff33e4f5798f51296ea3a2600615cab36985
2023-04-11 15:38:43 -07:00
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux
c641cc496b bp2build: migrate export_{,system_}include_dirs -> *includes for cc_prebuilt_library{,_static,_shared}
Migrate `export_include_dirs` property to attribute `export_includes`, handling arch/os-variants
Migrate `export_system_include_dirs` property to attribute `export_system_includes`, handling arch/os-variants

Test: cc_prebuilt_library_{,shared_,static_}conversion_test.go
Test: mixed_droid.sh
Bug: 229374533

Change-Id: I658a336a71265af0545c1c2db1a4f6eb613a7366
2023-04-11 18:56:41 +00:00
Jingwen Chen
6134211c2d Revert^2 "Re-land test tzdata apex with bazel builds."
fb8b1a69e9

Change-Id: Id5c0edd1cd4aacbb75a8019e0a5ada4e608fbf09
2023-04-11 14:55:27 +00:00
Treehugger Robot
dfa0a761f2 Merge "Clean old symlink forests" 2023-04-06 01:28:33 +00:00
Treehugger Robot
dd5653bbf0 Merge "Fix issue merging bp2build files with handcrafted ones" 2023-04-05 20:32:14 +00:00
Cole Faust
5db92090e1 Clean old symlink forests
There was an incrementality bug in the symlink forest generation that
was recently fixed. However, if the appropriate files don't get touched,
the issue will remain. Add a mechanism to clean old symlink forests
so that when we fix incrementality bugs we can ensure they don't remain
in any old out directories.

Bug: 276349152
Test: Presubmits
Change-Id: I36664dfb0ca7227e3e1f89de859ebccb808c5f15
2023-04-05 11:44:49 -07:00
Cole Faust
3f4f521711 Fix issue merging bp2build files with handcrafted ones
It was possible for the merged content to end up back in the bp2build
generated file because there was a symlink from the symlink forest to
the bp2build generated file.

Remove the symlink if it exists.

Bug: 276349152
Test: m bp2build, add a handcrafted file in the same folder as a Android.bp file, m bp2build again, check that the symlink forest version is not a symlink
Change-Id: Id64aa3addebcf0c6b1728389f21ae246796aaf8d
2023-04-05 09:08:38 -07:00
Romain Jobredeaux
15807fa7ed Merge "Bp2build converter for java_host_for_device." 2023-04-05 13:32:29 +00: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
Romain Jobredeaux
e7370eabe4 Bp2build converter for java_host_for_device.
Change-Id: I70a345c641bbed3223dc6222062fb6948f7dc6cb
Bug: 276710283
Test: Presubmit
2023-04-04 19:49:17 -04:00
Cole Faust
e28bde81fd Merge "Move the testing platforms out of soong_injection" 2023-03-31 00:17:33 +00:00
Cole Faust
117bb747a4 Move the testing platforms out of soong_injection
See the other cl in this topic for more information.

Bug: 269577299
Test: b test --config=android //build/bazel/rules/apex:all
Change-Id: I1f20bc5f85398cd79dc5b7fe9d0bd4d93d442383
2023-03-29 14:46:20 -07: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
Cole Faust
d3cc7c9bef Merge "Add testing android products" 2023-03-29 00:19:51 +00:00
Liz Kammer
f2571c4136 Merge "Propagate testonly for override_apex bp2build" 2023-03-28 20:57:45 +00:00
Cole Faust
ebc01a3225 Add testing android products
These must be added in the soong_injection code as opposed to just
defined loosely in checked-in bzl files because the product_vars
select statement must be updated to support the new platforms.

Bug: 269577299
Test: b test --config=android //build/bazel/...
Change-Id: I7bba9af214896dd3b5938bae70b7c0cea4f75e41
2023-03-28 11:27:30 -07: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
Cole Faust
426b1c6c7f Merge "Rename utils.bzl to android_product.bzl" 2023-03-27 21:56:43 +00:00