Commit graph

56 commits

Author SHA1 Message Date
Martin Stjernholm
dbd814d44e Fix genrule tool dependencies when a prebuilt tool is preferred.
Since the genrule tool dep mutator runs after the prebuilt mutators,
this adds a helper function android.PrebuiltGetPreferred to resolve the
source or prebuilt as appropriate.

Test: m SOONG_CONFIG_art_module_source_build=false droid
  in internal
Bug: 214292395
Change-Id: I1a208fd048b998f9f19ad1f45d8389decda2cb9e
2022-01-12 23:35:57 +00:00
Usta
851a3271ce Use Module.GetProperties() instead of ModuleBase.generalProperties
ModuleBase.generalProperties served the pupose of being a subset
of ModuleBase.customizableProperties. But now with the removal of
the latter, the former is simply a redirection to Module.GetProperties()

Bug: 206961391
Test: m nothing and diff the ninja files
Change-Id: I6dd8b7ba74eb5e7ffb61029b0f9129eec2ccfdaf
2022-01-08 03:09:52 +00:00
Usta
dca0219965 Remove customizableProperties from android.ModuleBase
- customizableProperties was being used to access all properties,
i.e. basically `GetProperties()`

- generalProperties was a subset of properties,
i.e. `initArchModule()` would only add new arch-specific properties
to `customizableProperties` (and `archProperties`) but not `generalProperties`

This PR sets generalProperties to contain all properties,
which then makes customizableProperties redundant.
And in arch.go, any iteration is done via `archProperties` instead.

Bug: 206961391
Test: m nothing and diff the ninja files
Change-Id: Ieb72b31c0a447fcbf34c92a04f002d7b9d777a86
2022-01-04 13:33:51 -05: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
Martin Stjernholm
25a69de8de Improve the error when srcs field has the wrong type.
In particular it's useful to print the module, since the panic is
delayed from the init call.

#codehealth

Test: m nothing
Change-Id: Ia91127be83d8a9ce08cf0c08bc3f13fce7be14af
2021-09-14 00:33:47 +01:00
Paul Duffin
0c52c7ba63 Choose prebuilt or source via an Soong config variable
A simple way to provide fine grained control over the use of a prebuilt
or source module via a Soong config variable.

Bug: 193523070
Test: m nothing
Change-Id: I47ae8ac04fa29156d2e87efd9e60ab995f50ea6d
2021-07-14 20:23:06 +00:00
Liz Kammer
69d6413dd0 Make prebuilt properties customizable
Previously whether prebuilt properties were customizable was dependent
on the order of calling various inits.

Test: go test soong tests
Bug: 191975220
Change-Id: Icaa1fe811a5f5fc4aa5fc9fa0ec0b90debe3d537
2021-06-24 13:34:18 -04:00
Paul Duffin
f7c99f5983 Add GetEmbeddedPrebuilt and IsModulePrebuilt
Dedups the many repetitions of the code to obtain a *Prebuilt from a
module.

Bug: 177892522
Test: m nothing
Change-Id: I1ededbe9ee79e89ea6dd8882dfee4be0bf0b51b7
2021-04-28 14:02:04 +01:00
LuK1337
fb545bf2f3 Make sure prebuilt modules are exported before attempting to use them
Fixes an issue where prebuilt module under unexported soong
namespace overrides source modules when flag `prefer` was set.

Test: Create two modules under the same name, use cc_library_shared
      for first one and cc_prebuilt_library_shared with `prefer` set
      to true.
      Then put the prebuilt module under `soong_namespace {}` and
      attempt to compile it without appending the namespace path to
      product namespaces.
      Without this change it should fail to resolve the
      cc_library_shared module even if it should be available.

Change-Id: I506641218e6af94a0b5f048e09e06d83602e50f5
2021-04-14 22:55:22 +02:00
Paul Duffin
56dc66e2ea Stop deapexer module type from being treated as a prebuilt
Previously, the private deapexer module type was treated as a prebuilt
as that was the quickest way to implement it. However, there is no
reason why it should be as there is no corresponding source module type
which it might replace.

