Commit graph

397 commits

Author SHA1 Message Date
Nan Zhang
870025f89b Move classes.jar generation right below JarJar phase.
By doing this, we don't need run desugar/Jacoco/proguard twice for
static java libraries(one for their self build, another for downstream
dependents).

Test: m clean && m java
Bug: b/65455145
Change-Id: I87aee34940937dbde33a977f55d1faf2c8054561
2017-09-14 14:44:40 -07:00
Nan Zhang
b3ec534bd1 Revert "Revert "Add Turbine as part of java build toolchain in Make.""
This reverts commit 33dcd0c5eb.

Reason for revert: <stub.jar.toc needs classes.jar.toc which is no longer existed after Turbine was introduced. So use classes.jar to represent stub.jar.toc>

Bug: b/64308460
Test: m clean && time m -j32 ANDROID_COMPILE_WITH_JACK=true
Change-Id: If618993f1e0c789d93cc15664212603f994fd460
2017-08-31 14:56:54 -07:00
Colin Cross
9a594e05af Remove GLOBAL_JAVAC_DEBUG_FLAGS
GLOBAL_JAVAC_DEBUG_FLAGS is no longer set, -g is already included
in the javac command line.  Jack is on its way out, just use -g
directly there for now.

Test: m -j checkbuild
Change-Id: Ib99c248bbb8b65fa2cd2b55449a502fc20deffa8
2017-08-31 14:48:31 -07:00
Nan Zhang
33dcd0c5eb Revert "Add Turbine as part of java build toolchain in Make."
This reverts commit 0739155c86.

Reason for revert: <sdk_google_aw_x86-sdk (linux) build 4310016 in git_master is broken>

Change-Id: I525d48557bd0425917e61a85f596663ccc63c887
2017-08-31 19:56:59 +00:00
Nan Zhang
0739155c86 Add Turbine as part of java build toolchain in Make.
1. Bundle static_java_header_libs during turbine-classes.jar if
necessary. This can be improved if we have the ability to merge jars on
the fly.

2. Copy sdk/stubs-classes.jar to sdk/stubs-classes-header.jar, and Use
.KATI_RESTAT to cut un-necessary targets rebuilt.

3. Copy prebuilt-classes.jar to prebuilt-classes-header.jar since
Turbine doesn't apply to prebuilt.

4. Run jarjar after Turbine compilation, otherwise downstream targets
won't find corresponding symbols.

5. Change classes.jar in -classpath used in Desugar to
classes-header.jar.

6. Change legacy-libs in Proguard from classes.jar to
classes-header.jar.

7. Add .KATI_RESTAT for turbine-classes.jar, and remove IJAR.

8.boot.art is re-generated during the incremental rebuild since
javalib.jar got re-generated. Then boot.art re-triggered lots of
downstream targets to be rebuilt. So we add .KATI_RESTAT for javalib.jar
to prevent downstream to be rebuilt. The ziptime & commit-change-to-toc
operation for javalib.jar(small) didn't bring too much overhead when we build
from clean state.

Next step: specify static_java_header_libs in -classpath, and merge jars
at the end.

touch frameworks/base/core/java/com/google/android/util/Procedure.java &&
time m
time: 1m58s (794 -> 49 targets)

m clean && time m java
time: 9m34s

Bug: b/64308460

Test: m clean && m checkbuild

Change-Id: Iefcc234405b9f461b6882c06bba15e21fa783d28
2017-08-30 16:01:39 -07:00
Colin Cross
dfc45ec337 Separate java source list generation into its own rule
Move the java source list generation step into its own rule.  This
has a couple of advantages.  It consolidates the source list
generation so that it only has to run once for javac, jack, and
jack-check.  It also massively reduces the length of the javac
command line, so that error messages are significantly shorter,
and allows easily rerunning the failing build command because
the file list is still on disk.

The primary disadvantage is that javac error messages no longer
include the list of files passed to javac, but the list is
available earlier in the build long when the file list was written,
and is still available on disk.

Test: m -j javac-check
Change-Id: I9730b352b33a060e08221b61c11c617d23320d67
2017-08-29 16:50:11 -07:00
Colin Cross
604a2423b6 Merge "Sort files in directories passed to jar"
am: 966ed15a1d

