Commit graph

348 commits

Author SHA1 Message Date
Paul Duffin
a54016c3ba Only output annotations properties in snapshots for T+
Marks the `scopeProperties.AnnotationsZip` property as only being
supported on T builds and above.

Bug: 204763318
Test: m nothing
Change-Id: Ie59396287c08da77a6a1f15d4be202429e011e17
2022-01-31 12:28:04 +00:00
Paul Duffin
106a3a4bec Allow pruning of unsupported fields in structs in maps
Adds support for traversing into a field that is of type:
   map[...]*struct{...}

This is needed to allow java_sdk_library to mark scope specific
properties, e.g. public.annotations as being target build release
specific.

It was necessary to change the Scope field from:
   Scope map[*apiScope]scopeProperties
to:
   Scope map[*apiScope]*scopeProperties

That is because there is no way in go to change the field of a struct
value of a map. i.e. you cannot do the following, not even using
reflection:
   Scope[apiScopePublic].AnnotationsZip = nil

Bug: 204763318
Test: m nothing
Change-Id: Id103f70f55d4202971321ef4925cbec4b55f8136
2022-01-31 12:28:04 +00:00
Sorin Basca
18ecf61090 Revert^2: "Setting Java 11 as the default version"
Reverted Change: I2f9866deff41406aede24758f6eda5e5808c7f29

Reason for revert: Post-submission failure have been fixed.

Test: presubmit
Bug: 195387473
Change-Id: If5db1614ef455e2f1eae1d36cf514e13e7aab993
2022-01-24 13:31:05 +00:00
Sorin Basca
8d3e0bb25e Revert "Setting Java 11 as the default version"
Revert submission 1944928-default-java11

Reason for revert: Post-submit failures
Reverted Changes:
Ia9a0aa2a4:Setting Java 11 as the default version
Ibf5d10521:Setting Java 11 as the default version

Fixes: 215504708
Fixes: 215502091
Fixes: 215502091
Change-Id: I2f9866deff41406aede24758f6eda5e5808c7f29
2022-01-20 15:37:11 +00:00
Sorin Basca
171c2103b8 Setting Java 11 as the default version
Test: m
Change-Id: Ia9a0aa2a4aa02d7b67ad8e1cb6083d33c3d75e70
2022-01-18 09:05:34 +00:00
Pedro Loureiro
196d3e6b6b Rename updatable-library to apex-library
Mostly for consistency with the names used in related changes.

Test: m nothing

Bug: 191978330
Change-Id: I34637986ead1c671bcc649891aceb3fe0f44b52a
2022-01-06 10:33:42 +00:00
Sorin Basca
9347ae3ba0 Adding option to include sources only for Java 11 builds
Bug: 207852002
Test: m
Test: EXPERIMENTAL_TARGET_JAVA_VERSION_11=true m
Change-Id: I554a79798ea7f1dd4a96b09f761090f83a009cb4
2021-12-20 21:33:14 +00:00
Colin Cross
c68db4b305 Remove InstallBypassMake and ToMakePath
InstallBypassMake and ToMakePath are obsolete, remove them.

Bug: 204136549
Test: m checkbuild
Change-Id: Ie5a6f7254b3d317ed6039e114ed6aec35e1ce273
2021-12-15 15:22:53 -08:00
Colin Cross
d8395b1b2f Revert^2 "Build license metadata files in Soong" am: 4acaea9cbf
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1918948

Change-Id: I8682f46f7843e0d367b96a09135dad03e3df934c
2021-12-11 03:48:25 +00:00
Colin Cross
4acaea9cbf Revert^2 "Build license metadata files in Soong"
b3264f2090

Change-Id: I5ea5f7e29eb1dbc72b8b30f010006a25f5f72fac
2021-12-10 23:05:02 +00:00
Colin Cross
67938c2925 Merge changes from topic "revert-1899703-AMWIVCREEV"
* changes:
  Revert "Build license metadata files in Soong"
  Revert "Add dependency license annotations"
2021-12-10 23:04:45 +00:00
Colin Cross
b3264f2090 Revert "Build license metadata files in Soong"
Revert submission 1899703

Reason for revert: b/210158272
Reverted Changes:
I142c19284:Reuse license metadata files from Soong
Ife89b8f23:Add dependency license annotations
I8e7410837:Build license metadata files in Soong

Change-Id: I48f2bf2e2797ac9d38f7ece35ba616b823035607
2021-12-10 23:02:57 +00:00
Colin Cross
b435744fdc Merge changes from topic "soong-license-metadata"
* changes:
  Add dependency license annotations
  Build license metadata files in Soong
  Escape Host*Variable contents
2021-12-10 21:43:49 +00:00
Colin Cross
3dd2ff28ed Build license metadata files in Soong
Soong has enough information to build the license metadata files
without resorting to the fixups required in Make.

Bug: 207445310
Test: m checkbuild
Change-Id: I8e74108376162b8fdb87ba098ebe94350aa1f7c4
2021-12-08 15:08:59 -08:00
satayev
758968a700 Allow java_sdk_library in an APEX to have higher min_sdk_version.
Inidividual boot or system server jars may have higher min_sdk_version
than the contianing apex, since the runtime respects the values of
min/max_sdk_version; e.g. runtime would not load a boot jar with
higher min_sdk_version. This allows shipping new boot jars via apexes
that target older platforms.

Bug: 190818041
Test: presubmit
Change-Id: I08ec0b4463a17bc8265b948fe09da55eb4e52ac3
2021-12-08 11:36:34 +00:00
satayev
8f088b09d8 Perform CheckMinSdkVersion for java_sdk_library.
In a follow up, apex would expect that any module that implements
ModuleWithMinSdkVersionCheck to have performed appropate checks on
min_sdk_version, to allow relaxing some of the existing conditions.

