Commit graph

42 commits

Author SHA1 Message Date
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
Sam Delmerico
130d75b6b3 export SimpleModuleDoNotConvertBp2build for AIDL
Bug: 298246873
Change-Id: I06ed7bb8fc1139731a2b48440a91aeb7f383efff
2023-09-10 19:05:54 +00:00
Trevor Radcliffe
d9b7f17f37 bp2build for sanitizer blocklists long term fix
Bug: 286872909
Test: Unit tests
Test: b build relevant targets
Change-Id: I553091f76fca936006651b1ed22c8fe4d176e18f
2023-08-14 19:29:39 +00:00
Liz Kammer
0a681989ae Merge "Handle static binary repetition of system deps" into main 2023-07-19 14:16:52 +00:00
Trevor Radcliffe
d71487173e Update name of blocklist feature in bp2build
Bug: 290908194
Test: Forrest
Change-Id: I0576fb644edb6b6043df9cf01b508ee887f946f1
2023-07-12 13:45:10 +00:00
Liz Kammer
b492843c3f Handle static binary repetition of system deps
Test: b build `bmod toybox-static`
Test: go test bp2build tests
Change-Id: Id728f6fd08832a4fc153f0ff5282cdfb6b19c2f6
2023-07-10 10:28:02 -04:00
Alix
e266787aed bp2build conversion for rscript srcs in cc modules
Bazel does not support using .rscrip/.fs files as cc srcs.
For a module foo with foo srcs, Bp2build will create a bazel
target of rule class rscript_to_cpp with name foo_renderscript
which will have only the renderscript files as srcs.
Bp2build will also create a target foo with the expected cc rule class.
The foo target will have all other src files as srcs and will also
have the target foo_renderscript as another src.

Bug: 210509914
Test: bp2build testing & b build target rstest-latency
Change-Id: Ifdc55051a3595f5fcf54eab8b59e11e9351e141c
2023-06-21 14:58:10 +00:00
Trevor Radcliffe
523c5c6597 Explicitly disable CFI in bp2build when false
In Soong, CFI being explicitly set to false overrides presence in
CFI_INCLUDE_PATHS, so this change causes Bazel to mimic the same
precedence.

Bug: 278789968
Test: Unit tests
Change-Id: I827b3d4272eac2002031970f1e67c9321979b14b
2023-06-16 20:15:45 +00:00
Trevor Radcliffe
ded095ce45 Bp2build Sanitizer Blocklist
Bug: 286894426
Test: Unit tests
Change-Id: I382e028410a185a5017dba1fc47c83ad5b2432cf
2023-06-13 20:46:27 +00:00
Spandan Das
39ccf93c65 bp2build support for stem
By default, the artifacts generated by cc_binary and cc_library in Soong
track the module name. But Soong supports overidding this using the stem
property. e.g.
```
cc_library {
  name: "foo.1.2",
  stem: "foo",
}
```
will generate foo.so

This CL adds this property to bp2build

Test: bp2build unit tests
Bug: 240563612
Change-Id: I1dfed870d5bad450511b72c397d2355c01fa3b60
2023-06-06 00:07:37 +00:00
Trevor Radcliffe
27669c0c9e CFI Bp2Build
Bug: 261733820
Test: Unit Tests and manual verification
Change-Id: Ife1b33c58e3770177eab1b6168edbf7969418ad7
2023-06-05 18:08:07 +00:00
Trevor Radcliffe
f06dd91420 CFI Versionscript changes in bp2build
Bug: 261733820
Test: Unit Tests
Change-Id: I0bf2f42944738c0fefb10e59e859d2af44402792
2023-05-19 14:51:41 +00:00
Trevor Radcliffe
5f0c2ac535 Change bp2build to reflect arm_isa refactor
We now rely on a `with_features` clause to effectively disable
thumb when `arm_isa_arm` is enabled. Thus, we no longer need to
add `-arm_isa_thumb` in bp2build.

