Commit graph

1709 commits

Author SHA1 Message Date
Paul Duffin
1f4ad0e44d Remove unused Module.visibility() method
Bug: 155787200
Test: m nothing
Merged-In: Iee7a9ab9d816ed1948e2c7cde23f9907cfda337d
Change-Id: Iee7a9ab9d816ed1948e2c7cde23f9907cfda337d
(cherry picked from commit 36c5b8d0b8)
2020-05-13 13:50:34 +01:00
Paul Duffin
31c43e7fb3 Add //visibility:override to allow control over inheritance
Visibility rules can be 'inherited' in one of two ways. Either from
defaults or from a module that called ctx.CreateModule(...).
Previously, in both cases the inheriting module could only append
additional visibility rules to the end of the inherited rules. That
made it impossible to restrict the visibility by removing or ignore
inherited rules.

The //visibility:override rectifies that by allowing the inheriting
module to ignore all the rules that they would have inherited. It can
only go at the beginning of a list of rules specified in a module but
after defaults are applied it can end up in the middle of a list of
rules. In that case it behaves as if all the rules up to and including
the //visibility:override rule were discarded.

It can be used with //visibility:private to override
//visibility:public and vice versa.

Bug: 155787200
Test: m nothing
Merged-In: I8a9c9c5a1bdceaee387c08864ae2b34629e0d46f
Change-Id: I8a9c9c5a1bdceaee387c08864ae2b34629e0d46f
(cherry picked from commit 51084ff6cf)
2020-05-13 13:50:34 +01:00
Paul Duffin
cd9b6971c4 Allow sdk_version: "none" to be used in prebuilts/
Bug: 156354511
Test: m nothing
Merged-In: Iffce78cbce88a8341146bf19e78acf25fc69f2b0
Change-Id: Iffce78cbce88a8341146bf19e78acf25fc69f2b0
(cherry picked from commit e5c3b85ee5)
2020-05-13 11:27:44 +01:00
Paul Duffin
4d125bd8ad Retry: Adds support for 'ignored-on-host'
Adds a filter mechanism that can exclude property values from being
included in the common value extraction. That is needed to prevent the
snapshot mechanism from generating invalid output for properties that
are ignored on host (and have their values cleared) and which are not
tagged with `android:"arch_variant"`.

Changes:
* Updates the documentation of SdkMemberType to explain what effect
  the 'ignored-on-host' tag has.
* Adds some tests for this new mechanism.

Bug: 155628860
Test: m nothing
Merged-In: Ibafdb6e921ba5abe505bd8a91ca5a1d9c9b5d0cb
Change-Id: Ibafdb6e921ba5abe505bd8a91ca5a1d9c9b5d0cb
(cherry picked from commit c459f89fb4)
2020-05-10 23:56:28 +01:00
Paul Duffin
08385bf9ac Retry: Detect invalid arch specific properties in snapshot
Previously, the snapshot code did not know whether a specific property
could be arch specific or not and assumed that they all were which
meant that it could generate snapshots containing arch specific values
for properties that are not arch specific and so would fail when
unpacked.

This change requires arch specific fields in SdkMemberProperties to be
tagged as such using `android:"arch_variant"` (just as in module input
property structures). Any property without that must have properties
that are common across all variants.

Bug: 155628860
Test: m nothing
Merged-In: I3df60f0b53ba02ec2c55a80c7da058eac5909d26
Change-Id: I3df60f0b53ba02ec2c55a80c7da058eac5909d26
(cherry picked from commit 864e1b45db)
2020-05-10 23:56:18 +01:00
Paul Duffin
d7acc7b73e Remove reference to obsolete BuildSnapshot()
Bug: 155628860
Test: m nothing
Merged-In: If673d482e8318b5fbb86780236123b0bd59eb5d3
Change-Id: If673d482e8318b5fbb86780236123b0bd59eb5d3
(cherry picked from commit 425b0eacaa)
2020-05-07 22:59:55 +01:00
Paul Duffin
1b115d32b4 Add hook to be called after defaults have been applied
Previously, the only way for a module type to create modules (other
than defining its own mutator) was to register a LoadHook. However,
that is called before defaults are applied so any properties used in
that hook cannot take advantage of defaults, e.g. java_sdk_library
cannot use defaults to set its sdk_version property and have that
affect its child modules.

