Commit Graph

20035 Commits

Author SHA1 Message Date
Jooyung Han 17a8699112 Merge "apex: Make android_library support APEX variants" am: 5ab5856db3
Change-Id: Ica5977558ef6b5b828ba112e64d574c518eae085
2020-05-21 12:21:23 +00:00
Treehugger Robot 9e6bbde8b1 Merge "Improve tracking of exported sdk libraries" am: 7d74b5f142
Change-Id: I079fbce6f41fb8a36063f085b423f25aa79e6952
2020-05-21 12:21:09 +00:00
Jooyung Han 5ab5856db3 Merge "apex: Make android_library support APEX variants" 2020-05-21 12:02:39 +00:00
Treehugger Robot 7d74b5f142 Merge "Improve tracking of exported sdk libraries" 2020-05-21 12:02:05 +00:00
Jooyung Han acc7bbebe4 apex: Make android_library support APEX variants
The android_library module type can be used within an android_app that
can itself be added to an apex but android_library does not call
android.InitApexModule(module) and so it does not support apex variants
and so is treated as if it cannot be part of an APEX even though it
actually is.

Now, android_library supports AEPX variants.

Due to this change, the whilelist for apex_available got bigger.

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

Bug: 156978407
Test: m
Merged-In: I3a21d653fe9c4159e3a89791fe1a8597865eeae6
Change-Id: I3a21d653fe9c4159e3a89791fe1a8597865eeae6
(cherry picked from commit bd133b1bdc)
2020-05-21 12:01:54 +00:00
Ulyana Trafimovich 556290d2e4 Merge "Fix TestDexpreoptBootZip on non-Linux hosts." am: 8a4ec5024d
Change-Id: Ibd20365bf4dd5ef299d3de4467f62bec269d42d2
2020-05-21 10:01:49 +00:00
Ulyana Trafimovich 8a4ec5024d Merge "Fix TestDexpreoptBootZip on non-Linux hosts." 2020-05-21 09:39:38 +00:00
Paul Duffin 859fe961b0 Improve tracking of exported sdk libraries
The build tracks the java_sdk_library/_import modules that are
referenced by libraries so that it can ensure that any Android app that
includes code that depends on one of those modules has the appropriate
<uses-library> entry in their manifest.

Unfortunately, there were a couple of issues with that:
1) It only tracks direct references to the java_sdk_library module
   itself, e.g. android.test.mock. Direct references to the stubs
   module, e.g. android.test.mock.stubs were not tracked. Making it
   possible for Android apps to reference libraries which would not be
   available at runtime.
2) The logic for determining whether something was a java_sdk_library
   was repeated in a number of places making it difficult to allow
   java_sdk_library/_import instances to determine whether they should
   be treated as an Android shared library.
3) It tracks (and could use) even those java_sdk_library instances
   which do not represent a shared library, e.g. the ones that set
   api_only: true. While this change will simplifty fixing that the
   actual issue will be fixed in a follow up change.

Changes:
* Added EmbeddableSdkLibraryComponent and embedded it into
  java_sdk_library/_import, java_library and java_import. It provides
  the common code to minimize duplication. It contains an
  SdkLibraryToImplicitlyTrack field that if set will cause any
  references to the containing module to add the SdkLibraryParent to
  the list of implicit sdk libraries being tracked.
* Changed code that assumed that anything that implemented
  SdkLibraryDependency required tracking to use the
  OptionalImplicitSdkLibrary() method to get the optional name of the
  sdk library to track. That will allow a follow up change to return
  nil from that method to exclude an sdk library from being tracked.
* Moved SdkLibraryDependency from java.go to sdk_library.go as that is
  a better place for it to be.
* Changed the stubs java_library/java_import creation code to initialize
  the SdkLibraryToImplicitlyTrack field with the name of the creating
  module.
* Initialized the SdkLibraryToImplicitlyTrack field in the
  java_sdk_library/_import so that direct references to them will be
  tracked too.
* Added tests to verify that direct access to the .stubs child of both
  java_sdk_library and java_sdk_library_import are tracked properly.

Test: atest CtsProviderTestCases - which relies on android.test.mock
      being implicitly tracked to verify that I had not broken
	  anything. Used aapt2 dump badging to read the manifest.
	  m nothing - to run the new tests which failed before fixing the
	  code.