This change moves the responsibility of checking min_sdk_version
of java_sdk_library to java_sdk_library itself.

Bug: 205923322
Test: presubmit
Change-Id: I79b5a1fc34098fff60221e416db6e6e69e01f531
2021-12-08 11:36:34 +00:00
Pedro Loureiro
ba6682fabf Fix attribute names in generated permissions.xml
Previously it would write min_device_sdk whereas the correct name should
be min-device-sdk. This happened for all shared libs attributes.

Test: m nothing
Test: manually installed an apex with a shared lib and made sure PM used
the attributes as expected

Bug: 191978330

Change-Id: Iecf7edd6bae98c7af908d3f320f10ae4973d0396
Merged-In: Iecf7edd6bae98c7af908d3f320f10ae4973d0396
(cherry picked from commit bde653e5fd)
2021-11-24 17:09:20 +00:00
Pedro Loureiro
c362142438 Perform validation of shared library attributes
Perform consistency checks as per http://go/updatable-shared-libraries

These include:
  * no attribute can specified can be less than T
  * max-device-sdk can't be less than min-device-sdk
  * min and max-device-sdk need to be at least the module's
  min_sdk_version
  * using on-bootclasspath-before implies that the module's
  min_sdk_version is at least T or the library has min-device-sdk of at
  least T

Test: m nothing

Bug: 191978330

Change-Id: Iaca5cf23fb0bc7e65effb3529c8e829560894c2e
Merged-In: Iaca5cf23fb0bc7e65effb3529c8e829560894c2e
(cherry picked from commit f9e584dd20)
2021-11-24 17:09:19 +00:00
Pedro Loureiro
9956e5e281 Add support for new permissions library tag attributes
We are expanding PackageManager's supported attributes and this change
enables the developer to define them in the .bp file.

Test: m nothing

Bug: 191978330

Change-Id: I01d579190fb585662086a7fc456f3b33cb89fb57
Merged-In: I01d579190fb585662086a7fc456f3b33cb89fb57
(cherry picked from commit 826863c8e0)
2021-11-24 17:09:18 +00:00
Trevor Radcliffe
df8aa1fbcf Reformat SDK Library docs
We're not sure what formatting is applied to this but it sure
isn't markdown.

Fixes: 204572072
Test: Build and compare docs
Change-Id: Ib023f0cb490a7c7c5605d426ce5e70a7130d5162
2021-11-04 14:39:06 +00:00
Jiakai Zhang
a14b18fb31 Merge "Remove updatable-bcp-packages.txt." 2021-09-26 03:34:28 +00:00
Martin Stjernholm
cf6bf37d04 Merge changes I957f3df8,I68986dcc
* changes:
  Consolidate the code to resolve a deapexer module dependency.
  Propagate the dex jar path as an OptionalPath which is either valid or invalid with a message.
2021-09-24 09:32:24 +00:00
Jiakai Zhang
46eb0fd501 Remove updatable-bcp-packages.txt.
Historically, this file was used by the `--updatable-bcp-packages-file`
flag for dex2oat. The flag is no longer needed and is being deprecated.

Unfortunately, we cannot remove `permitted_packages` and all the code
related to it because we still need it for checking the module
compatibility with Q and R.

Bug: 200241946
Test: m nothing
Change-Id: Ie3be54fd47a847ba0caf627d12da76b415d99466
2021-09-24 03:19:05 +00:00
Martin Stjernholm
4482560cc7 Consolidate the code to resolve a deapexer module dependency.
It will get more logic in upcoming CLs.

Add a property to DeapexerInfo for the APEX name, for use in error
messages.

Test: m nothing
Bug: 192006406
Change-Id: I957f3df8b34543a38cde38768dac93e78132d672
2021-09-23 17:19:55 +01:00
Martin Stjernholm
8be1e6db16 Propagate the dex jar path as an OptionalPath which is either valid or
invalid with a message.

This will allow propagating any error from the deapexer module for
prebuilt APEXes to the location where the dex jars get used. It's only
at those points that we can raise errors about not being able to
extract files from the deapexer modules if they are invalid, and this
way we avoid encoding knowledge there about why they may be invalid.

To keep the refactoring limited it intentionally does not change any of
the existing logic for when dexJarFiles are set or not (non-nil vs nil
prior to this change), although there may be opportunity to use this
for more conditions when dex jars aren't available.

The refactoring is also not extended to
dexpreopt.ClassLoaderContextMap.

Test: m nothing
Bug: 192006406
Change-Id: I68986dccd9a9b3fee4d24caa1947ea17a36caedc
2021-09-23 17:19:55 +01:00
Anton Hansson
86da9c6a3d Merge "Add annotations.zip support to java_sdk_library" 2021-09-23 09:39:38 +00:00
Anton Hansson
d78eb76f64 Add annotations.zip support to java_sdk_library
The annotations zip file is produced by the "main" sdk build and is
primarily consumed by android studio.

In order to support building the main SDK without requiring the sources
of all modules, we are adding module SDK artifacts that allows
reconstructing these outputs. The annotations zip contains XML files
which should be fairly easy to merge from all the individual parts.

Bug: 187397779
Test: unit tests in this CL
Test: m sdkextensions-sdk and inspect output
Change-Id: I955cae720e6f1382936836ee1d8fb11003f51b7d
2021-09-22 17:23:10 +01:00
Anton Hansson
8b1add6dd4 Merge "Add back the api_srcs argument" 2021-09-21 14:45:02 +00:00
Anton Hansson
f8ea3729ca Add back the api_srcs argument
This arg provides the ability to pass sources to the metalava
invocations that are part of a java_sdk_library without affecting
the runtime library.