This change adds a new SetDefaultableHook() to DefaultableModule to
register a hook that is called after any defaults have been applied.

Also adds some tests to ensure that errors in the visibility property
introduced in a DefaultableHook are reported in the gather phase of
visibility processing.

A follow up change will switch java_sdk_library to use that instead
of the AddLoadHook() mechanism.

Bug: 155295806
Test: m checkapi
Merged-In: I13df3115f9e225f7324b6725eaeb16a78cc2538a
Change-Id: I13df3115f9e225f7324b6725eaeb16a78cc2538a
(cherry picked from commit afa9fa104d)
2020-05-07 11:36:57 +01:00
Paul Duffin
eedf3f1f4a Move prebuilts mutators after defaults have been applied
A follow up change will add a mechanism for a module to register a hook
that is called after any defaults have been applied. That is intended
for use by modules like java_sdk_library that create child modules that
are dependent upon properties that could be supplied by defaults.

Creating those child modules after prebuilts mutators are run will
cause problems if those child modules clash with prebuilts modules.
Moving the prebuilts mutators after the defaults mutators will fix
that.

Tests are currently being run with the mutators in different orders so
this change also cleans that up so they are consistent with the actual
code that is being run.

Bug: 155295806
Test: m checkbuild
Merged-In: I825c6df09058fb3a45db196661959eb332aca2f3
Change-Id: I825c6df09058fb3a45db196661959eb332aca2f3
(cherry picked from commit c988c8e202)
2020-05-07 11:36:44 +01:00
TreeHugger Robot
93f1d81cc0 Merge "Simplify package by using LoadHook instead of mutators" into rvc-dev 2020-05-07 06:56:29 +00:00
Artur Satayev
388d39ba9a Introduce min_sdk_version to deps info.
Bug: 149622332
Test: m
Change-Id: Ie6568cb8a82d5cca9a3dc91b5a068abf4b0632dc
Merged-In: Ie6568cb8a82d5cca9a3dc91b5a068abf4b0632dc
Exempt-From-Owner-Approval: cp from aosp
(cherry picked from commit 480e25b74f)
2020-05-06 15:01:14 +00:00
Artur Satayev
fb0a636f6d Merge "Introduce flat deps info list." into rvc-dev 2020-05-06 13:45:16 +00:00
Paul Duffin
a43e13e5d4 Simplify package by using LoadHook instead of mutators
This was not previously possible due to LoadHooks being run after the
module was registered.

Bug: 155462403
Test: m nothing
Merged-In: Ia8383b9d1272bb12c8a83948753a0e4b0d98a650
Change-Id: Ia8383b9d1272bb12c8a83948753a0e4b0d98a650
(cherry picked from commit cdfcec98bb)
2020-05-06 08:21:39 +01:00
Paul Duffin
6615b30812 Document preArch mutators
Bug: 155295806
Test: m checkbuild
Merged-In: I4cd6647a8707f49363d297a3b3082ef19ba93868
Change-Id: I4cd6647a8707f49363d297a3b3082ef19ba93868
(cherry picked from commit aa4162e71e)
2020-05-06 08:20:34 +01:00
Martin Stjernholm
fcb99e07fc Add SDK member support for cc_object.
Test: m nothing
Test: Add
    sdk {
        name: "runtime-module-sdk",
        native_shared_libs: [
            "libc",
            "libdl",
            "libm",
            "ld-android",
        ],
        native_objects: [
            "crtbegin_dynamic",
            "crtbegin_static",
            "crtend_android",
        ],
    }
  to bionic/apex/Android.bp. Then:
    build/soong/scripts/build-aml-prebuilts.sh runtime-module-sdk
  Take the generated runtime-module-sdk-current.zip and unzip into a
  master-art tree without bionic/, edit the generated Android.bp to
  extend cc_prebuilt_* modules with:
    nocrt: true,
    stl: "none",
    system_shared_libs: [],
    apex_available: ["//apex_available:anyapex"],
    recovery_available: true,
    vendor_available: true,
    ramdisk_available: true,
  Then "m com.android.art.debug". This passes Soong but fails in the
  build step because more members are required.
