Commit graph

258 commits

Author SHA1 Message Date
Sam Delmerico
4e27229b61 Convert javacflags -> javacopts for java_binary_host
This has already been done for java_library modules, we need to add
similar support for java_binary_host.

Bug: 213456294
Test: go test ./bp2build
Change-Id: Idf7b631f3afe9f59e50f9e45bcbdc29fb5923cc6
2022-01-06 21:00:46 +00:00
Liz Kammer
5430953c82 bp2build: Remove duplicate system shared libs
If a system shared lib is specified in shared_libs, this results in
duplicate values appearing, causing a failure in Bazel. This change
removes any system shared libraries that appear in shared libraries from
bionic OS axes where system_shared_libraries takes the default value.

Test: go soong tests
Test: temporarily allowlist directory with this issue, no longer hits
      duplicate library failure.
Change-Id: I9dce570b73c24973f695b815bce8d50f7259798d
2021-12-22 15:53:13 -05:00
Christopher Parsons
948e851b83 Merge "Handle the 'enabled' property in bp2build" 2021-12-22 15:50:10 +00:00
Chris Parsons
58852a05f3 Handle the 'enabled' property in bp2build
Also fix some bugs pertaining to configurable attribute handling of bool
attributes and label sttributes, so that they may support values across
multiple different axes at the same time.

Test: unit tests for bp2build
Test: mixed_droid

Change-Id: I411efcfddf02d55dbc0775962068a11348a8bb2c
2021-12-21 16:37:32 -05:00
Liz Kammer
48c6ead90d sh_binary: Use pointers for optional attributes
Empty strings for filename and sub_dir were unnecessicarily always being
propagated to BUILD files.

Test: build/bazel/ci/bp2build.sh
Change-Id: I39d6af12b1decd1d3813b92daa862ebc025daa7d
2021-12-21 16:01:53 -05:00
Liz Kammer
cac7f690eb bp2build remove "-std" from cflags
Soong overrides "-std" flags when provided via cppflags or conlyflags;
however, any user-provided "-std=" cflag will be overridden by Soong's
std flag handling.

For Bazel, we _always_ allow user to override via user provided flags.
To prevent conflicts, we remove the silently ignored values from
Android.bp files in the bp2build conversion.

Test: build/bazel/ci/bp2build.sh
Test: build/bazel/ci/mixed_droid.sh
Change-Id: I4c33b2ae593a7ff3ff8e3ad15ef3461354fc0c83
2021-12-21 11:49:01 -05:00
Liz Kammer
aabfb5dc47 bp2build: Expand check if filegroup contains proto
Previously we looked for proto as suffix, however, some filegroups use
"<foo>-proto-srcs" or "<bar>-proto-sources", instead we look for proto
as a distinct word in a filegroup name.

Test: go test soong tests
Change-Id: Icf916a84304a02617efff9768e5b82d5ffe658bd
2021-12-15 13:07:58 -05:00
Wei Li
2115d35101 Merge "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." 2021-12-15 03:39:51 +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
Christopher Parsons
f793ba068c Merge "Add missing test files to build/soong" 2021-12-14 21:56:26 +00:00
Chris Parsons
1de1d4ee02 Add missing test files to build/soong
Test: m nothing
Change-Id: Icd331f0c2ac09caed0d4f885dd2eb6ec2080b681
2021-12-14 15:25:51 -05:00
Liz Kammer
92344259c5 Merge "Use one mutator for all bp2build conversion." 2021-12-14 19:10:10 +00:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
8bb0d8f55d Merge "Log bp2build_metrics .pb" 2021-12-14 16:30:29 +00: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
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
947fdbfdee Log bp2build_metrics .pb
Also share `Save(pb proto.Message, filepath string)`

Bug: 201539536
Test: bp2build_metrics.pb has expected content & path
Test: m nothing
Test: {bp2build,mixed_{libc,droid}}.sh
Test: CI
Change-Id: I7d8ad87fca6a4b0355010090a527f5ae67b27c88
2021-12-13 13:03:44 -05:00
Liz Kammer
1263d9bdb1 Handle includes for generated headers
For generated headers, Soong introduces the package to the includes (and
re-exports as necessary).

Test: bp2build.sh
Change-Id: Iea9cda859ddaa3e5393f0f4533c15fc60222c408
2021-12-13 12:06:39 -05:00
Rupert Shuttleworth
484aa25875 Add initial support for use_version_lib.
Test: Resolves build error for BP2BUILD_VERBOSE=1 b build //packages/modules/adb:libadbd_core
Test: Added unit test

Bug: 208481704

Change-Id: I4022c686c7baf050de3f97295fe4654515622a66
2021-12-13 06:21:16 -05:00
Jingwen Chen
8d0bd355fd Merge "bp2build: Fix apex.binaries to be a LabelListAttribute." 2021-12-13 10:03:50 +00:00
Liz Kammer
8f3da38b70 Merge "Add test for performance testing" 2021-12-09 20:46:56 +00:00
Chris Parsons
91b81f0b50 Print number of converted modules
Previously this was equal to the number of generated targets, but with
recent cc_library changes, we now sometimes generate more than one BUILD
target for a single module. Thus, converted module count is a more
useful metric.

