Commit graph

787 commits

Author SHA1 Message Date
Jiakai Zhang
519c5c82e5 Revert^2 "Preopt APEX system server jars."
This reverts commit 92346c4832.

Reason for revert: Fixed build error.

The build error is fixed by ag/15841934. This CL remains unchanged. This
CL will be submitted AFTER ag/15841934 is submitted.

Bug: 200024131
Test: 1. Patch this CL and ag/15841934 into internal master.
  2. sudo vendor/google/build/build_test.bash

Change-Id: I5f2b8357846fc7dda56e25ebe6ffb095e8047ec8
2021-09-16 06:25:26 +00:00
Adrian Roos
92346c4832 Revert "Preopt APEX system server jars."
This reverts commit ca9bc98e0c.

Reason for revert: breaks build
Bug: 200024131

Change-Id: Ide07b4c4d267370ae31107b1598b2f878c701282
2021-09-15 14:11:07 +00:00
Jiakai Zhang
ca9bc98e0c Preopt APEX system server jars.
The path to the artifacts will in the form of
/system/framework/oat/<arch>/<encoded-jar-path>@classes.{odex,vdex,art},
where <encoded-jar-path> is the path to the jar file with "/" replaced
by "@". For example,
/system/framework/oat/x86_64/apex@com.android.art@javalib@service-art.jar@classes.odex

There will be a follow-up CL to update ART runtime to recognize
artifacts in that path.

Test: m com.android.art
Bug: 194150908
Change-Id: Ic89fd63c4b1cd565684cead83fc91dae3bc97a4c
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
Ulya Trafimovich
0b1c70efbc Don't add uses_libs/optional_uses_libs to the manifest_fixer.
These properties specify libraries that cannot be implicitly inferred by
Soong. If these properties are added to Android.bp, this can only be for
the reason that there is a <uses-library> tag in the manifest which is
unknown to the build system. Adding them to the manifest_fixer doesn't
make sense: if they are not in the manifest, they should be removed from
Android.bp as well.

Bug: 132357300
Test: $ lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd
      $ adb wait-for-device && adb root && adb logcat \
        | grep -E 'ClassLoaderContext [a-z ]+ mismatch'
        # empty grep output, no errors
Change-Id: Ic6eb5268a954ef3be7f06a181ec72af99000c547
2021-08-20 15:54:42 +01:00
Ulya Trafimovich
e4432874a9 Propagate <uses-library> dependencies from java_library to apps.
Automatically add `uses_libs`/`optional_uses_libs` properties specified
in `java_library` modules to the apps that transitively depend on these
libraries.

Note that a library may choose to specify its <uses-library> deps as
either optional or required. If this is not the right choice for an app,
it should be able to override it by specifying its own `uses_libs`/
`optional_uses_libs` properties.

Add Soong tests to cover the new cases.

Bug: 196377222
Test: lunch aosp_cf_x86_64_phone-userdebug && m
Change-Id: I601f3e2830ed9699b78d911966ee70812d32b4f6
2021-08-18 16:57:11 +01:00
Ulya Trafimovich
fc0f6e34ce Fix the way manifest fixer detects optional <uses-library> entries.
Previously manifest_fixer used a naive way to distiniguish optional libs
from required ones: it checked if a library is on the list of optional
compatibility libraries. This works for compatibility libs, but not for
other libs.

Now we properly track optionality through all stages of the build,
starting with the addition of the library as a dependency (here's where
the `uses_libs`/`optional_uses_libs` distinction kicks in), store it in
dependency tag and propagate to class loader context, and from there to
the manifest_fixer.

The tests have been updated accordingly.

Bug: 196377222
Test: lunch bertha_x86_64-userdebug && m droid dist cts mts
Change-Id: I3631ce59ebe47116ce7a9b3d33a86f636846ef0f
2021-08-13 16:10:42 +01:00
satayev
d604b210c4 Rename UpdatableBootJars to ApexBootJars.
Note that ART apex boot jars and core-icu4j are exceptions here as they
are not part of ApexBootJars. ART apex boot jars are defined in their
own variable, while core-icu4j is treated as a regular non-updatable
boot jar.