Bug: 148934017
Merged-In: I2ab8f6aadb1440b325697cae4a8ed761c62d15d2
Change-Id: I2ab8f6aadb1440b325697cae4a8ed761c62d15d2
(cherry picked from commit cd07bce437)
2020-05-06 08:17:10 +01:00
Artur Satayev
5e7c32d6cb Introduce flat deps info list.
Compared to full list, flat list drops dependency edges and simply
lists all transitive dependencies for a top-level apex bundle.

Bug: 149622332
Test: m, manually build flatlist
Change-Id: Ibd521c96b7aeab90b95965c1b524e0a0152aaf5a
Merged-In: Ibd521c96b7aeab90b95965c1b524e0a0152aaf5a
Exempt-From-Owner-Approval: cp from aosp
(cherry picked from commit a8bd113a69)
2020-05-05 17:28:41 +00:00
Artur Satayev
334b51730a Export depsInfo into android package.
Move depsInfo into android for easier sharing with APK code.

Bug: 149622332
Test: m, diff'ing outputs for conscrypt module.
Change-Id: If0ee967d37425540e69b4ce9304229d9f2cd86bd
Merged-In: If0ee967d37425540e69b4ce9304229d9f2cd86bd
Exempt-From-Owner-Approval: cp from aosp
(cherry picked from commit 872a144dca)
2020-05-05 16:19:07 +00:00
Paul Duffin
b33d21bdaf Report visibility errors in both check and gather phases
Previously, errors that were found when splitting visibility rules were
only reported in the check phase and simply ignored during the gather
phase. That was because every visibility property that was processed in
the gather phase had already been checked in the check phase. However,
that is not strictly true as it has always been possible to add a
mutator between the check and gather phases that creates a module with
invalid visibility properties that will just be ignored. Fortunately,
that has not happened.

A follow up commit will add the capability to create modules after the
defaults have been applied which means the chances of invalid visibility
properties being ignored will increase.

This change makes both phases report any errors they find. It will not
have any impact on existing code as if any errors are reported in the
check phase then the build will exit before the gather phase. It will
prevent any invalid visibility errors from being ignored.

Bug: 155295806
Test: m nothing
Merged-In: I101fa6b03d2530b16e4394a9e466fead48be0ff0
Change-Id: I101fa6b03d2530b16e4394a9e466fead48be0ff0
(cherry picked from commit 0c83aba28e)
2020-05-05 10:34:55 +01:00
Paul Duffin
abc9a647a2 Reduce duplication in visibility property management
Adds a couple of new methods to manage visibility property instances to
reduce duplication and encapsulate the implementation slightly better.

The AddVisibilityProperty method is exported as it will be needed by
other packages in follow up commits.

Bug: 155295806
Test: m nothing
Merged-In: Ic1a9bb1e151fc6ae65761344fd210b4e4ba74fbc
Change-Id: Ic1a9bb1e151fc6ae65761344fd210b4e4ba74fbc
(cherry picked from commit 5ec73ecc08)
2020-05-05 10:34:30 +01:00
Svet Ganov
ec83fd0642 Updating platform SDK version for R
* Update SDK versions

Test: build + boot

 bug:150281259

Change-Id: I30d7cda3c95327c4080e279e876129eb9e6a8091
Merged-In: I30d7cda3c95327c4080e279e876129eb9e6a8091
2020-05-03 09:41:41 -07:00
Colin Cross
2a5fb91370 Merge changes from topic "sdk_version_variant" into rvc-dev
* changes:
  Add sdk mutator for native modules
  Require apps built against the SDK to use JNI built against the NDK