This is useful in various scenarios, e.g.: when javadoc in some source
files affects the metalava behavior. For example, the javadoc-generation
javadoc tags @paramDoc, @returnDoc etc. Passing these as a library does
not work because class files do not contain javadoc.

Bug: 186197911
Test: manually inspect module stub src for doc enhancements
Merged-In: I2ce98f891283514e1896c52d9335550c1f5435fb
Change-Id: I2ce98f891283514e1896c52d9335550c1f5435fb
2021-09-17 13:42:44 +00:00
Jiakai Zhang
204356f3b5 Preopt APEX system server jars from prebuilts.
Similar to the previous CL, but for jars from prebuilts.

Test: manual - 1. Patch aosp/1818020 and aosp/1810840.
  2. m SOONG_CONFIG_art_module_source_build=false com.android.art
Bug: 194150908
Change-Id: Idc0c73a78045a602ad3a91cb5071d291bd611015
2021-09-15 09:01:07 +00:00
Paul Duffin
296701e35b Refactor SdkMemberType.AddDependencies()
Replaces the BottomUpMutatorContext parameter with a new
SdkDependencyContext type that extends BottomUpMutatorContext. This is
to allow the sdk to pass additional information to the implementations
of that method to allow the behavior to be more finely tuned.

Bug: 195754365
Test: m nothing
Change-Id: I69c6d2c523934eb67d7a7e6c55c241e9b8a81773
2021-08-31 17:07:07 +01:00
Spandan Das
93e95992a4 Update documentation for genrule and sdk_library
1. Documentation for genrule and sdk_library was missing a period, which
has been added now. For
genrule, Before:
https://android-build.googleplex.com/builds/submitted/7594870/linux/latest/view/genrule.html,
After:
https://x20web.corp.google.com/users/sp/spandandas/soong_docs/genrule.html

2. Documentation for genrule was missing definition of $(locations),
which has been added now