This change removes the prebuilt support to simplify the module type in
preparation for future work. As part of that it extracts the logic for
retrieving a single path from a PrebuiltSrcsSupplier to ensure
consistent behavior.

Bug: 181267622
Test: m droid
Change-Id: I1b2bb49601c13a3fff99a0026c235eaa70d2e612
2021-04-07 10:09:58 +01:00
Paul Duffin
864116ce3f Add PrebuiltNameFromSource
Bug: 177892522
Test: m nothing
Change-Id: I45274836d59adbd6b2a2a848705b189398f1e766
2021-04-06 21:20:58 +01:00
Paul Duffin
e1d3837645 Add IsModulePreferred
Bug: 177892522
Test: m nothing
Change-Id: I47268b81359d6fceb60e899a730b3b6034e09814
2021-04-06 21:18:34 +01:00
Jaewoong Jung
6158dfeb95 Remove obsolete comment on PrebuiltPostDepsMutator
Test: N/A
Change-Id: If01139ed361dd16022b50c503349d1d05282052b
2021-03-23 14:08:29 -07:00
Paul Duffin
c04fb9e6a2 Remove deapexer and prebuilt apex select mutators
Originally, when the prebuilt_apex was first created, it selected the
source to use in its DepsMutator. It did that because that was a
convenient place for it to perform that work which had to be:
* After the arch mutator had run so MultiTargets() was available.
* Before the prebuilt_select mutator runs as that relied on the Source
  property to have been set.

Change 064b70c9 then duplicated the call from the DepsMutator of the
deapexer module type that was added as part of the work to make dex
files available for hiddenapi processing.

Change 356f7d45 moved it out of the the DepsMutator methods into its
their own mutators, presumably because it interfered with the
Soong -> Bazel conversion work.

This change improves the existing PrebuiltSrcsSupplier mechanism to
support reporting errors so that the logic for selecting the source can
be done on demand rather than in separate mutators.

The main complication was that PrebuiltSrcsSupplier is called with a
BaseModuleContext for both source and prebuilt modules so it cannot use
any methods on it that are related to the current module. That
necessitated adding MultiTargets() to android.Module.

Bug: 181267622
Test: m droid
Change-Id: I106c78fd21016f051a315b82b470d8f12b1f820b
2021-03-01 17:11:25 +00:00
Colin Cross
a9c8c9f145 Call ctx.InstallFile for uninstallable cc modules
SkipInstall is actually primarily used to prevent making a module
visible to Make, rename it and add new SkipInstall that actually
skips installation without affecting Make.

Call c.SkipInstall() for uninstallable cc modules to allow calling
c.installer.install, which will collect PackagingSpecs for
uninstallable cc modules, allowing them to be used by genrules.

Bug: 124313442
Test: m checkbuild
Change-Id: I8038ed5c6f05c989ac21ec06c4552fb3136b9a7a
2020-12-17 10:02:18 -08:00
Paul Duffin
d23c726b36 Add RemoveOptionalPrebuiltPrefix() helper function
Test: m nothing
Bug: 171061220
Change-Id: Iaca95efcaf3f02e066751c6e988d609ac40e048a
2020-12-11 18:13:08 +00:00
Jaewoong Jung
729c0bdb54 Prebuilt is enabled even if the source one is not.
This fix a bug in a recent android_app_import-related change
(I8215aa1a6dad74b503eaa1169a64f8c30dda287c) where it uses an incorrect
module reference, and so disables a prebuilt module if its source-based
counterpart is disabled.

Test: app_test.go
Bug: 152343232
Change-Id: Ic7f5ca40be58f06e44b5ec4945caf209ef2dae96
2020-12-08 19:11:54 -08:00
Jaewoong Jung
84f1b80866 No matching variant android_app_import fix
This fixes a bug where android_app_import or android_test_import without
a matching variant or a default apk property value breaks the build.