At time of writing, this outputs:
`Converted 390 Android.bp modules to 453 total generated BUILD targets.
Included 4 handcrafted BUILD targets. There are 45093 total Android.bp
modules.`

Test: m bp2build
Change-Id: I7d68880dd4c6bf649ca753837a7f3a9c0d73753a
2021-12-08 11:39:07 -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
95b278757e Add test for performance testing
This is to ensure benchmarking infra continues working.

Test: go test bp2build tests
Change-Id: I20927652cf427548f6ff58a0c0cb8d3fa5df34d7
2021-12-07 16:59:40 -05:00
Romain Jobredeaux
4526269c2e Merge "Initial bp2build converter for android_app." 2021-12-07 20:14:29 +00:00
Romain Jobredeaux
1282c42484 Initial bp2build converter for android_app.
The only supported attributes at this point are:
- srcs
- manifest
- package_name
- resource_dirs
as they most easily map to bazel's android_binary's srcs, manifest, custom_package, and resource_files respectively.
Allow-listing all apps that use these fields, along with sdk_version and dex_preopt. The latter 2 are ignored by the converter,
- sdk_version because we're currently relying on a single pre-built SDK,
- dex_preopt because,
   1. though it is not supported in Bazel builds yet, it doesn't prevent the apps from building, and
   2. the apps being converted only use the dex_preopt attribute to disable dex_preopt, which is what is happening anyway.

Change-Id: I4a4f771eeb8f60a1cd4844b2ac1ce3df7c070e73
Test: ./build/bazel/scripts/run_presubmits.sh
Bug: 198224074
Bug: 203688791
2021-12-07 09:41:49 -05:00
Chris Parsons
77acf2e5c1 bp2build: split full_cc_library into shared/static
Test: mixed_droid.sh in conjunction with rule changes
Test: bp2build.sh
Change-Id: If0577065fd39a0446eab16b62c15204d43207e19
2021-12-06 14:11:40 -05:00
Liz Kammer
85c0097d69 Merge "bp2build: support full/lite protos in cc libs" 2021-12-06 14:46:34 +00:00
Yu Liu
0a84e93b7f Merge "Support filename and sub_dir attributes in sh_binary" 2021-12-03 01:04:04 +00:00
Yu Liu
b302455879 Support filename and sub_dir attributes in sh_binary
Test: test by building system/timezone/apex:com.android.tzdata
Change-Id: I08114910fccbdacf6750e237d3e80ba37fde7651
2021-12-02 14:42:20 -08:00
Liz Kammer
12615dbbca bp2build: support full/lite protos in cc libs
Test: bp2build.sh
Bug: 200601772
Change-Id: I3a7e00546726bc63b5eb8d5604557c5988a5320b
2021-12-02 11:00:46 -05:00
Liz Kammer
46fb7aba4d Support empty strings in bp2build
Previously, could not set an empty string as a value of an attribute;
however, this is necessary in some cases. To not unnecessarily create an
empty string, use string pointers for attributes rather than strings.

Test: go test bp2build tests
Change-Id: I03b3a3567452d455246d22d81f86c317d06b7c39
2021-12-01 10:14:49 -05:00
Chris Parsons
79bd2b7761 bp2build implementation for c_std
Test: mixed_droid in conjunction with topic changes
Change-Id: Ic673c1b269f5082b490b32057eb60f3b73eb0940
2021-11-29 18:38:31 -05:00
Jingwen Chen
01812020c1 Add support for writing all Soong config variables into @soong_injection.
Also remove the need to use bp2build_available on
soong_config_module_types as we want to convert every single of them
into the tree for a complete soong_injection soong_config_variables.bzl
file.

The variables are split into their bool, value and string types
respectively, as they all need to be handled differently on the Bazel
product_platform side, as well as for generating constraint values and
settings. For example, value variables need to integrate with
TemplateVariableInfo, and string variables need to include the string
value itself into the select key/constraint value.

Sample soong_config_variables.bzl file: https://gist.github.com/jin/cef700bfb20c8656a931306dd71d47e1

Test: CI
Bug: 198556411
Change-Id: I8665dd1269a507edb37de62407ed3641564bea5c
2021-11-23 08:37:30 +00:00
Jingwen Chen
58ff6801f4 Fix bp2build select generation for inter-attribute soong config
variable usage.

There's bug a in the current soong_config_variable handling
implementation where a soong_config_variable sets conditions_default
value for an attr, and a non-conditions_default value for another attr.
This results in the former attr not properly setting the zero value for
the non-conditions_default select key, resulting in the pretty printer
omitting the attribute totally.

The current implementation in this CL ensures that the zero value is set
whenever this happens at the module level. This is seen in
library_linking_strategy_cc_defaults (see comments in code, and the new
tests)

