android.ModuleBase already calls aconfigUpdateAndroidBuildActions()
that is the same with CollectDependencyAconfigFiles(). Remove the
CollectDependencyAconfigFiles() to avoid duplication with
aconfigUpdateAndroidBuildActions().
To make the aconfig information available in
GenerateAndroidBuildActions() of all modules, call
aconfigUpdateAndroidBuildActions() before calling
GenerateAndroidBuildActions() of each module.
Also, we don't need SetAconfigFileMkEntries(), which is a duplicate
of aconfigUpdateAndroidMkData()
Bug: 335363964
Test: diff `adb shell printflags` before and after the change.
Change-Id: I52808e442e9fed7db1eae7b7c5ed0b1c5ba74f5d
Some of the androidx libraries have a transformed manifest
alongside that needs to be used to avoid introducing extra
androidx.startup provider entries. Add a manifest property
that allows overriding the manifest provided by the aar file.
Bug: 336549758
Test: examine PermissionController.apk
Ignore-AOSP-First: submitting in topic with internal CL
Merged-In: I5c8daf810d2fde9a150cbfe48b4f4216f5d1ba0d
Change-Id: I5c8daf810d2fde9a150cbfe48b4f4216f5d1ba0d
Non final ids is a prerequisite for using optimized shrinking and
it will soon be a hard R8 error if you pass final ids in R classes
with optimized shrinking enabled.
Bug: 325905703
Test: SystemUIGo with optimized shrinking
Change-Id: I364edc5a0b22be7b4d737c2aa470a84704d05283
Bug: 331528424
Test: m --no-skip-soong-tests
Ignore-AOSP-First: Depends on internal changes. Will cherry-pick once merged.
Merged-In: Ied2821f11b6a5056ecf577e1e25765bc6dd212c0
Change-Id: Ied2821f11b6a5056ecf577e1e25765bc6dd212c0
This is a no-op change for a majority of cases.
Before this change, the contruction of the manifest check inputs is
confusing. It mutates uses_libs properties in place just for the
manifest check, by replacing module names with library names for
direct dependencies and merging library names from CLC for both direct
denpendencies and transitive denpendencies, and then constructs manifest
check inputs from those mutated uses_libs properties. This is
error-prone and leads to insistency: the goal is to check that the CLC
matches the manifest, but the inputs to the check don't reflect the CLC.
After this change, we no longer mutate uses_libs properties in place.
Instead, we maintain a separate list of missing denpendencies, and then
construct manifest check inputs directly from the CLC for all existing
libraries, no matter they are direct or transtive, and from the separate
list of missing libraries. This change makes the logic more
consistent and straightforward, and it also allows us to easily do the
next change, which is to propagate transtive missing denpendencies.
In fact, this change revealed several bugs around library optionality
and order in CLC construction, and fixed them.
Bug: 331528424
Test: m --no-skip-soong-tests
Ignore-AOSP-First: Depends on internal changes. Will cherry-pick once merged.
Merged-In: I0de82e76c47995b54aba9efd41538d950256a95f
Change-Id: I0de82e76c47995b54aba9efd41538d950256a95f
As part of aosp/3022586 where we added the idea of "test-only" modules
and top_level_test_targets, this CL implements that for java modules.
We let users set "test-only" on java_library, but not on other modules
where the module kind is implicitly test-only, like java_test.
The implementation, not the user decides it is test-only.
We also exclude it from java_defaults.
% gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind'
+--------------------------+----------+
| teams.kind | count(*) |
+--------------------------+----------+
| android_test | 1382 |
| android_test_helper_app | 1680 |
| java_fuzz | 5 |
| java_test | 774 |
| java_test_helper_library | 29 |
+--------------------------+----------+
% gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true and teams.kind not like "%cc_%" group by teams.kind'
+--------------+----------+
| teams.kind | count(*) |
+--------------+----------+
| android_test | 1382 |
| java_fuzz | 5 |
| java_test | 774 |
+--------------+----------+
Test: m nothing --no-skip-soong-tests
Test: go test ./java
Test: m all_teams
Bug: b/327280661
Change-Id: I9c3ad947dc3d68d6427abada27449526d69daa6b
androidx.annotation_annotation is used as a test data file, and
converting it from an android_library to an android_library_import
causes the relative path used in the test data path to change.
Clear the relative path in android_library_import the same way that
android_library and other java based modules do.
Also change the name of classes-combined.jar to the name of the
module so that the output file has the right name if there are no
static dependences that require running the merge_zips step.
Bug: 288358614
Test: TestAndroidLibraryOutputFileRel
Change-Id: I28210aa370a742d789102ff71db3685ca744878f
Add support for android_library_import to propagate the proguard specs
from its static dependencies.
Bug: 326265727
Test: TestExportedProguardFlagFiles
Change-Id: I174c1d7937a529958f8d240214b279062ef74868
Passing --shared-lib to aapt2 causes it to add an extra
onResourcesLoaded method that rewrites resources IDs to include
the package ID determined at runtime. ResourceProcessorBusyBox
has no equivalent functionality, so disable whenever --shared-lib
is found in aaptflags for now.
Fixes: 330646473
Bug: 331641946
Test: manual
Change-Id: Ibb0c2c7bf7a41ab294f5c84b4b6018cc8a63b0f4
If the flag is set we will:
- pass --optimized-resource-shrinking to the r8 invocation
- use non final fields for the generated R classes
- not pass the aapt2 generated proguard rules, R8 will do the tracing of xml files
Bug: 325905703
Test: This is simply passing the flag through to R8, this is off by default
Change-Id: Ib2043f3201578c3bcd39c1de9a524fd78f6d795c
Fix dependencies of android_library_import modules so that the -nodeps
modules created by pom2bp are no longer necessary. Provide transitive
manifests (b/288358614), combine static dependencies into the output
jars, and propagate uses_libraries and optional_uses_libraries from
dependencies.
Bug: 288358614
Test: TestManifestMerger
Test: TestAndroidResourceProcessor
Change-Id: Ief45169d04217826fbb21ba283602b38ef0dd3f6
This change adds the support that was added to android_app in
https://r.android.com/2854663 for android_library modules.
Implementation details:
- Move `Flags_packages` to aaptProperties, so that it can be utilized
for both android_app and android_library.
- Wrap `VisitDirectDeps` of aconfig_declarations to a function that
takes a ModuleContext as an input, so that it can be utilized in the
`GenerateAndroidBuildActions` of both android_app and android_library.
Test: m nothing --no-skip-soong-tests
Bug: 330222981
Change-Id: I8a755f5ca615c8a1651afcd2ec441fc9fbd82c61
Bug: 329762127
Test: cd build/soong/java ; go test -run TestJavaLibHostWithStem
Test: cd build/soong/java ; go test -run TestAppStem
Test: cd build/soong/java ; go test -run TestAndroidAppImport_ArchVariants
Test: cd build/soong/java ; go test -run TestOverrideAndroidAppStem
Test: cd build/soong/java ; go test -run TestOverrideAndroidApp
Test: cd build/soong/java ; go test -run TestPackageNameOverride
Change-Id: I8fbdc82116f9a0c68121fbbeb1ef4f78f2b6fea3
Reverse the order of transitive R.jar classpath entries so that
the R.jar from the current module comes first, and so that R.jar
from any direct dependency comes before the R.jar of any transitive
dependencies through the direct dependency. Also swap the order of
shared and static dependencies so that static dependencies come first
in the final classpath.
Bug: 294256649
Test: m javac-check
Test: TestAndroidResourceProcessor
Change-Id: Id9ea5b53ca563f79d0a25fb52b24552dbea70605
Use the R.txt files from aar imports directly instead of recreating
one using aapt2 from the embedded resources. Fixes an issue with
com.google.android.material where the jar was referencing
com.google.android.material.R.attr.theme, aapt2 was not producing
"int attr theme 0x0" in R.txt, but the aar's R.txt had it.
Bug: 294256649
Test: builds
Change-Id: Ibe1e5535a75eed59f3b8dbbc12eff9c07af51d37
At ToT, an optional_uses_libs is not added to the build time CLC if it
does not exist in the tree. One edge case here is
java_sdk_library_import, which might exist in the tree, but without an
implementation. This cause issues during analysis when we try to verify
the correctness of the build time CLC.
This CL disables dexpreopt if a dependency does not have an
implementation. To limit inadvertent side effects, this is restricted to
java_sdk_library(_import) module types. (more precisely, it is restricted
to java_sdk_library_import, since the source module type will always
have an impl)
Bug: 315802285
Test: Added a unit test
Test: m nothing
Test: printf debugging in internal main, verified that this CL does not
disable dexpreopt on any android app inadvertently
Change-Id: I173fc2f3ff654fe4091e9a43322164afd3222ee7
is_stubs_module property signifies whether the module compiles stubs or
not. The information is propagated to the reverse dependencies of the
java_library/java_sdk_library modules via JavaInfoProvider as
StubsLinkType, a ternary state that provides information about whether
the provided jars are compilation of stubs or implementation, or
unknown.
When java_sdk_library sets StubsLinkType, its state is Unknown as the
decision of providing stubs vs implementation jar differs by the reverse
dependency.
Note that this CL does NOT propagate the property up to its reverse
dependencies. This will be done in follow up CLs.
Test: m nothing
Bug: 310504781
Merged-In: Ic81488dbd1c9af1b5d31a33e5e9441d9f1416dbe
Change-Id: Ic81488dbd1c9af1b5d31a33e5e9441d9f1416dbe
--no-static-lib-packages was removed when compiling libraries with
use_resource_processor: true enabled, but that caused problems resolving
attributes of styleables. androidx.preference declares the "icon"
attribute inside a <declare-styleable>, but doesn't give it a format.
aapt2 refuses to create a new attribute for this case (b/131100106),
but without --no-static-lib-packages aapt2 can resolve the attribute
from the one defined in androidx.appcompat.
Bug: 294256649
Test: builds
Change-Id: I13661be83ba6501b0c2b1af8e632f260f405a370
Setting the RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT build flag will
change the default for use_resource_processor from false to true.
Bug: 294256649
Test: builds
Change-Id: If643bf8db9e2e039200f63f4aac226ed5b44d9e0
propagateRROEnforcementMutator walks dependencies of each module and
modifies them via SetRROEnforcedForDependent. That is unsafe in a
parallel mutator, as the same dependency could be being visited by
two parent modules at the same time. Don't mark it as a parallel
mutator.
Test: go test -race ./...
Change-Id: I9870aaa7d165bf72b751e3ceff5a2a3eb4d74ec4
This is a followup cleanup for aosp/2876754 and replaces panic with
ctx.ModuleErrorf. The latter creates a more expressive build error.
Implementation details
- export moduleErrorf interface from build/soong/android. This minimal
interface will be used as a parameter for `DexJarBuildPath`
- Add ModuleErrorf to the function signature of DexJarBuildPath. This
parameter only gets used for Import and SdkLibraryImport structs.
These two can have duplicate deapexer definitions, and ModuleErrorf
will be used to report that error
- Create a minimal implementation of `ModuleErrorf` in tests of java and
apex
Test: m nothing --no-skip-soong-tests
Change-Id: I0febec651f40c3f04deb957e64133c94b80fbd78
When --custom-package is specified as an aapt2 flag translate it to
--packageForR when running ResourceProcessorBusyBox.
Bug: 294256649
Test: m javac-check
Change-Id: I2c97c760ea8a0203790feda82b98e12c2dbd7b72
Convert all of the callers of OtherModuleProvider/OtherModuleHasProvider
to use the type-safe android.OtherModuleProvider API.
Bug: 316410648
Test: builds
Change-Id: Id77f514d68761a262d9ea830a601dbed804bbbe5
Convert all of the callers of Provider/HasProvider to use the type-safe
android.ModuleProvider API.
Bug: 316410648
Test: builds
Change-Id: I73479de1625fa2865b6c73444cd477e50d56dc5a
Convert all of the callers of SetProvider to use the type-safe
android.SetProvider API.
Bug: 316410648
Test: builds
Change-Id: If58f4b5355264ddab2045bc3591a4eac19cd58fc
Convert all of the callers to NewProvider and NewMutatorProvider
to use a generic type parameter instead of an example object.
Bug: 316410648
Test: builds
Change-Id: Ic9cdafc87336e26730d3fd596df05de0e7267542
TestAarImportProducesJniPackages was attempting to assert that an
aar_import module always had a JniPackageProvider, but was instead
asserting that the return type was always a JniPackageInfo. Since
ModuleProvider returned the zero value of JniPackageInfo even when
there was no provider that was always true.
Fix aar_import to always set JniPackageProvider.
Test: TestAarImportProducesJniPackages
Change-Id: Idaf106e14373490d4eb807892e174aaaf094bbcf
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.
Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7