Commit graph

113 commits

Author SHA1 Message Date
Spandan Das
2b6dfb554d Support mechanism to select a specific version of module sdk prebuilt
This CL is scoped to cc_* module types. With trunk stable, we will have
multiple prebuilts of the cc modules in
prebuilts/module_sdk/art/<v>/host-exports/, and this CL introduces a
mechanism to use apex_contributions to select a specific versioned
prebuilt when building.

If a soong module is selected using apex_contributions, all rdeps will
get that soong module, which includes
- rdep soong modules which might be depending on it via Android.bp
- Soong's rule builder HostToolPath API

Implementation details: Create a new source_module_name property to
identify the root module. rdeps referring to the root module will get
redirected if necessary. This property also
becomes the stem, if `stem` is not set explicitly.

Bug: 322175508

Test: Added a unit test

Change-Id: Ic8725602c81999621fcb33ce2a57fe4b9751baa8
2024-01-26 23:32:13 +00:00
Colin Cross
402130276c Convert SetProvider to generic providers API
Convert all of the callers of SetProvider to use the type-safe
android.SetProvider API.

Bug: 316410648
Test: builds
Change-Id: If58f4b5355264ddab2045bc3591a4eac19cd58fc
2023-12-14 16:12:20 -08:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Chris Parsons
637458d326 Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.

Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
2023-09-20 14:49:35 +00:00
Colin Cross
c85750bfe3 Use generics for DepSets
Use Go's generics for DepSets so they don't require a type-specific
wrapper and reflection.

Test: depsets_test.go
Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
2023-06-22 08:18:33 -07:00
Spandan Das
39b6cc5336 Ignore test apexes from bp2build generated tags
Soong does not enforce apex_available on the contents of test apex. To
prevent special-casing test apexes in the apex validation aspect in
Bazel, drop the test apexes from the tags altogether.

( The core problem I am trying to solve is making sure that stub
libraries in Bazel have a single apex available. apex validation happens
to be a nice side benefit)

Bug: 277651159
Test: go test ./bp2build
Change-Id: Ibb3cfedb5c0f2cda0464bf3758c70b67cb5885d1
2023-04-27 23:24:49 +00: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
Jooyung Han
e5f063e85f Do not install prebuilt stubs from module_sdk
This is a rework of commit 5bdf2d589c
which made implementation variant of prebuilts with stubs as not
installable except libclangrt. This change narrows the affected modules
to prebuilts/module_sdk because cc_prebuilt_library_shared with stub
implementation is a special case only used there. It's typical for
cc_prebuilt_library_shared to have implementation, not stub.

Bug: 220898484
Test: ART_MODULE_BUILD_FROM_SOURCE=false m nothing
Change-Id: I99e5213da8cc473901e23942b50f06c023d91f60
2023-03-28 18:19:04 +09:00
Jingwen Chen
8ac7d7d01d Revert "Export non-apex variants of modules to make"
This reverts commit 502da3987a.

Reason for revert: b/274195633

```
In file included from out/soong/installs-aosp_cf_x86_pasan.mk:134984:
In file included from out/soong/Android-aosp_cf_x86_pasan.mk:981696:
In file included from build/make/core/soong_cc_rust_prebuilt.mk:76:
build/make/core/base_rules.mk:342: error: packages/modules/Uwb/service/uci/jni: MODULE.TARGET.SHARED_LIBRARIES.libuwb_uci_jni_rust already defined by packages/modules/Uwb/service/uci/jni.
```

Change-Id: Ic1ea6969e54c23a7d126eb0fb47ab6f2e44ee965
2023-03-20 11:05:16 +00:00
Cole Faust
502da3987a Export non-apex variants of modules to make
Currently, non-apex variants of modules that are in apexes are not
exported to make unless they're apex_available to the platform. This
means that you can't `m` those modules directly.

However, there is a workaround in the apex androidmk implementation that
emits make rules for the removed modules, but just redirects them to
build the apex itself. We want to remove that, but one of the problems
with doing so is that you can no longer `m` many modules afterwards.

To fix that, unhide the apex's dependencies from make. To ensure they're
not installed, call SkipInstall() on them, and update SkipInstall() to
be more strict by setting `LOCAL_UNINSTALLABLE_MODULE := true`.