Change-Id: If01ba7d294e4308a28580b157b9efdb6c860bb35
2017-08-17 01:00:13 +00:00
Colin Cross
128800f2c8 Sort files in directories passed to jar
jar -C <dir> . produces a jar containing files in filesystem order,
which can vary between builds.  Manually find and sort the list of
files, and convert them into a list of -C <dir> <file> pairs.

Fixes: 64634025
Test: m -j checkbuild
Test: m -j out/target/product/sailfish/system/framework/ext.jar, check
      that entries are sorted
Test: m -j out/target/product/generic_arm64/system/framework/ext.jar on mac
Change-Id: I7dced6acbe621a60cd49daf17872941485602732
2017-08-16 13:37:00 -07:00
Colin Cross
4cea760106 Merge "Revert "Use dx.jar directly""
am: c7e3e962f8

Change-Id: Icd5402f7cc789224753537c070a91cbf6267ee66
2017-07-18 07:14:26 +00:00
Treehugger Robot
c7e3e962f8 Merge "Revert "Use dx.jar directly"" 2017-07-18 07:08:19 +00:00
Colin Cross
e44e75aa89 Revert "Use dx.jar directly"
This reverts commit e37a3c959a.

Reason for revert: breaks art test runner

Change-Id: Ice0cd3020ddec7f31eb789867a45f047a75a05d0
2017-07-18 05:22:59 +00:00
Colin Cross
4828fcad41 Merge "Use dx.jar directly"
am: c68434c971

Change-Id: Ief2c88d3ba0e93c7eb7bb9db0ac2b0a0b886bcea
2017-07-17 20:45:31 +00:00
Jeff Gaston
6264b662f3 Merge "Update to latest jacoco usage"
am: 483fae7430

Change-Id: Ibc94d5ba6db7690441825dd655b6cb26d989b78d
2017-07-17 20:44:10 +00:00
Colin Cross
c68434c971 Merge "Use dx.jar directly" 2017-07-17 20:40:13 +00:00
Jeff Gaston
483fae7430 Merge "Update to latest jacoco usage" 2017-07-17 20:36:39 +00:00
Colin Cross
06f8dec6e0 Merge "Fix LOCAL_JAR_PROCESSOR dependency"
am: 126e625fed

Change-Id: Ibe2786aa8853ea34513903728ae06fb5c5c39101
2017-07-14 23:10:57 +00:00
Jeff Gaston
aaae43cd24 Update to latest jacoco usage
Bug: 36792868
Test: EMMA_INSTRUMENT_STATIC=true m -j

Change-Id: I419b543283b52be9a72f5c6b10e4cbea68782174
2017-07-14 13:04:05 -07:00
Colin Cross
89b802b994 Fix LOCAL_JAR_PROCESSOR dependency
The LOCAL_JAR_PROCESSOR rule should depend on the path to the
processor jar and not the module name.

Test: m -j && m -j
Change-Id: I5ebd4cd3ad4429918edfd0a8cb5cb9a4e7e86ca7
2017-07-13 19:25:47 -07:00
Colin Cross
e37a3c959a Use dx.jar directly
Use $(JAVA) to invoke dx.jar instead of the dx wrapper script.
Also allow the dx command line or the dx jar to be specified on
the command line.  Allows better dependencies on dx.jar, and
doesn't rely on having java on the path.

Bug: 62956999
Test: m -j checkbuild
Change-Id: I5f265132690ad28b3139954fea44eb0c4a43393a
2017-07-07 13:34:33 -07:00
Przemyslaw Szczepaniak
8c485b6b0c Merge "Enable stripping of java debug information when required."
am: d659f806e5

Change-Id: I25facf64b176ae26db07d43cef92c522bf92e79a
2017-07-07 15:29:40 +00:00
Treehugger Robot
d659f806e5 Merge "Enable stripping of java debug information when required." 2017-07-07 15:24:32 +00:00
Przemyslaw Szczepaniak
2e81b3c49f Enable stripping of java debug information when required.
We're removing LocalVariableType / LocalVariableType in order to
save space. Enabling stripping reduces AOSP  image size save
by ~12MB.

Bug: 38224820
Test: CtsLibcoreTestCases
Change-Id: I3168d73ec6825aa5879db7e1135d7ed61d488d72
2017-07-06 08:31:14 +00:00
Colin Cross
e885ccf0df Merge "Provide make variables for java binaries"
am: 5e19557eb9