Test: app_test.go
Fixes: 152343232
Change-Id: I8215aa1a6dad74b503eaa1169a64f8c30dda287c
2020-12-04 11:51:29 -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
Liz Kammer
5ca3a6293e Add hidden_api for java_import
Test: go java tests
Test: m
Bug: 160455085
Change-Id: Ib6e826e32ca73ceea0799b26145ad06b1e62a1bf
2020-09-10 07:56:03 -07:00
Martin Stjernholm
f467732447 Do not consider disabled prebuilt variants.
This relands https://r.android.com/1356826 without changes. It got
reverted as part of b/161315642 but is not related to that issue.

Test: m nothing
Test: `m` with prebuilt SDKs in the manifest
Bug: 151303681
Bug: 161315642
Change-Id: I7af892ae28a8208113e0801b1b8a8204edb61ec8
2020-07-15 14:27:13 +01:00
Charles Chen
6ffbe57270 Revert "Do not consider disabled prebuilt variants."
This reverts commit 235e2fdbd3.

Reason for revert: <build break>

Bug: 161315642
Change-Id: Ie741252dc1d0749591f141c71c3d59ce45f0234f
2020-07-15 08:56:22 +00:00
Martin Stjernholm
235e2fdbd3 Do not consider disabled prebuilt variants.
Test: m nothing
Test: `m` with prebuilt SDKs in the manifest
Bug: 151303681
Change-Id: I44d3a3cc4d7c1e02cc0ec61827646801f804b168
2020-07-10 17:12:10 +01:00
Paul Duffin
80342d72d0 Restrict replacements of source dependencies with prebuilts
Previously, when java_sdk_library_import was preferred over a
java_sdk_library the latter ends up depending on the prebuilt child
modules created by the java_sdk_library_import instead of the source
child modules that it created itself. That was because all dependencies
on those source child modules were replaced with the corresponding
prebuilt child modules.

This change prevents those dependencies from being replaced to preserve
the dependencies from java_sdk_library onto its source child modules by
making the replacement conditional depending on the tag used. It also
updates the affected test.

Bug: 159902351
Test: m nothing
Change-Id: I4441b901dedfd44b9769df1ac2e248b94834cf85
2020-07-08 16:46:16 +01:00
Martin Stjernholm
009a9dc4ac Fall back to the source module for variants that the corresponding
prebuilt doesn't define.

Test: m
Test: "m" on a platform tree with prebuilts/runtime in the manifest
Bug: 151303681
Change-Id: I8e10579c5daa79e82009a0c3060cde76cdf520e9
2020-05-28 13:17:21 +01:00
Paul Duffin
38b5785e3f java_sdk_library_import: Propagate prefer to child modules
Bug: 155164730
Test: m nothing
Change-Id: Idb06d79baf346ac570beada79880814c5ef6bb50
2020-05-13 20:40:53 +01:00
Paul Duffin
dddd5469ad Ignore PrebuiltDepTag when processing APEX contents
When a source and a prebuilt module are present in the same build a
dependency is added from the source module to the prebuilt module.
Previously, the code for generating the APEX did not recognize that
tag and in some cases (e.g. for cc_(prebuilt_)library_shared) will
fail the build.

This change:
1) Adds a test to reproduce the problem.
2) Improves the debug message by pretty printing the tag.
3) Adds a new ExcludeFromApexContents interface that can be implemented
   by a tag to declare that it should be excluded from the APEX
   contents.
4) Ignores tags that implement that interface when generating APEX
   contents.
5) Implements that interface on prebuiltDependencyTag to fix the
   test.

Bug: 153326844
Test: m nothing
Change-Id: I9dd4312c4f995c816c0a31d8d733eb5d7f56e1ea
2020-04-08 08:40:44 +01:00
Paul Duffin
dcb4bd6fb4 Refactor prebuilt to use srcs supplier function
Previously, prebuilt had two ways to provide the src value, as a
pointer to an []string and using reflection. That meant that any code
that needed to check the src to use had to understand the two ways of
accessing it.

