Commit graph

176 commits

Author SHA1 Message Date
Colin Cross
b1bd1aabca Use logtags without merged file
Assume logtags files will have hardcoded tag numbers and don't
build against the merged file.  Simplifies the build when
logtags files are split across Make and Soong.

Test: m checkbuild
Change-Id: I1e995ec458690fcadb1b86d64864f277aa9fe3af
2017-11-17 11:22:08 -08:00
Colin Cross
1763da8eb9 Export extract-srcjars.sh to Make
Export extract-srcjars.sh to Make so that it can be used to add
srcjar support to droiddoc rules.

Test: m checkbuild
Change-Id: I203ba6dad731ec9167eb8706bbfb345a484f024b
2017-11-17 11:22:08 -08:00
Colin Cross
d243091381 Remove partial javastream proto support
javastream proto is rarely used and tricky to support directly
in java because it depends on an extra host tool.  It can be
supported with a genrule, so just remove the partial built-in
support.

Test: m checkbuild
Change-Id: Iffe75e7040cb889ca17fdd85ef3e8e64fc3aa9e9
2017-11-17 11:22:08 -08:00
Colin Cross
af05017b75 Add support for .srcjar files from genrules and srcs
Allow srcs to contain .srcjar files, which will be extracted just
before javac.  Also allow genrules and generated sources to directly
return .srcjar files.

Test: m checkbuild
Change-Id: Ie4cf60ecb9d2ec63a4c2275221544203b1383597
2017-11-17 11:22:08 -08:00
Colin Cross
ebe1a51c81 Fix java AIDL properties to match C/C++
The C/C++ aidl properties use:
aidl: {
    local_include_dirs: [],
    include_dirs: [],
}

But the Android.bp file was expecting:
aidl_include_dirs: [],
export_aidl_include_dirs: [],

Update java AIDL support to match the C support, which is
also what the androidmk conversion tool is creating.

Test: m checkbuild
Change-Id: I3df763d0b203b1b6556798a21b0553e7d35ad7d5
2017-11-17 11:22:08 -08:00
Colin Cross
d5dbfb78a0 Fix proto flags in java
Compute the common proto flags and pass them to the protoc invocation
when generating java files.

Test: m checkbuild
Change-Id: I0d4c23ad001d01eab03b404545383f009214106d
2017-11-17 11:22:08 -08:00
Nan Zhang
ea568a4a24 Change bool, and string properties to *bool, and *string for java,
python, and genrule.

Test: m -j checkbuild
Bug: b/68853585
Change-Id: Ic9a8083818e920dc399a4b00841e2aa496f70faa
2017-11-08 21:25:40 -08:00
Jeff Gaston
d3e141de80 Pass results of Finder into Blueprint
Bug: 64363847
Test: m -j

Change-Id: I79db8c524af6e77c35a0199ec1876e5eb94e8971
2017-11-08 23:48:44 +00:00
Dan Willemsen
d9e8f0a95a Setup java paths in soong_ui
This way config.mk no longer needs to check which java is in PATH and
fix it. It'll be consistent for all build steps under soong_ui.

Also unify handling of ANDROID_JAVA_HOME / JAVA_HOME with
OVERRIDE_ANDROID_JAVA_HOME / EXPERIMENTAL_USE_OPENJDK9.

Test: m nothing
Test: build/soong/soong_ui.bash --make-mode nothing (w/o envsetup.sh)
Test: aosp_arm ninja files are the same before/after
Test: before/after ninja files match with OVERRIDE_ANDROID_JAVA_HOME
Test: before/after ninja files match with EXPERIMENTAL_USE_OPENJDK9
Change-Id: Icdb65093d9c346524074de239a4f895e4230a24d
2017-11-08 00:44:47 -08:00
Nan Zhang
61eaedbddf Support Javac sharding in Soong.
Test: m clean && m -j java and java_test.go

Change-Id: I110a0ff029448d3319aed2788d25d90a6c1a7fa0
2017-11-06 14:23:59 -08:00
Alan Leung
a39899edb9 Merge "Always use installed version of d8-compat-dx" 2017-11-06 18:54:53 +00:00
Nan Zhang
3c807db06e Add default jar wrapper when wrapper property is not specified
Bug: b/68779881
Test: manually copied the jar-wrapper.sh to out/soong/host/linux-x86/framework
Change-Id: Idee1e7e64c6e3c89c89a8cd9c107a38533356b6c
2017-11-03 15:19:15 -07:00
Colin Cross
126a25cb3d Propagate PRODUCT_MINIMIZE_JAVA_DEBUG_INFO to soong and use it
Strip debug info in javac when PRODUCT_MINIMIZE_JAVA_DEBUG_INFO
is set.