Bug: 254205429
Test: Presubmits
Change-Id: Ib971981559f3b642ce6be8890679e994e1b44be0
2023-03-16 11:13:23 -07:00
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux
c353abdd53 Revert "Revert "Produce _alwayslink sibling targets through bp2b..."
Revert submission 2473787-revert-2467901-b/267214124-TLTTMLWFDS

Reason for revert: Fixed compilation errors

Reverted changes: /q/submissionid:2473787-revert-2467901-b/267214124-TLTTMLWFDS

Test: TOLIST
Bug: 271943047
Bug: 267214124

Change-Id: Ib08440377f6645cf26de4bda748d82c4dcd0b43a
2023-03-10 22:14:29 +00:00
Iván Budnik
295da16b95 Revert "Export non-apex variants of modules to make"
Revert submission 2462194-androidmk_for_apex_dependencies

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=full-eng&lkgb=9723453&lkbb=9724944&fkbb=9723508, bug b/272663333.

Reverted changes: /q/submissionid:2462194-androidmk_for_apex_dependencies

Bug: 272663333
Change-Id: I847fa910a8d54de19954f56fe92a80a9bcd0ee18
2023-03-10 16:11:26 +00:00
Cole Faust
ad222f271a Export non-apex variants of modules to make
Currently, non-apex variants of modules that are in apexes are not
exported to make unless they're apex_available to the platform. This
means that you can't `m` those modules directly.

However, there is a workaround in the apex androidmk implementation that
emits make rules for the removed modules, but just redirects them to
build the apex itself. We want to remove that, but one of the problems
with doing so is that you can no longer `m` many modules afterwards.

To fix that, unhide the apex's dependencies from make. To ensure they're
not installed, call SkipInstall() on them, and update SkipInstall() to
be more strict by setting `LOCAL_UNINSTALLABLE_MODULE := true`.

Bug: 254205429
Test: Presubmits
Change-Id: Ib094feb2c437ad50d8319c58caa997759e7ce32f
2023-03-09 11:20:10 -08:00
Wilson Sung
68e126ee62 Revert "Produce _alwayslink sibling targets through bp2build"
Revert submission 2467901-b/267214124

Reason for revert: compile error

Reverted changes: /q/submissionid:2467901-b/267214124

Change-Id: I2235fd1457fda60b4613d5512f7fb20b7044a2db
Fix: 271943047
2023-03-07 04:16:53 +00:00
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux
011b7cf063 Produce _alwayslink sibling targets through bp2build
Add Alwayslink to bazelPrebuiltLibraryStaticAttributes
Also adjust the corresponding tests to espect these new targets.

Test: m libc
Test: b build --config=android //prebuilts/clang/host/linux-x86:libunwind-exported_alwayslink
Test: bp2build.sh
Bug: 267214124
Change-Id: I4d996aef55321f1827947f00b0eaa52d0a14413e
2023-03-03 20:12:20 +00:00
Yu Liu
e43124023c Support DCLA
Bug: 240424572
Test: Manual tests:
1. m --dev-mode-staging com.android.adbd com.android.media.swcodec.
2. verify the DCLA libs from the two apexes have the same size and
   sha1sum, and also match the libs in bazel-out.
3. empty the DCLA libs list in allowlist.go and repeat step 1
4. repeat step 2 and verify the opposite result
5. build git_master: mainline_modules_bundles-userdebug in ABTD
   with the cl, then follow go/build-sideload-dcla-locally to
   download the adbd and swcodec aab files, run the DCLA trimming
   workflow locally, and verify the symlinks in the two trimmed
   apexes are identical and also match the lib path in the DCLA
   apex that was created by the workflow.

Change-Id: Ib2f8a29126a54829c0e10eba17b256a79930fd70
2023-02-21 10:12:47 -08:00
Sam Delmerico
4ed95e263f mixed build targets need transitive tidy files
Previously in mixed builds, only the tidy files for the boundary module
were built, whereas all of its transitive dependencies' tidy files were
not being built. Instead we should export the list of transitive tidy
files for a module so that we can run clang-tidy for the boundary module
as well as its dependencies.

