Commit Graph

260 Commits

Author SHA1 Message Date
Cole Faust
219009f606 Merge "Make the java static_libs property configurable" into main 2024-09-06 18:36:35 +00:00
Cole Faust
b749347fa5 Make the java static_libs property configurable
Bug: 362579941
Test: m nothing --no-skip-soong-tests
Change-Id: Iccc93cf14753aae1adb26c6eedd00aabf1c2f6a6
2024-09-05 14:16:37 -07:00
Colin Cross
c9b4f6b502 Use transitive header jars in classpaths
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
2024-09-04 16:13:46 -07:00
Colin Cross
fdaa672ad1 Remove obsolete robolectric test runner integration
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
2024-09-04 15:47:11 -07:00
Yu Liu
c55b25f125 Merge "Move the caching/restoring code from soong to blueprint to fully skip build actions." into main 2024-09-04 22:01:33 +00:00
Yu Liu
26a716d5e5 Move the caching/restoring code from soong to blueprint to fully skip build actions.
Bug: 358425833
Test: Manually verified the generated ninja and mk files and CI.
Change-Id: Ieebb822c46f37c0ff55fad08531e9870a76cbd7b
2024-09-04 19:59:55 +00:00
Colin Cross
13d8e82c5e Merge "Rename collectTransitiveHeaderJars and friends to mention R8" into main 2024-09-04 17:34:03 +00:00
Colin Cross
ca3bf2be39 Merge "Move checkbuild targets of Soong modules into Soong" into main 2024-09-04 17:12:03 +00:00
Yihan Dong
a596b12878 Merge "Apply apimapper instrument tool on android tests" into main 2024-09-04 00:52:09 +00:00
Colin Cross
9ffaf28f5f Rename collectTransitiveHeaderJars and friends to mention R8
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
2024-09-03 14:52:26 -07:00
Colin Cross
a6182ab2fa Move checkbuild targets of Soong modules into Soong
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
2024-09-03 14:52:19 -07:00
Yihan Dong
8be09c2075 Apply apimapper instrument tool on android tests
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-09-02 09:02:08 +08:00
Jihoon Kang
85bc193805 Revert^4 "Implement detecting container violations."
This change introduces a method to detect violating inter-container
dependencies between modules. The method is run in
`ModuleBase.GenerateBuildActions`, after the container info provider is
set. Given that the provider of the direct dependencies would have been
set at this time, the method utilizes this information to determine
the violations, which are introduced in https://r.android.com/3141104.

Note that this enforcement does not turn all inter-container
dependencies as errors. Instead, it will only turn dependencies that
matches the pre-defined violations into errors. Even if the dependency
matches the violation, an error will not be thrown if the dependency
satisfies any of the exception functions (e.g. the dependent module is
stubs, or the two modules belong to the same apexes).

Test: m nothing --no-skip-soong-tests
Bug: 338660802
Change-Id: Ib9ddc0761fa46f1309b1a1a4f759d9a4e04fd70e
2024-08-29 17:55:00 +00:00
Priyanka Advani (xWF)
33b3a638a5 Revert^3 "Implement detecting container violations."
2a88491afc

Change-Id: Iba4527f391a093703978fe01177b56fec4604b28
2024-08-28 23:10:29 +00:00
Jihoon Kang
2a88491afc Revert^2 "Implement detecting container violations."
This change introduces a method to detect violating inter-container
dependencies between modules. The method is run in
`ModuleBase.GenerateBuildActions`, after the container info provider is
set. Given that the provider of the direct dependencies would have been
set at this time, the method utilizes this information to determine
the violations, which are introduced in https://r.android.com/3141104.

Note that this enforcement does not turn all inter-container
dependencies as errors. Instead, it will only turn dependencies that
matches the pre-defined violations into errors. Even if the dependency
matches the violation, an error will not be thrown if the dependency
satisfies any of the exception functions (e.g. the dependent module is
stubs, or the two modules belong to the same apexes).

Test: m nothing --no-skip-soong-tests
Bug: 338660802
Change-Id: Ia693c4a53369c757a3e96656a769405c759b111c
2024-08-28 18:01:25 +00:00
Satish Yalla
f2d6e5004f Merge "Revert "Implement detecting container violations."" into main 2024-08-28 05:48:21 +00:00
Satish Yalla
b2b1ef63e2 Revert "Implement detecting container violations."
This reverts commit bb678f82d6.

