Commit graph

283 commits

Author SHA1 Message Date
Jihoon Kang
59bb904d6c Merge changes from topic "aconfig_dump_map" into main am: 25c187cc7d am: 1ed5d5ca20 am: 1befeeb5e8
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2854663

Change-Id: I18069b9fa74f1c72527bff397c61bc5510e7a684
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-08 11:31:22 +00:00
Jihoon Kang
84b2589e6d Add aconfig flag support for android_app
This change adds an overrideable property flags_packages to android_app,
which is used to list the aconfig_declarations module names that the app
depends on. The build action of android_app is modified to pass all
flags text file provided by the aconfig_declarations to aapt2 link as
--feature-flags arguments.

Test: m nothing --no-skip-soong-tests
Bug: 306024510
Change-Id: I4924f88b9954950cc1936a472cd7ac70f41add5d
2023-12-07 23:01:26 +00:00
Colin Cross
3888f701bf Merge "Don't write transitive dependencies to Android-${TARGET_PRODUCT}.mk" into main am: 556ba81849 am: c65780626c am: bd149b1c8f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2842060

Change-Id: I6cbacf8aaaa93a4003d5479ca5408fd47aa02b04
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-30 02:10:44 +00:00
Colin Cross
312634eb0f Don't write transitive dependencies to Android-${TARGET_PRODUCT}.mk
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-11-29 10:31:13 -08:00
Inseob Kim
550a615b4d Merge "Add support for auto-generated characteristics RRO" into main am: b5d713f2cb am: 99913d4e59 am: 6b52e7aabe
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2817177

Change-Id: I7bca74e210529ae6c2fbcb7746e06b7d4a493e8c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-17 06:47:43 +00:00
Inseob Kim
34dc4cd738 Add support for auto-generated characteristics RRO
Setting Generate_product_characteristics_rro will automatically generate
an RRO package which contains resources with
'product="{PRODUCT_CHARACTERISTICS}"'. The RRO package will be installed
to /product partition. The app will be compiled with '--product
default', making the app identical to all targets.

Motivation for this change is to minimize divergence of system.img.

Bug: 294799593
Test: boot and idmap2 dump
Change-Id: I1371f7410a1ecf337e1f73214b024af39aa6d57a
2023-11-17 11:15:32 +09:00
Sam Delmerico
1f2d568105 Merge "transitive r8 flags for installable {android,java}_libraries" into main am: d9569528bd am: 0b74fbb608 am: 727dc7ce68
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2812555

Change-Id: I3a029e51decdbcc76959cc056c5c2c69cbfe77d7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-01 17:11:59 +00:00
Sam Delmerico
d9569528bd Merge "transitive r8 flags for installable {android,java}_libraries" into main 2023-11-01 15:29:11 +00:00
Sam Delmerico
c8e040c70f transitive r8 flags for installable {android,java}_libraries
Only android_apps were actually applying transitive proguard flags files
to their r8 invocation. This CL ensures that this also occurs for
installable android_libraries and java_libraries.

Bug: 302342049
Test: go test ./java
Change-Id: Ie94d688d04367ee3d39e7e760fb3003df5829951
2023-10-31 18:59:04 +00:00
Alix Espino
137c7c3fc8 Merge "add manifest_values application id property to soong" into main am: a9ead6ef2b am: f98019df2f am: e073f0f8dd
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2769927

Change-Id: Iba14d929eba0592507030e2dfe726491e3e31172
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-31 15:42:37 +00:00
Alix
96ea8845c5 add manifest_values application id property to soong
Bug:278905106
Test: go test ./java --run TestManifestValuesApplicationIdSetsPackageName
	and locally built a module and checked manifest pacakge_name
Change-Id: I5c8fd27c177b9e255dce197706f62580894008cb
2023-10-23 18:26:53 +00:00
Colin Cross
a2deb31959 Merge "Export resource processor R.jar files to ASfP" into main am: c292fa1797 am: 8b57d1d786 am: 81a4d1ee2f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2794454

Change-Id: Iabf13796e8a91e38332ec1c9140c10555b052d87
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-18 19:19:03 +00:00
Colin Cross
c292fa1797 Merge "Export resource processor R.jar files to ASfP" into main 2023-10-18 18:24:48 +00:00
Colin Cross
95b53b83eb Export resource processor R.jar files to ASfP
Export the R.jar files generated by ResourceProcessorBusyBox to
module_bp_java_deps.json for use by Android Studio for Platform.

