Commit graph

39 commits

Author SHA1 Message Date
Spandan Das
972917d794 Support partial module variants with apex_contributions
Some libraries like `libnativehelper_compat_libc++` only exist as shared
library in module sdk. When prebuilt of this library is selected using
apex_contritbutions, only shared linkages should be redirected to the
prebuilt version. The static linkage should come from source.

Test: Added a unit test
Bug: 322175508

Change-Id: Ic65d376b2354b4a42c7b9ea3ed1cd80c37e2840f
2024-03-04 08:39:20 +00:00
Spandan Das
f2c1057586 Fix non-determinism in prebuilt selection
This relands aosp/2978137 with acknowledgement of soong namespaces.

If multiple versions of the prebuilt module sdk share the same soong
config namespace, then PrebuiltPostDepsMutator rewrites rdeps to one of
those prebuilts in a non-deterministic way.

This CL uses apex_contributions to make this deterministic. Multiple
prebuilts will not be allowed to have their prefer evaluate to true. If
this happens, one of the prebuilts must be explicitly declared in
apex_contributions.

This CL also fixes the special-casing of the top-level
java_sdk_library_import in ReplaceDirectDependencies. For
framework-foo.v2, it will use BaseModuleName framework-foo instead of
SdkLibraryName framework-foo.v2 to determine if the source module has
been selected.

Test: ran the previously failing cmd of b/327552112
Test: Added a unit test
Test: aninja -t query
    out/soong/.intermediates/packages/modules/Permission/SafetyCenter/Config/safety-center-config/android_common/javac/safety-center-config.jar
    | grep module_sdk is empty (should not cause a regression for
    323454855)
Change-Id: Id484a41192085c50b7e34ad415c6e195edb0d006
2024-03-04 07:59:34 +00:00
Spandan Das
af66212522 Revert "Fix non-determinism in prebuilt selection"
This reverts commit 2d8884a377.

Reason for revert: Build breakage https://groups.google.com/a/google.com/g/android-build-police-core/c/00mM-B9unVg/m/0FxBxpMbAwAJ. The validation does not check for namespace isolation which breaks libtonemap

Change-Id: Ieb4d3bc4f3ade856877ebb62a567620f5a1ed08c
2024-02-29 08:57:08 +00:00
Spandan Das
2d8884a377 Fix non-determinism in prebuilt selection
If multiple versions of the prebuilt module sdk share the same soong
config namespace, then PrebuiltPostDepsMutator rewrites rdeps to one of
those prebuilts in a non-deterministic way.

This CL uses apex_contributions to make this deterministic. Multiple
prebuilts will not be allowed to have their prefer evaluate to true. If
this happens, one of the prebuilts must be explicitly declared in
apex_contributions.

This CL also fixes the special-casing of the top-level
java_sdk_library_import in ReplaceDirectDependencies. For
framework-foo.v2, it will use BaseModuleName framework-foo instead of
SdkLibraryName framework-foo.v2 to determine if the source module has
been selected.

Test: Added a unit test
Test: aninja -t query
    out/soong/.intermediates/packages/modules/Permission/SafetyCenter/Config/safety-center-config/android_common/javac/safety-center-config.jar
    | grep module_sdk is empty (should not cause a regression for
    323454855)

Bug: TODO
Change-Id: I7191200c330c5bcb9d5532006d3c573a60db61cc
2024-02-29 06:34:49 +00:00
Spandan Das
3faa792093 Use BaseModuleName of dep when writing to make
Since BaseModuleName of the dep becomes its LOCAL_MODULE name in the
generated mk file, we should also use BaseModuleName of dep for populating
properties such as LOCAL_SHARED_LIBS of rdeps

Test: m nothing --no-skip-soong-tests
Bug: 322175508

Change-Id: I6b47112faa63f85d19b5b71e0e102cea0ab68e3b
2024-02-28 18:03:00 +00:00
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
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
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
Wei Li
598f92d704 Export Soong module type to LOCAL_SOONG_MODULE_TYPE to Make for SBOM generation.
Bug: 266726655
Test: CI

Change-Id: If5b1a77930a591b6061ca2749c9c5ad29b4491fb
2023-03-06 22:51:03 +00: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
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
b1bd77048d Add Soong tests for cc_prebuilt_binary for bad srcs
Test: TestPrebuiltBinary{NoSrcsNoError,MultipleSrcs}
Change-Id: I1c803e38bae68e452cebf6208412cefed900c7f6
2022-10-06 14:10:49 +00: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
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
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
Colin Cross
0c66bc615b Replace android.BuildOs with Config.BuildOS
Replace the android.BuildOs constant with Config.BuildOS so that it
can vary based on the product config.

Bug: 190084016
Test: all Soong tests
Change-Id: Ia67f872d8b2ab788747a22e3a9659dc21c9775cd
2021-07-20 12:46:48 -07:00
Paul Duffin
8567f226e4 Remove ccFixtureFactory
Bug: 182885307
Test: m nothing
Change-Id: Ia3e93b8ab70a7a6a986debd837bd2df84b234847
2021-03-30 23:44:43 +01:00
Paul Duffin
e8366da1f6 Automatically call TestingBuildParams.RelativeToTop()
Fixes the few tests that break due to this and which cannot easily be
separated into their own changes.