Bug: 156723295
Change-Id: Ia99def91e9b74d2ed0a777de04b476c00ea0393d
2020-05-21 10:39:32 +01:00
Ulya Trafimovich 5006d8d4f7 Fix TestDexpreoptBootZip on non-Linux hosts.
The test was written with the assumption that the build OS is
Linux, which is not always the case (the test was broken on Darwin).

Test: m nothing (on Linux host)
Bug: 157192627
Change-Id: I6ae3deed7a3342f4526528f29ce0a299d24b464b
2020-05-21 09:39:24 +00:00
Treehugger Robot 8054254ae9 Merge "java_sdk_library: Do not expose stubs implementation jar" am: c912b4617e
Change-Id: I57d56d0cd52e829e0d18cf2e82697a2d2e6cc059
2020-05-21 09:31:53 +00:00
Treehugger Robot 5cd1713634 Merge "java_sdk_library: Access outputs using tags" am: f716d58339
Change-Id: Icbadfb253714dca2aaff95914c46a9bd96152faa
2020-05-21 09:31:45 +00:00
Treehugger Robot c912b4617e Merge "java_sdk_library: Do not expose stubs implementation jar" 2020-05-21 09:16:04 +00:00
Treehugger Robot f716d58339 Merge "java_sdk_library: Access outputs using tags" 2020-05-21 09:15:58 +00:00
Treehugger Robot 12eaf6e62e Merge "java_sdk_library: Improve consistency with ..._import" am: 4e1f005046
Change-Id: If886ade59939af2e7b14cb4b6bca9e3c09cea2b1
2020-05-21 07:55:41 +00:00
Paul Duffin 8a75a5d5f3 Merge "java_sdk_library: Add redirection to module-lib stubs" am: 83322ba6a2
Change-Id: Id063adf60040bfcbcabd7bcfd03ee79a1621bc5f
2020-05-21 07:55:34 +00:00
Paul Duffin fb0e2c82ae Merge "java_sdk_library: Extract common stubs redirect code" am: 4b05b9ca39
Change-Id: I0126c939c51297c1e5aec30900f80a05f1ec72bb
2020-05-21 07:55:24 +00:00
Treehugger Robot 4e1f005046 Merge "java_sdk_library: Improve consistency with ..._import" 2020-05-21 07:36:35 +00:00
Paul Duffin 83322ba6a2 Merge "java_sdk_library: Add redirection to module-lib stubs" 2020-05-21 07:25:17 +00:00
Paul Duffin 4b05b9ca39 Merge "java_sdk_library: Extract common stubs redirect code" 2020-05-21 07:24:56 +00:00
Jooyung Han f7879cbfbd Merge "apex: install hwasan lib if depended on libc" am: 166349beeb
Change-Id: I5f87d8da976e47bf8cdc59613308942b492c23df
2020-05-21 01:11:21 +00:00
Jooyung Han 166349beeb Merge "apex: install hwasan lib if depended on libc" 2020-05-21 00:48:26 +00:00
Sasha Smundak 400f1f1f84 Handle universal APK case in extract_apks am: 827c55f502
Change-Id: I3de65b4b6b09235fb61f1ccc098487f29bb3bbea
2020-05-20 23:10:43 +00:00
Sasha Smundak 827c55f502 Handle universal APK case in extract_apks
Cherrypick of ag/11553550

Bug: 157081961
Test: manual and builtin

Merged-In: I5ac64c845328a54024171da41c369050243462b0
Change-Id: I3ebc4a84501623774b78c9c19628994c1d71dc64
2020-05-20 13:10:59 -07:00
Paul Duffin 94a475c066 Merge "Add --no-force-assign-all for java_sdk_library" am: 63beac5076
Change-Id: Ib38664dd88cb6393740753cb0ac154247ba63cbe
2020-05-20 17:12:45 +00:00
Paul Duffin 63beac5076 Merge "Add --no-force-assign-all for java_sdk_library" 2020-05-20 17:02:30 +00:00
Paul Duffin 23970f4285 java_sdk_library: Do not expose stubs implementation jar
The stubs header jar is optimized for use as a dependency for others
to use. It only changes if there is a significant difference in the
externals of the classes, i.e. anything that a library being compiled
against depends upon. So changes to implementations of method or the
addition/removal of private methods, fields will have no impact.

