Merge "Set fsverity.libs for soong generated filesystem modules" into main
diff --git a/android/filegroup.go b/android/filegroup.go
index ff0f74e..a8b4f00 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -139,3 +139,15 @@
return module
}
+
+// Collect information for opening IDE project files in java/jdeps.go.
+// Copied from build/soong/genrule/genrule.go
+func (fg *fileGroup) IDEInfo(ctx BaseModuleContext, dpInfo *IdeInfo) {
+ dpInfo.Srcs = append(dpInfo.Srcs, fg.Srcs().Strings()...)
+ for _, src := range fg.properties.Srcs.GetOrDefault(ctx, nil) {
+ if mod, _ := SrcIsModuleWithTag(src); mod != "" {
+ // Register the module name without any tags in `Deps`
+ dpInfo.Deps = append(dpInfo.Deps, mod)
+ }
+ }
+}
diff --git a/cc/cc_preprocess_no_configuration.go b/cc/cc_preprocess_no_configuration.go
index 3d1d0a5..3d4b077 100644
--- a/cc/cc_preprocess_no_configuration.go
+++ b/cc/cc_preprocess_no_configuration.go
@@ -16,6 +16,7 @@
import (
"android/soong/android"
+ "slices"
"strings"
)
@@ -78,6 +79,12 @@
return
}
+ cflags := slices.Clone(m.properties.Cflags)
+
+ // Match behavior of other cc modules:
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/soong/cc/compiler.go;l=422;drc=7297f05ee8cda422ccb32c4af4d9d715d6bac10e
+ cflags = append(cflags, "-I"+ctx.ModuleDir())
+
var ccCmd string
switch src.Ext() {
case ".c":
@@ -99,7 +106,7 @@
Output: outFile,
Input: src,
Args: map[string]string{
- "cFlags": strings.Join(m.properties.Cflags, " "),
+ "cFlags": strings.Join(cflags, " "),
"ccCmd": ccCmd,
},
})
diff --git a/cc/cc_preprocess_no_configuration_test.go b/cc/cc_preprocess_no_configuration_test.go
index 43e726d..c6eae4c 100644
--- a/cc/cc_preprocess_no_configuration_test.go
+++ b/cc/cc_preprocess_no_configuration_test.go
@@ -20,21 +20,24 @@
)
func TestCcPreprocessNoConfiguration(t *testing.T) {
+ bp := `
+ cc_preprocess_no_configuration {
+ name: "foo",
+ srcs: ["main.cc"],
+ cflags: ["-E", "-DANDROID"],
+ }
+ `
+
fixture := android.GroupFixturePreparers(
android.PrepareForIntegrationTestWithAndroid,
android.FixtureRegisterWithContext(RegisterCCPreprocessNoConfiguration),
+ android.FixtureAddTextFile("foo/bar/Android.bp", bp),
)
- result := fixture.RunTestWithBp(t, `
-cc_preprocess_no_configuration {
- name: "foo",
- srcs: ["main.cc"],
- cflags: ["-E", "-DANDROID"],
-}
-`)
+ result := fixture.RunTest(t)
foo := result.ModuleForTests("foo", "")
actual := foo.Rule("cc").Args["cFlags"]
- expected := "-E -DANDROID"
+ expected := "-E -DANDROID -Ifoo/bar"
android.AssertStringEquals(t, "cflags should be correct", expected, actual)
}
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 9d02e75..e075d08 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -339,58 +339,23 @@
// Creates a soong module to build the given partition. Returns false if we can't support building
// it.
func (f *filesystemCreator) createPartition(ctx android.LoadHookContext, partitionType string) bool {
- baseProps := generateBaseProps(proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), partitionType)))
-
- fsProps, supported := generateFsProps(ctx, partitionType)
- if !supported {
- return false
- }
-
- var module android.Module
- if partitionType == "system" {
- module = ctx.CreateModule(filesystem.SystemImageFactory, baseProps, fsProps)
- } else {
- // Explicitly set the partition.
- fsProps.Partition_type = proptools.StringPtr(partitionType)
- module = ctx.CreateModule(filesystem.FilesystemFactory, baseProps, fsProps)
- }
- module.HideFromMake()
- return true
-}
-
-type filesystemBaseProperty struct {
- Name *string
- Compile_multilib *string
-}
-
-func generateBaseProps(namePtr *string) *filesystemBaseProperty {
- return &filesystemBaseProperty{
- Name: namePtr,
+ baseProps := &struct {
+ Name *string
+ Compile_multilib *string
+ }{
+ Name: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), partitionType)),
Compile_multilib: proptools.StringPtr("both"),
}
-}
-func generateFsProps(ctx android.EarlyModuleContext, partitionType string) (*filesystem.FilesystemProperties, bool) {
fsProps := &filesystem.FilesystemProperties{}
- partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
- specificPartitionVars := partitionVars.PartitionQualifiedVariables[partitionType]
-
- // BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE
- fsType := specificPartitionVars.BoardFileSystemType
- if fsType == "" {
- fsType = "ext4" //default
- }
- fsProps.Type = proptools.StringPtr(fsType)
- if filesystem.GetFsTypeFromString(ctx, *fsProps.Type).IsUnknown() {
- // Currently the android_filesystem module type only supports a handful of FS types like ext4, erofs
- return nil, false
- }
-
// Don't build this module on checkbuilds, the soong-built partitions are still in-progress
// and sometimes don't build.
fsProps.Unchecked_module = proptools.BoolPtr(true)
+ partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
+ specificPartitionVars := partitionVars.PartitionQualifiedVariables[partitionType]
+
// BOARD_AVB_ENABLE
fsProps.Use_avb = proptools.BoolPtr(partitionVars.BoardAvbEnable)
// BOARD_AVB_KEY_PATH
@@ -403,6 +368,16 @@
}
fsProps.Partition_name = proptools.StringPtr(partitionType)
+ // BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE
+ fsType := specificPartitionVars.BoardFileSystemType
+ if fsType == "" {
+ fsType = "ext4" //default
+ }
+ fsProps.Type = proptools.StringPtr(fsType)
+ if filesystem.GetFsTypeFromString(ctx, *fsProps.Type).IsUnknown() {
+ // Currently the android_filesystem module type only supports a handful of FS types like ext4, erofs
+ return false
+ }
fsProps.Base_dir = proptools.StringPtr(partitionType)
@@ -433,8 +408,16 @@
// - filesystemProperties.Include_make_built_files
// - filesystemProperties.Build_logtags
// - systemImageProperties.Linker_config_src
-
- return fsProps, true
+ var module android.Module
+ if partitionType == "system" {
+ module = ctx.CreateModule(filesystem.SystemImageFactory, baseProps, fsProps)
+ } else {
+ // Explicitly set the partition.
+ fsProps.Partition_type = proptools.StringPtr(partitionType)
+ module = ctx.CreateModule(filesystem.FilesystemFactory, baseProps, fsProps)
+ }
+ module.HideFromMake()
+ return true
}
func (f *filesystemCreator) createDiffTest(ctx android.ModuleContext, partitionType string) android.Path {
@@ -499,29 +482,31 @@
var diffTestFiles []android.Path
for _, partitionType := range f.properties.Generated_partition_types {
- diffTestFiles = append(diffTestFiles, f.createDiffTest(ctx, partitionType))
+ diffTestFile := f.createDiffTest(ctx, partitionType)
+ diffTestFiles = append(diffTestFiles, diffTestFile)
+ ctx.Phony(fmt.Sprintf("soong_generated_%s_filesystem_test", partitionType), diffTestFile)
}
for _, partitionType := range f.properties.Unsupported_partition_types {
- diffTestFiles = append(diffTestFiles, createFailingCommand(ctx, fmt.Sprintf("Couldn't build %s partition", partitionType)))
+ diffTestFile := createFailingCommand(ctx, fmt.Sprintf("Couldn't build %s partition", partitionType))
+ diffTestFiles = append(diffTestFiles, diffTestFile)
+ ctx.Phony(fmt.Sprintf("soong_generated_%s_filesystem_test", partitionType), diffTestFile)
}
ctx.Phony("soong_generated_filesystem_tests", diffTestFiles...)
}
+// TODO: assemble baseProps and fsProps here
func generateBpContent(ctx android.EarlyModuleContext, partitionType string) string {
// Currently only system partition is supported
if partitionType != "system" {
return ""
}
- baseProps := generateBaseProps(proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), partitionType)))
- fsProps, _ := generateFsProps(ctx, partitionType)
-
deps := ctx.Config().Get(fsGenStateOnceKey).(*FsGenState).fsDeps
depProps := &android.PackagingProperties{
Deps: android.NewSimpleConfigurable(fullyQualifiedModuleNames(deps[partitionType])),
}
- result, err := proptools.RepackProperties([]interface{}{baseProps, fsProps, depProps})
+ result, err := proptools.RepackProperties([]interface{}{depProps})
if err != nil {
ctx.ModuleErrorf(err.Error())
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 637da36..5928446 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -562,7 +562,7 @@
// TODO(b/346662300): Let dexpreopter generate the installPath for dexpreopt files instead of
// using the dex location to generate the installPath.
if isApexSystemServerJar {
- dexpreoptPartition = "system"
+ dexpreoptPartition = dexpreoptConfig.ApexPartition
}
for _, install := range dexpreoptRule.Installs() {
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.