Bug: 191127295
Test: atest CtsClasspathsTestCases
Change-Id: I3cea3d82ef521655a1a5ffa8cae2258ab9d08bfc
2021-07-22 17:35:42 +01:00
Treehugger Robot
52cc87959b Merge "Revert "Export implementation class jars for java_boot_libs"" 2021-07-19 09:49:17 +00:00
Paul Duffin
5c21145915 Revert "Export implementation class jars for java_boot_libs"
This reverts commit 22ff0aaf51.

The workaround to support hidden API generation with prebuilts by
passing the full implementation jars through to the SDK snapshot is no
longer needed as the monolithic hidden API flag generation uses the
prebuilt flag files that are already part of the snapshot.

This change reverts that previous workaround.

Bug: 192868581
Test: - Update the prebuilts
      DIST_DIR=$PWD/dist TARGET_BUILD_VARIANT=userdebug art/build/build-art-module.sh --skip-apex
      packages/modules/ArtPrebuilt/update-art-module-prebuilts.py --local-dist=dist --skip-cls --skip-apex
      - Build hidden API flags to make sure it does not fail
Change-Id: Idb3fde6f7dcb171677316d8794a4af91ede1f7e0
2021-07-16 17:04:21 +01:00
Ulyana Trafimovich
fe261473b8 Merge "Don't attempt to add stub libraries to class loader context." 2021-07-16 15:45:19 +00:00
Ulya Trafimovich
840efb6661 Don't attempt to add stub libraries to class loader context.
A Java module may depend on a stub library. In that case an additional
dependency on the implementation library is created, and it is used to
add the implementation library to class loader context. We should not
attempt to add the stubs library as well (previously the attempt to add
it happend after the implemention was added to CLC, to the attempt was
unsuccessful).

Raise an error if someone tries to add the same library with different
build/instal paths.

Also, rename local variable `implicitSdkLib` to `sdkLib` to better
reflect its meaning.

Bug: 193425964

Test: $ lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd
      $ adb wait-for-device && \
        adb root && \
        adb logcat | \
        grep -E 'ClassLoaderContext [a-z ]+ mismatch' -C1
      # empty output, no errors
Change-Id: I01c1bdd23f9d118d891d0b806e7e3b4d78896a34
2021-07-16 14:44:18 +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
Ulyana Trafimovich
7beb099546 Merge "Drop strings.HasPrefix when guarding strings.TrimPrefix." 2021-07-15 10:15:26 +00:00
Ulya Trafimovich
497a09310b Drop strings.HasPrefix when guarding strings.TrimPrefix.
There is no need to check as `TrimPrefix` does nothing if the prefix
doesn't match (see https://pkg.go.dev/strings#TrimPrefix).

Bug: 193425964
Test: m nothing
Change-Id: Ieb82e72a471800e29eb6bb54308041a9ab4173e5
2021-07-15 08:30:27 +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
Jooyung Han
91913e3e07 Merge "fix: comparison between min_sdk_version" 2021-06-23 17:02:02 +00: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
Jooyung Han
4c4da0688c fix: comparison between min_sdk_version
Added test demonstrates the error case. The bug was that java modules'
ShouldSupportSdkVersion() converts min_sdk_version into effective
version before comparison, which discards "preview" version into
"future" version. That caused a weird case like rejecting with error
"should support "S"" even when it is set to "S".

Bug: n/a
Test: m nothing
Change-Id: Ieb53f0097b2969a8535778b1286dbfa0d4895ad4
2021-06-23 10:45:28 +09: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
Martin Stjernholm
0e4ccebb16 Don't fail if the target module is disabled in dex2oat tool
dependencies.

dexpreopt.RegisterToolDeps runs late after prebuilt dependencies have
been resolved, and there's special code in dex2oatPathFromDep to
resolve the prebuilt from the source module. However, if the source
module is disabled then the dependencies check in validateAndroidModule
will complain, so we need to disable that check in this particular
situation.

Also add a comment to explain why dexpreopt.RegisterToolDeps needs to
run so late.

Test: m nothing
Bug: 145934348
Bug: 172480615
Change-Id: Ibc673303d0336768fa23261a2068e91a08f46a30
2021-05-18 21:58:38 +01: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
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
820ed78954 Merge "Add missing calls to InitSdkAwareModule" 2021-05-07 12:15:16 +00:00
Paul Duffin
b17d044628 Transitively add APEX variants for contents of prebuilt_apex/apex_set
This is part of the work needed to allow the exported_java_libs
property to be replaced by exported_bootclasspath_fragments.

