Compare commits

...

10 commits

Author SHA1 Message Date
minaripenguin
2450781c33 gen_build_prop: Always return release-keys
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
2025-04-10 21:16:47 +00:00
Pranav Vashi
7b095f73bd soong: Always return release-keys
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
2025-04-10 21:16:42 +00:00
hmtheboy154
d5c9d6498b Rust: Use nehalem cpu-target when building with sandybridge arch variant
On Android, sandybridge doesn't include AVX support, so it's more like
nehalem target on Rust toolchain or GCC.

[cafebabe: This fixes booting on CPUs that does not support AVX, like LGA1156 ones, and LGA1150/LGA1155 Intel Celeron/Pentium]

Change-Id: I281e8f5a91271241c48336021582a42acc6d0120
Signed-off-by: hmtheboy154 <buingoc67@gmail.com>
2025-04-06 17:29:57 +08:00
Inseob Kim
cd34413b9d Make fsverity props configurable
Bug: 381019944
Test: build
Change-Id: I7389131a944ce477d5d49d01acbcacae2e6fecfe
2025-03-30 16:08:39 +02:00
Devin Moore
1b297b02d2
Add vintf_data inputPaths as Implicits to build command
This allows for incremental builds when the source files are modified.

Test: <modify shared/manifest.xml> m
Bug: none
Change-Id: Icd21a826a3831e92ce2bdcc6aefa9924ec64c3a5
2025-03-22 19:06:43 +02:00
Luca Stefani
fc4af1f5cc
fsgen: Use prebuilt_{root,any} in case install_in_root is set
If any of the other modules relative dir matches (eg lib/) it
would hit a neverallow as installing in the root directory
is allowlisted.

Test: m --no-skip-soong-tests
Test: m on tegra device with
PRODUCT_COPY_FILES += \
    tegra21x_xusb_firmware:recovery/root/tegra21x_xusb_firmware \

Change-Id: I157826703974544614f0049b8fa157358e7b17a7
2025-03-20 19:45:26 +01:00
Jihoon Kang
6f53e14455
Expand the usages of prebuilt_any in prebuilt_etc module gen
Currently, prebuilt_any is only used as a fallback behavior when the
generated prebuilt_root module tries to set the `Dsts` property, given
that prebuilt_root module type is no longer allowed to set `Dsts`
property with https://r.android.com/3540101.

This change expands the usages of the fallback behavior to when the
generated prebuilt_root module tries to set the `Relative_install_path`
property, given that this property is not also available to
prebuilt_root module type.

Test: m nothing --no-skip-soong-tests
Change-Id: I9344a8cb3e26bedbd0217a5344ac92b8def68554
2025-03-18 14:27:08 +01:00
Jihoon Kang
6b45f84557
Disallow prebuilt_root module type from setting Dsts property
...to prevent prebuilt_root module type from installing files in
arbitrary locations within the partition.

Test: m nothing --no-skip-soong-tests
Bug: 402903576
Change-Id: I6999c3256668bbe738a38abc4accc05e390511ba
2025-03-13 21:48:19 +02:00
Jihoon Kang
cc1c4aaf9a
Introduce prebuilt_any module type
prebuilt_any is a "wildcard" module type that allows installing the
files in any subdirectories within the partition. This module is only
used for converting the PRODUCT_COPY_FILES in fsgen, and should not be
written in the bp files.

Test: m nothing --no-skip-soong-tests
Bug: 375053752
Change-Id: Ic0839b0dbbfa6b012c6b920eecf4ebc6fed8d51f
2025-03-13 21:48:11 +02:00
Jihoon Kang
c099116fb0
Add vendor_manifest.xml to createFsGenState
Given that the module cannot be unconditionally added to
PRODUCT_PACKAGES.

Test: m soong_generated_vendor_filesystem_test
Change-Id: Ide8f330a2a94290adb187468e3b5b18938fafe7c
2025-03-13 21:44:51 +02:00
12 changed files with 116 additions and 49 deletions

View file

