Commit Graph

523 Commits

Author SHA1 Message Date
Paul Duffin f9b1da0fcb Dedup registration code for module types and singletons
The registration of module types and singletons is duplicated between
init() functions that register them for use in the build runtime and
test context creation code that registers them for testing.

This is a proof of concept for a mechanism that will allow the code
to be shared. It defines a RegistrationContext interface that is
implemented by both the TestContext and the new initRegistrationContext
type. An instance of the the latter is available through the
InitRegistrationContext variable.

The intent is that the registration of the module types and singleton
types will be extracted from the init() function into a separate
function that takes a RegistrationContext parameter. That method is
called from init() passing in the InitRegistrationContext and from a
test passing in the TestContext. Something like this:

  func init() {
    RegisterBuildComponents(android.InitRegistrationContext)
  }

  func RegisterBuildComponents(ctx android.RegistrationContext) {
    ctx.RegisterModuleType(....)
    ....
  }

A test would do something like this:

  ctx := android.NewTestContext()
  RegisterBuildComponents(ctx)

Test: m nothing
Change-Id: I97173cabb6d6cf7ce98fdb5f73418438b1997b35
2019-12-19 10:09:53 +00:00
Treehugger Robot a03edbeddc Merge "Remove apex_pubkey from the bundle module" 2019-12-19 01:55:44 +00:00
Nikita Ioffe 5c3869a7db Remove apex_pubkey from the bundle module
It's not yet supported by bundletool and blocks other testing (see
attached bug).

This is a partial revert of
https://android-review.googlesource.com/c/platform/build/soong/+/1183459/

Test: out/dist/mainline_modules_arm64/com.android.tzdata-base.zip
Test: checked content doesn't have apex_pubkey
Bug: 146460014
Change-Id: I268caa9f9736ba1913145a1ce1065f6f5179a6db
2019-12-18 17:40:21 +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
Treehugger Robot 572aeed6a4 Merge "Move imageMutator before archMutator" 2019-12-18 02:34:36 +00:00
Jooyung Han 405c7ab959 Merge "Override package name for VNDK APEX" 2019-12-18 01:10:36 +00:00
Jooyung Han 70415ceb9e Merge changes Icbdf4979,I1a6f135d
* changes:
  Fix apex to override certificate
  Fix apex to follow deps of modules with stubs.
2019-12-18 01:04:53 +00:00
Colin Cross fb0c16e95a Move imageMutator before archMutator
Run the imageMutator between osMutator and archMutator so that
different arch variants can be set for the different partitions.

Bug: 142286466
Test: m checkbuild
Change-Id: I65d05714b75aa462bf9816da60fdc2deda4de593
Merged-In: I65d05714b75aa462bf9816da60fdc2deda4de593
(cherry picked from commit 9c8f687584)
2019-12-17 14:45:11 -08:00
Jooyung Han 27151d93b6 Override package name for VNDK APEX
com.android.vndk.v<VER> is overridden with
com.google.android.vndk.v<VERE>.

Test: m com.android.vndk.current
    && aapt2 dump badging ../system/apex/com.android.vndk.current.apex
Change-Id: I623d7a144418d7198f0bbf09c5dc983ed1a631c6
Merged-In: I623d7a144418d7198f0bbf09c5dc983ed1a631c6
(cherry picked from commit 0ed1b1b169)
2019-12-17 15:22:21 +00:00
Jooyung Han f121a657c9 Fix apex to override certificate
The rules for apex certificate:
1. <unspecified>: use <default app cerficicate>
2. name: use <default app cerficiate dir>/<name>(.x509.pem|.pk8)
3. :module: use specified by <module>

Certificates can be overridden by PRODUCT_CERTIFICATE_OVERRIDES.

Currently, 1) and 2) aren't overridden by PRODUCT_CERTIFICATE_OVERRIDES,
which should be.

Bug: n/a
Test: m (apex_test.go amended)
Change-Id: Icbdf4979613ef10127ecc02f3debd6a798460532
2019-12-17 15:20:50 +09:00
Jooyung Han 671f1ce75e Fix apex to follow deps of modules with stubs.
In case that an apex module depends on a module with stubs directly
*and* indirectly, the build system should follow the deps graph further.

Note that WalkDeps() visits deps in DFS and it won't visit again visited
modules.

Bug: n/a
Test: m (apex_test.go amended)
Change-Id: I1a6f135dbda6d1eb641575a3fbbc9bbee0622076
2019-12-17 15:18:54 +09:00
Treehugger Robot 1d1a920794 Merge "Support apps attribute in apex_defaults" 2019-12-17 05:44:42 +00:00
Treehugger Robot bd0624304e Merge "Use empty string for core image variant" 2019-12-16 20:54:32 +00:00
Jooyung Han f21c797f38 Support apps attribute in apex_defaults
Adding overridableProperties to apex_defaults as well.

Bug: 146217017
Test: m
Change-Id: I51182fec25ee589fea4006164c4dd69acc5ba67d
2019-12-16 13:36:34 +00:00
Treehugger Robot c829ff371e Merge "java libs that isn't installable is gracefully rejected" 2019-12-16 09:56:13 +00:00
Jiyong Park 479321dc34 java libs that isn't installable is gracefully rejected
... rather than causing soong panic.

Bug: 146197571
Test: m (apex_test amended)
Change-Id: I3679a4e3041527533c1c05d54f3aa514abd6095b
2019-12-16 15:59:54 +09:00
Jiyong Park 1833ceff09 fix: LOCAL_PATH for modules included in APEX is wrong
This change fixes a bug that LOCAL_PATH for modules included in an APEX
is set to the path of the APEX bundle, not to the path of the embedded
module. For example, LOCAL_PATH of libconscrypt included in
com.android.adbd was set to /system/core/adb instead of
/external/boringssl. This caused a problem that NOTICE file in
/external/boringssl is not tagged to libconscrypt, but the NOTICE file
for adbd is.

Fixing the problem by recording the module directories of the included
modules and emitting it in LOCAL_PATH.

Bug: 145347092
Test: Settings -> About Phone -> Legal Information -> Third-party
license. The license for /apex/com.android.adbd/lib64/libconscrypt.so is
OpenSSL.

Change-Id: I76f1830d5a10af63fa74dcc2a42730ffabb8c4ed
2019-12-16 10:53:44 +09: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
Treehugger Robot ac68248051 Merge "Add "legacy_android10_support" to "apex"" 2019-12-14 02:07:16 +00:00
Treehugger Robot e676810de5 Merge "Install flattened/unflattend apexes for GSI" 2019-12-13 21:10:56 +00:00
Treehugger Robot 90872f1c9c Merge "add apex_pubkey and apex_manifest.pb to the bundle module" 2019-12-13 03:16:31 +00:00
Jooyung Han 214bf37311 Add "legacy_android10_support" to "apex"
APEXes with "legacy_android10_support" will have apex_manifest.json for
compatibility as well as apex_manifest.pb.

Bug: 143951586
Test: m (soong tests)
Change-Id: I019252aee5a9423f4b180ba1026e6e99c9961437
2019-12-13 08:47:16 +09:00
Jiyong Park 0b0e1b9804 AndroidMkEntries() returns multiple AndroidMkEntries structs
AndroidMkEntries now returns multiple AndroidMkEntires so that a module
can emit multiple Make modules if needed.

Bug: 128708192
Test: m

Change-Id: I56b6f76d22943b80329951c5acb80a1b932441ad
2019-12-11 17:25:27 +09:00
Treehugger Robot 32fc94d097 Merge "Add property to apex soong modules to generate an APEX without hashtree" 2019-12-11 01:51:48 +00:00
Nikita Ioffe c72b5dd10a Add property to apex soong modules to generate an APEX without hashtree
This will help testing on-device hashtree generation.

Test: see other CL in topic
Bug: 145670581
Change-Id: I96b1b2392302aed8a6e80ed52de2d057a532a288
2019-12-10 11:24:53 +00:00
Oliver Nguyen 1382ab6d31 Add coverage flags for Clang coverage builds.
Bug: 143977934
Test: m CLANG_COVERAGE=true
Test: m NATIVE_COVERAGE=true
Change-Id: I5d07d336e241856961eb0bc9678fdc9d5a076802
2019-12-09 16:35:15 -08:00
Treehugger Robot 455e3a089d Merge "Move/dedupe some host path functions in package_ctx.go." 2019-12-09 23:20:16 +00:00
Martin Stjernholm 7260d066ea Move/dedupe some host path functions in package_ctx.go.
These functions don't need a PackageContext object.

Test: m
Bug: 145934348
Change-Id: Ia1da2c76cbad292f9ca79617199b2b5b6b265568
2019-12-09 22:04:21 +00:00
Jiyong Park 53ae334130 add apex_pubkey and apex_manifest.pb to the bundle module
The two were missing.

Bug: 145678884
Test: m out/dist/mainline_modules_arm64/com.android.tzdata-base.zip and
inspect the content

Change-Id: I7e244561f59e5adce56b6a64f363a413faa106f2
2019-12-08 02:06:24 +09:00
Treehugger Robot e2f3b5dfe5 Merge "Move ImageMutator after archMutator" 2019-12-07 00:37:30 +00:00
Jeff Sharkey e2e4a5dd56 Merge "Overridden APEX doesn't contribute to the file contexts" 2019-12-06 23:02:01 +00:00
Colin Cross ae6c5207cc Move ImageMutator after archMutator
Move the ImageMutator to be registered just after the archMutator
in preparation for moving it between osMutator and archMutator.
Requries updating variants in a few tests that now run the
ImageMutator.

Bug: 142286466
Test: no change to build.ninja
Test: all soong tests
Change-Id: Ia9d2a7bc0e225bedec3c9a83ea04f471a931bf47
2019-12-06 12:37:14 -08:00
Treehugger Robot cea93afe76 Merge "apex_available is defaultable" 2019-12-06 04:23:37 +00:00
Jooyung Han 3ab2c3e68c Install flattened/unflattend apexes for GSI
GSI targets are supposed to have both 'flattened' and 'unflattened'
APEXes. By adding 'flattened' APEX as REQUIRED moduled for 'unflattened'
APEX, both will be installed togetther.

This is done by a new variable PRODUCT_INSTALL_EXTRA_FLATTENED_APEXES,
which is set only for GSI targets.

Bug: 137802149
Test: lunch aosp_arm64-userdebug && m
  resulting apex images under /system/apex
  and flattened apexes under /system/system_ext/apex

Change-Id: I336e2674e427b358542e0045b2a49dfa3d84095b
2019-12-06 09:52:19 +09:00
Jiyong Park 317645e84c Overridden APEX doesn't contribute to the file contexts
This change fixes the problem that when an apex module is overridden by
another override_apex, the <apex_name>-file_contexts are duplicated when
creating the system-level file-contexts.

Fixing this by not emitting the file_context info for the overridden
apex.

In doing so, OverridableModule interface was extended to have
GetOverriddenBy() method which can be used to test whether a module is
an overridden one or not.

Bug: 144338929
Test: m (apex_test amended)
Test: add "override_apex {name:"com.googlge.android.tzdata",
Change-Id: I5e9401c32899bb9987c90cba4185f571dc1a87f0
base:"com.android.tzdata"}" and the build is successful
2019-12-05 13:25:39 +09:00
Treehugger Robot 7b34ebf447 Merge "Remove implicit outputs for the flattened APEX Make module" 2019-12-05 00:21:29 +00:00
Jiyong Park 1753e58df7 Remove implicit outputs for the flattened APEX Make module
When flattened, the Make module for an APEX is a phony package for the
files in it. There is no output (either implcit or explicit) there.