Bug: 183650682
Test: m nothing
Change-Id: Ia2f31213a1f114a78e66a81d89279ecde9f4c465
2021-03-30 19:35:35 +01:00
Paul Duffin
6a1160e749 Convert cc/prebuilt_test.go to use fixtures
Bug: 181070625
Test: m nothing
Change-Id: I6048812962382e2adaf79d941a24e5c0ffdd9b25
2021-03-11 15:04:43 +00:00
Jingwen Chen
cda22c9bb9 Refactor 'in_make' to mean Kati is not skipped.
In Nougat and before, Make wrote a marker file to indicate that
soong_build was invoked from Make to change certain behaviors of Soong
at build time.
https://cs.android.com/android/platform/superproject/+/android-7.1.2_r36:build/core/soong.mk;l=70-73;drc=ae18638b0406ad107b0882a02a13cdd8b92f2a4e

Things have changed, and now soong_build is invoked from soong_ui, which
supports a --skip-make configuration flag:
https://cs.android.com/android/platform/superproject/+/master:build/soong/ui/build/build.go;l=31-33;drc=680387bf1d3ce7cbc77f535be7c42cec411b1687

Thus, the various remnants of 'EmbeddedInMake' and 'inMake'
configuration are misleading, since soong_build is no longer invoked
from Make. This CL refactors all instances to actually mean that
Kati is enabled (not skipped with --skip-make), and will run after
soong_build finishes, so Kati-specific behavior like the AndroidMk
singleton should run.

Test: TH presubmit

Change-Id: I576ab8e54f99f5c8ddf9feaf9a828019b279e266
2020-11-23 00:29:18 -05:00
Colin Cross
ae8600b507 Pass Config to NewTestContext instead of ctx.Register
Prepare for using Config when adding singletons by passing
Config to NewTestContext and NewContext instead of to ctx.Register.
This will enable a followup change to store SingletonMakeVarsProviders
registered on the Context in the Config, which is necessary to run
multiple tests in parallel without data races.

Test: all soong tests
Change-Id: Id229629a4e42ff4487d317241673837726c075fc
2020-11-12 10:07:49 -08:00
Evgenii Stepanov
2080bfe79a Support asan/hwasan versions of prebuilts.
In apex_set and cc_prebuilt_library_*, provide a way to specify an
alternative source to use when build with sanitizers.

Test: prebuilt_test, apex_test
Change-Id: I1ab8091bf696d94da3547cf5248853df489bdee6
2020-10-13 03:37:32 +00:00
Colin Cross
405af07859 Revert "Make lots of tests run in parallel"
This reverts commit 323dc60712.

Reason for revert: Possible cause of test instability
Bug: 170513220
Test: soong tests

Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
2020-10-09 18:34:24 -07:00
Colin Cross
323dc60712 Make lots of tests run in parallel
Putting t.Parallel() in each test makes them run in parallel.
Additional t.Parallel() could be added to each subtest, although
that requires making a local copy of the loop variable for
table driven tests.

Test: m checkbuild
Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
2020-10-06 15:12:22 -07:00
Martin Stjernholm
6a9a14663d Disable the prebuilt host binary test on darwin.
Variants and paths are different there, and it is hard to test since
it's only in postsubmit in TH.

Test: m nothing
Bug: 168558897
Change-Id: I071540b3c7ff9a9fd4104dca75079e831b1b2529
2020-09-15 02:56:19 +01:00
Martin Stjernholm
837ee1a6df Symlink prebuilt binaries on host.
This means binaries will run from their source location and look up
shared libs relative to there.

Test: m nothing
Test: Set up a prebuilt binary with shared libs, check that it can
  be executed during build, and check that its symlinks get updated
  when a shared lib is touched.
Bug: 145934348
Change-Id: I1a600c7163ce0ec34ee8caf0ffe87fef4feb3064
2020-09-03 19:05:18 +01:00
Yo Chiang
a3ad9b204e cc_prebuilt_library respect module name and stem
Installed name of prebuilt shared library should be stem or module name.
For example:

cc_prebuilt_library_shared {
  name: "libfoo",
  srcs: ["libbar.so"],
}
should install with the filename libfoo.so, and

cc_prebuilt_library_shared {
  name: "libfoo",
  stem: "libbaz",
  srcs: ["libbar.so"],
}
should install with the filename libbaz.so.

Prebuilt Windows PE library should specify its import library.
For example:

cc_prebuilt_library_shared {
  name: "libfoo",
  srcs: ["libfoo.dll"],
  windows_import_lib: "libfoo.lib",
  enabled: false,
  target: {
    windows: {
      enabled: true,
    },
  },
}