Test: m with PRODUCT_MINIMIZE_JAVA_DEBUG_INFO=true
Change-Id: I167e742662801291c516bf1ff826486560d22147
2017-11-01 12:51:16 -07:00
Treehugger Robot
76530ec6f7 Merge "Import AAPT-related product variables from make" 2017-10-31 23:39:24 +00:00
Yohann Roussel
2e19cd8959 Always use installed version of d8-compat-dx
Also adapt to the renaming of d8 to d8-compat-dx.

Test: USE_D8=true m -j16 PRODUCT-aosp_arm64-eng showcommands core-oj
Change-Id: Ic7aaa6a5da34a6a5706c20f53922a83cb1de1100
2017-10-31 13:29:07 -07:00
Colin Cross
face4e4563 Import AAPT-related product variables from make
Test: m checkbuild
Change-Id: I22113c17d240ff26652cea7df801a183343faebd
2017-10-30 17:36:41 -07:00
Treehugger Robot
047a24ac5c Merge "Allow java_host_binary to be used with genrule." 2017-10-28 00:01:53 +00:00
Alex Light
2423717a0f Allow java_host_binary to be used with genrule.
This is done by implementing the HostToolPath interface for java
Binary objects.

Currently, in order for a java_binary_host to be used in this way the
java_host_binary must include:
    compile_multilib: "first"

Otherwise the genrule is unable to find the correct variant.

Test: ./build_test.bash
Test: Manual

Bug: 68397812

Change-Id: I6849488dc13fa8c383df69d00f62ad815ec17876
2017-10-27 22:07:48 +00:00
Alan Leung
899f3742b8 Use D8 by default
The min-sdk-version issue is solved.

Same goes for the ART layout gtests failure found on the art host bots.

Bug: 67569208
Test: m checkbuild / tests
Change-Id: I88c7f5e9ea5c5c5d1b13404ba5db1479f9f7f2f7
2017-10-27 11:51:01 -07:00
Colin Cross
715d7110f7 Fix kotlin -classpath argument
kotlinc expects -classpath, not --classpath.

Also add a test that uses only .kt files to exercise the code when
there are no java sources.

Test: java_test.go
Change-Id: Ifa5a007b460b40ea2188d0907570fbdca6c48da7
2017-10-26 14:47:40 +00:00
Colin Cross
8eadbf0aaf Fix source jars
Source jars were not working as designed because javac will only
compile files from the -sourcepath if there are references to them
starting from files on the command line.  Switch to extracting
the source jars into a directory and passing a list of the files
to javac.

Test: m checkbuild
Change-Id: I9f7d824f8538d081b2f5ad64ae3cbfd0e96213af
2017-10-26 01:00:46 +00:00
Nan Zhang
9a36418089 Use prebuilt turbine jar for unbundled javac builds.
Test: m -j
Change-Id: If2ab85f8591fe7ab275a1d4fefdd80d871f2c36d
2017-10-25 11:11:37 -07:00
Colin Cross
88c37d3c5f Add convenience phony targets for system modules
OpenJDK9 system modules are not build modules, which means they
can't be built with m core-system-modules.  Add a phony target.

Test: m core-system-modules
Change-Id: If6d512ff7a009b49743fb25cbb566935ec1c0153
2017-10-24 16:02:53 -07:00
Colin Cross
5c6ecc179f Don't panic in turbine with no classes
ALLOW_MISSING_DEPENDENCIES=true can cause missing dependencies to be
hidden from GenerateAndroidBuildActions, which is triggering the
len(jars) == 0 check in compileJavaHeader.  For the
ALLOW_MISSING_DEPENDENCIES=true case the check is unnecessary, as the
build rules will be replaced with runtime errors.  On the off chance
the check would have been hit in a real build, allow merge_zips to
create an empty zip file if it is asked to.

Test: m ALLOW_MISSING_DEPENDENCIES=true
Change-Id: I3171f921d51229ddf38a1a647d32566658c673fa
2017-10-24 16:01:44 -07:00
Colin Cross
d11fcda940 Convert Visit*Deps from blueprint.Module to android.Module
Also adds checks that the dependencies are android.Modules and
are not disabled.