Bug: 305997998
Test: examine module_bp_java_deps.json
Change-Id: I48e3e28b45219646765de7848ec9dbe77d14c662
2023-10-17 13:21:02 -07:00
Treehugger Robot
1881a83f05 Merge "Add assets property for Android apps." into main am: c82e844121 am: ab202d1aa2 am: e5d4f786c8 am: 2e2a37666f am: 45c943b958
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2786252

Change-Id: Ie0b10c2f2b24e8d626f0a7d8f6b3fd94cda7fdd6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-16 22:44:01 +00:00
Jiakai Zhang
ba82e28d5d Add assets property for Android apps.
This property is similar to `asset_dirs`, but for individual files. This
is especially useful when the user wants to pack generated asset files
into the APK.

Bug: 257532944
Test: m nothing
Change-Id: If3062124e9dedb41315dcaf5d379803e5419b8cd
2023-10-16 18:53:30 +01:00
Colin Cross
e331433dd9 Merge "Put shared library R.jar files in the classpath" into main am: 149f6f6f78 am: a43251d771 am: e88d5b1796 am: 0abb9e863b am: f4578a4787
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2787024

Change-Id: I22929b25c07d531d71ae9d077129b4d0a21341ee
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-13 20:53:38 +00:00
Colin Cross
8676c8cba5 Put shared library R.jar files in the classpath
When building with use_resource_processor: true R.jar files from
shared andoid_library dependencies need to be added to the classpath
so that the generated R classes can be referenced.

Bug: 294256649
Test: m DocumentsUIPerfTests
Change-Id: I30a6bddc3f378ecf58f142f94049e67ba33a47e3
2023-10-12 16:01:04 -07:00
Alix Espino
221b7393a0 Merge "Use an option struct in aapt.buildActions & manifestMerger" into main am: 37e64f9c91 am: a51e83ac06 am: aa0e12c22b am: 24520e5ab7 am: 2b38e79029
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2769926

Change-Id: Ie9ef8ad2c3e7e93ac15a58e689f8eea11af1f78f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-12 05:33:33 +00:00
Alix
f7a1027c6b Use an option struct in aapt.buildActions & manifestMerger
Change-Id: Ia056ab321e1fd146ed0cdb98fc2d4455601f648c
Test: Treehugger
2023-10-10 14:31:03 +00:00
Zi Wang
e2929e42a4 Merge "Always drop deps from android_library with no srcs" into main am: 2201343fce am: 50225c86b6 am: 965367f3e0 am: 489210e8c4 am: 4230ef999f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2765453

Change-Id: I852f8ebfdd9974e8ab21c47e85b2a107876bdba3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-28 20:44:34 +00:00
Zi Wang
2201343fce Merge "Always drop deps from android_library with no srcs" into main 2023-09-28 16:16:51 +00:00
Romain Jobredeaux
49c184262f Merge changes from topic "bazel_framework_res" into main am: 641b62b205 am: b0e61183f3 am: f1a3d7a303 am: ae9096771c am: bb53a4fc75
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2720593

Change-Id: I9a9b31f51bced57a22db829cdf0dee58fd11f200
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-28 01:58:21 +00:00
Romain Jobredeaux
641b62b205 Merge changes from topic "bazel_framework_res" into main
* changes:
  bp2build support for framework-res
  Keep rules_testing BUILD files
2023-09-27 20:52:50 +00:00
Zi Wang
1066479258 Always drop deps from android_library with no srcs
android_library does not accept deps when there are no srcs because
there is no compilation happening. The libs of android_library module
are unnecessary as deps on the android_library since they aren't
being propagated to any dependencies.
So we can drop deps here.

Test: the updated test case and CI

Bug: 302290600

Change-Id: Ib43a1c273a5f3b3e0aa6f29f4e8569ad3487e451
2023-09-27 12:36:36 -07:00
Romain Jobredeaux
d5d7e2bc72 Merge "Do not convert android_library_import with no aars." into main am: 832e131725 am: 51cab22f4e am: 2682639f03 am: f1037ec0eb am: 8d9d976c0d
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2760791

Change-Id: I039fd28954fbe6fa0b9900090d2d3fa29b6a9578
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-27 00:26:56 +00:00
Romain Jobredeaux
9c06ef353b bp2build support for framework-res
Change-Id: I5b32a702e02b5f1ec08d5608d766a8a0c08d845c
Bug: 276928228
Bug: 297356405
2023-09-26 15:06:50 -04:00
Romain Jobredeaux
afc5d27ab0 Do not convert android_library_import with no aars.
Bug: 301007952
Change-Id: Ia32d47eeb1a888ea2555d5ca08f56f191c040bc7
2023-09-22 15:52:59 -04:00
Alix Espino
b8f84acee8 Merge "Mark android_* modules with java_resources as unconvertible" into main am: c62b27a7ea am: ea88c79b2e am: 540f688f3f am: 0f75212971 am: 4a60c10598
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2752994