This change refactors the code to abstract the origin of the src values
being a supplier function. That insulates the callers from having to
know the details and makes it easy to add new suppliers in future.

Test: m nothing
Bug: 142918168
Change-Id: I5cc7517c46cce96924c9f34ba1b046b468f7684a
2020-03-16 19:27:11 +00:00
Paul Duffin
50061511d4 java_sdk_library - Use prebuilt/prefer for unbundled app builds
Previously, the java_sdk_library had special support for disabling the
stubs library when the build was configured to use prebuilts for sdks,
e.g. in an unbundled app build. That caused the prebuilt version of the
stubs library to be used instead. The disabling was done irrespective
of whether a prebuilt was available which prevents java_sdk_library
from being used in situations when prebuilts are not available, e.g.
when they have not been created yet.

This change moves the logic into tha java_sdk_library_import and
leverages the existing prebuilt/prefer mechanism to ensure that the
prebuilt version is used when required.

* Adds a ForcePrefer() method to Prebuilt to allow a module to forcibly
  set the value of the prefer property.
* Sets prefer true on the java_sdk_library_import and the stubs modules
  it creates when the prebuilt version should be used.
* Refactors PrebuiltJars for use by both java_sdk_library and
  java_sdk_library_import as they both need to provide access to
  prebuilts for previously released versions of the library.
* Removes disabling logic from java_sdk_library.

This will probably require some additional java_sdk_library_import
modules to be added to prebuilts/sdk/current/Android.bp.

Bug: 148080325
Test: m droid && TARGET_BUILD_APPS=Camera2 m
Change-Id: I0b5f751e82a2179a967ae64ca03dc9b9e7665c16
2020-02-05 08:09:57 +00:00
Paul Duffin
78ac5b962e Exclude source->prebuilt deps from visibility enforcement
When both prebuilt and source versions of a module are present in the
build an implicit dependency is added from source -> prebuilt. This
change excludes that dependency from visibility enforcement as it
provides no value and would otherwise require an sdk snapshot to
rewrite the visibility of the generated prebuilt modules which would
be complicated.

The rewriting would include:
* Detecting //visibility:public and just passing that straight through.
* Detecting //visibility:private and replacing that with the location
  of the source.
* Otherwise, adding the location of the source to the visibility
  property.

This adds a general mechanism to allow any dependency to be excluded
from visibility enforcement by simply using a tag that implements
the ExcludeFromVisibilityEnforcementTag interface.

Bug: 142940300
Test: m nothing
Change-Id: I0668ff5aa798152d17faf3aac1bb8eff8d6350c3
2020-01-15 11:17:57 +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
Jiyong Park
42aaba73ac Merge "Delete prebuilt APEXes when installing source-built APEXes" am: a822256e15
am: fb45ee3d1e

Change-Id: I8d8eddee843c34fbce4c19a6cbb5a1d2ce3f218e
2019-07-31 00:50:07 -07:00
Jiyong Park
03b68ddd10 Delete prebuilt APEXes when installing source-built APEXes
To build the platform for ASAN, we do

`m && SANITIZE_TARGET='addresss' m`

However, at the end of the second build, the system partition could have
conflicting APEXes; prebuilt APEXes from the first build and
source-built APEXes from the second build. Since the file names for the
prebuilt and the source-built are different (e.g.
com.google.android.media.apex v.s. com.android.media.apex), we end up
having two files for the same APEX. This is confusing apexd at runtime
and the device fails to boot.

To fix this, when building a non-prebuilt APEX, the prebuilt APEX might
have been installed by the previous build is deleted.

Bug: 138146044
Test: lunch aosp_cf_x86_pasan; m && SANITIZE_TARGET='address' m
check that out/target/product/vsoc_x86/system/apex has
com.android.*.apex only.

