Commit graph

51 commits

Author SHA1 Message Date
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
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
Spandan Das
af72583468 Generate a ndk_sysroot target in bp2build
This target will have a dependency edge to every bp2build equivalent of
Soong's ndk_headers. In b builds, sdk variants will compile against this
aggregated CcInfo providing target

A non monolithic alternative was discarded after conversations in
b/300504837#comment1-5

Contents of bp2build generated target: https://paste.googleplex.com/6643820291686400

Implementation details
- Since there is no equivalent Soong module for ndk_sysroot, hardcode
  bp2build/build_conversion.go to collect all ndk_headers soong modules.
  Add them to `deps` of a ndk_sysroot target
- Create `ndk_sysroot` in build/bazel/rules/cc/BUILD.bazel. This is
  expected to be a temporary location. This will use the
  cc_library_headers macro
- Update SetStubsForDynamicDeps so that sdk variant of rdeps depends on
  //build/bazel/rules/cc:ndk_sysroot. This will provide a CcInfo during
  compilation. Since ndk_sysroot is of type cc_library_headers, it will
  not get packaged into the apk.
- Refactor `goBazelTarget` to a generic `bTarget` so that it is
  representative of the expanded usage by ndk_sysroot

Test: b build //build/bazel/examples/android_app/java/com/app:app_with_sdk_variant_of_jni_deps --config=android (with aosp/2755284)

Bug: 300504837

Change-Id: Ifa427dd78115703ab251b0e1a0b71d3f19e91008
2023-09-25 21:27:19 +00:00
Liz Kammer
e1b39a5286 Handle prebuilt vs source selection in bp2build
Test: enable mainline modules build from prebuilts and build
Bug: 300640274
Change-Id: Ib1d6bbca7e0ab459515d3cf6378741e8368e7327
2023-09-19 16:04:39 -04:00
Liz Kammer
86a407f284 Always convert prebuilt cc library headers
Test: go tests
Test: CI
Test: patch in CL using prebuilts for mainline modules and build
Bug: 300640274
Change-Id: I73f70dac679e341670e1484ce57bc984f413d409
2023-09-19 15:58:20 -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
Sam Delmerico
130d75b6b3 export SimpleModuleDoNotConvertBp2build for AIDL
Bug: 298246873
Change-Id: I06ed7bb8fc1139731a2b48440a91aeb7f383efff
2023-09-10 19:05:54 +00:00
Chris Parsons
73f411b72c Delete ApiBp2build soong_build mode
This feature is obsolete.

This makes a large number of codepaths "dead code" (such as
module-specific implementations of ApiBp2build functionality). These
will be deleted in a followup CL.

Bug: 284029211
Test: Presubmits
Change-Id: Ib53b99f1fe8c24380d219caf44e9bb3b96724fa0
2023-09-05 17:09:51 -07:00
Zi Wang
9f609db46a Add variant_prepend support for all the properties in bp2build
This is a follow up of aosp/2336916. All the properties that have
variant_prepend tag are supported in bp2build.

Bug: 261644490
Test: TH and modified tests with updated expected behaviors
Change-Id: I13bb5d4d8fcd38bf153fa9083c9c945aec2dfa19
2023-01-04 11:19:50 -08:00
Colin Cross
133782e4bb Use //build/bazel/platforms/os:linux_glibc for osLinux
osLinux is implicitly glibc, use //build/bazel/platforms/os:linux_glibc
for the configurability select key for it.

Bug: 259266326
Test: build/bazel/ci/mixed_libc.sh
Test: USE_HOST_MUSL=true build/bazel/ci/mixed_libc.sh
Change-Id: Ifbd121ab3d943f3fdfbd3f6c3e982d1eaaaa9ec1
2022-12-20 15:29:31 -08:00
Zi Wang
1cb11800f7 Add support for variant_prepend properties in bp2build for cc library
Some properties in soong are marked "variant_prepend", which means
in bp2build output, variant properties(select ...) should come before
general properties.
Prepend property is added in StringListAttribute
stuct so that bp2build can handlle variant_prepend properly, if
Prepend is properly set in different module logics.
This change also coordinates cc library with Prepend.
Coordination with other module types will be in separate CLs.