2020-05-02 01:41:18 +00:00
TreeHugger Robot
99899b3582 Merge "Fix RuleBuilder remoteable actions running in the local pool." into rvc-dev 2020-04-28 19:54:47 +00:00
Jiyong Park
f0d01b7c98 Add test_for property
This change adds 'test_for' property to cc_test_* types. The property is
used to mark a module as a test for one or more APEXes, in which case
the module has accecss to the private part of the listed APEXes. For
example, the module is linked with the actrual shared library in the
APEX instead of the stub of the shared library.

Exempt-From-Owner-Approval: cherry-pick from AOSP

Bug: 129539670
Bug: 153046163
Test: m
Merged-In: I45ed0d7a15540b0d69b2a3b8d9c4cb202adff6f2
(cherry picked from commit 62304bbeec)
Change-Id: I45ed0d7a15540b0d69b2a3b8d9c4cb202adff6f2
2020-04-28 21:35:40 +09:00
Jiyong Park
6a9ddc37a9 mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.

In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.

The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.

cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}

Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.

Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,

cc_library_shared { name: "mylib", static_libs: ["libfoo"] }

can exist and it might be installed to the device, in which case
we really should trigger an error.

Since Make has the knowledge of what's installed and what's not,
the check should be done there.

Exempt-From-Owner-Approval: cherry-pick from AOSP

Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails

Merged-In: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
(cherry picked from commit 89e850ab84)
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-28 09:27:24 +09:00
Colin Cross
01fd7ccbc7 Add sdk mutator for native modules
Compiling native modules against the NDK disables platform features
like ASAN.  For anything shipped on the system image there is no
reason to compile against the NDK.  Add a new mutator to Soong that
creates a platform and an SDK variant for modules that set
sdk_version, and ignore sdk_version for the platform variant.  The
SDK variant will be used for embedding in APKs that may be installed
on older platforms.  Apexes use their own variants that enforce
backwards compatibility.

Test: sdk_test.go
Test: TestJNIPackaging
Bug: 149591340
Change-Id: I7d72934aaee2e1326cc0ba5f29f51f14feec4521
Merged-In: I7d72934aaee2e1326cc0ba5f29f51f14feec4521
(cherry picked from commit 82e192c3ae)
2020-04-27 14:45:05 -07:00
Ramy Medhat
79c4fcce32 Fix RuleBuilder remoteable actions running in the local pool.
This CL fixes a bug with RuleBuilder's handling of remoteable actions.
It adds a new type of pool to identify remoteable rules by the android
module context. The pool is then set to nil to actually run actions at
NINJA_REMOTE_NUM_JOBS parallelism.

Bug: b/154712413
Test: built aosp crosshatch userdebug
Change-Id: I29452f6fc7a161b94189731e3e3cc1f34907b80c
Merged-In: I29452f6fc7a161b94189731e3e3cc1f34907b80c
2020-04-27 18:54:45 +00:00
TreeHugger Robot
416b811742 Merge changes Ib8025019,I7d58d104,I9dd4312c,I995ed389,Iba2a8a5a, ... into rvc-dev
* changes:
  Allow droidstubs to not generate any stubs
  Remove conscrypt.module.intra.core.api.stubs from apex white list
  Ignore PrebuiltDepTag when processing APEX contents
  Stop requiring apex_available on java_library members of sdks
  Add dependency tags to apex available errors
  Extract DepIsInSameApex and RequiredSdks interfaces