Bug: 187266082
Test: m nothing
      m SOONG_CONFIG_art_module_source_build=false nothing
Change-Id: I2c1d70a390200b93163f9799719290c9d55a041c
2021-05-06 23:43:43 +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
2da0424b19 Extract java SdkMemberType instances as vars
This will allow them to be used from elsewhere in a follow up change.

Bug: 177892522
Test: m nothing
Change-Id: I60e94e148af5b1810aea7f724cba090b49ae758e
2021-04-26 21:21:58 +01:00
Colin Cross
f8d9c499d4 Reland: Add jni_libs property to java tests
Add jni_libs property to java tests and treat it as test data that
should be copied to the lib or lib64 directory in the test directory.

This relands I3a118b933ab30dcd731c6dc2708da9bc63ab5520 with fixes for
the test on mac.

Fixes: 176593487
Test: java_test.go
Change-Id: I2f8c46643cff7a7ae6dc4d4dbad58f0396e45f09
2021-04-19 10:57:55 -07:00
Colin Cross
de1b891690 Merge "Revert "Add jni_libs property to java tests"" 2021-04-17 05:17:45 +00:00
Colin Cross
26616d4cfd Revert "Add jni_libs property to java tests"
This reverts commit 246164a055.

Reason for revert: broke the mac build
Bug: 176593487

Change-Id: Id0242e37aa40d84d291bf7b8ee46dfe98c4d5905
2021-04-17 05:17:03 +00:00
Treehugger Robot
aef14db78a Merge changes from topic "tvts-test-host-jni"
* changes:
  Add jni_libs property to java tests
  Add Target to cc.SharedLibraryInfo
2021-04-17 04:35:24 +00:00
Colin Cross
246164a055 Add jni_libs property to java tests
Add jni_libs property to java tests and treat it as test data that
should be copied to the lib or lib64 directory in the test directory.

Fixes: 176593487
Test: java_test.go
Change-Id: I3a118b933ab30dcd731c6dc2708da9bc63ab5520
2021-04-16 21:59:23 +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
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
d0afefa4b1 Merge "Revert "Revert "Add min_sdk_version to java_import.""" 2021-04-02 15:49:58 +00:00
Jaewoong Jung
56e12dbbaf Revert "Revert "Add min_sdk_version to java_import.""
This reverts commit 5ab6508008.

Reason for revert: Resubmitting Ie255f74d40432f4bdd0092d618705a7d17235e58 after fixing the broken targets.

Bug: 183695497
Test: https://android-build.googleplex.com/builds/forrest/run/L58600000849810513
Change-Id: I5f072f396002ca3a45bd530ad9be987efa732833
2021-04-02 04:55:27 +00:00
Julien Desprez
cb05715e9e Merge "Remove tradefed static_lib heuristic" 2021-04-02 03:47:13 +00:00
Jaewoong Jung
37a5d5ebd8 Merge "Revert "Add min_sdk_version to java_import."" 2021-04-02 00:34:06 +00:00
Jaewoong Jung
5ab6508008 Revert "Add min_sdk_version to java_import."
This reverts commit 6d15d63556.

Reason for revert: Broke git_sc-mainline-prod on test_suites_x86_64

Fixes: 184305592
Change-Id: I4b2e2675e0dd9e2e84966f545a52f45d5b731bab
2021-04-02 00:17:59 +00:00
Jaewoong Jung
51a0d85ebc Merge "Add min_sdk_version to java_import." 2021-04-01 19:45:53 +00:00
Jaewoong Jung
6d15d63556 Add min_sdk_version to java_import.
Fixes: 183695497
Test: apex_test.go
Change-Id: Ie255f74d40432f4bdd0092d618705a7d17235e58
2021-03-31 16:50:42 -07:00
Paul Duffin
535e0a105e Remove unused java testing methods
Also, stops exporting methods that are no longer used outside the java
package.

Bug: 181070625
Test: m nothing
Change-Id: I23d35bbc21f82f2dae802aa53badda4c58b41024
2021-03-31 16:20:12 +01:00
Jaewoong Jung
263426431a Take Module implementations out of java/java.go.
Test: TreeHugger
Change-Id: I5c39915ad2cadf5981c201a2b412916524d4c3e2
2021-03-19 15:46:38 -07:00
Yuexi Ma
b96a04ba49 Merge "Export a few utility methods" 2021-03-17 01:40:51 +00:00