Change-Id: Ie0b328aee779de433b286d2f7e612b902a7f19ef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-22 18:13:02 +00:00
Alix
ee51bd6588 Mark android_* modules with java_resources as unconvertible
Change-Id: I9da921feaf9edb5fe7d1b1cb733494f90d8c64b3
BUG: 300470246
2023-09-21 03:58:24 +00:00
Christopher Parsons
b8db405c7b Merge "Have ConvertWBp2build use Bp2buildMutatorContext" into main am: c331812a59 am: 95f97af223 am: 88db04e1a9 am: 5b60cdaa36 am: 097399434f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2756986

Change-Id: I3bfd6e81efefe823c8f7b443d28d8df593aad93d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-20 21:15:09 +00:00
Chris Parsons
637458d326 Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.

Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
2023-09-20 14:49:35 +00:00
Jingwen Chen
3284042a0e Merge "[bp2build] android_test bp2build." into main am: 088c4b652b am: 3aaf1a80bd am: 3a02b22205 am: cd2454b172 am: 278d4778c8
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2727561

Change-Id: I7594547b6f80d7b63cde2458d556ccad3b7d508e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-19 02:46:52 +00:00
Treehugger Robot
c9a581f5dc Merge "don't compress JNI libs extracted from aar_import" into main am: 35bc07cb2a am: 16542620eb am: fcc7fcf1eb am: 1edc01ae07 am: ed965f2258
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2636192

Change-Id: I2c8f767315f91cf3039b5a963f452ad62bde615b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-19 00:10:56 +00:00
Jingwen Chen
088c4b652b Merge "[bp2build] android_test bp2build." into main 2023-09-18 23:27:14 +00:00
Treehugger Robot
35bc07cb2a Merge "don't compress JNI libs extracted from aar_import" into main 2023-09-18 18:20:52 +00:00
Jingwen Chen
e12c083198 [bp2build] android_test bp2build.
android_test is just an android_app, but the test bits are handled
purely in Starlark (tradefed_test_impl).

This enables building HelloWorldTests (android_test) with Bazel.

Bug: 297030120
Bug: 297029612
Test: WIP
Change-Id: I6d287c94b31698ea247da48e4cd6b5a75bc71e11
2023-09-18 12:39:06 +00:00
Treehugger Robot
2444405e7a Merge "export_proguard_spec for libs deps" into main am: b4cd93ccc0 am: 671d826bba am: 69ecb6812f am: fe966999ba am: 1421dac199
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2691152

Change-Id: I2b7029ea7d610f541586029459bbaae7ddb1a839
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-18 20:14:15 +00:00
Treehugger Robot
b4cd93ccc0 Merge "export_proguard_spec for libs deps" into main 2023-08-18 18:17:19 +00:00
Sam Delmerico
95d709402a export_proguard_spec for libs deps
Add a property to export proguard flags files for libs dependencies.
Currently only proguard flags files from static deps are propagated up
to reverse dependencies, but it is necessary sometimes to have flags
from libs dependencies also be propagated.

Bug: 289087274
Test: go test ./java
Change-Id: Ic0aa22b086792bf322041aa5780db6c4f4eb2770
2023-08-18 15:43:56 +00:00
Romain Jobredeaux
f0f822d4dc Merge "Support asset_dirs property in bp2build for android_{app,library}" into main am: 491fa2fe50 am: 67a98d3520 am: 6a5370155c am: ed541ef3d1 am: dfdd351c73
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2715093

Change-Id: I7927ebe2107ee9bd9faab397ab6296f9fc7656fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-17 20:06:08 +00:00
Romain Jobredeaux
7a71e07040 Support asset_dirs property in bp2build for android_{app,library}
Bug: 276928228
Test: Unit Tests
Change-Id: I6a2899de21e046e54cd0cd71314bf7aec4a470f6
2023-08-17 10:18:55 -04:00
Colin Cross
9b419ad17f Merge "Don't generate aapt2 srcjars when using resource processor" into main am: 002764c8ee am: 1a436c9b61 am: c2bb066321 am: 005bef73b0 am: e6c9c91cb9
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2690449

