Commit graph

6951 commits

Author SHA1 Message Date
Treehugger Robot
744a2a6b7d Merge "Handle installation rules for co-existing prebuilts" into main 2024-01-11 18:46:58 +00:00
Spandan Das
3576e769a4 Handle installation rules for co-existing prebuilts
Every module belonging to a single mainline module family will be
hidden from make, except the one which has been flagged using
apex_contributions

Details
- Introduce a new `source_apex_name` property to prebuilt_apex and
  override_apex. This property will be used to identify the source
  equivalent of a prebuilt soong apex module.
- Create an N-ary tree from source to prebuilt(s). The tree wil be
  rooted at the source module.
- In a subsequent mutator, visit every node in the tree(s). Query
  apex_contributions and store the handle of the node which is "active"
  (if any)
- In the same mutator, do another pass over the tree. Invoke
  `HideFromMake` on every node which is not "active". The two-pass
  approach is needed PrebuiltSelectionInfoProvider does not know about
  the inter source-prebuilt dependency, this dependency can only be
  known by doing a graph walk of the N-ary tree.

Some tangential implementation details
- Each prebuilt apex has an internal deapxer module that is responsible
  for generating the deapex ninja rules. The name of this internal
  module uses the BaseModuleName (without the prebuilt_ prefix). Since
  we can have multiple prebuilt soong modules in trunk stable, change
  this to follow the name of the prebuilt module in order to avoid name
  collisions. Update existing unit tests accordingly

Bug: 316179314
Test: go test ./apex -run TestInstallationRulesForMultipleApexPrebuilts
Test: m nothing --no-skip-soong-tests
Test: presubmits

Change-Id: I58aa99d5e6a9859954614e6db9a8e9e2e581642d
2024-01-11 02:02:59 +00:00
Yu Liu
edeadbfdcf Add container to the path of the merged aconfig files.
Bug: 312769710
Test: CI
Change-Id: I4b8a71cf86a3bcefc4a41360a241aa14b798f6e8
2024-01-10 23:38:09 +00:00
LaMont Jones
afe7baf47d Propagate aconfig providers for more modules.
Bug: 308625757
Test: manual
Change-Id: Iaf6d45a4259f1c6c34476c34c431344283ae2830
2024-01-10 14:03:30 +00:00
LaMont Jones
acae2d7656 move SetAconfigFileMkEntries to android
This will need to be called by some modules handled in android.

Bug: 308625757
Test: manual
Change-Id: Ic56e8ef3a453c59866aab6d39a21108cf8536b56
2024-01-10 14:03:29 +00:00
LaMont Jones
1e0a69a02e aconfig: harden dependency collection
To prevent errors, when we collect dependencies for a module, walk the
blueprint modules, and ignore blueprint and disabled modules.

This avoids errors in validateAndroidModule when a android.Module (such
as a genrule) depends on a blueprint.Module, and strict checking is
enabled.

Bug: 308625757
Test: manual

Change-Id: I11f0a0b504aa18d6d786cc91319b9d1d9497c04f
2024-01-10 14:02:47 +00:00
Treehugger Robot
ec3887ad2f Merge "Replace panic with ModuleErrorf" into main 2024-01-10 00:16:52 +00:00
Spandan Das
59a4a2b8d2 Replace panic with ModuleErrorf
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
2024-01-09 22:53:52 +00:00
Elliott Hughes
10363161e7 "master" was renamed "main".
Test: N/A
Change-Id: I86d5578eaac260e55a9583db7ab49812b4ba1f5d
2024-01-09 22:09:07 +00:00
Colin Cross
8460fab92d Merge "Remove more bp2build" into main 2024-01-08 20:26:14 +00:00
Treehugger Robot
208444ce5d Merge changes from topics "revert-2897484-revert-2897682-dont_limit_systemsdk-JCOOOXGAIF-BSJGJAJAWC", "revert-2897568-revert-2894701-limit_systemsdk-WNEMOTGMRS-ROJNXPXKUV" into main
* changes:
  Revert^2 "Add BUILD_BROKEN_DONT_CHECK_SYSTEMSDK"
  Revert "Revert "Limit System SDK to 34 for Java modules in the v..."