Bug: 144338929
Test: m
Test: check the generated Android-<target>.mk file
Change-Id: I86df3b69f402a7e2d94bafa39f2aad3312d8c28b
2019-12-04 13:38:56 +09:00
Jiyong Park 3814f4df2b apex_available is defaultable
Previously, it was defaultable only for cc_library. Now, it is
defaultable for all module types.

Bug: 128708192
Test: m
Change-Id: If248f593da6f4b724bf889ccd7f2e077d48069b5
2019-12-02 13:48:33 +09:00
Jiyong Park f653b05d55 Refactor the routine for creating apexFile
This change is to make it easier to add new fields to the struct.
transitiveDep field is added to distinguish apexFiles coming from
transitive dependencies of the APEX. We will later use the info to
reduce the size of bundled APEXes by replacing the transitive deps with
symlinks to the corresponding files in the system partition outside of
the APEX.

Bug: 144533348
Test: m

Change-Id: I283859f2f2f1b5cfb3025569f168ba8569b22bb9
2019-11-30 14:49:13 +09:00
Jooyung Han 6aa363b7ae Merge "Fix: install flattened apex on system_ext" 2019-11-27 07:30:54 +00:00
Jooyung Han 91df2084ad Fix: install flattened apex on system_ext
This build rule is specific to platform APEXes.
For non-platform APEXes, MakeAsSystemExt() is not applied.

This fixes the cases of "soc_specific: true" apexes which fails to
build.

Bug: 139053989
Test: m nothing (soong tests)
Change-Id: I98d0257499647ab41cdaa62a3671d89addbdf833
Exempt-From-Owner-Approval: got +1 before rebasing
2019-11-27 07:30:37 +00:00
Colin Cross 09ef474b6f Merge changes I0dcc9c7b,I9bc40642
* changes:
  Move cc.imageMutator into the android package
  Make CreateVariations return []android.Module
2019-11-25 22:30:17 +00: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
Jaewoong Jung 1670ca0d8b Fix Make modules name conflict for override_apex
When an override_apex named Foo overrides an apex module named Bar, the
Make modules from Foo have Foo as their suffix. Previously the suffix
was Bar for both of the overriding and the overridden APEXes, causing
name conflicts in the Make side.

Bug: 144338929
Test: apex_test.go
Change-Id: I1396910ab294ba5f5e0585af6d37f1eab9460250
2019-11-23 16:20:50 +09:00
Jooyung Han 9d78c66ac3 Merge "Make 'file_contexts' prop as `android:"path"`" 2019-11-23 03:37:33 +00:00
Treehugger Robot 126c57b52d Merge changes I7642c57b,I2120b40e
* changes:
  apex uses the first arch variant of prebuilt_etc modules
  sh_binary prefer 32bit when TARGET_PREFER_32_BIT
2019-11-22 02:53:04 +00:00
Jooyung Han 54aca7b3f3 Make 'file_contexts' prop as `android:"path"`
For platform APEXes, file_contexts should point a file under
/system/sepolicy.

Bug: 144732805
Test: m
Change-Id: Ib2d5db715bbebc80a6178d1c42e387b268cc4a0d
2019-11-21 22:05:06 +09:00
Jiyong Park ce6aadc410 apex uses the first arch variant of prebuilt_etc modules
prebult_etc module type does not respect prefer32, i.e. its primary arch
is 64-bit on 64/32-bit device even when built with TARGET_PREFER_32_BIT
is true. However, the apex module type respects prefer32 and therefore
when TARGET_PREFER_32_BIT is true its primary arch becomes 32-bit. Then
the problem is that the apex tries to depend on 32-bit variant of the
prebuilt_etc modules which don't exist.

Fixing the problem by force using the first arch of the device when
adding dependencies to prebuilt_etc modules.

Bug: 144532908
Test: choosecombo 1 aosp_arm64 userdebug; TARGET_PREFER_32_BIT=true m;
Change-Id: I7642c57b05a837495587bbe4d3589d8549607862
2019-11-21 16:16:40 +09:00
Colin Cross 7228ecd5e3 Move cc.imageMutator into the android package
Prepare for making the image mutator available to all modules and
moving it between the os and arch mutators by moving it into the
android package and using an interface implemented by the module
types to control it.

Bug: 142286466
Test: No unexpected changes to out/soong/build.ninja
Change-Id: I0dcc9c7b5ec80edffade340c367f6ae4da34151b
2019-11-20 15:21:32 -08:00
Jiyong Park 5d790c3dda Add override_apex module type
override_apex module type is used to override existing apex module with
certain properties overridden. Currently, only the 'apps' property is
overridable.

Bug: 144338929
Test: m
Change-Id: Ic050b062093cda29ce78126cc92dd6097647f7db
2019-11-19 16:49:36 +09:00
Jiyong Park 09d77522fe split apex.go
apex.go is too big. Separate the build rule and android.mk generation
logic into builder.go and androidmk.go, respectively. prebuilt_apex is
moved to prebuilt.go as well.

No refactoring has been made other than the splitting.

Test: m
Change-Id: I839ab0a1ba2b70ce82d98ac1fa8e3534808b5fd3
2019-11-18 16:37:06 +09:00
Treehugger Robot a3ab1a927e Merge "Change the partition of outputfile" 2019-11-18 01:43:50 +00:00
Treehugger Robot 19258857ef Merge "apexDepsMutator is now bottom-up mutator" 2019-11-15 05:18:24 +00:00
Treehugger Robot bbdeda5bed Merge "Override apexes with LOCAL_OVERRIDES_MODULES" 2019-11-15 05:02:55 +00:00
Jiyong Park a308ea1591 apexDepsMutator is now bottom-up mutator
... in preparation for override_apex.

Bug: 144338929
Test: m
Change-Id: I6c19e384edc089fe5c8aa9bd00082178bd1a37a2
2019-11-15 10:38:39 +09:00
Treehugger Robot bc196606c3 Merge changes Ibcc1096e,I21ac2441
* changes:
  Install AndroidApp only when needed
  Reland: JNI lib is always embedded for APKs in APEX
2019-11-15 00:10:05 +00:00
Jiyong Park b0a012cfec Override apexes with LOCAL_OVERRIDES_MODULES
APEXes are ETC type, which should be overridden via
LOCAL_OVERRIDES_MODULES. This change fixes a bug that
LOCAL_OVERRIDES_PACKAGES was used for APEXes.

Bug: 140792287
Test: m
Test: add com.google.android.tzdata to PRODUCT_PACKAGES and build.
/system/apex/com.google.android.tzdata.apex exists, but
/system/apex/com.android.tzdata.apex doesn't.

Change-Id: Id65743b36e0b706d6ffd8cae0597cc0a42a83fb7
2019-11-14 17:17:03 +09:00
Sundong Ahn d95aa2d45c Change the partition of outputfile
If some apex module can be installed for both flattened and unflattened,
flattened apex should be installed to system_ext partition.
So add MakeAsSystemExt func to change the partition from system to
system_ext.

Bug: 139053989
Test: m -j
Change-Id: I3e3430413a9045d96130af99e249567b1a26ed7e
2019-11-14 16:04:15 +09:00
Jooyung Han c5c4d18db0 Merge "make ApexProperties defaultable" 2019-11-14 00:42:43 +00:00
Roland Levillain c3eb1b2959 Merge "Fix some typos in Soong." 2019-11-13 18:50:36 +00:00
Jiyong Park 52cd06fc73 Reland: JNI lib is always embedded for APKs in APEX
If a JNI lib is depended on by an APK that is included in an APEX, the
lib is embedded inside the APK.

This change also fixes a bug that APKs are not mutated for APEXes.

Bug: 144135069
Test: m (apex_test.go amended)
Change-Id: I21ac24412b30c05afc03385655c6b196130dffe3
2019-11-14 00:39:47 +09:00
Sam Saccone f9e10f9443 Merge "Revert submission" 2019-11-13 15:24:50 +00:00
Sam Saccone e3c22f7a3f Revert submission
Reason for revert: b/144387414
Fixes: b/144387414
Change-Id: I21e15a4d149a5a8fefd0f84010600cb41b59db95
2019-11-13 15:24:11 +00:00
Roland Levillain 8ac05575aa Fix some typos in Soong.
Test: m
Change-Id: I032b6ce2a61491b88416db9943b42e6af4783459
2019-11-13 10:46:49 +00:00
Jooyung Han 18020eabc4 make ApexProperties defaultable
ApexPropreties are added in InitApexModule() and they are supposed to be
defaultable. To be defaultable, InitApexModule() should be called before
InitDefaultableModule().

Bug: 144332048
Test: m (soong test added)
Change-Id: I6c90ed3b66a086292a4c0ecb37c61f83769e62bd
2019-11-13 05:52:57 +00:00
Treehugger Robot d006779e3e Merge "JNI lib is always embedded for APKs in APEX" 2019-11-13 02:25:25 +00:00
Ulyana Trafimovich b21ed4281e Merge "Revert^4 "Package dexpreopt artifacts for libcore jars in the ART apex."" 2019-11-11 10:30:12 +00:00
Jiyong Park d237ad6d71 JNI lib is always embedded for APKs in APEX
If a JNI lib is depended on by an APK that is included in an APEX, the
lib is embedded inside the APK.

This change also fixes a bug that APKs are not mutated for APEXes.

Bug: 144135069
Test: m (apex_test.go amended)
Change-Id: Icf490d2701a7ede8bcad7e671fc72be9c8d7c01e
2019-11-11 12:40:09 +09:00
Treehugger Robot c70d3c3cf6 Merge "APEX now correctly tracks jni_lib dependencies" 2019-11-09 13:53:08 +00:00
Jooyung Han d0e39622c7 Merge "apex_manifest in protobuf binary format" 2019-11-08 17:33:38 +00:00
Ulyana Trafimovich de534414b3 Revert^4 "Package dexpreopt artifacts for libcore jars in the ART apex."
This reverts commit bf0e47648a.

Reason for revert: coverage build with EMMA_INSTRUMENT_FRAMEWORK=true
is fixed by inspecting the environment variable and not generating
boot image in case it is set.

Dexpreopt artifacts for the libcore part of the boot class path are
now packaged in the ART apex. The system image still contains
dexpreopt artifacts for the full set of boot class path libraries
(both libcore and framework); the libcore part will be removed and
boot image extension will be used in a follow-up CL.

Since this is specific to the ART apex and makes no sense for other
apexes, the implementation adds a boolean flag "is ART apex" rather
than a new apex module property.

Build rules for the new set of dexpreopt artifacts are created using
a new variant of the global boot image config. Previously we had two
variants: "default" (for the system image) and "apex" (for the
JIT-zygote experiment). This patch adds a third "art" variant.

Test: m
Test: m art/build/apex/runtests.sh

Bug: 144091989
Change-Id: I113c0d39222d6d697cb62cd09d5010607872fc2b
2019-11-08 12:48:53 +00:00
Jiyong Park 8be103b04c APEX now correctly tracks jni_lib dependencies
Bug: 144135069
Test: m (apex_test.go amended)
Change-Id: If9dde4e2e62c2642267dbcac68bab76a032682c0
2019-11-08 15:53:48 +09:00
Jooyung Han 01a3ee287a apex_manifest in protobuf binary format
For Q compatibility, .json files are also bundled.

Three different apex_manifest files are built from input.
- apex_manifest.json: Q-readable .json file
- apex_manifest_full.json: input + dependency
- apex_manifest.pb: apex: converted from apex_manifest_full.json

apexer will handle these files.

Bug: 143654022
Test: m
Change-Id: I9697094057f0c0543282b1b46b7535cf21431176
2019-11-08 13:40:45 +09:00
Jooyung Han 39edb6c6c1 VNDK APEX contains related *.libraries.txt files
These files were highly coupled with vndk version, so having them inside
the corresponding VNDK APEX is reasonable.

These files are used by linkerconfig and libnativeloader. In the future,
they reference these files from and VNDK APEX.

Bug: 141450808
Test: m com.android.vndk.current
Change-Id: I055a979d2636ddd8844a0afff81f6ba441f7965e
2019-11-07 16:47:38 +09:00
Treehugger Robot 549f6c235f Merge "Create variants for each image type" 2019-11-01 02:13:52 +00:00
Jooyung Han e9b33cd8f8 Merge "apex: Restrict usage of "use_vendor"" 2019-11-01 01:58:33 +00:00
Jooyung Han dc782449b8 apex: Restrict usage of "use_vendor"
When use_vendor is used, native modules are built with
__ANDROID_VNDK__ and __ANDROID_APEX__, which may cause
compatibility issues. (e.g. libbinder)

Even though libbinder restricts its availability via
'apex_available' property and relies on yet another macro
__ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from
other APEX modules to avoid similar problems.

Bug: 142684427
Test: m -j
Change-Id: Ibc781de2efcd20cb6688a183b08e908a8a6e2593
2019-11-01 03:15:38 +09:00
Sundong Ahn abb6443895 Create variants for each image type
Create variant of image, zip or flattened according to
TARGET_FLATTEN_APEX and payload type.
If payload type is zip, only zip variant is created because flattened
apex is not supported. And if payload type is image, image and flattened
variants are created.

Bug: 139053989
Test: m -j
Change-Id: Ibde18490d23ec602c4cca97cf97db90a562e014e
2019-10-31 22:14:46 +09:00
Jooyung Han bdad6c378f Merge "apex: __ANDROID_APEX__ defined with no value" 2019-10-30 23:50:58 +00:00
Nicolas Geoffray 8a947aeefc Merge "Revert "Package dexpreopt artifacts for libcore jars in the ART apex."" 2019-10-30 11:28:12 +00:00
Nicolas Geoffray 24babe3a66 Revert "Package dexpreopt artifacts for libcore jars in the ART apex."
This reverts commit d5df949385.

Bug: 143594594
Bug: 143593500
Reason for revert: Some builds are failing.

Change-Id: I69986b472bce39266095e526fcd7ef5f48ece85e
Exempt-From-Owner-Approval: Going back to green.
2019-10-30 11:27:58 +00:00
Ulyana Trafimovich b30d91cbc5 Merge "Package dexpreopt artifacts for libcore jars in the ART apex." 2019-10-30 10:13:32 +00:00
Jooyung Han 8aee204cb2 Do not follow deps for apex_vndk
Since apex_vndk deals with its own dependencies, it should not follow
dependencies while packaging.

Bug: 139772411
Test: TARGET_VNDK_USE_CORE_VARIANT=true m com.android.vndk.current
      see if there are unexpected libs in the apex
      for example, android.hardware.audio.common@2.0.so should not be
      included in the apex since it is not listed as "must use vendor
      variant".

Change-Id: Ibada600b3099fb19630d1e327a2e09cd26b2deb0
2019-10-30 00:03:22 +00:00
Jooyung Han 6b8459be4f apex: __ANDROID_APEX__ defined with no value
__ANDROID_APEX__ was defined with the name of apex module.
-D__ANDROID_APEX__=com.android.foo