Change-Id: Ia0223900eac77f27ae8cce63607f523c434d8217
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-08 22:21:24 +00:00
Liz Kammer
c519bc6f28 Merge "Add unconverted reason for jarjar incompatibility." into main am: 6b6b150d0a am: 7d941462bb am: 1397a3a96b am: 472f943b6d am: 44536d9bfa
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2696067

Change-Id: I7d831ad01c92b86d585764dc8cbcffa58a649353
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-08 20:48:44 +00:00
Colin Cross
002764c8ee Merge "Don't generate aapt2 srcjars when using resource processor" into main 2023-08-08 18:57:02 +00:00
Liz Kammer
7f375869ab Add unconverted reason for jarjar incompatibility.
Test: m bp2build
Change-Id: I112b84fa53f57b9df2bd1e1616012fe55b48001e
2023-08-04 16:39:57 -04:00
Colin Cross
f3b7bada56 Don't generate aapt2 srcjars when using resource processor
When using resource processor the R.class files are generated
directly, and the R.java files generated by aapt2 are unused.  These
files can huge, reaching 500 MB for some modules and 76 GB across
all modules for a checkbuild on internal main.  They will be deleted
after zipping into srcjars after Ie5143e1e4b36ca1f4e45b001d79aca5379063517,
but we can skip generating them completely for modules where resource
processor is used.

Bug: 284023594
Bug: 294285775
Test: m checkbuild
Change-Id: If5e3fd1d25c6c7860898776ecdd392be8850c17c
2023-08-02 21:50:38 -07:00
Treehugger Robot
245482e039 Merge "Move android_library resource handling to Bazel's ResourceProcessorBusyBox" into main 2023-07-26 00:34:57 +00:00
Colin Cross
4eae06dcc9 Move android_library resource handling to Bazel's ResourceProcessorBusyBox
The R.Java files generated by aapt2 link --no-static-lib-packages
cause scaling problems by combining all resources into every package
listed in a dependencies' AndroidManifest.xml file.  For SystemUI-core
this results in 74 R.java files, each with 76k lines, and takes 20
seconds to compile in javac.

Both AGP and Bazel have workarounds for this that avoid using the
R.java files generated by aapt2, instead generating more efficient
R.class files directly based on the R.txt file.

Bazel uses the ResourceProcessorBusyBox tool that is already present
in our tree to process the resources.  Reuse the same tool in Soong
to create the R.jar.

The more efficient R.class files require modifiying source files
that use incorrect packages to refer to resources.

Bug: 284023594
Test: TestAndroidResourceProcessor
Change-Id: I026073b40dabcfdb10e5d7a52e9348205b0e9a66
Merged-In: I026073b40dabcfdb10e5d7a52e9348205b0e9a66
2023-07-25 21:30:21 +00:00
Colin Cross
17f4f1cea9 Merge "Move android_library resource handling to Bazel's ResourceProcessorBusyBox" into main 2023-07-25 16:50:35 +00:00
Treehugger Robot
f360471575 Merge "Track transitive usage of aconfig flags and add LOCAL_ACONFIG_FILES to Android-<product>.mk" into main am: 8bad43ad53 am: a4f896ab0d am: fdfe8d1dbb am: a0954b57f4 am: ec92e4b766
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2645432

Change-Id: If84e0d87ca4494a647d7e79d121c12083ca7c391
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-21 17:22:57 +00:00
Colin Cross
039d8dfb67 Move android_library resource handling to Bazel's ResourceProcessorBusyBox
The R.Java files generated by aapt2 link --no-static-lib-packages
cause scaling problems by combining all resources into every package
listed in a dependencies' AndroidManifest.xml file.  For SystemUI-core
this results in 74 R.java files, each with 76k lines, and takes 20
seconds to compile in javac.

Both AGP and Bazel have workarounds for this that avoid using the
R.java files generated by aapt2, instead generating more efficient
R.class files directly based on the R.txt file.

Bazel uses the ResourceProcessorBusyBox tool that is already present
in our tree to process the resources.  Reuse the same tool in Soong
to create the R.jar.

The more efficient R.class files require modifiying source files
that use incorrect packages to refer to resources.

Ignore-AOSP-First: merge conflict
Bug: 284023594
Test: TestAndroidResourceProcessor
Change-Id: I026073b40dabcfdb10e5d7a52e9348205b0e9a66
2023-07-20 21:39:37 +00:00
Joe Onorato
6fe59eb7f0 Track transitive usage of aconfig flags and add LOCAL_ACONFIG_FILES to Android-<product>.mk
Bug: 283910439
Test: m nothing (runs soong tests)
Change-Id: I59f9bef7b7c502565d531a5685c002a177e0a77c
2023-07-20 11:33:06 -07:00
Jihoon Kang
5938ef7cf7 Merge "Fix stem to be propagated to output jar name in java_library" into main am: ef5d8278be am: 258edea6f6 am: 70de94a1e0 am: 0f00e9c056 am: e6d26a02db
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2646424

