Commit graph

24 commits

Author SHA1 Message Date
Colin Cross
6db4d4e613 Optimize CPU time when running d8 and r8
Pass -XX:+TieredCompilation -XX:TieredStopAtLevel=1 to the JVM to
reduce the time spent JITing, which in local experiments reduced
the CPU time of R8 while increasing the wall time, and reduced the
total number of runnable threads.

Without the new flags:
$ time out/soong/host/linux-x86/bin/r8-compat-proguard -injars out/target/common/obj/APPS/Dialer_intermediates/classes.jar ...
real	0m30.090s
user	4m35.337s
sys	0m12.853s

With the new flags:
$ time out/soong/host/linux-x86/bin/r8-compat-proguard -JXX:+TieredCompilation -JXX:TieredStopAtLevel=1 -injars out/target/common/obj/APPS/Dialer_intermediates/classes.jar ...
real	0m35.674s
user	2m45.135s
sys	0m9.531s

The increase in wall time should be offset by the better parallelism from
the reduced CPU time.

Bug: 119270658
Test: m checkbuild
Change-Id: I8fc78b5ef1f8c6f51fd97a29461b96ae2b35cada
2019-03-01 15:28:19 +00:00
Sasha Smundak
d3cf4ee87b soong_zip after dex should not fail when no *.dex files were generated
This can happen if Android application has only a manifest file and no
java code.

Fixes: 124483155
Test: treehugger with Android.mk converted to Android.bp in
platforms/frameworks/base/tests/privapp-permnissions

Change-Id: I45f95680b62a7a4bda0e7ab156f3df24b0dad70b
2019-02-15 10:14:23 -08:00
Nicolas Geoffray
65fd8ba2fe Always do zipalign with uncompressDex.
Also preserve the alignment with hiddenapi.

Test: conscrypt apex has its conscrypt.jar zipaligned.
Change-Id: I43cc0eadb9548c3d8055e12c077fb7bbe1935fe6
2019-01-23 06:36:48 +00:00
Colin Cross
afbb1734f6 Pass annotation processors to kotlinc
Enable the kotlin-annotation-processing plugin and pass annotation
processors to it.

Bug: 122251693
Test: m checkbuild
Test: TestKapt in kotlin_test.go
Change-Id: I841df454beaaa7edd263eea714ca0d958a03c9de
2019-01-22 21:47:19 +00:00
Jaewoong Jung
1d6eb68731 Use debug mode when running R8 for eng builds.
Bug: 119601874
Test: Built for different variants.
Change-Id: I2250587eb3e457ca15265eb9f8359872e9b08363
2018-11-30 15:23:16 +00:00
Colin Cross
5a0dcd5acf Store dex files uncompressed and unstripped in privileged APKs
Privileged APKs need to store their dex files uncompressed so they
can be verified and mapped directly out of the APK.

Also track whether the module will be dexpreopted or not in order
to determine if the dex file should be stripped before signing.

Test: SystemUI.apk contains an uncompressed dex file
Change-Id: I4dca86c7f8778595882405b34adcf2a7bae03c67
2018-10-25 17:47:12 +00:00
Colin Cross
4b964c00a6 Fix instrumentation_for to match LOCAL_INSTRUMENTATION_FOR
The value from instrumentation_for should not go to
aapt2 link --rename-instrumentation-target-package, that should
be the equivalent of LOCAL_MANIFEST_INSTRUMENTATION_FOR.  That
property is never used in Make, so it is left unimplemented in
Soong.

Add the module listed in instrumentation_for as a shared library
for javac, but don't import its resources.

Bug: 117804211
Test: m checkbuild
Change-Id: I7f035dc0ecb964a3ca391ae1ca2b87cb0f6a7cec
2018-10-18 23:54:38 +00:00
Colin Cross
791399f1fd Use file glob for zipping classes*.dex files
Using a directory to zip the output of d8 and r8 was causing the
empty classes.dex.jar file in the output directory to get
zipped in.  Use a file glob instead so that it only picks up the
classes*.dex files even if classes.dex.jar already exists.

Test: m checkbuild
Change-Id: I1f3c1cbc23439fc52756aad027ab8cac10213d1d
2018-09-28 16:14:58 -07:00
Colin Cross
6dab9bd57a Add dependencies on d8 and r8 library arguments
d8 and r8 were missing dependencies on jars passed as library
arguments.  This normally worked because the input jar is likely
to also depend on the same jars.  When the classpath was added
to d8 it started to fail on libraries that have no code but
include other static libraries.

Bug: 116840360
Test: rm out/soong/.intermediates/external/nist-sip/nist-sip/android_common/turbine-combined/nist-sip.jar && m out/soong/.intermediates/frameworks/base/ext/android_common/dex/ext.jar
Change-Id: Ie642f4a343b949778d8ee6dcc4511f3fd7633be1
2018-09-28 15:15:08 +00:00
Colin Cross
ffb657ebc0 Pass classpath to d8
d8 requires the full classpath if --min-api requires default method
or try-with-resources desugaring.  Always pass the full classpath,
since it will already have been built to generate the input jar.