But in this way, conditional compilation is not easy since comparing
macro's string value is not supported in C/C++.
(There's no usages of this value in source tree.)

In most cases, modules can check if __ANDROID_APEX__ is defined to see
if they are compiled for apex.
For modules which should behave differently according to which apex they
are included, they can check __ANDROID_APEX_<NAME>__.

Bug: 142582178
Test: m (soong tests run) && boot device && TH
Change-Id: I0f5e3e9463ccd96cbba333a8bdd648470c5c912d
2019-10-29 23:47:59 +00:00
Treehugger Robot 520367cbd3 Merge "Add support for including app prebuilts in APEX." 2019-10-29 23:02:38 +00:00
Dario Freni cde2a037f6 Add support for including app prebuilts in APEX.
Bug: 138429615
Test: Created an APEX containing CtsShimPrebuilt and
CtsShimPrivPrebuilt.
Change-Id: I9d138ccfc03e4b96c9989d2681ad4e4ad5f20108
2019-10-28 16:05:32 +00:00
Dario Freni e423582f07 Sort the file with image content.
While modifying the CTS shim apex packages, it was observed that the
output of the image content file is not necessarily sorted, which in
turn can cause failure when checking the file against a whitelist.

Bug: 138429615
Test: Succesfully built a modified version of CTS Shim v3 that was
previously failing because of the issue this CL fixes.

Change-Id: I901859ae08feb6012f34b851e125977e1c0100d9
2019-10-28 15:51:03 +00:00
Ulya Trafimovich d5df949385 Package dexpreopt artifacts for libcore jars in the ART apex.
This patch adds dexpreopt files for the libore part of the
bootclasspath to the ART apex.

Since this is specific to the ART apex and makes not sense for other
apexes, the patch does not add a new module property, but only a
boolean flag denoting that this is an ART apex.

Dexpreopt artifacts packaged into the ART apex differ from those that
are packaged in the system image: it inludes only the libcore part of
bootclasspath jars, but not the framework part. When the boot image
extension is implementd, dexpreopt artifacts for the libcore jars will
be removed from the system image (but for now they are both in the
apex and in the system image).

Build rules for the new set of dexpreopt artifacts are created using
a new variant of the global boot image config. Previously we had two
variants: "default" (for the system image) and "apex" (for the
JIT-zygote experiment). This patch adds the third "libcore" variant.

Test: m
Test: m com.android.art deapexer \
    && find $ANDROID_BUILD_TOP -type f -name 'com.android.art.*.apex \
        | xargs deapexer | grep boot \
    Expect to find dexpreopt/$ARCH/boot-art*.{art,oat,vdex} files.
Test: m art/build/apex/runtests.sh

Change-Id: I353ef90304bc5e18c3055ea379b3b223e5c38948
2019-10-28 14:03:08 +00:00
Jooyung Han 72bd2f8f15 add symlink for compatibility (vndk apex)
With VNDK APEX, the location of VNDK lib is changed.
But vndk libs of older VNDK versions still depend on old location.

For current VNDK version, those hard-coded references will be fixed.
TODO(b/142911355): [VNDK APEX] Fix hard-coded references to /system/lib/vndk

Bug: 143192278
Bug: 142912195
Test: m com.android.vndk.current and check if /system/lib/vndk
      OVERRIDE_TARGET_FLATTEN_APEX m com.android.vndk.current

Change-Id: I2ebacde7fcd1c7621e4509e08a76765e1dfeb059
2019-10-24 18:48:51 +09:00
Jooyung Han 7798857a0d Revert "Revert "Add __ANDROID_APEX_<NAME>__ for apex variants""
This reverts commit 12f629b26d.

Bug: 142582178
Test: m (soong test added)
2019-10-19 02:28:39 +09:00
Jooyung Han 31c470b5d5 Revert "Revert "Supports VNDK APEX with different versions""
This reverts commit 48dd4b5ea4.

Bug: 141451661
Bug: 139772411
Test: m (soong tests)
Test: boot with aosp_arm64 system image on Q vendor device
2019-10-19 02:28:39 +09:00
Treehugger Robot d091c6a67a Merge "Support privleged app in APEX" 2019-10-18 01:30:39 +00:00
Treehugger Robot c5bba642f1 Merge "Prohibit dependencies outside of uses_sdks" 2019-10-18 00:30:18 +00:00
Colin Cross ad4a597c79 Merge "Add method to determine variations from a Target" 2019-10-17 18:52:20 +00:00
Treehugger Robot a8f91ec00d Merge "Revert "Supports VNDK APEX with different versions"" 2019-10-17 11:50:47 +00:00
Treehugger Robot 50dce7372b Merge "Revert "Add __ANDROID_APEX_<NAME>__ for apex variants"" 2019-10-17 11:50:47 +00:00
Jiyong Park f7487318ac Support privleged app in APEX
privileged apps are installed to priv-app dir in APEX

Test: m
Change-Id: I8141e1c20e9486655606fa43b949783f11da09f4
2019-10-17 12:54:30 +09:00
Jiyong Park a7bc8ad0b9 Prohibit dependencies outside of uses_sdks
When an APEX is built with uses_sdks, any depedndency from the APEX to
the outside of the APEX should be from the SDKs that the APEX is built
against.

Bug: 138182343
Test: m

Change-Id: I1c2ffe8d28ccf648d928ea59652c2d0070bf10eb
2019-10-17 11:19:53 +09:00
Jooyung Han 12f629b26d Revert "Add __ANDROID_APEX_<NAME>__ for apex variants"
This reverts commit d29e551efd.

Reason for revert: some targets are broken

Bug: 142773030
Change-Id: I50ac6842ab8aa572c11262ee0ec965ddbe903b0e
2019-10-16 23:51:09 +00:00
Jooyung Han 48dd4b5ea4 Revert "Supports VNDK APEX with different versions"
This reverts commit 394951da73.

Reason for revert: some targets are broken

Bug: 142773030
Change-Id: I4ce2e4a4c683c71958bc4f73e45a5ddd4a4ae32a
2019-10-16 23:50:39 +00:00
Colin Cross 0f7d2ef3ac Add method to determine variations from a Target
The arch variants are hardcoded in every module type.  Refactor
them out into a Target.Variations() method in preparation for
splitting the arch mutator into two, which will require using
different variations.

Test: m checkbuild
Change-Id: I28ef7cd5168095ac888fe77f04e27f9ad81978c0
2019-10-16 14:52:30 -07:00
Treehugger Robot a4cdb8dd40 Merge "add [static|shared].apex_available to cc_library" 2019-10-16 02:09:44 +00:00
Jooyung Han 5ac191f51f Merge changes from topic "add-vndk-apex"
* changes:
  Add __ANDROID_APEX_<NAME>__ for apex variants
  Supports VNDK APEX with different versions
2019-10-15 09:21:19 +00:00
Jiyong Park a90ca00786 add [static|shared].apex_available to cc_library
apex_available property can be appended differently per the linkage
type. This will be used to restrict certain libs (e.g.
libc_malloc_debug) to an APEX while allowing them to be statically
linkable from platform for testing purpose.

Test: m (apex_test amended)
Change-Id: I6dec23129c5ac93a3ef06fea28f26f240c0ba410
2019-10-15 15:28:07 +09:00
Jooyung Han d29e551efd Add __ANDROID_APEX_<NAME>__ for apex variants
With __ANDROID_APEX_<NAME>__ definition, native modules may have
different behavior when it is built for a specific apex module.

Previously, the name is passed as value of definition __ANDROID_APEX__
like -D__ANDROID_APEX__=com.android.foo. But it is difficult to do
conditional compilation with it.

Now, since the name is incorporated into definition itself, it gets
easier to set #ifdef condition.

Bug: 142582178
Test: m (soong test added)
Change-Id: I3c90c789fa692a19addf2e5a7c8d4cc571cde112
2019-10-15 07:34:02 +09:00
Jooyung Han 394951da73 Supports VNDK APEX with different versions
Older VNDK libraries are provided as vndk_prebuilt_shared modules. Those
are added to corresponding VNDK APEX as dependencies.

With VNDK APEX installed, VNDK libs are unnecessary. By the way, since
there can be vendor modules which depend on VNDK libs, Make targets are
still emitted with UNINSTALLABLE=true.

Android.mk has additional modules for vndk libraries which are named
with apex name as suffices. For example, if libfoo is a vndk library,
then libfoo.vendor is its vendor variant and it would be in
/system/lib/vndk. But with vndk apex, it has additional
libfoo.com.android.vndk.current variant.

Bug: 141451661
Bug: 139772411
Test: m (soong tests)
Test: boot with aosp_arm64 system image on Q vendor device
Change-Id: I269c28a4d4c4e2f1518bd51df558438fe5316774
2019-10-15 07:33:49 +09:00
Jiyong Park f383f7cfc6 Correctly install APK-in-APEX
APK in a flattened APEX is installed as 'ETC' class module, instead of
the 'APP' class. This is to prevent Make from doing app-specific
amendments (e.g. such as adding module name after my_module_path)
to the paths and filenames which are all correctly set in the Soong
side.

Test: add `installable:true` to development/samples/Snake/Android.mk
and add 'Snake' to the `apps` property of an APEX. The build is
successful.
Test:  build the APEX on a device with TARGET_FLATTEN_APEX=true
The APK is at system/apex/<apexname>/app/Snake/Snake.apk

Bug: 142537672

Change-Id: I314bf1ab7abd4d4a4e9fa210442c004f54d8ccca
2019-10-12 01:06:39 +09:00
Treehugger Robot 9c32e3101e Merge "Fix flattened apex install dir" 2019-10-10 08:41:53 +00:00
Jooyung Han 7a78a92f79 Fix flattened apex install dir
This fixes the bug: flattened apex is installed under
/system/apex/<soong module name> not /system/apex/<apex name>.

Flattened apexes can be seen as pre-activated under /system/apex, which
is bind-mount to /apex. Therefore, install dir for flattend apex should
be the same with the activation point(or mountpoint) of non-flattened apex.

When apex_name: is set, it should be used as its name instead of name:.

This change also emits makevar APEX_FILE_CONTEXTS_INFOS which is list of
pairs(<apex_name>:<file_contexts>) and is used by sepolicy to modify
file_contexts files for flattened apexes properly.

Bug: 123314817
Bug: 142300241
Test: add a test apex module(foo) with apex_name(foobar)
Test: OVERRIDE_TARGET_FLATTEN_APEX=true m foo
Test: see if the apex is installed correctly(/system/apex/foobar)
Test: see if the file_contexts for foo is correctly modified
Change-Id: I97a07de5cc772cd1d91e95ae059d282038028916
2019-10-10 12:54:56 +09:00
Jiyong Park 583a226c0e Don't check apex_available for host
The check doesn't make sense for host.

Test: ALLOW_MISSING_DEPENDENCIES=true DIST_DIR=out/dist
./art/tools/dist_linux_bionic.sh -j110 com.android.art.host
is successful

Change-Id: Icdb4bb557a83b3c8044e6c73721dab47c56888a1
2019-10-08 20:55:38 +09:00
Treehugger Robot e89b8fb919 Merge "Remove no_apex in favor or apex_available" 2019-10-08 05:33:29 +00:00
Treehugger Robot c6136c9d65 Merge "Remove old-style support for translated second architectures" 2019-10-07 20:48:07 +00:00
Colin Cross 8b0dc4be07 Merge "Add symlinks to sh_binary in soong" 2019-10-07 17:47:45 +00:00
Treehugger Robot 36aecc1f6d Merge "Rename vndk apex according to vndk version" 2019-10-07 04:44:45 +00:00
Rashed Abdel-Tawab 6a34131da4
Add symlinks to sh_binary in soong
This allows us to change `logpersist.start` to `sh_binary` and unblocks
breakpad symbol uploading

Test: convert logpersist.start to sh_binary and verify symlinks are correct
Change-Id: I1b86c512df73a336205ca35216445a08e43bb879
2019-10-04 20:51:44 -07:00
Colin Cross ff6c33d885 Replace RelPathString() with ToMakePath()
Add a ToMakePath() method that returns a new path that points out
out/ instead of out/soong/, and replace the
"$(OUT_DIR)/" + path.RelPathString()
pattern with
path.ToMakePath().String()

Bug: 141877526
Test: m checkbuild
Change-Id: I391b9f2ed78c83a58d905d48355ce9b01d610d16
2019-10-03 10:07:53 -07:00
Colin Cross 70dda7e3da Separate InstallPath from OutputPath
Create a new type InstallPath that is similar to OutputPath to
differentiate intermediates output paths from installed output
paths.

RelPathString is a poorly defined, undocumented function that is
primarily used to get an install path relative to out/soong to
generate an equivalent install path for Make relative to $(OUT_DIR).
Move it to InstallPath for now, and fix the one remaining user on
OutputPath.

Add a method to create an NDK install path so that ndk_sysroot.go
doesn't have to do it manually with PathForOutput.

Bug: 141877526
Test: m checkbuild
Change-Id: I83c5a0bd1fd6c3dba8d3b6d20d039f64f353ddd5
2019-10-03 10:07:53 -07:00
Jiyong Park 7916bfc3cc Remove no_apex in favor or apex_available
This change reverts following three changes to remove the no_apex
property. no_apex: true is equivalent to apex_available:
["//apex_available:platform"].

Revert "fix: "no_apex" can be put in defaults"
This reverts commit cc372c5b1d.

Revert "Add no_apex check for static library"
This reverts commit 2db7f46d0c.

Revert "Add no_apex property"
This reverts commit 4f7dd9b4db.

Bug: 139870423
Bug: 128708192
Test: m

Change-Id: Ia4b094e371e9f8adff94ae6dc3ebb8e081381d4e
2019-10-02 14:12:16 +09:00
Jiyong Park 127b40b316 Add apex_available to control the availablity of a module to APEXes
apex_available property controls the availability of a module to APEXes.
For example, `apex_available: ["myapex", "otherapex"]` makes the module
available only to the two APEXes: myapex and otherapex, and nothing
else, even to the platform.

If the module is intended to be available to any APEX, then a pseudo
name "//apex_available:anyapex" can be used.

If the module is intended to be available to the platform, then another
pseudo name "//apex_available:platform" is used.

For now, if unspecified, this property defaults to ["//apex_available:platform",
"//apex_available:anyapex"], which means the module is available to everybody.
This will be reduced to ["//apex_available:platform"], when marking for
apex_available for existing modules are finished.

Bug: 139870423
Bug: 128708192
Test: m
Change-Id: Id4b233c3056c7858f984cbf9427cfac4118b2682
2019-10-02 14:12:16 +09:00
Jooyung Han 90eee02a9a Rename vndk apex according to vndk version
VNDK APEX should be named after the version of VNDK libs.
For example, if vndk_version is 29, then the apex name should be
com.android.vndk.v29. If vndk_version is not set or is 'current', then
the platform vndk version is implied.

This is done with setting "apex_name" with proper name.

Bug: 139774701
Test: m (soong test added)
Change-Id: I918252f12ccd351886030fe9139a020d6cf1ff32
2019-10-02 10:02:30 +09:00
Steven Moreland 06bf3bcd7c apex: libbinder whitelist -= com.android.media
All APEXes need to ship w/o libbinder since it does not offer a stable
wire protocol. Removing this since nothing adds a libbinder dep here.

Bug: 139016109
Test: build
Merged-In: Ic6a3fcb68054d8c7a5f2f64795a0e2889ce1abe8
(cherry picked from commit 1c3108d629)
Change-Id: Ic6a3fcb68054d8c7a5f2f64795a0e2889ce1abe8
2019-09-30 21:34:45 +09:00
Jooyung Han d15aa1f123 respect "apex_name:" for "apex" module
For now, apex_name is used only for flattened apex.
Even if apex_name is set, the activation point of unflattened is
determined by 'name' in apex_manifest.json.

This change make apex_name as priority.
If apex_name is set, then use this for apex name
- update name in apex_manifest.json to apex_name
- do not check if key filename matches (use apex_name as key name)

This can be useful if soong wants to rename apex module. Simply setting
apex_name has the same effect of renaming "activation point" of apex.

But: 139774701
Test: m (soong test)
Change-Id: I8ea3645e4aa8f317997bc1443ec308ed0595b1c2
2019-09-27 01:50:46 +09:00
Jooyung Han 5e493d5660 Merge "fix: "no_apex" can be put in defaults" 2019-09-26 01:07:21 +00:00
Przemyslaw Szczepaniak 598898444f Remove libneuralnetworks from libbinder whitelist.
Test: build & flash crosshatch
Bug: 139282353
Change-Id: Iaf7904fdb306dd648430ce7e167977bd6508f146
Merged-In: Iaf7904fdb306dd648430ce7e167977bd6508f146
(cherry picked from commit 76b155448d)
2019-09-25 13:04:48 +01:00
Jooyung Han cc372c5b1d fix: "no_apex" can be put in defaults
Currently, putting no_apex in defaults module doesn't work.

To fix this,
* 'no_apex' property is added as 'defaultable'.
* apex module doesn't follow beyond 'defaults' module.

Bug: 141560644
Test: m (soong tests added)
Change-Id: I8410785f7f83d843689a33b1241d74086c6a7671
2019-09-25 15:27:47 +09:00
Sundong Ahn e8fb724689 Add isFlattenedVariant function
The return value is true if TARGET_FLATTEN_APEX is true,
TARGET_BUILD_APPS is false and the module is flatten variant.
Only the module name of flattened variant is appended with
".flattened" as suffix.

Test: m -j
Bug: 139716748
Change-Id: I966a178b43c5d08bd69d19e97e59456aa66d9d28
2019-09-23 14:40:21 +09:00
Treehugger Robot b1102ba828 Merge "Introduce module type 'sdk'" 2019-09-23 04:38:24 +00:00
Jiyong Park d1063c1586 Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.

A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:

sdk {
    name: "mysdk#20",
    java_libs: ["myjavalib_mysdk_20"],
}

java_import {
    name: "myjavalib_mysdk_20",
    srcs: ["myjavalib-v20.jar"],
    sdk_member_name: "myjavalib",
}

sdk {
    name: "mysdk#21",
    java_libs: ["myjavalib_mysdk_21"],
}

java_import {
    name: "myjavalib_mysdk_21",
    srcs: ["myjavalib-v21.jar"],
    sdk_member_name: "myjavalib",
}

java_library {
    name: "myjavalib",
    srcs: ["**/*/*.java"],
}

An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.

apex {
    name: "myapex",
    java_libs: ["libX", "libY"],
    uses_sdks: ["mysdk#20"],
}

With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).

Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-09-22 08:21:27 +09:00
Colin Cross 3b19f5d71d Remove old-style support for translated second architectures
Translated second architectures now go in NativeBridgeArch instead
of DeviceSecondaryArch.

This reapplies I568046330abc002d4eed582cb999b62a5eaba790 with
ctx.Config().HasMulitlibConflict() added to fix the NDK build,
which has arm64, arm, x86_64, and x86 architectures enabled.

Test: m checkbuild
Test: OUT_DIR=out_ndk build/soong/scripts/build-ndk-prebuilts.sh
Test: no change to build.ninja or Android-aosp_cf_x86_phone.mk
Change-Id: Iadcafbd64bfb9579ae7c86914927c43a062b0c8e
2019-09-19 12:54:32 -07:00
Roland Levillain 411c584cba Fix documentation of field `soong.apex.apexBundleProperties.Apex_name`.
Remove the mention to the (APEX) manifest (`apex_manifest.json`) from
this field's documentation, as `Apex_name` is neither read from nor
written to that file.