2020-04-23 15:19:41 +00:00
TreeHugger Robot
4586da2aae Merge changes Ie883eb45,If46a2f74,I8f4c5395,Ic4eb169d,I2b2408ef, ... into rvc-dev
* changes:
  Replace references to droiddoc with droidstubs
  Allow walkPayloadDeps visitor to control walk flow
  Add apex_available to sysprop_library
  Improve missing apex_available message
  Split TestApexAvailable into separate tests
  Use reflect.Zero(type) to get value to clear field
  Sdk snapshot set compile_multilib per OsType
  Remove old SdkMemberType API for creating snapshot modules
  Improve consistency of handling java snapshot properties
  Make new module creation API more flexible
  Add abstraction for tracking compile multilib usages
  Add support for using cc_library in sdk/module_exports
  Extract the osTypeSpecificInfo code from module creation loop
  Extract archTypeSpecificInfo code from module creation loop
  Clean up the main module creation loop
  Add support for cc_prebuilt_library
  Refactor prebuilt to use srcs supplier function
  Output properties before sets in snapshot module
  Remove SdkMemberType.FinalizeModule
  Follow up a review comment that was missed
  Copy shared_libs and system_shared_libs to module snapshot
  Support extracting common values from embedded structures
  Refactor common value extraction
  Copy white listed apex available settings into snapshot
  Disable installation for sdk snapshot versioned prebuilts
  Remove special handling of test_ apexes
  Remove special handling of com.android.art.debug/release
  Allow sdk members to vary by os type
  Add support for multiple os types
  Copy sdk_version to cc library snapshots
  Refactor java_library/java_test snapshot processing
  Refactor snapshot module creation
  Enable androidmk processing in sdk testing
  Add a nice install paths for module SDKs and exports.
  Copy apex_available properties to snapshot modules
  Improve documentation of CompileMultiTargets and related properties
  Only check copy rules into the snapshot directory
  Simplify java library sdk member code
  Add CommonOS variant for sdk
  Fix bug in error reporting when adding duplicate properties
  Avoid invoking sdk member to add empty list of dependencies
  Add windows to the list of available OS's in sdk tests
  Add support for cc_library_headers in sdk/module_exports
  Prune any empty property sets from the modules before transforming
  Simplify cc library sdk snapshot handling of include dirs/headers
  Add support for transforming a property set after its contents
  Fix issues with bp transformation
2020-04-23 15:19:26 +00:00
Paul Duffin
3766cb7b6a 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
Bug: 153306490
Test: m nothing
Merged-In: I9dd4312c4f995c816c0a31d8d733eb5d7f56e1ea
Change-Id: I9dd4312c4f995c816c0a31d8d733eb5d7f56e1ea
2020-04-22 12:51:52 +01:00
Paul Duffin
f020796cad Add dependency tags to apex available errors
Having dependency tags in the dependency path that shows why a specific
module is considered part of an apex makes it easier to understand why
that is the case and detect possible issues.

Bug: 152762638
Bug: 153306490
Test: m nothing
Merged-In: Iba2a8a5a6abe03dadee456e760aa4373cd00c07b
Change-Id: Iba2a8a5a6abe03dadee456e760aa4373cd00c07b
2020-04-22 12:51:51 +01:00
Paul Duffin
03e7d0ca9c Extract DepIsInSameApex and RequiredSdks interfaces
The DepIsInSameApex() and RequiredSdks() methods were defined in a few
places to avoid having to depend on the whole ApexModule/SdkAware
interfaces directly. However, that has a couple of issues:
1) It duplicates functionality making it difficult to change, changes
   to the definitions outside the main interfaces do not cause compile
   time failures, instead they result in a runtime change in behavior
   which can be difficult to debug.
2) IDE navigation (specifically in Intellij) does not detect that the
   duplicate definitions can resolve to the definitions in the main
   interface.

This change extracts the methods into their own interfaces and reuses
those interfaces instead of duplicating the methods to fix both of
these issues.

Bug: 152878661
Bug: 153306490
Test: m nothing
Merged-In: I0cfdf342a14eb0bfb82b1bd17e0633d81c7facfb
Change-Id: I0cfdf342a14eb0bfb82b1bd17e0633d81c7facfb
2020-04-22 12:51:50 +01:00
Paul Duffin
93520edca2 Remove old SdkMemberType API for creating snapshot modules
Migrates system modules and droid stubs over to use the new API for
creating the snapshot modules and removes the old API.

Bug: 153306490
Test: m nothing
Merged-In: Ia825767f1f7ee77f68cfe00f53e09e6f6bfa027f
Change-Id: Ia825767f1f7ee77f68cfe00f53e09e6f6bfa027f
2020-04-22 12:51:45 +01:00
Paul Duffin
c9103930a4 Improve consistency of handling java snapshot properties
Previously, java snapshot properties (java_library and java_test)
relied on the properties not being optimized when there was a single os
type and instead being added directly to the common os type properties.
However, that means that the behavior is inconsistent for other member
types depending on whether there was one os type or not.