Bug: 116243313
Test: m checkbuild
Change-Id: Ib0c18873880697b7cf942e0548dd2c53ee5ad23c
2018-09-27 11:05:09 -07:00
Søren Gjesse
24f1702872 Don't include data resources when running R8
The change https://r8-review.googlesource.com/c/r8/+/26482 made R8
process data resources by default. This is not expected for the
Android Platform build

Test: m -j PRODUCT-aosp_x86-userdebug core-oj
Change-Id: Idb17e39dae524dacf4b258c9f27be86e3179667f
2018-09-14 15:20:42 +02:00
Søren Gjesse
0e84935ac4 Ensure that the R8 minification map (ProGuard dictionary) file exists
R8 no longer outputs an empty map file when minification
(obfuscation) is turned off.

Test: m -j PRODUCT-aosp_x86-eng
Change-Id: I317e703597368dc8c16751bcc8d0e43f985614fa
2018-08-27 12:56:16 +02:00
Colin Cross
331a1213b0 Don't pass resources to r8
R8 complains when it gets dex files in the input jar, but some tests
use dex files or dex jars as resources.  Keep resources separate
from classes until after r8 has been run.

Test: java_test.go
Test: m checkbuild
Change-Id: I1d9164d60d6b054ebb138648da07d80ee769177f
2018-08-16 17:03:56 -07:00
Colin Cross
3063b78ea5 Make :module provide the output file for java modules
Make :module on a java_library provide the output file, which is
normally the implementation jar.  For java_library modules with
installable: true or compile_dex: true this will be the dexjar
instead.  For android_app modules this will be the apk.

Bug: 80144045
Test: no change to out/soong/build.ninja
Change-Id: I739674aee60a38bfccb859369e4414b46f293d82
2018-08-16 16:13:58 -07:00
Colin Cross
bd1cef5618 Add proguard_flags_files to r8 command line
We were not passing the proguard_flags_files files as -include
arguments to R8.

Bug: 112462307
Test: m checkbuild
Change-Id: I8f3b10fc338aa4b15c0fb220ee2891efbb0b020f
2018-08-13 17:29:58 +00:00
Colin Cross
4c03f68763 Make merge_zips -stripFile use blueprint style globs
merge_zips -stripFile was only considering the name of the file and
ignoring the path.  Make it more useful by supporting blueprint style
globs.  The previous behavior can be recreated by prefixing with **/.

Bug: 111389216
Test: m checkbuild
Change-Id: I25760fe3f1f77704dd9da9d107d9a38a415d681f
2018-07-16 15:24:43 -07:00
Colin Cross
83bb3167f6 Add support for min_sdk_version
Add min_sdk_version properties and use it for aapt2
--min-sdk-version and --target-sdk-version flags.  Add an sdkContext
interface that any function that needs an sdk version can take in
order to get the values for the current module.

Bug: 110848854
Test: m checkbuild
Change-Id: Ic69f1f935d8b865ec77689350407df08bfac5925
2018-07-09 12:42:01 -07:00
Colin Cross
bafb897de7 Revert "Revert "Remove desugar support""
This reverts commit 7576916efc.

Reason for revert: includes art veridex fix this time

Change-Id: Ia8da00b5ec8ed3dc3ce2a2521f0a7b2b2b131960
2018-06-06 21:46:32 +00:00
Colin Cross
7576916efc Revert "Remove desugar support"
This reverts commit 000280bb0e.

Reason for revert: broke art veridex build

Change-Id: I9f7d7cdbe8e34671614687ac0b34c0338ef240e7
2018-06-06 21:42:39 +00:00
Colin Cross
000280bb0e Remove desugar support
Desugaring is always handled by d8 now.

Test: m checkbuild
Change-Id: I29e8f68e51b194a4090866acc63f19f0605e318d
2018-06-06 10:05:06 -07:00
Colin Cross
c0c664cd56 Declare proguard_dictionary as implicit output of r8
Soong was generating proguard_dictionary, but not marking it as an
output, so ninja would fail with:
ninja: error: 'out/soong/.intermediates/bootable/recovery/tools/recovery_l10n/RecoveryLocalizer/android_common/proguard_dictionary', needed by 'out/target/common/obj/APPS/RecoveryLocalizer_intermediates/proguard_dictionary', missing and no known rule to make it

Fixes: 78770148
Test: mmma bootable/recovery/tools/recovery_l10n
Change-Id: I956f92519ea81d4fb1322114214099d46d734906
2018-05-17 03:46:09 +00:00
Colin Cross
3144dfc966 Add EMMA_INSTRUMENT_STATIC support
Add jacocoagent when instrumenting with EMMA_INSTRUMENT_STATIC.

Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_STATIC=true
Change-Id: I451bb9d16b7f0a66fd06c2da576062b28830e470
2018-01-04 14:52:45 -08:00
Colin Cross
66dbc0bc32 Add R8 support
Add support for R8 to optimize apps and java libraries.

Test: m checkbuild
Change-Id: I2afd5d7a84912d3ab613c32c599bd1ebe60562e0
2018-01-03 14:15:57 -08:00
Colin Cross
f0056cb2ed Refactor dexing
Move dexing support into java/dex.go, including the rules and logic
from builder.go and the function from java.go.

Test: no change to build.ninja
Change-Id: I098d2a9774e28079ba44791679a0db6f876fe3e6
2018-01-02 18:23:43 -08:00