Bug: 261644490
Test: TestCcLibraryHeadersSimple,
TestCcLibraryHeadersArchAndTargetExportSystemIncludes and TH

Change-Id: I3b61c491c54bbe91ba9aa2af9b4c84193c91ae7f
2022-12-09 16:41:23 -08:00
Spandan Das
4238c65a17 Converters for contributions to systemapi and vendorapi
The module types in scope of this conversion are
1. cc_library and cc_library_shared (non-null llndk or stubs prop)
2. cc_library_headers (all)

For (2), we need some postprocessing on the results of the parser
bp2BuildParseBaseProps. This is necessary because arch and os specific
API exports need to be flattened and added to the generateed API headers
target along NoConfigAxis
e.g.
```
The api equivalent of
cc_library_headers (
  name = "lifoo",
  deps = select({
  	"//build/bazel/platforms/arch:arm": ["arm_deps"],
  	"//build/bazel/platforms/arch:arm64": ["arm64_deps"],
	}),
)
should be
cc_api_library_headers (
  name = "lifoo",
  deps = ["arm_deps", "arm64_deps"],
)
```

For (1), we also need to generate 1:many header api targets so that
arch-specific deps can propagate arch metadata to the top-level
api_domain rule

Test: go test ./bp2build
Test: go test ./cc

Change-Id: Ie40cba1ac8e89f290b3d926c190d5e93abd52859
2022-10-07 23:48:00 +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
Trevor Radcliffe
7f897fcef0 Reexport whole_static_libs in cc_library_headers
Fixes: 236268577
Test: Unit Tests
Change-Id: I3a13f850d1d593b90c79f668f1eaf5be0035db1f
2022-08-18 15:53:00 +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
Trevor Radcliffe
2be7f54b45 Add support and tests for export_*_lib_headers
There are 3 different properties about exporting headers in Soong:

1. export_static_lib_headers
2. export_shared_lib_headers
3. export_header_lib_headers

The static and header cases are already supported in bp2build but
do not have tests. This CL adds support for the shared case and
adds tests for all cases.

Fixes: 236268577
Test: Unit tests
Change-Id: Idfb788271e607919d4ac6bc0e4eb4e6ff8f78e8d
2022-06-29 15:25:01 +00:00
Trevor Radcliffe
fb6c522420 Remove implementation_deps from cc_library headers
Don't add implementation_deps to cc_library_headers in bp2build

Fixes: 236404654
Test: unit tests, USE_MIXED_BUILDS=1 m
Change-Id: I0f6a35c10284f261b6a8b7a4831655d5fa084977
2022-06-21 22:34:11 +00: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
718eb27f5b Delete toolchain_library
Test: m && ci
Change-Id: Iab5267e02e3559431d980c70a58b49c2b8b4e6de
2022-01-14 12:52:59 -05: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
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
7a210ac233 bp2build: Add support for export_.*headers props
Soong supports export_.*_headers properties, the libraries contained in
this list must also be within a shared/static/whole_static/header libs
property. For bp2build, we eliminate this duplication. The libraries
not listed in an export_.*_headers property will migrate to an attribute
prepended with implementation_, those in export_.*_headers will not have
a prefix.

Test: build/bazel/ci/bp2build.sh
Test: build/bazel/ci/mixed_libc.sh
Bug: 198241472
Change-Id: I3eb84c983ec5d241c8a568e411dfd5619d3184a7
2021-09-23 16:07:45 -04:00
Liz Kammer
35687bc77a Split local/absolute include into attributes
Previously these were expanded into copts, requiring making all includes
absolute and duplicating includes to account for potentially generated
files. We now can handle both of these properly on the Bazel side, so
let's clean up build files a bit.