Bug: 194231221
Test: m soong_docs
Change-Id: Ia367f13055c110d92a491a9c1b1af4113f66b296
2021-07-30 00:25:20 +00:00
Ulyana Trafimovich
c2427ea290 Merge "Remove OptionalImplicitSdkLibrary() function (it's not used anymore)." 2021-07-19 10:38:45 +00:00
Ulya Trafimovich
78645fbba1 Remove OptionalImplicitSdkLibrary() function (it's not used anymore).
Slightly improve documentation for `OptionalSdkLibraryImplementation()`.

Bug: 193425964
Test: m nothing
Change-Id: I3c3f385cf948cdbec54b5a6fb33a4d24d4b54be3
2021-07-16 16:24:31 +01:00
Paul Duffin
630b11e9d4 Build updatable-bcp-packages.txt from prebuilts in sdk snapshot
Previously, the java_import and java_sdk_library_import modules did not
make their permitted_packages available to the rule that generates the
updatable-bcp-packages.txt file. This change corrects that.

Bug: 193763688
Test: m nothing
      - Added unit tests, which all failed and then fixed the tests.
Change-Id: If0706e4551a331b48d383123088e63924dded48b
2021-07-15 14:16:44 +01:00
Paul Duffin
869de147ab Propagate permitted packages to sdk snapshot
Previously, permitted_packages were not copied to the sdk snapshot.
This change corrects that.

Bug: 193763688
Test: m nothing
      - Added unit tests, which all failed and then fixed the tests.
Change-Id: I4560987f746f78c0ae706058195b6db4bea438aa
2021-07-15 14:15:58 +01:00
Jeongik Cha
d5fe8782e0 SdkLibraryImport's DexJarInstallPath uses installPath from source module
Even though actual installed module path is the same as source module,
it uses impl's one.

Bug: 188179858
Bug: 193082464
Test: compare dexpreopt_config.zip files from
  1. TARGET_BUILD_UNBUNDLED_IMAGE=true m dexpreopt_config_zip
  2. m dexpreopt_config_zip
  (note that m clean should run between steps)
Test: build aosp_cf_x86_64_phone,  launch_cvd, and then
  adb wait-for-device \
      && adb root \
      && adb logcat \
      | grep -E 'ClassLoaderContext [a-z ]+ mismatch' -C 1
      and then check if there is no message.

Change-Id: I34ffd9a2d214a6614c2befc35b2beec003cfcd25
2021-07-13 13:54:03 +00:00
Paul Duffin
3f0290ef79 Support using java_sdk_library components in stub_libs
Previously, if a bootclasspath_fragment had both a java_sdk_library
module and one of its components in stub_libs properties they would be
treated as separate modules instead of simply different APIs from the
same module. That would result in them both providing stub dex jars to
"hiddenapi list" which would fail because it found duplicate
definitions of the same class.

e.g. Specifying something like this:
    api: {
        stub_libs: [
            "art.module.public.api",
        ],
    },
    core_platform_api: {
        stub_libs: [
            "art.module.public.api.stubs.module_lib",
        ],
    },

would cause "hiddenapi list" to fail because it would have been passed
paths to two dex jars (actually the same dex jar but that does not
matter) each of which defined the same class, e.g. java.lang.Object.

This change treats the "art.module.public.api.stubs.module_lib" and
"art.module.public.api" modules as being the same for the purposes of
hidden API processing.

Bug: 192446466
Test: m nothing
Change-Id: I9de96337f64f26e24cff040d4bbed9eecc67b1ed
2021-06-30 19:36:52 +01:00
Paul Duffin
ea8f808580 Ensure consistent APEX variation for java_sdk_library and java_sdk_library_import
Previously, a java_sdk_library with shared_library = true would create
a variation per APEX because it depends on an sdkLibraryXml module
which generates a file containing the APEX name. However, a shared
java_sdk_library_import would create a merged APEX variation. The
inconsistent variations caused failures in sdkDepsReplaceMutator.

This change ensures that both java_sdk_library and
java_sdk_library_import create an APEX specific variation when their
shared_library property is true.

Bug: 190499958
Test: m nothing
      - ran the above command after modifying the test to reproduce the
        problem and then after fixing to verify that it fixed the problem.
Change-Id: Iee81776a8569db3e871c40cbde14d248dfeb56e4
2021-06-24 13:33:01 +01:00
Paul Duffin
b97b1579d3 Remove duplicate component from sdk snapshot
Previously, an sdk snapshot could contain the following:
* A java_sdk_library_import module, e.g. "foo" which creates component
  modules "foo.stubs", etc.
* A corresponding versioned module, e.g. "sdk_foo@current" which
  created component modules "sdk_foo@current.stubs", etc.
* An internal (to the sdk snapshot) java_import for one of "foo"'s
  components, e.g. "sdk_foo.stubs"
* A corresponding versioned module, e.g. "sdk_foo.stubs@current".

That causes a few problems:
1. The "foo.stubs" is duplicated.
2. The names of the components created by the versioned
   java_sdk_library_import are invalid, as they append the component's
   suffix to the version and not the name before the version.

The latter causes problems when building against prebuilts and fixing
that causes the generated snapshot to be invalid because it contains
duplicate definitions of the "sdk_foo.stubs@current" module. One
explicitly in the Android.bp file and one created by the
"sdk_foo@current" module.

Removing the duplicates from the snapshot causes errors as the name
generated by the snapshot for the component module, i.e.
"sdk_foo.stubs@current" does not match the name generated by the
"sdk_foo@current", i.e. "sdk_foo@current.stubs".

This change fixes them together.

Bug: 179354495
Test: m nothing
Merged-In: I515f235fe21755b5275af12366e96c24c94c0273
Change-Id: I515f235fe21755b5275af12366e96c24c94c0273
(cherry picked from commit a1aa7387f7)
2021-06-23 21:38:14 +01:00
Paul Duffin
71b33cca9d Add commonSdkLibraryAndImportModule interface
The commonSdkLibraryAndImportModule defines the methods that a module
which embeds the commonToSdkLibraryAndImport struct need to provide.

Bug: 179354495
Test: m nothing
Change-Id: I7a469ae03ea5c19922200284da08a9ae38a46751
2021-06-23 11:50:08 +01:00
Paul Duffin
86fe8f8514 Remove unused apiModuleName
Bug: 179354495
Test: m nothing
Change-Id: Id1dd09a11c63981b32af524cffcdbd177c8f0232
2021-06-22 12:45:07 +01:00
Paul Duffin
b4bbf2ca10 Simplify deapexer support
Uses the apex relative path to the file as the identifier that is used
to obtain the path to the corresponding file extracted from the apex.
That is instead of a special constructed string id.

Bug: 177892522
Test: m nothing
Change-Id: I5dc77c8fb272bac289b8891d1eac801e541af1f5
2021-06-17 15:59:07 +01:00
Paul Duffin
fef5500a76 Remove javalib special case in createDeapexerModuleIfNeeded
Removes the special case in createDeapexerModuleIfNeeded for handling
java libraries and just get the Import and SdkLibraryImport module
types to implement RequiredFilesFromPrebuiltApex instead.

Bug: 177892522
Test: m nothing
Change-Id: I5cc341b5b4168b8eb196f72273a00d498de6856f
2021-06-17 14:56:05 +01:00
Colin Cross
f0eace9eed Remove core_lib property from java_sdk_library
Its not used, remove it.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I1689b670a8ae6a614e5e4ec5e79cb5e283b2e277
2021-06-02 13:02:23 -07:00
Colin Cross
59b92bfdb3 Ignore owner property when computing java_sdk_library dist subdirectory
The owner property is no longer used, the dist subdirectory is determined
by the dist_group property.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: Id6d997eef05f6511070677974219674f248cb754
2021-06-02 13:02:01 -07:00
Colin Cross
3dd662509d Make the default java_sdk_library dist_group "unknown"
Change the default dist_group from "android" to "unknown" to prevent
accidentally including java_sdk_library stubs that do not set
dist_group or owner in the public SDK.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I9aae2a16254ac1a8d444acfa63bc571d1ef4b045
2021-06-02 12:59:21 -07:00
Colin Cross
986b69aa51 Support dist_group property instead of owner for setting sdk dist subdirectory
Reusing the owner property is confusing, especially when the property is
required on every java_sdk_library module.  Create a new dist_group property
to use instead.

Bug: 186723288
Test: TestJavaSdkLibraryDist
Change-Id: I9e62c703a95d6b63cafa60bffb1b37ba85388593
2021-06-01 13:40:44 -07:00
Paul Duffin
32cf58a8fc Support removed API members in modular hidden API processing
Previously, the hidden API flags generated for a bootclasspath_fragment
did not include removed API members. That was because it did not supply
a file containing the dex signatures of the removed API members.

The monolithic hidden API processing uses combined-removed-dex which is
the output of a genrule that takes as input the *removed.txt files from
all the APIs and uses metalava to construct the dex signatures file.
This change does the equivalent for the *removed.txt files for the APIs
provided by a bootclasspath_fragment and then passes them to the rule
that generates the final all-flags.csv.

Bug: 179354495
Test: - Update packages/modules/RuntimeI18N to enable hidden API
        processing.
      m out/soong/hiddenapi/hiddenapi-flags.csv
      - Before this change that fails as the flags generated for the
        i18n-bootclasspath-fragment differ from the monolithic flags.
	After this change that passes.
      - Verify that this change does not change any of the monolithic
        hidden API files.
      m com.android.i18n
      - Verify that the apex file before and after this change are byte
        for byte identical.
Change-Id: I6a21edb8a5231666e3f35b2c99a8687f36dd98fd
2021-05-24 15:05:21 +01:00
Colin Cross
18f840c45e Allow missing java_sdk_library files in AllowMissingDependencies builds
java_sdk_library modules in builds with AllowMissingDependencies may
be missing defaults modules that cause them to look for api files that
they normally wouldn't need.  Move the error to runtime so it doesn't
block the build unless the branch tries to build that module.

Test: prebuilts/build-tools/build-prebuilts.sh in aosp-build-tools
Change-Id: I279b0cd8493779f972c0ac02235967c10b35a5a0
2021-05-20 18:00:37 -07:00
Jiyong Park
ab50b0795a Rename InApexes -> InApexVariants
.. in preparation for the upcoming change. This change doesn't alter any
behavior.

InApexes is a misleading name. People expects that it has the list of
soong module names of the APEXes that a module is part of. So, for
example, `core-oj` is a part of both `com.android.art` and
`com.google.android.art`. However, in reality, that's not true. The
field has `com.android.art` only. This is because the two APEXes
(android and Google) have the same apex name which is `com.android.art`.
That apex name is used in various places like the `apex_available` and
allows us to keep using the same name regardless of whether the APEX is
overridden or not.

However, this is causing problems in some cases where the exact list of
soong module names is required. The upcoming change will add a new field
to handle the case and the new field actually will get the name
'InApexes'. So, the existing field is renamed to a less misleading name
`InApexVariants`.

Bug: 180325915
Test: m nothing

Change-Id: I0c73361b452eddb812acd5ebef5dcedaab382436
2021-05-18 16:05:14 +09:00
Paul Duffin
1bbd0626f2 Make uncompressDex available for use through hiddenAPIModule
In order for the bootclasspath_fragment to perform dex encoding on its
contents it needs to know whether the dex file is uncompressed or not.
This change makes that information available by passing it to
initHiddenAPI, storing it in hiddenAPI struct and providing access
through the hiddenAPIModule.

Bug: 179354495
Test: m droid
Change-Id: I913416b4836766de194203fd8ed5124b61dfa3dd
2021-05-17 18:38:06 +01:00
Paul Duffin
74d18d1d6f Merge initHiddenAPI and hiddenAPIUpdatePaths
These two methods did very similar jobs and merging them together
simplifies the behavior.

Bug: 179354495
Test: m droid
Change-Id: Ibe1a23d54105e6a0e5693079cd8743679301fc85
2021-05-17 18:38:06 +01:00
Paul Duffin
66cdbf07ef Remove configurationName from java library and hidden API
The configurationName was intended to separate the name of the module
from the name used in configuration (such as BootJars) so that the
child implementation library of a java_sdk_library on the bootclasspath
would have hidden API encoding performed on it just as for the main
java_library embedded within the java_sdk_library.

While that did use to work it no longer does as the test added in the
preceding change proves. It is not surprising that this regression does
not appear to have caused any issues as the the child implementation
library is only a build time artifact and not used at runtime.

In future the only modules that will require hidden API encoding are
those that are part of a bootclasspath module so there is no point in
maintaining this capability.

Bug: 179354495
Test: m droid
Change-Id: Ief8136fa9e98600cdd8d36108ec22edc2ebd7c69
2021-05-17 18:38:06 +01:00
Paul Duffin
afaa47c74a Stop generating unnecessary hidden API rules
The rules to extract hidden API information from an individual module
in order to create module specific files are no longer necessary as
the monolithic files are created directly from the module's class jars
and not the module specific files.

Bug: 179354495
Test: verified that the monolithic out/soong/hiddenapi/... files are
      unchanged by this change
Change-Id: I573ac17f3ea5da5a2a7e4f08718160dacca71c0c
2021-05-14 15:57:10 +01:00
Paul Duffin
f4600f6e6a Disallow shared libraries in bootclasspath_fragment contents
Bug: 177892522
Test: m nothing
Change-Id: I78c8ef8664ec1eb0fe3456a2de2cb956162ca0da
2021-05-14 00:39:24 +01:00
Paul Duffin
22628d50f3 Add support for SOONG_SDK_SNAPSHOT_USE_SRCJAR
Test: m SOONG_SDK_SNAPSHOT_USE_SRCJAR=true ipsec-module-sdk
      - check generated snapshot.zip file.
Change-Id: I02991e2a60d7784984b308cff2c47ee809d61f01
2021-05-12 23:13:22 +01:00
Jaewoong Jung
476b9d6d17 Strict updatability linting against dependencies.
Propagate strict_updatability_linting to transitive dependencies using a
top-down mutator.

Test: lint_test.go
Bug: 182349282
Change-Id: Ifc9e58f1a597e3c7725ee49b4027afb6f42f45cb
2021-05-10 15:30:00 -07:00
Paul Duffin
320055eb8c Merge "Stop exporting java_sdk_library libs in the snapshot" 2021-05-07 13:34:33 +00:00
Paul Duffin
e7c94a689b Stop exporting java_sdk_library libs in the snapshot
The libs property in java_sdk_library is not safe to export as it can
contain libraries that contain implementation specific classes. No
snapshot appears to need this capability but if it does become
necessary then either it will need to use the existing stub_only_libs
property or a new one will need to be added.

Bug: 157884619
Test: m nothing
Change-Id: I60a069177dbee4070d311b23d25f4eb3c5e7ea13
2021-05-06 23:22:15 +01:00
Paul Duffin
b6b89a4074 Add missing calls to InitSdkAwareModule
A follow up change will add methods to SdkBase which requires its
module field to have been initialized.

Bug: 181569894
Test: m nothing
Change-Id: I9b02f260ad3f82316cc7ab3b5717b7e81090b0d8
2021-05-06 23:13:06 +01:00
Paul Duffin
976b0e5bbb Automatically export bootclasspath_fragment stubs from sdk
This change makes the tag that is used to add dependencies onto stubs
from the bootclaspath_fragment module cause the dependency to be
automatically exported from the sdk. If the dependency is a
java_sdk_library then it will be as if it was added to the
java_sdk_libs property, otherwise it will be as if it was added to the
java_header_libs property instead.

Bug: 177892522
Test: m nothing
Change-Id: I97010c4342dd39415dba81a4395db7831410436e
2021-04-27 23:27:34 +01:00
Anton Hansson
dae54cd84f Add new stub_only_static_libs attr for sdk_library
Allow java_sdk_libraries to include libraries statically into their
stubs. The immediate use-case of this is to embed libcore notice files
into their stubs.

Also extend the java_sdk_library tests for impl/stub-only-libs, plus
some not assert utils.

Bug: 173186484
Bug: 184839599
Test: soong tests
Change-Id: I1ebf2f35c048eab5cec5125482a0304fe660f188
2021-04-22 10:20:13 +01:00
Paul Duffin
1267d875b6 java_sdk_library: Make dex stub jars available for hiddenapi
The hidden API processing needs access to dex jars for the API stubs in
order to determine which dex members are part of an API surface. The
dex stubs used for the monolithic file are provided by normal
java_library modules for legacy reasons. However, the APEXes that
contribute to the bootclasspath, and so need to perform hidden API
processing, typically provide stubs created by a java_sdk_library.

This change adds support to java_sdk_library/_import to make the dex
stub jars available when requested, that involves:
1. Adding compile_dex property to java_sdk_library_import and
   propagating it down the the java_import modules for the stubs. That
   is already handled for java_sdk_library.
2. Propagating the java_sdk_library compile_dex property to the
   java_sdk_library_import in the generated snapshot.
3. Refactoring and wiring to make the dex stubs jar available to other
   parts of Soong.

Bug: 179354495
Test: m nothing
Change-Id: I5895d4f2ba0b684870862b9429b2364865e4afc6
2021-04-16 18:48:20 +01:00
Jiyong Park
f398995a64 Merge "SdkSpec is fully using ApiLevel" 2021-04-14 13:27:05 +00:00
Anton Hansson
f247ff73ae Merge "Fix bug in sdk_library string matching" 2021-04-08 09:28:41 +00:00
Jiyong Park
9231537fe2 SdkSpec is fully using ApiLevel
Previously, SdkSpec was constructed only from the user string. It didn't
make use of the Config struct where information about the latest stable
SDK version, etc. is recorded. As a result, the build system couldn't
check if the sdk version "current" is referring to the in-development
(i.e.  not-yet-frozen) SDK version or the latest stable version.
"current" was always assumed to be in-development (IsPreview() returns
true) even when Platform_sdk_final == true.

As the first step for fixing that, this change requires
android.EarlyModuleContext to be passed when constructing SdkSpec from
the user string.

In the following changes, "current" will be mapped to either
FutureApiLevel (10000) or one of the FinalApiLevels() depending on
whether the platform SDK was finalized or not.

Bug: 175678607
Test: m
Change-Id: Ifea12ebf147ecccf12e7266dd382819806571543
2021-04-08 11:27:24 +09:00
Anton Hansson
08f476bf83 Fix bug in sdk_library string matching
- The public stubs were being matched against the string ".stubs.public"
  which was never the suffix that these stubs used
- Remove obsolete naming pattern matching

Test: m
Change-Id: I1f7bd54e4629f42e34fb3c09828d8853813ba2a7
2021-04-07 15:39:58 +01:00
Paul Duffin
864116ce3f Add PrebuiltNameFromSource
Bug: 177892522
Test: m nothing
Change-Id: I45274836d59adbd6b2a2a848705b189398f1e766
2021-04-06 21:20:58 +01:00
Jiyong Park
54105c48f4 SdkSpec = Scope + ApiLevel
SdkSpec.Version was an int type. Now it becomes ApiLevel type which
is a better abstraction of the version (or api level).

Bug: 1655587
Test: m

Change-Id: I4d67b9b9eae45f653b6af4f5b73da9e091b3dfab
2021-04-05 09:32:06 +09:00
Jiyong Park
f1691d2a2c Move java.sdkSpec to the android package
... in preparation for making the handling of sdk versions consistent
across java and cc modules.

Bug: 175678607
Test: m
Change-Id: I598f0454bce9b7320621022115412fbe97403945
2021-04-03 08:25:12 +09:00
Jaewoong Jung
bc15e3a798 Improve java.go readability.
Test: TreeHugger
Change-Id: I98bb7bddb740451ff2ccd28dcdaddff27e35a8cd
2021-03-15 13:58:44 -07:00
Jaewoong Jung
1a97ee0b20 Populate baseline_file values.
Set baseline_file properties of droidstubs generated in sdk_libary.go to
incompatibilities modules auto-generated by prebuilt_api. This requires
prebuilt_api to generate the modules whether next_api_dir is set or not.

Test: TreeHugger
Bug: 180123247
Change-Id: I690604a8a54e9d9419f072a28a0c0e7734abbd85
2021-03-09 16:26:03 -08:00
Paul Duffin
3785673f9b Allow java_sdk_library_import to contribute to hiddenapi processing
Invokes hiddenAPIExtractInformation() on the java_sdk_library_import's
dex implementation jar provided by the deapexer (on behalf of
prebuilt_apex) so that hiddenAPI can extract the information it needs,
if anything, from the dex file.

The dex file provided by deapexer has already had the hiddenapi
information encoded into it so it does not need to do that again.

Usually, it would require a classes implementation jar as well in
order to extract information from UnsupportedAppUsage annotations but
that is not available for a java_sdk_library_import. Fortunately, the
modules that are currently affected by this do not contain any such
annotations. This just uses a public api stubs jar instead.

Bug: 181267622
Test: m nothing
Change-Id: I96275e46f8b7fecba88075319e9f2da5ae315c03
2021-03-01 12:58:28 +00:00
Paul Duffin
3985351df6 Retrieve dex implementation jars from apex for java_sdk_library_import
Bug: 181267622
Test: m nothing
Change-Id: Idd6af2482f48bd3a05db88b8a06dbbbdee01ef78
2021-03-01 12:58:28 +00:00
Treehugger Robot
277303f042 Merge "Add ctx to AndroidMkExtraEntriesFunc" 2021-02-22 22:40:31 +00:00
Colin Cross
aa2555387d Add ctx to AndroidMkExtraEntriesFunc
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to
access providers.

Test: m checkbuild
Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
2021-02-19 23:05:40 +00:00
Colin Cross
dcf71b299c Convert java.Dependency to JavaInfo provider
Export information about java dependencies through a Provider
instead of accessing the module directly.

Test: java_test.go
Test: no changes to build.ninja
Change-Id: Ifc5d566bf6f6ebc0ad399e948effaa1ef6a22876
2021-02-09 15:36:25 -08:00
Anton Hansson
e77fccc959 Add a better error message for missing api files
Add some instructions for what to do.

Bug: 177806245
Test: m nothing (with java_sdk_library with no tracking files)
Change-Id: I286018f4d9105d5ade1e76cddb8670d0d097d77d
2021-01-20 19:21:16 +00:00
Anton Hansson
e6056153cf Remove Ignore_missing_latest_api
This flag was only used by sdk_library.go, and is no longer needed
since sdk_library.go now knows which libraries are missing latest_api
tracking files.

Bug: 176092454
Test: m
Change-Id: I5a967f784bde99f103b85654c794e8d7110fd0db
2020-12-31 10:44:38 +00:00
Anton Hansson
591920fcfa Merge "Stop allowing missing last-api files by default" 2020-12-31 08:53:45 +00:00
Anton Hansson
e87b03d1bb Set previous_api correctly for java_sdk_library
Metalava used this attribute to potentially re-write some nullness
annotations from @Nullable to @RecentlyNonNull, and not doing so can
cause problems when compiling kotlin.

Bug: 176092452
Test: m art.module.public.api.stubs && \
      rm -rf /tmp/lib && \
      unzip -qd /tmp/lib art.module.public.api.stubs.jar && \
      javap -v /tmp/lib/java/util/concurrent/ConcurrentHashMap.class | \
      grep Recently
Change-Id: I9012798f27e39d9a53dbcf0976548f6cec2d3150
2020-12-29 13:24:02 +00:00
Anton Hansson
0615864046 Stop allowing missing last-api files by default
Bug: 176092454
Test: m nothing
Change-Id: I9eadcb774e9898bb4f43054661826326b2c527c2
2020-12-29 13:20:42 +00:00
Anton Hansson
74c8436ce0 Merge "Add attribute to disable last-api compat tracking" 2020-12-23 09:05:46 +00:00
Jaewoong Jung
18aefc1977 Remove unnecessary snake case variables.
Test: m nothing + TreeHugger
Change-Id: I99f7162944daa6c57c6ae4763261e108bb5cb6b1
2020-12-22 12:38:35 -08:00
Ulyana Trafimovich
b630c37d61 Merge changes I6a512209,I56437f26
* changes:
  Unify addition of class loader subcontext from dependencies.
  Move ClassLoaderContexts() method to UsesLibraryDependency interface.
2020-12-22 10:14:41 +00:00
Anton Hansson
dff2c78a20 Add attribute to disable last-api compat tracking
Setting this to true by default is dangerous as it can mask bugs. Create
a dedicated attribute for java_sdk_library to enable this behavior
instead. The default will be flipped in a future CL when all the current
offenders have been fixed.

Fix all the tests to have the right API files.

Bug: 176092454
Test: m nothing
Change-Id: Ieab94bcb74abf8d018365a56fb447fe3dbd46957
2020-12-21 17:25:30 +00:00
Ulya Trafimovich
dbf31665ab Move ClassLoaderContexts() method to UsesLibraryDependency interface.
This method logically belongs with other UsesLibraryDependency methods,
as it is used in the same context when computing class loader context.
Previously it was part of Dependency interface, which doesn't cover SDK
libraries. We do not currently have the necessary information for
SdkLibraryImport (so ClassLoaderContexts() returns nil for it), but we
do have it for SdkLibrary (via Library).

Bug: 132357300
Test: m nothing
Change-Id: I56437f260efc6a9af3f45b334e84e915244ccce1
2020-12-17 15:05:26 +00:00
Jiyong Park
45bf82e953 Assert android.ApexModule interface for types having ApexModuleBase
Bug: 173472337
Test: m nothing
Change-Id: Idf1c6cb9fff6c18e34c4636e38a662ba4ff7d538
2020-12-15 14:31:27 +00:00
Colin Cross
f1a035e6be Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access
the BuilderContext by passing it to NewRuleBuilder instead of
RuleBuilder.Build.

Test: genrule_test.go
Test: rule_builder_test.go
Test: m checkbuild
Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-12-01 16:22:16 -08:00
Paul Duffin
040e906fcf java_sdk_library: Copy removed API specification file to dist
Uses the dists property to copy the removed API specification file for
each API scope alongside the API specification file in the dist.

Bug: 158544979
Test: m nothing
      m dist sdk - before and after this change, compare result to
      make sure that there are no significant differences other than
      the after now contains -removed.txt files for each scope of each
      java_sdk_library
Change-Id: If23c594d29a12e49d2c5a8945ad488874bb1590c
2020-11-27 15:17:44 +00:00
Ulyana Trafimovich
af07f732e6 Merge "Assume any <uses-library> is shared, add only toplevel ones to manifest." 2020-11-27 10:44:54 +00:00
Ulya Trafimovich
78a7155c17 Assume any <uses-library> is shared, add only toplevel ones to manifest.
This patch reworks the approach introduced in
https://r.android.com/1450819. That patch based the decision which
libraries should be added to the manifest <uses-library> tags by the
manifest_fixer on the "shared" status of the library.

That approach is incorrect for two reasons:

  - It doesn't make sense to have a non-shared library in class loader
    context ("shared" libraries are those specified in
    frameworks/base/data/etc/platform.xml, and they are the only ones
    that PackageManager knows about).

  - It doesn't make sense to add anything but the top-level of the
    class loader context tree to the manifest, because this part of the
    tree is flattened to a sequence, and PackageManager cannot restore
    it to the previous tree shape (there is an information loss).

This patch removes the "shared" bit of information from class loader
context elements and assumes that all libraries that end up in class
loader context are shared. Consequently, only the top-level libraries
should be passed to manifest_fixer.

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Bug: 168686456
Change-Id: I902690f0f38f1047fa79cf6ccbe956077eceaab0
2020-11-25 14:47:05 +00:00
Paul Duffin
3131025d61 java_sdk_library: Allow dist artifacts to be named
Unless no_dist: true is specified the java_sdk_library will
automatically copy the stubs jar and the API specification file (but
not the removed API specification file) for each scope to the apistubs/
directory in the dist from which the sub-directories in prebuilts/sdk
are populated. Previously, the name of those artifacts was based on the
name of the module. This change adds the dist_stem property to allow
the name of those artifacts to be specified separately to the module.

The purpose of this is to allow the art.module.public.api,
conscrypt.module.public.api and i18n.module.public.api java_sdk_library
modules to use a different name when copying to the dist,
e.g. conscrypt.module.public.api should use conscrypt.

Additionally, as the artifacts in the dist end up being copied verbatim
to prebuilts/sdk and the prebuilt_apis module uses those names to
create a filegroup referencing the latest released version of the API
and removed API specification files the dist_stem property is also
used in constructing the name of those filegroups.

Bug: 173715943
Test: lunch sdk-eng && m dist sdk
      Compare the results of the above before and after the change to
      ensure that this change does not affect the contents of the dist.
      See the topic's other change in external/conscrypt for testing
      the behavior of this new property.
Change-Id: Ie81345021991ff91ca55fec15b02627135293308
2020-11-20 22:43:21 +00:00
Paul Duffin
05c2f3e29a Merge "java_sdk_library: Stop disabling copy to dist when sdk_version: none" 2020-11-20 12:48:11 +00:00
Paul Duffin
de6df73b44 Merge "java_sdk_library: Allow no_dist to be explicitly set in .bp file" 2020-11-20 12:47:43 +00:00
Paul Duffin
defa9403a3 Merge "java_sdk_library: Remove unused SetNoDist method" 2020-11-20 10:02:13 +00:00
Paul Duffin
3aef8d2c1f java_sdk_library: Stop disabling copy to dist when sdk_version: none
Previously, setting "sdk_version: none" would have a side effect of
disabling copying to dist by default. This change removes that behavior
and will copy to dist by default unless explicitly specified.

This will have no impact on the dist because all java_sdk_library
modules that relied on the previous behavior to disable copying to
dist have been modified to explicitly disable copying to dist.

Test: lunch sdk-eng && m dist sdk
      compare out/dist/apistubs directories before and after this
      change to make sure that they have not changed.
Bug: 173715943
Change-Id: I376546b5a8b03de6c944961f7408dad22184fe49
2020-11-19 19:28:10 +00:00
Paul Duffin
4f5c1ef229 java_sdk_library: Allow no_dist to be explicitly set in .bp file
Currently, the no_dist property cannot be set in a .bp file and
defaults to true if the sdk_version property is set to none. That
behavior was added to prevent the output files from the libcore,
conscrypt and icu java_sdk_library modules from being copied to the
dist. It worked because they were the only java_sdk_library modules to
set "sdk_version: none".

Unfortunately, that default behavior is no longer required because
we want to be able to convert "conscrypt" module to a java_sdk_library
and have its public API output files be copied to the dist
automatically. This change allows the no_dist property to be explicitly
set in the .bp file so that those modules that rely on the implicit
behavior can explicitly specify it and allow the default behavior to
be removed.

This change:
* Removes the `blueprint:"mutated"` tag from the No_dist property which
  allows it to be specified in a .bp file.
* Only sets the default if the property has not been explicitly
  specified in a .bp file.

Test: lunch sdk-eng && m dist sdk
      compare out/dist/apistubs directories before and after this
      change to make sure that they have not changed.
Bug: 173715943
Change-Id: I8a1c97b690ae05bfe71ea72acc0831fa51aca7e9
2020-11-19 19:28:10 +00:00
Paul Duffin
e3ecd6c7a8 java_sdk_library: Remove unused SetNoDist method
This method was added for use in sysprop_library.go but it is no longer
used there. So, this change removes it.

Bug: 173715943
Test: m nothing
Change-Id: I0c2ae8a8d515faf2692eca2aaed63475fdb6a196
2020-11-19 19:28:05 +00:00