Move the installation rules of boot images to soong

This CL adds moves the installation rules of boot images to soong. This
will eventually allow us to build devices by skipping `katiBuild` and
moving straight to `katiPackaging`

Details
1. Drop `no_full_install` from dex_bootjars singleton. This ensures that
   the files installed by this singleton module does not get skipped
when generating the soong installs file (out/soong/installs-*)
2. Replace PackageFile with InstallFile. This registers the installation
   rules for both make-built and soong-built images (e.g.
aosp_cf_system_x86_64)
3. Implement `AndroidMkEntries` for dex_bootjars singleton. OutputFile
   needs to be non-nil so that this module does not get elided when
generating out/soong/Android-*. `OutputFile` was abritrarily set to one
of the many files installed by this singleton.

Test: no diff in
target/product/vsoc_x86_64/obj/PACKAGING/system_intermediates/file_list.txt
(top of stack)
Bug: 355700341
Bug: 355703904

Change-Id: I3531defa6bba58ef78f6d66e881502a8222fc229
This commit is contained in:
Spandan Das
2024-07-30 23:28:17 +00:00
parent 32b8daff1d
commit 29207b57cf
3 changed files with 22 additions and 10 deletions

View File

@@ -104,7 +104,6 @@ cc_genrule {
// Instantiate the dex_bootjars singleton module. // Instantiate the dex_bootjars singleton module.
dex_bootjars { dex_bootjars {
name: "dex_bootjars", name: "dex_bootjars",
no_full_install: true,
} }
// Pseudo-test that's run on checkbuilds to ensure that get_clang_version can // Pseudo-test that's run on checkbuilds to ensure that get_clang_version can

View File

@@ -616,10 +616,8 @@ func getModuleInstallPathInfo(ctx android.ModuleContext, fullInstallPath string)
return installPath, relDir, installBase return installPath, relDir, installBase
} }
// RuleBuilder.Install() adds output-to-install copy pairs to a list for Make. To share this // installFile will install the file if `install` path and the target install partition are the same.
// information with PackagingSpec in soong, call PackageFile for them. func installFile(ctx android.ModuleContext, install android.RuleBuilderInstall) {
// The install path and the target install partition of the module must be the same.
func packageFile(ctx android.ModuleContext, install android.RuleBuilderInstall) {
installPath, relDir, name := getModuleInstallPathInfo(ctx, install.To) installPath, relDir, name := getModuleInstallPathInfo(ctx, install.To)
// Empty name means the install partition is not for the target image. // Empty name means the install partition is not for the target image.
// For the system image, files for "apex" and "system_other" are skipped here. // For the system image, files for "apex" and "system_other" are skipped here.
@@ -628,7 +626,7 @@ func packageFile(ctx android.ModuleContext, install android.RuleBuilderInstall)
// TODO(b/320196894): Files for "system_other" are skipped because soong creates the system // TODO(b/320196894): Files for "system_other" are skipped because soong creates the system
// image only for now. // image only for now.
if name != "" { if name != "" {
ctx.PackageFile(installPath.Join(ctx, relDir), name, install.From) ctx.InstallFile(installPath.Join(ctx, relDir), name, install.From)
} }
} }

View File

@@ -491,6 +491,11 @@ type dexpreoptBootJars struct {
// Build path to a config file that Soong writes for Make (to be used in makefiles that install // Build path to a config file that Soong writes for Make (to be used in makefiles that install
// the default boot image). // the default boot image).
dexpreoptConfigForMake android.WritablePath dexpreoptConfigForMake android.WritablePath
// Build path to the boot framework profile.
// This is used as the `OutputFile` in `AndroidMkEntries`.
// A non-nil value ensures that this singleton module does not get skipped in AndroidMkEntries processing.
bootFrameworkProfile android.WritablePath
} }
func (dbj *dexpreoptBootJars) DepsMutator(ctx android.BottomUpMutatorContext) { func (dbj *dexpreoptBootJars) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -603,7 +608,8 @@ func (d *dexpreoptBootJars) GenerateAndroidBuildActions(ctx android.ModuleContex
installs := generateBootImage(ctx, config) installs := generateBootImage(ctx, config)
profileInstalls = append(profileInstalls, installs...) profileInstalls = append(profileInstalls, installs...)
if config == d.defaultBootImage { if config == d.defaultBootImage {
_, installs := bootFrameworkProfileRule(ctx, config) bootProfile, installs := bootFrameworkProfileRule(ctx, config)
d.bootFrameworkProfile = bootProfile
profileInstalls = append(profileInstalls, installs...) profileInstalls = append(profileInstalls, installs...)
} }
} }
@@ -613,7 +619,7 @@ func (d *dexpreoptBootJars) GenerateAndroidBuildActions(ctx android.ModuleContex
profileLicenseMetadataFile: android.OptionalPathForPath(ctx.LicenseMetadataFile()), profileLicenseMetadataFile: android.OptionalPathForPath(ctx.LicenseMetadataFile()),
}) })
for _, install := range profileInstalls { for _, install := range profileInstalls {
packageFile(ctx, install) installFile(ctx, install)
} }
} }
} }
@@ -939,7 +945,7 @@ func packageFileForTargetImage(ctx android.ModuleContext, image *bootImageVarian
} }
for _, install := range image.installs { for _, install := range image.installs {
packageFile(ctx, install) installFile(ctx, install)
} }
for _, install := range image.vdexInstalls { for _, install := range image.vdexInstalls {
@@ -1231,7 +1237,7 @@ func bootImageProfileRule(ctx android.ModuleContext, image *bootImageConfig) (an
profile := bootImageProfileRuleCommon(ctx, image.name, image.dexPathsDeps.Paths(), image.getAnyAndroidVariant().dexLocationsDeps) profile := bootImageProfileRuleCommon(ctx, image.name, image.dexPathsDeps.Paths(), image.getAnyAndroidVariant().dexLocationsDeps)
if image == defaultBootImageConfig(ctx) { if image == defaultBootImageConfig(ctx) && profile != nil {
rule := android.NewRuleBuilder(pctx, ctx) rule := android.NewRuleBuilder(pctx, ctx)
rule.Install(profile, "/system/etc/boot-image.prof") rule.Install(profile, "/system/etc/boot-image.prof")
return profile, rule.Installs() return profile, rule.Installs()
@@ -1377,3 +1383,12 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(getImageNames(), " ")) ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(getImageNames(), " "))
} }
} }
// Add one of the outputs in `OutputFile`
// This ensures that this singleton module does not get skipped when writing out/soong/Android-*.mk
func (d *dexpreoptBootJars) AndroidMkEntries() []android.AndroidMkEntries {
return []android.AndroidMkEntries{{
Class: "ETC",
OutputFile: android.OptionalPathForPath(d.bootFrameworkProfile),
}}
}