Test: m checkbuild
Change-Id: I05e945f38915d49cd3c0ab72a86576949bc7eff2
2017-10-24 13:01:03 -07:00
Colin Cross
ae88703df5 Move ModuleContext.ModuleBuild to ModuleContext.Build
Now that android.ModuleContext does not include blueprint.ModuleContext
we can rename android.ModuleContext.ModuleBuild to
android.ModuleContext.Build without colliding with
blueprint.ModuleContext.Build.  Leave ModuleBuild as a wrapper around
Build for now to avoid having to update all the users outside
build/soong simultaneously.

Test: m checkbuild
Change-Id: I18eb8cc04faf002049a11d9aac97e9732ff5d638
2017-10-24 10:59:00 -07:00
Colin Cross
0d3f8c0db6 Use prebuilt dx for PDK builds
The source for dx may not be available in PDK builds, use the
prebuilt one from prebuilts/build-tools instead.

Bug: 67663308
Test: m TARGET_BUILD_PDK=true
Change-Id: I9090b5190539f901fc05264a472133c12d4ea2a1
2017-10-24 10:52:26 -07:00
Colin Cross
1e45cb77a0 Fail when a module depends on a disabled module
Copy the logic from cc.go to fail when a module depends on a disabled
module.  A future change will refactor this to remove the duplication
and cover all other module types.

Test: m TARGET_BUILD_PDK=true doesn't panic
Bug: 67663308
Change-Id: Iab2b142cebdbd74df934e4733f0de83bd3334d86
2017-10-23 16:43:47 -07:00
Colin Cross
e243c231da Fix finding src directory for aidl
aidlFlags was always looking for a src directory at the top level
instead of in the module's source directory.

Test: m checkbuild
Change-Id: Ie31baa21c8632c2bd9a6ebc42e6291417b1f31cd
2017-10-21 15:19:43 -07:00
Colin Cross
15e86d938b Support multiple outputs in genrules with depfile: true
Ninja doesn't support depfiles on a rule with multiple outputs.
Use a single output and put all the rest as implicit outputs.

Bug: 68057449
Test: java_test.go
Change-Id: Ia544493b1b3b51b185c865149d8f3e0eb3c57ee2
2017-10-20 20:44:50 -07:00
Colin Cross
535e2cf4e1 Support installable prebuilt jars
Some host modules need to be installed.  Add an installable property.

Test: m checkbuild
Change-Id: Ifd023213ff66e81aa77ba1741c75837a1dd88d1d
2017-10-20 20:14:47 -07:00
Colin Cross
2ebc476646 Use prebuilts/sdk/*current until Soong can generate stubs
The android_*stubs_current modules don't yet exist, so fall back to
the prebuilt jars for now.

Test: m checkbuild
Change-Id: Iabd32b30954b3f4a6d9a779fde52a032b684807e
2017-10-20 20:14:22 -07:00
Colin Cross
461bd1aae7 Add sdk_version property to imported jars
Test: m checkbuild
Change-Id: I83dd6ad157c7a5918747ce8c9be05c1e1e22d710
2017-10-20 20:14:22 -07:00
Nan Zhang
ed19fc3e2c Support Turbine in Soong.
If sdk jars(android_stubs_current, etc) are compiled using soong java
modules, we have to filter them when running Java build with Turbine.

TODO: provide more unit-tests.

Test: m clean && m -j32; go test java_test

Change-Id: Iad7c241b0e8b0ca760950733f513124b56c84564
2017-10-20 16:26:18 -07:00
Alan Leung
9e07394fd0 Merge "Add D8 support" 2017-10-20 18:59:22 +00:00
Alan Leung
1d476fcbeb Add D8 support
Bug: 67754178
Test: m -j32 checkbuild && USE_D8=true m -j32 checkbuild

Change-Id: If63afc10ceb5e753bbb7f195bb8a895eaef10775
2017-10-19 16:27:42 -07:00
Colin Cross
a22116e2d9 Add property to prevent dex preopting
Add dex_preopt property and pass it through to make as
LOCAL_DEX_PREOPT.

Test: m checkbuild
Change-Id: I6f19d097d1769068b7e4093f011574c540c137f3
2017-10-19 14:26:32 -07:00
Colin Cross
1ee2317555 Move all jar intermediates to subdirs
Make all the jar intermediates called modulename.jar, and put each
in a subdir for the tool that generated it.  This will simplify
using the jars as inputs to genrules and resources.

Test: java_test.go
Change-Id: If00e16bd7df5a4ba24ebc4b68c9ccf2cfda49544
2017-10-19 20:45:11 +00:00
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