As there is no benefit in returning the implementation of the stubs
jar this change removes it. The implementation is still used when
taking a snapshot as the header jar is an internal build artefact
that is not suitable for long term snapshot.

Bug: 155164730
Test: m droid
Change-Id: If91b4d106683f23788547c537228c58be2867174
2020-05-20 18:02:00 +01:00
Paul Duffin 46dc45aba9 java_sdk_library: Access outputs using tags
Previously, in order to access say the public stubs source jar it was
necessary to directly reference the module by name. This change adds
support for accessing them indirectly via tags.

Test: nothing
Bug: 155164730
Change-Id: Id6d76e56c7b46944b2d2a44a2163fb05a5b03de9
2020-05-20 18:01:54 +01:00
Paul Duffin 0f8faffdc0 java_sdk_library: Improve consistency with ..._import
The scopePaths struct is used by both java_sdk_library and its prebuilt
but was not populated in the same way. This change addresses those
discrepancies in preparation for a follow up change which will allow
access to some of those fields through OutputFileProvider.

Changes:
* Document the scopePaths field and struct.
* Switch those fields that may not be fully populated from Paths to
  OptionalPath to make that 100% clear and protect against unchecked
  use.
* Switch java_sdk_library_import to use the dependency extraction
  mechanism driven by the dependency tag. This should actually have
  been part of the change that added that mechanism.
* Only create prebuilt_stubs_sources if sources have been provided.
* Add dependencies from java_sdk_library_import on its stubs source
  child modules if sources have been provided. That will ensure the
  stubsSrcJar field is updated.
* Updates current/removedApiFilePath if provided for the scope in
  java_sdk_library_import.
* Extracts ApiStubsSrcProvider from ApiStubsProvider to allow it to
  be implemented by PrebuiltStubsSources so that it can provide access
  to the stubs src jar that it creates.

Test: m nothing
Bug: 148080325
Bug: 155164730
Change-Id: Ic5bf884b2b1e79841843e7c3b4642796ecd49f5d
2020-05-20 18:00:45 +01:00
Paul Duffin 803a9565cd java_sdk_library: Add redirection to module-lib stubs
Previously, when using sdk_version: "module_current" any direct
reference to an sdk library would use the public not module-lib stubs.
This change corrects that.

Prior to the addition of the module-lib api scope almost all
java_sdk_library instances supported all the scopes to which a request
for jars could be redirected, i.e. public, system and test. The
exceptions to that are a few special instances that were used with
sdk_version: "none" and so were either caught by the java_sdk_library
special cases or dropped through to public.

The addition of module-lib, plus the flexible control over which scopes
are generated means that is no longer true. It is possible for a
java_sdk_library to be requested for a scope it does not have which
would have resulted in an empty set of paths being returned leading to
confusing compilation errors.

To avoid that this change also adds support for using the inheritance
hierarchy defined by the apiScope.extends field to fall back to the
closest available surface.

Test: m nothing
Bug: 155164730
Change-Id: I6aab75a772433ee0a36b6f1758a4aec4be2f9a49
2020-05-20 18:00:45 +01:00
Paul Duffin b05d4295de java_sdk_library: Extract common stubs redirect code
The java_sdk_library and java_sdk_library_import redirect a request for
header and implementation jars to broadly the same place although the
java_sdk_library does have some special code that is mixed in with the
common code.

This change separates the java_sdk_library special code from the common
code and moves the common code into its own method for use by both
module types. That makes the special behavior clearer and ensures the
common behavior remains consistent in future.

Test: m nothing
Bug: 155164730
Change-Id: I53e41a18792488aefd6a886c587559e90b3c4fde
2020-05-20 18:00:45 +01:00
Liz Kammer a40034e3eb Merge "Add signing linage support for android_app_import" am: ff000d65d4
Change-Id: I8ad941274d91793407dcd0fad6ead721ad31eee4
2020-05-20 15:43:48 +00:00
Liz Kammer ff000d65d4 Merge "Add signing linage support for android_app_import" 2020-05-20 15:21:16 +00:00
Ulyana Trafimovich acdab217ac Merge "Add a test for boot.zip (zip archive with boot image files)." am: 7bdb5e5aaa
Change-Id: I74d8d248746e84087e8191acf64b30508ac9d520
2020-05-20 08:43:49 +00:00
Ulyana Trafimovich 2a6f9587de Merge "Raise an error instead of panic in SplitApexJarPairs." am: 7645764e58
Change-Id: I5a65eed47005ea7687b686b1a90abc08360c6bc2
2020-05-20 08:43:42 +00:00
Ulyana Trafimovich 7bdb5e5aaa Merge "Add a test for boot.zip (zip archive with boot image files)." 2020-05-20 08:29:21 +00:00
Ulyana Trafimovich 7645764e58 Merge "Raise an error instead of panic in SplitApexJarPairs." 2020-05-20 08:28:43 +00:00
Paul Duffin c495d2bfed Add --no-force-assign-all for java_sdk_library
Previously, the flag was only added for java_library modules that were
being instrumented. This will also add if for java_sdk_library modules
too.