Test: CI
Bug: 198556411

Change-Id: Ibaeb94508c51a7429fb7a08df610cbb5470f76d2
2021-11-23 08:37:30 +00:00
Jingwen Chen
84817de033 Add support for merging defaults soong_config_module_types into bp2build
select statements.

This supports defaults from the same or different namespaces, and
transitively defaults as well.

Test: soong unit tests
Test: CI
Change-Id: I99435bacfcfbfe20ad753b8021a1779531d7595a
2021-11-23 08:37:30 +00:00
Treehugger Robot
59a5cb072b Merge "Refactor ProductConfigProperties to use a struct key instead of an string key with hardcoded patterns." 2021-11-16 04:55:15 +00:00
Jingwen Chen
25825ca08d Refactor ProductConfigProperties to use a struct key instead of an
string key with hardcoded patterns.

This fixes a bug with label list conditions_default attrs where the
attribute values get clobbered in a map with the keys
"conditions_default" (with a default empty list) and
"acme__feature__conditions_default" (with a non-empty list) when
generating the LabelListAttribute.

Test: CI
Change-Id: I5429e40f747b7a0ed559f8a468a4831cd32df2c0
2021-11-16 02:50:22 +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
Jingwen Chen
a47f28d28e bp2build: add support for soong_config_module_type.
Test: CI, go unit test
Bug: 198556411
Change-Id: Idf862904d51d822f92af0c072341c31b7a02fc64
2021-11-08 13:38:28 +00:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
7fa0696eb7 cc_prebuilt_library_shared converted via bp2build
Bug: b/203699063
Test: bp2build/cc_prebuilt_library_shared_test.go
Test: USE_BAZEL_ANALYSIS=1 m nothing
Test: mixed_{libc,droid}.sh
Change-Id: I4c58224e88c31507a4b285f8c55bdc066bd47232
2021-10-28 11:04:50 -04:00
Liz Kammer
e6583482a8 bp2build: Handle export_generated_header property
The generated_header property resides in BaseCompilerProperties, while
export_generated_header resides in BaseLinkerProperties. Previously
bp2build handled these property structs separately; however, these two
related properties residing in separate structs requires restructuring
the code to allow access to both BaseCompilerProperties and
BaseLinkerProperties for a single axis/configuration combination to
resolve which generated headers are exported/not for the
axis/configuration..

Test: go test soong tests
Test: build/bazel/ci/bp2build.sh
Change-Id: Id150003637fd19d87e8dc5d6941e9f36dc4031dd
2021-10-26 15:10:41 -04:00
Liz Kammer
2dafba7da9 Merge "bp2build: Add support for cc_binary." 2021-10-20 14:02:39 +00:00
Liz Kammer
2ec92fc0a0 Merge "bp2build include generated hdrs in all src splits" 2021-10-19 20:51:00 +00:00
Liz Kammer
2b8004b1ef bp2build: Add support for cc_binary.
Bug: 197920036
Test: build/bazel/ci/bp2build.sh
Change-Id: I2c4200967653af15a330ab8cbaf796b70d43f32d
2021-10-19 14:12:39 -04:00
Liz Kammer
ae3994ed4c bp2build include generated hdrs in all src splits
Currently generated headers are only included in the srcs split;
however, if c or assembly sources depend on the headers, the
dependendency is lacking and can cause non-deterministic failures.

Test: build/bazel/ci/bp2build.sh
Change-Id: Ic354c88300a5fb1b85241f68889e904c33a81488
2021-10-19 14:09:49 -04:00
Chris Parsons
3b1f83d076 Add x86_host vars to config.bzl
Test: USE_BAZEL_ANALYSIS=1 m adbd
Test: Manually verified config.bzl contains various x86_host flags after
bp2build.
Test: Unit tests

Change-Id: Ie9201ea2be4cd1c6659bea088a797cedbae37403
2021-10-19 12:18:13 -04:00
Liz Kammer
51da93381c Merge "Update version_script to be handled as linkopt" 2021-10-15 14:22:27 +00:00
Liz Kammer
fdd72e6351 bp2build: Add special arch-variant targets.
Soong supports additional arch-variant targets based on arch/os aside
from strictly arch/os names. Handle the unconverted cases based solely
on arch/os.

Test: build/bazel/ci/bp2build.sh
Change-Id: I8dc987b1aa4a4ea646dd5b03a94b84297ba6113a
2021-10-13 09:01:56 -04:00
Liz Kammer
d2871189b1 Update version_script to be handled as linkopt
This allows us to handle this consistently between cc_binary and
cc_library* types.

Test: build/bazel/ci/bp2build.sh
Change-Id: I996f42bbe591215217c3d561662e775925b871ff
2021-10-13 08:36:58 -04:00
Liz Kammer
06f00c33a7 Merge "Do not sort after subtraction." 2021-10-13 12:27:48 +00:00
Jingwen Chen
e466cc7ea6 Merge "Convert cpp_std to be an attribute instead of a copt." 2021-10-12 23:13:53 +00:00