Reason for revert: Droidmonitor created revert due to b/362639013. Will be verifying through ABTD before submission.

Change-Id: I1dcb71672eeb44a17cf176d3731bcaf9aaf81edf
2024-08-28 05:10:31 +00:00
Treehugger Robot
26f071db92 Merge "Implement detecting container violations." into main 2024-08-28 04:39:12 +00:00
Cole Faust
b36d31d870 Add ctx argument to IDEInfo()
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
2024-08-27 16:04:28 -07:00
Jihoon Kang
bb678f82d6 Implement detecting container violations.
This change introduces a method to detect violating inter-container
dependencies between modules. The method is run in
`ModuleBase.GenerateBuildActions`, after the container info provider is
set. Given that the provider of the direct dependencies would have been
set at this time, the method utilizes this information to determine
the violations, which are introduced in https://r.android.com/3141104.

Note that this enforcement does not turn all inter-container
dependencies as errors. Instead, it will only turn dependencies that
matches the pre-defined violations into errors. Even if the dependency
matches the violation, an error will not be thrown if the dependency
satisfies any of the exception functions (e.g. the dependent module is
stubs, or the two modules belong to the same apexes).

Test: m nothing --no-skip-soong-tests
Bug: 338660802
Change-Id: I36e9cd956c5a076a53635be0c6ff27f77725516e
2024-08-27 17:30:42 +00:00
Jihoon Kang
fa3f0782f7 Remove suffix based stub matching logic
This change prevents non-stub modules with stub suffix from being
determined as the stub module, and instead makes the check more robust
by determining the condition based on the user-hidden
`Stub_contributing_api` property, which is only set for the stub
submodules generated by `java_sdk_library`.

Test: m nothing --no-skip-soong-tests
Bug: 361179822
Change-Id: I28a599c5b4fe1e8460e60580c0535aaf19e39ba3
2024-08-22 22:05:03 +00:00
Treehugger Robot
a5289ac9ef Merge changes Ia0e1b307,I63c7c33e into main
* changes:
  Define unstable container
  Define additional exception functions for container enforcement
2024-08-17 04:07:00 +00:00
Jihoon Kang
224ea08ee6 Define additional exception functions for container enforcement
These exception functions allow restriction to be loosened for some
inter-container dependencies.

Note that these functions are still no-op. Restriction enforcement will
be done in the child change.

Test: m nothing
Bug: 338660802
Change-Id: I63c7c33e33f271d4c2a84cc6070eb4896e030ab4
2024-08-16 22:57:39 +00:00
Treehugger Robot
08e76d9591 Merge "Run "ravenizer" on ravenwood jars" into main 2024-08-16 22:16:41 +00:00
Colin Cross
f0df94a76d Merge "Move kotlin stdlib to normal dependency tag" into main 2024-08-16 21:01:23 +00:00
Makoto Onuki
7ded3827a4 Run "ravenizer" on ravenwood jars
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-16 12:08:35 -07:00
Colin Cross
882d600d79 Move kotlin stdlib to normal dependency tag
The kotlin standard library was added with a custom dependency tag,
which then required special handling later.  We know up front whether
it will be treated the same as a static_libs or libs dependency, so
just reuse staticLibTag or libTag, and remove all the special handling.

Bug: 308016794
Test: TestKotlin
Flag: exempt REFACTOR
Change-Id: I2c5601faec284d88f28e13378d9cbffc24560efa
2024-08-14 15:28:34 -07:00
Colin Cross
08b6061539 Merge changes If313580b,I68d50d68 into main
* changes:
  Use a provider for systems modules
  Add PrepareForTestWithBuildFlag
2024-08-12 16:53:42 +00:00
Colin Cross
b61c226943 Use a provider for systems modules
Replace the SystemModulesProvider interface with Provider

Test: all soong tests
Flag: EXEMPT refactor
Change-Id: If313580b28094d55b71f1635259bafa850ef7af5
2024-08-09 16:47:45 -07:00
Spandan Das
b4cd5df573 Make IdeInfo aware of jarjar-ing
jarjar can be used to repackage a java_library. e.g. Foo.java in package
com.android might get repackaged to prefix.com.android.Foo in the
resultant jar. To allow code completion of rdeps, we should use the
repackaged jar instead of the src files.

