summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp3
-rw-r--r--android/Android.bp1
-rw-r--r--android/dirgroup.go63
-rw-r--r--android/neverallow.go18
-rw-r--r--android/paths.go52
-rw-r--r--android/prebuilt.go19
-rw-r--r--apex/apex_test.go39
-rw-r--r--apex/builder.go3
-rw-r--r--filesystem/filesystem.go17
-rw-r--r--fsgen/filesystem_creator.go32
-rw-r--r--genrule/genrule.go18
-rw-r--r--java/app_import.go42
-rw-r--r--java/builder.go2
-rw-r--r--java/java.go2
-rw-r--r--java/jdeps_test.go39
-rwxr-xr-xscripts/keep-flagged-apis.sh15
-rw-r--r--ui/build/androidmk_denylist.go28
-rw-r--r--ui/build/finder.go1
18 files changed, 354 insertions, 40 deletions
diff --git a/Android.bp b/Android.bp
index 34f9bf012..bd4b40fec 100644
--- a/Android.bp
+++ b/Android.bp
@@ -161,10 +161,11 @@ build_prop {
name: "system-build.prop",
stem: "build.prop",
product_config: ":product_config",
- // Currently, only microdroid and cf system image can refer to system-build.prop
+ // Currently, only microdroid, Ravenwood, and cf system image can refer to system-build.prop
visibility: [
"//build/make/target/product/generic",
"//packages/modules/Virtualization/build/microdroid",
+ "//frameworks/base/ravenwood",
],
}
diff --git a/android/Android.bp b/android/Android.bp
index 44cddcc10..3b5432687 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -52,6 +52,7 @@ bootstrap_go_package {
"defs.go",
"depset_generic.go",
"deptag.go",
+ "dirgroup.go",
"early_module_context.go",
"expand.go",
"filegroup.go",
diff --git a/android/dirgroup.go b/android/dirgroup.go
new file mode 100644
index 000000000..20c4d13a6
--- /dev/null
+++ b/android/dirgroup.go
@@ -0,0 +1,63 @@
+// Copyright 2024 Google Inc. All rights reserved.
+//
+// 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 android
+
+import (
+ "github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
+)
+
+func init() {
+ RegisterDirgroupBuildComponents(InitRegistrationContext)
+}
+
+func RegisterDirgroupBuildComponents(ctx RegistrationContext) {
+ ctx.RegisterModuleType("dirgroup", DirGroupFactory)
+}
+
+type dirGroupProperties struct {
+ // dirs lists directories that will be included in this dirgroup
+ Dirs proptools.Configurable[[]string] `android:"path"`
+}
+
+type dirGroup struct {
+ ModuleBase
+ DefaultableModuleBase
+ properties dirGroupProperties
+}
+
+type DirInfo struct {
+ // TODO(b/358302178): Use DirectoryPaths instead of Paths
+ Dirs Paths
+}
+
+var DirProvider = blueprint.NewProvider[DirInfo]()
+
+// dirgroup contains a list of dirs that are referenced by other modules
+// properties using the syntax ":<name>". dirgroup are also be used to export
+// dirs across package boundaries. Currently the only allowed usage is genrule's
+// dir_srcs property.
+func DirGroupFactory() Module {
+ module := &dirGroup{}
+ module.AddProperties(&module.properties)
+ InitAndroidModule(module)
+ InitDefaultableModule(module)
+ return module
+}
+
+func (fg *dirGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
+ dirs := DirectoryPathsForModuleSrc(ctx, fg.properties.Dirs.GetOrDefault(ctx, nil))
+ SetProvider(ctx, DirProvider, DirInfo{Dirs: dirs})
+}
diff --git a/android/neverallow.go b/android/neverallow.go
index e93763b7b..041c9a0f8 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -60,6 +60,7 @@ func init() {
AddNeverAllowRules(createCcStubsRule())
AddNeverAllowRules(createProhibitHeaderOnlyRule())
AddNeverAllowRules(createLimitNdkExportRule()...)
+ AddNeverAllowRules(createLimitDirgroupRule()...)
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -275,6 +276,23 @@ func createLimitNdkExportRule() []Rule {
}
}
+func createLimitDirgroupRule() []Rule {
+ reason := "dirgroup module and dir_srcs property of genrule is allowed only to Trusty build rule."
+ return []Rule{
+ NeverAllow().
+ ModuleType("dirgroup").
+ WithMatcher("visibility", NotInList([]string{"//trusty/vendor/google/aosp/scripts"})).Because(reason),
+ NeverAllow().
+ ModuleType("dirgroup").
+ Without("visibility", "//trusty/vendor/google/aosp/scripts").Because(reason),
+ NeverAllow().
+ ModuleType("genrule").
+ Without("name", "lk.elf.arm64").
+ Without("name", "lk.elf.x86_64").
+ WithMatcher("dir_srcs", isSetMatcherInstance).Because(reason),
+ }
+}
+
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {
diff --git a/android/paths.go b/android/paths.go
index ec05831ca..371aed86d 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -550,6 +550,58 @@ func PathsRelativeToModuleSourceDir(input SourceInput) Paths {
return ret
}
+// DirectoryPathsForModuleSrcExcludes returns a Paths{} containing the resolved references in
+// directory paths. Elements of paths are resolved as:
+// - filepath, relative to local module directory, resolves as a filepath relative to the local
+// source directory
+// - other modules using the ":name" syntax. These modules must implement DirProvider.
+//
+// TODO(b/358302178): Implement DirectoryPath and change the return type.
+func DirectoryPathsForModuleSrc(ctx ModuleMissingDepsPathContext, paths []string) Paths {
+ var ret Paths
+
+ for _, path := range paths {
+ if m, t := SrcIsModuleWithTag(path); m != "" {
+ module := GetModuleFromPathDep(ctx, m, t)
+ if module == nil {
+ ctx.ModuleErrorf(`missing dependency on %q, is the property annotated with android:"path"?`, m)
+ continue
+ }
+ if t != "" {
+ ctx.ModuleErrorf("DirProvider dependency %q does not support the tag %q", module, t)
+ continue
+ }
+ mctx, ok := ctx.(OtherModuleProviderContext)
+ if !ok {
+ panic(fmt.Errorf("%s is not an OtherModuleProviderContext", ctx))
+ }
+ if dirProvider, ok := OtherModuleProvider(mctx, module, DirProvider); ok {
+ ret = append(ret, dirProvider.Dirs...)
+ } else {
+ ReportPathErrorf(ctx, "module %q does not implement DirProvider", module)
+ }
+ } else {
+ p := pathForModuleSrc(ctx, path)
+ if isDir, err := ctx.Config().fs.IsDir(p.String()); err != nil {
+ ReportPathErrorf(ctx, "%s: %s", p, err.Error())
+ } else if !isDir {
+ ReportPathErrorf(ctx, "module directory path %q is not a directory", p)
+ } else {
+ ret = append(ret, p)
+ }
+ }
+ }
+
+ seen := make(map[Path]bool, len(ret))
+ for _, path := range ret {
+ if seen[path] {
+ ReportPathErrorf(ctx, "duplicated path %q", path)
+ }
+ seen[path] = true
+ }
+ return ret
+}
+
// OutputPaths is a slice of OutputPath objects, with helpers to operate on the collection.
type OutputPaths []OutputPath
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 19f12f035..5d75b62fe 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -272,6 +272,25 @@ func InitConfigurablePrebuiltModule(module PrebuiltInterface, srcs *proptools.Co
InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
}
+// InitConfigurablePrebuiltModuleString is the same as InitPrebuiltModule, but uses a
+// Configurable string property instead of a regular list of strings. It only produces a single
+// source file.
+func InitConfigurablePrebuiltModuleString(module PrebuiltInterface, srcs *proptools.Configurable[string], propertyName string) {
+ if srcs == nil {
+ panic(fmt.Errorf("%s must not be nil", propertyName))
+ }
+
+ srcsSupplier := func(ctx BaseModuleContext, _ Module) []string {
+ src := srcs.GetOrDefault(ctx, "")
+ if src == "" {
+ return nil
+ }
+ return []string{src}
+ }
+
+ InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, propertyName)
+}
+
func InitSingleSourcePrebuiltModule(module PrebuiltInterface, srcProps interface{}, srcField string) {
srcPropsValue := reflect.ValueOf(srcProps).Elem()
srcStructField, _ := srcPropsValue.Type().FieldByName(srcField)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 645778b10..68978b2e8 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11861,3 +11861,42 @@ func TestApexSSCPJarMustBeInSamePartitionAsApex(t *testing.T) {
dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
)
}
+
+// partitions should not package the artifacts that are included inside the apex.
+func TestFilesystemWithApexDeps(t *testing.T) {
+ t.Parallel()
+ result := testApex(t, `
+ android_filesystem {
+ name: "myfilesystem",
+ deps: ["myapex"],
+ }
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ binaries: ["binfoo"],
+ native_shared_libs: ["libfoo"],
+ apps: ["appfoo"],
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ }
+ cc_binary {
+ name: "binfoo",
+ apex_available: ["myapex"],
+ }
+ cc_library {
+ name: "libfoo",
+ apex_available: ["myapex"],
+ }
+ android_app {
+ name: "appfoo",
+ sdk_version: "current",
+ apex_available: ["myapex"],
+ }
+ `, filesystem.PrepareForTestWithFilesystemBuildComponents)
+
+ partition := result.ModuleForTests("myfilesystem", "android_common")
+ fileList := android.ContentFromFileRuleForTests(t, result, partition.Output("fileList"))
+ android.AssertDeepEquals(t, "filesystem with apex", "apex/myapex.apex\n", fileList)
+}
diff --git a/apex/builder.go b/apex/builder.go
index c244b2532..20b4dbeeb 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -621,7 +621,8 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
}
} else {
if installSymbolFiles {
- installedPath = ctx.InstallFile(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile)
+ // store installedPath. symlinks might be created if required.
+ installedPath = apexDir.Join(ctx, fi.installDir, fi.stem())
}
}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 1e816a752..8c59df371 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -198,6 +198,10 @@ const (
unknown
)
+func (fs fsType) IsUnknown() bool {
+ return fs == unknown
+}
+
type FilesystemInfo struct {
// A text file containing the list of paths installed on the partition.
FileListFile android.Path
@@ -205,8 +209,7 @@ type FilesystemInfo struct {
var FilesystemProvider = blueprint.NewProvider[FilesystemInfo]()
-func (f *filesystem) fsType(ctx android.ModuleContext) fsType {
- typeStr := proptools.StringDefault(f.properties.Type, "ext4")
+func GetFsTypeFromString(ctx android.EarlyModuleContext, typeStr string) fsType {
switch typeStr {
case "ext4":
return ext4Type
@@ -217,11 +220,19 @@ func (f *filesystem) fsType(ctx android.ModuleContext) fsType {
case "cpio":
return cpioType
default:
- ctx.PropertyErrorf("type", "%q not supported", typeStr)
return unknown
}
}
+func (f *filesystem) fsType(ctx android.ModuleContext) fsType {
+ typeStr := proptools.StringDefault(f.properties.Type, "ext4")
+ fsType := GetFsTypeFromString(ctx, typeStr)
+ if fsType == unknown {
+ ctx.PropertyErrorf("type", "%q not supported", typeStr)
+ }
+ return fsType
+}
+
func (f *filesystem) installFileName() string {
return f.BaseModuleName() + ".img"
}
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index ed0c390ba..d5e0c581a 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -114,7 +114,11 @@ func filesystemCreatorFactory() android.Module {
}
func (f *filesystemCreator) createInternalModules(ctx android.LoadHookContext) {
- for _, partitionType := range []string{"system"} {
+ partitionTypes := []string{"system"}
+ if ctx.DeviceConfig().SystemExtPath() == "system_ext" { // system_ext exists
+ partitionTypes = append(partitionTypes, "system_ext")
+ }
+ for _, partitionType := range partitionTypes {
if f.createPartition(ctx, partitionType) {
f.properties.Generated_partition_types = append(f.properties.Generated_partition_types, partitionType)
} else {
@@ -143,15 +147,23 @@ func (f *filesystemCreator) createDeviceModule(ctx android.LoadHookContext) {
Name: proptools.StringPtr(f.generatedModuleName(ctx.Config(), "device")),
}
- // Currently, only the system partition module is created.
+ // Currently, only the system and system_ext partition module is created.
partitionProps := &filesystem.PartitionNameProperties{}
if android.InList("system", f.properties.Generated_partition_types) {
partitionProps.System_partition_name = proptools.StringPtr(f.generatedModuleNameForPartition(ctx.Config(), "system"))
}
+ if android.InList("system_ext", f.properties.Generated_partition_types) {
+ partitionProps.System_ext_partition_name = proptools.StringPtr(f.generatedModuleNameForPartition(ctx.Config(), "system_ext"))
+ }
ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps)
}
+var (
+ // https://source.corp.google.com/h/googleplex-android/platform/build/+/639d79f5012a6542ab1f733b0697db45761ab0f3:core/packaging/flags.mk;l=21;drc=5ba8a8b77507f93aa48cc61c5ba3f31a4d0cbf37;bpv=1;bpt=0
+ partitionsWithAconfig = []string{"system", "product", "vendor"}
+)
+
// 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 {
@@ -183,17 +195,19 @@ func (f *filesystemCreator) createPartition(ctx android.LoadHookContext, partiti
fsProps.Partition_name = proptools.StringPtr(partitionType)
// BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE
- fsProps.Type = proptools.StringPtr(specificPartitionVars.BoardFileSystemType)
- if *fsProps.Type != "ext4" {
- // TODO(b/372522486): Support other FS types.
- // Currently the android_filesystem module type only supports ext4:
- // https://cs.android.com/android/platform/superproject/main/+/main:build/soong/filesystem/filesystem.go;l=416;drc=98047cfd07944b297a12d173453bc984806760d2
+ 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)
- fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
+ fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(android.InList(partitionType, partitionsWithAconfig))
// Identical to that of the generic_system_image
fsProps.Fsverity.Inputs = []string{
@@ -222,6 +236,8 @@ func (f *filesystemCreator) createPartition(ctx android.LoadHookContext, partiti
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()
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 349615f7e..f2a761cde 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -219,6 +219,7 @@ type generateTask struct {
// For nsjail tasks
useNsjail bool
+ dirSrcs android.Paths
}
func (g *Module) GeneratedSourceFiles() android.Paths {
@@ -579,10 +580,12 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
}
if task.useNsjail {
- for _, input := range task.in {
- // can fail if input is a file.
+ for _, input := range task.dirSrcs {
+ cmd.Implicit(input)
if paths, err := ctx.GlobWithDeps(filepath.Join(input.String(), "**/*"), nil); err == nil {
rule.NsjailImplicits(android.PathsForSource(ctx, paths))
+ } else {
+ ctx.PropertyErrorf("dir_srcs", "can't glob %q", input.String())
}
}
}
@@ -858,6 +861,12 @@ func NewGenRule() *Module {
taskGenerator := func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask {
useNsjail := Bool(properties.Use_nsjail)
+ dirSrcs := android.DirectoryPathsForModuleSrc(ctx, properties.Dir_srcs)
+ if len(dirSrcs) > 0 && !useNsjail {
+ ctx.PropertyErrorf("dir_srcs", "can't use dir_srcs if use_nsjail is false")
+ return nil
+ }
+
outs := make(android.WritablePaths, len(properties.Out))
for i, out := range properties.Out {
outs[i] = android.PathForModuleGen(ctx, out)
@@ -868,6 +877,7 @@ func NewGenRule() *Module {
genDir: android.PathForModuleGen(ctx),
cmd: rawCommand,
useNsjail: useNsjail,
+ dirSrcs: dirSrcs,
}}
}
@@ -884,6 +894,10 @@ func GenRuleFactory() android.Module {
type genRuleProperties struct {
Use_nsjail *bool
+ // List of input directories. Can be set only when use_nsjail is true. Currently, usage of
+ // dir_srcs is limited only to Trusty build.
+ Dir_srcs []string `android:"path"`
+
// names of the output files that will be generated
Out []string `android:"arch_variant"`
}
diff --git a/java/app_import.go b/java/app_import.go
index a54cf2fc3..f5d9f3e79 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -61,6 +61,9 @@ var (
func RegisterAppImportBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("android_app_import", AndroidAppImportFactory)
ctx.RegisterModuleType("android_test_import", AndroidTestImportFactory)
+ ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("disable_prebuilts_without_apk", disablePrebuiltsWithoutApkMutator)
+ })
}
type AndroidAppImport struct {
@@ -90,7 +93,7 @@ type AndroidAppImport struct {
type AndroidAppImportProperties struct {
// A prebuilt apk to import
- Apk *string `android:"path"`
+ Apk proptools.Configurable[string] `android:"path,replace_instead_of_append"`
// The name of a certificate in the default certificate directory or an android_app_certificate
// module name in the form ":module". Should be empty if presigned or default_dev_cert is set.
@@ -193,13 +196,6 @@ func (a *AndroidAppImport) processVariants(ctx android.DefaultableHookContext) {
}
}
}
-
- if String(a.properties.Apk) == "" {
- // Disable this module since the apk property is still empty after processing all matching
- // variants. This likely means there is no matching variant, and the default variant doesn't
- // have an apk property value either.
- a.Disable()
- }
}
func MergePropertiesFromVariant(ctx android.EarlyModuleContext,
@@ -219,6 +215,30 @@ func MergePropertiesFromVariant(ctx android.EarlyModuleContext,
}
}
+// disablePrebuiltsWithoutApkMutator is a pre-arch mutator that disables AndroidAppImport or
+// AndroidTestImport modules that don't have an apk set. We need this separate mutator instead
+// of doing it in processVariants because processVariants is a defaultable hook, and configurable
+// properties can only be evaluated after the defaults (and eventually, base configurabtion)
+// mutators.
+func disablePrebuiltsWithoutApkMutator(ctx android.BottomUpMutatorContext) {
+ switch a := ctx.Module().(type) {
+ case *AndroidAppImport:
+ if a.properties.Apk.GetOrDefault(ctx, "") == "" {
+ // Disable this module since the apk property is still empty after processing all
+ // matching variants. This likely means there is no matching variant, and the default
+ // variant doesn't have an apk property value either.
+ a.Disable()
+ }
+ case *AndroidTestImport:
+ if a.properties.Apk.GetOrDefault(ctx, "") == "" {
+ // Disable this module since the apk property is still empty after processing all
+ // matching variants. This likely means there is no matching variant, and the default
+ // variant doesn't have an apk property value either.
+ a.Disable()
+ }
+ }
+}
+
func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) {
cert := android.SrcIsModule(String(a.properties.Certificate))
if cert != "" {
@@ -409,7 +429,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
if apexInfo.IsForPlatform() {
a.installPath = ctx.InstallFile(installDir, apkFilename, a.outputFile)
- artifactPath := android.PathForModuleSrc(ctx, *a.properties.Apk)
+ artifactPath := android.PathForModuleSrc(ctx, a.properties.Apk.GetOrDefault(ctx, ""))
a.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, artifactPath, a.installPath)
}
@@ -633,7 +653,7 @@ func AndroidAppImportFactory() android.Module {
android.InitApexModule(module)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
- android.InitSingleSourcePrebuiltModule(module, &module.properties, "Apk")
+ android.InitConfigurablePrebuiltModuleString(module, &module.properties.Apk, "Apk")
module.usesLibrary.enforce = true
@@ -686,7 +706,7 @@ func AndroidTestImportFactory() android.Module {
android.InitApexModule(module)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
- android.InitSingleSourcePrebuiltModule(module, &module.properties, "Apk")
+ android.InitConfigurablePrebuiltModuleString(module, &module.properties.Apk, "Apk")
return module
}
diff --git a/java/builder.go b/java/builder.go
index e5d510923..895ddb6f9 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -301,7 +301,7 @@ var (
gatherReleasedFlaggedApisRule = pctx.AndroidStaticRule("gatherReleasedFlaggedApisRule",
blueprint.RuleParams{
- Command: `${aconfig} dump-cache --dedup --format='{fully_qualified_name}={state:bool}' ` +
+ Command: `${aconfig} dump-cache --dedup --format='{fully_qualified_name}' ` +
`--out ${out} ` +
`${flags_path} ` +
`${filter_args} `,
diff --git a/java/java.go b/java/java.go
index 0b48873f6..288042b42 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2454,7 +2454,7 @@ func (al *ApiLibrary) ideDeps(ctx android.BaseModuleContext) []string {
ret := []string{}
ret = append(ret, al.properties.Libs.GetOrDefault(ctx, nil)...)
ret = append(ret, al.properties.Static_libs.GetOrDefault(ctx, nil)...)
- if al.properties.System_modules != nil {
+ if proptools.StringDefault(al.properties.System_modules, "none") != "none" {
ret = append(ret, proptools.String(al.properties.System_modules))
}
// Other non java_library dependencies like java_api_contribution are ignored for now.
diff --git a/java/jdeps_test.go b/java/jdeps_test.go
index 7a0fb10cb..143500004 100644
--- a/java/jdeps_test.go
+++ b/java/jdeps_test.go
@@ -134,3 +134,42 @@ func TestCollectJavaLibraryLinkingAgainstVersionedSdk(t *testing.T) {
android.AssertStringListContains(t, "IdeInfo.Deps should contain versioned sdk module", dpInfo.Deps, "sdk_public_29_android")
}
+
+func TestDoNotAddNoneSystemModulesToDeps(t *testing.T) {
+ ctx := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureMergeEnv(
+ map[string]string{
+ "DISABLE_STUB_VALIDATION": "true",
+ },
+ ),
+ ).RunTestWithBp(t,
+ `
+ java_library {
+ name: "javalib",
+ srcs: ["foo.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+
+ java_api_library {
+ name: "javalib.stubs",
+ stubs_type: "everything",
+ api_contributions: ["javalib-current.txt"],
+ api_surface: "public",
+ system_modules: "none",
+ }
+ java_api_contribution {
+ name: "javalib-current.txt",
+ api_file: "javalib-current.txt",
+ api_surface: "public",
+ }
+ `)
+ javalib := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
+ dpInfo, _ := android.OtherModuleProvider(ctx, javalib, android.IdeInfoProviderKey)
+ android.AssertStringListDoesNotContain(t, "IdeInfo.Deps should contain not contain `none`", dpInfo.Deps, "none")
+
+ javalib_stubs := ctx.ModuleForTests("javalib.stubs", "android_common").Module().(*ApiLibrary)
+ dpInfo, _ = android.OtherModuleProvider(ctx, javalib_stubs, android.IdeInfoProviderKey)
+ android.AssertStringListDoesNotContain(t, "IdeInfo.Deps should contain not contain `none`", dpInfo.Deps, "none")
+}
diff --git a/scripts/keep-flagged-apis.sh b/scripts/keep-flagged-apis.sh
index 9c48fdbad..48efb7a29 100755
--- a/scripts/keep-flagged-apis.sh
+++ b/scripts/keep-flagged-apis.sh
@@ -25,21 +25,12 @@ FLAGGED="android.annotation.FlaggedApi"
# Convert the list of feature flags in the input file to Metalava options
# of the form `--revert-annotation !android.annotation.FlaggedApi("<flag>")`
# to prevent the annotated APIs from being hidden, i.e. include the annotated
-# APIs in the SDK snapshots. This also preserves the line comments, they will
-# be ignored by Metalava but might be useful when debugging.
+# APIs in the SDK snapshots.
while read -r line; do
- key=$(echo "$line" | cut -d= -f1)
- value=$(echo "$line" | cut -d= -f2)
-
- # Skip if value is not true and line does not start with '#'
- if [[ ( $value != "true" ) && ( $line =~ ^[^#] )]]; then
- continue
- fi
-
# Escape and quote the key for sed
- escaped_key=$(echo "$key" | sed "s/'/\\\'/g; s/ /\\ /g")
+ escaped_line=$(echo "$line" | sed "s/'/\\\'/g; s/ /\\ /g")
- echo $line | sed "s|^[^#].*$|--revert-annotation '!$FLAGGED(\"$escaped_key\")'|"
+ echo "--revert-annotation '!$FLAGGED(\"$escaped_line\")'"
done < "$FLAGS"
# Revert all flagged APIs, unless listed above.
diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go
index 2ec897273..a8044dfbf 100644
--- a/ui/build/androidmk_denylist.go
+++ b/ui/build/androidmk_denylist.go
@@ -16,6 +16,8 @@ package build
import (
"strings"
+
+ "android/soong/android"
)
var androidmk_denylist []string = []string{
@@ -64,3 +66,29 @@ func blockAndroidMks(ctx Context, androidMks []string) {
}
}
}
+
+// The Android.mk files in these directories are for NDK build system.
+var external_ndk_androidmks []string = []string{
+ "external/fmtlib/",
+ "external/google-breakpad/",
+ "external/googletest/",
+ "external/libaom/",
+ "external/libusb/",
+ "external/libvpx/",
+ "external/libwebm/",
+ "external/libwebsockets/",
+ "external/vulkan-validation-layers/",
+ "external/walt/",
+ "external/webp/",
+}
+
+func ignoreNdkAndroidMks(androidMks []string) []string {
+ return android.FilterListPred(androidMks, func(s string) bool {
+ for _, d := range external_ndk_androidmks {
+ if strings.HasPrefix(s, d) {
+ return false
+ }
+ }
+ return true
+ })
+}
diff --git a/ui/build/finder.go b/ui/build/finder.go
index 573df21d9..a89982274 100644
--- a/ui/build/finder.go
+++ b/ui/build/finder.go
@@ -128,6 +128,7 @@ func FindSources(ctx Context, config Config, f *finder.Finder) {
// Stop searching a subdirectory recursively after finding an Android.mk.
androidMks := f.FindFirstNamedAt(".", "Android.mk")
+ androidMks = ignoreNdkAndroidMks(androidMks)
blockAndroidMks(ctx, androidMks)
err := dumpListToFile(ctx, config, androidMks, filepath.Join(dumpDir, "Android.mk.list"))
if err != nil {