2024-01-06 17:53:41 +00:00
Colin Cross
3cc3154d33 Remove more bp2build
Bug: 315353489
Test: m blueprint_tests
Change-Id: Ib854fe1a448c258fe086691a6e5ed2d98537f5e4
2024-01-05 09:54:09 -08:00
Vladimír Marko
80abaa85e8 Merge "Add a new x86(_64) arch variant "goldmont-without-xsaves"" into main 2024-01-05 12:29:33 +00:00
Tongbo Liu
1ce76dfb4c Merge "Enable building whole MCTS and partial MCTS test suites." into main 2024-01-05 05:55:10 +00:00
Zi Wang
c6837a2a8c Merge "Update TestNonExistentPropertyInSoongConfigModule" into main 2024-01-04 23:35:05 +00:00
Jiyong Park
3bb9924c87 Revert^2 "Add BUILD_BROKEN_DONT_CHECK_SYSTEMSDK"
fbf1b5e7f1

Change-Id: I2b6c7866eac24b217197d5f659b37b2ae6b4207d
2024-01-04 23:22:41 +00:00
Jiyong Park
7416d67f28 Revert "Revert "Limit System SDK to 34 for Java modules in the v..."
Revert submission 2897568-revert-2894701-limit_systemsdk-WNEMOTGMRS

Reason for revert: Forward fix was merged

Reverted changes: /q/submissionid:2897568-revert-2894701-limit_systemsdk-WNEMOTGMRS

Change-Id: Id857406513fbf33a20e5d3836742ebd8a0105516
2024-01-04 23:20:42 +00:00
Sebastian Pickl
1f1662217a Revert "Limit System SDK to 34 for Java modules in the vendor pa..."
Revert submission 2894701-limit_systemsdk

Reason for revert: might be breaking builds at 318695834

Bug: 318695834

Reverted changes: /q/submissionid:2894701-limit_systemsdk

Change-Id: I71a87d0a026a444ea9d26f889b3421162e13fea9
2024-01-04 19:28:16 +00:00
Sebastian Pickl
13c52b9963 Merge "Revert "Add BUILD_BROKEN_DONT_CHECK_SYSTEMSDK"" into main 2024-01-04 19:27:24 +00:00
Sebastian Pickl
fbf1b5e7f1 Revert "Add BUILD_BROKEN_DONT_CHECK_SYSTEMSDK"
Revert submission 2897682-dont_limit_systemsdk

Reason for revert: blocking revert for 318695834

Bug:318695834

Reverted changes: /q/submissionid:2897682-dont_limit_systemsdk

Change-Id: I4cf7268cba21c7b81b406c91240bb98190fa4ebc
2024-01-04 19:01:27 +00:00
Joe Onorato
7a0823fb77 Merge "Add BUILD_BROKEN_DONT_CHECK_SYSTEMSDK" into main 2024-01-04 17:40:49 +00:00
Jiyong Park
87312a2fac Add BUILD_BROKEN_DONT_CHECK_SYSTEMSDK
https://android-review.git.corp.google.com/q/topic:limit_systemsdk
introduced a new check for preventing the use of system SDKs above 34
from Java modules in the vendor partition.

As this may break some unprepared targets, introduce
BUILD_BROKEN_DONT_CHECK_SYSTEMSDK as a temporary escape hatch.

This flag will be deleted eventually.

Bug: 314011075
Test: Add BUILD_BROKEN_DONT_CHECK_SYSTEMSDK := true to BoardConfig.mk
Change-Id: Id7901f85c221bc03fa1c15ef15dbec14b783a79a
2024-01-04 22:33:27 +09:00
Jiyong Park
77e105628f Merge "Limit System SDK to 34 for Java modules in the vendor partition" into main 2024-01-04 09:37:36 +00:00
Tongbo Liu
c5f7b96ab5 Enable building whole MCTS and partial MCTS test suites.
Bug: 318608673
Test: m mcts
Change-Id: I2af74e319c40b0e36d8a71e1da3c6934f66a51be
2024-01-04 09:04:18 +00:00
Jiyong Park
ec47e99b4d Limit System SDK to 34 for Java modules in the vendor partition
This change disallows Java modules in the vendor partition to use System
SDK that is newer than API level 34; 34 is the latest allowed.

Background 1: with Trunk Stable, the system/vendor interface is released
at Q2 whereas the system/app interface is released at Q3. In other
words, at Q2, the APIs which will be added to the system SDK at Q3 are
not available. Since the system/vendor interface (which is fronzen at
Q2) is what the modules in the vendor partition will be building
against, they can't and shouldn't use those new APIs that will be added
in the future (Q3). Using those APIs is risky because there's a chance
that those APIs get removed or changed between Q2 and Q3. For example,
2024 Q2 is technically still Android U, not Android V.