This CL sets dpInfo.Jars to the header jar _only_ when jarjar_rules is
not empty. We could probably set `Jars` to the header jar even for non
jarjar-d libraries and get rid of `Srcs`, `SrcJars` altogether, but that
would likely slow down any tools that index
out/soong/module_bp_java_deps.json for code completion.

Test: go test ./java
Bug: 356572093
Change-Id: Ib45810799a479cb315aed011a34351d386a21357
2024-08-09 22:37:33 +00:00
Spandan Das
6e8bd1cc37 Register versioned sdk dependency in module_bp_java_deps.json
java modules that link against a versioned sdk (sdk_version: <num>) get
the appropriate stub jar on its classpath, but the dependency is not
registered in its build graph. This CL registers this dependency for
module_bp_java_deps.json. Ideally, we should move this to `decodeSdkDep`
so that this dependendency becomes known to other tools that analyze
soong's module graph (e.g. soongdbg)

Test: go test ./java
Bug: 358608607
Bug: 356572093
Change-Id: Iab6efe7826d18dedfadbe4d34d78e7eb2888bd8d
2024-08-09 17:16:23 +00:00
Colin Cross
d1d8f17e9e Move kotlin stdlib after javac jars
A future CL is going to treat local jars separately from dependency
jars.  Rearrange the order of the kotlin standard library jars to
come after the local jars produced by javac, which will better match
the future ordering and ease ninja file comparisions.

Bug: 308016794
Test: all soong tests pass
Flag: EXEMPT refactor
Change-Id: I9ed6a649350451bf1788077752db5222f50c0247
2024-08-07 14:11:43 -07:00
Colin Cross
edec77c453 Split jarjarIfNecessary out of compileJavaHeader
A future CL is going to change transitive classpath behavior when
jarjar is enabled.  In preparation, split the jarjar rules out
of compileJavaHeader into a separate jarjarIfNecessary method, and
use it on the classes and resource jars too.

Also tweak the naming of the output files in repackageFlagsIfNecessary
to be prettier.

