Commit graph

90 commits

Author SHA1 Message Date
Ying Wang
e295c3df68 AAPT2: library resource compilation
- Switch to static library's package-res.apk as the link artifact.
- For prebuilt AAR file, build package-res.apk using aapt2's "--dir"
  option.
- New LOCAL variables:
  LOCAL_USE_AAPT2: a module can opt-in with "LOCAL_USE_AAPT2 := true".
  LOCAL_STATIC_ANDROID_LIBRARIES: static Java libraries with compiled
                   resources.
  LOCAL_SHARED_ANDROID_LIBRARIES: shared Java libraries with compiled
                   resources.

Bug: 25958912
Change-Id: I4be2d1e8137555986338c2583cb39b0c97391751
2016-02-26 10:44:56 -08:00
Sebastien Hertz
8192d3b821 Merge "Support code coverage with Jack" am: 4dad88980f
am: 7b02e64148

* commit '7b02e64148e6a1c0355d715b2a8034061f0d2837':
  Support code coverage with Jack
2016-02-02 09:13:57 +00:00
Sebastien Hertz
dfce8ad4f4 Support code coverage with Jack
Building an app with Jack and with the environment variable
EMMA_INSTRUMENT_STATIC set to true will apply code coverage
onto the app targeting Jacoco.

Bug: 20115492
Change-Id: Ief3640fa3faa466f7f6aaa9739e06d3db24110a0
2016-01-27 19:14:14 +01:00
Ying Wang
dd71c85a45 Support to build with AAPT2
To build with AAPT2, set "USE_AAPT2=true".
TODO: Support split apks and generated resources from other than renderscript.

Bug: 25958912
Change-Id: I19b1a038824ce5b2a3d3ffadbce3173c845193fc
2016-01-25 22:41:43 -08:00
Alex Klyubin
f29904e889 Merge "Do not run zipalign when building APK (except prebuilts)." am: b437f58006 am: fddfc2c604
am: 60d6e2eb00

* commit '60d6e2eb002b12c28c0f28527c020837adea9164':
  Do not run zipalign when building APK (except prebuilts).
2015-12-08 03:04:50 +00:00
Alex Klyubin
5b826ac609 Do not run zipalign when building APK (except prebuilts).
This changes the build system to no longer run zipalign except for
those prebuilts which do not need to re-signed.

Running zipalign is no longer needed because signapk takes care of
alignment. For those prebuilts which do not need to be re-signed
signapk is not invoked and thus zipalign is still needed because the
prebuilts may not have been aligned properly. This exemption will go
away once prebuilts are properly aligned.

Bug: 25794543
Change-Id: I31f10af80b9baa3c9481cb36f41e5e5046e852f9
2015-12-04 10:15:06 -08:00
Michael Wright
0fb087fc73 Add new Test API for CTS testing.
Bug: 25608286
Change-Id: I0334061b548970959e46392dc3a1feed8533548c
2015-11-25 11:38:44 +00:00
Ying Wang
3799a8a534 Merge "Tag "tests" alone doesn\'t prevent including emma.jar" am: a23a97e3bf am: 7c09c937b6
am: 1704a32d40

* commit '1704a32d40d181a659a25e2c69e51ef9b719f818':
  Tag "tests" alone doesn't prevent including emma.jar
2015-11-06 19:36:43 +00:00
Ying Wang
324ffb2785 Tag "tests" alone doesn't prevent including emma.jar
Only if an app has LOCAL_INSTRUMENTATION_FOR, it can get the emma
classes from the target app and we don't need to instrument the test app
itself.

Change-Id: If0fba50ddae757254fc58ca104d729d61603fd78
2015-11-06 11:22:28 -08:00
Ying Wang
62170e2004 Merge "Make sure R.stamp is always created" am: 47e46f7725 am: 3d7584d9c3
am: a34fb5fe34

* commit 'a34fb5fe3445bf6f185720a3f029da4d39268dc6':
  Make sure R.stamp is always created
2015-10-23 18:27:25 +00:00
Martin Arenlind
fb6985e4dc Make sure R.stamp is always created
When an app has a resource directory, but the
directory contain no resources, R.stamp is not created.

