summaryrefslogtreecommitdiff
path: root/java/builder.go
AgeCommit message (Collapse)Author
2025-03-04Replace --revert-annotation with a flags config file Paul Duffin
Previously, Metalava did not support flags specifically and instead relied on the build to generate the appropriate `--revert-annotation` options to ensure that each flagged API was reverted or finalized as appropriate to the flag state. However, Metalava now supports configuring the flag state explicitly so this change switches the build to make use of that. The set of flags to be passed to Metalava are generated using exactly the same queries as before except that instead of just outputting the `{fully_qualified_name}` it outputs the whole protobuf definition. The `keep-flagged-apis.sh` script has been replaced by `aconfig-to-metalava-flags.py` which consumes the protobuf and generates a config file suitable for Metalava to consume. Finally, instead of using `@<file>` syntax to pass a file containing command line options the config file is specified using `--config-file`. One point to note, previously, when `aconfigFlagsPaths` was empty it would just pass `--revert-annotation android.annotation.FlaggedApi` to revert them all. To do the same with the configuration file it is necessary to pass an empty `<api-flags/>` as no `<api-flags>` means keep all the flagged APIs, just like no `--revert-annotation` does. Rather than have some special logic to handle that case and create an empty file I just let it drop through as the code below generates an empty protobuf file which in turn creates an empty `<api-flags/>` element in the config file. Bug: 399846595 Test: # Before applying this change run: tools/metalava/scripts/gather-android-metalava-artifacts.py before # After applying this change run: tools/metalava/scripts/gather-android-metalava-artifacts.py after # Make sure that there are no differences. meld before after Change-Id: Ia95e111f10d066996e4e51c5b7027b09f4d05d57
2025-02-08Convert api.xml dist rules to Soong Jihoon Kang
...from make to support dist'ing *-api.xml files in soong-only builds. Test: m droid dist --soong-only && ls out/dist/api.xml Bug: 395162087 Bug: 394365683 Change-Id: I98e92423a107d24b04e6f6f0f96c23c24de01fa5
2025-01-28Fix sharded-jarjar output path Makoto Onuki
Make sure to use a relative path. Flag: EXEMPT trivial bugfix Bug: 383559945 Test: $ANDROID_BUILD_TOP/development/tools/ndk/update_ndk_abi.sh # only make sure ninja-gen works Test: OUT_DIR=$ANDROID_BUILD_TOP/out m nothing --no-skip-soong-tests Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh -s Test: treehugger Change-Id: I3f2c097f9a8a047133e9bc246df38549b922507a
2025-01-10Fix running turbine with many srcjars through RBE Colin Cross
The turbine RBE configuration was missing the srcjar rsp file when RBE_TURBINE was enabled and the module contains many srcjars. Add the srcjar rsp file to the list of rbe rsp files so that rewrapper treats all of the srcjars as inputs. Fixes: 388999911 Test: m RBE_TURBINE=true RBE_TURBINE_EXEC_STRATEGY=remote out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/turbine/framework.jar Change-Id: I3a14c18eb10b90ac18f54b842d3f6048f97f0770
2025-01-08Merge "Extract proguard rules found in imported JAR archives" into main Treehugger Robot
2025-01-03Extract proguard rules found in imported JAR archives Luca Stefani
In Android Studio R8 is able to use bundled proguard rules found both in AAR archives (under /proguard.txt) and JAR archives (under /META-INF/proguard/*) Soong currently only handles the _easier_ AAR format and ignores the possibility to have rules in JAR archives. To support those rules we use the newly introduced ExtractR8Rules cli tool in R8 to extract all the embedded rules in the imported JAR for later propagation. Bug: 377144587 Test: m, including okhttp-4.12.0.jar now doesn't create R8 warnings. Change-Id: I10f9bbf76bc8daec1ec470fb493e399d1beffc8a
2024-12-27Use test ([) instead of extended test ([[) in if statements jyeon.noh
- Using extended test is not portable since some /bin/sh doesn't support it. [ 4% 5228/128453 3h38m43s remaining] //external/javaparser:javaparser javac [linux_glibc common] /bin/sh: 1: [[: not found - Use "test" instead Change-Id: Ic29eb8cd04b8d29b4b8ca8863a826b073c2d2d71
2024-12-13Use $in_newline instead of $in for turbine rsp files Colin Cross
The latest version of turbine only supports newline separated rsp files, switch to $in_newline, and manually use newlines instead of spaces for the classpath and srcjars. Bug: 384046733 Test: m javac-check Change-Id: Ic56d9abbfcb99154a4a58e3f3e39de3b6c6224a9
2024-12-12Support jarjar sharding Makoto Onuki
- If the new option `jarjar_shards` is set, use this as the number of shards and enable sharding. - The plan is to use it on "big" jars such as framework-minus-apex, but for now, we only use it in a "test" target, `framework-minus-apex_jarjar-sharded`. - Also add `framework-minus-apex_jarjar-sharded` to the various hardcoded spacial cases. Test: m framework-minus-apex framework-minus-apex_jarjar-sharded and make sure the javac output jars have the same entries. $ diff \ <(jar tf $ANDROID_BUILD_TOP/out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/jarjar/framework.jar \ | sort) \ <(jar tf $ANDROID_BUILD_TOP/out/soong/.intermediates/frameworks/base/framework-minus-apex_jarjar-sharded/android_common/jarjar/framework-minus-apex_jarjar-sharded.jar \ | sort) (no output) Bug: 383559945 Flag: EXEMPT New options are not used on production jars Change-Id: I94c2ad978add25267f22b65c063e9148901b208b
2024-12-10Collect file delta metrics for java and kotlin compiles LaMont Jones
- Update the kotlinc and javac build rules to generate changed file metrics. - Upload the aggregated metrics at build completion. - Also fixes parsing of --inputs_file and --target to be consistent with existing use cases. Bug: b/365537477 Test: manual, TH Change-Id: I48efe06917baa98081e18b6351b63a624b55dba8
2024-10-17Modify disabled flags to be exposed in keep-flagged-apis Jihoon Kang
Currently, keep-flagged-apis filters flags that are disabled (so that the apis associated with the disabled flags are not exposed in the "exportable" stubs), but sdk_with_runtime_apis product builds require disabled flagged apis to be exposed. Filtering of the flags should be done by aconfig, and keep-flagged-apis should only convert the list of flags to the metalava-consumable format. Test: lunch sdk_with_runtime_apis-trunk_staging-eng && m sdk dist and observe outputs Bug: 371248797 Change-Id: If1622a6b81bc69a99e8f89c60a11ebec7899b95b
2024-10-04Merge "[Ravenwood] Allow sending additional args to Ravenizer" into main Treehugger Robot
2024-10-04[Ravenwood] Allow sending additional args to Ravenizer John Wu
Provide a new property to send the "--strip-mockito" argument to the Ravenizer tool through Android.bp. Bug: 292141694 Flag: EXEMPT host test change only Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh Change-Id: I88a11640244f02e9a02858245307f9ad887eedda
2024-10-03Strip versioned module-info.class files Cole Faust
The latest errorprone updates use a multi-release jar file: https://github.com/google/error-prone/issues/3756 https://openjdk.org/jeps/238 The module-info.class existing under certain version folders caused package-check.sh to fail. Currently errorprone only has a versioned module-info.class file, but if it later adds versioned implementation classes, we may also need to update package-check.sh to respect multi-release jars. Bug: 253827323 Test: m RUN_ERROR_PRONE=true out/soong/.intermediates/packages/modules/Media/apex/framework/updatable-media/android_common/package-check.stamp with errorprone update to 3.32.0 Change-Id: Ieaee73636aa5321494c14c221d38964e1b0cebb1
2024-09-02Apply apimapper instrument tool on android tests Yihan Dong
Apimapper is a tool to instrument android tests to log potentail API calls at the run time. The real tool is developed internally. We use a placeholder binary in AOSP before the real tool is ready. The tool will only take affect when the enviroment var EMMA_API_MAPPER is set to true. Test: m cts Bug: 328699028 Change-Id: Iece53b8afdb9803334b7393527f4fa24e22f71a8
2024-08-16Merge "Run "ravenizer" on ravenwood jars" into main Treehugger Robot
2024-08-16Run "ravenizer" on ravenwood jars Makoto Onuki
Ravenizer is a new tool to preprocess ravenwood tests. It can optionally be applied to other java targets (for analyzing them, etc). The actual tool is being implemented internally, so in AOSP, we just use a script that copies the jar file as a replacement. Test: manual -- run `m RavenwoodBivalentTest` and make sure the ravenizer log message shows up. Flag: EXEMPT host test change only Bug: 360390999 Change-Id: I6d1f81e7c425397b16c37e7c30267957097387fd
2024-08-13Use rsp files to pass turbine inputs to RBE Colin Cross
Turbine rules that run in RBE fail when they have long lists of flags. They work locally because the list of flags is placed in an RSP file, but the list of inputs still appears on the command line when RBE is enabled to pass them to rewrapper. When the list of srcjars or classpath arguments are too long, move the list of files into an rsp file, and pass the rsp file to RBE instead of the list of files. Bug; 308016794 Test: builds Flag: EXEMPT refactor Change-Id: I5ee610a91302ce94ec77b6f13b28a29bc63fd962
2024-04-11Revert "Add the implicit deps of javacRE" Anna Bauza
This reverts commit eaa475107dc4cc21c061b643dd08b270442facf4. Reason for revert: This cl broke AOSP build, read more b/333846153 Change-Id: I5538a3c78617d7c2db98a11b60cb61269dcec8d3
2024-04-10Add the implicit deps of javacRE Spandan Das
This includes 1. the prebuilt javac binary 2. the input .java files 3. the jars that are placed on the classpath during javac (2) is passed via ${out}.rsp. This rsp file gets populated with the input java files For (3), this CL creates a new intermediate file whose content is comma separated jars available on the classpath (this is the format expected by rewrapper). This file is then registered in RSPFiles of javacRE command, so that it gets passed to the rewrapper cmd as `--input_list_paths` (rspfiles are necesary for modules like framework-minus-apex to avoid exceeding cmd line limits) Bug: 308687455 Test: m framework-minus-apex; # verified that the relevant files are added as `--inputs` of javac Change-Id: I2ab9277fc394eb00454ef503c78a9f3451e596ac
2024-03-14Add exports for JDK 21 to Kythe extractor Sorin Basca
Change-Id: Ie977f08f8aee59ea21dcbfe7c9c07dc0dc535775 Fixes: 328877412 Test: TH
2024-02-29Merge changes I8d060594,I2b6a57ae into main Colin Cross
* changes: Put extraCombinedJars after the compiled jars Use RSP file for long classpaths
2024-02-28Use RSP file for long classpaths Colin Cross
Setting use_resource_processor: true can increase the length of the classpath enough to trigger "command line too long" errors. There are clockwork libraries with 546 transitive android_library dependencies. Write classpaths longer than 64kB to a separate file and add them to the javac and turbine command lines with the @file syntax. Bug: 294256649 Test: m checkbuild Change-Id: I2b6a57ae30de03347db3221e9c9a4b2efb490115
2024-02-08Add dedup flag to aconfig dump-cache calls. Yu Liu
Bug: None Test: CI Change-Id: I34a73576a7a7ea43178895049a0f7dbcd9e329bc
2024-01-10Update released flagged apis rule Jihoon Kang
The aconfig command has been recently updated to fully specify the output format instead of passing the keyword format (e.g., bool). This change reflects the change in the aconfig tool. Test: m art.module.public.api && inspect the generate released-flagged-apis-exportable.txt output Change-Id: I620b7f34c346288ca87342448f50a0e90813304f
2024-01-09Fix the static rule for generating the revert annotations Jihoon Kang
While the static rule depends on the keep-flagged-apis binary, the command deps was mistakenly not specified. This change fixes the rule. Test: m Change-Id: I4875ac516e0e03389eb6a09d720c94f28710fbc9
2024-01-08Add aconfig_declarations property to droidstubs and java_sdk_library Jihoon Kang
In consideration of the incremental build performance, this change let droidstubs and java_sdk_library (which generates droidstubs per api scope) modules to specify `aconfig_declaration` modules where the dependent flags are defined in via the "aconfig_declarations" property, opposed to passing uniform "all_aconfig_declaration"-generated flag arguments to metalava. When "aconfig_declarations" property is defined for java_sdk_library modules, the property is passed to the generated droidstubs modules. When "aconfig_declarations" property is defined for droidstubs modules, the all aconfig_declaration modules listed in the property are listed as deps, all cache protobuf files are gathered and metalava-consumable flags are generated in "revert-annotations.txt". Although this change introduces scalable implementation to easily support generation of the "runtime" stubs corresponding flags, actual support of the runtime flags/stubs will be done in future changes. This change mostly focuses on the generation of the "exportable" flags. Utilization of the generated "exportable" flags will be done in future changes. Test: go test ./java Bug: 315485740 Change-Id: I37becd1b9dd9069d7ac4abed130906df30b3fdf4
2023-11-29Don't write transitive dependencies to Android-${TARGET_PRODUCT}.mk Colin Cross
Java libraries were writing lists of files that changed whenever transitive dependencies changed to Android-${TARGET_PRODUCT}.mk, causing Kati analysis to rerun whenever a dependency was changed in Soong. In both cases, Make would immediately use the list to write a single output file. Write the files in Soong and pass the path to the file to Make instead, which will both reduce the size of Android-${TARGET_PRODUCT}.mk and skip Kati analysis more often. Bug: 309006256 Test: m checkbuild Change-Id: I5dff16c6fb7cca8c6da927b37c612c7b1d0954e6
2023-09-06Error out if skip_preprocessed_apk_checks is set when it's not necessary Cole Faust
So that we don't erroneously add skip_preprocessed_apk_checks everywhere. Bug: 185811447 Test: Presubmits Change-Id: Icb1c6163d170ca4181c5c6a814b51fda4777746f
2023-08-29Only allow setting presigned without preprocessed on targetSdk < 30 Cole Faust
When targetSdk is >= 30, the system verifies that you use a valid signature V2+ certificate. Uncompressing ndk/dex files or aligning the zip file will break a signature V2, so these apks should really just set preprocessed: true. Fixes: 185811447 Test: Presubmits Change-Id: Id89c42bcd5b5daa6eda1716bff4023423298036b
2023-07-27Delete the javac/classes directory after zipping it Colin Cross
javac produces a directory containing class files, which is then zipped with soong_zip into a jar file. The class files are never used outside of the rule, so delete them after zipping them. This should save 19 GB of disk space in checkbuilds. Do the same for kotlinc/classes directories for consistency. Bug: 293352015 Test: treehugger Change-Id: Id1e889cfbee47eab552a5bb27134fa4b3b4c4d14
2023-07-24Merge changes I69f80d12,I40d48644 into main Treehugger Robot
* changes: Merge META-INF/services/* files in merge_zips -jar Strip META-INF/services from implementation jars when using as header jars
2023-07-20Enable restat for javac rules LaMont Jones
Bug: 280820245 Test: presubmit Change-Id: I315fb864f8df3d749fa1545b6e59ee37f8f5ec18
2023-07-19Strip META-INF/services from implementation jars when using as header jars Colin Cross
If a header jar couldn't be built (for example when an API generating annoation processor is in use) the implementation jar is reused as the header jar. If the implementation jar contains an annotation processor listed in META-INF/services/javax.annotation.processing.Processor then later javac executions with the implementation jar in the classpath could attempt to run the annotation processors unexpectedly. Remove the META-INF/services directory when using an implementation jar as a header jar. Bug: 290933559 Test: builds Change-Id: I40d48644bc5a09a9564dc2c4b38f627edd00fcf8
2023-07-12AIDEGen: Collect apt generated sources Vadim Spivak
The Java compiler may generate sources when processing annotations. These sources are currently not included in the IDE project model, which results in unresolved symbols when using Hilt and other annotation processors. These sources are not passed to the Java compiler for compilation, so they cannot be handled like other Java module sources. This change archives the generated sources and appends them to the existing srcjar list in module_bp_java_deps.json. Test: go test . Test: Verified that module_bp_java_deps.json contained srcjar entry Test: with path/to/android_common/javac/anno.srcjar. Test: Verified that IntelliJ can resolve generated symbols after Test: invoking aidegen. Change-Id: I6a3011f9140fd25f785178baee0cd6074ad94600
2023-06-09Make aconfig flags generate a library instead of a srcjar. Joe Onorato
Also add unit tests for the rest of device_config Bug: 283475679 Test: m nothing (soong unit tests) Change-Id: Iee18a1f2f2cbb23e8c8d84c54e903b32be29a693
2023-04-25Expand preprocessed flag to work on android_app_imports Cole Faust
Setting the preprocessed flag will now also verify that the apk is zip-aligned and does not have compressed JNI libs or dex files. Bug: 185811447 Test: m nothing Change-Id: I01b7c25f390345b14385f6f9e1640f48a5d9dc93
2023-03-21Add skip-sdk-check to extract_apks Pranav Gupta
Add skip-sdk-check to skip checking the SDK version when extracting an APK/APEX from an App Set Bundle. This can be used when the platform SDK version is not defined and the APEXs/APKs use SHA based SDK versions. This check should not be set to true for non Beta dessert releases Bug: 274518686 Test: # Add SHA targeting modules to platform m SOONG_SKIP_APPSET_SDK_CHECK=true #Build Passes m SOONG_SKIP_APPSET_SDK_CHECK=false #Build Fails m #No config supplied, build fails Change-Id: I1919437d3410f09c991e1de39031bd88e1f8246a
2022-12-13Pass -t epoch to jetifier Colin Cross
Pass -t epoch to jetifier to get reproducible output files from it. Bug: 262448304 Test: builds Change-Id: I65d42e5d556f27e15e6700363840857c1a25da74
2022-10-23Add --add-exports= options to the java extractor invocation. Sasha Smundak
Long live Java modules system. Fixes: 254752344 Test: run build_kzip.bash Change-Id: I9c807afd22d7b2abc2af1f6ac7a0c1e4c8a8b3e1
2022-04-06Revert "Use kapt stubs for kotlin header jar for javac" Isaac Chiou
This reverts commit c6ef4853704080b1340170c5c30046cc4dacd418. Reason for revert: Multiple systemui presubmits are broken due to this change Bug: 228262695 Change-Id: I1efed519c49d8d0583815c7bf2b3801bf0ba12fa
2022-04-04Use kapt stubs for kotlin header jar for javac Colin Cross
When compling kotlin code with annotation processors we are generating java stubs for the kotlin sources using kapt, and parsing them in turbine when running the annotation processors. Passing --output to turbine will also compile the stubs into a header jar that can be used as a dependency to javac, allowing the javac and kotlinc rules to run in parallel. The turbine-apt header jar can't be used as the header jar for downstream modules as it doesn't contain the kotlin metadata needed by kotlinc rules, so the kotlinc gen-jvm-abi plugin output is still used for the module's final header jar. Test: TestKapt Bug: 222095735 Change-Id: I82d0900f3dc30f3e3ebd7cab0693dfe741d9b955
2022-03-25Use turbine instead of kapt for kotlin annotation processors Colin Cross
Follow Bazel by using turbine instead of kapt to run annotation processors. This still requires using kapt to generate java stubs of kotlin soruces, then uses turbine to run annotation processors on the java stubs and any java sources to generate sources and resources, and passes the annotation processor generated sources to kotlinc and javac. Bug: 225013372 Test: m checkbuild Test: TestKapt Change-Id: I9c6fc496a9fba64658bb062538bc5f7b9478b07a
2022-03-25Don't use ziptime or --temp_dir for turbine Colin Cross
Turbine sets dates to 2010 and doesn't need ziptime any more, and ignores the --temp_dir flag. Bug: 225013372 Test: m checkbuild Change-Id: I6122f27d873ca671050e4dc0d65641bb52e90e99
2022-03-18Don't pass static libs to r8 Colin Cross
r8 gets the static libs in the program jar, it shouldn't also get them as library jars. Keep a separate classpath for dexing that includes libs but not static_libs. Bug: 222468116 Test: m checkbuild Test: TestD8 Test: TestR8 Change-Id: Icca3393f496cbcadcc633f3b156761e6c145f975
2021-11-17Extract primary apk from apk set zip Colin Cross
Extract and install the primary apk normally, and then unzip the rest of them as a post install command. Bug: 204136549 Test: app_set_test.go Change-Id: I17437ff27f49df6bc91bdbbea6173b46c7d3ec4e
2021-09-20Enable compose kotlinc plugin when depending on the compose runtime Colin Cross
When a module depends on the compose runtime add a -Xplugin argument to the kotlinc flags that enables the compose compiler plugin. Bug: 196351110 Test: TestKotlinCompose Change-Id: I423a3c4d12df42804a24b672a40a165bc8dd165f
2021-06-14Add a build flag to always enable errorprone per-target Cole Faust
Currently, errorprone is only run if the RUN_ERROR_PRONE enviornment variable is true. Add a flag that individual modules can use to always enable errorprone. In a followup cl, I plan to add another flag that will force all errorprone checks to be errors, so that modules can be confident that they're not ignoring any errorprone checks. Bug: 190944875 Test: New unit test and manually Change-Id: Iab0c81642ed22a736add054147829e91a891d179
2021-03-25Support multiple rsp files in REParams Colin Cross
rewrapper supports a comma separate list of rsp files, replace REParams.RSPFile with REParmas.RSPFiles. Test: remoteexec_test.go Change-Id: I7850c071c23d368d6fad4480dd527d146c13c6d3
2021-03-18Move android package on top of remotexec Colin Cross
Remove the references to the android package in remotexec so that the android package can reference the remoteexec package. This will allow RuleBuilder to integrate directly with remoteexec. Bug: 182612695 Test: m checkbuild Change-Id: I15be5ef126d8aacbd605518638f341daf6f31bb3