Change-Id: Ib1be7da98214e3b6c27867b80005e18cc68a0d33
2017-07-01 01:36:14 +00:00
Colin Cross
0851df8c82 Provide make variables for java binaries
Replace java -> $(JAVA), etc. to prepare for moving java binaries
out of the path and using full paths to them.

Test: builds
Bug: 62956999
Change-Id: I5dfcd0d4e855ecde69cd127169e9545e59723d12
2017-07-01 01:03:14 +00:00
Paul Duffin
b61544dd73 Merge "Add junit/textui/** to the proguard filter" am: 3b3bffc0d0
am: 5022a346c7

Change-Id: I5ba99c3e20a0aeee1c8a6c5bd6119a1615112cb5
2017-06-15 09:12:50 +00:00
Paul Duffin
54747a7f09 Add junit/textui/** to the proguard filter
Fixes build breakage caused by having duplicate versions of
a class in the application and in the API. This workaround will
be removed once junit classes have been removed from the API.

Bug: 30188076
Test: make Browser2 ANDROID_FORCE_JACK_ENABLED=disabled
Change-Id: I9a9031d3ef6d82f35413b229d588a605f9ed39dc
2017-06-15 08:42:23 +01:00
Colin Cross
a1b843c2b6 Merge "Add LOCAL_JAR_PROCESSOR" am: 9f52f0d17d am: abcbe9ab86
am: dcc9240a71

Change-Id: I21ecc09b9f5678746b8bb02056583f10e90e71ee
2017-05-23 02:12:43 +00:00
Colin Cross
f8a49c5a37 Add LOCAL_JAR_PROCESSOR
Allow using a host java library as an intermediate processor step
after javac but before desugar, proguard, or dx.

Test: manual
Change-Id: I7fb843e10d96c0167f6e4371582fabcc1454521f
2017-05-22 17:30:13 -07:00
Paul Duffin
29cdd2d433 Merge "Add c/a/i/u/* to the list of injar filters" am: 9198da8c21 am: 23eb5019bc
am: c4977665f1

Change-Id: I5673a8604c4fbfe4efaedd750863d5a757e33977
2017-05-15 15:54:51 +00:00
Paul Duffin
e949585a62 Add c/a/i/u/* to the list of injar filters
Previous change that moved com.android.internal.util.Predicate
to the legacy-android-test JAR caused a proguard build breakage
due to duplicate classes in the application and library. This
fixes it in the same way as previous issues with junit and
android.test classes were resolved by excluding those classes
from the application JAR.

Bug: 30188076
Test: make checkbuild and make -j ANDROID_FORCE_JACK_ENABLED=disabled checkbuild
Change-Id: Ica0089607187f970251ddba339a1f71d4cad80cc
2017-05-15 15:17:55 +01:00
Colin Cross
5730186686 Merge "Make javac checkbuilds match jack" am: cb8077df16 am: 9f1e58aab9
am: 2e2758b69d

Change-Id: I7d62da41492c2a4aae39d5f29b9b6086be9f58e6
2017-05-02 23:10:30 +00:00
Colin Cross
761d673df4 Merge "Support LOCAL_JACK_ENABLED := javac_frontend" am: 64ed2f2478 am: d6a3273faa
am: eb2457b89e

Change-Id: I98104d161dcc709a764cb86750d3217538863fdb
2017-05-02 18:15:12 +00:00
Colin Cross
9eff830fa2 Make javac checkbuilds match jack
Building all java to dex is very slow.  Make javac checkbuilds act
like jack checkbuilds and only build to class files for unused
modules, and add a java-dex target that can be used to build
everything to dex.

Test: m -j checkbuild
Change-Id: Idcf9c9e0223b9dd88aaa53beb0cb50a230034b0f
2017-04-28 13:39:16 -07:00
Colin Cross
b17f285169 Support LOCAL_JACK_ENABLED := javac_frontend
Allow working around Jack bugs by using javac to compile *.java
to class files, and then pass through Jack for desugaring,
proguarding, and dexing.

Also make ANDROID_COMPILE_WITH_JACK=false override LOCAL_JACK_ENABLED.

Bug: 37483961
Test: m -j checkbuild
Test: Add LOCAL_JACK_ENABLED := javac_frontend to a target
Change-Id: I2189055aac9deccc36b8eab8e949796dddadf7a1
2017-04-28 13:39:12 -07:00
Colin Cross
bb7ba04031 Merge "Filter and colorize javac output V3" am: c8387929d1 am: f4ef1db272
am: 2f1488ae86

Change-Id: I73b5ca7a919c299aa062e5814f9f6b165f8c6527
2017-04-18 23:13:27 +00:00
Colin Cross
5f89212e24 Filter and colorize javac output V3
Add soong_javac_wrapper to all javac commands. soong_javac_wrapper
colorizes javac output, and hides noisy messages.

Previously attempted in I7e8fcd2e4e1ed3ff530a8ccfe931ceb7e411e0ad
and I449a61ed2c95b3e1afd51a31a11baab15d97e2f2.

Test: m -j ANDROID_COMPILE_WITH_JACK=false
Change-Id: I9d7a20d766fadab323a4cf95e5734741b3f578bb
2017-04-18 21:04:58 +00:00
Colin Cross
e8ee68bb9b Support java annotation proccessors
The codebase is growing more uses of annotation processors,
through a mixture of LOCAL_ADDITIONAL_DEPENDENCIES and
LOCAL_JACK_FLAGS.  Add LOCAL_ANNOTATION_PROCESSORS and handle
the rest in the build system.

For now we also need LOCAL_ANNOTATION_PROCESSOR_CLASSES to
work around bad behavior in grok (b/25860419).

Test: m -j java
Change-Id: I465b021e65d25ed3ea517333a82ec4ebd63fc038
(cherry picked from commit cde14987ba)
2017-04-11 12:22:53 -07:00
Colin Cross
cde14987ba Support java annotation proccessors
The codebase is growing more uses of annotation processors,
through a mixture of LOCAL_ADDITIONAL_DEPENDENCIES and
LOCAL_JACK_FLAGS.  Add LOCAL_ANNOTATION_PROCESSORS and handle
the rest in the build system.

For now we also need LOCAL_ANNOTATION_PROCESSOR_CLASSES to
work around bad behavior in grok (b/25860419).

Test: m -j java
Change-Id: I465b021e65d25ed3ea517333a82ec4ebd63fc038
2017-04-11 09:56:09 -07:00
Colin Cross
5e58793731 Add support for LOCAL_ERROR_PRONE_FLAGS
This will allow individual modules to enable error prone checks
as needed so that the change to treat an error prone check as a
compiler error can be done atomically with the changes to fix
the issues that check reveals.

Tested with the following steps, cleaning up the targets in
between to ensure that it was rebuilt everytime.

Set LOCAL_ERROR_PRONE_FLAGS := -Xep:ClassCanBeStatic:WARN
compiler error in junit-params-test target. Built
javac-check-junit-params-test with RUN_ERROR_PRONE=true to make
sure that compilation failed.

Built the javac-check-junit-params-test without RUN_ERROR_PRONE
set to make sure that the flag is not included unless explicitly
requested.

Built the junit-params-test as normal to make sure it still
worked properly.

Bug: 31507496
Test: See above
Change-Id: I88b5800dacd0e30dd9dcfa5f42e89d1428957365
Merged-In: I88b5800dacd0e30dd9dcfa5f42e89d1428957365
(cherry picked from commit 3ca9298d99)
2017-04-07 17:46:40 -07:00
Colin Cross
5cc452de64 Merge "Fix duplicate and dangling rules" am: f9f8b21af3 am: 50d2ffdfe3
am: 348d20bcce

Change-Id: I495a6d0a8c733c942248e1d378c9f660e1cc7322
2017-04-06 20:07:31 +00:00
Colin Cross
96476c1d50 Fix duplicate and dangling rules
I6730e2d3ec38004874265b2a690442dec57b33f4 introduced duplicate rules
to build classes.jar for static java library prebuilts, and left rules
to copy $(built_dex_intermediates) to $(built_dex) for modules that
don't build dex files.

Move prebuilts LOCAL_BUILT_MODULE back to javalib.jar to match
non-prebuilt modules, and remove the manual building of javalib.jar.

Add a check around $(built_dex_intermediates) for static java libraries.

Bug: 36901093
Test: m -j ANDROID_COMPILE_WITH_JACK=false
Change-Id: I291510b56162f0d35553e3c7ccd59b1382224d62
2017-04-06 10:23:04 -07:00
Colin Cross
99c83f2bda Merge "Rearrange java library outputs" am: 7b7363fffb am: a4435a5025
am: 09018269a8

Change-Id: I35b5527c4142f9486c6d57498789ba2249d0a4a3
2017-04-06 15:52:26 +00:00
Colin Cross
1ed4235172 Merge "Move proguard before classes.jar" am: 41d5cd7420 am: c40073c77f
am: 6ade789f59

Change-Id: I9ac539f18a998c3a85960526a77cfdebef9ca641
2017-04-06 02:50:55 +00:00
Colin Cross
941b682099 Rearrange java library outputs
Jack can silently handle using a java library as a static java
library by merging in the java library dex file.  This causes
problems when switching to javac, because dex doesn't support
dex merging with multidex enabled?

Make the output files consistent between java libraries and static
java libraries.  Java libraries will now produce:
classes-pre-proguard.jar: the classes before proguard processing
classes.jar: the final jar file containing classes before dexing
javalib.jar: a jar containing classes.dex

Static java libraries will eventually only produce
classes-pre-proguard.jar and classes.jar.  All inter-library
linking is done with classes.jar, so a java library can be
used as a static java library.

There are too many dependencies outside the build system that
expect javalib.jar to exist for static and host java libraries,
so for now continue to build a javalib.jar that is a copy of
classes.jar.

Test: m -j ANDROID_COMPILE_WITH_JACK=false java
Test: m -j java
Bug: 36901093
Change-Id: I6730e2d3ec38004874265b2a690442dec57b33f4
2017-04-05 18:04:37 -07:00
Colin Cross
950f1efbbc Move proguard before classes.jar
Downstream users of a library always link against javalib.jar, which
is either the dex jar for java libraries or a copy of
proguard.classes.jar for static java libraries.  In preparation for
making java libraries a superset of static java libraries, make
classes.jar always be the final class-containing jar for use
downstream, and always create a classes-pre-proguard.jar for
users that need a jar without shrinking or obfuscation.

Also rename the intermediates to be consitent: classes-<tool>.jar

Test: m -j ANDROID_COMPILE_WITH_JACK=false java
Change-Id: I3df8b9a4edcd5db996f1fedc54c8a782d4f36a92
Merged-In: I3df8b9a4edcd5db996f1fedc54c8a782d4f36a92
(cherry picked from commit 6fabefa88e)
2017-04-06 00:46:23 +00:00
Colin Cross
d75f928450 Merge "Optimize out extra jar copies" am: 678c77d9af am: cad1043266
am: bc46ba1b98

Change-Id: I8f396b1b14cd0e5b4b5a436473c42b046ecfa527
2017-03-31 04:58:06 +00:00
Colin Cross
0e53734035 Optimize out extra jar copies
Don't copy jar files for disabled stages.  Instead, set the name of
the output to the name of the input so the next stage will directly
pick up the output of the previous stage.

Test: m -j ANDROID_COMPILE_WITH_JACK=false java
Change-Id: Ib7268cbff7ea7ff2ad2caf994aa145e1b7a12b83
2017-03-30 19:35:15 -07:00
Colin Cross
52573ac615 Merge "Revert "Revert "Revert "Add soong_javac_filter to all javac commands"""" am: df69a927d8 am: e088c648c7
am: af35fe9424

Change-Id: I067770d5129653c8502a5db020d963f1a0d8b43b
2017-03-30 01:06:21 +00:00
Treehugger Robot
df69a927d8 Merge "Revert "Revert "Revert "Add soong_javac_filter to all javac commands"""" 2017-03-30 00:53:06 +00:00
Colin Cross
fc8ead6609 Revert "Revert "Revert "Add soong_javac_filter to all javac commands"""
This reverts commit 440079b84b.

Adding the pipe interferes with error codes, which results
in an empty classes-full-debug.jar output file being left
after the failure.  The next build sees the output file with
an up-to-date timestamp and doesn't rerun the failing rule.

Bug: 36666657
Change-Id: I6658edb766d8ba3120f88e3d8d6eda6ea6c691da
2017-03-29 21:01:24 +00:00