This leads to that such apps are always rebuilt,
even when there are no changes.

This patch changes so that an empty R.stamp is
created even if there are no resources.
This leads to that affected apps are not rebuilt
unless changed.

Change-Id: Ia63e5b1913a4456402700b615ba7f9d56d2da852
2015-10-23 11:07:28 -07:00
Ying Wang
9d8a062da0 Fix cts split apk testcase copy pattern rule.
Bug: 21762834
Change-Id: Ib8ff956685c898132a11de45a0d7cfdd1009f48c
2015-10-21 14:15:52 -07:00
Ying Wang
6c4176e2d0 am 8b4d1432: am cd7dfdb4: Merge "Cleanups."
* commit '8b4d1432395733db45e2dfaeee24fe44d3c49bbe':
  Cleanups.
2015-07-23 02:06:39 +00:00
Ying Wang
9e612d6d7c am 960424bc: am 8b4d1432: am cd7dfdb4: Merge "Cleanups."
* commit '960424bc31ae8072c300681c40bfeb1035e091d1':
  Cleanups.
2015-07-22 00:26:18 +00:00
Ying Wang
960424bc31 am 8b4d1432: am cd7dfdb4: Merge "Cleanups."
* commit '8b4d1432395733db45e2dfaeee24fe44d3c49bbe':
  Cleanups.
2015-07-22 00:12:18 +00:00
Ying Wang
8b4d143239 am cd7dfdb4: Merge "Cleanups."
* commit 'cd7dfdb4bf3f7d431d2a37908c550a83a282bf22':
  Cleanups.
2015-07-21 23:57:42 +00:00
Ying Wang
bbd4755647 Cleanups.
- Deleted unused functions in definitions.mk.
- lint is never fully functional in the platform source tree.
- Retire LOCAL_DIST_BUNDLED_BINARIES: now the build system/framework
  supports JNI embedded in apk.

Change-Id: I6314cb20d1544c704ccbc4c1f9cccb9c54fb5a51
2015-07-21 16:03:19 -07:00
Dimitry Ivanov
a66f8bae07 am 9c836723: am 72bced8a: Merge changes from topic \'prebuilt-open-from-apk\' into mnc-dev
* commit '9c836723b784a344442d4646fc849470b8fcd515':
  Uncompress .so files before signing the apk.
  Don't extract jni from prebuilt apks.
2015-06-04 20:33:25 +00:00
Ying Wang
1624361d84 Add support for LOCAL_COMPATIBILITY_SUITE
A module can specify itself to be a Compatibility Suite module with:
LOCAL_COMPATIBILITY_SUITE := <cts-name>
<cts-name> can be "cts" or any other cts name supported by the
build system.

The cts name's config.mk must define global variable
COMPATIBILITY_TESTCASES_OUT_<cts-name> to point to the testcase
output directory.
This change copies the module's built file, as well as the module's
AndroidTest.xml, to the testcase output directory.
The build system collects all the testcase files in a global variable
COMPATIBILITY.<cts-name>.FILES, which you can reference in a build
task that builds the suite's zip package.
Also copy over the test case files if user runs mm/mmm/etc.

Change-Id: Ica0dbc4f193db7de7d395b9c686733bdac41f566
2015-06-03 16:21:12 -07:00
Ying Wang
1fb0152ff7 Don't extract jni from prebuilt apks.
- We don't need LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES now, for we always
  page-align jni shared libraries and store them umcompressed.
- For prebuilt apks, we don't extract jni any more; Instead we always run
  uncompress-shared-libs on them.
- For apks built from source, we still install the jni separately, because
  that way multiple apks can share the same jni and it saves space.

With this change, for most prebuilt apks, we don't need to specify
LOCAL_PREBUILT_JNI_LIBS ("@lib/<abi>/foo.so") any more, for the build
system automatically replaces the embedded jni with uncompressed files;
But if a prebuilt is a fat apk (i.e. containing jni not needed by the
current product architecture), you still need LOCAL_PREBUILT_JNI_LIBS to
specify what jni to keep. Otherwise all embedded jni will be replaced with
uncompressed files, that wastes space.