Change-Id: I06aaf6ee150c64fa51aa619999c13c4303e80e1f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-18 22:20:34 +00:00
Jihoon Kang
ef5d8278be Merge "Fix stem to be propagated to output jar name in java_library" into main 2023-07-18 18:26:36 +00:00
Colin Cross
e699b48df5 Merge changes Ied0a6cfe,I8c025efe into main am: adb892c539 am: d4875a4ae6 am: 4bc82d4f82 am: 52b380f33a am: 41fe9dc4fd
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2658796

Change-Id: I935488792818808bc80b143adaefd958fd1ee2c9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-17 22:14:29 +00:00
Jihoon Kang
1bfb6f231e Fix stem to be propagated to output jar name in java_library
Currently, java_library.stem property is not correctly reflected in the
output jar name in java_library when the module specifies
java_resource_dirs property. This change fixes the unexpected behavior
so that setting the stem property behaves as expected.

Test: go test ./java && m
Bug: 285843207
Change-Id: I0941fcea83c92f4c42ae415aa6ad9125da5cf57b
2023-07-14 21:41:46 +00:00
Colin Cross
cb49a6f8fb Merge "Revert "Use depsets for transitive manifests and assets"" into main am: 0a30ce7c4b am: 20d572b050 am: e5dcad264d am: 9addd4b924 am: a90456ae99
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2658795

Change-Id: Ice11213c12da0d79b897c9a38234f90aeb91c436
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-14 20:39:16 +00:00
Colin Cross
ab8d138d42 Reland: Use depsets for transitive manifests and assets
Instead of rolling assets and manifests up through each static lib,
provide them as a DepSet.  This will help with the next patch, which
needs to pass all the transitive manifests and R.txt files together.

This relands Id8b3aa2bed3771e82ab6bde192c9b43baa38b54c with a fix
to include additional manifests from dependencies in the final
manifest merger.

Test: app_test.go
Test: TestManifestMerger
Change-Id: Ied0a6cfee2f18e87188db145b9411d4a903ab6c9
2023-07-14 11:26:43 -07:00
Colin Cross
d8c711f884 Revert "Use depsets for transitive manifests and assets"
This reverts commit 4c90f99cb3.

Reason for revert: b/291252863

Change-Id: I646b039a305a1297167e0c56b0bce0f541da260d
2023-07-14 15:52:41 +00:00
Colin Cross
c7b0295c62 Merge "Use depsets for transitive manifests and assets" into main am: 654f176379 am: b54cec3cb9 am: 44891a09ac am: 5bf41f6f96 am: 0b6b095c7f am: 3b4b912b39
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2633850

Change-Id: Ie77c6c6b2d8b6bfa000628fa8e366ef5dd2a8b7d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-14 00:30:27 +00:00
Colin Cross
4c90f99cb3 Use depsets for transitive manifests and assets
Instead of rolling assets and manifests up through each static lib,
provide them as a DepSet.  This will help with the next patch, which
needs to pass all the transitive manifests and R.txt files together.

Test: app_test.go
Change-Id: Id8b3aa2bed3771e82ab6bde192c9b43baa38b54c
2023-07-11 09:54:59 -07:00
Sam Delmerico
80ee45ccc9 don't compress JNI libs extracted from aar_import
APKs expect JNI libs in the libs folder to be stored uncompressed, so we
should not compress libs that we extract from the AAR.

Bug: 280339573
Test: m AiWallpapers before this change &&
  compare to AiWallpapers with ag/22948656
Change-Id: I63baa3763bc01c74d8df9b0b3e035ea50c31904c
2023-06-22 15:38:46 -04:00
Eric Miao
1957e6eeb9 Merge "Revert "Revert "Enable compact resource entries for aapt linking""" 2023-06-22 16:49:11 +00:00
Alix
a381cd1973 Delete android/rules.bzl file
Bug: 277800767
Test: treehugger
Change-Id: I578bf63e33d15219812c2c17117186c74323d8d3
2023-05-10 15:33:10 +00:00
Romain Jobredeaux
2eef2e13e9 Bp2build support for sdk_version and java_version.
This CL adds java_version and sdk_version support to bp2build
converters for
   - java library
   - java binary
   - android library
   - android binary
   - android library import