Background 2: The use of Java APIs in the vendor partition had many
issues. Most significantly, those "vendor" Java apps are categorized as
part of the system partition because all Java app processes require
access to platform internal libraries that are prohibited to vendor
processes. Furthermore, since the Project Treble, the vendor partition
was re-purposed to a partition to host SoC-dependent bits - usually
HALs. Implementing HALs in Java has never been officially supported and
has had many loop holes.

We'd like to use both background 1 and 2 as a chance to disallow any
Java code in the vendor partition. However, since there are already some
Java modules in the partition, we can't suddenly ban it. The deprecation
will be made gradually, and this CL is the start.

Note that sdk_version: "current" or "system_current" is automatically
overridden into 34 or system_34. This is to prevent sudden breakage of
vendor modules that have been targetting the latest (i.e. current) API
level. They will however fail if they use APIs newer than API level 34.

Bug: 314011075
Test: m blueprint_tests
Change-Id: I59f5ac15ce9ac2ff7cc89e9c110169359077c37c
2024-01-04 13:29:04 +09:00
Cole Faust
3b3a011408 Check for errors in preparer.sh
In case any of the commands fail.

Also skip writing out empty preparer.sh files.

Bug: 314933937
Test: Presubmits
Change-Id: Ia94d032bc4800379608d8a3cf594f25951a3ab32
2024-01-03 15:22:32 -08:00
Colin Cross
138d37dd6c Merge "Support generating module_info.json in Soong" into main 2024-01-03 17:55:47 +00:00
Colin Cross
c67cef48ee Merge "Install vintf fragments and init.rc files in Soong" into main 2024-01-03 16:53:45 +00:00
Treehugger Robot
202bc5b689 Merge "Extract zip_deps preparation work as a script" into main 2024-01-03 05:24:04 +00:00
Jeongik Cha
76e677f93e Extract zip_deps preparation work as a script
If there are lots of files to be packaged, it causes `Argument list too
long` error. So I extracted that as a separate script with
WriteExecutableFileRuleVerbatim, and the method do sharding for long input.

Bug: 314933937
Test: define large system_image definition
Change-Id: Ibf692d4db6da6b7a536cb5b53b15c545e07ff262
2024-01-03 03:58:12 +00:00
Treehugger Robot
5181d0ebfa Merge "Enable Soong to correctly add dependencies to .PHONY targets." into main 2024-01-03 02:58:01 +00:00
Nelson Li
f3c706868a Enable Soong to correctly add dependencies to .PHONY targets.
Previously, Soong's phony simply added "required" or "host_required"
to LOCAL_REQUIRED_MODULES and `include BUILD_PHONY_PACKAGE` without
correctly adding them to the dependency list.

This change add a new `phony_rule` module type to Soong that acts like
`.PHONY` instead of `BUILD_PHONY_PACKAGE`

Bug: 316838256
Bug: 309730110
Test: 1. Use `phony_rule` and adding "phony_deps: [dep_modules]" to
         Android.bp.
      2. make target and check the dep_modules be built.
Change-Id: I3e9e9ac26ecc456668f1b6baf5c08f9c9139b3b2
2024-01-03 02:01:36 +00:00
Colin Cross
d6fd013394 Support generating module_info.json in Soong
Generate module_info.json for some Soong modules in Soong in order to
pass fewer properties to Kati, which can prevent Kati reanalysis when
some Android.bp changes are made.

Soong modules can export a ModuleInfoJSONProvider containing the
data that should be included in module-info.json.  During the androidmk
singleton the providers are collected and written to a single JSON
file.  Make then merges the Soong modules into its own modules.

For now, to keep the result as similar as possible to the
module-info.json currently being generated by Make, only modules that
are exported to Make are written to the Soong module-info.json.

Bug: 309006256
Test: Compare module-info.json
Change-Id: I996520eb48e04743d43ac11c9aba0f3ada7745de
2024-01-02 16:03:43 -08:00
Colin Cross
d9bbf4b424 Install vintf fragments and init.rc files in Soong
Determine the install location of vintf fragments and init.rc files
in Soong so that they are available to Soong-generated module-info.json
entries.  Collect the vintf fragment and init.rc files requested by all Soong
modules, deduplicate the list, and install them in Soong.