Change-Id: Ib5a021a297cf0173ea5a3b50e9398b1cf295c558
2019-07-30 13:52:15 +09:00
Jiyong Park
2cb5288341 Don't use prebuilt_apex when TARGET_FLATTEN_APEX is set to true
When the device does not support non-flattened APEX (i.e.
TARGET_FLATTEN_APEX is set to true), then ignore the prebuilt_apex
modules even when `prefer: true`.

Bug: 136251130
Bug: 136662772
Test: build marlin, and check if /system/apex has flattened APEXes
Merged-In: I9f3dfefc3bd357d6750fbb1e418937d095720b04
(cherry picked from commit 0a573d798f)
Change-Id: I9f3dfefc3bd357d6750fbb1e418937d095720b04
2019-07-11 18:40:48 +09:00
Jaewoong Jung
22dad113ce resolve merge conflicts of c40949db97 to qt-dev-plus-aosp
Bug: None
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I496cca8b8c1b4330d56341f12c0f151766c77980
2019-07-10 10:18:16 -07:00
Jiyong Park
a237e62db0 Don't use prebuilt_apex when TARGET_FLATTEN_APEX is set to true
am: 0a573d798f

Change-Id: I67d532961fc4584bc0d7bf3616edb3236fb1acc9
2019-07-09 20:15:23 -07:00
Jaewoong Jung
3e18b19442 Improve android_app_import.dpi_variants handling.
Instead of circumventing the limitation of Prebuilt implementation by
picking a source path itself, it now uses the same mechanism as
archMutator and replaces the source path in advance so that Prebuilt
always sees the corrent source path.

Because this requires the Apk field to be a string pointer, the single
source prebuilt implementation is being updated to be reflection-based.

Test: Soong unit tests, m soong_docs, TreeHugger
Change-Id: I2304f15e32d632f74f95f0d9e9bf1f75ff3e2225
2019-07-09 15:00:15 -07:00
Jiyong Park
0a573d798f Don't use prebuilt_apex when TARGET_FLATTEN_APEX is set to true
When the device does not support non-flattened APEX (i.e.
TARGET_FLATTEN_APEX is set to true), then ignore the prebuilt_apex
modules even when `prefer: true`.

Bug: 136251130
Bug: 136662772
Test: build marlin, and check if /system/apex has flattened APEXes
Change-Id: I9f3dfefc3bd357d6750fbb1e418937d095720b04
2019-07-07 13:57:10 +09:00
Jaewoong Jung
a5e5abc449 Implement DPI variants in android_app_import.
Bug: 128610294
Test: app_test.go
Change-Id: Ie3e558bfdb40de6b0b9df95d3b373d08a4084d7b
2019-05-07 17:55:23 -07:00
Jiyong Park
4d27704da0 Prebuilt APEXes are recoreded in apexkeys.txt
apexkeys.txt now correctly lists prebuilt APEXes with keys specified as
PRESIGNED.

This change also fixes a bug that non-installable APEXes are listed in
the file.

Bug: 131130235
Test: m out/soong/apexkeys.txt and check that
com.android.apex.cts.shim.apex is listed there with PRESIGNED keys.

Merged-In: Ib6d391a82864714743a1cc59cd655bea917b5073
Change-Id: Ib6d391a82864714743a1cc59cd655bea917b5073
(cherry picked from commit a41f12a6fa)
2019-04-29 09:21:23 +09:00
Jiyong Park
a41f12a6fa Prebuilt APEXes are recoreded in apexkeys.txt
apexkeys.txt now correctly lists prebuilt APEXes with keys specified as
PRESIGNED.

This change also fixes a bug that non-installable APEXes are listed in
the file.

Bug: 131130235
Test: m out/soong/apexkeys.txt and check that
com.android.apex.cts.shim.apex is listed there with PRESIGNED keys.