This change updates the java sdk member handling to support
optimization. This involved:
1) Adding AidlIncludeDirs field to librarySdkMemberProperties to
   specify the aidl include dirs instead of extracting that from the
   library field.

2) Renaming jarToExport to JarToExport (in both
   library/testSdkMemberProperties)to allow it to be optimized.

3) Adding MemberType() and Name() methods to SdkMemberPropertiesContext
   to avoid having to store the former in the properties struct and
   retrieve the latter from the library/test fields.

4) Removing the now unused library/test fields from the properties
   structures.

5) Separating the processing of the jar/test config in
   AddToPropertySet(...) as they may be optimized separately.

6) Ditto for the jar/aidl include dirs.

7) While doing this work I noticed that although the contents of the
   aidl include dirs are copied into the snapshot the java_import does
   not make use of them. Raised bug 151933053 and added TODO to track
   that work.

Bug: 142935992
Bug: 153306490
Test: m nothing
Merged-In: Iba9799e111ca5672b2133568163d8c49837ba9cd
Change-Id: Iba9799e111ca5672b2133568163d8c49837ba9cd
2020-04-22 12:51:44 +01:00
Paul Duffin
17ab883cb0 Make new module creation API more flexible
Previously passing additional information to the implementations of
AddPrebuiltModule() or the SdkMemberProperties interface would have
required making changes to the API. This change added an
SdkMemberContext object into which additional information can easily
be added without requiring changes to existing implementations.

The BuildSnapshot() method was not modified because it is deprecated
and will be removed in a follow up change.

It also switches the API from passing variants as android.SdkAware to
android.Module. That is for a couple of reasons:
1) SdkAware is designed for managing the relationship between the
   module and the SDK, not for generating the output snapshot. As such
   there is nothing in SdkAware that is needed for generating the
   output snapshot.
2) Accepting android.Module instead makes it easier to use the
   underlying code for generating the snapshot module as well as the
   individual member modules.

This is in preparation for a number of improvements and bug fixes in
both the snapshot creation code and implementations to address found
while trying to built the platform against ART prebuilts.

Bug: 151937654
Bug: 153306490
Test: m nothing
Merged-In: Iac10f1200c0f283aa35402167eec8f9aeb65a38e
Change-Id: Iac10f1200c0f283aa35402167eec8f9aeb65a38e
2020-04-22 12:51:44 +01:00
Paul Duffin
6cb8f172b8 Add support for using cc_library in sdk/module_exports
Added link type support in module creation code as cc_prebuilt_library
has to provide both shared and static libraries.

Had to add some calls to FirstUniquePaths() around the include dirs
settings in library_sdk_member as otherwise the shared variant contains
duplicate include dirs (presumably because it gets one set from its
dependency on the static variant and one set of its own). That
difference in include dirs causes problems in the generated
cc_prebuilt_library.

Bug: 153306490
Test: m nothing
Bug: 142918168
Merged-In: Ie7f23fc2341c83c7814cc98e3970df4f5d4c8423
Change-Id: Ie7f23fc2341c83c7814cc98e3970df4f5d4c8423
2020-04-22 12:51:43 +01:00
Paul Duffin
406ea1c393 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.

Bug: 153306490
Test: m nothing
Bug: 142918168
Merged-In: I5cc7517c46cce96924c9f34ba1b046b468f7684a
Change-Id: I5cc7517c46cce96924c9f34ba1b046b468f7684a
2020-04-22 12:51:40 +01:00
Paul Duffin
2bdbe83ec9 Remove SdkMemberType.FinalizeModule
This was only being used to set the "stl" property for cc library sdk
member type and so that functionality was moved to AddPrebuiltModule()
and FinalizeModule was removed.

Required a few test changes to move the property to the correct
position in the generated module.