Test: bp2build.sh
Change-Id: I6c6160738cd6c269408c6c7a37010654d84f3c9d
2021-09-13 12:49:42 +00:00
Liz Kammer
8337ea4e7d Cleanup bp2build tests to reduce repetition
Test: go test bp2build tests
Change-Id: Ia96a1a8ed58d5be13fedf31e1667670efdfe3aef
2021-09-10 10:14:09 -04:00
Liz Kammer
5fad501aeb bp2build: Split export_{includes,system_includes}
The specification of exporting includes vs system includes has an impact
on inclusion sort order. Conflating the two caused some symbols to not
be resolved correctly.

Bug: 198403271
Test: build/bazel/ci/bp2build.sh
Test: USE_BAZEL_ANALYSIS=1 m libbacktrace_no_dex succeeds with libc++_*
      modules removed from mixed build denylist (would fail otherwise)
Change-Id: I08aff253d8962dc678ed10214b1c171330e0fe19
2021-09-09 15:59:05 -04:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
1c92aeff4e Share runBp2BuildTestCase & runPythonTestCase
Pull along bp2buildTestCase as well
Because none are specific to their current hosts

Move `errored` up to the "generic" block vs.
the "custom" block

Test: Existing tests pass
Change-Id: Ie8d5322a5554ebd88f0c142a4c541791687be326
2021-08-23 19:20:29 +00:00
Christopher Parsons
2f1102fe58 Merge "Remove bp2build deps mutator" 2021-07-23 14:55:40 +00:00
Chris Parsons
5a34ffb350 Remove bp2build deps mutator
Refactor bp2build to retrieve modules directly by name, instead of via
DirectDeps. This functions properly as bp2build has no need for variant
information of the blueprint graph.

Test: USE_BAZEL_ANALYSIS=1 m fmtlib
Change-Id: Ief4b67bc56f24929871af772f3a742f07085bf8c
2021-07-22 18:09:34 -04:00
Colin Cross
cb0ac95bde Remove Fuchsia support from Soong
Bug: 194215932
Test: m checkbuild
Change-Id: Id7d3964d9417f8b0938af9b168bb4c00cebe9390
2021-07-21 20:37:46 -07:00
Liz Kammer
d366c909ca Handle no_libcrt in bp2build.
Test: ci/bp2build.sh
Bug: 187928307
Change-Id: Ib80c4318169652b322e5d878c8784679e42f87dd
2021-06-08 17:18:22 -04:00
Liz Kammer
e4982e8828 Mark test helpers as helpers.
This enables identifying the correct location of test failures.

from godocs:
Helper marks the calling function as a test helper function.
When printing file and line information, that function will be skipped.
Helper may be called simultaneously from multiple goroutines.

Test: go test bp2build tests
Change-Id: I52430e541494c78f5222c11510a4d273fe205a06
2021-05-25 14:41:43 +00:00
Lukacs T. Berki
c1cc3b9678 Split each test case to a different test function.
This is so that they can be individually debugged.

Test: Presubmits.
Change-Id: I7d929c4126bba7470aaa1c0def85bad65429ffdc
2021-05-23 20:41:14 +02:00
Chris Parsons
d6358775c8 Propagate unexported deps via implementation_deps
Test: bp2build and mixed_libc CI
Test: Manually verified that libc_bionic_ndk compilation gets the
appropriate headers (and no extra headers) from downstream

Change-Id: I79eb6e8ec1d415bd50d12105da4cf97101f95474
2021-05-20 12:05:24 -04:00
Rupert Shuttleworth
06559d07cb Move some implicitly shared testing code for bp2build into testing.go.
Test: go test
Change-Id: I403d703184e517dbffbdccb8007229cad00858c1
2021-05-19 09:14:26 -04:00
Chris Parsons
484e50aa7c bp2build: support generated sources and hdrs
There are two pieces to make this work:
1. Local include paths must include $(BINDIR)-relative paths, to support
generated headers in those directories.
2. The srcs that bp2build outputs for BUILD targets must include labels
for targets given in generated_hdrs and generated_srcs.

Support for exported_generated_hdrs intentionally deferred.

This allows us to remove several targets from the bp2build denylist.
Some are moved to the mixed build denylist, because genreated headers are
still unsupported in mixed builds.
Test: bp2build.sh CI script