Bug: 195029134
Test: WITH_TIDY=1 DISABLE_ARTIFACT_PATH_REQUIREMENTS=true mss tidy-packages-modules-NeuralNetworks --bazel-mode-dev
Change-Id: I463646d2ae1fc4aa075a54c264e1c34571c3fd5c
2023-02-07 16:50:30 -05:00
Sam Delmerico
5fb794ae37 clean up CL for androidmk variables
Change-Id: If14d1925bea78f467740f8395f1d529db00b618c
2023-01-27 16:01:37 -05:00
Treehugger Robot
4520481c6a Merge changes I07db8afc,Ia89e0239
* changes:
  Stop module types being SdkAware
  Replace usages of SdkAware in sdk module with Module
2023-01-07 14:46:22 +00:00
Paul Duffin
d796f6f6dc Stop module types being SdkAware
Removes all usages of SdkBase and InitSdkAwareModule.

Bug: 260237150
Test: m nothing
Change-Id: I07db8afc805eadbeb5b23f2e1d2f51567eecfab0
2022-12-12 17:33:06 +00:00
Colin Cross
c5075e917e Add bp2build support for cc_prebuilt_object
Add bp2build support for cc_prebuilt_object to allow buiiding
musl crt objects that use prebuilt clang_rt.crtbegin and
clang_rt.crtend.

Bug: 259266326
Test: //extenral/musl:libc_musl builds
Change-Id: Ic2b0375bc6e7336d31c9e2cf51bdc2ea894185aa
2022-12-09 13:58:58 -08:00
Jingwen Chen
8ec23f846d Merge "Convert apex_available (for supported modules) to bazel tags." 2022-12-02 07:22:10 +00:00
Jingwen Chen
c4c34e1eab Convert apex_available (for supported modules) to bazel tags.
The tags will then be read by an aspect applied from apex attributes to
validate that the deps are explicitly opt-in to the appropriate apex.

The semantics of this is the same as the Soong apex_available property.

This also adds the "base_apex_name" attr to override_apex conversion so
that apex_available checks continue to work on the non-Google and non-Go
apex names.

Test: presubmits
Fixes: 218841706
Change-Id: I19b3637da9aa47573b252d74f62b601fbdc3784d
2022-12-01 06:25:25 +00:00
Liz Kammer
2c1d6aae37 Update sanitize to not modify user properties
Test: m nothing before/after and compare build.ninja (no diff)
Change-Id: Ia165e4beea0b34417f873247b592837a152d45cd
2022-11-22 13:14:39 -05:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
c5184ec089 Rename prebuilt_library_* to cc_prebuilt_library_*
Follow the convention of everything else in `cc`

Test: CI
Change-Id: I133d0b7119d4e9b357aada3467bc079f20dc0f60
2022-10-20 14:51:55 +00:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
256e3b4597 Support mixed building for cc_prebuilt_binary
Enable cc_prebuilt_binary to also take part in mixed builds.

Bug: 241415823
Test: TestPrebuiltBinaryWithBazel
Test: mixed_droid yields stats-log-api-gen under bazel-out/
Change-Id: I18b2906c91ea90370ab851a1287c2890546d633f
2022-10-11 18:13:54 +00:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
b12ff59f0b Support cc_prebuilt_binary building with Bazel
Bp2build-enable cc_prebuilt_binary -> cc_prebuilt_binary

Bug: 241415823
Test: cc_prebuilt_binary_conversion_test.go
Change-Id: I007deef8d44f68993012f2114314d1cb52cfbb0e
2022-10-06 19:39:09 +00:00
Pierre-Clément Tosi
329a03196f Merge "Support prefix_symbols for prebuilt libraries" 2022-08-22 07:44:42 +00:00
Colin Cross
d079e0b270 Reformat build/soong for go 1.19
Test: none
Change-Id: I132368f0fcbdb5ea088b5b84dbe4ccfdd9e94cad
2022-08-17 10:43:13 -07:00
Pierre-Clément Tosi
6f630ae6f2 Support prefix_symbols for prebuilt libraries
Add support for prefix_symbols from binary and object targets to allow
rules to prefix symbols from a checked-in library before linking against
it, namespacing the resulting symbols and avoiding potential clashes.

Bug: 237371962
Test: Android.bp with cc_prebuilt_library_static::prefix_symbols
Change-Id: Iaf9cdd12637d5a259ae4c4827ff20e4f911699a4
2022-08-10 09:36:11 +01:00
Trevor Radcliffe
5d6fa4d857 Enable Mixed Builds for Prebuilt Library
This change provides support for mixed builds for
cc_prebuilt_library modules and allowlists some such modules.