Although java import doesn't support java_version and sdk_version, the
neverlink java_library wrapper around a java_import must specify a
sdk_version when targetting a device. "none" is used by convention.

Change-Id: I22a69dea2e351858368df69ed6a703b568d613ea
Bug: 215230098
Test: Presubmits
2023-04-11 21:05:48 -04:00
Eric Miao
40eab20c34 Revert "Revert "Enable compact resource entries for aapt linking""
This reverts commit 825cff4169.

Reason for revert: Failed test has been fixed - b/275572186

Change-Id: I661206f4e0e783a5c403ac15ed33a93ba3acaf40
2023-03-30 16:57:37 +00:00
Spandan Das
a26eda7f2c Update max_sdk_version from SdkSpec to ApiLevel
max_sdk_version signifies device version and does not need an sdkKind to
describe it fully. Update the type and cleanup existing usages. As a
side benefit, we also get better error handling since users can no
longer enter something like `public_30` as a valid max_sdk_version in bp
files

Bug: 208456999
Test: no change in ninja file (this should be a no-op)
Test: TH
Change-Id: I304b5ad802bde200137d8e225182828dfd6f7227
2023-03-23 19:38:56 +00:00
Spandan Das
ca70fc40bd Update target_sdk_version from SdkSpec to ApiLevel
target_sdk_version signifies device version and does not need an sdkKind to
describe it fully. Update the type and cleanup existing usages. As a
side benefit, we also get better error handling since users can no
longer enter something like `public_30` as a valid target_sdk_version in bp
files

Test: m nothing
Test: no change in ninja files (this should be a no-op)
Bug: 208456999

Change-Id: I3c19245e29184bd9e5660ad8981966f64dfa9424
2023-03-23 19:31:17 +00:00
Spandan Das
8c9ae7ed67 Update min_sdk_version from SdkSpec to ApiLevel
This relands aosp/2457063. The original change broke T and U since those
branches still contain soong modules of type (kind+level). Those soong
modules have been cleaned up now

Test: Used go/abtd to test T and U branches with this change

Bug: 208456999
Change-Id: I0ef7933c055f88cb512a02108f1173e51156ef1c
2023-03-22 20:15:45 +00:00
Spandan Das
b74d1e1d91 Revert "Update min_sdk_version from SdkSpec to ApiLevel"
Revert submission 2457063

Reason for revert: Broken udc-dev

Reverted changes: /q/submissionid:2457063

Change-Id: Id6349fc1318877044af713c914a0afd437d3d2d5
2023-03-21 01:36:47 +00:00
Spandan Das
e773739787 Update min_sdk_version from SdkSpec to ApiLevel
min_sdk_version signifies device version and does not need an sdkKind to
describe it fully. Update the type and cleanup existing usages. As a
side benefit, we also get better error handling since users can no
longer enter something like `public_30` as a valid min_sdk_version in bp
files

Will do a similar cleanup for targetSdkVersion and maxSdkVersion in a
followup CL

Test: m nothing
Test: no change in ninja files (this should be a no-op)
Bug: 208456999

Change-Id: Ie6ae7e267d093c5e4787e82685daaca1021d202e
2023-03-20 16:51:32 +00:00
Alix
3254002a7c Create helper function for BazelTargetModuleProperties in java/android
Prevents inconsistent load locations from being added for java_library,
android_library, kt_jvm_library targets that are generated in multiple
places.

Change-Id: I66ae5af137d7dff3f6fa6660dee539cf9ab22b9e
Test: go test ./bp2build
2023-03-16 21:29:01 +00:00
Alix
75db7840ab Created kotlinAttributes struct
makes it clearer which attributes are kotlin specific
embedded within javaCommonAttributes since both
java_* and android_* use kotlin.

Change-Id: Ib7c9b912a9901cd1c3d150ab1e0a79011d8e07de
Test: go test ./bp2build
2023-03-08 17:15:10 +00:00
Spandan Das
0cd201c6b5 Merge "Update usages of min_sdk_version that relies on (kind+level)" 2023-02-27 18:39:11 +00:00
Spandan Das
50885c0524 Update usages of min_sdk_version that relies on (kind+level)
The type of min_sdk_version is being migrated from
android.SdkSpec(kind+level) to android.ApiLevel(level). This affects the
{min|target}-sdk-version aapt2 flag for vendor modules. For these
modules, if min_sdk_version is not set in Android.bp files,
MinSdkVersion would default to SdkVersion, and therefore would get
access to the sdkKind it was compiling against.