Bug: 261733820
Test: Unit tests
Change-Id: I9da85834855b297a75097ce3a11e101f55bd53f4
2023-05-15 18:00:59 +00: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
Trevor Radcliffe
56b1a2b575 LTO Bp2build
Bug: 261733821
Test: Unit Tests
Change-Id: I8c3721d35c464e296012145b2e95a7f0866aac37
2023-03-02 17:45:01 +00:00
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux
01ec55ec92 Express no{,_lib}crt via features vs attrs
Given that we can map them directly to disabling the
corresponding Bazel features: `-{link_,use_lib}crt`

Test: Existing (adapted) Unit Tests
Test: bp2build.sh
Change-Id: Ib502f6fb929ace8e86a1001e3cc21f399317500c
2023-02-17 19:24:42 +00:00
Trevor Radcliffe
db7e0263f4 bp2build conversion for Sanitize.Integer_overflow
and Sanitize.Misc_undefined.

This is a redo of aosp/2277186 with changes to account for issues
in mixed builds. Specifically, for now we're disabling mixed builds
for modules that use ubsan. This bug tracks enabling it:
b/261058727.

Bug: 253428057
Test: Unit tests
Change-Id: Ia1277a7fa9a82f40998d7f3d2c40ea90f38201e7
2022-12-29 21:21:23 +00:00
Trevor Radcliffe
682bfb2923 Revert "bp2build conversion for Sanitize.Integer_overflow"
This reverts commit f82482db31.

Reason for revert: http://b/261935841

Change-Id: I8155c2b17c6052b734efea43be06b1099ffedd32
2022-12-09 20:39:12 +00:00
Trevor Radcliffe
f82482db31 bp2build conversion for Sanitize.Integer_overflow
and Sanitize.Misc_undefined.

This is a redo of aosp/2277186 with changes to account for issues
in mixed builds. Specifically, for now we're disabling mixed builds
for modules that use ubsan. This bug tracks enabling it:
b/261058727.

Bug: 253428057
Test: Unit tests
Change-Id: I9dbec1d99353f8cbe6751d5241283ab19592dc27
2022-12-06 20:13:21 +00:00
Jingwen Chen
0ead79bd11 Revert "bp2build conversion for Sanitize.Integer_overflow"
Revert submission 2277186-ubsan_bp2build

Reason for revert: b/260630869 broke mixed_droid
Reverted Changes:
Idd9b33e53:bp2build conversion for Sanitize.Integer_overflow
I0d636e439:Add Sanitizer libs up the dependency tree
If113de7bc:Introduce toolchain features for sanitizers

Change-Id: Idf7e7b62f6fb6d4ff92341cc4c9c4b7426b70951
2022-11-28 22:44:35 +00:00
Trevor Radcliffe
548fc5dcec bp2build conversion for Sanitize.Integer_overflow
and Sanitize.Misc_undefined.

Bug: 253428057
Test: Unit tests
Change-Id: Idd9b33e537d1b1c80b0c96a9590327dae13fada7
2022-11-28 19:31:34 +00:00
Trevor Radcliffe
4e503ec09d Merge "Split ldflags in bp2build" 2022-10-07 17:31:29 +00:00
Trevor Radcliffe
82dd855229 Update tests for cc_* converters
Forgot to update these tests when doing aosp/2233406

Bug: 249175838
Test: Unit tests
Change-Id: I50fbf7c232d0a7aec72af83bcbe805d785f82897
2022-10-03 20:27:27 +00:00
Trevor Radcliffe
ea6a45deda Split ldflags in bp2build
But do the splitting before adding $(location...) flags.

Fixes: 247830974
Test: Unit tests
Test: m nothing
Change-Id: I4a7e8e20f720a1074a5ffa17da4fe9b96ca6ed58
2022-10-03 20:10:08 +00:00
Trevor Radcliffe
cee4e056aa Enable bp2build for cc modules relying on sysprop
Bug: 244439349
Test: m bp2build
Test: Inspect BUILD.bazel files
Test: Unit tests
Change-Id: I85bfb9fa69cb3f96b15bdbeb797dba86b3349804
2022-09-19 23:38:33 +00:00
Liz Kammer
baced71cd2 Add libbuildversion in converion instead of macro
Test: bp2build.sh
Change-Id: I96fa6e4dda7d54224a20bcb35414d61c6f70cf7e
2022-09-19 11:57:10 -04:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
a56e97042c Support suffix property in bp2build
Support this in cc_{binary,library{,_shared}}

Bug: 204811222
Test: Suffix additions to cc_{binary,library{,_shared}}_conversion_test.go
Test: mixed_{libc,droid}.sh also builds newly allowlisted
Change-Id: I596694794b01b04c542cbcd7d54baeb7d914ba50
2022-08-31 18:06:21 +00:00
Cole Faust
5fa4e961fb bp2build support for instruction_set
Convert `instruction_set: "arm"` to an
"arm_isa_arm" bazel feature.

Bug: 215719349
Test: go tests
Change-Id: Ib976d23d2a57e8c0ab5d83ec994a0b7f3c69a7fe
2022-08-26 10:13:34 -07:00
Cole Faust
6b29f593ea Bp2build support for runtime_libs
Bug: 213201180
Test: Updated the minimal apex in the build/bazel cl to include runtime_libs so the apex diff test will test it
Change-Id: I10add1895cfa122a370d24196a33ec2dcfafccfc
2022-08-17 15:20:17 -07: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
Liz Kammer
dfeb120324 Handle restricting to device only builds
By default, most module types are only enabled for device. Converting
this behavior and host_supported/device_supported properties allows us
to skip building incompatible targets.

Test: soong tests
Test: bp2build.sh
Change-Id: If1da523b4cc8c4cbf2bb26da063d9923b662cc32
2022-05-31 17:46:48 -04:00
Trevor Radcliffe
ef9c900ec3 Generate genlex rules from bp2build for cc targets
This change will cause bp2build to generate genlex targets any
time a .l or .ll file is present in the srcs for a cc target and
add those genlex targets to the srcs attribute of the original
target.

Bug: 207408632
Test: unit tests
Change-Id: I1bce82c9d3c3d458eae1cef547ffae3d6e975134
2022-05-24 14:42:51 +00:00
Yu Liu
a79c946fb0 Support use_version_lib in cc_binary.
Bug: 208481704
Test: Add unit test
Change-Id: I7cf299dd6b3287974067234687b3b2495a85d31e
2022-04-15 15:45:06 -07:00
Yu Liu
fc603167f4 Support tailoring clang --target flag based on min sdk version.
Bug: 215748260
Test: Tested using aquery to verify the --target flag; add added unit

Change-Id: Ifb13509db7d1e110316aa44d55ec9cccaa4b83d1
2022-03-18 01:16:52 +00:00
Liz Kammer
7756c8f20e Correct bp2build canonical_from_root logic
The logic was inverted from what it should have been,
canonical_from_root --> no strip_import_prefix attribute.

Test: build/bazel/ci/bp2build.sh
Test: build/bazel/ci/mixed_droid.sh
Change-Id: Ic6685d8f0b88279d4444bab3b5e03a544d225f77
2022-02-15 09:54:57 -05:00
Sam Delmerico
75539d62ae add target_compatible_with stanza for host targets
Soong modules that are specific for the host platform (e.g.
java_library_host, cc_binary_host, java_genrule_host, etc.) should
not be built on the target platform (Android), so we add a
target_compatible_with attribute to skip this type of module on an
Android target build.

Bug: 215229742
Test: go test ./bp2build
Change-Id: Ifb76ef4e0dc4cb3adb6a64b5c375ce36f7973e48
2022-02-03 19:25:12 +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
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
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
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
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
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