Bug: 142918168
Bug: 153306490
Test: m nothing
Merged-In: If6400189833d4ff3285e7a7adf63a9b509e2a03b
Change-Id: If6400189833d4ff3285e7a7adf63a9b509e2a03b
2020-04-22 12:51:39 +01:00
Paul Duffin
206433a1fa Copy shared_libs and system_shared_libs to module snapshot
This change ensures that the runtime dependencies between a
binary/shared library are correctly specified in the snapshot so that
the build can ensure that shared libraries are built before the targets
that use them.

It adds support for differentiating between references that are
required to refer to another sdk member (required) and those that may
refer to either an sdk member or a non-sdk member (optional). The
latter is used for shared library references as the libraries used by
an sdk member may be provided from outside the sdk. e.g. liblog is not
part of the ART module but is used by some members of the ART sdk.

Bug: 142935992
Bug: 153306490
Test: m nothing
Merged-In: Ia8509ffe79b208c23beba1880fe9c8a92b732685
Change-Id: Ia8509ffe79b208c23beba1880fe9c8a92b732685
2020-04-22 12:51:38 +01:00
Paul Duffin
49096815fe Support extracting common values from embedded structures
This change also added support for excluding properties from common
value extraction by using a struct tag of `sdk:"keep"` That was needed
to prevent the fields in SdkMemberPropertiesBase from having their
values cleared.

The purpose of this change is to make it easier to share functionality
across sdk member types.

Bug: 142935992
Bug: 153306490
Test: m nothing
Merged-In: Ie5160a8f854056920e411801ca20721eab7c8578
Change-Id: Ie5160a8f854056920e411801ca20721eab7c8578
2020-04-22 12:51:38 +01:00
Paul Duffin
404db3f4e8 Copy white listed apex available settings into snapshot
Makes sure that the module snapshots do not rely on the white list
of apex available settings so that when those lists are removed it is
not necessary to update any snapshots.

Bug: 142935992
Bug: 153306490
Test: m nothing
Merged-In: Iedcff7dfc2646a4da77258d16e06657dd2f411f9
Change-Id: Iedcff7dfc2646a4da77258d16e06657dd2f411f9
2020-04-22 12:51:37 +01:00
Paul Duffin
9b358d7a58 Add support for multiple os types
Updates the member snapshot creation code to support multiple os types.
It basically sorts the variants by os type, then applies the code to
optimize the arch properties and then it optimizes the properties that
are common across architectures and extracts any properties that are
common across os types.

The java and cc member types needed to be modified to make the location
of the generated files within the snapshot os type dependent when there
is more than one os type. That was done by adding an OsPrefix() method
to the SdkMemberPropertiesBase which returns the os prefix to use when
there is > 1 os type and otherwise returns an empty string.

Added three tests, one for cc shared libraries, one for cc binary and
one for java header libraries.

Bug: 150451422
Bug: 153306490
Test: m nothing
Merged-In: I08f5fbdd7852b06c9a9a2f1cfdc364338a3d5bac
Change-Id: I08f5fbdd7852b06c9a9a2f1cfdc364338a3d5bac
2020-04-22 12:51:34 +01:00
Paul Duffin
33cedcc421 Refactor snapshot module creation
Generalize the processing of arch specific properties to reduce
duplication in snapshot module creation and simplify addition of
support for handling multiple os types.

Supporting multiple os types with the current method for building
snapshot modules would require every affected module type to add
support for it. Rather than duplicate multiple os type handling code
across those module types this work generalizes the process cc modules
use for handling arch types as it can be used as a basis for handling
multiple os types. Migrating module types over to this new process
will insulate them from having to handle multiple os types.
OB
SdkMemberType changes:
* BuildSnapshot is deprecated in favour of the new AddPrebuiltModule()
  method.
* Additional methods, CreateVariantPropertiesStruct() and
  FinalizeModule() are added.
* A new interface SdkMemberProperties, is defined that handles
  extracting information from the variant (prior to common value
  optimization) and adding properties to a property set.

The sdk module type uses these new methods and types to delegate the
member type specific processing to the relevant member types while
handling the behavior that is common across all members types, e.g.
extracting common values across multiple architectures. A future change
will leverage this processing to add support for multiple os types.

This change also refactors the cc module processing to use the new
process.