Bug: 8076853
Change-Id: Ic3666dc72bf17cd293787414dd185470b365f967
2015-06-01 19:19:45 -07:00
Yohann Roussel
f09e59eb52 [DO NOT MERGE] Compile using Jack.
This allows to compile dex targeted java sources using Jack and Jill.
Default is still to compile with the legacy toolchain. Default can be
switched to the new toolchain by setting environement variable:
export ANDROID_COMPILE_WITH_JACK=true
Toolchain can also be forced for one module by defining
LOCAL_JACK_ENABLED:=full # disabled, full, incremental
in the mk portion defining the module.

Jack execution environement can be controlled with:

Global variable ANDROID_JACK_VM allow to change the jvm executing Jack.
Global variable ANDROID_JACK_VM_ARGS allows to change default args given
to the jvm.
Global variable ANDROID_JACK_EXTRA_ARGS allows to define some default args
to give to Jack

LOCAL_JACK_VM_ARGS allows to override default args given to the jvm for
the module.
LOCAL_JACK_EXTRA_ARGS allows to override default args passed to Jack.

This includes cherry-picks of the following changes:
b4c49cba57
22c3fa6d73
138768c1bb
5dd3e1d312
83d5d04047
8bc90fd2d6
140274707e
0fbc9ff2a2
833b427d72
f9a27f45b4
2809666941
37822c443d
c6b44d43c3
d2a76c14bf
06744f60fc
95573d5036
b821391614
2794e7b582
801f2c44d0
c76d99dca1
f528e132d6
76a5e0bd1a
e25b3984ff Partially, only Jack related parts werekept
ec46a3b71f
abee3a9f41
77cbe10fd9
daf07db4cd
b6bfb5893a

Ie all Jack related changes untill
b6bfb5893a
except
a96cc59ab5 "Use Jack by default"

Change-Id: If9d47ef1c4fd1e6765ad2a47d816c1ad3cfab0e3
2015-05-19 18:31:05 +02:00
Ying Wang
97dfa3177d Revert "Don't extract jni from prebuilt apks."
This reverts commit 3797466fbd.

Bug: 20810492
Bug: 20811499
Change-Id: Ic922d9daccc4550db489c0f3d4ad6b4ff85b5e60
2015-05-04 18:39:46 +00:00
Ying Wang
3797466fbd Don't extract jni from prebuilt apks.
- We don't need LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES now, for we always
  page-align jni shared libraries and store them umcompressed.
- For prebuilt apks, we don't extract jni any more; Instead we always run
  uncompress-shared-libs on them.
- For apks built from source, we still install the jni separately, because
  that way multiple apks can share the same jni and it saves space.

With this change, for most prebuilt apks, we don't need to specify
LOCAL_PREBUILT_JNI_LIBS ("@lib/<abi>/foo.so") any more, for the build
system automatically replaces the embedded jni with uncompressed files;
But if a prebuilt is a fat apk (i.e. containing jni not needed by the
current product architecture), you still need LOCAL_PREBUILT_JNI_LIBS to
specify what jni to keep. Otherwise all embedded jni will be replaced with
uncompressed files, that wastes space.

Bug: 8076853
Change-Id: Icf07e0998ac3602e6e05e80fed836fbafca33e01
2015-05-01 16:09:58 -07:00
Ying Wang
ed0361f1d3 Data-binding integration.
- Set up LOCAL_JAVACFLAGS to run annotation processing.
- Set up a new intermediate directory $(data_binding_intermediates) to
  contain data-binding intermediate files.
- The annotation generated code is generated to
  $(data_binding_intermediates)/anno-src. The code will be automatically
  included by javac, so no need to store it in
  $(LOCAL_INTERMEDIATE_SOURCE_DIR).
- Set up rules to run DATA_BINDING_COMPILER. The generated code will be
  put in $(LOCAL_INTERMEDIATE_SOURCE_DIR)/data-binding, so that it can
  be automatically included by $(compile-java); Other generated files
  are put in in subdirs of $(data_binding_intermediates). The generated
  resource dir replaces the app's original LOCAL_RESOURCE_DIR.

