Commit graph

138 commits

Author SHA1 Message Date
Colin Cross
a482065454 Use soong_javac_wrapper in soong javac compiles
Test: m checkbuild
Change-Id: I0f9ff0a719ac550a011c2878fc51595dc3427aed
2017-10-18 17:09:54 +00:00
Colin Cross
975f9f79ff Allow jarjar_rules to be arch-specific
Modules may need to use jarjar on the device to move classes into
the android namespace, but not on the host.

Test: m checkbuild
Change-Id: I910ebbe20e45e98edecca0d7c4fb18e806bc3c6c
2017-10-17 16:25:26 -07:00
Colin Cross
93e8595044 Initial kotlin support
Allow java libraries to specify .kt sources, precompile them with
kotlin, and then pass them in the classpath to javac.

Bug: 65219535
Test: java_test.go
Change-Id: Ife22b6ef82ced9ec26a9e5392b2dadacbb16546f
2017-10-17 16:25:22 -07:00
Colin Cross
59149b6df5 Use jars containg sources for java generators
srcFileLists was an ill-fated attempt to deal with generators that
produce a set of java sources that is not known ahead of time.
For example, the list of files produced by protoc depends on the
package statement in the .proto file.  srcFileLists put the list
of generated files into a file, which was then passed to javac
using the @file syntax.  This worked, but it was too easy to cause
missing dependencies, and will not work well in a future distributed
build environment.

Switch to putting generated sources into a jar, and then pass them
jar to javac using -sourcepath.

Test: m checkbuild
Change-Id: Iaab7a588a6c1239f7bf46e4f1b102b3ef517619b
2017-10-16 19:39:39 -07:00
Colin Cross
e9a275b440 Pass output file names into java.Transform* functions
Pass the output file name into the java.Transform* functions.
This consistently puts control of the filename into java.go,
which is often necessary to avoid collisions when the same
rule is used multiple times in a single module.  It also
has the side-effect of removing the poorly named "stem"
parameters.

Test: java_test.go
Change-Id: I7bc1d1f3bfae6f9d2c92870e6df381817817aab4
2017-10-16 19:39:39 -07:00
Colin Cross
1369cdb280 Initial support for converting jars to java9 system modules
Adds a java_system_modules module type that (when
EXPERIMENTAL_USE_OPENJDK9 is set to true) converts a list of
java library modules and prebuilt jars into system modules,
and plumbs the system modules through to the javac command
line.

Also exports the location of the system modules to make
variables, as well as the name of the default system module.

Test: TestClasspath in java_test.go, runs automatically as part of the build
Bug: 63986449
Change-Id: I27bd5d2010092422a27b69c91568e49010e02f40
2017-10-16 15:00:02 -07:00
Colin Cross
070879e69e Refactor errorprone support to reduce duplication
Use a helper function to set up errorprone and javac compiles.

Test: m -j checkbuild
Test: m -j RUN_ERROR_PRONE=true
Change-Id: Icef3a5e1b359487eea3c3306d3d5763dab912b38
2017-10-16 12:50:29 -07:00
Colin Cross
6ccbc913e4 Let tests override environment
Pass an environment to TestConfig that will be used for
all Config.Getenv calls.

Test: none
Change-Id: I683cd9c9e0db61c9bfd2adb27fca78f558f225c4
2017-10-10 23:28:43 -07:00
Colin Cross
92430106c3 Add hostdex support
If hostdex: true is specified for a java library, create an extra
Make module that copies the dex jar to a module with a -hostdex
suffix in the host output directory.

Bug: 67600882
Test: m -j checkbuild
Change-Id: I859dfaabeefdca714b566de94e00f74e03c85939
2017-10-10 08:02:20 -07:00
Colin Cross
54190b3b13 Add test for java generated sources
Bug: 67364649
Test: TestGeneratedSources
Change-Id: I5400e4b013dc47c04b9d32787e50c5281033484d
2017-10-09 15:36:06 -07:00
Colin Cross
52b1e4cf06 Fix doubled generated source files
Generated source files were being included twice, once manually
and once by ctx.ExpandSources.  Remove the manual one.

