I'm rewriting how globs work in soong to make them compatible with
hash-based ninja implementations. As part of this, I'm removing this
unnecessary usage of globs to make them simpler.
In this case, since we're already globbing the directory at analysis
time and causing soong to rerun, we can ensure the aapt2 action also
reruns by putting a hash of the glob results onto the command line.
Bug: 364749114
Test: m framework-res, touch frameworks/base/core/res/assets/test1.txt, m framework-res rebuilt framework-res.apk, rm frameworks/base/core/res/assets/test1.txt, m framework-res rebuilt framework-res.apk again
Change-Id: I4f666367a9a0fd0dfa42dc51ef3a788a02b41747
Skip combining jars into turbine-combined, combined, and withres jars
and instead collect transitive jars to use in the classpath and to
produce the final dexed jar.
This reduces the size of a `m checkbuild` in git_main by 11%, from
1300 KiB to 1154 KiB. It may also improve caching and reduce uplink
network bandwidth when building with RBE, as now the classpath inputs
to rules are themselves outputs of previous rules and so already in
the RBE CAS.
The downside is that the classpath inputs to each rule are now much
longer, increasing the Soong ninja file size 11%, from 4.6 GiB to
5.1 GiB. This could be mitigated in the future by supporting something
like depsets in the generated ninja file to reduce duplication.
Bug: 308016794
Test: TestSimple, TestKotlin, TestClasspath
Flag: build.RELEASE_USE_TRANSITIVE_JARS_IN_CLASSPATH
Change-Id: I2b7b4261375494370da70f98597c8719f1d561cf
The `m Run*RoboTests` test runner is no longer supported, remove the
code to generate the Make rules for it.
Also reduce the number of combining steps by passing the extra jars
that need to be combined into the compile step.
This relands Icf05079bf570bed7a10962cbf03459bd53c51f99 with a fix to
reorder the instrumented app classes after dependency classes.
Test: atest --host SystemUiRoboTests
Flag: EXEMPT refactor
Change-Id: I174ceb95af5557e1859eeb12a2f5fac2332975a8
collectTransitiveHeaderJarsForR8 visits direct dependencies and collects
all transitive libs and static_libs header jars. The semantics of the
collected jars are odd (it collects combined jars that contain the static
libs, but also the static libs, and it collects transitive libs dependencies
of static_libs), so these are only used to expand the --library arguments
to R8. Rename the method and all the fields it uses with a "ForR8"
suffix to avoid confusion when more transitive header jar collection is
added to support transitive classpaths.
Bug: 308016794
Test: all soong tests pass
Change-Id: I291a86fbbc2e2f088598fb309d1b992080d60941
Pass the name of Soong's checkbuild target for each module to
Make so that it can depend on it from the main checkbuild rule.
This will give better control over which files get built, allowing
checkbuild to skip the jar combining step when transitive classpath
jars are enabled. The per-module checkbuild targets are passed to
make instead of added directly as a dependency of checkbuild in order
to maintain the existing behavior of only building modules exposed
to make in checkbuild.
Also tweak the existing calls to CheckbuildFile and add
InstallFileWithoutCheckbuild to match the files that are
in the Make-based checkbuild.
Bug: 308016794
Test: m checkbuild
Change-Id: Ic5140819381d58f4d00f23a7a12447950c4cf268
The IDEInfo() methods read properties. To make those properties
configurable, we need a context to evaluate them with.
Bug: 362579941
Test: m nothing --no-skip-soong-tests
Change-Id: I26d4b7084439b3006e50b02277298f74a929e1aa
Similar to I40f28075ce151e4be80d6cfc7ec173dfa46f9bbf, convert
more long-lived WritablePaths to Paths.
Test: all soong tests pass
Flag: EXEMPT refactor
Change-Id: I9be448f811694fe0524fbbd7c5d4553cf69d533a
The information will be used for IDE autocompletion.
Test: {
"jars": [
"out/soong/.intermediates/prebuilts/misc/common/androidx-test/androidx.test.core-nodeps/android_common/turbine-combined/androidx.test.core-nodeps.jar",
"out/soong/.intermediates/prebuilts/misc/common/androidx-test/androidx.test.core-nodeps/android_common/busybox/R.jar"
],
"path": [
"prebuilts/misc/common/androidx-test"
]
}
Bug: 356572093
Change-Id: I62166c6d5cfa1cf0c49adf42d5d8b4ca40ab5a11
Convert JavaInfoProvider to return a *JavaInfo instead of a JavaInfo.
This will reduce copying when reading the provider, and also allows
JavaInfo to recursively contain a depset of JavaInfos from
dependencies.
Bug: 308016794
Test: go test ./java/...
Flag: EXEMPT refactor
Change-Id: Ibf6d9b797f760ad1fe815d59839839fdfad91733
ResourceProcessorBusyBox generates the R.jar binary from R.txt without
creating an intermediate R.srcjar file. Disable this behavior in kythe
builds (ctx.Config().EmitXrefRules()) to support xrefs to R imports
Test: XREF_CORPUS=$internal_corpus m nothing
Test: aninja -t query out/soong/.intermediates/frameworks/libs/systemui/animationlib/animationlib_tests/android_common/animationlib_tests.kzip
Test: verified that an R.srcjar is present in its deps
Bug: 354854007
Change-Id: I2d63c3393c5bc58103c267c4593172ce77fbc79c
Resource_dirs is queried using PathsWithOptionalDefaultForModuleSrc,
which includes all the infrastructure to resolve module references,
but needs to be tagged android:"path" to be able to add the module
references as dependencies.
Test: Manually
Change-Id: Ie3f75332c9a4cc0ee4b4c93268188440ff7ce249
Since only a single rule can write to a given WritablePath, it is
unecessary to hold on to the WritablePath once the rule has been
created. Keeping a WritablePath causes complications, as it
prevents using the input Path as the output when no modifications to
the input file are necessary. The normal pattern should be to create
a WritablePath using PathForModuleOut, build the rule that writes to
the WritablePath, and then store the WritablePath as a Path for use
as an input to any future rules.
WithoutRel previously only existed on OutputPath, which required
keeping the output path of the module as an OutputPath for as long
as possible in order to call WithoutRel on it at the end of the module.
Add WithoutRel to Path, make it always return a Path type, and implement
it on all the types that implement Path by using a helper in basePath.
Replace long-lived WritablePaths with Paths.
Test: all soong tests pass
Flag: EXEMPT refactor
Change-Id: I40f28075ce151e4be80d6cfc7ec173dfa46f9bbf
This change modifies the aconfig and aapt2 build rules to support
resources flagging in aapt2.
Implementation details:
- Modify the aconfig text rule to include flag permission in the output
text file
- Pass the `--flags-packages` argument to `aapt2 compile` command,
similar to what is currently being done in the `aapt2 link` command
Bug: 344979955
Test: m nothing --no-skip-soong-tests
Change-Id: I3b0b1fd6dcd691b7cc50ba3d081ecafd82c2c904
In the context of incremental soong, the output files
inter-module-communication will be through OutputFilesProvider.
The OutputFileProducer interface will be deprecated.
Test: CI
Bug: 339477385
Change-Id: I3c9f0b766325dd490bc903dc65259c3953d34606
In the context of incremental soong, the output files
inter-module-communication will be through OutputFilesProvider.
The OutputFileProducer interface will be deprecated.
Test: CI
Bug: 339477385
Change-Id: I51ccf59f97cb8a790642cb4463c479feaf18058a
flags_packages property was added to supports flagging the manifest
files. The listed names of `aconfig_declarations` modules are passed to
aapt2. However, this is currently scoped to the module level, and is not
propagated to the reverse dependencies. In other words, if the manifest
is flagged with `featureFlag` property, all of the reverse dependency of
the android_app/android_library should specify `flags_packages` property
in the bp module definition, leading to huge toil for the users.
In order to resolve such inconvenience, this change modifies the build
rules of android_app,android_library and runtime_resource_overlay such
that flags_packages of the static dependencies are collected.
Test: Patch ag/27816261 && m Settings --no-skip-soong-tests
Bug: 347289274
Change-Id: I4c3855541dd09cb72293515eb2626eaf4ae8c0df
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