Fixes: 225938765
Test: Unit tests, run mixed builds and verify correctness
Change-Id: I04396c79661df6b9a43907859e4f96d0191e8e1b
2022-06-07 20:36:53 +00:00
Liz Kammer
707f65d3d5 Merge "Remove library decorator for extracting headers" 2022-05-23 19:36:57 +00:00
Chris Parsons
6ce2cf9b69 cc bazel handlers: use better interface checking
This is a far better approach for ensuring that bazel handlers implement
the BazelHandler interface, as it causes a compile error if they do not
implement the appropriate interface methods.

Test: Manually verified no change in ninja file
Change-Id: I63a4f8b57e3aedd4c0915c2fd2eb7029e9a993aa
2022-05-20 10:54:17 -04:00
Chris Parsons
f874e46153 Refactor mixed builds to only take one pass
This large refactoring has both immense performance implications and
improves mixed builds complexity / usability. Summary:

1. Queueing calls to Bazel is done in a new mutator instead of a full
   soong_build pass. Normal soong_build flow is interrupted (via a
   functional hook in blueprint) to invoke bazel and parse its response.
2. Implementing mixed build support for additional modules is as simple
   as implementing MixedBuildsBuildable. In this interface, define the
   request that must be queued to Bazel, and then subsequently define
   how to handle the returned bazel cquery metadata.
3. Mixed builds consists of only a single pass. This greatly
   improves mixed build performance.

Result:
  A 33% runtime improvement on soong analysis phase with mixed builds.

Caveats:
  C++ BazelHandler handling still remains a bit of a mess; I did what
  I could within this CL's scope, but this may require additional cleanup.

Test: Treehugger
Test: Verified that aosp_arm ninja file is bit-for-bit identical with or
without this change.

Change-Id: I412d9c94d429105f4ebfafc84100d546069e6621
2022-05-20 10:04:13 -04:00
Liz Kammer
5454944b9a Remove library decorator for extracting headers
It is unused and removing it allows us to use the same function for
prebuilt/not libraries.

Test: bp2build.sh
Change-Id: I92ac56496cff2c2e55d6eb9f261fe75a1b232856
2022-05-13 19:52:27 -04:00
Colin Cross
8d0e466f19 Merge "Copy prebuilt objects to the intermediates directory" 2022-04-19 23:29:17 +00:00
Colin Cross
ee02aed756 Copy prebuilt objects to the intermediates directory
Copy prebuilt objects to the intermediate directory so that their
output file name matches the module name.  This simplifies using
the clang crt objects, whose input names vary by architecture,
in the musl sysroot genrule.

Bug: 216192129
Test: m checkbuild
Change-Id: I467d699f718e2cc5c6bf0a5c35820dedd51c5930
2022-04-15 15:16:02 -07:00
Trevor Radcliffe
58ea451750 bp2build support for cc_prebuilt_library
while cc_prebuilt_library_(shared|static) were already supported,
the raw cc_prebuilt_library module type was not supported by
bp2build. This CL provides that functionality.

Also did a little bit of refactoring and cleaning.

Bug: 225938765
Test: Confirm output BUILD.bazel files look as expected. Confirm
      that build succeeds.
Change-Id: Ic004f88febc0e5b527f2ef420dbd96ecc55d2e09
2022-04-15 16:29:28 +00:00
Martin Stjernholm
5bdf2d589c Mark implementation variant of prebuilts with stubs as not installable
This is necessary to avoid installing them. Previously, when install
dependencies were resolved in make, they weren't installed because they
got a .bootstrap suffix in their mk modules. However when that logic
moved into Soong by resolving transitive dependencies in
computeInstallDeps, they started to get dependencies and hence their
stubs could get installed, e.g. system/lib{,64}/libdexfile.so from
prebuilt_libdexfile.

Test: m nothing
Test: env NINJA_ARGS="-t path droid out/target/product/vsoc_x86_64/system/lib64/libdexfile.so" \
        m SOONG_CONFIG_art_module_source_build=false nothing
  verify that ninja reports no dependency path