Bug: 150451422
Bug: 153306490
Test: m nothing
Merged-In: If6ab2498407b17f50391d062cd9afc01b5e01af4
Change-Id: If6ab2498407b17f50391d062cd9afc01b5e01af4
2020-04-22 12:51:33 +01:00
Paul Duffin
22595f9370 Enable androidmk processing in sdk testing
Previously, while sdk tests would pass the sdk code would often fail
in androidmk processing. This change makes the tests more realistic
and will catch the errors earlier.

Bug: 142935992
Bug: 153306490
Test: m nothing
Merged-In: Ifd0b2d7cf24e941c919f6b6e0beb2403a67d4308
Change-Id: Ifd0b2d7cf24e941c919f6b6e0beb2403a67d4308
2020-04-22 12:51:32 +01:00
Nicolas Geoffray
a40f0b5db9 Add a nice install paths for module SDKs and exports.
Following how NDK also creates its own install path.

Bug: 142935992
Bug: 153306490
Test: cc_sdk_test.go, java_sdk_test.go
Merged-In: I98a3656903f37f6d7c90e6cf609431b2461a6161
Change-Id: I98a3656903f37f6d7c90e6cf609431b2461a6161
2020-04-22 12:51:31 +01:00
Paul Duffin
3a6c095145 Copy apex_available properties to snapshot modules
Bug: 142935992
Bug: 153306490
Test: m nothing
Merged-In: I1cdaae5b4e13a89dc46541dacd34ef5a44735b6a
Change-Id: I1cdaae5b4e13a89dc46541dacd34ef5a44735b6a
2020-04-22 12:51:30 +01:00
Paul Duffin
28d70c74db Improve documentation of CompileMultiTargets and related properties
Bug: 153306490
Test: m nothing
Merged-In: I1e3f0bf7e2a1303d2519d8405a228e9234235514
Change-Id: I1e3f0bf7e2a1303d2519d8405a228e9234235514
2020-04-22 12:51:30 +01:00
Paul Duffin
b0cbec3ada Add CommonOS variant for sdk
Adds a CommonOS variant for sdk that depends on the os specific
variants and is used to generate a single sdk for multiple OsTypes,
e.g. host linux and android.

At the minute the member types only support a single OsType but the
basic mechanism for managing the CommonOS variant and collating the
variants across all of them is there.

The only visible effect of this change is that the location of the
generated snapshot is changed, it is no longer os specific and instead
is in the same location irrespective of which os it is built for.

A lot of tests needed to be changed to specify "common_os" as the
variant type instead of the specific os type. As that is the same across
all tests it is hard coded in CheckSnapshot method.

Bug: 153306490
Test: m nothing
Bug: 150451422
Merged-In: If36be39b06d6910453649f7c288c2d34f688b2f4
Change-Id: If36be39b06d6910453649f7c288c2d34f688b2f4
2020-04-22 12:51:28 +01:00
Jeongik Cha
8691f3f75c Apply EnforceRROExemptedTargets in Soong
As PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS is defined in make, define it in
soong accordingly

Bug: 150820813
Test: m
Change-Id: I309482b6ad439a7602127f68f2f7ffa856b9e192
Merged-In: I309482b6ad439a7602127f68f2f7ffa856b9e192
2020-04-20 14:02:23 +00:00
Artur Satayev
b39ea9b61c Allow defining neverallow in packages other than android.
This exposes test func on ValueMatcher and helpers relevant for testing neverallows.

Bug: 153333044
Test: m
Change-Id: Ied07cd33afa537f9d7aa3c33e59f4ac985901a0f
Merged-In: Ied07cd33afa537f9d7aa3c33e59f4ac985901a0f
Exempt-From-Owner-Approval: clean cherry-pick
(cherry picked from commit c5570ac9b1)
2020-04-16 13:34:31 +00:00
TreeHugger Robot
a59774eb49 Merge "soong config: add value_variable substitution" into rvc-dev 2020-04-11 17:24:57 +00:00
TreeHugger Robot
a6ffd8b141 Merge "Make the names of 'soong_config_module_type_import' modules unique." into rvc-dev 2020-04-10 21:09:21 +00:00