@ -1169,14 +1169,7 @@ func (c *config) ExtraOtaKeys(ctx PathContext, recovery bool) []SourcePath {
}
func (c *config) BuildKeys() string {
defaultCert := String(c.productVariables.DefaultAppCertificate)
if defaultCert == "" || defaultCert == filepath.Join(testKeyDir, "testkey") {
return "test-keys"
}
if strings.HasPrefix(defaultCert, "vendor/lineage-priv/") {
return "release-keys"
}
return "dev-keys"
return "release-keys"
}
func (c *config) ApexKeyDir(ctx ModuleContext) SourcePath {

View file

@ -250,6 +250,7 @@ func createInstallInRootAllowingRules() []Rule {
NotModuleType("prebuilt_system").
NotModuleType("prebuilt_first_stage_ramdisk").
NotModuleType("prebuilt_res").
NotModuleType("prebuilt_any").
Because("install_in_root is only for init_first_stage or librecovery_ui_ext."),
}
}
@ -341,6 +342,7 @@ func createKotlinPluginRule() []Rule {
func createPrebuiltEtcBpDefineRule() Rule {
return NeverAllow().
ModuleType(
"prebuilt_any",
"prebuilt_usr_srec",
"prebuilt_priv_app",
"prebuilt_rfs",

View file

@ -140,6 +140,7 @@ func (m *vintfDataRule) GenerateAndroidBuildActions(ctx ModuleContext) {
// Process vintf fragment source file with assemble_vintf tool
builder.Command().
Implicits(inputPaths).
Flags(assembleVintfEnvs).
BuiltTool("assemble_vintf").
FlagWithArg("-i ", strings.Join(inputPaths.Strings(), ":")).

View file

@ -87,6 +87,7 @@ func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory)
ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory)
ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory)
ctx.RegisterModuleType("prebuilt_any", PrebuiltAnyFactory)
ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
@ -104,12 +105,6 @@ type PrebuiltEtcProperties struct {
// set. May use globs in filenames.
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
// Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
// set filename_from_src. This can be used to install each source file to a different directory
// and/or change filenames when files are installed. Must be exactly one entry per source file,
// which means care must be taken if srcs has globs.
Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
// Optional name for the installed file. If unspecified, name of the module is used as the file
// name. Only available when using a single source (src).
Filename *string `android:"arch_variant"`
@ -148,6 +143,20 @@ type PrebuiltEtcProperties struct {
Oem_specific *bool `android:"arch_variant"`
}
// Dsts is useful in that it allows prebuilt_* modules to easily map the source files to the
// install path within the partition. Dsts values are allowed to contain filepath separator
// so that the source files can be installed in subdirectories within the partition.
// However, this functionality should not be supported for prebuilt_root module type, as it
// allows the module to install to any arbitrary location. Thus, this property is defined in
// a separate struct so that it's not available to be set in prebuilt_root module type.
type PrebuiltDstsProperties struct {
// Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
// set filename_from_src. This can be used to install each source file to a different directory
// and/or change filenames when files are installed. Must be exactly one entry per source file,
// which means care must be taken if srcs has globs.
Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
}
type prebuiltSubdirProperties struct {
// Optional subdirectory under which this file is installed into, cannot be specified with
// relative_install_path, prefer relative_install_path.
@ -183,6 +192,8 @@ type PrebuiltEtc struct {
properties PrebuiltEtcProperties
dstsProperties PrebuiltDstsProperties
// rootProperties is used to return the value of the InstallInRoot() method. Currently, only
// prebuilt_avb and prebuilt_root modules use this.
rootProperties prebuiltRootProperties
@ -373,7 +384,7 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if srcProperty.IsPresent() && len(srcsProperty) > 0 {
ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
}
dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
dstsProperty := p.dstsProperties.Dsts.GetOrDefault(ctx, nil)
if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
}
@ -580,6 +591,7 @@ func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
p.AddProperties(&p.properties)
p.AddProperties(&p.subdirProperties)
p.AddProperties(&p.rootProperties)
p.AddProperties(&p.dstsProperties)
}
func InitPrebuiltRootModule(p *PrebuiltEtc) {
@ -591,6 +603,7 @@ func InitPrebuiltRootModule(p *PrebuiltEtc) {
func InitPrebuiltAvbModule(p *PrebuiltEtc) {
p.installDirBase = "avb"
p.AddProperties(&p.properties)
p.AddProperties(&p.dstsProperties)
p.rootProperties.Install_in_root = proptools.BoolPtr(true)
}
@ -634,6 +647,20 @@ func PrebuiltEtcHostFactory() android.Module {
return module
}
// prebuilt_any is a special module where the module can define the subdirectory that the files
// are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong
// modules, and should never be defined in the bp files. If none of the existing prebuilt_*
// modules allow installing the file at the desired location, introduce a new prebuilt_* module
// type instead.
func PrebuiltAnyFactory() android.Module {
module := &PrebuiltEtc{}
InitPrebuiltEtcModule(module, ".")
// This module is device-only
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
return module
}
// prebuilt_etc_host is for a host prebuilt artifact that is installed in
// <partition>/etc/<sub_dir> directory.
func PrebuiltEtcCaCertsFactory() android.Module {

View file

@ -20,6 +20,8 @@ import (
"strings"
"android/soong/android"
"github.com/google/blueprint/proptools"
)
type fsverityProperties struct {
@ -27,10 +29,10 @@ type fsverityProperties struct {
// will be generated and included to the filesystem image.
// etc/security/fsverity/BuildManifest.apk will also be generated which contains information
// about generated .fsv_meta files.
Inputs []string
Inputs proptools.Configurable[[]string]
// APK libraries to link against, for etc/security/fsverity/BuildManifest.apk
Libs []string `android:"path"`
Libs proptools.Configurable[[]string] `android:"path"`
}
func (f *filesystem) writeManifestGeneratorListFile(ctx android.ModuleContext, outputPath android.WritablePath, matchedSpecs []android.PackagingSpec, rebasedDir android.OutputPath) {
@ -44,7 +46,7 @@ func (f *filesystem) writeManifestGeneratorListFile(ctx android.ModuleContext, o
func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir android.OutputPath, rebasedDir android.OutputPath) {
match := func(path string) bool {
for _, pattern := range f.properties.Fsverity.Inputs {
for _, pattern := range f.properties.Fsverity.Inputs.GetOrDefault(ctx, nil) {
if matched, err := filepath.Match(pattern, path); matched {
return true
} else if err != nil {
@ -112,7 +114,7 @@ func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, build
apkPath := rebasedDir.Join(ctx, "etc", "security", "fsverity", fmt.Sprintf("BuildManifest%s.apk", apkNameSuffix))
idsigPath := rebasedDir.Join(ctx, "etc", "security", "fsverity", fmt.Sprintf("BuildManifest%s.apk.idsig", apkNameSuffix))
manifestTemplatePath := android.PathForSource(ctx, "system/security/fsverity/AndroidManifest.xml")
libs := android.PathsForModuleSrc(ctx, f.properties.Fsverity.Libs)
libs := android.PathsForModuleSrc(ctx, f.properties.Fsverity.Libs.GetOrDefault(ctx, nil))
minSdkVersion := ctx.Config().PlatformSdkCodename()
if minSdkVersion == "REL" {

View file

@ -224,7 +224,7 @@ func partitionSpecificFsProps(ctx android.EarlyModuleContext, fsProps *filesyste
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
// Identical to that of the aosp_shared_system_image
if partitionVars.ProductFsverityGenerateMetadata {
fsProps.Fsverity.Inputs = []string{
fsProps.Fsverity.Inputs = proptools.NewSimpleConfigurable([]string{
"etc/boot-image.prof",
"etc/dirty-image-objects",
"etc/preloaded-classes",
@ -232,8 +232,8 @@ func partitionSpecificFsProps(ctx android.EarlyModuleContext, fsProps *filesyste
"framework/*",
"framework/*/*", // framework/{arch}
"framework/oat/*/*", // framework/oat/{arch}
}
fsProps.Fsverity.Libs = []string{":framework-res{.export-package.apk}"}
})
fsProps.Fsverity.Libs = proptools.NewSimpleConfigurable([]string{":framework-res{.export-package.apk}"})
}
// Most of the symlinks and directories listed here originate from create_root_structure.mk,
// but the handwritten generic system image also recreates them:
@ -377,12 +377,12 @@ func partitionSpecificFsProps(ctx android.EarlyModuleContext, fsProps *filesyste
})
case "system_ext":
if partitionVars.ProductFsverityGenerateMetadata {
fsProps.Fsverity.Inputs = []string{
fsProps.Fsverity.Inputs = proptools.NewSimpleConfigurable([]string{
"framework/*",
"framework/*/*", // framework/{arch}
"framework/oat/*/*", // framework/oat/{arch}
}
fsProps.Fsverity.Libs = []string{":framework-res{.export-package.apk}"}
})
fsProps.Fsverity.Libs = proptools.NewSimpleConfigurable([]string{":framework-res{.export-package.apk}"})
}
case "product":
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)

View file

@ -271,6 +271,8 @@ func TestPrebuiltEtcModuleGen(t *testing.T) {
"some/non/existing/file.txt:system/etc/file.txt",
"device/sample/etc/apns-full-conf.xml:product/etc/apns-conf.xml:google",
"device/sample/etc/apns-full-conf.xml:product/etc/apns-conf-2.xml",
"device/sample/etc/apns-full-conf.xml:system/foo/file.txt",
"device/sample/etc/apns-full-conf.xml:system/foo/apns-full-conf.xml",
}
config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
map[string]android.PartitionQualifiedVariablesType{
@ -347,15 +349,25 @@ func TestPrebuiltEtcModuleGen(t *testing.T) {
eval := generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
android.AssertBoolEquals(
t,
"module expected to set correct srcs and dsts properties",
"module expected to set correct srcs property",
true,
checkModuleProp(generatedModule0, func(actual interface{}) bool {
if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
srcs := p.Srcs.GetOrDefault(eval, nil)
dsts := p.Dsts.GetOrDefault(eval, nil)
return len(srcs) == 1 &&
srcs[0] == "apns-full-conf.xml" &&
len(dsts) == 1 &&
srcs[0] == "apns-full-conf.xml"
}
return false
}),
)
android.AssertBoolEquals(
t,
"module expected to set correct dsts property",
true,
checkModuleProp(generatedModule0, func(actual interface{}) bool {
if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
dsts := p.Dsts.GetOrDefault(eval, nil)
return len(dsts) == 1 &&
dsts[0] == "apns-conf.xml"
}
return false
@ -366,15 +378,25 @@ func TestPrebuiltEtcModuleGen(t *testing.T) {
eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
android.AssertBoolEquals(
t,
"module expected to set correct srcs and dsts properties",
"module expected to set correct srcs property",
true,
checkModuleProp(generatedModule1, func(actual interface{}) bool {
if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
srcs := p.Srcs.GetOrDefault(eval, nil)
dsts := p.Dsts.GetOrDefault(eval, nil)
return len(srcs) == 1 &&
srcs[0] == "apns-full-conf.xml" &&
len(dsts) == 1 &&
srcs[0] == "apns-full-conf.xml"
}
return false
}),
)
android.AssertBoolEquals(
t,
"module expected to set correct dsts property",
true,
checkModuleProp(generatedModule1, func(actual interface{}) bool {
if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
dsts := p.Dsts.GetOrDefault(eval, nil)
return len(dsts) == 1 &&
dsts[0] == "apns-conf-2.xml"
}
return false

View file

@ -162,6 +162,10 @@ func createFsGenState(ctx android.LoadHookContext, generatedPrebuiltEtcModuleNam
(*fsGenState.fsDeps["product"])["system_other_avbpubkey"] = defaultDepCandidateProps(ctx.Config())
}
if len(ctx.Config().DeviceManifestFiles()) > 0 {
(*fsGenState.fsDeps["vendor"])["vendor_manifest.xml"] = defaultDepCandidateProps(ctx.Config())
}
// Add common resources `prebuilt_res` module as dep of recovery partition
(*fsGenState.fsDeps["recovery"])[fmt.Sprintf("recovery-resources-common-%s", getDpi(ctx))] = defaultDepCandidateProps(ctx.Config())

View file

@ -164,7 +164,6 @@ type prebuiltModuleProperties struct {
Ramdisk *bool
Srcs []string
Dsts []string
No_full_install *bool
@ -301,6 +300,7 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition,
etcInstallPathKey = etcInstallPath
}
}
moduleFactory := etcInstallPathToFactoryList[etcInstallPathKey]
relDestDirFromInstallDirBase, _ := filepath.Rel(etcInstallPathKey, destDir)
for fileIndex := range maxLen {
@ -335,13 +335,31 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition,
propsList = append(propsList, &prebuiltInstallInRootProperties{
Install_in_root: proptools.BoolPtr(true),
})
// Discard any previously picked module and force it to prebuilt_{root,any} as
// they are the only modules allowed to specify the `install_in_root` property.
etcInstallPathKey = ""
relDestDirFromInstallDirBase = destDir
}
// Set appropriate srcs, dsts, and releative_install_path based on
// the source and install file names
if allCopyFileNamesUnchanged {
modulePropsPtr.Srcs = srcBaseFiles
modulePropsPtr.Srcs = srcBaseFiles
// prebuilt_root should only be used in very limited cases in prebuilt_etc moddule gen, where:
// - all source file names are identical to the installed file names, and
// - all source files are installed in root, not the subdirectories of root
// prebuilt_root currently does not have a good way to specify the names of the multiple
// installed files, and prebuilt_root does not allow installing files at a subdirectory
// of the root.
// Use prebuilt_any instead of prebuilt_root if either of the conditions are not met as
// a fallback behavior.
if etcInstallPathKey == "" {
if !(allCopyFileNamesUnchanged && android.InList(relDestDirFromInstallDirBase, []string{"", "."})) {
moduleFactory = etc.PrebuiltAnyFactory
}
}
if allCopyFileNamesUnchanged {
// Specify relative_install_path if it is not installed in the root directory of the
// partition
if !android.InList(relDestDirFromInstallDirBase, []string{"", "."}) {
@ -350,15 +368,18 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition,
})
}
} else {
modulePropsPtr.Srcs = srcBaseFiles
dsts := []string{}
// If dsts property has to be set and the selected module type is prebuilt_root,
// use prebuilt_any instead.
dsts := proptools.NewConfigurable[[]string](nil, nil)
for _, installBaseFile := range installBaseFiles {
dsts = append(dsts, filepath.Join(relDestDirFromInstallDirBase, installBaseFile))
dsts.AppendSimpleValue([]string{filepath.Join(relDestDirFromInstallDirBase, installBaseFile)})
}
modulePropsPtr.Dsts = dsts
propsList = append(propsList, &etc.PrebuiltDstsProperties{
Dsts: dsts,
})
}
ctx.CreateModuleInDirectory(etcInstallPathToFactoryList[etcInstallPathKey], srcDir, propsList...)
ctx.CreateModuleInDirectory(moduleFactory, srcDir, propsList...)
moduleNames = append(moduleNames, moduleName)
}

View file

@ -36,7 +36,7 @@ var (
"goldmont-without-sha-xsaves": []string{"-C target-cpu=goldmont", "-C target-feature=-sha,-xsaves"},
"haswell": []string{"-C target-cpu=haswell"},
"ivybridge": []string{"-C target-cpu=ivybridge"},
"sandybridge": []string{"-C target-cpu=sandybridge"},
"sandybridge": []string{"-C target-cpu=nehalem"},
"silvermont": []string{"-C target-cpu=silvermont"},
"skylake": []string{"-C target-cpu=skylake"},
//TODO: Add target-cpu=stoneyridge when rustc supports it.

View file

@ -35,7 +35,7 @@ var (
"goldmont-without-sha-xsaves": []string{"-C target-cpu=goldmont", "-C target-feature=-sha,-xsaves"},
"haswell": []string{"-C target-cpu=haswell"},
"ivybridge": []string{"-C target-cpu=ivybridge"},
"sandybridge": []string{"-C target-cpu=sandybridge"},
"sandybridge": []string{"-C target-cpu=nehalem"},
"silvermont": []string{"-C target-cpu=silvermont"},
"skylake": []string{"-C target-cpu=skylake"},
//TODO: Add target-cpu=stoneyridge when rustc supports it.

View file

@ -40,12 +40,7 @@ def get_build_flavor(product_config):
return build_flavor
def get_build_keys(product_config):
default_cert = product_config.get("DefaultAppCertificate", "")
if default_cert == "" or default_cert == os.path.join(TEST_KEY_DIR, "testKey"):
return "test-keys"
if default_cert.startswith("vendor/lineage-priv/"):
return "release-keys"
return "dev-keys"
return "release-keys"
def override_config(config):
if "PRODUCT_BUILD_PROP_OVERRIDES" in config: