summaryrefslogtreecommitdiff
path: root/java/builder.go
AgeCommit message (Collapse)Author
2018-12-13Dexpreopt soong modules inside soong Colin Cross
Port the dexpreopt logic from Make to the dexpreopt package in Soong, and use it to dexpreopt Soong modules. The same package is also compiled into the dexpreopt_gen binary to generate dexpreopt scripts for Make modules. Bug: 119412419 Bug: 120273280 Test: no differences to dexpreopt outputs on aosp_sailfish system/, only expected changes to dexpreopt outputs on system_other (.vdex files for privileged Soong modules no longer incorrectly contain .dex contents). Change-Id: Ib67e2febf9ed921f06e8a86b9ec945c80dff35eb
2018-11-04Revert "Use protoc-gen-javalite for java lite protos" Colin Cross
This reverts commit 5a5aca05680f2289e00583adeafa3d5f54da51ae. Change-Id: Iadbc2ec7fbc45d888383e0e6f569cbfc5ef6a996
2018-11-03Use protoc-gen-javalite for java lite protos Colin Cross
Protobuf 3.5.2 does not natively support lite protos, instead they are generated by the protoc-gen-javalite plugin compiled from external/protobuf-javalite. Bug: 117607748 Test: m checkbuild Change-Id: I95c2d873f19d4c00e9dc312d7fdbe98cae250a8b
2018-10-18Support main_class property in java_binary modules Colin Cross
Add a main_class property that will be used to generate a manifest containing a Main-Class entry. Test: m checkbuild Change-Id: I0a59bb2b93cad915afd82fba708fa0f7eda2fe7a
2018-10-08Add support for JNI libraries to android_app modules Colin Cross
Make android_app modules a MultiTargets module, which means the common variant will have a list of Targets that it needs to handle. Collect JNI libraries for each Target, and package them into or alongside the APK. Bug: 80095087 Test: app_test.go Change-Id: Iabd3921e1d4c4b4cfcc7e131a0b0d9ab83b0ebbb
2018-09-28soong_zip: support globs in -f and -D arguments Colin Cross
-f and -D arguments can now take globs in the Soong format. Also update the use of soong_zip that jars resources to escape the globs in the arguments, and then shell-escape them when writing to the rsp file so the glob escape are not intepreted by ReadRespFile. Also remove an unused argument to the buildAAR rule that could have contained values that needed escaping. Relands I7f20bb169dc01f952d2a7681ec6ee9c05737ed37 with a fix for trailing "\n" in list files, which causes a call to pathtools.Glob("") that returns "./", which could then get incorrectly translated to "../../../" in the zip file. Also adds tests. Test: m checkbuild Test: zip_test.go Change-Id: I54b8eef9231875e6042a32c9f8bcc5c2f779922a
2018-09-26Revert "soong_zip: support globs in -f and -D arguments" Colin Cross
This reverts commit 08e28abc4ecd10a0e0ab2dcb683560f9c6331e1b. Reason for revert: inserts extra ../../ entries in the zip file. Bug: 116737386 Change-Id: I048f94889a66fe618058e37a5827d0cf6b1a6b68
2018-09-21soong_zip: support globs in -f and -D arguments Colin Cross
-f and -D arguments can now take globs in the Soong format. Also update the use of soong_zip that jars resources to escape the globs in the arguments, and then shell-escape them when writing to the rsp file so the glob escape are not intepreted by ReadRespFile. Also remove an unused argument to the buildAAR rule that could have contained values that needed escaping. Test: m checkbuild Change-Id: I7f20bb169dc01f952d2a7681ec6ee9c05737ed37
2018-09-13Allow '$' in some paths Colin Cross
The icu resource directories contain filenames that have '$' characters. Allow paths returned by the Glob functions to contain '$', on the assumption that real paths on disk are unlikely to contain strings that are valid ninja variables. Fix the Build rules to escape any paths that are passed as Path arguments. Fix the resource rules to manually escape the paths that are passed as strings. Test: m checkbuild Change-Id: Ie631bc6d96259e592adb280491a365c0df7ed0e2
2018-09-08Move kotlinc-build.xml out of classes directory Colin Cross
kotlinc-build.xml was ending up in the final jar because it was being created in the directory where the classes were written. Rename the variable containing the classes directory from outDir to classesDir to discourage putting other files in there, and move kotlinc-build.xml up a directory. Bug: 114524493 Test: m checkbuild Change-Id: Id2e2af0a6543499bd25b8fbd642bc59b14bd241f
2018-08-29Add jetifier support in Soong. Nan Zhang
This is a blocker for droiddoc targets migration under vendor/. Test: N/A Bug: b/72552006 Change-Id: If85a0917c1ac0d88b9d5b488216a638b4dabd39f
2018-08-29Revert "Add support for renamed kotlin stdlib." Colin Cross
This reverts commit 66c0c4067f8a70847eaa37273671aa8fe4203f1d. Bug: 112674805 Test: m checkbuild Change-Id: I687888136b570f080b57af352af0130355acd216
2018-08-16Support patch_module in java modules Colin Cross
A few tests that have classes in the java.base module need to pass --patch-module=java.base=<classpath> to javac. Test: m checkbuild Change-Id: I246bad92dcde976969b064aace5e2856e2bac971
2018-08-16Make :module provide the output file for java modules Colin Cross
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-07-12Add exclude_files and exclude_dirs properties to java_import Colin Cross
Prebuilt jars sometime contain files that we don't want. In Make we would delete everything in META-INF when importing jars, but that caused problems when there were necessary files in there, so we added LOCAL_DONT_DELETE_JAR_META_INF. Soong does the opposite, keeping everything by default. Add properties to allow explicitly stripping unwanted files instead. Bug: 111389216 Test: m checkbuild Change-Id: I6d07f519ebc7d0e1bf0af93416bb569e3c2b1500
2018-06-29Add condtion to avoid build error Sundong Ahn
If docs file which is result of javadoc is null, there is a build error when building stubs file. To avoid build error, we don't build if srcJar files is exist but they don't have java file list. Bug:77577799 Test: make -j Test: Marking @hide to all APIs in javax.obex library -> make -j -> check build result. result is success Change-Id: I85439417a36425e89a8fa2ecbc66d1b2022bc63a
2018-06-20Run ErrorProne in OpenJDK9 Colin Cross
Use the OpenJDK9 javac to run ErrorProne by adding it to -processorpath and using -Xplugin:ErrorProne. Bug: 69485063 Test: m RUN_ERROR_PRONE=true javac-check Change-Id: I0496006b71b70766ef16d57753cbcf037897799c
2018-06-20Use -processorpath for annotation processors Colin Cross
ErrorProne needs to be added to -processorpath, but once anything is passed via -processorpath javac stops looking in the classpath for annotation processors. Move annotation processors to -processorpath in preparation. This reapplies Ife06b3c7432ab971f5605dcc18a558bcbd99a675 with fixes to processorpath in errorprone rules. Test: m java Change-Id: I188136771386a2183fb31f4b70b50c95ac419ff8
2018-06-21Revert "Use -processorpath for annotation processors" Colin Cross
This reverts commit 6dd0bb3b7726cbf3f385da90745ce25deead9790. Reason for revert: broke RUN_ERROR_PRONE=true build Change-Id: I23d066281e392c6e7df29c5cd4558c7cf731c1a5
2018-06-20Use -processorpath for annotation processors Colin Cross
ErrorProne needs to be added to -processorpath, but once anything is passed via -processorpath javac stops looking in the classpath for annotation processors. Move annotation processors to -processorpath in preparation. Test: m java Change-Id: Ife06b3c7432ab971f5605dcc18a558bcbd99a675
2018-06-06Revert "Revert "Remove desugar support"" Colin Cross
This reverts commit 7576916efcc5e73d3b5e6437187697a451dd43f0. Reason for revert: includes art veridex fix this time Change-Id: Ia8da00b5ec8ed3dc3ce2a2521f0a7b2b2b131960
2018-06-06Revert "Remove desugar support" Colin Cross
This reverts commit 000280bb0e13902b2d19fd102ecf68d0dbbabfba. Reason for revert: broke art veridex build Change-Id: I9f7d7cdbe8e34671614687ac0b34c0338ef240e7
2018-06-06Remove desugar support Colin Cross
Desugaring is always handled by d8 now. Test: m checkbuild Change-Id: I29e8f68e51b194a4090866acc63f19f0605e318d
2018-03-20Add support for renamed kotlin stdlib. Przemyslaw Szczepaniak
Added new CompilerProperty flag, rename_kotlin_stdlib, which allow to build kotlin libraries/binaries that use platform internal version of kotlin stdlib (com.android.kotlin.*). This way, app-provided kotlin standard library won't collide with version used internaly. + remove kotlinc-build.xml after compilation so it won't end up in the result jar file + remove *.kotlin_module and *.kotlin_bultin filesfrom result jar file. These files are needed only by kotlin-reflect library and need more work to support kotlin-stdlib renaming. Bug: 73281388 Test: java_test.go Change-Id: Iae7ccb919e2ae9853b3f30f3dd447ebd01a1bed0
2018-03-15Replace extract-srcjars.sh with zipsync tool Colin Cross
extract_srcjars.sh uses zipinfo and unzip, which fail with an error on an empty zip file. Instead of trying to hack around this (which is hard to make guarantees for since they are non-hermetic host tools), replace them with a go tool to unzip a set of zip files into a directory. Bug: 73885582 Test: m checkbuild Change-Id: I151fed347ed5196726e36866ffc27bc831799afb
2018-03-13Update turbine command line flags Colin Cross
The latest version of turbine requires a -- after the javac options, and uses multiple --bootclasspath arguments instead of a javac-style colon separated list. Test: m javac-check Bug: 74339924 Change-Id: Ib7096294a43e9bd30abc36751299bfac7879f765
2018-03-07Use turbine's native source jar support Colin Cross
Turbine doesn't need extract_srcjars.sh, just pass the source jars with --source_jars. Bug: 74339924 Test: m checkbuild Change-Id: Ie7fe06f5a9f5e29287cf79c2d46b23a676a03d41
2018-02-22Add proto.canonical_path_from_root Dan Willemsen
Historically, we've always passed '-I .' as the first argument to protoc, essentially treating all proto file package names as their full path in the android source tree. This would make sense in a monorepo world, but it makes less sense when we're pulling in external projects with established package names. So keep the same default (for now), but allow individual builds to opt into using local paths as the default names with 'canonical_path_from_root: false'. A cleanup effort and/or large scale change in the future could change the default to false. As part of this, run protoc once per input proto file, since the flags may need to change per-file. We'll also need this in order to specify --dependency_out in the future. Bug: 70704330 Test: aosp/master build-aosp_arm.ninja is identical Test: aosp/master soong/build.ninja has expected changes Test: m Test: Build protobuf test Change-Id: I9d6de9fd630326bbcced1c62a4a7e9546429b0ce
2018-02-22Droiddoc Support in Soong Nan Zhang
Support Droiddoc to Soong based on core/droiddoc.mk. The non-std doclet based droiddoc compilation output is a "real" stubs.jar instead of a directory of java files and a timestamp file. The std doclet based javadoc compilation output is a "empty" stubs.jar instead of a timestamp file. The stubs.jar will be exported to out/target/common/obj/JAVA_LIBRARIES/$(LOCAL_MODULE)_intermediates/classes.jar and out/target/common/docs/$(LOCAL_MODULE)-stubs.jar A $(LOCAL_MODULE).zip file will be generated also, and is exported to out/target/common/docs/$(LOCAL_MODULE)-docs.zip if property: installable is not set to false. Bug: b/70351683 Test: unittest + convert libcore docs Android.mk to Soong manually. Change-Id: I1cffddd138a5d9d445f86a3d4a3fd4de88a2bc0f (cherry picked from commit 78188ec622cb1ee24171455867fc58ffab91562e)
2018-02-20Fix comment on how java rules handle unknown output files Colin Cross
Test: none Change-Id: I985e7961c87dd145d6eb2bd94cb8bdc43becc360
2018-02-14Add rsp and srcjar support to kotlinc build rule Przemyslaw Szczepaniak
Rsp files are supported through helper script (gen-kotlin-build-file.sh) that generates the kotlinc module/build xml file. Since rsp files are supported, I've added ExtractSrcJarsCmd step to handle srcjars extraction. Minor reorderings to make sure that TransformKotlinToClasses recives only .java and .kt files when called from Module.compile. Bug: 73281388 Test: make -j hidl-doc Change-Id: I5a40b914569018dc529903a7f2864a5aeae838e5
2018-02-13Add Respfile support for soong_zip. Nan Zhang
Sometime the size of our command line passed to soong_zip go program exceeds the cmdline size limit. So add an RespFile support with "@" special character prefix. The args in the cmdline will be considered together with the args in RespFile during soong_zip running. Test: real tests in my local machine, and compare the res/libphonenumber.jar before and after changes. ./cmd -o test.zip '""'-C -> [./cmd,-o,test.zip,""-C] ./cmd -o test.zip '-C -f -> [./cmd,-o,test.zip,-C -f] ./cmd -o test.zip '\"'-C -f -> [./cmd,-o,test.zip,\"-C -f] ./cmd -o test.zip '\\'-C -f -> [./cmd,-o,test.zip,\\-C -f] ./cmd -o test.zip '\a'-C -f -> [./cmd,-o,test.zip,\a-C -f] ./cmd -o test.zip \'-C -> [./cmd,-o,test.zip,'-C] ./cmd -o test.zip \\-C -> [./cmd,-o,test.zip,\-C] ./cmd -o test.zip \"-C -> [./cmd,-o,test.zip,"-C] ./cmd -o test.zip "'"-C -> [./cmd,-o,test.zip,'-C] ./cmd -o test.zip "\\"-C -f -> [./cmd,-o,test.zip,\a-C -f] ./cmd -o test.zip "\""-C -f -> [./cmd,-o,test.zip,"a-C -f] Bug: b/72484223 Change-Id: I83c3630b70c8396c8e8a3f266244d868d754c4e8
2018-02-08Disable duplicates warnings when merging jars Colin Cross
There are too many duplicates warnings, disable them until someone is actually looking at them. Bug: 69316739 Test: m checkbuild Change-Id: I7b3315f999dff1c01b6df37ab5ca83f7b8a60bd9
2018-01-23Soong: support Errorprone javacflags Andreas Gampe
Add support for an errorprone block in Java modules that accepts additional javacflags for the errorprone build. Sample: errorprone: { javacflags: ["-Xep:EqualsNaN:WARN"], }, Bug: 72004718 Test: m RUN_ERROR_PRONE=true Test: manual - add block with ERROR to a project Test: androidmk_test Change-Id: I502248fe76c26aa19102f413af72a7324c35b7f4
2018-01-03Add R8 support Colin Cross
Add support for R8 to optimize apps and java libraries. Test: m checkbuild Change-Id: I2afd5d7a84912d3ab613c32c599bd1ebe60562e0
2018-01-02Refactor dexing Colin Cross
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
2017-12-21Strip module-info.class files when combining jars Colin Cross
Combining static jars from dependencies may bring in module-info.class files, which don't make sense once multiple modules have been combined, and sometimes confuse downstream tools like desugar. Strip them out like make does when combining jars. Test: m checkbuild Change-Id: I560c5acfcc6e1be9adf604c22cf200581f92f702
2017-12-18Prep D8 default instead of CompatDX in build/soong Alan Leung
Bug: 69329508 Test: m checkbuild tests Change-Id: Ibaa2d787c644cf25104af78305a6eed16028dcf0
2017-12-16Add missing dependencies on classpath jars for kotlinc Colin Cross
The kotlinc build rules were missing dependencies on the jars in the classpath. Test: TestKotlin in java_test.go Change-Id: I56681785289f942b1070751b7dc5944e7a995b7f
2017-12-15When compiling with the lite protobuf option, pass the option to aprotoc to ↵ Joe Onorato
force the lite runtime. Test: make Merged-In: I450f89d144d496a6ddfccc6a6a5a679a05809595 Change-Id: I450f89d144d496a6ddfccc6a6a5a679a05809595
2017-12-11Add USE_D8_DESUGAR option in build/soong Alan Leung
Add an option to use D8's desugar instead of the standalone version. USE_D8_DESUGAR=true m would trigger DCHECK in dex2oat unless https://android-review.googlesource.com/c/platform/art/+/562595 is patched in as well. Bug: 69329508 Test: m && USE_D8_DESUGAR=false m Change-Id: I864d88e257a2ba0b7f19aa5cced537301950e963
2017-11-30Replace ModuleContext.AConfig() with Config() Colin Cross
AConfig() now duplicates Config(). Replace the uses of AConfig() with Config(). Leave AConfig() for now until code in other projects is cleaned up. Test: m checkbuild Change-Id: Ic88be643049d21dba45dbd1a65588ed94bf43bdc
2017-11-18kotlinc: Always pass -jvm-target 1.8 Tobias Thierer
AOSP's current version of kotlinc only supports -jvm-target 1.8 or 1.6. Previously, we were passing the javaVersion (the value passed to javac -target) but that would fail if javaVersion was eg. 1.9. This CL changes the kotlinc invocation to always pass -jvm-target 1.8, regardless of javaVersion. Bug: 69160377 Test: Treehugger Change-Id: Ib12a8c2afbe908319513861a5380e70bf09d0be0
2017-11-17Fix proto flags in java Colin Cross
Compute the common proto flags and pass them to the protoc invocation when generating java files. Test: m checkbuild Change-Id: I0d4c23ad001d01eab03b404545383f009214106d
2017-11-06Support Javac sharding in Soong. Nan Zhang
Test: m clean && m -j java and java_test.go Change-Id: I110a0ff029448d3319aed2788d25d90a6c1a7fa0
2017-10-26Fix kotlin -classpath argument Colin Cross
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-26Fix source jars Colin Cross
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-24Move ModuleContext.ModuleBuild to ModuleContext.Build Colin Cross
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-20Support Turbine in Soong. Nan Zhang
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-19Move all jar intermediates to subdirs Colin Cross
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