Bug: 151744695
Test: prebuilt_test.go && built walleye-userdebug
Change-Id: Ia8d0afb7fa46783c670870440432779c5fc7321a
2020-04-13 17:02:27 +08:00
Martin Stjernholm
adeb088c8b Minor refactoring to put mock filesystem init closer to tests.
Test: m nothing
Change-Id: I39449b52d39d8e4351ff5a193df5804f281a017f
2020-04-02 22:39:12 +01:00
Martin Stjernholm
0b92ac8e43 Add cc_prebuilt_object.
To be used for prebuilt object support in SDK snapshots.

Test: m nothing
Bug: 148934017
Change-Id: I53d58100cc1d410c5cf5b7906de7ed6f7add2035
2020-03-20 00:15:35 +00:00
Paul Duffin
bce90daf45 Add support for cc_prebuilt_library
Test: m nothing
Bug: 142918168
Change-Id: I8aacc0052812208e1892ef533545ae53bb387a0d
2020-03-16 19:27:16 +00:00
Paul Duffin
d686791c16 Improve cc tests by adding sanitizer mutators
This fixes an issue that arises when deduping cc build component
registration code.

The sanitize_runtime_deps and sanitize_runtime post deps mutators were
not previously added when running cc tests. That meant the tests were
not actually testing the same behavior as at runtime.

Adding the mutators breaks the TestFuzzTarget test as the mutator adds
libclang_rt.ubsan_standalone-aarch64-android as a dependency of libc++
and the former is not available.

This fixes the test by adding the missing dependency as a cc prebuilt
shared library.

Test: m checkbuild
Bug: 146540677
Change-Id: Ie13c7e6fcefef7d9cb1cc5364be3dc563ce40de5
2019-12-19 19:19:40 +00:00
Paul Duffin
0c4979bbdf Dedup prebuilt mutator registration
Test: m checkbuild
Bug: 146540677
Change-Id: I9f8a11adf61fe6f352ec1eabc7c5bac332348ba2
2019-12-19 19:19:40 +00:00
Paul Duffin
59986b23cc Dedup cc prebuilts module type registration
Test: m checkbuild
Bug: 146540677
Change-Id: I7e9440a075ef9c683729ed83e0033ab529fe4ac0
2019-12-19 19:19:40 +00:00
Colin Cross
98be1bb00f Move filesystem into Config
The filesystem object was available through ModuleContext.Fs(), but
gives too much access to the filesystem without enforicing correct
dependencies.  In order to support sandboxing the soong_build
process move the filesystem into the Config.  The next change will
make it private.

Bug: 146437378
Test: all Soong tests
Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
2019-12-18 08:19:10 -08:00
Colin Cross
7113d20774 Use empty string for core image variant
Use the empty string for the core image variant so that modules
added to imageMutator do not change their build directory.

Bug: 142286466
Test: m checkbuild
Change-Id: Ida4534d9a4d6176236aaa480fed359ce27acfaa1
Merged-In: Ida4534d9a4d6176236aaa480fed359ce27acfaa1
(cherry picked from commit 72d685ee7f45e5393be44ae4159edf083ac918de)
2019-12-13 20:44:36 -08:00
Colin Cross
4b49b768a2 Make TestContext.RegisterModuleType take an android.ModuleFactory
Avoid having to pass ModuleFactoryAdaptor to every call to
RegisterModuleType in a test by wrapping RegisterModuleType.

Test: all soong tests
Change-Id: If8847d16487de0479cc3020b728256922b3cadba
2019-11-25 10:59:44 -08:00
Jooyung Han
344d5439c1 Add "apex_vndk" module type
"apex_vndk" is a variant of "apex" module.

apex_vndk {
  name: "com.android.vndk",
  ..
}

This rule is used to produce a VNDK APEX per vndk version.
It supports automatic inclusion of vndk libs.

If "vndk_version" property is set, the prebuilt vndk libs of
the version will be included in the apex bundle.

apex_vndk {
  name: "com.android.vndk.v29"
  vndk_version: "29",
  ...
}

Otherwise, platform's vndk version is used.

This will replace /system/{lib}/vndk-{ver} and vndk-sp-{ver}.

Bug: 134357236
Bug: 139772411
Test: m com.android.vndk
Change-Id: Ib5c86e625839389670d13c683a7427198ef6852f
2019-09-10 11:22:59 +09:00
Colin Cross
9a94287fc9 Move CreateTestContext to cc/testing.go
Allow CreateTestContext to be called by tests in other packages
that need cc modules.

Test: all soong tests
Change-Id: I6be04dec50632baa8cb51e55ba14d0ddc0df60b8
2019-05-17 08:43:36 -07:00
Colin Cross
33b2fb7333 Support using cc_prebuilt_library_shared with cc_library
Allow a cc_prebuilt_library_shared to share the same name as a
cc_library by always creating static and shared variants of
prebuilts so that the variants of the source module are always
a superset of the variants of the target module.

Bug: 131709055
Test: TestPrebuilts
Change-Id: I4afd6d37e6a986d08ad25aee69eca6d994febc6b
2019-05-17 08:40:42 -07:00