Test: n/a
Change-Id: Ia0dfac4f35f1ea697f379bcb19dd11af8705a0a0
2019-09-19 16:54:07 +01:00
Inseob Kim 64c4395386 Add version to vendor variants
Vendor variant is now divided into several vendor.{version} variants,
depending on their intended usages:

vendor.{BOARD_VNDK_VERSION}: vendor and vendor_available modules
vendor.{PLATFORM_VNDK_VERSION}: VNDK modules in the source tree
vendor.{snapshot_ver}: VNDK snapshot modules

This also affects exported module names from Soong to Make. But to
maintain backward compatibility, ".{BOARD_VNDK_VERSION}" suffix will not
be emitted for modules having version BOARD_VNDK_VERSION, so that vendor
modules still can be referred as-is.

Bug: 65377115
Bug: 68123344
Test: clean build and boot blueline
Change-Id: Ib9016a0f1fe06b97e9423fd95142653a89a343fa
2019-09-18 10:53:30 +09:00
Treehugger Robot 1f6c94a3ac Merge "Add "apex_vndk" module type" 2019-09-17 17:14:48 +00:00
Sundong Ahn 72f1f3ec22 Fix the construction of ziptype APEX
If payload type of APEX is zip, flattened variant and non-flattened
variant create the same MK rules (it's build error). So only
non-flattened variant case, MK rule is created.
And if a.flattenedConfigValue is true, soong don't mutate variants. So
when a.flattenedConfigValue is true, MK rule should be created.

This CL is a partial revert of 4c04713871

Bug: 139716748
Test: m -j com.android.art.host
Change-Id: I37b2fa17e203fb668a0255cda37f10fcfadb3f85
2019-09-16 12:46:58 +09:00
Jaewoong Jung 096c323f65 Merge "Add NOTICE file path to apex bundle base rule." 2019-09-12 19:29:37 +00:00
Martin Stjernholm 931849f36f Merge "Treat libclang_rt.hwasan-* the same way as the other Bionic bootstrap libs." 2019-09-12 17:55:55 +00:00
Jaewoong Jung b00c1fb224 Add NOTICE file path to apex bundle base rule.
The NOTICE files are missing from prebuilt apexes, and it turns out they
were excluded when building bundles.

Bug: 140317706
Test: Ran build_mainline_modules.sh and checked bundle base modules.
Change-Id: I92c4231f2007e1d8cd9c2bd044201458803c0fd7
Merged-In: I92c4231f2007e1d8cd9c2bd044201458803c0fd7
2019-09-11 17:40:59 -07:00
Roland Levillain 4c04713871 Fix the construction of host APEX (`.zipapex`) packages.
Test: m com.android.art.host
Bug: 139716748
Change-Id: I3d3783bcb016475ccf658872b4cb31d1a8d7a59e
2019-09-11 14:25:06 +01:00
Martin Stjernholm 279de572d7 Treat libclang_rt.hwasan-* the same way as the other Bionic bootstrap libs.
Ensure that it ends up in the bionic/ subdir in the Runtime APEX and is
symlinked from /system/lib(64). That makes it available in the default
(platform) linker namespace and no longer requires it to be accessible
through the runtime namespace. All this makes it consistent with how the
other Bionic libs are handled, and avoids the need for various special
cases in ld.config.txt files (to be cleaned up later).

With this there might no longer be a need for a linker namespace for the
Runtime APEX, and we could consider removing the kludge with the
/apex/com.android.runtime/${LIB}/bionic subdirectories and the special case
in getCopyManifestForNativeLibrary in apex.go. However, keeping it calls out
the special treatment of those libraries, and allows a namespace to be added
again if necessary.

Test: Build and boot on taimen_hwasan-userdebug
Test: adb shell /apex/com.android.art/bin/dexdump on taimen_hwasan-userdebug
Test: atest CtsCompilationTestCases on taimen_hwasan-userdebug
Bug: 140734238
Bug: 140790209
Change-Id: Ieb506bfa5d5c159db391273c7eba41d7909de286
2019-09-11 12:16:31 +01:00
Treehugger Robot 84bd071cac Merge "Create flattened variants for soong apex module" 2019-09-11 05:18:34 +00:00
Sundong Ahn e9b5572cbf Create flattened variants for soong apex module
The apexBundle module is mutated flattened variant and unflattened
variant. So we can install flattened apex and unflattened apex at the
same time with adding {Apex module name}.flattened to PRODUCT_PACKAGES.

Bug: 139716748
Test: m -j && Add com.android.art.debug.flattened to PRODUCT PACAGES and
check system/apex/com.android.art.debug directory

Change-Id: I0d8c9a155e47c5d0ff13e2f55d4080d91ef5093d
2019-09-11 10:47:12 +09:00
Logan Chien 0342c58262 apex: Install nativeTest with soong_cc_prebuilt.mk
This commit switches the build rule for APEX nativeTests from
`$(BUILD_PREBUILT)` to `soong_cc_prebuilt.mk`.  Since these are not real
prebuilts, `soong_cc_prebuilt.mk` should be sufficient.

Using `soong_cc_prebuilt.mk` also fixes a problem reported by prebuilt
ELF checker because `LOCAL_SHARED_LIBRARIES` are not generated for
nativeTests.

Bug: 139525855
Test: lunch aosp_walleye-userdebug && make check-elf-files
Change-Id: I7bfc29f9c2708896dad4e7cfc214480e1205a51e
2019-09-10 09:59:18 -07: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
Treehugger Robot 5afe2d6869 Merge "Support including apk inside an apex" 2019-09-05 23:43:33 +00:00
Nikita Ioffe 1acf6f9f6e Use PathForModuleOutput instead of PathForPhony
Later breaks some build flavours ¯\_(ツ)_/¯

Bug: 140467657
Test: soong_ui.bash --make-mode vts dist DIST_DIR=/tmp/dist-dir/ TARGET_PRODUCT=aosp_arm64 WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true BUILD_GOOGLE_VTS=true TARGET_BUILD_VARIANT=eng NATIVE_COVERAGE=true COVERAGE_PATHS="test/vts/hals/light" ENABLE_TREBLE=true
Change-Id: I0cb5754cb93551f2ed66d804f36019b037ccd871
2019-09-04 10:57:13 +00:00
Sundong Ahn e1f05aaf44 Support including apk inside an apex
New property "apps" is added to APEX soong module. This property
configure a list of APKs to package inside APEX payload. For each
android_app module package it's APK into /app/$(android_app module Name)
directory.

Bug: 139906763
Test: m -j
Change-Id: Ic6655f211951af08097c76e157a07ebc52425718
2019-09-04 12:10:00 +09:00
Nikita Ioffe 5d5ae761c5 apex.go: Add support for diffing content of APEX with whitelist file
So far a very basic version.

In case there is a diff, soong will emit an error message with a command
to resolve the diff. Example:

New unexpected files were added to com.android.apex.cts.shim.v3. To fix the build run following command:
system/apex/tools/update_whitelist.sh system/apex/shim/build/default_shim_whitelist.txt out/soong/.intermediates/system/apex/shim/build/com.android.apex.cts.shim.v3/android_common_com.android.apex.cts.shim.v3/com.android.apex.cts.shim.v3-content.txt

Test: m checkbuild
Bug: 139125405
Change-Id: I57e694f394c56105dc7363a684983605c7bf5e7d
2019-09-02 17:55:21 +01:00
Roland Levillain af93360ef9 Merge changes from topic "check-flattened-art-apex"
* changes:
  Add an output file type for flattened APEXes.
  Allow modules to be enabled/disabled depending on whether APEXes are flattened.
2019-08-29 15:17:29 +00:00
Jaewoong Jung 7ca5576905 Merge changes Ife12ba69,Ibf910262
* changes:
  Implement android_test_import
  AndroidMkEntries minor refactoring.
2019-08-29 00:55:14 +00:00
Jooyung Han a9caf47ea2 Merge "soong: Add tests for depending on disabled module" 2019-08-28 23:58:33 +00:00
Jaewoong Jung e0dc8dfd22 AndroidMkEntries minor refactoring.
This includes a few changes that make AndroidMkEntries more resemble
AndroidMkData, especially in terms of how extra entries are added.
Most importantly it can now have multiple custom functions.

Test: Soong tests
Change-Id: Ibf9102624d16d0c1c9894a2794fc7c797bb34c9a
2019-08-28 13:07:03 -07:00
Treehugger Robot 21738f6032 Merge "Remove hashtree from builtin APEXes" 2019-08-28 14:18:21 +00:00
Jooyung Han e65ed7cd67 Remove hashtree from builtin APEXes
Builtin APEXes (/system, ...) don't need hashtree.
So if we remove hashtree from builtin APEXes we can save more space in
/system.

However, this change only affects to the apex bundles which are built
from source, not from prebuilts.
Removing hashtree from prebuilts will be handled in a follow CL.

Bug: 139957269
Test: m
Test: see if /system/apex/*.apex have hashtree
Change-Id: Id755382b2153bf6bbaf2c480f3bbb91b6f62a564
2019-08-28 17:27:27 +09:00
Roland Levillain 935639d70f Add an output file type for flattened APEXes.
Allow modules to depend on the flattened flavor of an APEX package
using `module.{flattened}` (returning the output install path of the
flattened APEX).

Also add this flattened output install path as an implicit output
dependency of a flattened APEX phony module.

Test: m checkbuild
Bug: 139277987
Change-Id: I8c55d5ff2922a36fcc8ec0819fbe3e93a772ef8a
Merged-In: I8c55d5ff2922a36fcc8ec0819fbe3e93a772ef8a
2019-08-27 14:26:18 +01:00
Sundong Ahn 2db7f46d0c Add no_apex check for static library
If no_apex module is static library, this module is not included to
filesInfo. So add a check tat the static library is no_apex among
indirect dependencies.

Bug: 139016109
Test: m -j
Change-Id: I46ddf099715aea0e088027a1141e282969cef0e1
2019-08-27 19:06:49 +09:00
Jooyung Han d48f3c3885 soong: Add tests for depending on disabled module
This will check if direct deps of android.Module type is "Enabled()".
Previously, this is checked only if a module calls VisitDeps*()
functions in GenerateAndroidBuildActions().

Most modules call VisitDeps*() in GenerateAndroidBuildActions(),
but some modules don't. For example, "apex" module calls
WalkDepsBlueprint() or VisitDirectDepsBlueprint() since it
exceptionally depends on non-android.Module modules.

Therefore, when an apex module depends on disabled(enabled:false) module,
build fails with panic, which is fixed by this change.

Test: m # runs soong tests
Change-Id: I81c5c148bbd51a253d2904690eb76ae7b6df1a0f
2019-08-26 13:19:42 +00:00
Treehugger Robot fb7e0b3aa2 Merge "Add no_apex property" 2019-08-23 04:00:38 +00:00
Jiyong Park 4f7dd9b4db Add no_apex property
This change adds 'no_apex' property which, when set to true, prevents
the module from being installed to any APEX. If the module is included
either directly or transitively in an APEX, but build fails.

Bug: 139016109
Test: m

Change-Id: If1478aa9660a3442f7dd1ffe45e4ca5611a6acbe
2019-08-22 20:37:07 +09:00
Jooyung Han 9c80baeccf apex: add llndk libs as requireNativeLibs
"use_vendor: true" APEX modules may bundle vendor variants of cc
modules, which can depend on llndk stubs.

In that case, those llndk libraries should be also counted as required
libraries. (stored in 'requireNativeLibs' key in apex_manifest.json)

Bug: 138695532
Test: m nothing (runs soong tests)
Change-Id: If7ad4dec0e723c8d0c73ca60453b555063e14694
2019-08-20 17:30:57 +09:00
Treehugger Robot dcea882ef9 Merge "Build native coverage variant of APEXes when needed" 2019-08-15 00:08:59 +00:00
Treehugger Robot f02f30952d Merge "java_import can be included in apex" 2019-08-13 04:18:29 +00:00
Jiyong Park 9e6c242856 java_import can be included in apex
java_import can be included in apex via 'java_libs' property.

Bug: 139175488
Test: m (apex_test.go updated)
Change-Id: I3680a47cdac93b0cb2d41da8df3f8defa2bbe670
2019-08-13 09:36:39 +09:00
Jiyong Park ee9a98d88e Build native coverage variant of APEXes when needed
When the native coverage is enabled, APEXes (and files there) are built
for native coverage as well.

Bug: 138952487
Test: make -j NATIVE_COVERAGE=true COVERAGE_PATHS='*' com.android.resolv
find out -name "*.gcno" | grep DnsResolver shows files

Test: libnetd_resolv.zip is found under
$(TARGET_OUT)/apex/com.android.resolv/lib directory

Change-Id: I97bcee9bf8ffc0dc71453abbdb613ed56ea2cdb4
2019-08-13 08:55:08 +09:00
Jooyung Han d363955938 Soong: Add test for apex
This test checks if "runtime_libs" dep of "cc_library" is respected.

Test: m (run soong tests)

Change-Id: I4b81fc548761be9b284d15c61c62718df72d409f
2019-08-09 12:59:09 +09:00
Jooyung Han 07149d36aa Add TEST_MAPPING for build/soong/apex
build/soong/apex is highly coupled with system/apex.
So it is reasonable to "import" presubmit tests from system/apex.

Test: atest --test-mapping build/soong/apex
Bug: 138984456
Change-Id: I7447e04a63b86486daef0f2a7642842101c0029f
2019-08-07 17:33:24 +09:00
Treehugger Robot d62b4af8b7 Merge changes from topic "put-dep-in-apex"
* changes:
  Add jsonmodify tool
  Put dependency in apex_manifest.json
2019-08-06 00:21:11 +00:00
Kun Niu a535be6012 Merge "Build module from source branch instead of using prebuilds when coverage is enabled." 2019-08-05 18:04:49 +00:00
Kun Niu 10c9f83f26 Build module from source branch instead of using prebuilds when coverage is enabled.
Test: successfully get coverage data from coverage build.
Bug: 137865099
Change-Id: I7df96c2b2c2ec2859393fb2c19ffe1081d112c96
2019-08-02 10:13:46 -07:00
Jooyung Han e16330393a Put dependency in apex_manifest.json
To generate ld.config.txt dynamically(b/123722631), each APEX should
provide some dependency information:
a) list of libraries which other APEXes(or system) can use from this apex
b) list of libraries which this apex uses from other APEXes(or system)

This change puts dependency information in apex_manifest.json at
build-time with two additional keys:
a) provideNativeLibs
b) requireNativeLibs

Bug: 138695532
Test: m (runs soong tests)
Test: find $OUT/apex -name apex_manifest.json  -exec cat {} \;
 (shows contents of apex_manifest.json files)

Change-Id: Iaad12c8c35454222ad177ce923cce76ef12a8a5a
2019-08-01 23:45:37 +09:00
Roland Levillain ec5fc70856 Merge "Materialize the copy commands of an APEX rule as a Ninja response file." 2019-08-01 13:51:22 +00:00
Roland Levillain 96cf4d4646 Materialize the copy commands of an APEX rule as a Ninja response file.
For some APEX packages (i.e. the Runtime Testing APEX), the set of
files to copy can be so large that the copy commands (which are part
of the Ninja shell command executed for an APEX package) may exceed
the maximum length of argument to the exec() functions (ARG_MAX). To
work around this limitation, record these copy commands in a Ninja
response file (rspfile) and `source` this file in the Ninja command to
execute them.

Test: m nothing (`apex/apex_test.go` amended)
Test: m com.android.runtime.testing (with CL https://android-review.googlesource.com/c/platform/art/+/1008034/ cherry-picked)
Bug: 129534335
Change-Id: I09ff2d9cf66bfd4cbc12cb724a45d455d08da0b2
2019-07-31 17:22:00 +01:00
Roland Levillain 4644b22b75 Fix some typos in error messages in apex/apex.go.
Test: m
Change-Id: Iee54bd0e2e0d6651d82b7fbae246f20643e49ceb
2019-07-31 14:09:17 +01:00
Treehugger Robot a822256e15 Merge "Delete prebuilt APEXes when installing source-built APEXes" 2019-07-31 07:03:49 +00: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
Roland Levillain f89cd0949c Handle `test_per_src` modules as indirect dependencies in APEXes.
In `apex.apexBundle.GenerateAndroidBuildActions`, we used to pass the
"all tests" ("") module as `module` for all `apexFile` objects created
from a test module using `test_per_src: true`.  An immediate issue of
this situation was that the "" module is hidden from Make, which made
all the generated `apexFile` objects hidden from Make too. This would
break the construction of flattened APEXes, as they rely on Make logic
to install their files.

Instead of collecting `test_per_src` test variations' output files in
`cc.Module.GenerateAndroidBuildActions` and using them in
`apex.apexBundle.GenerateAndroidBuildActions` as part of handling the
"" variation as a direct dependency of an `apexBundle`, process them
as indirect dependencies (and do nothing for the "" variation direct
dependency).

Adjust the indirect dependency logic in
`apex.apexBundle.GenerateAndroidBuildActions` to allow not only
shared/runtime native libraries as indirect dependencies of an
`apexBundle`, but also `test_per_src` tests.

Test: m (`apex/apex_test.go` amended)
Bug: 129534335
Change-Id: I845e0f0dd3a98d61d0b7118c5eaf61f3e5335724
2019-07-29 19:21:27 +01:00
Jiyong Park 7f7766d5ee Revert "Revert "Split Java libraries per apex""
This reverts commit f0f7ca8335.

Bug: 138182343
Test: apex_test added
Change-Id: I5c8a0935ac0f456137c8656815e220b0e7848a5d
2019-07-26 14:19:38 +09:00
Treehugger Robot 38b9f76d63 Merge "Revert "Split Java libraries per apex"" 2019-07-25 11:29:28 +00:00
Jiyong Park f0f7ca8335 Revert "Split Java libraries per apex"
This reverts commit aa53324ac8.

Reason for revert: b/138337109 (broke ndk build)

Change-Id: I9497cb4337add3f8c491a684bcaadea3bdbfaa85
2019-07-25 04:38:02 +00:00
Treehugger Robot 8f7a3fc633 Merge "Split Java libraries per apex" 2019-07-24 23:15:22 +00:00
Roland Levillain dfe75b389c Fix some typos in Soong.
Test: m
Change-Id: I5b332ce12d70f13eca93b23060620c0ea4f46db7
2019-07-23 17:29:57 +01:00
Jiyong Park aa53324ac8 Split Java libraries per apex
Just like native libs, a java library that is included in an APEX is
mutated for the APEX. This allows us to infer the context (e.g.
sdk_version, etc.) for building a java library in an APEX.

Bug: 138182343
Test: apex_test added
Change-Id: I9292ea097b98e74a8a794f164bd2bed3921d6337
2019-07-23 20:32:14 +09:00
Treehugger Robot c793ebf1ae Merge "Fix: symlink bin/arm directory is not handled correctly" 2019-07-23 00:53:25 +00:00
Jiyong Park c80b5fa0c6 Fix: symlink bin/arm directory is not handled correctly
This change fixes a bug that a symlink in the bin/* directory of an APEX
is not added to the fs_config file.

Bug: 137918291
Test: choosecombo aosp_x86_arm
TARGET_FLATTEN_APEX=false m com.android.runtime.debug is successful

Change-Id: Ib10b635f08e03b18e8ad5407d8de6bac2c85326d
2019-07-20 15:18:21 +09:00
Roland Levillain 9b5fde9ca4 Handle `test_per_src` test variations as dependencies of APEX modules.
If a test module with a `test_per_src` property set to `true` is
included in an APEX module, add all the variants for mutator
`test_per_src` as dependencies of the APEX module (not just the
first one).

This is done by adding variation "" of mutator `test_per_src` when
adding a test dependency to an APEX module, which creates an indirect
dependency of the APEX module on all the `test_per_src` variants of
the test module. When generating outputs for the APEX bundle, fetch
and include the set of test outputs from the "" variant.

Test: m (`apex/apex_test.go` amended)
Bug: 129534335
Change-Id: I1c99855971a8a9b2fc5b964a420e882b6791d4e6
2019-07-19 14:15:06 +01:00
Jaewoong Jung 6f67daa93c Merge "Add overrides property to prebuilt_apex" 2019-07-18 17:35:07 +00:00
Treehugger Robot a0eb5a899f Merge "fix: APEX prebuilts are disabled in platform build" 2019-07-17 04:00:48 +00:00
Jaewoong Jung 22f7d18a5d Add overrides property to prebuilt_apex
Bug: 137218697
Test: apex_test.go
Change-Id: I55a42e1e4af60d6d7185515a380c786312b8b29b
2019-07-16 18:45:26 -07:00
Jiyong Park ca8992ea0b fix: APEX prebuilts are disabled in platform build
This change fixes a bug that APEX prebuilts are auto-disabled in
platform builds (i.e. non-unbundled builds).

Bug: 137282010
Test: m com.android.conscrypt
check that the apex is from prebuilt directory

Merged-In: I935ef3896e80864bdcc1ca5f6fc12b63c9588c0d
(cherry picked from commit 895e224d8f)

Change-Id: I935ef3896e80864bdcc1ca5f6fc12b63c9588c0d
2019-07-17 08:34:03 +09:00
Dimitry Ivanov 2ca7a8835e Merge "Make relative path for native_bridge binaries configurable" 2019-07-16 09:17:35 +00:00
dimitry 8d6dde8831 Make relative path for native_bridge binaries configurable
This change introduces NativeBridgeRelativePath and
NativeBridgeSecondaryRelativePath product variables to
make relative path to native_bridge binaries configurable.

It also removes moves information about native bridge
host architecture to Target and sets it during decodeTargetProductVariables

Test: make PRODUCT-cf_x86_phone-userdebug dist
Change-Id: Ie736e81eae507e1775566ce9f29135011b12af27
2019-07-15 20:04:07 +02:00
Jiyong Park e3ef3c8f0c Fix the unbundled mainline module build
This change fixes two problems:

1) the prebuilt apexes are force disabled for the unbundled builds
because we need to build the modules from the source then

2) the dependencies from an sdk_library module to
*.stubs.{public|system|tests} are not added for the unbundled build
because the stubs modules are disabled.

Bug: 137282010
Test: unbundled mainline builds are successful
Test: build com.android.media and inspect the jar file to see if
hiddenapi flags are there
$ cd out/dist/mainline_modules_arm
$ unzip com.android.media.apex apex_payload.img
$ mkdir -p mnt
$ sudo mount -o ro,loop apex_payload.img mnt
$ dexdump2 mnt/javalib/updatable-media.jar | grep hiddenapi
shows results

Change-Id: I2c00af07aac4a15770d3acab011a36e2e4803bfc
2019-07-15 17:20:05 +09:00
Jiyong Park 50b81e532b Don't use APEX prebuilts when asan is on
Some prebuilt APEXes are enabled with scudo, which causes crash on
devices with asan.

Bug: 137216042
Test: build walleye_hwasan and check if apexes are not from prebuilts
Merged-In: Ic436ad06e724af952d99fb8e66358a595450eb84
(cherry picked from commit 3b98a509f1)
Change-Id: Ic436ad06e724af952d99fb8e66358a595450eb84
2019-07-15 17:17:31 +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
Treehugger Robot f378a85523 Merge "Use ctx.Target().NativeBridge to detect if the arch is translated or not" 2019-07-11 00:49:42 +00:00
Jaewoong Jung 3af8661af7 Merge "Improve android_app_import.dpi_variants handling." 2019-07-10 16:39:53 +00:00
Jiyong Park acbf6c76c6 Use ctx.Target().NativeBridge to detect if the arch is translated or not
Bug: 137015854
Test: m
Test: build cf_x86_phone and ensure there is no dangling symlink
/system/lib/arm/libm.so

Change-Id: I0f5efdb9e1f5e4e213ca4ebaa28ace0a130b36a6
2019-07-10 18:07:38 +09: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
Jooyung Han 5c998b9ff8 Add "provide_cpp_shared_libs/uses" props to "apex"
For APEXes to share C++ native libraries, we need a new kind of depedency
between APEXes: "providing" APEXes and "using" APEXes. To reflect this
dependency two new properties are added.

provide_cpp_shared_libs: bool
  this indicates that the current APEX module provides the native C++ shared
  libs to other APEXes.

uses: []string
  this indicates that the current APEX module uses the native C++ shared
  libraries from APEXes listed.

With these two, "using" APEXes can omit shared libraries in its APEX
bundle and use them from the "providing" APEXes.

Note that without corresponding changes in ld.config.txt, this won't
work.(The linker namespaces should be configured so that user APEX can
access provided libs.)

Bug: 136975105
Test: m nothing (this will trigger soong's test)
Change-Id: Iec6f9f67bcbde01145acc383f862ba21c8197536
2019-07-09 21:30:45 +09:00
Jaewoong Jung b1907ee587 Merge "Dist NOTICE outputs for app targets." 2019-07-08 23:28:13 +00:00
Jaewoong Jung 9877279855 Dist NOTICE outputs for app targets.
Bug: 136501164
Test: m NetworkStack, TreeHugger
Change-Id: I2279eeb0e50b1b5685e23130a8da6ab090f37f56
2019-07-08 09:26:02 -07:00
Roland Levillain 630846d244 Add support for tests in APEX test modules.
Allow `tests` property in `apex_test` Soong modules.

Test: m (`apex/apex_test.go` amended)
Bug: 129534335
Change-Id: Ieeff7cf0980a7c394409632b6448102f59bceb3d
2019-07-05 19:01:18 +01:00
Jaewoong Jung c1001ec0c5 Create test build dir only once for apex_test.
Test: apex_test.go
Change-Id: Ib96ea4ec5d5ff0d8e8cf4a9eb479099cf2b1977c
2019-06-25 11:20:53 -07:00
Jaewoong Jung 50c744e916 Merge changes from topic "apex_notice"
* changes:
  Embed NOTICE output as an APEX asset.
  Optionally embed NOTICE files in apks.
2019-06-25 16:41:16 +00:00
Jaewoong Jung 14f5ff62c9 Embed NOTICE output as an APEX asset.
Instead of outputting an aggregated NOTICE file as an intermediate build
resource to allow Make to include it in the final system-wide NOTICE,
process and embed it as an asset in the final APEX. This allows us to
update the NOTICE contents automatically when an APEX is updated.

Fixes: 135218846
Test: Built mainline modules, apex_test.go
Change-Id: Ic851b330fe93be1f602907d44ecc7886c3b0171b
2019-06-24 20:10:34 -07:00
Jaewoong Jung 5b425e2e20 Optionally embed NOTICE files in apks.
If embed_notices or ALWAYS_EMBED_NOTICES is set, collect NOTICE files
from all dependencies of the android_app, merge them with the app's own
one (if exists), transform it to HTML, gzip it, and put it as an asset
in the final APK output.

Bug: 135460391
Test: app_test.go
Change-Id: I52d92e2fd19b3f5f396100424665c5cc344190d8
2019-06-24 19:10:22 -07:00
Colin Cross 643614de24 Make apexMutator parallel
apexMutator only modifies the currently visited module, it can
visit modules in parallel.

Test: builds
Change-Id: I7d0ad142f5161742bd25dc57bac64c0f4a733ecf
2019-06-20 10:45:39 -07:00
Treehugger Robot 42d33779cd Merge changes If25be604,I0a310229,I44155630
* changes:
  Add another jar used by kotlinc
  Actually depend on the headers from renderscript
  Fix a few missing dependencies in APEX building
2019-06-13 17:40:01 +00:00
Dan Willemsen dd651faac3 Fix a few missing dependencies in APEX building
I found these while trying to build an aosp_arm system image with RBE,
which only makes the sources that you depend on available to every rule.

The hardcoded prebuilts/sdk path is a bit unfortunate, but that's
currently hardcoded as a default in the script as well.

Bug: 130111713
Test: treehugger
Test: build a system image with RBE
Change-Id: I4415563017e053749788b0a537a48d61a2161935
2019-06-13 05:21:09 +00:00
Colin Cross 59037628f4 Add GenerateAndroidBuildActions to DefaultsModuleBase
Add an empty GenerateAndroidBuildActiosn to DefaultsModuleBase
so that every defaults module doesn't need to provide one.  This
will also allow adding an implementation in the next patch.

Test: m checkbuild
Change-Id: I13554bdb3a287c2f18e1efab74d4f08a1ba8620c
2019-06-10 13:51:17 -07:00
Colin Cross 0ea8ba82fc Consolidate baseContext, BaseContext, and BaseModuleContext
blueprint.BaseModuleContext is the set of methods available to all
module-specific calls (GenerateBuildActions or mutators).  The
android package split the same functionality across baseContext (nee
androidBaseContext), BaseModuleContext, and BaseContext.
Consolidate all of them into android.BaseModuleContext.

Test: m checkbuild
Change-Id: I2d7f5c56fd4424032cb93edff6dc730ff33e4f1e
2019-06-06 20:01:31 -07:00
Treehugger Robot b4c35f3378 Merge "Support tagged module references" 2019-06-05 17:17:32 +00:00
Colin Cross 41955e8895 Support tagged module references
There are cases where a module needs to refer to an intermediate
output of another module instead of its final output.  For example,
a module may want to use the .jar containing .class files from
another module whose final output is a .jar containing classes.dex
files.  Support a new ":module{.tag}" format in any property that
is annotated with `android:"path"`, which will query the target
module for its ".tag" output(s).

Test: path_properties_test.go, paths_test.go
Test: no unexpected changes in build.ninja
Change-Id: Icd3c9b0d83ff125771767c04046fcffb9fc3f65a
2019-06-04 10:22:51 -07:00
Yi Kong e7fe9913d6 Clean up no_libgcc
no_libgcc is no longer needed anywhere. Move all occurances to no_libcrt
and remove no_libgcc.

Test: build
Change-Id: I6dd49db71d05d7685aa90cc837627f65e6742d6d
2019-06-03 15:52:40 -07:00
Peter Collingbourne 3478bb2a7f Teach soong not to duplicate the HWASAN runtime into each APEX.
When HWASAN is enabled, the runtime is conceptually part of Bionic (and
mutually depends on it), so it needs to be treated in the same way as the
Bionic libs.

Now there are only two copies of the runtime: the one in
/system/lib64/bootstrap (which won't be used by ordinary processes) and the
one in the runtime APEX.

This reduces the size of the HWASAN system image and fixes an issue where
multiple copies of the HWASAN runtime were being loaded into 64-bit binaries in
APEXes because the linker namespace for the binary is different from the one
for its dependent libraries outside of APEXes. HWASAN only supports loading
one copy of the runtime per process, so this was causing such binaries to
crash on startup.

Change-Id: I228896e193a035e6dfba9f6e28d0b2e12fc163ea
2019-05-17 10:00:39 -07:00
Yi Kong acee27cd72 Strip libgcc to only keep fallback symbols
We use libgcc as fallback for symbols not present in libclang_rt
builtins, however we didn't know what exact symbols were being used,
some may not be intended to fallback.

Create libgcc_stripped, which only contains unwind symbols from libgcc.

Bug: 29275768
Test: bionic-unit-tests
Change-Id: I5b349fa6138e51663bf3b67109b880b4356da8e8
2019-04-30 10:07:00 -07:00
Treehugger Robot 1341942d86 Merge "Prebuilt APEXes are recoreded in apexkeys.txt" 2019-04-30 03:14:01 +00: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
Logan Chien 41eabe63e8 Support opt-in ABI checks
This commit allows a module to opt in for ABI checks even when it is
not an LLNDK/VNDK module.

Bug: 131421213
Test: Add `header_abi_checker { enabled: true, }` to some module
Change-Id: Ie09d262e651cbb44d7d0eba652f55dc1e1e52962
2019-04-27 01:55:50 +08:00
Jiyong Park 71b519d6ce Set default target SDK version for APEX
Target SDK version is used for targeting an APEX to a specific set of
platform builds. Usually, the targeting is unrestricted (in case the
APEX can run on all platforms), or based on platform SDK version (e.g.
28 for P). However, when the platform is under development and SDK is
not finalized, the targeting should be much more fine-grained; the
APEX should be targeted to a very specific build that supports the same
set of APIs that the APEX was built against.

To support that, target sdk version is automatically set by the build
system. When the platform is released or SDK is finalized, the target sdk
version set to the SDK version number. If not, it is set to
<version_code>.<fingerprint> (e.g., Q.123456).
Note that the target sdk version set by the build system is used only
when the target sdk version is not explicitly set in
AndroidManifest.xml.

Bug: 130541924
Test: UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true \
UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true \
TARGET_BUILD_APPS=com.android.tzdata m
build.ninja has --target_sdk_version Q.$$(cat out/soong/api_fingerprint.txt)

Test: aapt dump badging out/dist/com.android.tzdata.apex | grep \
targetSdkVersion shows:
targetSdkVersion:'Q.6ee443d9ad5f0cca7a43cfa97b7fc62a'

Change-Id: I086230d787f01075c28fc3f0163550300fa00212
2019-04-19 14:45:41 +09:00
dimitry f807167023 Make apex_key HostAndDeviceDefault
Since apex_key is used in number of apex_test host_supported modules it
is no longer a device only module.

Test: add new device target and check that the build does not fail
Change-Id: I6402e3b622d22ee0ca0e6af71dfd71a690938e49
2019-04-12 09:26:00 +00:00
Dan Willemsen 412160e1c9 Stop using build/target -> build/make/target symlink
Instead, fully specify build/make/target/... everywhere

Test: treehugger
Change-Id: I07ba0e9b0604919a271afd5133070616e1f404fc
2019-04-09 21:36:26 -07:00
Nikita Ioffe 89ecd590ea Make prebuilt_apex be usable via :modulename syntax
Test: m
Bug: 127789981
Bug: 128677967
Change-Id: Ie1a1147c1d5570cd7eda48e274faabf95566d53f
2019-04-06 16:57:57 +01:00
Nikita Ioffe 7a41ebdf5f Add filename property to prebuilt_apex
* Makes it more inline with prebuilt_etc;
* For shim apexes, prebuilt_apex modules have pattern of
  com.android.apex.cts.shim.v1_prebuilt, but I would prefer
  pre-installed shim to be: /system/apex/com.android.apex.cts.shim.apex

Bug: 128677967
Bug: 127789981
Test: m
Change-Id: I34e3e078733420b5cf777fd6e3ce4d8c5796b19b
2019-04-06 11:39:22 +01:00
Nikita Ioffe dd53e8be18 Add installable property for prebuilt_apex
In case of shim apexes, we prebuilt all of them, but only need to
install v1 to a system partition.

Bug: 128677967
Test: manually checked that non-installable prebuilts don't end in /system
Change-Id: I112432abfd8f03cc7d7379ea3cab3f5491ace49c
2019-04-05 22:07:10 +01:00
Colin Cross cc0ce80ed5 Fix package path of android/soong/android pctx
android/soong/common was renamed to android/soong/android long
ago, but the pctx package path was still "android/soong/common".
This required all users of rules defined in android/soong/android
to import "android/soong/android" and then
pctx.Import("android/soong/common").

Test: m checkbuild
Change-Id: I20d096522760538f7cfc2bec3d4bfeba99b275d4
2019-04-04 03:59:34 +00:00
Jiyong Park c320e8262a Key property is removed from prebuilt_apex
The property is not needed as key is embedded in the apex.

Bug: 128344735
Test: m
Change-Id: Iae671994fc271593dd9319f6262279736ea34ad1
2019-04-01 19:25:08 +09:00
Jiyong Park 42cca6c951 Always bundle the public key for APEX
The public key associated with an APEX is always included in the APEX.

Obviously, the public keys are no longer installed to
/system/etc/security/apex

Bug: 128344735
Test: m
Change-Id: I1e1aef1d32597a447b57d49ab80bbfb921fa8178
2019-04-01 19:24:31 +09:00
Jiyong Park c95714ed0d Arch-specific source for prebuilt_apex
Arch-specific source can be specified for prebuilt_apex as follows.

arch: {
    arm64: {
        src: "myapex-arm64.apex",
    },
},

A note on the implementation. The Src property was not tagged as
`android:"arch_variant"` as usual. Instead, multiple Src properties are
explicitly declared like

struct Arch {
    struct Arm {
        struct Src *string
    }
    ...
}

Corresponding Src property is manually selected according to the
MultiTargets()[0].

This is because prebuilt_apex is mutated only for android_common, in
order to have the same arch variant with the apex module type.
Therefore, we can't rely on the arch_variant tag.

Bug: 127789981
Test: m (apex_test amended)

Change-Id: I77dbe626171d8975f549bdb4af3c487232cf05f7
2019-03-30 14:11:37 +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
Jiyong Park 6788256d09 :module syntax support properties in apex_key
public_key and private_key properties support :module syntax so that the
key pairs can be dynamically created during the build, which is useful
for one-time keys.

Bug: 128960614
Test: m (apex_test amended)

Change-Id: I249b1d29f247784193b0d733a7b6a20274ece105
2019-03-22 11:41:09 +09:00
Jiyong Park 52818fcde8 Notice support for APEX
Notice file for an APEX is created by merging notice files for the
modules included in it (plus the notice file for the APEX itself if
specified).

Notice files having the same content are not duplicated; it is emitted
only once.

Bug: 128701495
Test: m (apex_test is amended)
Test: m and inspect $(PRODUCT_OUT)/obj/NOTICE.txt to check there are
license entries for /system/apex/*.apex files

Change-Id: I169d91038291a6c71615de97cf5b03174afab5d4
2019-03-21 08:05:50 +09: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
Jiyong Park 05e70ddc60 Fix the symbol file paths for files in APEXes
This change fixes the problem that symbol files for APEXes are installed to
incorrect path when TARGET_FLATTEN_APEX is set to true or the canonical
name of an APEX is different fro the module name of the APEX.

For the case when TARGET_FLATTEN_APEX is true, LOCAL_SOONG_SYMBOL_PATH
is set to point to the runtime path of a file (e.g. /apex/<name>/*).

For the case of the different canonical and module names, apex_name
property is added to explicitly specify the canonical name

Bug: 120846816
Test: m and inspect that symbol files exist under
$(PRODUCT_OUT)/symbols/apex/com.android.runtime/

Change-Id: Idfec88d6a30a18c225b0d87b868b9f1e0a617e38
2019-03-20 11:55:04 +09:00
Jiyong Park bd13e44610 respect relative_install_path for binaries in APEXes
Bug: 123721777
Test: m (apex_test.go has the test)
Change-Id: I89bc83d4bc6fe8dc374cf36e06e795c75b290844
2019-03-18 14:49:21 +09:00
Jiyong Park d1e293d11e product_specific support for apex_key
apex_key, when with product_specific: true, is installed to
/product/etc/security/apex.

Bug: 128519063
Test: m (apex_test.go amended)
Change-Id: I39e8ac1c486c734dfe0555cd1874468d75e71f34
2019-03-15 02:15:39 +09: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
Alex Light 778127a041 Add support for including py_binary and *_go_binary in apexs
These additional binary types are useful for some apexs. Add the
ability to include them. Due to the nature of the resulting artifacts
only py binaries with embedded launchers and host go binaries are
supported.

Test: m com.android.support.apexer
Bug: 119332365
Bug: 119332362
Change-Id: I27c253d3647cf7bbe15896610d7a74a5f93e8bec
2019-03-01 01:56:14 +00:00
Jaewoong Jung acb6db331b Revert "Add override_module."
This reverts commit aa65e17016.

Reason for revert: Not compatible with PRODUCT_PACKAGES, and so has very limited use.

Change-Id: Ib141d3984a6f12bb50989e66037494c466b066f1
2019-02-28 16:22:30 +00:00
Jaewoong Jung aa65e17016 Add override_module.
This new module type replaces the inherit-package function in make by
allowing developers to override the name, the certificate, and the
manifest package name of an android_app module.

Bug: 122957760
Fixes: 123640028
Test: app_test.go + BrowserGoogle
Change-Id: Iefe447e7078b25039233221361ef95c83a29973a
2019-02-27 14:35:39 -08:00
Alex Light f4857cf3dd Include symlinks in flattened apexs
Flattened apexs were not including symlinks. This could cause expected
files not to be present.

Test: lunch aosp_marlin-userdebug
      m droid
      stat $OUT/system/apex/com.android.runtime.debug/bin/dalvikvm
Bug: 124924906

Change-Id: I04e696602b776b383bf7198eb19220353df74192
2019-02-25 10:14:55 -08:00
Alex Light 49ae3d9819 Don't use stubs for host apexs
Host apexs don't have a system-image associated with them so we need
to include all libraries, including those with stubs.

Test: ./art/test/testrunner/run_build_test_target.py -j50 art-linux-bionic-x64-zipapex
Bug: 125417922
Change-Id: Ie76e6a34e8be1057b29e2e005597c3e4b5fb1f9c
2019-02-21 14:02:46 -08:00
Treehugger Robot 1455d47788 Merge "Install external deps of an APEX" 2019-02-21 00:02:08 +00:00
Jiyong Park 37eb8bbb3a Export make vars using MakeVars method
ed023eca73 introduced a new (better) way
of exporting make vars from singletone. apex_keys_text singletone is
switched to the new method.

Test: inspect out/soong/make_vars-<target>.mk
Check SOONG_SOONG_APEX_KEYS_FILE is set

Change-Id: Ia218852ba9ae40070cb6c99340d97e0c77d19841
2019-02-20 22:26:21 +09:00
Jiyong Park ac2bacd418 Install external deps of an APEX
By default, if a lib is included in an APEX, all its direct and indirect
dependencies are also included in the same APEX. However, when one of
the dependencies have stable API (i.e. has stubs: {...}) then the lib
having stable API and its dependencies are not included in the APEX.

However, the problem here is that the lib having stable API might not be
installed on the system, thus causing error at runtime. This can happen
if there is no other module in the platform that depends on the lib.

This change fixes the problem by adding such libraries as external
dependencies so that they are also installed on the device along with
the APEXes using them.

Bug: 124831003
Test: m installclean; m com.android.resolv
libbinder_ndk, libvndksupport are found under system/lib

Change-Id: I457e03ff3fce37e0890c64d911e6e0ea6d0c6dd6
2019-02-20 22:02:22 +09:00
Jiyong Park 0ca3ce867c build apexkeys.txt
apexkeys.txt is a text file having APEX-to-keys mappings. The file is
included in the target-files package where it is used when re-sign the
APEXes with release keys.

Each line of the file consists of 5 fields:
1) name: file name of the APEX
2) public_key: the public key for the apex_payload.img of the APEX
3) private_key: the private key used to sign the apex_payload.img
4) container_certificate: the certificate used to sign the APEX zip
container
5) container_private_key: the private key used to sign the APEX zip
container

Bug: 124406181
Test: m out/soong/apexkeys.txt and inspect the content
Test: TARGET_BUILD_APPS=com.android.tzdata m dist and make sure
out/dist/apexkeys.txt exists
Change-Id: I1daa13ec50956323b97e15e8df7f1fbe5ea21d63
2019-02-19 14:13:36 +09:00
Jiyong Park 809bb724f5 Add ":name" support for manifest and androidManifest properties in apex
The manifest and androidManifest properties in the apex module type now
supports ":name" syntax.

Bug: 123857186
Test: m (apex_test amended)
Change-Id: Ic4e5a73cf73260d156ec61d07932ad07b2561413
2019-02-14 15:28:58 +09:00
Jiyong Park f97782b18c Remove prefer_sanitize.* properties
The properties are no longer required as an APEX module is mutated with
required sanitizers which are gathered by scanning the sanitizers that
are enabled for its direct dependencies.

Bug: 124128094
Test: m on marlin
The extractor libs are found under /system/apex/com.android.media

Merged-In: I55961d400dcbac067a5c0dcecb90e399d4991a70
Change-Id: I55961d400dcbac067a5c0dcecb90e399d4991a70
(cherry picked from commit abda0eb76b)
2019-02-14 12:30:49 +09:00
Alex Light f1801bc0a5 Ensure that make doesn't flatten zipapex files.
Zip apex files are not really installed so should not ever be
flattened. Unfortunately we didn't send this information to make which
would still unzip everything.

Test: ALLOW_MISSING_DEPENDENCIES=true
      ./art/tools/build_linux_bionic_tests.sh com.android.runtime.host
Bug: 124333446

Change-Id: I3eda579f8c40f768f1ef2be867967f436396cd4c
2019-02-13 19:14:15 +00:00
Jiyong Park b2742fdec9 APEX certificates can be overriden by PRODUCT_CERTIFICATE_OVERRIDES
Test: m (apex_test amended)
Change-Id: I9b66a250c9ca20ad754e12455de2b444cf19b1fa
2019-02-13 19:22:43 +09:00
Jiyong Park 40e26a2a99 Allow each APEX to provide its own AndroidManifest
AndroidManifest.xml file can be specified via the 'androidManifest'
property in the apex module type. It can be used to have a custom
AndroidManifest.xml that have additional tags (such as <uses-sdk> or
<uses-feature>) for precise targeting.

The property is optional; if unspecified, then one is auto-generated as
before.

Bug: 123857186
Test: m apex_test_build_features
Change-Id: Id7ee0471661887cfa11124cbaa3beea8cffcdda4
2019-02-13 16:24:59 +09:00
Alex Light 2a2561f8ac Always build zipapex's unflattened.
Zipapex's cannot be flattened so do not prevent them from being built
even if TARGET_FLATTEN_APEX is set.

Test: lunch aosp_arm-eng;
      ALLOW_MISSING_DEPENDENCIES=true \
      ./art/tools/build_linux_bionic.sh com.android.runtime.host

Bug: 124333446
Change-Id: I4bef65cce100136a8f7852692e841b62ed9e399f
2019-02-12 17:04:47 -08:00