Bug: 309006256
Test: Compare module-info.json
Change-Id: I491dc05a773d1a82e485475834d2669fc95cfa1e
2024-01-02 16:01:56 -08:00
Colin Cross
a3759f98a6 Merge "Write raw files to disk instead of the ninja file" into main 2024-01-02 19:44:52 +00:00
Colin Cross
24c1cbe63e Reland "Remove non-generic provider APIs"
There are no more callers to the non-generic provider APIs, remove them.

This reapplies I4d336340e630643f98531787a81e0f1f18ec108d after
I79736e44d85bc6e8c97f08ebf783b40533a3e6ae removed a newly introduced
usage.

Bug: 316410648
Change-Id: I152f8e5ef8330b811d3f42f8c2c73943ac0979bb
Test: builds
2023-12-22 00:06:05 +00:00
Spandan Das
412b33a6e7 Merge "Use the correct bootjars when multiple prebuilt apexes exist" into main 2023-12-20 19:00:49 +00:00
Spandan Das
5be6333692 Use the correct bootjars when multiple prebuilt apexes exist
hiddenapi and dexpreopt require boot and system server jars from apexes.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares dex_bootjars to select the right
deapexerd .jar files when mutliple prebuilts exist.

Implementation details
- Update prebuilt module types (prebuilt_apex/apex_set) and source
  apexes to set a map of
  library name to dex jar path on host.
- dex_bootjars will access the path of the .dex jar on host via the
  provider. These then
  copied/installed to the right locations.

This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped

Bug: 308790457
Test: git_master-art-host:art-gtest https://android-build.corp.google.com/builds/abtd/run/L21500030000926533
Test: git_main:art_standalone_dexpreopt_tests https://android-build.corp.google.com/builds/abtd/run/L99000030000891212
Test: Added a unit test that checks that the right .jar is selected
when multiple prebuilts exists

Change-Id: I6ef94135b9303a35135810930af4b641df13a583
2023-12-20 16:43:01 +00:00
Cole Faust
30e32f67fc Merge changes I8b352305,Iadf9e324 into main
* changes:
  Sandbox CtsApkVerityTestDebugFiles
  Include "soong" in sandboxed out paths
2023-12-20 01:35:40 +00:00
Colin Cross
a4cca85eea Merge "Revert "Remove non-generic provider APIs"" into main 2023-12-20 01:00:27 +00:00
Colin Cross
84b68c90ae Revert "Remove non-generic provider APIs"
This reverts commit ad50aca6ab.

Reason for revert: Broke builds when combined with aosp/2876755

Change-Id: I3bfbcb05d8c695b9315b7e8e3f63c6bd5c9dbe36
2023-12-20 00:59:28 +00:00
Colin Cross
e87e278086 Merge "Remove non-generic provider APIs" into main 2023-12-20 00:42:38 +00:00
Colin Cross
31a674571e Write raw files to disk instead of the ninja file
Writing raw files as rules in the ninja file unnecessarily bloats
the ninja file.  Write files immediately to disk instead to files
based on the hash of the contents, and then emit ninja rules to
copy the files into place during the build.  Delete obsolete files
in a singleton at the end of analysis.

Bug: 306029038
Test: Run: m libc_musl_version.h
           touch build/soong/Android.bp
           m libc_musl_version.h
      libc_musl_version.h/genrule.sbox.textproto is not recopied.
Test: Run: lunch aosp_cf_x86_64_phone-userdebug
           m libc_musl_version.h
	   lunch aosp_x86_64-userdebug
	   m libc_musl_version.h
	   lunch aosp_cf_x86_64_phone-userdebug
	   m libc_musl_version.h
      libc_musl_version.h/genrule.sbox.textproto is recopied but restat prevents rerunning the genrule.
Test: Run: touch out/soong/raw-aosp_cf_x86_64_phone/00/foo
           touch build/soong/Android.bp
	   m nothing
      out/soong/raw-aosp_cf_x86_64_phone/00/foo is removed.