Bug: 67364649
Test: TestGeneratedSources in later patch
Change-Id: Ia6760b01a34a96767a914bdcb911a39fa6683300
2017-10-09 15:35:57 -07:00
Treehugger Robot
ac1c64e2f3 Merge "Use prebuilts/jdk/jdk9 if EXPERIMENTAL_USE_OPENJDK9 is set" 2017-10-06 04:34:52 +00:00
Treehugger Robot
a221b16e02 Merge "Correctly add dependencies to java_resource_dirs files" 2017-10-06 00:56:19 +00:00
Treehugger Robot
9d7bee729a Merge "Honor resource exclusions in java_resources properties" 2017-10-06 00:54:19 +00:00
Colin Cross
e2ad230989 Use prebuilts/jdk/jdk9 if EXPERIMENTAL_USE_OPENJDK9 is set
Bug: 62123342
Test: m -j EXPRIMENTAL_USE_OPENJDK9=1.8 checkbuild
Change-Id: I2a5a0f0962bca050a087340f7c6a262448c54a94
2017-10-06 00:08:46 +00:00
Treehugger Robot
c21d11850d Merge changes I5f6f3da7,Ia37b8b93,Ie79a2e78
* changes:
  Get dex jar resources from classpath jar
  Add -stripFile argument to merge_zips
  Change default jar time to match ziptime
2017-10-05 23:20:17 +00:00
Colin Cross
647aa4f009 Allow full protos in host modules
Test: m -j checkbuild
Change-Id: I9dd076fea3e0544b8bdeeac9b040a8ee9d818715
2017-10-05 20:56:51 +00:00
Colin Cross
af9c55b780 Correctly add dependencies to java_resource_dirs files
java_resource_dirs was using a file list file that was generated
at ninja time to get the list of files to include, which meant
there were no dependencies on the files to cause res.jar to get
rebuilt.  Switch to using a glob at soong time instead.  This
is substantially similar to a glob in java_resources, except that
java_resource_dirs strips the listed directories off the paths
that end up in the jar.

Test: TestResources in java_test.go
Change-Id: I4b9b38f7b6b38a013cbb4e211187e7282a6795c0
2017-10-04 17:19:43 -07:00
Colin Cross
2372923fe0 Honor resource exclusions in java_resources properties
Honor the default resource exclusions in java_resources properties
including *.java.

Test: m -j checkbuild
Change-Id: Ia117a000680161b54c189758926ddb2068a2a2c3
2017-10-04 17:19:43 -07:00
Colin Cross
7db5d6332f Get dex jar resources from classpath jar
Dex jars were getting their resources from the res.jar files of
their transitive static dependencies.  This accidentally bypassed
jarjar on resources, since the jarjar pass only happened once the
resources jar was combined into the classpath jar.  Switch to
getting the resources out of the classpath jar by merging it
with the dex jar while skipping *.class.

Test: m -j checkbuild
Test: compare ext.jar to one generated by make
Change-Id: I5f6f3da738dcb0af56ab9a1bd7174ed5359de2b2
2017-10-04 17:19:43 -07:00
Colin Cross
c157a8d0e5 Allow libraries with no sources to be installed
Libraries with no source files but static lib dependencies should
still be installable.

Test: m -j checkbuild
Change-Id: Ibc91aa3153241092ce86888dbf90e99b66069ff2
2017-10-04 15:00:27 +00:00
Colin Cross
965714f139 Fix bootclasspath for host variants of java_library modules
The partial hostdex support was causing the host variant of
java_library modules to depend on core-oj and core-libart,
which caused the tagsoup jar to use the wrong
java.lang.System.arraycopy signature.  Remove the hostdex
code that was causing the problem, and add a test.

Test: java_test.go
Change-Id: I4f7b1f29c99aae328ba19b042538d9d35544aa43
2017-10-04 05:50:00 +00:00
Colin Cross
6af17aa022 Add support for .proto files in java modules
Test: m -j checkbuild
Change-Id: Ia03429948baebff85164a91a34507866c97a08ef
2017-10-03 10:25:15 -07:00
Colin Cross
47ff2521c6 Relax SDK checks for unbundled builds
Unbundled builds might not have the prebuilt/sdk files, allow
the build to continue and then fail if the module is actually
built.

Test: m -j checkbuild
Change-Id: I21163778f1cc50945c7a12e57da0e39ba963aa7c
2017-10-02 23:18:32 -07:00
Colin Cross
d5934c8bb7 Fix arch specific properties for java modules
Arch specific properties were not being applied to modules
with OS set to Common.

Test: java_test.go
Change-Id: I8f1b49ca51b0cf96f78006dfcd121672e581d9c5
2017-10-02 23:18:19 -07:00
Colin Cross
a60ead85fc Make java_library_static uninstallable by default
Static libraries are not dexed and are not installable on a
device.