Change-Id: Ib6d391a82864714743a1cc59cd655bea917b5073
2019-04-23 18:03:16 +09:00
Jaewoong Jung
939ebd5f33 Add prebuilt_apex.
Bug: 127789981
Test: apex_test.go + com.android.tzdata.apex
Change-Id: I09bb0a4b2acf310c55c789569da3c9d755638232
2019-03-28 15:56:22 -07:00
Colin Cross
8a49795df1 Replace ctx.ExpandSources with android.PathsForModuleSrc
Move the logic from ctx.ExpandSources into android.PathsForModuleSrc
and ctx.ExpandSource into android.PathForModuleSrc, and deprecate
them.  When combined with the pathDepsMutator this will let all
properties that take source paths also take filegroups or genrule
outputs, as long as they are tagged with `android:"path"`.

Test: All soong tests
Change-Id: I01625e76b5da19240e9649bf26a014eeeafcab8f
2019-03-20 19:36:13 +00:00
Colin Cross
27b922f53e Annotate paths and deprecate ExtractSource(s)Deps
Add `android:"path"` to all properties that take paths to source
files, and remove the calls to ExtractSource(s)Deps, the
pathsDepsMutator will add the necessary SourceDepTag dependency.

Test: All soong tests
Change-Id: I488ba1a5d680aaa50b04fc38acf693e23c6d4d6d
2019-03-07 18:36:35 +00:00
Pirama Arumuga Nainar
955dc4999e Fix few issues with filegroups
Bug: http://b/64121881
Bug: http://b/78188880

- Allow filegroup's properties to be extended by a LoadHook
- Support a filegroup (':module') in a prebuilt's 'Srcs' property to
export files from a different path as the prebuilt's sources.

This change also includes a refactoring that moves genrule/filegroup.go
to android/filegroup.go so that FileGroupFactory is visible in
prebuilt_test.go.

Test: Test
https://android-review.googlesource.com/c/platform/development/+/469159
in clang-tools branch on Linux, Darwin.  Test regular build in
aosp/master.

Change-Id: I3ff6215ab2e62955f039fd1086c31f1bd50ebcf6
2018-04-18 18:56:33 +00:00
Colin Cross
ee6143cde2 Add VisitDirectDepsWithTag
Add a method on ModuleContext and TopDownMutatorContext to visit
direct dependencies that have a given dependency tag.

Test: m checkbuild
Change-Id: Ib875563091dcae6b7282b3e3427d0eb07d8c8af5
2018-01-02 18:23:43 -08:00
Nan Zhang
0007d810e2 Change bool, and string properties to *bool, and *string for cc
there's no use case for prepending/appending to bool, and string
properties within module struct. Declearing "*bool" and "*string" almost
cover everything user need.

I did see one case that user specify relative_install_path as
path prefix in cc_defaults, and concatenate with the one in real module
to get the final relative install path in Android.bp <bionic/tests/libs>.

Test: m -j checkbuild
Bug: b/68853585
Change-Id: If3a7a2689c3fc307aae136af6bc9c57f27a1e1a0
2017-11-07 15:57:16 -08:00
Colin Cross
d11fcda940 Convert Visit*Deps from blueprint.Module to android.Module
Also adds checks that the dependencies are android.Modules and
are not disabled.

Test: m checkbuild
Change-Id: I05e945f38915d49cd3c0ab72a86576949bc7eff2
2017-10-24 13:01:03 -07:00
Colin Cross
74d73e2bfb Rename java_prebuilt_library to java_import
And make it work like bazel's java_import, using a "jars" property
instead of "srcs", and allowing multiple jars to be listed.

Test: soong tests
Change-Id: Ida2ace6412bd77b4feb423646000a1401004e0ea
2017-08-11 15:24:11 -07:00
Colin Cross
5ea9bcc50b Fix java prebuilts
The java prebuilt tests weren't registering the prebuilts mutators,
which hid an issue where prebuilts modules weren't getting renamed
to avoid collisions with source modules of the same name, which
ended up causing the prebuilt module to try to add a dependency
on itself.

Test: java_test.go
Change-Id: I3327d27533591cb08a4b8b8b5e1668a6f72be8df
2017-07-31 23:50:01 -07:00