Bug: 308016794
Test: all soong tests pass
Flag: EXEMPT refactor
Change-Id: I2b182cd30631f2bd7925341b9171e6b3c0e8d450
2024-08-07 14:11:43 -07:00
Colin Cross
7727c7f096 Convert JavaInfoProvider to *JavaInfo
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
2024-08-07 14:11:43 -07:00
Treehugger Robot
d40aac1340 Merge "Don't hold on to WritablePath" into main 2024-08-07 20:48:50 +00:00
Colin Cross
7707b246ef Don't hold on to WritablePath
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
2024-07-30 14:46:13 -07:00
Joe Onorato
a5d171773d Add jarjar_rename property to java modules.
It's the same mechanism that aconfig uses, but now it's exposed directly
to Android.bp files.  (I had wanted to test it out there before making
it a property just in case it didn't work well)

Bug: 352385368
Test: go test -v -run TestJarJar.*
Change-Id: I72d797d08a250be93779ee4b038a1b8fc62123b7
2024-07-20 17:46:15 -07:00
Spandan Das
8aac993b94 Add all compile deps to module_bp_java_deps.json
`Dependencies` in module_bp_java_deps.json currently only contains the
`libs` and `static_libs` of the corresponding module. This is only a
subset of the dependencies which are required to compile the java
module. Most notably, the SDK deps (determined using `sdk_version`) are
missing.

This CL adds all the compile dependencies to the json file. Implementation
details:
1. Add a `compileDepNames` to java.Module in base.go. Almost all the
   module types in java package are composed with the java.Module
struct.
2. Populate this property in java.Module.collectDeps. This function is
   used by java.Module.compile to determine the classpath used for
compilation.
3. Return `compileDepNames` in java.Module.CompilerDeps.

Since `compileDepNames` is populated in `GenerateAndroidBuildActions`,
update existing unit tests that check for correctness of IDEInfo.Deps

Bug: 353811607
Test: m nothing --no-skip-soong-tests
Test: cat out/soong/module_bp_java_deps.json | jq '."DebuggingRestrictionController".dependencies'
[
  "android_system_stubs_current", <-- missing previously
  "core-lambda-stubs", <-- missing previously
  "core-public-stubs-system-modules", <-- missing previously
  "com.google.android.material_material",
  ...
  ...
]

Change-Id: I166c0eaf6e87ca7adc98bb4e21447cf82612d103
2024-07-19 01:03:27 +00:00
Treehugger Robot
9678733731 Merge changes I861a60e1,I01bf99fa,I9d16dfec into main
* changes:
  Add util method HasIntersection(...)
  Implement InstallableModule for Java modules
  Collect container informations
2024-07-16 00:43:04 +00:00
Jihoon Kang
f86fe9a876 Implement InstallableModule for Java modules
This change enables the container information to be collected for Java
modules.

Test: m nothing --no-skip-soong-tests
Bug: 338660802
Change-Id: I01bf99fa274275a608601ad6248d577ae8f6dffc
2024-07-15 23:46:01 +00:00
mrziwang
9f7b9f4a9a Use OutputFilesProvider on java modules
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
2024-07-10 12:18:06 -07:00
Treehugger Robot
4c8f885b84 Merge "release_config: various cleanup" into main am: 000fe5ac5d
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3129154

Change-Id: Iddd2935b353fdfb8a22fccdbe5aa56c6cc17496d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-06-14 01:51:17 +00:00
LaMont Jones
09721868db release_config: various cleanup
- move WriteMakefile to release_config.go
- use slices.Sort instead of slices.SortFunc where applicable.
- improve error message when inheriting an invalid release config

Bug: None
Test: manual
Change-Id: Id959ddccc75fad912518d5cce8d14da506e0bbea
2024-06-13 09:18:03 -07:00
Sam Saccone
695908cf6d Merge "Only generate kythe xrefs on the primary module" into main am: 6ace4cf906
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3126514

Change-Id: Id836a095e7f3c3f22fca1ed470b832da6677fb59
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-06-11 23:17:50 +00:00
Cole Faust
9decf834ce Only generate kythe xrefs on the primary module
Currently the kythe build is hitting the 6 hour timeout, but we're
generating kythe files for all variants. Generating them only for
the primary variant should drastically cut its runtime.

Bug: 345440993
Test: Presubmits
Change-Id: I3846b25c7f0bc22153e4f0a0cb81c5015854dd70
2024-06-11 11:50:47 -07:00
Treehugger Robot
5149417e90 Merge "Make dex_preopt.enable_prof_rewrite=false an error for optimized apps" into main am: 6e1a3815d8
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3108767

Change-Id: I249dea1d5c71054ef022ec674d78dd936078ca4c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-31 02:35:21 +00:00
Spandan Das
15a67111f8 Make dex_preopt.enable_prof_rewrite=false an error for optimized apps
If profile guided dexpreopt _and_ optimization/obfuscation is true, then
apps must use the rewritten profile created by r8/d8

Bug: 335418838
Test: m nothing --no-skip-soong-tests
Change-Id: Iac45b614f43e52ac40ad1d13df0338bcafa788c3
2024-05-30 20:44:44 +00:00
Treehugger Robot
b18a30edde Merge "Use r8/d8 optimized profile for dexpreopt" into main am: 8723705fad
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3095860

Change-Id: Ifc3c21a58ff94bf7ece2a23b1f66c35eb7e51872
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-29 02:33:11 +00:00
Spandan Das
3dbda18e80 Use r8/d8 optimized profile for dexpreopt
Currently, dexpreopt supports profile guided optimization. This does not
work well with r8/d8 optimization, since the checked-in profile will not
match the dex signatures after r8/d8 has optimized the dex code.

This CL introduces a new property `dex_preopt.enable_profile_rewrting`.
If set, the checked-in profile will passed as `input` to r8 via
`--art-profile <input> <output>`. The <output> from the previous command
will be used as the profile for dexpreopt.

Test: m nothing --no-skip-soong-tests
Test: m CredentialManager with https://ag.corp.google.com/27448930
and obfuscation turned on
Test: nm -U symbol.odex # contains obfuscated methods

Bug: 335418838

Change-Id: I53beed9ed76f013262f1c503de0f2b74997c2a7f
2024-05-29 01:05:05 +00:00
Xin Li
8a31520ef8 Merge Android 24Q2 Release (ab/11526283) to aosp-main-future
Bug: 337098550
Merged-In: I4a6dd1c5e48db7085ea41035def31f0844948a46
Change-Id: If8ad1d0d87495bbd685f5f9f03f5eb7ea78bf192
2024-05-24 08:25:18 -07:00