Also fixed transform-jar-to-jack on prebuilt aar.

Bug: 19945740
Change-Id: I42d9b0e5cd48cf2dce4488298a960b3c95602beb
2015-04-29 18:24:42 -07:00
Dmitriy Ivanov
cc39abfdd2 am a6c44859: am bc671bc6: am e3aa1c1f: Merge "Remove LOCAL_JNI_SHARED_LIBRARIES_ZIP_OPTIONS"
* commit 'a6c44859c5344d489526641ce5a08598254da57b':
  Remove LOCAL_JNI_SHARED_LIBRARIES_ZIP_OPTIONS
2015-04-17 19:42:55 +00:00
Dmitriy Ivanov
8f9487431c Remove LOCAL_JNI_SHARED_LIBRARIES_ZIP_OPTIONS
Use LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES instead.

Change-Id: Id30529fbc1652d066e0008813352848b5e404ab9
2015-04-17 11:39:04 -07:00
Ying Wang
87a21c8b89 resolved conflicts for merge of eec386a4 to master
Change-Id: Ia686e67ed480427a6422d87bef2dcd4e44e27266
2015-04-15 14:39:26 -07:00
Kenny Root
dff3755a93 Move package signing after file stripping
For dex preopt and JNI library extraction, we should remove the
classes.dex and .so files before we sign the APK so that there
isn't an entry in the manifest.

Prebuilt APKs which are pre-signed will simply not have the files
removed. This may cause some system.img bloat, but signature checks make
this necessary.

Bug: 20247329
Change-Id: I4742d1aa3aa64ab5aea2264304cb8c0bea24f784
2015-04-15 12:40:22 -07:00
Ying Wang
454bcff255 Add back Java resources to apk without Java code.
With commit 33360dd569 we moved Java
resource packaging forward to creation of the jar file. But the Java
resource packaging will be skipped if a module has no Java code at all.
(The build system does support building an apk without Java code.)
In this change we add back the Java resources directly to the built apk
when the apk has no Java code.

(cherry-picked from commit 8b27d1879c)

Bug: 19947218
Change-Id: I0e1a65a9cbe656974f8ef3923b2f15e9efa5feb9
2015-03-27 11:30:51 -07:00
Ying Wang
8b27d1879c Add back Java resources to apk without Java code.
With commit 33360dd569 we moved Java
resource packaging forward to creation of the jar file. But the Java
resource packaging will be skipped if a module has no Java code at all.
(The build system does support building an apk without Java code.)
In this change we add back the Java resources directly to the built apk
when the apk has no Java code.

Bug: 19947218
Change-Id: I0e1a65a9cbe656974f8ef3923b2f15e9efa5feb9
2015-03-27 11:15:17 -07:00
Narayan Kamath
4fc5df7f65 am cafb413c: am 59c24c79: am 095c4515: Merge "Remove unused variables."
* commit 'cafb413c2d4ec69ac111df76ea264f8594065398':
  Remove unused variables.
2015-02-27 16:47:30 +00:00
Narayan Kamath
59c24c790a am 095c4515: Merge "Remove unused variables."
* commit '095c451541765c7efb9d5a8152f8ef15626ccedb':
  Remove unused variables.
2015-02-27 16:33:23 +00:00
Narayan Kamath
7a9e388405 am 738871f6: am e886392c: am 37a44faa: Merge "Store native libs aligned to PAGE_SIZE"
* commit '738871f6eb3c372b60928e761f0dc24e46a6bba5':
  Store native libs aligned to PAGE_SIZE
2015-02-26 12:58:11 +00:00
Narayan Kamath
e886392c37 am 37a44faa: Merge "Store native libs aligned to PAGE_SIZE"
* commit '37a44faa7266c8a7e0cc5077a4c028d6f5bfa7f7':
  Store native libs aligned to PAGE_SIZE
2015-02-26 12:45:34 +00:00
Narayan Kamath
bc0d368896 Remove unused variables.
Follow up from 13e5965306.