Bug: 211770050
Bug: 220898484
Change-Id: Ifbfe31a15428926ce57b9e91b535b7ae79038fbd
2022-02-23 09:19:18 +00:00
Liz Kammer
2b376bca00 Create subdir for cc rules.
Test: mixed_libc.sh
Change-Id: I7f43f283f40ad6236dcedfccae175a007ea252d2
2022-01-27 11:16:34 -05:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
c3b97c3568 libclang_rt_prebuilt_library_shared mixed builds
Also fix nil deref in setting $LOCAL_SOONG_UNSTRIPPED_BINARY

Bug: 201802518
Test: request_type_test.go
Test: prebuilt_test.go:TestPrebuiltLibrarySharedWithBazel
Test: mixed_{libc,droid}.sh
Change-Id: I22afb56c4b42d3412c2b2e1f079f1bcf8f3129a7
2022-01-20 12:03:18 -05:00
Liz Kammer
bdc922f3fe bp2build: do not convert prebuilt cc binaries
These do not have a conversion process yet, do not convert them. Add
more protection against using the wrong conversion for prebuilts in cc.

Test: allowlist project with prebuilt objs/binaries and verify BUILD
      files
Change-Id: Ib26689fa19d6fbb1f5c73ded3b5836165977e987
2021-12-14 14:27:57 -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
Martin Stjernholm
d51cb5c130 Fix prebuilt header files to produce proper AndroidMk entries.
Necessary for modules that depend on headers through
LOCAL_HEADER_LIBRARIES in legacy Android.mk files.

Test: m nothing
Test: m nothing SOONG_CONFIG_art_module_source_build=false
  on internal master
Test: m droid checkbuild SOONG_CONFIG_art_module_source_build=false
Test: m SOONG_CONFIG_art_module_source_build=false \
        out/soong/.intermediates/prebuilts/module_sdk/art/current/sdk/prebuilt_jni_headers/linux_glibc_x86_64/prebuilt_jni_headers.a
      ar t out/soong/.intermediates/prebuilts/module_sdk/art/current/sdk/prebuilt_jni_headers/linux_glibc_x86_64/prebuilt_jni_headers.a \
        && echo ok
Bug: 202192894
Change-Id: Ied267053d1fc3563870a3faaf41d79983a22815a
2021-12-02 10:54:45 +00:00
Martin Stjernholm
e65c3aee02 Fix prebuilt selection logic for cc_prebuilt_library_headers.
Unlike other prebuilt modules it doesn't have a srcs property of any
kind, so android.Prebuilt cannot defer to the source module just
because its srcsSupplier would return nil.

Test: m nothing
Bug: 202192894
Change-Id: Iafcf165569bad6eae37820cf71aa0fcacb720e02
2021-11-24 20:48:04 +00:00
Ivan Lozano
7b0781d14c rust: Emit toc files for cdylibs
Write toc files that list the exported symbols so dependents are
only rebuilt if the exported symbols change.

This exports the CC function TransformSharedObjectToToc, and also
removes an unused arg from its signature.

Bug: 178185435
Test: New Soong test passes.
Test: m <toc file path>
Change-Id: I7ab69bf7e7f32f25eb4c7ca9d18d877dac1511db
2021-11-03 15:34:50 -04: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
Paul Duffin
9804da0544 Dedup use of "prebuilt_"
Bug: 177893770
Test: m nothing
Change-Id: I664ee4d9c3aafda3de0a3f8985ee23f25db38680
2021-10-26 10:43:23 +01:00
Chris Parsons
787fb36189 Add OS to configuration key in mixed builds
This also removes the special-case filegroup from mixed builds
buildroot; no special handling is required. Since we're currently
hardcoding linux_x86_64 as our host platform, it should be fine
to continue assumping that hardcoded host for now.

Test: USE_BAZEL_ANALYSIS=1 m adbd
Change-Id: I35509f4eb33ba7a243fab4c34b35958f6f2fceab
2021-10-19 16:55:52 -04:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
0d99045b69 Lift BazelHandler interface into android/
Because it's commonly useful and not cc/ specific
Also export GenerateBazelBuildActions and update uses

Test: Existing tests pass
Change-Id: Ibc6858bb1129afba181a7686dda432defe33b00d
2021-08-11 18:19:40 +00:00