Merge "Generate SBOM of products in Soong." into main
diff --git a/android/config.go b/android/config.go
index 0e3b0a1..cadc929 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1195,6 +1195,10 @@
return Bool(c.productVariables.UseGoma)
}
+func (c *config) UseABFS() bool {
+ return Bool(c.productVariables.UseABFS)
+}
+
func (c *config) UseRBE() bool {
return Bool(c.productVariables.UseRBE)
}
@@ -1356,10 +1360,6 @@
return ExistentPathForSource(ctx, "frameworks", "base", "Android.bp").Valid()
}
-func (c *config) VndkSnapshotBuildArtifacts() bool {
- return Bool(c.productVariables.VndkSnapshotBuildArtifacts)
-}
-
func (c *config) HasMultilibConflict(arch ArchType) bool {
return c.multilibConflicts[arch]
}
@@ -1423,10 +1423,6 @@
return "vendor"
}
-func (c *deviceConfig) RecoverySnapshotVersion() string {
- return String(c.config.productVariables.RecoverySnapshotVersion)
-}
-
func (c *deviceConfig) CurrentApiLevelForVendorModules() string {
return StringDefault(c.config.productVariables.DeviceCurrentApiLevelForVendorModules, "current")
}
@@ -1804,22 +1800,6 @@
return c.SystemExtSepolicyPrebuiltApiDir() != "" || c.ProductSepolicyPrebuiltApiDir() != ""
}
-func (c *deviceConfig) DirectedVendorSnapshot() bool {
- return c.config.productVariables.DirectedVendorSnapshot
-}
-
-func (c *deviceConfig) VendorSnapshotModules() map[string]bool {
- return c.config.productVariables.VendorSnapshotModules
-}
-
-func (c *deviceConfig) DirectedRecoverySnapshot() bool {
- return c.config.productVariables.DirectedRecoverySnapshot
-}
-
-func (c *deviceConfig) RecoverySnapshotModules() map[string]bool {
- return c.config.productVariables.RecoverySnapshotModules
-}
-
func createDirsMap(previous map[string]bool, dirs []string) (map[string]bool, error) {
var ret = make(map[string]bool)
for _, dir := range dirs {
@@ -1846,40 +1826,6 @@
return dirMap.(map[string]bool)
}
-var vendorSnapshotDirsExcludedKey = NewOnceKey("VendorSnapshotDirsExcludedMap")
-
-func (c *deviceConfig) VendorSnapshotDirsExcludedMap() map[string]bool {
- return c.createDirsMapOnce(vendorSnapshotDirsExcludedKey, nil,
- c.config.productVariables.VendorSnapshotDirsExcluded)
-}
-
-var vendorSnapshotDirsIncludedKey = NewOnceKey("VendorSnapshotDirsIncludedMap")
-
-func (c *deviceConfig) VendorSnapshotDirsIncludedMap() map[string]bool {
- excludedMap := c.VendorSnapshotDirsExcludedMap()
- return c.createDirsMapOnce(vendorSnapshotDirsIncludedKey, excludedMap,
- c.config.productVariables.VendorSnapshotDirsIncluded)
-}
-
-var recoverySnapshotDirsExcludedKey = NewOnceKey("RecoverySnapshotDirsExcludedMap")
-
-func (c *deviceConfig) RecoverySnapshotDirsExcludedMap() map[string]bool {
- return c.createDirsMapOnce(recoverySnapshotDirsExcludedKey, nil,
- c.config.productVariables.RecoverySnapshotDirsExcluded)
-}
-
-var recoverySnapshotDirsIncludedKey = NewOnceKey("RecoverySnapshotDirsIncludedMap")
-
-func (c *deviceConfig) RecoverySnapshotDirsIncludedMap() map[string]bool {
- excludedMap := c.RecoverySnapshotDirsExcludedMap()
- return c.createDirsMapOnce(recoverySnapshotDirsIncludedKey, excludedMap,
- c.config.productVariables.RecoverySnapshotDirsIncluded)
-}
-
-func (c *deviceConfig) HostFakeSnapshotEnabled() bool {
- return c.config.productVariables.HostFakeSnapshotEnabled
-}
-
func (c *deviceConfig) ShippingApiLevel() ApiLevel {
if c.config.productVariables.Shipping_api_level == nil {
return NoneApiLevel
diff --git a/android/defaults.go b/android/defaults.go
index ff79002..ba26e00 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -28,7 +28,7 @@
var DefaultsDepTag defaultsDependencyTag
type defaultsProperties struct {
- Defaults []string
+ Defaults proptools.Configurable[[]string]
}
type DefaultableModuleBase struct {
@@ -278,13 +278,14 @@
func defaultsDepsMutator(ctx BottomUpMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok {
- ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults...)
+ ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)...)
}
}
func defaultsMutator(ctx TopDownMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok {
- if len(defaultable.defaults().Defaults) > 0 {
+ defaults := defaultable.defaults().Defaults.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)
+ if len(defaults) > 0 {
var defaultsList []Defaults
seen := make(map[Defaults]bool)
@@ -294,7 +295,7 @@
if !seen[defaults] {
seen[defaults] = true
defaultsList = append(defaultsList, defaults)
- return len(defaults.defaults().Defaults) > 0
+ return len(defaults.defaults().Defaults.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)) > 0
}
} else {
ctx.PropertyErrorf("defaults", "module %s is not an defaults module",
diff --git a/android/module.go b/android/module.go
index 37e26f9..39c257c 100644
--- a/android/module.go
+++ b/android/module.go
@@ -389,7 +389,7 @@
Init_rc []string `android:"arch_variant,path"`
// VINTF manifest fragments to be installed if this module is installed
- Vintf_fragments []string `android:"path"`
+ Vintf_fragments proptools.Configurable[[]string] `android:"path"`
// names of other modules to install if this module is installed
Required proptools.Configurable[[]string] `android:"arch_variant"`
@@ -1853,7 +1853,7 @@
}
}
- m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments)
+ m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments.GetOrDefault(m.ConfigurableEvaluator(ctx), nil))
vintfDir := PathForModuleInstall(ctx, "etc", "vintf", "manifest")
for _, src := range m.vintfFragmentsPaths {
installedVintfFragment := vintfDir.Join(ctx, src.Base())
diff --git a/android/module_test.go b/android/module_test.go
index 922ea21..829c079 100644
--- a/android/module_test.go
+++ b/android/module_test.go
@@ -722,7 +722,6 @@
propInfo{Name: "Arch.X86_64.A", Type: "string", Value: "x86_64 a"},
propInfo{Name: "B", Type: "bool", Value: "true"},
propInfo{Name: "C", Type: "string slice", Values: []string{"default_c", "c"}},
- propInfo{Name: "Defaults", Type: "string slice", Values: []string{"foo_defaults"}},
propInfo{Name: "Embedded_prop", Type: "string", Value: "a"},
propInfo{Name: "Name", Type: "string", Value: "foo"},
propInfo{Name: "Nested.E", Type: "string", Value: "nested e"},
@@ -746,7 +745,6 @@
foo := result.ModuleForTests("foo", "").Module().base()
AssertDeepEquals(t, "foo ", tc.expectedProps, foo.propertiesWithValues())
-
})
}
}
diff --git a/android/variable.go b/android/variable.go
index b2173ec..df0e59c 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -239,8 +239,6 @@
VendorApiLevel *string `json:",omitempty"`
- RecoverySnapshotVersion *string `json:",omitempty"`
-
DeviceSecondaryArch *string `json:",omitempty"`
DeviceSecondaryArchVariant *string `json:",omitempty"`
DeviceSecondaryCpuVariant *string `json:",omitempty"`
@@ -296,6 +294,7 @@
HostStaticBinaries *bool `json:",omitempty"`
Binder32bit *bool `json:",omitempty"`
UseGoma *bool `json:",omitempty"`
+ UseABFS *bool `json:",omitempty"`
UseRBE *bool `json:",omitempty"`
UseRBEJAVAC *bool `json:",omitempty"`
UseRBER8 *bool `json:",omitempty"`
@@ -373,20 +372,6 @@
PgoAdditionalProfileDirs []string `json:",omitempty"`
- VndkSnapshotBuildArtifacts *bool `json:",omitempty"`
-
- DirectedVendorSnapshot bool `json:",omitempty"`
- VendorSnapshotModules map[string]bool `json:",omitempty"`
-
- DirectedRecoverySnapshot bool `json:",omitempty"`
- RecoverySnapshotModules map[string]bool `json:",omitempty"`
-
- VendorSnapshotDirsIncluded []string `json:",omitempty"`
- VendorSnapshotDirsExcluded []string `json:",omitempty"`
- RecoverySnapshotDirsExcluded []string `json:",omitempty"`
- RecoverySnapshotDirsIncluded []string `json:",omitempty"`
- HostFakeSnapshotEnabled bool `json:",omitempty"`
-
MultitreeUpdateMeta bool `json:",omitempty"`
BoardVendorSepolicyDirs []string `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index c1a9d74..4c36458 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -86,7 +86,7 @@
// AndroidManifest.xml file used for the zip container of this APEX bundle. If unspecified,
// a default one is automatically generated.
- AndroidManifest *string `android:"path"`
+ AndroidManifest proptools.Configurable[string] `android:"path,replace_instead_of_append"`
// Determines the file contexts file for setting the security contexts to files in this APEX
// bundle. For platform APEXes, this should points to a file under /system/sepolicy Default:
@@ -104,7 +104,7 @@
// path_or_glob is a path or glob pattern for a file or set of files,
// uid/gid are numerial values of user ID and group ID, mode is octal value
// for the file mode, and cap is hexadecimal value for the capability.
- Canned_fs_config *string `android:"path"`
+ Canned_fs_config proptools.Configurable[string] `android:"path,replace_instead_of_append"`
ApexNativeDependencies
@@ -117,7 +117,8 @@
Bootclasspath_fragments []string
// List of systemserverclasspath fragments that are embedded inside this APEX bundle.
- Systemserverclasspath_fragments []string
+ Systemserverclasspath_fragments proptools.Configurable[[]string]
+ ResolvedSystemserverclasspathFragments []string `blueprint:"mutated"`
// List of java libraries that are embedded inside this APEX bundle.
Java_libs []string
@@ -221,7 +222,8 @@
Rust_dyn_libs []string
// List of native executables that are embedded inside this APEX.
- Binaries []string
+ Binaries proptools.Configurable[[]string]
+ ResolvedBinaries []string `blueprint:"mutated"`
// List of native tests that are embedded inside this APEX.
Tests []string
@@ -230,7 +232,8 @@
Filesystems []string
// List of prebuilt_etcs that are embedded inside this APEX bundle.
- Prebuilts []string
+ Prebuilts proptools.Configurable[[]string]
+ ResolvedPrebuilts []string `blueprint:"mutated"`
// List of native libraries to exclude from this APEX.
Exclude_native_shared_libs []string
@@ -255,14 +258,14 @@
}
// Merge combines another ApexNativeDependencies into this one
-func (a *ApexNativeDependencies) Merge(b ApexNativeDependencies) {
+func (a *ApexNativeDependencies) Merge(ctx android.BaseMutatorContext, b ApexNativeDependencies) {
a.Native_shared_libs = append(a.Native_shared_libs, b.Native_shared_libs...)
a.Jni_libs = append(a.Jni_libs, b.Jni_libs...)
a.Rust_dyn_libs = append(a.Rust_dyn_libs, b.Rust_dyn_libs...)
- a.Binaries = append(a.Binaries, b.Binaries...)
+ a.ResolvedBinaries = append(a.ResolvedBinaries, b.Binaries.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)...)
a.Tests = append(a.Tests, b.Tests...)
a.Filesystems = append(a.Filesystems, b.Filesystems...)
- a.Prebuilts = append(a.Prebuilts, b.Prebuilts...)
+ a.ResolvedPrebuilts = append(a.ResolvedPrebuilts, b.Prebuilts.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)...)
a.Exclude_native_shared_libs = append(a.Exclude_native_shared_libs, b.Exclude_native_shared_libs...)
a.Exclude_jni_libs = append(a.Exclude_jni_libs, b.Exclude_jni_libs...)
@@ -338,10 +341,10 @@
// base apex.
type overridableProperties struct {
// List of APKs that are embedded inside this APEX.
- Apps []string
+ Apps proptools.Configurable[[]string]
// List of prebuilt files that are embedded inside this APEX bundle.
- Prebuilts []string
+ Prebuilts proptools.Configurable[[]string]
// List of BPF programs inside this APEX bundle.
Bpfs []string
@@ -715,7 +718,7 @@
// this module. This is required since arch variant of an APEX bundle is 'common' but it is
// 'arm' or 'arm64' for native shared libs.
ctx.AddFarVariationDependencies(binVariations, executableTag,
- android.RemoveListFromList(nativeModules.Binaries, nativeModules.Exclude_binaries)...)
+ android.RemoveListFromList(nativeModules.ResolvedBinaries, nativeModules.Exclude_binaries)...)
ctx.AddFarVariationDependencies(binVariations, testTag,
android.RemoveListFromList(nativeModules.Tests, nativeModules.Exclude_tests)...)
ctx.AddFarVariationDependencies(libVariations, jniLibTag,
@@ -727,7 +730,7 @@
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
ctx.AddFarVariationDependencies(target.Variations(), prebuiltTag,
- android.RemoveListFromList(nativeModules.Prebuilts, nativeModules.Exclude_prebuilts)...)
+ android.RemoveListFromList(nativeModules.ResolvedPrebuilts, nativeModules.Exclude_prebuilts)...)
}
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
@@ -782,20 +785,19 @@
// Add native modules targeting both ABIs. When multilib.* is omitted for
// native_shared_libs/jni_libs/tests, it implies multilib.both
- deps.Merge(a.properties.Multilib.Both)
- deps.Merge(ApexNativeDependencies{
+ deps.Merge(ctx, a.properties.Multilib.Both)
+ deps.Merge(ctx, ApexNativeDependencies{
Native_shared_libs: a.properties.Native_shared_libs,
Tests: a.properties.Tests,
Jni_libs: a.properties.Jni_libs,
- Binaries: nil,
})
// Add native modules targeting the first ABI When multilib.* is omitted for
// binaries, it implies multilib.first
isPrimaryAbi := i == 0
if isPrimaryAbi {
- deps.Merge(a.properties.Multilib.First)
- deps.Merge(ApexNativeDependencies{
+ deps.Merge(ctx, a.properties.Multilib.First)
+ deps.Merge(ctx, ApexNativeDependencies{
Native_shared_libs: nil,
Tests: nil,
Jni_libs: nil,
@@ -806,27 +808,27 @@
// Add native modules targeting either 32-bit or 64-bit ABI
switch target.Arch.ArchType.Multilib {
case "lib32":
- deps.Merge(a.properties.Multilib.Lib32)
- deps.Merge(a.properties.Multilib.Prefer32)
+ deps.Merge(ctx, a.properties.Multilib.Lib32)
+ deps.Merge(ctx, a.properties.Multilib.Prefer32)
case "lib64":
- deps.Merge(a.properties.Multilib.Lib64)
+ deps.Merge(ctx, a.properties.Multilib.Lib64)
if !has32BitTarget {
- deps.Merge(a.properties.Multilib.Prefer32)
+ deps.Merge(ctx, a.properties.Multilib.Prefer32)
}
}
// Add native modules targeting a specific arch variant
switch target.Arch.ArchType {
case android.Arm:
- deps.Merge(a.archProperties.Arch.Arm.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.Arm.ApexNativeDependencies)
case android.Arm64:
- deps.Merge(a.archProperties.Arch.Arm64.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.Arm64.ApexNativeDependencies)
case android.Riscv64:
- deps.Merge(a.archProperties.Arch.Riscv64.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.Riscv64.ApexNativeDependencies)
case android.X86:
- deps.Merge(a.archProperties.Arch.X86.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.X86.ApexNativeDependencies)
case android.X86_64:
- deps.Merge(a.archProperties.Arch.X86_64.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.X86_64.ApexNativeDependencies)
default:
panic(fmt.Errorf("unsupported arch %v\n", ctx.Arch().ArchType))
}
@@ -840,11 +842,13 @@
}
}
+ a.properties.ResolvedSystemserverclasspathFragments = a.properties.Systemserverclasspath_fragments.GetOrDefault(a.ConfigurableEvaluator(ctx), nil)
+
// Common-arch dependencies come next
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
ctx.AddFarVariationDependencies(commonVariation, rroTag, a.properties.Rros...)
ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...)
- ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments...)
+ ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.ResolvedSystemserverclasspathFragments...)
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...)
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...)
@@ -857,9 +861,9 @@
}
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
- ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...)
+ ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps.GetOrDefault(a.ConfigurableEvaluator(ctx), nil)...)
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.overridableProperties.Bpfs...)
- if prebuilts := a.overridableProperties.Prebuilts; len(prebuilts) > 0 {
+ if prebuilts := a.overridableProperties.Prebuilts.GetOrDefault(a.ConfigurableEvaluator(ctx), nil); len(prebuilts) > 0 {
// For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device)
// regardless of the TARGET_PREFER_* setting. See b/144532908
arches := ctx.DeviceConfig().Arches()
@@ -1492,7 +1496,6 @@
Native_shared_libs: []string{"libclang_rt.hwasan"},
Tests: nil,
Jni_libs: nil,
- Binaries: nil,
}, target, imageVariation)
break
}
@@ -2806,7 +2809,7 @@
func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...)
- dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments...)
+ dpInfo.Deps = append(dpInfo.Deps, a.properties.ResolvedSystemserverclasspathFragments...)
}
var (
diff --git a/apex/apex_test.go b/apex/apex_test.go
index a2dbbfc..f62ee68 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11738,3 +11738,121 @@
}
`)
}
+
+func TestPrebuiltStubNoinstall(t *testing.T) {
+ testFunc := func(t *testing.T, expectLibfooOnSystemLib bool, fs android.MockFS) {
+ result := android.GroupFixturePreparers(
+ prepareForApexTest,
+ android.PrepareForTestWithAndroidMk,
+ android.PrepareForTestWithMakevars,
+ android.FixtureMergeMockFs(fs),
+ ).RunTest(t)
+
+ ldRule := result.ModuleForTests("installedlib", "android_arm64_armv8-a_shared").Rule("ld")
+ android.AssertStringDoesContain(t, "", ldRule.Args["libFlags"], "android_arm64_armv8-a_shared/libfoo.so")
+
+ installRules := result.InstallMakeRulesForTesting(t)
+
+ var installedlibRule *android.InstallMakeRule
+ for i, rule := range installRules {
+ if rule.Target == "out/target/product/test_device/system/lib/installedlib.so" {
+ if installedlibRule != nil {
+ t.Errorf("Duplicate install rules for %s", rule.Target)
+ }
+ installedlibRule = &installRules[i]
+ }
+ }
+ if installedlibRule == nil {
+ t.Errorf("No install rule found for installedlib")
+ return
+ }
+
+ if expectLibfooOnSystemLib {
+ android.AssertStringListContains(t,
+ "installedlib doesn't have install dependency on libfoo impl",
+ installedlibRule.OrderOnlyDeps,
+ "out/target/product/test_device/system/lib/libfoo.so")
+ } else {
+ android.AssertStringListDoesNotContain(t,
+ "installedlib has install dependency on libfoo stub",
+ installedlibRule.Deps,
+ "out/target/product/test_device/system/lib/libfoo.so")
+ android.AssertStringListDoesNotContain(t,
+ "installedlib has order-only install dependency on libfoo stub",
+ installedlibRule.OrderOnlyDeps,
+ "out/target/product/test_device/system/lib/libfoo.so")
+ }
+ }
+
+ prebuiltLibfooBp := []byte(`
+ cc_prebuilt_library {
+ name: "libfoo",
+ prefer: true,
+ srcs: ["libfoo.so"],
+ stubs: {
+ versions: ["1"],
+ },
+ apex_available: ["apexfoo"],
+ }
+ `)
+
+ apexfooBp := []byte(`
+ apex {
+ name: "apexfoo",
+ key: "apexfoo.key",
+ native_shared_libs: ["libfoo"],
+ updatable: false,
+ compile_multilib: "both",
+ }
+ apex_key {
+ name: "apexfoo.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+
+ installedlibBp := []byte(`
+ cc_library {
+ name: "installedlib",
+ shared_libs: ["libfoo"],
+ }
+ `)
+
+ t.Run("prebuilt stub (without source): no install", func(t *testing.T) {
+ testFunc(
+ t,
+ /*expectLibfooOnSystemLib=*/ false,
+ android.MockFS{
+ "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp,
+ "apexfoo/Android.bp": apexfooBp,
+ "system/sepolicy/apex/apexfoo-file_contexts": nil,
+ "Android.bp": installedlibBp,
+ },
+ )
+ })
+
+ disabledSourceLibfooBp := []byte(`
+ cc_library {
+ name: "libfoo",
+ enabled: false,
+ stubs: {
+ versions: ["1"],
+ },
+ apex_available: ["apexfoo"],
+ }
+ `)
+
+ t.Run("prebuilt stub (with disabled source): no install", func(t *testing.T) {
+ testFunc(
+ t,
+ /*expectLibfooOnSystemLib=*/ false,
+ android.MockFS{
+ "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp,
+ "impl/Android.bp": disabledSourceLibfooBp,
+ "apexfoo/Android.bp": apexfooBp,
+ "system/sepolicy/apex/apexfoo-file_contexts": nil,
+ "Android.bp": installedlibBp,
+ },
+ )
+ })
+}
diff --git a/apex/builder.go b/apex/builder.go
index 763ce4d..6f645ab 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -704,8 +704,9 @@
optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
}
- if a.properties.AndroidManifest != nil {
- androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest))
+ androidManifest := a.properties.AndroidManifest.GetOrDefault(a.ConfigurableEvaluator(ctx), "")
+ if androidManifest != "" {
+ androidManifestFile := android.PathForModuleSrc(ctx, androidManifest)
if a.testApex {
androidManifestFile = markManifestTestOnly(ctx, androidManifestFile)
@@ -1195,8 +1196,9 @@
}
// Custom fs_config is "appended" to the last so that entries from the file are preferred
// over default ones set above.
- if a.properties.Canned_fs_config != nil {
- cmd.Text("cat").Input(android.PathForModuleSrc(ctx, *a.properties.Canned_fs_config))
+ customFsConfig := a.properties.Canned_fs_config.GetOrDefault(a.ConfigurableEvaluator(ctx), "")
+ if customFsConfig != "" {
+ cmd.Text("cat").Input(android.PathForModuleSrc(ctx, customFsConfig))
}
cmd.Text(")").FlagWithOutput("> ", cannedFsConfig)
builder.Build("generateFsConfig", fmt.Sprintf("Generating canned fs config for %s", a.BaseModuleName()))
diff --git a/bin/installmod b/bin/installmod
index 1d0d836..1ad5b84 100755
--- a/bin/installmod
+++ b/bin/installmod
@@ -28,7 +28,6 @@
return 1
fi
-local _path
_path=$(outmod ${@:$#:1})
if [ $? -ne 0 ]; then
return 1
@@ -39,7 +38,7 @@
echo "Module '$1' does not produce a file ending with .apk (try 'refreshmod' if there have been build changes?)" >&2
return 1
fi
-local serial_device=""
+serial_device=""
if [[ "$1" == "-s" ]]; then
if [[ $# -le 2 ]]; then
echo "-s requires an argument" >&2
@@ -48,7 +47,7 @@
serial_device="-s $2"
shift 2
fi
-local length=$(( $# - 1 ))
+length=$(( $# - 1 ))
echo adb $serial_device install ${@:1:$length} $_path
adb $serial_device install ${@:1:$length} $_path
diff --git a/cc/cc.go b/cc/cc.go
index 64b2465..3c17be6 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -4079,6 +4079,13 @@
return c.ModuleBase.BaseModuleName()
}
+func (c *Module) stubsSymbolFilePath() android.Path {
+ if library, ok := c.linker.(*libraryDecorator); ok {
+ return library.stubsSymbolFilePath
+ }
+ return android.OptionalPath{}.Path()
+}
+
var Bool = proptools.Bool
var BoolDefault = proptools.BoolDefault
var BoolPtr = proptools.BoolPtr
diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go
index fb2924a..8f3ad96 100644
--- a/cc/cmake_snapshot.go
+++ b/cc/cmake_snapshot.go
@@ -347,8 +347,11 @@
if slices.Contains(ignoredSystemLibs, moduleName) {
return false // system libs built in-tree for Android
}
+ if dep.IsPrebuilt() {
+ return false // prebuilts are not supported
+ }
if dep.compiler == nil {
- return false // unsupported module type (e.g. prebuilt)
+ return false // unsupported module type
}
isAidlModule := dep.compiler.baseCompilerProps().AidlInterface.Lang != ""
diff --git a/cc/library.go b/cc/library.go
index 6dd5b56..092b177 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -64,7 +64,7 @@
Stubs struct {
// Relative path to the symbol map. The symbol map provides the list of
// symbols that are exported for stubs variant of this library.
- Symbol_file *string `android:"path"`
+ Symbol_file *string `android:"path,arch_variant"`
// List versions to generate stubs libs for. The version name "current" is always
// implicitly added.
@@ -75,7 +75,7 @@
// implementation is made available by some other means, e.g. in a Microdroid
// virtual machine.
Implementation_installable *bool
- }
+ } `android:"arch_variant"`
// set the name of the output
Stem *string `android:"arch_variant"`
@@ -118,7 +118,7 @@
// If this is an LLNDK library, properties to describe the LLNDK stubs. Will be copied from
// the module pointed to by llndk_stubs if it is set.
- Llndk llndkLibraryProperties
+ Llndk llndkLibraryProperties `android:"arch_variant"`
// If this is a vendor public library, properties to describe the vendor public library stubs.
Vendor_public_library vendorPublicLibraryProperties
@@ -428,6 +428,9 @@
*baseInstaller
apiListCoverageXmlPath android.ModuleOutPath
+
+ // Path to the file containing the APIs exported by this library
+ stubsSymbolFilePath android.Path
}
// linkerProps returns the list of properties structs relevant for this library. (For example, if
@@ -596,6 +599,7 @@
ctx.PropertyErrorf("symbol_file", "%q doesn't have .map.txt suffix", symbolFile)
return Objects{}
}
+ library.stubsSymbolFilePath = android.PathForModuleSrc(ctx, symbolFile)
// b/239274367 --apex and --systemapi filters symbols tagged with # apex and #
// systemapi, respectively. The former is for symbols defined in platform libraries
// and the latter is for symbols defined in APEXes.
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 1f71c19..e8a9827 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -406,6 +406,9 @@
if len(libInfo.StubsVersions) > 0 {
stubsSet := outputProperties.AddPropertySet("stubs")
stubsSet.AddProperty("versions", libInfo.StubsVersions)
+ // The symbol file will be copied next to the Android.bp file
+ stubsSet.AddProperty("symbol_file", libInfo.StubsSymbolFilePath.Base())
+ builder.CopyToSnapshot(libInfo.StubsSymbolFilePath, libInfo.StubsSymbolFilePath.Base())
}
}
@@ -481,6 +484,9 @@
// is written to does not vary by arch so cannot be android specific.
StubsVersions []string `sdk:"ignored-on-host"`
+ // The symbol file containing the APIs exported by this library.
+ StubsSymbolFilePath android.Path `sdk:"ignored-on-host"`
+
// Value of SanitizeProperties.Sanitize. Several - but not all - of these
// affect the expanded variants. All are propagated to avoid entangling the
// sanitizer logic with the snapshot generation.
@@ -549,6 +555,11 @@
// the versioned stub libs are retained in the prebuilt tree; currently only
// the stub corresponding to ccModule.StubsVersion() is.
p.StubsVersions = lib.allStubsVersions()
+ if lib.buildStubs() && ccModule.stubsSymbolFilePath() == nil {
+ ctx.ModuleErrorf("Could not determine symbol_file")
+ } else {
+ p.StubsSymbolFilePath = ccModule.stubsSymbolFilePath()
+ }
}
}
p.SystemSharedLibs = specifiedDeps.systemSharedLibs
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 85c3edf..5ece78a 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -30,7 +30,7 @@
type llndkLibraryProperties struct {
// Relative path to the symbol map.
// An example file can be seen here: TODO(danalbert): Make an example.
- Symbol_file *string
+ Symbol_file *string `android:"path,arch_variant"`
// Whether to export any headers as -isystem instead of -I. Mainly for use by
// bionic/libc.
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index e9f790f..e023a32 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -205,17 +205,6 @@
TableOfContents: p.tocFile,
})
- // TODO(b/220898484): Mainline module sdk prebuilts of stub libraries use a stub
- // library as their source and must not be installed, but other prebuilts like
- // libclang_rt.* libraries set `stubs` property because they are LLNDK libraries,
- // but use an implementation library as their source and need to be installed.
- // This discrepancy should be resolved without the prefix hack below.
- isModuleSdkPrebuilts := android.HasAnyPrefix(ctx.ModuleDir(), []string{
- "prebuilts/runtime/mainline/", "prebuilts/module_sdk/"})
- if p.hasStubsVariants() && !p.buildStubs() && !ctx.Host() && isModuleSdkPrebuilts {
- ctx.Module().MakeUninstallable()
- }
-
return outputFile
}
}
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 71b7e43..86e6af9 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -385,112 +385,6 @@
assertString(t, static2.OutputFile().Path().Base(), "libf.hwasan.a")
}
-func TestPrebuiltStubNoinstall(t *testing.T) {
- testFunc := func(t *testing.T, expectLibfooOnSystemLib bool, fs android.MockFS) {
- result := android.GroupFixturePreparers(
- prepareForPrebuiltTest,
- android.PrepareForTestWithMakevars,
- android.FixtureMergeMockFs(fs),
- ).RunTest(t)
-
- ldRule := result.ModuleForTests("installedlib", "android_arm64_armv8-a_shared").Rule("ld")
- android.AssertStringDoesContain(t, "", ldRule.Args["libFlags"], "android_arm64_armv8-a_shared/libfoo.so")
-
- installRules := result.InstallMakeRulesForTesting(t)
- var installedlibRule *android.InstallMakeRule
- for i, rule := range installRules {
- if rule.Target == "out/target/product/test_device/system/lib/installedlib.so" {
- if installedlibRule != nil {
- t.Errorf("Duplicate install rules for %s", rule.Target)
- }
- installedlibRule = &installRules[i]
- }
- }
- if installedlibRule == nil {
- t.Errorf("No install rule found for installedlib")
- return
- }
-
- if expectLibfooOnSystemLib {
- android.AssertStringListContains(t,
- "installedlib doesn't have install dependency on libfoo impl",
- installedlibRule.OrderOnlyDeps,
- "out/target/product/test_device/system/lib/libfoo.so")
- } else {
- android.AssertStringListDoesNotContain(t,
- "installedlib has install dependency on libfoo stub",
- installedlibRule.Deps,
- "out/target/product/test_device/system/lib/libfoo.so")
- android.AssertStringListDoesNotContain(t,
- "installedlib has order-only install dependency on libfoo stub",
- installedlibRule.OrderOnlyDeps,
- "out/target/product/test_device/system/lib/libfoo.so")
- }
- }
-
- prebuiltLibfooBp := []byte(`
- cc_prebuilt_library {
- name: "libfoo",
- prefer: true,
- srcs: ["libfoo.so"],
- stubs: {
- versions: ["1"],
- },
- }
- `)
-
- installedlibBp := []byte(`
- cc_library {
- name: "installedlib",
- shared_libs: ["libfoo"],
- }
- `)
-
- t.Run("prebuilt stub (without source): no install", func(t *testing.T) {
- testFunc(
- t,
- /*expectLibfooOnSystemLib=*/ false,
- android.MockFS{
- "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp,
- "Android.bp": installedlibBp,
- },
- )
- })
-
- disabledSourceLibfooBp := []byte(`
- cc_library {
- name: "libfoo",
- enabled: false,
- stubs: {
- versions: ["1"],
- },
- }
- `)
-
- t.Run("prebuilt stub (with disabled source): no install", func(t *testing.T) {
- testFunc(
- t,
- /*expectLibfooOnSystemLib=*/ false,
- android.MockFS{
- "prebuilts/module_sdk/art/current/Android.bp": prebuiltLibfooBp,
- "impl/Android.bp": disabledSourceLibfooBp,
- "Android.bp": installedlibBp,
- },
- )
- })
-
- t.Run("prebuilt impl (with `stubs` property set): install", func(t *testing.T) {
- testFunc(
- t,
- /*expectLibfooOnSystemLib=*/ true,
- android.MockFS{
- "impl/Android.bp": prebuiltLibfooBp,
- "Android.bp": installedlibBp,
- },
- )
- })
-}
-
func TestPrebuiltBinaryNoSrcsNoError(t *testing.T) {
const bp = `
cc_prebuilt_binary {
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index b69a76f..5616483 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -244,6 +244,7 @@
}
odexPath := module.BuildPath.InSameDir(ctx, "oat", arch.String(), pathtools.ReplaceExtension(base, "odex"))
+ odexSymbolsPath := odexPath.ReplaceExtension(ctx, "symbols.odex")
odexInstallPath := ToOdexPath(module.DexLocation, arch)
if odexOnSystemOther(module, global) {
odexInstallPath = filepath.Join(SystemOtherPartition, odexInstallPath)
@@ -258,7 +259,8 @@
systemServerClasspathJars := global.AllSystemServerClasspathJars(ctx)
rule.Command().FlagWithArg("mkdir -p ", filepath.Dir(odexPath.String()))
- rule.Command().FlagWithOutput("rm -f ", odexPath)
+ rule.Command().FlagWithOutput("rm -f ", odexPath).
+ FlagWithArg("rm -f ", odexSymbolsPath.String())
if jarIndex := systemServerJars.IndexOfJar(module.Name); jarIndex >= 0 {
// System server jars should be dexpreopted together: class loader context of each jar
@@ -386,7 +388,9 @@
FlagWithArg("--instruction-set=", arch.String()).
FlagWithArg("--instruction-set-variant=", global.CpuVariant[arch]).
FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]).
- Flag("--no-generate-debug-info").
+ FlagWithOutput("--oat-symbols=", odexSymbolsPath).
+ Flag("--generate-debug-info").
+ Flag("--strip").
Flag("--generate-build-id").
Flag("--abort-on-hard-verifier-error").
Flag("--force-determinism").
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 5b40768..08d857d 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -139,7 +139,8 @@
Export_include_dirs []string
// list of input files
- Srcs []string `android:"path,arch_variant"`
+ Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
+ ResolvedSrcs []string `blueprint:"mutated"`
// input files to exclude
Exclude_srcs []string `android:"path,arch_variant"`
@@ -382,7 +383,8 @@
}
return srcFiles
}
- srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs)
+ g.properties.ResolvedSrcs = g.properties.Srcs.GetOrDefault(g.ConfigurableEvaluator(ctx), nil)
+ srcFiles := addLabelsForInputs("srcs", g.properties.ResolvedSrcs, g.properties.Exclude_srcs)
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcFiles.Strings()})
var copyFrom android.Paths
@@ -589,7 +591,7 @@
// Collect information for opening IDE project files in java/jdeps.go.
func (g *Module) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Srcs = append(dpInfo.Srcs, g.Srcs().Strings()...)
- for _, src := range g.properties.Srcs {
+ for _, src := range g.properties.ResolvedSrcs {
if strings.HasPrefix(src, ":") {
src = strings.Trim(src, ":")
dpInfo.Deps = append(dpInfo.Deps, src)
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index fba9aec..444aedb 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -694,7 +694,7 @@
android.AssertStringEquals(t, "cmd", expectedCmd, gen.rawCommands[0])
expectedSrcs := []string{"in1"}
- android.AssertDeepEquals(t, "srcs", expectedSrcs, gen.properties.Srcs)
+ android.AssertDeepEquals(t, "srcs", expectedSrcs, gen.properties.ResolvedSrcs)
}
func TestGenruleAllowMissingDependencies(t *testing.T) {
diff --git a/java/app_import.go b/java/app_import.go
index fa87997..045a89a 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -431,6 +431,9 @@
var extraArgs []string
if a.Privileged() {
extraArgs = append(extraArgs, "--privileged")
+ if ctx.Config().UncompressPrivAppDex() {
+ extraArgs = append(extraArgs, "--uncompress-priv-app-dex")
+ }
}
if proptools.Bool(a.properties.Skip_preprocessed_apk_checks) {
extraArgs = append(extraArgs, "--skip-preprocessed-apk-checks")
diff --git a/java/app_import_test.go b/java/app_import_test.go
index 496fc13..54a5e75 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -777,30 +777,79 @@
}
func TestAndroidAppImport_Preprocessed(t *testing.T) {
- ctx, _ := testJava(t, `
- android_app_import {
- name: "foo",
- apk: "prebuilts/apk/app.apk",
- presigned: true,
- preprocessed: true,
- }
- `)
+ for _, dontUncompressPrivAppDexs := range []bool{false, true} {
+ name := fmt.Sprintf("dontUncompressPrivAppDexs:%t", dontUncompressPrivAppDexs)
+ t.Run(name, func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.UncompressPrivAppDex = proptools.BoolPtr(!dontUncompressPrivAppDexs)
+ }),
+ ).RunTestWithBp(t, `
+ android_app_import {
+ name: "foo",
+ apk: "prebuilts/apk/app.apk",
+ presigned: true,
+ preprocessed: true,
+ }
- apkName := "foo.apk"
- variant := ctx.ModuleForTests("foo", "android_common")
- outputBuildParams := variant.Output(apkName).BuildParams
- if outputBuildParams.Rule.String() != android.Cp.String() {
- t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String())
- }
+ android_app_import {
+ name: "bar",
+ apk: "prebuilts/apk/app.apk",
+ presigned: true,
+ privileged: true,
+ preprocessed: true,
+ }
+ `)
- // Make sure compression and aligning were validated.
- if outputBuildParams.Validation == nil {
- t.Errorf("Expected validation rule, but was not found")
- }
+ // non-privileged app
+ apkName := "foo.apk"
+ variant := result.ModuleForTests("foo", "android_common")
+ outputBuildParams := variant.Output(apkName).BuildParams
+ if outputBuildParams.Rule.String() != android.Cp.String() {
+ t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String())
+ }
- validationBuildParams := variant.Output("validated-prebuilt/check.stamp").BuildParams
- if validationBuildParams.Rule.String() != checkPresignedApkRule.String() {
- t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String())
+ // Make sure compression and aligning were validated.
+ if outputBuildParams.Validation == nil {
+ t.Errorf("Expected validation rule, but was not found")
+ }
+
+ validationBuildParams := variant.Output("validated-prebuilt/check.stamp").BuildParams
+ if validationBuildParams.Rule.String() != checkPresignedApkRule.String() {
+ t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String())
+ }
+
+ expectedScriptArgs := "--preprocessed"
+ actualScriptArgs := validationBuildParams.Args["extraArgs"]
+ android.AssertStringEquals(t, "check script extraArgs", expectedScriptArgs, actualScriptArgs)
+
+ // privileged app
+ apkName = "bar.apk"
+ variant = result.ModuleForTests("bar", "android_common")
+ outputBuildParams = variant.Output(apkName).BuildParams
+ if outputBuildParams.Rule.String() != android.Cp.String() {
+ t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String())
+ }
+
+ // Make sure compression and aligning were validated.
+ if outputBuildParams.Validation == nil {
+ t.Errorf("Expected validation rule, but was not found")
+ }
+
+ validationBuildParams = variant.Output("validated-prebuilt/check.stamp").BuildParams
+ if validationBuildParams.Rule.String() != checkPresignedApkRule.String() {
+ t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String())
+ }
+
+ expectedScriptArgs = "--privileged"
+ if !dontUncompressPrivAppDexs {
+ expectedScriptArgs += " --uncompress-priv-app-dex"
+ }
+ expectedScriptArgs += " --preprocessed"
+ actualScriptArgs = validationBuildParams.Args["extraArgs"]
+ android.AssertStringEquals(t, "check script extraArgs", expectedScriptArgs, actualScriptArgs)
+ })
}
}
diff --git a/java/config/config.go b/java/config/config.go
index 2bb50f6..66e857c 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -47,6 +47,7 @@
"services",
"android.car",
"android.car7",
+ "android.car.builtin",
"conscrypt",
"core-icu4j",
"core-oj",
diff --git a/java/droidstubs.go b/java/droidstubs.go
index a8e0a22..d622903 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -197,6 +197,10 @@
// a list of aconfig_declarations module names that the stubs generated in this module
// depend on.
Aconfig_declarations []string
+
+ // List of hard coded filegroups containing Metalava config files that are passed to every
+ // Metalava invocation that this module performs. See addMetalavaConfigFilesToCmd.
+ ConfigFiles []string `android:"path" blueprint:"mutated"`
}
// Used by xsd_config
@@ -259,6 +263,7 @@
module.AddProperties(&module.properties,
&module.Javadoc.properties)
+ module.properties.ConfigFiles = getMetalavaConfigFilegroupReference()
module.initModuleAndImport(module)
InitDroiddocModule(module, android.HostAndDeviceSupported)
@@ -279,6 +284,7 @@
module.AddProperties(&module.properties,
&module.Javadoc.properties)
+ module.properties.ConfigFiles = getMetalavaConfigFilegroupReference()
InitDroiddocModule(module, android.HostSupported)
return module
}
@@ -694,7 +700,7 @@
}
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs android.Paths,
- srcJarList android.Path, homeDir android.WritablePath, params stubsCommandConfigParams) *android.RuleBuilderCommand {
+ srcJarList android.Path, homeDir android.WritablePath, params stubsCommandConfigParams, configFiles android.Paths) *android.RuleBuilderCommand {
rule.Command().Text("rm -rf").Flag(homeDir.String())
rule.Command().Text("mkdir -p").Flag(homeDir.String())
@@ -738,9 +744,26 @@
cmd.Flag(config.MetalavaFlags)
+ addMetalavaConfigFilesToCmd(cmd, configFiles)
+
return cmd
}
+// MetalavaConfigFilegroup is the name of the filegroup in build/soong/java/metalava that lists
+// the configuration files to pass to Metalava.
+const MetalavaConfigFilegroup = "metalava-config-files"
+
+// Get a reference to the MetalavaConfigFilegroup suitable for use in a property.
+func getMetalavaConfigFilegroupReference() []string {
+ return []string{":" + MetalavaConfigFilegroup}
+}
+
+// addMetalavaConfigFilesToCmd adds --config-file options to use the config files list in the
+// MetalavaConfigFilegroup filegroup.
+func addMetalavaConfigFilesToCmd(cmd *android.RuleBuilderCommand, configFiles android.Paths) {
+ cmd.FlagForEachInput("--config-file ", configFiles)
+}
+
// Pass flagged apis related flags to metalava. When aconfig_declarations property is not
// defined for a module, simply revert all flagged apis annotations. If aconfig_declarations
// property is defined, apply transformations and only revert the flagged apis that are not
@@ -812,7 +835,10 @@
srcJarList := zipSyncCmd(ctx, rule, params.srcJarDir, d.Javadoc.srcJars)
homeDir := android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "home")
- cmd := metalavaCmd(ctx, rule, d.Javadoc.srcFiles, srcJarList, homeDir, params.stubConfig)
+
+ configFiles := android.PathsForModuleSrc(ctx, d.properties.ConfigFiles)
+
+ cmd := metalavaCmd(ctx, rule, d.Javadoc.srcFiles, srcJarList, homeDir, params.stubConfig, configFiles)
cmd.Implicits(d.Javadoc.implicits)
d.stubsFlags(ctx, cmd, params.stubsDir, params.stubConfig.stubsType, params.stubConfig.checkApi)
diff --git a/java/java.go b/java/java.go
index 3dae4e4..b320732 100644
--- a/java/java.go
+++ b/java/java.go
@@ -269,7 +269,7 @@
ImplementationAndResourcesJars android.Paths
// ImplementationJars is a list of jars that contain the implementations of classes in the
- //module.
+ // module.
ImplementationJars android.Paths
// ResourceJars is a list of jars that contain the resources included in the module.
@@ -2039,12 +2039,17 @@
// List of aconfig_declarations module names that the stubs generated in this module
// depend on.
Aconfig_declarations []string
+
+ // List of hard coded filegroups containing Metalava config files that are passed to every
+ // Metalava invocation that this module performs. See addMetalavaConfigFilesToCmd.
+ ConfigFiles []string `android:"path" blueprint:"mutated"`
}
func ApiLibraryFactory() android.Module {
module := &ApiLibrary{}
- android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
module.AddProperties(&module.properties)
+ module.properties.ConfigFiles = getMetalavaConfigFilegroupReference()
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
module.initModuleAndImport(module)
android.InitDefaultableModule(module)
return module
@@ -2060,7 +2065,7 @@
func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
srcs android.Paths, homeDir android.WritablePath,
- classpath android.Paths) *android.RuleBuilderCommand {
+ classpath android.Paths, configFiles android.Paths) *android.RuleBuilderCommand {
rule.Command().Text("rm -rf").Flag(homeDir.String())
rule.Command().Text("mkdir -p").Flag(homeDir.String())
@@ -2099,6 +2104,8 @@
FlagWithArg("--hide ", "InvalidNullabilityOverride").
FlagWithArg("--hide ", "ChangedDefault")
+ addMetalavaConfigFilesToCmd(cmd, configFiles)
+
if len(classpath) == 0 {
// The main purpose of the `--api-class-resolution api` option is to force metalava to ignore
// classes on the classpath when an API file contains missing classes. However, as this command
@@ -2310,7 +2317,9 @@
ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName())
}
- cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, systemModulesPaths)
+ configFiles := android.PathsForModuleSrc(ctx, al.properties.ConfigFiles)
+
+ cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, systemModulesPaths, configFiles)
al.stubsFlags(ctx, cmd, stubsDir)
diff --git a/java/metalava/Android.bp b/java/metalava/Android.bp
new file mode 100644
index 0000000..ccbd191
--- /dev/null
+++ b/java/metalava/Android.bp
@@ -0,0 +1,18 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+filegroup {
+ name: "metalava-config-files",
+ srcs: ["*-config.xml"],
+}
diff --git a/java/metalava/OWNERS b/java/metalava/OWNERS
new file mode 100644
index 0000000..e8c438e
--- /dev/null
+++ b/java/metalava/OWNERS
@@ -0,0 +1,3 @@
+# Bug component: 463936
+
+file:platform/tools/metalava:/OWNERS
diff --git a/java/metalava/main-config.xml b/java/metalava/main-config.xml
new file mode 100644
index 0000000..c61196f
--- /dev/null
+++ b/java/metalava/main-config.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<config xmlns="http://www.google.com/tools/metalava/config"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.google.com/tools/metalava/config ../../../../tools/metalava/metalava/src/main/resources/schemas/config.xsd"/>
diff --git a/java/metalava/source-model-selection-config.xml b/java/metalava/source-model-selection-config.xml
new file mode 100644
index 0000000..c61196f
--- /dev/null
+++ b/java/metalava/source-model-selection-config.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<config xmlns="http://www.google.com/tools/metalava/config"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.google.com/tools/metalava/config ../../../../tools/metalava/metalava/src/main/resources/schemas/config.xsd"/>
diff --git a/java/ravenwood.go b/java/ravenwood.go
index 908619d..84c285c 100644
--- a/java/ravenwood.go
+++ b/java/ravenwood.go
@@ -33,6 +33,8 @@
var ravenwoodLibContentTag = dependencyTag{name: "ravenwoodlibcontent"}
var ravenwoodUtilsTag = dependencyTag{name: "ravenwoodutils"}
var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"}
+var ravenwoodDataTag = dependencyTag{name: "ravenwooddata"}
+var ravenwoodTestResourceApkTag = dependencyTag{name: "ravenwoodtestresapk"}
const ravenwoodUtilsName = "ravenwood-utils"
const ravenwoodRuntimeName = "ravenwood-runtime"
@@ -53,6 +55,13 @@
type ravenwoodTestProperties struct {
Jni_libs []string
+
+ // Specify another android_app module here to copy it to the test directory, so that
+ // the ravenwood test can access it.
+ // TODO: For now, we simply refer to another android_app module and copy it to the
+ // test directory. Eventually, android_ravenwood_test should support all the resource
+ // related properties and build resources from the `res/` directory.
+ Resource_apk *string
}
type ravenwoodTest struct {
@@ -114,6 +123,11 @@
for _, lib := range r.ravenwoodTestProperties.Jni_libs {
ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib)
}
+
+ // Resources APK
+ if resourceApk := proptools.String(r.ravenwoodTestProperties.Resource_apk); resourceApk != "" {
+ ctx.AddVariationDependencies(nil, ravenwoodTestResourceApkTag, resourceApk)
+ }
}
func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -175,6 +189,14 @@
installDeps = append(installDeps, installJni)
}
+ resApkInstallPath := installPath.Join(ctx, "ravenwood-res-apks")
+ if resApk := ctx.GetDirectDepsWithTag(ravenwoodTestResourceApkTag); len(resApk) > 0 {
+ for _, installFile := range resApk[0].FilesToInstall() {
+ installResApk := ctx.InstallFile(resApkInstallPath, "ravenwood-res.apk", installFile)
+ installDeps = append(installDeps, installResApk)
+ }
+ }
+
// Install our JAR with all dependencies
ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...)
}
@@ -198,6 +220,9 @@
Libs []string
Jni_libs []string
+
+ // We use this to copy framework-res.apk to the ravenwood runtime directory.
+ Data []string
}
type ravenwoodLibgroup struct {
@@ -236,6 +261,9 @@
for _, lib := range r.ravenwoodLibgroupProperties.Jni_libs {
ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib)
}
+ for _, data := range r.ravenwoodLibgroupProperties.Data {
+ ctx.AddVariationDependencies(nil, ravenwoodDataTag, data)
+ }
}
func (r *ravenwoodLibgroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -266,6 +294,13 @@
ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path)
}
+ dataInstallPath := installPath.Join(ctx, "ravenwood-data")
+ for _, data := range r.ravenwoodLibgroupProperties.Data {
+ libModule := ctx.GetDirectDepWithTag(data, ravenwoodDataTag)
+ file := android.OutputFileForModule(ctx, libModule, "")
+ ctx.InstallFile(dataInstallPath, file.Base(), file)
+ }
+
// Normal build should perform install steps
ctx.Phony(r.BaseModuleName(), android.PathForPhony(ctx, r.BaseModuleName()+"-install"))
}
diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go
index 5961264..d26db93 100644
--- a/java/ravenwood_test.go
+++ b/java/ravenwood_test.go
@@ -57,6 +57,14 @@
name: "framework-rules.ravenwood",
srcs: ["Rules.java"],
}
+ android_app {
+ name: "app1",
+ sdk_version: "current",
+ }
+ android_app {
+ name: "app2",
+ sdk_version: "current",
+ }
android_ravenwood_libgroup {
name: "ravenwood-runtime",
libs: [
@@ -67,6 +75,9 @@
"ravenwood-runtime-jni1",
"ravenwood-runtime-jni2",
],
+ data: [
+ "app1",
+ ],
}
android_ravenwood_libgroup {
name: "ravenwood-utils",
@@ -102,6 +113,7 @@
runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni1.so")
runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/libred.so")
runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/ravenwood-data/app1.apk")
utils := ctx.ModuleForTests("ravenwood-utils", "android_common")
utils.Output(installPathPrefix + "/ravenwood-utils/framework-rules.ravenwood.jar")
}
@@ -143,6 +155,7 @@
"jni-lib2",
"ravenwood-runtime-jni2",
],
+ resource_apk: "app2",
sdk_version: "test_current",
}
`)
@@ -169,6 +182,7 @@
module.Output(installPathPrefix + "/ravenwood-test/lib64/jni-lib1.so")
module.Output(installPathPrefix + "/ravenwood-test/lib64/libblue.so")
module.Output(installPathPrefix + "/ravenwood-test/lib64/libpink.so")
+ module.Output(installPathPrefix + "/ravenwood-test/ravenwood-res-apks/ravenwood-res.apk")
// ravenwood-runtime*.so are included in the runtime, so it shouldn't be emitted.
for _, o := range module.AllOutputs() {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 1eb7ab8..3931456 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1516,6 +1516,13 @@
// Add other dependencies as normal.
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
+ // If the module does not create an implementation library or defaults to stubs,
+ // mark the top level sdk library as stubs module as the module will provide stubs via
+ // "magic" when listed as a dependency in the Android.bp files.
+ notCreateImplLib := proptools.Bool(module.sdkLibraryProperties.Api_only)
+ preferStubs := proptools.Bool(module.sdkLibraryProperties.Default_to_stubs)
+ module.properties.Is_stubs_module = proptools.BoolPtr(notCreateImplLib || preferStubs)
+
var missingApiModules []string
for _, apiScope := range module.getGeneratedApiScopes(ctx) {
if apiScope.unstable {
diff --git a/java/testing.go b/java/testing.go
index 5ae326d..7a42e4c 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -52,6 +52,8 @@
android.MockFS{
// Needed for linter used by java_library.
"build/soong/java/lint_defaults.txt": nil,
+ // Needed for java components that invoke Metalava.
+ "build/soong/java/metalava/Android.bp": []byte(`filegroup {name: "metalava-config-files"}`),
// Needed for apps that do not provide their own.
"build/make/target/product/security": nil,
// Required to generate Java used-by API coverage
diff --git a/rust/bindgen.go b/rust/bindgen.go
index dbc3697..f1579cc 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -29,7 +29,7 @@
defaultBindgenFlags = []string{""}
// bindgen should specify its own Clang revision so updating Clang isn't potentially blocked on bindgen failures.
- bindgenClangVersion = "clang-r522817"
+ bindgenClangVersion = "clang-r530567"
_ = pctx.VariableFunc("bindgenClangVersion", func(ctx android.PackageVarContext) string {
if override := ctx.Config().Getenv("LLVM_BINDGEN_PREBUILTS_VERSION"); override != "" {
diff --git a/scripts/check_prebuilt_presigned_apk.py b/scripts/check_prebuilt_presigned_apk.py
index abedfb7..abab2e1 100755
--- a/scripts/check_prebuilt_presigned_apk.py
+++ b/scripts/check_prebuilt_presigned_apk.py
@@ -37,7 +37,7 @@
sys.exit(args.apk + ': Contains compressed JNI libraries')
return True
# It's ok for non-privileged apps to have compressed dex files, see go/gms-uncompressed-jni-slides
- if args.privileged:
+ if args.privileged and args.uncompress_priv_app_dex:
if info.filename.endswith('.dex') and info.compress_type != zipfile.ZIP_STORED:
if fail:
sys.exit(args.apk + ': Contains compressed dex files and is privileged')
@@ -52,6 +52,7 @@
parser.add_argument('--skip-preprocessed-apk-checks', action = 'store_true', help = "the value of the soong property with the same name")
parser.add_argument('--preprocessed', action = 'store_true', help = "the value of the soong property with the same name")
parser.add_argument('--privileged', action = 'store_true', help = "the value of the soong property with the same name")
+ parser.add_argument('--uncompress-priv-app-dex', action = 'store_true', help = "the value of the product variable with the same name")
parser.add_argument('apk', help = "the apk to check")
parser.add_argument('stampfile', help = "a file to touch if successful")
args = parser.parse_args()
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 5d76930..25839b8 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -2205,6 +2205,7 @@
"3",
"current",
],
+ symbol_file: "stubslib.map.txt",
},
arch: {
arm64: {
@@ -2268,6 +2269,7 @@
"3",
"current",
],
+ symbol_file: "stubslib.map.txt",
},
target: {
host: {
diff --git a/snapshot/Android.bp b/snapshot/Android.bp
index 6cb318e..c384f8a 100644
--- a/snapshot/Android.bp
+++ b/snapshot/Android.bp
@@ -14,7 +14,6 @@
// Source file name convention is to include _snapshot as a
// file suffix for files that are generating snapshots.
srcs: [
- "host_fake_snapshot.go",
"host_snapshot.go",
"snapshot_base.go",
"util.go",
diff --git a/snapshot/host_fake_snapshot.go b/snapshot/host_fake_snapshot.go
deleted file mode 100644
index 278247e..0000000
--- a/snapshot/host_fake_snapshot.go
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2021 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package snapshot
-
-import (
- "encoding/json"
- "path/filepath"
-
- "android/soong/android"
-)
-
-// The host_snapshot module creates a snapshot of host tools to be used
-// in a minimal source tree. In order to create the host_snapshot the
-// user must explicitly list the modules to be included. The
-// host-fake-snapshot, defined in this file, is a utility to help determine
-// which host modules are being used in the minimal source tree.
-//
-// The host-fake-snapshot is designed to run in a full source tree and
-// will result in a snapshot that contains an empty file for each host
-// tool found in the tree. The fake snapshot is only used to determine
-// the host modules that the minimal source tree depends on, hence the
-// snapshot uses an empty file for each module and saves on having to
-// actually build any tool to generate the snapshot. The fake snapshot
-// is compatible with an actual host_snapshot and is installed into a
-// minimal source tree via the development/vendor_snapshot/update.py
-// script.
-//
-// After generating the fake snapshot and installing into the minimal
-// source tree, the dependent modules are determined via the
-// development/vendor_snapshot/update.py script (see script for more
-// information). These modules are then used to define the actual
-// host_snapshot to be used. This is a similar process to the other
-// snapshots (vendor, recovery,...)
-//
-// Example
-//
-// Full source tree:
-// 1/ Generate fake host snapshot
-//
-// Minimal source tree:
-// 2/ Install the fake host snapshot
-// 3/ List the host modules used from the snapshot
-// 4/ Remove fake host snapshot
-//
-// Full source tree:
-// 4/ Create host_snapshot with modules identified in step 3
-//
-// Minimal source tree:
-// 5/ Install host snapshot
-// 6/ Build
-//
-// The host-fake-snapshot is a singleton module, that will be built
-// if HOST_FAKE_SNAPSHOT_ENABLE=true.
-
-func init() {
- registerHostSnapshotComponents(android.InitRegistrationContext)
-}
-
-// Add prebuilt information to snapshot data
-type hostSnapshotFakeJsonFlags struct {
- SnapshotJsonFlags
- Prebuilt bool `json:",omitempty"`
-}
-
-func registerHostSnapshotComponents(ctx android.RegistrationContext) {
- ctx.RegisterParallelSingletonType("host-fake-snapshot", HostToolsFakeAndroidSingleton)
-}
-
-type hostFakeSingleton struct {
- snapshotDir string
- zipFile android.OptionalPath
-}
-
-func (c *hostFakeSingleton) init() {
- c.snapshotDir = "host-fake-snapshot"
-
-}
-func HostToolsFakeAndroidSingleton() android.Singleton {
- singleton := &hostFakeSingleton{}
- singleton.init()
- return singleton
-}
-
-func (c *hostFakeSingleton) GenerateBuildActions(ctx android.SingletonContext) {
- if !ctx.DeviceConfig().HostFakeSnapshotEnabled() {
- return
- }
- // Find all host binary modules add 'fake' versions to snapshot
- var outputs android.Paths
- seen := make(map[string]bool)
- var jsonData []hostSnapshotFakeJsonFlags
- prebuilts := make(map[string]bool)
-
- ctx.VisitAllModules(func(module android.Module) {
- if module.Target().Os != ctx.Config().BuildOSTarget.Os {
- return
- }
- if module.Target().Arch.ArchType != ctx.Config().BuildOSTarget.Arch.ArchType {
- return
- }
-
- if android.IsModulePrebuilt(module) {
- // Add non-prebuilt module name to map of prebuilts
- prebuilts[android.RemoveOptionalPrebuiltPrefix(module.Name())] = true
- return
- }
- if !module.Enabled(ctx) || module.IsHideFromMake() {
- return
- }
- apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
- if !apexInfo.IsForPlatform() {
- return
- }
- path := hostToolPath(module)
- if path.Valid() && path.String() != "" {
- outFile := filepath.Join(c.snapshotDir, path.String())
- if !seen[outFile] {
- seen[outFile] = true
- outputs = append(outputs, WriteStringToFileRule(ctx, "", outFile))
- jsonData = append(jsonData, hostSnapshotFakeJsonFlags{*hostJsonDesc(ctx, module), false})
- }
- }
- })
- // Update any module prebuilt information
- for idx := range jsonData {
- if _, ok := prebuilts[jsonData[idx].ModuleName]; ok {
- // Prebuilt exists for this module
- jsonData[idx].Prebuilt = true
- }
- }
- marsh, err := json.Marshal(jsonData)
- if err != nil {
- ctx.Errorf("host fake snapshot json marshal failure: %#v", err)
- return
- }
- outputs = append(outputs, WriteStringToFileRule(ctx, string(marsh), filepath.Join(c.snapshotDir, "host_snapshot.json")))
- c.zipFile = zipSnapshot(ctx, c.snapshotDir, c.snapshotDir, outputs)
-
-}
-func (c *hostFakeSingleton) MakeVars(ctx android.MakeVarsContext) {
- if !c.zipFile.Valid() {
- return
- }
- ctx.Phony(
- "host-fake-snapshot",
- c.zipFile.Path())
-
- ctx.DistForGoal(
- "host-fake-snapshot",
- c.zipFile.Path())
-
-}
diff --git a/snapshot/host_test.go b/snapshot/host_test.go
index ab9fedd..c68fdaf 100644
--- a/snapshot/host_test.go
+++ b/snapshot/host_test.go
@@ -107,17 +107,6 @@
var prepareForFakeHostTest = android.GroupFixturePreparers(
prepareForHostTest,
android.FixtureWithRootAndroidBp(hostTestBp),
- android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
- registerHostSnapshotComponents(ctx)
- }),
-)
-
-// Prepare for fake host snapshot test enabled
-var prepareForFakeHostTestEnabled = android.GroupFixturePreparers(
- prepareForFakeHostTest,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.HostFakeSnapshotEnabled = true
- }),
)
// Validate that a hostSnapshot object is created containing zip files and JSON file
@@ -140,31 +129,3 @@
}
}
-
-// Validate fake host snapshot contains binary modules as well as the JSON meta file
-func TestFakeHostSnapshotEnable(t *testing.T) {
- result := prepareForFakeHostTestEnabled.RunTest(t)
- t.Helper()
- bins := []string{"foo", "bar"}
- ctx := result.TestContext.SingletonForTests("host-fake-snapshot")
- if ctx.MaybeOutput(filepath.Join("host-fake-snapshot", "host_snapshot.json")).Rule == nil {
- t.Error("Manifest file not found")
- }
- for _, bin := range bins {
- if ctx.MaybeOutput(filepath.Join("host-fake-snapshot", hostTestBinOut(bin))).Rule == nil {
- t.Error("Binary file ", bin, "not found")
- }
-
- }
-}
-
-// Validate not fake host snapshot if HostFakeSnapshotEnabled has not been set to true
-func TestFakeHostSnapshotDisable(t *testing.T) {
- result := prepareForFakeHostTest.RunTest(t)
- t.Helper()
- ctx := result.TestContext.SingletonForTests("host-fake-snapshot")
- if len(ctx.AllOutputs()) != 0 {
- t.Error("Fake host snapshot not empty when disabled")
- }
-
-}
diff --git a/ui/build/build.go b/ui/build/build.go
index c7319ed..49ac791 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -211,9 +211,38 @@
}
}
+func abfsBuildStarted(ctx Context, config Config) {
+ abfsBox := config.PrebuiltBuildTool("abfsbox")
+ cmdArgs := []string{"build-started", "--"}
+ cmdArgs = append(cmdArgs, config.Arguments()...)
+ cmd := Command(ctx, config, "abfsbox", abfsBox, cmdArgs...)
+ cmd.Sandbox = noSandbox
+ cmd.RunAndPrintOrFatal()
+}
+
+func abfsBuildFinished(ctx Context, config Config, finished bool) {
+ var errMsg string
+ if !finished {
+ errMsg = "build was interrupted"
+ }
+ abfsBox := config.PrebuiltBuildTool("abfsbox")
+ cmdArgs := []string{"build-finished", "-e", errMsg, "--"}
+ cmdArgs = append(cmdArgs, config.Arguments()...)
+ cmd := Command(ctx, config, "abfsbox", abfsBox, cmdArgs...)
+ cmd.RunAndPrintOrFatal()
+}
+
// Build the tree. Various flags in `config` govern which components of
// the build to run.
func Build(ctx Context, config Config) {
+ done := false
+ if config.UseABFS() {
+ abfsBuildStarted(ctx, config)
+ defer func() {
+ abfsBuildFinished(ctx, config, done)
+ }()
+ }
+
ctx.Verboseln("Starting build with args:", config.Arguments())
ctx.Verboseln("Environment:", config.Environment().Environ())
@@ -351,6 +380,7 @@
if what&RunDistActions != 0 {
runDistActions(ctx, config)
}
+ done = true
}
func updateBuildIdDir(ctx Context, config Config) {
diff --git a/ui/build/config.go b/ui/build/config.go
index 2470f84..631b76f 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -1270,9 +1270,25 @@
if !c.StubbyExists() && strings.Contains(authType, "use_google_prod_creds") {
return false
}
+ if c.UseABFS() {
+ return false
+ }
return true
}
+func (c *configImpl) UseABFS() bool {
+ if v, ok := c.environ.Get("NO_ABFS"); ok {
+ v = strings.ToLower(strings.TrimSpace(v))
+ if v == "true" || v == "1" {
+ return false
+ }
+ }
+
+ abfsBox := c.PrebuiltBuildTool("abfsbox")
+ err := exec.Command(abfsBox, "hash", srcDirFileCheck).Run()
+ return err == nil
+}
+
func (c *configImpl) UseRBE() bool {
// These alternate modes of running Soong do not use RBE / reclient.
if c.Queryview() || c.JsonModuleGraph() {
@@ -1585,6 +1601,23 @@
}
}
+func (c *configImpl) KatiBin() string {
+ binName := "ckati"
+ if c.UseABFS() {
+ binName = "ckati-wrap"
+ }
+
+ return c.PrebuiltBuildTool(binName)
+}
+
+func (c *configImpl) NinjaBin() string {
+ binName := "ninja"
+ if c.UseABFS() {
+ binName = "ninjago"
+ }
+ return c.PrebuiltBuildTool(binName)
+}
+
func (c *configImpl) PrebuiltBuildTool(name string) string {
if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
if sanitize := strings.Fields(v); inList("address", sanitize) {
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index e77df44..5df3a95 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -93,7 +93,7 @@
defer tool.Finish()
cmd := Command(ctx, config, "dumpvars",
- config.PrebuiltBuildTool("ckati"),
+ config.KatiBin(),
"-f", "build/make/core/config.mk",
"--color_warnings",
"--kati_stats",
diff --git a/ui/build/kati.go b/ui/build/kati.go
index d599c99..a0efd2c 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -84,7 +84,7 @@
// arguments, and a custom function closure to mutate the environment Kati runs
// in.
func runKati(ctx Context, config Config, extraSuffix string, args []string, envFunc func(*Environment)) {
- executable := config.PrebuiltBuildTool("ckati")
+ executable := config.KatiBin()
// cKati arguments.
args = append([]string{
// Instead of executing commands directly, generate a Ninja file.
diff --git a/ui/build/ninja.go b/ui/build/ninja.go
index 1935e72..b5e74b4 100644
--- a/ui/build/ninja.go
+++ b/ui/build/ninja.go
@@ -49,7 +49,7 @@
nr := status.NewNinjaReader(ctx, ctx.Status.StartTool(), fifo)
defer nr.Close()
- executable := config.PrebuiltBuildTool("ninja")
+ executable := config.NinjaBin()
args := []string{
"-d", "keepdepfile",
"-d", "keeprsp",
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index edb3b66..5c3fec1 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -200,6 +200,9 @@
// Only log important warnings / errors
"-q",
}
+ if c.config.UseABFS() {
+ sandboxArgs = append(sandboxArgs, "-B", "{ABFS_DIR}")
+ }
// Mount srcDir RW allowlists as Read-Write
if len(c.config.sandboxConfig.SrcDirRWAllowlist()) > 0 && !c.config.sandboxConfig.SrcDirIsRO() {
diff --git a/ui/build/soong.go b/ui/build/soong.go
index e18cc25..2ccdfec 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -661,7 +661,7 @@
}
ninjaArgs = append(ninjaArgs, targets...)
- ninjaCmd := config.PrebuiltBuildTool("ninja")
+ ninjaCmd := config.NinjaBin()
if config.useN2 {
ninjaCmd = config.PrebuiltBuildTool("n2")
}