Change-Id: I370e52acd998ce72b4d7dbf2aba604d4b08bb0cf
2015-02-26 12:40:34 +00:00
Dmitriy Ivanov
13e5965306 Store native libs aligned to PAGE_SIZE
- Add a new flag to zipalign (-p) that page aligns shared
  libraries (zip entries ending with ".so") in the archive.

- Add a new build variable LOCAL_PAGE_ALIGN_SHARED_LIBRARIES
  to turn on this behaviour in zipalign.

- Add a new LOCAL_JNI_SHARED_LIBRARIES_ZIP_OPTIONS to control
  zip behaviour.

Bug: 8076853
Bug: 19330157

Co-Authored-By: Simon Baldwin <simonb@google.com>
Co-Authored-By: Dimitry Ivanov <dimitry@google.com>
Change-Id: I1aa2c039bb2a590ae72f256acc9ba5401c2c59b1
2015-02-26 12:31:40 +00:00
Yohann Roussel
d2a76c14bf Change built module of static java libraries
Set LOCAL_BUILT_MODULE of static java libraries when Jack is enabled
to classes.jack instead of javalib.jar.
This allows that running mm in those libraries will build classes.jack
instead of the jar.

Change-Id: I96b4b227848e971df96331b3f0cc731e856be349
2015-02-18 22:54:18 +01:00
Yohann Roussel
37822c443d Engage Jack incremental on demand
Each module may engage Jack incremental with

LOCAL_JACK_ENABLED := incremental

Include renaming of LOCAL_USE_JACK to LOCAL_JACK_ENABLED that is
now accepting 3 values "disabled", "full" and "incremental".

Change-Id: Icbff275b397bee36b29312e821f3e8d45f83fbcc
2015-02-04 11:22:26 +01:00
Ying Wang
723db51fdb am 7c05897b: am e937ac81: Merge "Add new build flag LOCAL_DONT_DELETE_JAR_DIRS."
* commit '7c05897b69801e1945889a9b1a89b86bbbbbdd3a':
  Add new build flag LOCAL_DONT_DELETE_JAR_DIRS.
2015-01-29 18:38:00 +00:00
Ying Wang
7c05897b69 am e937ac81: Merge "Add new build flag LOCAL_DONT_DELETE_JAR_DIRS."
* commit 'e937ac814c7f4e1989509f94f7ac8ae5b28a3526':
  Add new build flag LOCAL_DONT_DELETE_JAR_DIRS.
2015-01-29 18:05:13 +00:00
Fredrik Roubert
cc93f0c87c Add new build flag LOCAL_DONT_DELETE_JAR_DIRS.
Normally the build function initialize-package-file will delete all
class files and all directory entries from JAR files, but sometimes
external projects (eg. ICU4J) depend on having directory entries in
their JAR files.

This change adds the flag LOCAL_DONT_DELETE_JAR_DIRS (analogous to the
flag LOCAL_DONT_DELETE_JAR_META_INF) which when set will skip deletion
of directory entries in initialize-package-file.

Change-Id: I4464b947b7528fca23925affa95e4071915f04d4
2015-01-29 17:44:27 +00:00
Ying Wang
0f205ad959 am 29a29875: Merge "Running jarjar on Java resources."
* commit '29a29875627758aa3c76aa5256641c1782c904bf':
  Running jarjar on Java resources.
2015-01-22 00:13:33 +00:00
Ying Wang
07acdbfd32 Running jarjar on Java resources.
Before this change, Java resources are added as a separate step
(add-java-resources-to-package) after dex is run, so jarjar isn't run on
the resource files.
With this change, we add Java resources immediately after we call javac,
so jarjar is run on the resource files (the module's own resource, as
well as resources carried by static Java libraries).
When we generate the final apk/jar, we use the jarjar'ed jar as the
inital pacakge file, with class files and empty folders removed.

(cherry-picked from commit 140274707e)

Bug: 18837479
Change-Id: I15ecf282bfb65fd53dd03fbd03dd4c71927c186a
2015-01-21 11:57:52 -08:00
Ying Wang
33360dd569 Running jarjar on Java resources.
Before this change, Java resources are added as a separate step
(add-java-resources-to-package) after dex is run, so jarjar isn't run on
the resource files.
With this change, we add Java resources immediately after we call javac,
so jarjar is run on the resource files (the module's own resource, as
well as resources carried by static Java libraries).
When we generate the final apk/jar, we use the jarjar'ed jar as the
inital pacakge file, with class files and empty folders removed.