Change-Id: Ib4f9dac20f6445487b8dad53b91eac01f437a590
2021-05-17 14:30:07 -04:00
Jingwen Chen
882bcc1c1c bp2build: remove header globs in generated srcs.
Not needed anymore for bp2build-incremental since https://android-review.googlesource.com/q/topic:no-include-check.

Not needed for mixed builds either, since cc compile actions aren't sandboxed.

Fixes: 186488830
Test: treehugger and go tests

Change-Id: Ib5d4908dcce6bf910a653c457bb251d726e717d4
2021-04-27 06:26:40 +00:00
Rupert Shuttleworth
375451edfe Add support for per-target exported includes.
Test: Added unit test
Change-Id: I8ab58ddc73c15d5ec0f515e43407542bd4e8081a
2021-04-26 07:49:08 -04:00
Jingwen Chen
ed9c17d033 bp2build: refactor/standardize cc_* bp2build converters
This CL refactors the cc* bp2build converters to use the common
attribute extractors in cc/bp2build.go.

This also adds include_build_directory to be handled by the compiler
attr extractor to generate recursive headers as inputs.

This also turns include_dirs and local_include_dirs into the
execroot-relative -I flags.

e.g. if a module in  bionic/libc has "private" in local_include_dirs,
the "-Ibionic/libc/private" copt is generated for it.

Fixes: 185139955

Test: TH
Test: Forrest for mixed_clean-droid
Change-Id: Ib67056482227e62068fbbea0455035bdf5d56319
2021-04-22 08:31:24 +00:00
Jingwen Chen
b4628eb03f bp2build: codegen singleton lists on one line.
This CL refactors the bp2build code generator to pretty print lists with
a single element on one line, instead of taking up three lines, which
can make BUILD files unnecessarily long. A single line singleton list is
also more commonly used in BUILD files.

Test: TH
Change-Id: Ic9e44741bbb070c8f45925466b9ccdd0608498b2
2021-04-09 09:42:57 +00:00
Jingwen Chen
6393098ecf bp2build: cc_library converter for //bionic/libdl:libdl_android
This CL contains the converter for libdl_android, a cc_library that
expands into a cc_shared_library and a regular cc_library.

Test: TH
Test: bp2build; bazel test //build/bazel/tests/...

Change-Id: If70641a538211b0d6b2aac0e4d0d06912318304d
2021-04-09 09:42:53 +00:00
Rupert Shuttleworth
64a90286c4 Merge "Support arch variations for export_system_include_dirs in cc_library_headers bp2build converter." 2021-04-08 00:54:47 +00:00
Rupert Shuttleworth
b815168474 Support arch variations for export_system_include_dirs in cc_library_headers bp2build converter.
Test: Added unit test
Test: bp2build-sync.py write; bazel build //bionic/... works for more cc_library_static targets (in a parent CL)
Change-Id: Ib487216a4bcbc52958ff948722dae347b0d8b606
2021-04-07 16:05:44 +00:00
Ryan Prichard
3f3bb83f81 Merge "Remove libgcc toolchain libs for Android" 2021-04-06 21:43:33 +00:00
Ryan Prichard
c2018e2ed4 Remove libgcc toolchain libs for Android
Remove Android-targeting gcc toolchain libraries -- libgcc,
libgcc_stripped, libatomic, and libgcov. Also remove libunwind_llvm,
which is replaced with a libunwind toolchain prebuilt.

The __atomic_* library functions are now part of the compiler-rt
builtins library:

https://android-review.googlesource.com/c/toolchain/llvm_android/+/1625025

Bug: http://b/153025717
Test: treehugger
Change-Id: I971d0a4a49f1aaeb3546e80b6d94208277a171ac
2021-04-02 21:07:35 -07:00
Jingwen Chen
91220d7334 Add os/target configurable selects for label list attributes.
This CL is pretty large, so I recommend starting with reading the newly
added tests for the expected behavior.