Bug: 156705688
Test: TARGET_BUILD_VARIANT=userdebug PRODUCT=mainline_modules_x86 EMMA_INSTRUMENT=true NATIVE_COVERAGE=true ./vendor/google/build/build_unbundled_coverage_mainline_module.sh -j8
Merged-In: I5d06ec037007b1770748df24a2e2e8691f177f4f
Change-Id: I5d06ec037007b1770748df24a2e2e8691f177f4f
(cherry picked from commit 31b84c83bf)
2020-05-20 08:19:56 +01:00
Treehugger Robot b64ac9a99f Merge "Revert "Use aapt2 flag --rename-resources-package in soong"" am: 4cb7fc05ae
Change-Id: I27af983e99b57da368da0a53f5d8e9469c938828
2020-05-19 23:42:17 +00:00
Treehugger Robot 4cb7fc05ae Merge "Revert "Use aapt2 flag --rename-resources-package in soong"" 2020-05-19 23:30:08 +00:00
Treehugger Robot 8fae075645 Merge "Correct apex data in androidmk for flattened apex" am: 28f34bf920
Change-Id: I44a0f79e3af3513b181970c5b548cfcbca0b6c34
2020-05-19 19:34:15 +00:00
Treehugger Robot 28f34bf920 Merge "Correct apex data in androidmk for flattened apex" 2020-05-19 19:18:53 +00:00
Liz Kammer 1d5983b0f6 Revert "Use aapt2 flag --rename-resources-package in soong"
This reverts commit 1674f9b4e9.

Reason for revert: Breaks build

Change-Id: I465300eba68b62d65a0c0660b6bc283e4c89253b
2020-05-19 19:15:37 +00:00
Liz Kammer 2497899bb6 Add signing linage support for android_app_import
(This is a cherry pick.)

Test: app_test
Bug: 153366049
Merged-In: I260f198637a1a0f8b3373250413356785c56588a
Change-Id: I260f198637a1a0f8b3373250413356785c56588a
2020-05-19 09:00:25 -07:00
Liz Kammer 4a313bf0c1 Merge "Use aapt2 flag --rename-resources-package in soong" am: f32bbf89de
Change-Id: I9e66f2165c1c8ee0114eba7080e0fe806d8922f9
2020-05-19 15:19:56 +00:00
Liz Kammer f32bbf89de Merge "Use aapt2 flag --rename-resources-package in soong" 2020-05-19 14:59:04 +00:00
Liz Kammer 345e25783a Correct apex data in androidmk for flattened apex
Incorrectly used fmt.Println, printing to stdout instead of the desired
file.

Test: m com.android.art.testing
Bug: 155820504
Change-Id: I1aaf15de4f18f71710bc344bc8f71723e9756ad4
2020-05-19 07:38:59 -07:00
Ulyana Trafimovich 3102921784 Merge "Refactor test to use Go subtests idiom." am: 56b92cf177
Change-Id: Ia9d181d43b8edacf023636ab561ccf8e4e7fc10a
2020-05-19 13:45:50 +00:00
Ulyana Trafimovich 56b92cf177 Merge "Refactor test to use Go subtests idiom." 2020-05-19 13:28:59 +00:00
Jiyong Park df88e6fd6a Merge "Revert "Revert "Allow libz to have stub even though it's not an ..."" am: 550ff8cbfc
Change-Id: Ic3d7724b2b8ebc30eda01473ee1a88579584ce93
2020-05-19 12:16:29 +00:00
Jiyong Park 550ff8cbfc Merge "Revert "Revert "Allow libz to have stub even though it's not an ..."" 2020-05-19 12:06:00 +00:00