When jack is enabled, in jack-java-to-dex we add the Java resources to
a temp jar using the PRIVATE_EXTRA_JAR_ARGS, and extrac the files in a
temp dir. Jack will process the resource files and output the result to
PRIVATE_JACK_INTERMEDIATES_DIR. When we package the final apk/jar, we
need to call add-carried-jack-resources to readd the resources.
(TODO: if jack can output all resources to a jar/zip file, we can use
that file as the initial package file as well.)

Bug: 18837479
Change-Id: I8d7296e30ec8d005054cf04c4f2aed6d7a0d823b
2015-01-21 11:54:13 -08:00
Narayan Kamath
c1ed9796bb Revert "Running jarjar on Java resources."
This reverts commit 140274707e.

Breaks the build on uiautomator_compat.

Change-Id: I6d14f39e3432bf5e691027bbb8e7260e4bec8e8d
2015-01-21 11:04:22 +00:00
Ying Wang
140274707e Running jarjar on Java resources.
Before this change, Java resources are added as a separate step
(add-java-resources-to-package) after dex is run, so jarjar isn't run on
the resource files.
With this change, we add Java resources immediately after we call javac,
so jarjar is run on the resource files (the module's own resource, as
well as resources carried by static Java libraries).
When we generate the final apk/jar, we use the jarjar'ed jar as the
inital pacakge file, with class files and empty folders removed.

When jack is enabled, in jack-java-to-dex we add the Java resources to
a temp jar using the PRIVATE_EXTRA_JAR_ARGS, and extrac the files in a
temp dir. Jack will process the resource files and output the result to
PRIVATE_JACK_INTERMEDIATES_DIR. When we package the final apk/jar, we
need to call add-carried-jack-resources to readd the resources.
(TODO: if jack can output all resources to a jar/zip file, we can use
that file as the initial package file as well.)

Bug: 18837479
Change-Id: I15ecf282bfb65fd53dd03fbd03dd4c71927c186a
2015-01-20 11:46:59 -08:00
Ying Wang
92d6249f83 am aa4c8870: am a1e09b1a: am 98ae7985: Fix using variable intermediates.COMMON before defining.
* commit 'aa4c8870a802e317fda14f0574b00d844a4b4716':
  Fix using variable intermediates.COMMON before defining.
2014-12-19 00:08:15 +00:00
Ying Wang
98ae798535 Fix using variable intermediates.COMMON before defining.
In commit e9dd9f2bf we moved "include $(BUILD_SYSTEM)/android_manifest.mk"
forward before the variable intermediates.COMMON gets defined. That's a
mistake.
This change replaced the tentative variables
package_expected_intermediates_COMMON and guessed_intermediates with
their proper counterparts defined in base_rules.mk.
If their values differ in the two file, that's an error and we should
fix.

Bug: 18168693
Change-Id: I2bf17b0476b4a7f97810fbb0bde7630eb8878b53
2014-12-18 15:13:04 -08:00
Ying Wang
2902d4585f Add support for prebuilt AARs.
- You can give a .aar as source file to a prebuilt static Java library
  module. The build system will set up dependencies and rules to extract
  classes.jar and other resource files.
- To build against a prebuilt AAR module, use:
  LOCAL_STATIC_JAVA_AAR_LIBRARIES := <module names of aar prebuilt AARs>
  The build system will set up rules to merge the library's
  AndroidManifest.xml with the main AndroidManifest.xml, add the AAR's
  resource dirs and link/merge the AAR's classes.jar.

Bug: 18168693
Change-Id: Ic2c1d20572a93bd98dbc72f8a39e26b459e442c2
(cherry picked from commit e9dd9f2bfc)
2014-12-17 22:27:26 +00:00
Yohann Roussel
75dbbb6e0f Merge "Compile using Jack." 2014-12-04 09:27:14 +00:00