To accomodate the upcoming change of min_sdk_version to ApiLevel,
explicitly use SdkVersion to determine the `min-sdk-version` flags for
modules targeting `current`.

Bug: 208456999
Test: no change in ninja files (this should be a noop)
Change-Id: Ie2924698687597cdd572d4bb4c687d0b1569c4b8
2023-02-25 00:24:02 +00:00
Spandan Das
6450b555b5 Add documentation for target-sdk-version flag
This is using min_sdk_version and not target_sdk_version value from
Android.bp. Add documentation on why it has been implemented as such.

Test: N/A
Change-Id: I7da38ed351562dc530cde4c0d6bf7bd6b691f01d
2023-02-25 00:04:45 +00:00
Sam Delmerico
41f9b734bb Merge "transitive Java deps for r8" 2023-01-25 16:05:43 +00:00
Alix
36795a74dc bp2build support .kt in android_library
Bug: 258690851
Test: bp2build tests and built target renderscript_toolkit
Change-Id: I43ddf5637c97e4849b63abd2423f29519d44c28f
2023-01-24 14:53:44 +00:00
Sam Delmerico
9f9c0a22fa transitive Java deps for r8
The -libraryjars argument to r8 was missing transitive dependencies, and
so complained when there were classes used in the program JAR which were
not provided via libraries. This CL propagates transitive dependencies
to the r8 command to reduce the warnings that are generated for missing classes.

Bug: 242088131
Change-Id: Ifad7bc7c5d406e3de8d98ea963c97e88c84b45a1
2023-01-20 17:05:14 -05:00
Alix
14101de2e1 bp2build support libs for *->android_library_import
Test: bp2build tests
Bug: 258688914
Change-Id: Ibeae04e4c006f84f902774821c92f463a7c709eb
2023-01-17 15:55:07 +00:00
Romain Jobredeaux
5ccb460c42 Use centralized rules.bzl file for android rules in bp2build.
Change-Id: I6e4837d8b6715960337d0db9b36f8137efb5673e
2023-01-11 16:29:12 -05:00
Alix
82fb94e91e support libs for android_library
adds support for *-> android_library and android_library->* edges

Change-Id: I41d4e1d1b8106a17e67951d47e67b59ef3170d17
Test: manually inspected build files for libWallpaperPicker & android-suppor-v4
2023-01-05 21:13:57 +00:00
Colin Cross
4a80a158d4 Don't add dexpreopt compat deps to android_library modules
android_library modules are only dexpreopted when built into an app,
and the app will already get the dexpreopt compat dependencies itself.
Adding the compat dependencies to android_library modules causes
circular dependencies when the android_library is used to build
part of the framework, which is then used to build the compat libraries,
which is added as a dependency to the andorid_library.

Test: TestUsesLibraries
Change-Id: I3aca780858c7e5f19d270bcbbe18e6cff8616b43
2022-12-21 21:56:16 -08:00
Jared Duke
5979b30170 Revert "Revert "Include proguard flag files from transitive java_library deps""
This reverts commit 6f7e288fb5.

Reason for revert: Downstream proguard usage has been fixed.

Change-Id: I3667e7e908eebc62c640b42cb96b04993fc66e45
2022-12-19 23:05:28 +00:00
Colin Cross
ed8b52ca27 Merge "Revert "Include proguard flag files from transitive java_library deps"" 2022-12-17 03:15:36 +00:00
Colin Cross
6f7e288fb5 Revert "Include proguard flag files from transitive java_library deps"
This reverts commit 9c54f032b9.

Reason for revert: b/262940536

Bug: b/262940536
Change-Id: I8140eacc7ca8716f799561412cb5cef29df35d29
2022-12-17 03:15:22 +00:00
Treehugger Robot
c1260dd095 Merge "Include proguard flag files from transitive java_library deps" 2022-12-17 01:39:08 +00:00
Jared Duke
9c54f032b9 Include proguard flag files from transitive java_library deps
Ensure proguard flag files specified by java_library targets propagate
to downstream targets. This matches bazel behavior, as well as
behavior for transitive android_library deps.

Bug: 212623640
Test: m + presubmit
Change-Id: I61abaf1fd43d6f06bb610383751bb26e9a1bafd6
2022-12-16 14:09:08 -08:00
Alix
8062f4dee7 bp2build for java_library with .kt srcs or common_srcs
java_library modules with .kt srcs or common_srcs will be converted into
module type kt_jvm_library