Change-Id: I172869c4d49565504794c051e2e8c1f7cf46486e
2023-12-19 16:33:46 -08:00
Spandan Das
96feedc555 Merge "Use the correct prof file when multiple prebuilt apexes exist" into main 2023-12-20 00:02:20 +00:00
Colin Cross
225ad7e8b2 Merge "Remove cc.moduleContext override of android.ModuleContext.*Specific" into main 2023-12-19 23:39:54 +00:00
Spandan Das
da739a30a6 Use the correct prof file when multiple prebuilt apexes exist
Generating boot image requires a .prof file provided by the ART apex.
When building with prebuilts, this comes via the
prebuilt_bootclasspath_fragment module, which acts as a shim for
prebuilt_apex/apex_set. If we have multiple prebuilt apexes in the tree,
this shim becomes 1:many. This CL prepares dex_bootjars to select the
right .prof file when multiple prebuilts exist.

Implementation details
- Update deps mutator of dex_bootjars to create a dep on
  all_apex_contributions. The latter contains information about which
  apex is selected in a specific release configuration. dex_bootjars
  will create a dependency on the selected apex in a postdeps phase
  mutator.
- All apex module types (apex, prebuilt_apex and apex_set) will set a
  provider that contains info about the location of the .prof file on
  host
- dex_bootjars will access the provider of the selected apex to get the
  location of the .prof file

This CL does not drop the old mechanism to get the .prof file (i.e. by
creating a dep on {prebuilt_}bootclasspath_fragment). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped

Bug: 308790457
Test: Added a unit test that checks that the right .prof is selected
when multiple prebuilts exists

Change-Id: I40fdb21416c46bed32f6ff187ce5153711ec2c69
2023-12-19 22:37:29 +00:00
Cole Faust
e8561c6108 Include "soong" in sandboxed out paths
Previously, the path to built files in the sandbox would be
out/.intermediates/... instead of out/soong/.intermediates/....

After this cl, it will be out/soong/.intermediates/.... This makes
it more consistent with the non-sandboxed paths, which is easier for
developers.

CtsApkVerityTestDebugFiles is a genrule that's used to find the paths
to other modules. Developers were expected to build it, then copy all
the files listed in its output file to a temporary directory. Those
paths would be wrong before this change.

Bug: 307824623
Test: ./build/soong/tests/genrule_sandbox_test.py CtsApkVerityTestDebugFiles
Change-Id: Iadf9e3240a2c828567e46b6b02cc14004f30e8bf
2023-12-19 12:14:01 -08:00
LaMont Jones
aa005ae080 move CollectDependencyAconfigFiles to android
This needs to be called by some modules in android.

Bug: 308625757
Test: manual
Change-Id: I389fcfd88a3f4bd85a9218fdd4dd66d8a239bb67
2023-12-19 19:34:00 +00:00
Spandan Das
fae468ef14 Move validation from FindDeapexerProviderForModule to rdeps
FindDeapexerProviderForModule raises an exception if multiple apexes in
the tree has an export dep on the java module. In prepartation to
support multiple prebuilts, move this error check out of
FindDeapexerProviderForModule and into rdeps. i.e. raise an exception
only if an rdep calls DexJarBuildPath

- This should be a no-op for now.
- In the short-term future, a java import module will be allowed to have
  multiple deapexers. An error will be raised if anyone actually tries
  to depend on the dexjar
- In the long-term future, this function will be removed. All processing
  will be done at the prebuilt apex level and not at the prebuilt java
  library level

Since this check now happens in the moduleCtx of rdeps, add some
additional props to unit tests to ensure that it does not exit early on
unrelated validation checks (e.g. hidden_api prop is not set)

Test: go test ./apex ./java
Bug: 308790457

Change-Id: I3323d993c1ea8f43305834cae8e65b6fe41dfefd
2023-12-18 23:19:47 +00:00
Colin Cross
ea30d85a65 Remove cc.moduleContext override of android.ModuleContext.*Specific
Overriding android.ModuleContext's implementations of *Specific()
methods in cc.moduleContext and then passing that back to
android.PathForModuleInstall to affect the install path causes
problems if android.ModuleBase.GenerateBuildActions also tries
to call android.PathForModuleInstall directly with the
android.ModuleContext as it gets a different result.

Add InstallIn* methods to the android.Module interface, implement
default versions in android.ModuleBase, and override them in
cc.Module and rust.Module.  Use them in android.PathsForModuleInstall
to allow the module to customize the behavior directly.

Test: TestInstallPartition
Change-Id: I7840e07eae34ac4f4d3490b021143d5f33a83626
2023-12-18 15:07:05 -08:00