This change works in conjunction with the linked CLs in the Gerrit topic.
Those CLs add support for new platform() definitions for OS targets
specified in Soong's arch.go, which are configurable through
Android.bp's `target {}` property. It works similary to previous CLs
adding support for the `arch {}` property.

These configurable props are keyed by the OS: android, linux_bionic,
windows, and so on. They map to `select` statements in label list
attributes, which this CL enables for cc_library_headers' header_libs
and export_header_lib_headers props.

This enables //bionic/libc:libc_headers to be generated correctly, from:

    cc_library_headers {
        name: "libc_headers",
        target: {
            android: {
                header_libs: ["libc_headers_arch"],
                export_header_lib_headers: ["libc_headers_arch"],
            },
            linux_bionic: {
                header_libs: ["libc_headers_arch"],
                export_header_lib_headers: ["libc_headers_arch"],
            },
        },
        // omitted props
    }

to:

    cc_library_headers(
        name = "libc_headers",
        deps = [] + select({
            "//build/bazel/platforms/os:android": [
                ":libc_headers_arch",
            ],
            "//build/bazel/platforms/os:linux_bionic": [
                ":libc_headers_arch",
            ],
            "//conditions:default": [],
        }),
    )

Test: TH
Test: Verify generated //bionic/libc:libc_headers
Fixes: 183597786

Change-Id: I01016cc2cc9a71449f02300d747f01decebf3f6e
2021-04-02 08:17:34 +00:00
Rupert Shuttleworth
095081c6d7 Add bp2build support for cc_library_static.
Also refactor bp2build-related code for cc_library_headers.

(Retry of previous CL after the presubmit failed to detect a merge conflict)

Test: Added unit test.

Test: bp2build-sync.py write; bazel build //bionic/... still works (but bp2build is disabled for most cc_library_static targets for other reasons)
Change-Id: I2f4405c2fea305623bbc6daaaf62808b0c074216
2021-03-25 15:16:11 +00:00
Jingwen Chen
f9410540a8 Revert "Add bp2build support for cc_library_static."
Revert submission 1594391-bp2build-cc_library_static

Reason for revert: Broke the build on aosp-master
Reverted Changes:
Ib16ccf31a:Add cc_library_static macro to help with bp2build ...
I37c856be2:Add bp2build support for cc_library_static.

Change-Id: Ie94d5bc6da81758cd4e0461c08a810a29643c971
2021-03-25 06:11:59 +00:00
Rupert Shuttleworth
21e743df41 Add bp2build support for cc_library_static.
Also refactor bp2build-related code for cc_library_headers.

Test: Added unit test.

Test: bp2build-sync.py write; bazel build //bionic/... still works (but bp2build is disabled for most cc_library_static targets for other reasons)

Change-Id: I37c856be20a47b154909338a22a7dba1ab55693f
2021-03-24 13:56:44 +00:00
Jingwen Chen
ba369adff1 bp2build: Unexport GenerateBazelTargetsForDir.
Resolving a comment from aosp/1595678

Test: build/bazel/scripts/milestone-2/demo.sh
Change-Id: Ia7aba2b149fc09615fbafee67838632c71320f1b
2021-02-22 10:22:58 -05:00
Jingwen Chen
164e0867fc bp2build: add a simple UI to report migration progress.
Sample output:

[bp2build] cc_library_headers: 5 targets
[bp2build] cc_object: 5 targets
[bp2build] filegroup: 4 targets
[bp2build] genrule: 4 targets
[bp2build] sh_binary: 1 targets
[bp2build] Generated 19 total BUILD targets from 39270 Android.bp modules.

This CL adds an additional CodegenMetrics return value to
GenerateBazelTargets calls, which are called from bp2build, queryview,
and their tests. For this UI, we only want to use it for bp2build, and
not queryview or tests, since it's not useful for the former, and can
pollute the CLI for the latter.

Test: build/bazel/scripts/milestone-2/demo.sh
Change-Id: Ic84307a1ed1a25e360c9b23459e5449d932bc2e7
2021-02-19 09:30:11 -05:00