Test: m bp2build, manually inspected build files for allowlisted modules
Bug: 258688914
Change-Id: I8293a11c8247b4b76358d0991f82c6b61b58adc3
2022-11-15 20:01:29 +00:00
Treehugger Robot
dfd50cc813 Merge "Change deptag for sdk deps to help distinguish" 2022-09-30 22:56:36 +00:00
Liz Kammer
ef28a4c5ce Change deptag for sdk deps to help distinguish
Test: m nothing before and after and diff build.ninja files
Change-Id: Idc4c7f86d3e626bd1ee2f90ae3c6fb755644a605
2022-09-30 11:01:18 -04:00
Harshit Mahajan
5b8b730cdd Enforce mainline modules to have latest target sdk version by default.
Due to GMS target SDK requirements (https://docs.partner.android.com/gms/policies/preview/mba#min-target-sdk)
we need to ensure all the  mainline packages to target latest API
level. Currently, the team chases each module to bump their target
API level.

Updating the build code to make sure that mainline modules
(i.e updatable modules) target the latest sdk version by default.
It would be by default set to 10000 before SDK finalization and updated to the new API level after finalization.

Effectively it would mean:
1. '10000' in aosp and internal master
2. Finalized number in development branches like "33" in "tm-dev"
3. As sdk hasn't been finalised in "udc-dev", it would be "10000"
which would be automatically updated to finalized version after sdk finalization.

For local development if the target sdk version is required to be set,
users would need to set Updatable flag to false.
Enforce_default_target_sdk_version flag needs to be used in bp file,
if this feature needs to be tested locally when updatable: false.

Bug: b/227460469
Test: m nothing
Change-Id: I05e0ae74ae44fd73df75e91b926bcc924446253f
2022-09-21 19:09:38 +00:00
Romain Jobredeaux
c9b2bba3cd Bp2Build converter for android_library_import and android_library.
Minor refactor of android_app converted to account for common attributes
between library and app.

Test: go test
Test: ../bazel/ci/bp2build.sh
Change-Id: I60b06eef6d2b9bc2d91f8b83522747ebbe76bbb6
Bug: 215230093
Bug: 215230095
2022-08-08 11:23:02 -04:00
Alexei Nicoara
075571b5e7 Merge "Overriding placeholder version in updatable apks" 2022-08-04 08:28:16 +00:00
Alexei Nicoara
69cf0f3756 Overriding placeholder version in updatable apks
Test: presubmit, checked the app version after build locally
Bug: 231691162
Change-Id: Icd242432540ea424235b226a45aac839dbc995be
2022-08-03 12:05:14 +01:00
Sam Delmerico
82602492fc copy JNI from AAR files to android_app APK
JNI libs present in AAR files are ignored in the build. If those
libraries are necessary, they must be manually extracted and a
prebuilt_cc_library module must be created for them. Instead, we can
extract these libraries and copy them to an output APK as part of the build.

Bug: 228848794
Test: created android_app that depends on an android_library_import with
  JNI embedded, and verified that .so libs are present in APK
Test: created android_app that depends on an android_library which
  depends on android_library_import with JNI embedded, and verified
  that .so libs are present in APK
Test: verified that multiple .so's from a single architecture are copied
  to APK
Test: verified that the absence of a jni/<arch> folder or files in the
  folder will cause the Ninja action to error
Change-Id: I242a862d7bd881f7a4a8c23493924d8fe441ea25
2022-08-02 16:12:06 -04:00
Sam Delmerico
af8bb7008a fix typo in AARImport prebuilt type assertion
This looks like it may have been a typo'd copy paste or maybe a name
change that got forgotten about.

Test: CI
Change-Id: I9f5c17f8e2d11b9cf6cd0da4685d719cdbbdcc11
2022-07-25 15:39:32 -04:00
William Loh
5a082f9a33 Propagate max_sdk_version to manifest_fixer
If max_sdk_version is included in Android.bp that value will now be
propagated to manifest_fixer.py. This value will then be used to
override any maxSdkVersion attribute set on permission or
uses-permission tags in the android manifest if maxSdkVersion="-1".

Bug: 223902327
Test: add max_sdk_version to Android.bp for test app
Test: create permission in test app manifest with maxSdkVersion="-1"
Test: run test to check maxSdkVersion=max_sdk_version
Change-Id: Ic533ef2a41b9ecc9ee68c69399026df47ee945b7
2022-06-28 22:07:23 +00:00
Vinh Tran
ce0781f8f5 Document AARImportProperties fields
Test: no testing necessary

Change-Id: Idff223f5c9a0b89cd5e0e2c8782c700d8fe9e9b3
2022-04-13 02:12:37 +00:00