The data attributes for cc library rules is dropped by their starlark
macros, so serves no real purpose. Furthermore, this unused dependency
proves problematic for allowlist v2, as there are many cases at HEAD
where the corner-case "requires" dependency would otherwise mark a module
as unconvertible.
Fixes: 303307456
Test: New unit test
Test: Manual verification to unblock allowlist v2 `bp2build.sh` runs in
AOSP
Change-Id: I6ca6104b958d2b428fc2ca5b3fa794106571acca
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
This module type is used by a single soong module - `common_libc` in
bionic/libc
Implementation details
- Convert this module type to ndk_headers rule. Bazel's ndk_headers rule
will have a boolean attribute `run_versioner` to determine if
verioner should be run on the headers
- Add this module type to the alwaysConvert bp2build list
- Add the converted target for `common_libc` to the deps of
`ndk_sysroot`. This ensures that unbundled apps link against the
versioned NDK headers of libc
Test: go test ./bp2build
Test: b build //bionic/libc:common_libc --config=android
Test: for f in $(find bazel-bin/bionic/libc/common_libc.versioned -type f); do cmp $f ${f/bazel-bin\/bionic\/libc\/common_libc.versioned/out\/soong\/ndk\/sysroot\/usr\/include}; done # no diff
Bug: 301169067
Change-Id: I55be202f0589db9bdc743c8be41c9c5afd74c352
bp2build tests should not use bp2build_available:false test deps,
because, with the "allowlist v2" feature, this will cause these modules
to stop being converted with bp2build. Instead, such test deps should be
"stubbed", which effectively treats them like targets in pre-existing
BUILD files on the filesystem.
Bug: 301312260
Test: m nothing
Change-Id: Ib1ce7c87cd1e98568fdaf2a52a893dafa74ab327
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
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
ndk_libary will be converted to a cc_stub_suite target. Its api_surface
attribute will be publicapi
The headers corresponding to this stub target will be added in a followup bug
(tracked in b/300504837)
Bug: 298085502
Test: Added a unit test
Change-Id: If9745083b18e0bcf5ecb89229a0f709b949d401c
Ignore-AOSP-First: ag/24746588, in the same topic, is in an internal repo. This CL will be cherry-picked to AOSP afterward.
Test: go test
Bug: 277091218
Change-Id: I389d9535ea176991a1faa9beb46352b93363acd2
Merged-In: I389d9535ea176991a1faa9beb46352b93363acd2
cc_stub_suite now has an additional attribute correponding to the api
surface. This attribute will be used to pass additional args to the stub
generator.
Update bp2build to set the api_surface of the apex stubs. This ensures
that its stubs are generated with "--systemapi --apex"
Test: unit tests
Bug: 298085502
Change-Id: If4c479f85e6e485b5c795a565a0c559f1f013bf5
For a dependency edge A --> B (stublib), Soong will link A's platform
variant against impl of B's platform variant if either of these are true
1. A and B have same apex_available
2. B has bootstrap: true
3. B is only available to platform
(3) was missing from bp2build. This CL adds that.
To implement this, we check the `apex_available` property of B.
Test: updated bp2build tests
Test: Built the internal module b/299191635 that was failing due to this
Bug: 299191635
Change-Id: Iafb173a3ab20d69b89f7949ce40c6f4096396f24
For explicit values of compile_multilib (e.g. 32 or 64), add an
incompatibilty constraint for the arches that do not have the correct
bitness.
Test: go test ./bp2build
Bug: 299135307
Change-Id: I4cd997de6804a5c6d89086d740f773936db1cab9
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
A single proto providing directory can be used by multiple soong modules. Some of these
can be
1. Host specific
2. Device specific
3. Both host and device
Since the generated proto_library can have 1:many mapping, it should
have an empty target_compatible_with. Compatiblity will be enforced at
the top-level {cc|java|python}_proto_library.
(This is a followup to aosp/2727054 which did not handle this correctly)
Test: Added a unit test
Change-Id: I09b3def70e3d043fd8ba0d1eb4ffff1910f097d1
The fixes are
- Dedupe the dir list. Since we partition the proto srcs per pacakge and
then iterate the map, a single include directory was being listed
multiple times
- Drop target_compatible_with from these proto_library targets. The
compatibility will be enforced at the top-level <lang>_proto_library.
Test: Added a unit test
Change-Id: Ia18c0f8c495585010fd4e372092afe80c5d8290c
This is a followup to aosp/2711093 which added support for
proto.include_dirs. local_include_dirs is simlar, except that is
relative to the module directory.
Test: go test ./bp2build
Bug: 285140726
Change-Id: I32ddc7371048672d6935f827c8aee9d767305e2c
This is a fix similar to aosp/2707793. This adds manual tags to the
top-level proto_library created in the root package, plus any
dynamically created proto_library targets for proto.include_dirs. These
proto_library targets might not specify their deps correctly and might
be unbuildable.
(We need to keep these targets because they provide a ProtoInfo for
cc/java/py source gen)
Test: go test ./bp2build
Change-Id: Ic00f05186327fcfcc8d33a0a2c0891ed619b7acb
Soong's proto.include_dirs becomes the -I path for aprotoc cpp code
generation. This does not translate well to Bazel because it runs this
action in a sandbox. Even if we construct an -I path, the .proto files
will not be there. This CL attempts to handle this kind of dependency
automatically via bp2build.
For this hypothetical example
```
foo.proto # contains `import bar.proto"
Android.bp # cc_library {srcs:"foo.proto", p.include_dirs:["subdir"]},
subdir/bar.proto
```
Implementation details for CcProtoGen of foo
- Glob the labels of .proto files for each includeDir, and create a
proto_library that encapsulates them.
- Since Bazel poses a contraint that proto_library target needs to be
in the same pacakge as the .proto file, the proto_library might be created
in a subdirectory with an import_prefix
- Add bar's proto_library as transitive deps of foo's cc_proto_library.
This will be added to -I during aprotoc. We cannot add them to `deps`,
otherwise bar's symbols will be statically linked into foo's .a
file.
Implementation details for clang compile of foo
At the end of CcProtoGen, we have converted foo.proto
to .cpp/.h files. To compile them to .a files, we need the .h files
generated from bar.proto. Soong specifies this at the
top-level cc_library soong module, so add those deps as the
implementation deps for clang compile.
(Will add support for java in a follow-up CL)
Test: go test ./bp2build
Test: built some internal modules that were previously blocked by this
Bug: 285140726
Change-Id: I7e1f9f0d1b1ba916a7ba8278f6cfb342b381d695
This is a fix for aosp/2693190 that handled .proto files that end up in
different bazel packages. It did it by creating proto_library targets in
the correct bazel package.
Changing the granularity causes issues if the the new proto_library in
the subpackage imports a .proto file from a parent package or a
different package. e.g.
```
tmp
├── foo.proto
└── subdir/import_foo.proto # contains an `import "foo.proto"`
└── subdir/Android.bp # package boundary
├── Android.bp # contains a cc_library with foo.proto and
# subdir/import_foo.proto
```
At ToT, the ProtoInfo we provide to CcProtoGen is correct, but the
proto_library in subdir/BUILD will not compile because it does not have
a dep on the proto_library in ./BUILD
This CL creates a workaround by adding `manual` to the proto_library
targets. This CL is based on the assumption that the buildable unit in
bp2build is cc_library_*, and not proto_library necessarily (atleast
till we do a manual/automated cleanup)
Test: Created an integration test in build/bazel
Test: go test ./bp2build
Bug: 292583584
Bug: 246997908
Change-Id: I73120be2411967cb144f37ed4417f76ecf1a6ffa
Protos in another directory were using import prefix, which was
prepending the repository-relative path with the value, instead, we want
to strip the prefix of the directory of the module the protos were used
in such that they can be referenced at the appropriate relative path.
Reference on import_prefix:
https://bazel.build/reference/be/protocol-buffer#proto_library.import_prefix
Test: b build //packages/modules/adb:libfastdeploy_host
Change-Id: If050b0f5fc5103bd9cc5a99703bd604325aa4204
* changes:
Handle .proto files in different package for filegroups
Handle .proto files that end up in a different package
Allow creation of BazelTargets in a different directory
Followup to aosp/2693190, this CL adds the support to filegroups.
<mod>__bp2build_converted is now an alias to a proto_library
target <mod>_proto. This proto_library will be created in a different
package if the .proto file exists in a different package.
Test: bp2build unit tests
Test: TH
Bug: 292583584
Change-Id: I8ca452aacf1a86dfc9e218464e38aab89afa5a29
Bazel poses a strict requirement that .proto files and proto_library
must be in the same package. This CL handles this automatically by
creating the proto_library in a separate dir/package if necessary
Implementation details
- Partition the `srcs` by package. `srcs` has been computed using
`transformSubpackagePath`, so the information about packages is
available at this point
- Create a proto_library in each package by using
`CommonAttributes.Dir`. Collect all these additional libraries
and put them in `info.Proto_libraries` so that they get added as deps
of (cc|python|...)_proto_library
- Add an import_prefix to the proto_library in subpackages relative to
the current directory. This relies on the assumption that every src is
beneath the current directory (Soong will complain if a path in
Android.bp contains ../)
filegroup module type uses a separate code-path to create proto_library.
This will be handled in the next CL in stack.
Test: bp2build unit tests
Test: TH
Test: Built the failing internal module mentioned in
b/292583584#comment1
Bug: 292583584
Change-Id: I437fc89092321b26c5f0511387cde9e84084d6f9
...instead of based on constraint settings.
Bug: 269577299
Test: m nothing and ./build/bazel/ci/bp2build.sh
Change-Id: Ib9caec79c92b8fd304e46be841de5612bd1637e3
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
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
host_ldlibs are used during linking. Set these in `linkopts` for now.
Note that this CL does not do the `CheckBadHostLdLibs` validation of
Soong. There are some different ways to do this, and these are being
discussed in b/216626461. It is likely that we will need to create a new
property `host_ldlibs` to do the validation. But for now, re-use
`linkopts`.
Bug: 216626461
Test: bp2build unit tests
Change-Id: Id4c77e4460fb1fb003fa58ea27bab5b50ea8cefe
https://source.android.com/docs/core/architecture/aidl/aidl-backends#custom-parcelables
Some aidl files have custom parcelables with references to cpp headers. Hence, we need to pass the include dirs from cc libs to cc_aidl_library so that custom cpp headers are findable by the generated cpp/h files.
Test: go test
Bug: 278704136
Change-Id: I4ede1d23fbc04bdbfb69823d955c6df6b0a7b4ee
Introduce aidl.libs prop on cc libraries to pass in aidl_library. The goal is to eventually disallow aidl.include_dirs (a pattern for passing aidl headers dir for aidl compilation) and enforce aidl headers to be explicitly specified in Android.bp.
Bug: 278704136
Test: go test
Change-Id: Ia78bc11dfa12f47d2d1bb90dc65372ddb17f7e14
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
For cc_libraries containing .y/.yy srcs, we will generate an additional
cc_yacc_static_library target. This target will produce an .a file that
will be statically linked to the parent target.
Test: go test ./bp2build
Bug: 281546029
Change-Id: I094ba56f0a95869e5bc1e1d38b83c777192b7ddd
Create a select statement for every api_domain a library could be
included in. The stub/impl
selection heuristics per apex domain are
1. If dep has stubs and the api domain appears in dep's apex_available, use
impl
2. If dep has stubs and the api domain does not appear in dep's
apex_available, use stubs
(Category 3: If dep does not have stubs and the apex does not appear in
dep's apex_available, then a separate apex_available validation in Bazel
will emit an error).
Platform variants have been special-cased for now to use equality of
apex_available for stub/impl selection
Test: go test ./bp2build
Bug: 272378496
Change-Id: Ibd29efd763c8863c7e6d2a9af0da30bbde07175d
The use case for this is for creating a select statement for stub/impl
selection. Since Bazel propagates apex_name from the top-level apex,
the source apex and test apex builds a specific library in two different
configurations. We need select statements for both these two
configurations, but this metadata might not always exist in Android.bp
since test apexes are not necessary to be listed in Android.bp files.
To overcome this, the select statements will be created per api domain
instead. This CL uses a naming convention to infer the api domain of
apexes.
Test: go test ./bp2build
Change-Id: Iad2b45f736bc98a24d2ce1cf2f69aad67973092d