Test: m -j checkbuild
Change-Id: Iea01df381e6c8cf2439fdb87200895db6aac99e2
2017-10-02 23:01:02 -07:00
Colin Cross
0532fb0d4c Fix excluding resource directories
Using a glob as a path failed the existence check.  Append the
glob after converting the path to a string.

Test: TestExcludeResources in java_test.go
Change-Id: Ic1fd40aa283f3b0d59c1c589dbeec411583eddf1
2017-10-03 02:13:16 +00:00
Colin Cross
fa5eb23df6 Add no_framework_libs property
Add a no_framework_libs property similar to no_standard_libs.
The new property will allow modules to continue to link against
the standard bootclasspath libraries that contain java.*, but
not against the framework libraries.  This avoids having to
specify the bootclasspath libraries explicitly.

Test: m -j checkbuild
Change-Id: I0be13a45cadca9b90a0fd1797885cd18c5b462e3
2017-10-01 20:34:35 -07:00
Colin Cross
8b9d37b40a Allow modules with empty sdk_version in unbundled builds
The apps build depends modules that have empty sdk_version.  Let the
behavior match make for now.

Test: m -j TARGET_BUILD_APPS=Gallery2
Change-Id: Ie5545d2cd6b1268b0b3392dc0af2e4eb3d38a588
2017-09-30 02:41:25 +00:00
Colin Cross
0f37af0c15 Add java file resources and flag to include sources
Add a properties to allow including files as resources, including
support for filegroups.  Also add a flag that causes module sources
to be included in the final jar.

Test: java_test.go TestResources
Change-Id: Ida8ee59b28df9fe66952170f46470d3a09fd5d65
2017-09-29 14:02:22 -07:00
Colin Cross
8649b2653c Use pre-desugar classes in classpath
Follow the make change in I87aee34940937dbde33a977f55d1faf2c8054561
to use classes before desugar in the classpath.

Test: java_test.go
Change-Id: I1054f4aea1eb349b6f687e1af0adb92a944fd8c5
2017-09-29 14:02:22 -07:00
Colin Cross
59f1bb66ea Only desugar/dx installable libraries
Don't waste time running dx on libraries that will never end up
on the device.

Test: m -j checkbuild
Change-Id: Iad1750823d3261cd6ad6eb6aa00c74d45b9737a3
2017-09-29 14:02:22 -07:00
Colin Cross
40a3671416 Remove jarSpec structure
It's not doing anything anymore, and the next patch will need more
complex jar arguments.  Just remove it.

Test: m -j checkbuild
Change-Id: I96d15995e86263ec04fd5c13ab0fd54d8b85c788
2017-09-29 14:02:22 -07:00
Colin Cross
d689143f1d Move errorprone dependency to compiled classes jar
The resources jar and the combined jar are not always used, so
add the errorprone dependency to the compiled jar.

Test: m -j checkbuild
Change-Id: Iaa10a04347758c676bb704969b86f9442e6c3175
2017-09-29 14:02:22 -07:00
Colin Cross
86a63ff366 Rename resource_dirs to java_resource_dirs
For consistency with make, rename java resources to
java_resource_dirs and android resources to resource_dirs.

Test: m -j checkbuild
Change-Id: Ie9aac50fef40f6a9093b4b98759e79cd086bb797
2017-09-27 23:21:36 -07:00
Colin Cross
cb2c92961c Remove duplication of bootclasspath in DefaultLibraries
Don't add bootclasspath libraries as classpath dependencies too.

Test: m -j checkbuild
Change-Id: Icb45e45536ce3babab73f67d281ca593edd4ab7f
2017-09-23 22:36:16 -07:00
Colin Cross
a713a6f6bd Don't generate dex jars for host modules
Hostdex support isn't working yet, and we are accidentally producing
a dex jar for host modules, which confuses soong_java_prebuilt.mk.

Test: m -j checkbuild
Change-Id: Ie2c331fa697f49dab23c380a5c6e0490d67c9f74
2017-09-20 18:08:04 -07:00
Colin Cross
fc3674a607 Remove android_prebuilt_sdk modules
Forcing sdk modules to be declared explicitly is unnecessary, just
add the required dependencies on the jar and aidl files.

Test: java_test.go
Change-Id: Ib28bdc1051c5825e7c0efb6adff1f9282675560e
2017-09-20 13:20:45 -07:00
Colin Cross
2acdae8853 Fix java sdk tests
Fix the java module sdk tests, and expand them to cover testing
all classpaths including for the host.

Test: java_test.go
Change-Id: I71be13cc5545f5c4d5b377c4c8de3dccbb09abf9
2017-09-20 13:20:45 -07:00
Colin Cross
4c428dfb28 Convert java tests to NewTestArchContext
Java tests will need to test code inside if ctx.Device() blocks,
switch to using TestArchConfig and NewTestArchContext.

Disable TestSdk for now, just registering modules that depend
on the SDK triggers panics because of previously untested code
that is now executed.

Test: java_test.go
Change-Id: Iff2c814af56cc830327db8d951c4350034c00361
2017-09-20 13:20:45 -07:00
Colin Cross
6ade34f641 Initial device java support
First pass at java support for the device.  Adds desugar before
dx, and passes javalib.jar to make.

Test: m -j checkbuild
Change-Id: I3138d943bc4867a52c3fce8fbdb597773793988d
2017-09-20 13:20:45 -07:00
Colin Cross
635acc9446 Rearrange manifest file handling in merge_zips and soong_zip
Jar always puts default MANIFEST.MF files in if none was specified.
Copying that behavior in soong_zip causes problems with merge_zips,
because it ends up taking the default manifest from the classes.jar
instead of the user's manifest from res.jar.  We don't want the
user's manifest in the classes.jar, otherwise a change to the
manifest will cause all the class files to rebuild.  Instead,
move the manifest insertion to the final merge_zips stage.

Test: m -j checkbuild
Change-Id: Id6376961dbaf743c2fb92843f9bdf2e44b963be0
2017-09-20 13:20:45 -07:00
Colin Cross
945c000aac Add -XDskipDuplicateBridges=true flag to javac
Turbine leaves out bridges which can cause javac to unnecessarily insert
them into subclasses.  Setting this flag causes our custom javac to
assume that the missing bridges will exist at runtime and not recreate
them in subclasses.  If a different javac is used the flag will be
ignored and extra bridges will be inserted, which should be harmless.
The flag is implemented by https://android-review.googlesource.com/c/486427

Test: m -j checkbuild
Test: check core-libart for extra methods
Bug: 65645120
Change-Id: I6e2babe4a5a24cda4903845ae895c369343ec55b
2017-09-19 12:19:36 -07:00
Dan Willemsen
d6ba0d592c Use dependency tags for genrules
So that we don't get confused when using :<module> in srcs to depend on
a module that could also be a HostBinTool.

Test: m -j
Change-Id: Ia3b1c26826e70f84c6dc5ff78c95dd11d76901b6
2017-09-14 22:59:33 +00:00
Colin Cross
3a5de657db Add missing space between errorprone flags
A space was missing between flags in the errorprone build rule.

Test: m -j RUN_ERROR_PRONE=true checkbuild
Change-Id: If6f48a700e6f19e318b6cc9734e1d8fd2289491f
2017-09-11 23:10:21 -07:00
Colin Cross
4f26bc0263 Strip javac 9 module arguments
Strip module-related javac 9 command line arguments that don't apply
to javac 8.

Test: m -j checkbuild
Change-Id: If44a3d9d7227e923117dc75bbabbddb41026b25d
2017-09-11 13:14:21 -07:00
Colin Cross
018f4a0d08 Merge changes Ifbf9fe27,I41a6cd42,Ieae59efb
* changes:
  Allow some duplicates in merged jars
  Add support for java annotation processors
  Update java androidmk conversions
2017-09-09 05:18:44 +00:00
Colin Cross
1965568eee Use same module name for java binary wrapper and jar
Trying to use dx.jar for the jar module name and dx for the
wrapper module name leads to the make side installing dx.jar.jar.
The separate names are only needed to make LOCAL_REQUIRED_MODULES
work.  Make the names the same again, and use a manual dependency
from the installed location of the wrapper script to the installed
location of the jar to make sure that both get installed and that
the wrapper script timestamp is always as new as the jar.

Test: m -j checkbuild
Change-Id: Ibc8ce9d24ed770e9a270fb8eaa8fe1b427a382a7
2017-09-07 17:00:22 -07:00
Colin Cross
5349941875 Use soong_java_prebuilt.mk to export soong jars to java
Instead of trying to squeeze soong jars through prebuilt_internal.mk,
make a separate soong_java_prebuilt.mk.

Test: m -j checkbuild
Change-Id: Idadef3c21a6f618d573110f04c80d7db3db92031
2017-09-07 20:23:43 +00:00
Colin Cross
32f676a7b4 Add support for java annotation processors
Add annotation_processor and annotation_processor_classes properties.

Test: m -j checkbuild
Change-Id: I41a6cd42f0c048070a99cb18af150030170498f7
2017-09-06 13:44:03 -07:00