Loading apex/apex.go +4 −32 Original line number Diff line number Diff line Loading @@ -1937,8 +1937,6 @@ type visitorContext struct { // visitor skips these from this list of module names unwantedTransitiveDeps []string aconfigFiles []android.Path } func (vctx *visitorContext) normalizeFileInfo(mctx android.ModuleContext) { Loading Loading @@ -2005,7 +2003,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, fi := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs) fi.isJniLib = isJniLib vctx.filesInfo = append(vctx.filesInfo, fi) addAconfigFiles(vctx, ctx, child) // Collect the list of stub-providing libs except: // - VNDK libs are only for vendors // - bootstrap bionic libs are treated as provided by system Loading @@ -2017,7 +2014,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, fi := apexFileForRustLibrary(ctx, ch) fi.isJniLib = isJniLib vctx.filesInfo = append(vctx.filesInfo, fi) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName) Loading @@ -2026,11 +2022,9 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, switch ch := child.(type) { case *cc.Module: vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, ch)) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies case *rust.Module: vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, ch)) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("binaries", Loading Loading @@ -2070,7 +2064,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, return false } vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child)) Loading @@ -2079,14 +2072,11 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, switch ap := child.(type) { case *java.AndroidApp: vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies case *java.AndroidAppImport: vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) addAconfigFiles(vctx, ctx, child) case *java.AndroidTestHelperApp: vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) addAconfigFiles(vctx, ctx, child) case *java.AndroidAppSet: appDir := "app" if ap.Privileged() { Loading @@ -2100,7 +2090,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap) af.certificate = java.PresignedCertificate vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) default: ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) } Loading Loading @@ -2132,7 +2121,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, for _, etcFile := range filesToCopy { vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile)) } addAconfigFiles(vctx, ctx, child) } else { ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName) } Loading @@ -2147,7 +2135,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := apexFileForExecutable(ctx, ccTest) af.class = nativeTest vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } else { ctx.PropertyErrorf("tests", "%q is not a cc module", depName) Loading Loading @@ -2227,7 +2214,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, } vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } else if rm, ok := child.(*rust.Module); ok { if !android.IsDepInSameApex(ctx, am, am) { Loading @@ -2237,7 +2223,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := apexFileForRustLibrary(ctx, rm) af.transitiveDep = true vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } } else if cc.IsHeaderDepTag(depTag) { Loading @@ -2260,7 +2245,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := apexFileForRustLibrary(ctx, rustm) af.transitiveDep = true vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } } else if rust.IsRlibDepTag(depTag) { Loading @@ -2279,7 +2263,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, return false } vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("bootclasspath_fragments", Loading @@ -2294,7 +2277,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, if profileAf := apexFileForJavaModuleProfile(ctx, child.(javaModule)); profileAf != nil { vctx.filesInfo = append(vctx.filesInfo, *profileAf) } addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("systemserverclasspath_fragments", Loading @@ -2312,19 +2294,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, return false } func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) { if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigPropagatingProviderKey); ok { if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil { vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...) } } validationFlag := ctx.DeviceConfig().AconfigContainerValidation() if validationFlag == "error" || validationFlag == "warning" { android.VerifyAconfigBuildMode(ctx, ctx.ModuleName(), module, validationFlag == "error") } } func (a *apexBundle) shouldCheckDuplicate(ctx android.ModuleContext) bool { // TODO(b/263308293) remove this if a.properties.IsCoverageVariant { Loading Loading @@ -2406,12 +2375,15 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // 3) some fields in apexBundle struct are configured a.installDir = android.PathForModuleInstall(ctx, "apex") a.filesInfo = vctx.filesInfo a.aconfigFiles = android.FirstUniquePaths(vctx.aconfigFiles) a.setPayloadFsType(ctx) a.setSystemLibLink(ctx) a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx) //////////////////////////////////////////////////////////////////////////////////////////// // 3.a) some artifacts are generated from the collected files a.filesInfo = append(a.filesInfo, a.buildAconfigFiles(ctx)...) //////////////////////////////////////////////////////////////////////////////////////////// // 4) generate the build rules to create the APEX. This is done in builder.go. a.buildManifest(ctx, vctx.provideNativeLibs, vctx.requireNativeLibs) Loading apex/apex_test.go +27 −18 Original line number Diff line number Diff line Loading @@ -267,6 +267,7 @@ func ensureNotContains(t *testing.T, result string, notExpected string) { } func ensureMatches(t *testing.T, result string, expectedRex string) { t.Helper() ok, err := regexp.MatchString(expectedRex, result) if err != nil { t.Fatalf("regexp failure trying to match %s against `%s` expression: %s", result, expectedRex, err) Loading @@ -277,6 +278,14 @@ func ensureMatches(t *testing.T, result string, expectedRex string) { } } func ensureListContainsMatch(t *testing.T, result []string, expectedRex string) { t.Helper() p := regexp.MustCompile(expectedRex) if android.IndexListPred(func(s string) bool { return p.MatchString(s) }, result) == -1 { t.Errorf("%q is not found in %v", expectedRex, result) } } func ensureListContains(t *testing.T, result []string, expected string) { t.Helper() if !android.InList(expected, result) { Loading Loading @@ -10791,14 +10800,14 @@ func TestAconfigFilesJavaDeps(t *testing.T) { mod := ctx.ModuleForTests("myapex", "android_common_myapex") s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) if len(copyCmds) != 8 { t.Fatalf("Expected 5 commands, got %d in:\n%s", len(copyCmds), s) if len(copyCmds) != 12 { t.Fatalf("Expected 12 commands, got %d in:\n%s", len(copyCmds), s) } ensureMatches(t, copyCmds[4], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$") ensureMatches(t, copyCmds[5], "^cp -f .*/package.map .*/image.apex/etc$") ensureMatches(t, copyCmds[6], "^cp -f .*/flag.map .*/image.apex/etc$") ensureMatches(t, copyCmds[7], "^cp -f .*/flag.val .*/image.apex/etc$") ensureListContainsMatch(t, copyCmds, "^cp -f .*/aconfig_flags.pb .*/image.apex/etc/aconfig_flags.pb") ensureListContainsMatch(t, copyCmds, "^cp -f .*/package.map .*/image.apex/etc/package.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.map .*/image.apex/etc/flag.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.val .*/image.apex/etc/flag.val") inputs := []string{ "my_aconfig_declarations_foo/intermediate.pb", Loading Loading @@ -10926,14 +10935,14 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) { mod := ctx.ModuleForTests("myapex", "android_common_myapex") s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) if len(copyCmds) != 12 { t.Fatalf("Expected 12 commands, got %d in:\n%s", len(copyCmds), s) if len(copyCmds) != 16 { t.Fatalf("Expected 16 commands, got %d in:\n%s", len(copyCmds), s) } ensureMatches(t, copyCmds[8], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$") ensureMatches(t, copyCmds[9], "^cp -f .*/package.map .*/image.apex/etc$") ensureMatches(t, copyCmds[10], "^cp -f .*/flag.map .*/image.apex/etc$") ensureMatches(t, copyCmds[11], "^cp -f .*/flag.val .*/image.apex/etc$") ensureListContainsMatch(t, copyCmds, "^cp -f .*/aconfig_flags.pb .*/image.apex/etc/aconfig_flags.pb") ensureListContainsMatch(t, copyCmds, "^cp -f .*/package.map .*/image.apex/etc/package.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.map .*/image.apex/etc/flag.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.val .*/image.apex/etc/flag.val") inputs := []string{ "my_aconfig_declarations_foo/intermediate.pb", Loading Loading @@ -11094,14 +11103,14 @@ func TestAconfigFilesRustDeps(t *testing.T) { mod := ctx.ModuleForTests("myapex", "android_common_myapex") s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) if len(copyCmds) != 32 { t.Fatalf("Expected 28 commands, got %d in:\n%s", len(copyCmds), s) if len(copyCmds) != 36 { t.Fatalf("Expected 36 commands, got %d in:\n%s", len(copyCmds), s) } ensureMatches(t, copyCmds[28], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$") ensureMatches(t, copyCmds[29], "^cp -f .*/package.map .*/image.apex/etc$") ensureMatches(t, copyCmds[30], "^cp -f .*/flag.map .*/image.apex/etc$") ensureMatches(t, copyCmds[31], "^cp -f .*/flag.val .*/image.apex/etc$") ensureListContainsMatch(t, copyCmds, "^cp -f .*/aconfig_flags.pb .*/image.apex/etc/aconfig_flags.pb") ensureListContainsMatch(t, copyCmds, "^cp -f .*/package.map .*/image.apex/etc/package.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.map .*/image.apex/etc/flag.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.val .*/image.apex/etc/flag.val") inputs := []string{ "my_aconfig_declarations_foo/intermediate.pb", Loading apex/builder.go +55 −41 Original line number Diff line number Diff line Loading @@ -262,6 +262,58 @@ var ( }, "tool_path", "unwanted") ) func (a *apexBundle) buildAconfigFiles(ctx android.ModuleContext) []apexFile { var aconfigFiles android.Paths for _, file := range a.filesInfo { if file.module == nil { continue } if dep, ok := android.OtherModuleProvider(ctx, file.module, android.AconfigPropagatingProviderKey); ok { if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil { aconfigFiles = append(aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...) } } validationFlag := ctx.DeviceConfig().AconfigContainerValidation() if validationFlag == "error" || validationFlag == "warning" { android.VerifyAconfigBuildMode(ctx, ctx.ModuleName(), file.module, validationFlag == "error") } } aconfigFiles = android.FirstUniquePaths(aconfigFiles) var files []apexFile if len(aconfigFiles) > 0 { apexAconfigFile := android.PathForModuleOut(ctx, "aconfig_flags.pb") ctx.Build(pctx, android.BuildParams{ Rule: aconfig.AllDeclarationsRule, Inputs: aconfigFiles, Output: apexAconfigFile, Description: "combine_aconfig_declarations", Args: map[string]string{ "cache_files": android.JoinPathsWithPrefix(aconfigFiles, "--cache "), }, }) files = append(files, newApexFile(ctx, apexAconfigFile, "aconfig_flags", "etc", etc, nil)) for _, info := range createStorageInfo { outputFile := android.PathForModuleOut(ctx, info.Output_file) ctx.Build(pctx, android.BuildParams{ Rule: aconfig.CreateStorageRule, Inputs: aconfigFiles, Output: outputFile, Description: info.Desc, Args: map[string]string{ "container": ctx.ModuleName(), "file_type": info.File_type, "cache_files": android.JoinPathsWithPrefix(aconfigFiles, "--cache "), }, }) files = append(files, newApexFile(ctx, outputFile, info.File_type, "etc", etc, nil)) } } return files } // buildManifest creates buile rules to modify the input apex_manifest.json to add information // gathered by the build system such as provided/required native libraries. Two output files having // different formats are generated. a.manifestJsonOut is JSON format for Q devices, and Loading Loading @@ -644,48 +696,10 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) { outHostBinDir := ctx.Config().HostToolPath(ctx, "").String() prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin") defaultReadOnlyFiles := []string{"apex_manifest.json", "apex_manifest.pb"} aconfigDest := imageDir.Join(ctx, "etc").String() if len(a.aconfigFiles) > 0 { apexAconfigFile := android.PathForModuleOut(ctx, "aconfig_flags.pb") ctx.Build(pctx, android.BuildParams{ Rule: aconfig.AllDeclarationsRule, Inputs: a.aconfigFiles, Output: apexAconfigFile, Description: "combine_aconfig_declarations", Args: map[string]string{ "cache_files": android.JoinPathsWithPrefix(a.aconfigFiles, "--cache "), }, }) copyCommands = append(copyCommands, "cp -f "+apexAconfigFile.String()+" "+aconfigDest) implicitInputs = append(implicitInputs, apexAconfigFile) defaultReadOnlyFiles = append(defaultReadOnlyFiles, "etc/"+apexAconfigFile.Base()) for _, info := range createStorageInfo { outputFile := android.PathForModuleOut(ctx, info.Output_file) ctx.Build(pctx, android.BuildParams{ Rule: aconfig.CreateStorageRule, Inputs: a.aconfigFiles, Output: outputFile, Description: info.Desc, Args: map[string]string{ "container": ctx.ModuleName(), "file_type": info.File_type, "cache_files": android.JoinPathsWithPrefix(a.aconfigFiles, "--cache "), }, }) copyCommands = append(copyCommands, "cp -f "+outputFile.String()+" "+aconfigDest) implicitInputs = append(implicitInputs, outputFile) defaultReadOnlyFiles = append(defaultReadOnlyFiles, "etc/"+outputFile.Base()) } } //////////////////////////////////////////////////////////////////////////////////// // Step 2: create canned_fs_config which encodes filemode,uid,gid of each files // in this APEX. The file will be used by apexer in later steps. cannedFsConfig := a.buildCannedFsConfig(ctx, defaultReadOnlyFiles) cannedFsConfig := a.buildCannedFsConfig(ctx) implicitInputs = append(implicitInputs, cannedFsConfig) //////////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -1139,8 +1153,8 @@ func (a *apexBundle) buildLintReports(ctx android.ModuleContext) { a.lintReports = java.BuildModuleLintReportZips(ctx, depSetsBuilder.Build()) } func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext, defaultReadOnlyFiles []string) android.OutputPath { var readOnlyPaths = defaultReadOnlyFiles func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.OutputPath { var readOnlyPaths = []string{"apex_manifest.json", "apex_manifest.pb"} var executablePaths []string // this also includes dirs var appSetDirs []string appSetFiles := make(map[string]android.Path) Loading Loading
apex/apex.go +4 −32 Original line number Diff line number Diff line Loading @@ -1937,8 +1937,6 @@ type visitorContext struct { // visitor skips these from this list of module names unwantedTransitiveDeps []string aconfigFiles []android.Path } func (vctx *visitorContext) normalizeFileInfo(mctx android.ModuleContext) { Loading Loading @@ -2005,7 +2003,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, fi := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs) fi.isJniLib = isJniLib vctx.filesInfo = append(vctx.filesInfo, fi) addAconfigFiles(vctx, ctx, child) // Collect the list of stub-providing libs except: // - VNDK libs are only for vendors // - bootstrap bionic libs are treated as provided by system Loading @@ -2017,7 +2014,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, fi := apexFileForRustLibrary(ctx, ch) fi.isJniLib = isJniLib vctx.filesInfo = append(vctx.filesInfo, fi) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName) Loading @@ -2026,11 +2022,9 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, switch ch := child.(type) { case *cc.Module: vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, ch)) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies case *rust.Module: vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, ch)) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("binaries", Loading Loading @@ -2070,7 +2064,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, return false } vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child)) Loading @@ -2079,14 +2072,11 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, switch ap := child.(type) { case *java.AndroidApp: vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies case *java.AndroidAppImport: vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) addAconfigFiles(vctx, ctx, child) case *java.AndroidTestHelperApp: vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) addAconfigFiles(vctx, ctx, child) case *java.AndroidAppSet: appDir := "app" if ap.Privileged() { Loading @@ -2100,7 +2090,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap) af.certificate = java.PresignedCertificate vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) default: ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) } Loading Loading @@ -2132,7 +2121,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, for _, etcFile := range filesToCopy { vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile)) } addAconfigFiles(vctx, ctx, child) } else { ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName) } Loading @@ -2147,7 +2135,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := apexFileForExecutable(ctx, ccTest) af.class = nativeTest vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } else { ctx.PropertyErrorf("tests", "%q is not a cc module", depName) Loading Loading @@ -2227,7 +2214,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, } vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } else if rm, ok := child.(*rust.Module); ok { if !android.IsDepInSameApex(ctx, am, am) { Loading @@ -2237,7 +2223,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := apexFileForRustLibrary(ctx, rm) af.transitiveDep = true vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } } else if cc.IsHeaderDepTag(depTag) { Loading @@ -2260,7 +2245,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := apexFileForRustLibrary(ctx, rustm) af.transitiveDep = true vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies } } else if rust.IsRlibDepTag(depTag) { Loading @@ -2279,7 +2263,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, return false } vctx.filesInfo = append(vctx.filesInfo, af) addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("bootclasspath_fragments", Loading @@ -2294,7 +2277,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, if profileAf := apexFileForJavaModuleProfile(ctx, child.(javaModule)); profileAf != nil { vctx.filesInfo = append(vctx.filesInfo, *profileAf) } addAconfigFiles(vctx, ctx, child) return true // track transitive dependencies default: ctx.PropertyErrorf("systemserverclasspath_fragments", Loading @@ -2312,19 +2294,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, return false } func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) { if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigPropagatingProviderKey); ok { if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil { vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...) } } validationFlag := ctx.DeviceConfig().AconfigContainerValidation() if validationFlag == "error" || validationFlag == "warning" { android.VerifyAconfigBuildMode(ctx, ctx.ModuleName(), module, validationFlag == "error") } } func (a *apexBundle) shouldCheckDuplicate(ctx android.ModuleContext) bool { // TODO(b/263308293) remove this if a.properties.IsCoverageVariant { Loading Loading @@ -2406,12 +2375,15 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // 3) some fields in apexBundle struct are configured a.installDir = android.PathForModuleInstall(ctx, "apex") a.filesInfo = vctx.filesInfo a.aconfigFiles = android.FirstUniquePaths(vctx.aconfigFiles) a.setPayloadFsType(ctx) a.setSystemLibLink(ctx) a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx) //////////////////////////////////////////////////////////////////////////////////////////// // 3.a) some artifacts are generated from the collected files a.filesInfo = append(a.filesInfo, a.buildAconfigFiles(ctx)...) //////////////////////////////////////////////////////////////////////////////////////////// // 4) generate the build rules to create the APEX. This is done in builder.go. a.buildManifest(ctx, vctx.provideNativeLibs, vctx.requireNativeLibs) Loading
apex/apex_test.go +27 −18 Original line number Diff line number Diff line Loading @@ -267,6 +267,7 @@ func ensureNotContains(t *testing.T, result string, notExpected string) { } func ensureMatches(t *testing.T, result string, expectedRex string) { t.Helper() ok, err := regexp.MatchString(expectedRex, result) if err != nil { t.Fatalf("regexp failure trying to match %s against `%s` expression: %s", result, expectedRex, err) Loading @@ -277,6 +278,14 @@ func ensureMatches(t *testing.T, result string, expectedRex string) { } } func ensureListContainsMatch(t *testing.T, result []string, expectedRex string) { t.Helper() p := regexp.MustCompile(expectedRex) if android.IndexListPred(func(s string) bool { return p.MatchString(s) }, result) == -1 { t.Errorf("%q is not found in %v", expectedRex, result) } } func ensureListContains(t *testing.T, result []string, expected string) { t.Helper() if !android.InList(expected, result) { Loading Loading @@ -10791,14 +10800,14 @@ func TestAconfigFilesJavaDeps(t *testing.T) { mod := ctx.ModuleForTests("myapex", "android_common_myapex") s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) if len(copyCmds) != 8 { t.Fatalf("Expected 5 commands, got %d in:\n%s", len(copyCmds), s) if len(copyCmds) != 12 { t.Fatalf("Expected 12 commands, got %d in:\n%s", len(copyCmds), s) } ensureMatches(t, copyCmds[4], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$") ensureMatches(t, copyCmds[5], "^cp -f .*/package.map .*/image.apex/etc$") ensureMatches(t, copyCmds[6], "^cp -f .*/flag.map .*/image.apex/etc$") ensureMatches(t, copyCmds[7], "^cp -f .*/flag.val .*/image.apex/etc$") ensureListContainsMatch(t, copyCmds, "^cp -f .*/aconfig_flags.pb .*/image.apex/etc/aconfig_flags.pb") ensureListContainsMatch(t, copyCmds, "^cp -f .*/package.map .*/image.apex/etc/package.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.map .*/image.apex/etc/flag.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.val .*/image.apex/etc/flag.val") inputs := []string{ "my_aconfig_declarations_foo/intermediate.pb", Loading Loading @@ -10926,14 +10935,14 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) { mod := ctx.ModuleForTests("myapex", "android_common_myapex") s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) if len(copyCmds) != 12 { t.Fatalf("Expected 12 commands, got %d in:\n%s", len(copyCmds), s) if len(copyCmds) != 16 { t.Fatalf("Expected 16 commands, got %d in:\n%s", len(copyCmds), s) } ensureMatches(t, copyCmds[8], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$") ensureMatches(t, copyCmds[9], "^cp -f .*/package.map .*/image.apex/etc$") ensureMatches(t, copyCmds[10], "^cp -f .*/flag.map .*/image.apex/etc$") ensureMatches(t, copyCmds[11], "^cp -f .*/flag.val .*/image.apex/etc$") ensureListContainsMatch(t, copyCmds, "^cp -f .*/aconfig_flags.pb .*/image.apex/etc/aconfig_flags.pb") ensureListContainsMatch(t, copyCmds, "^cp -f .*/package.map .*/image.apex/etc/package.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.map .*/image.apex/etc/flag.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.val .*/image.apex/etc/flag.val") inputs := []string{ "my_aconfig_declarations_foo/intermediate.pb", Loading Loading @@ -11094,14 +11103,14 @@ func TestAconfigFilesRustDeps(t *testing.T) { mod := ctx.ModuleForTests("myapex", "android_common_myapex") s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) if len(copyCmds) != 32 { t.Fatalf("Expected 28 commands, got %d in:\n%s", len(copyCmds), s) if len(copyCmds) != 36 { t.Fatalf("Expected 36 commands, got %d in:\n%s", len(copyCmds), s) } ensureMatches(t, copyCmds[28], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$") ensureMatches(t, copyCmds[29], "^cp -f .*/package.map .*/image.apex/etc$") ensureMatches(t, copyCmds[30], "^cp -f .*/flag.map .*/image.apex/etc$") ensureMatches(t, copyCmds[31], "^cp -f .*/flag.val .*/image.apex/etc$") ensureListContainsMatch(t, copyCmds, "^cp -f .*/aconfig_flags.pb .*/image.apex/etc/aconfig_flags.pb") ensureListContainsMatch(t, copyCmds, "^cp -f .*/package.map .*/image.apex/etc/package.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.map .*/image.apex/etc/flag.map") ensureListContainsMatch(t, copyCmds, "^cp -f .*/flag.val .*/image.apex/etc/flag.val") inputs := []string{ "my_aconfig_declarations_foo/intermediate.pb", Loading
apex/builder.go +55 −41 Original line number Diff line number Diff line Loading @@ -262,6 +262,58 @@ var ( }, "tool_path", "unwanted") ) func (a *apexBundle) buildAconfigFiles(ctx android.ModuleContext) []apexFile { var aconfigFiles android.Paths for _, file := range a.filesInfo { if file.module == nil { continue } if dep, ok := android.OtherModuleProvider(ctx, file.module, android.AconfigPropagatingProviderKey); ok { if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil { aconfigFiles = append(aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...) } } validationFlag := ctx.DeviceConfig().AconfigContainerValidation() if validationFlag == "error" || validationFlag == "warning" { android.VerifyAconfigBuildMode(ctx, ctx.ModuleName(), file.module, validationFlag == "error") } } aconfigFiles = android.FirstUniquePaths(aconfigFiles) var files []apexFile if len(aconfigFiles) > 0 { apexAconfigFile := android.PathForModuleOut(ctx, "aconfig_flags.pb") ctx.Build(pctx, android.BuildParams{ Rule: aconfig.AllDeclarationsRule, Inputs: aconfigFiles, Output: apexAconfigFile, Description: "combine_aconfig_declarations", Args: map[string]string{ "cache_files": android.JoinPathsWithPrefix(aconfigFiles, "--cache "), }, }) files = append(files, newApexFile(ctx, apexAconfigFile, "aconfig_flags", "etc", etc, nil)) for _, info := range createStorageInfo { outputFile := android.PathForModuleOut(ctx, info.Output_file) ctx.Build(pctx, android.BuildParams{ Rule: aconfig.CreateStorageRule, Inputs: aconfigFiles, Output: outputFile, Description: info.Desc, Args: map[string]string{ "container": ctx.ModuleName(), "file_type": info.File_type, "cache_files": android.JoinPathsWithPrefix(aconfigFiles, "--cache "), }, }) files = append(files, newApexFile(ctx, outputFile, info.File_type, "etc", etc, nil)) } } return files } // buildManifest creates buile rules to modify the input apex_manifest.json to add information // gathered by the build system such as provided/required native libraries. Two output files having // different formats are generated. a.manifestJsonOut is JSON format for Q devices, and Loading Loading @@ -644,48 +696,10 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) { outHostBinDir := ctx.Config().HostToolPath(ctx, "").String() prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin") defaultReadOnlyFiles := []string{"apex_manifest.json", "apex_manifest.pb"} aconfigDest := imageDir.Join(ctx, "etc").String() if len(a.aconfigFiles) > 0 { apexAconfigFile := android.PathForModuleOut(ctx, "aconfig_flags.pb") ctx.Build(pctx, android.BuildParams{ Rule: aconfig.AllDeclarationsRule, Inputs: a.aconfigFiles, Output: apexAconfigFile, Description: "combine_aconfig_declarations", Args: map[string]string{ "cache_files": android.JoinPathsWithPrefix(a.aconfigFiles, "--cache "), }, }) copyCommands = append(copyCommands, "cp -f "+apexAconfigFile.String()+" "+aconfigDest) implicitInputs = append(implicitInputs, apexAconfigFile) defaultReadOnlyFiles = append(defaultReadOnlyFiles, "etc/"+apexAconfigFile.Base()) for _, info := range createStorageInfo { outputFile := android.PathForModuleOut(ctx, info.Output_file) ctx.Build(pctx, android.BuildParams{ Rule: aconfig.CreateStorageRule, Inputs: a.aconfigFiles, Output: outputFile, Description: info.Desc, Args: map[string]string{ "container": ctx.ModuleName(), "file_type": info.File_type, "cache_files": android.JoinPathsWithPrefix(a.aconfigFiles, "--cache "), }, }) copyCommands = append(copyCommands, "cp -f "+outputFile.String()+" "+aconfigDest) implicitInputs = append(implicitInputs, outputFile) defaultReadOnlyFiles = append(defaultReadOnlyFiles, "etc/"+outputFile.Base()) } } //////////////////////////////////////////////////////////////////////////////////// // Step 2: create canned_fs_config which encodes filemode,uid,gid of each files // in this APEX. The file will be used by apexer in later steps. cannedFsConfig := a.buildCannedFsConfig(ctx, defaultReadOnlyFiles) cannedFsConfig := a.buildCannedFsConfig(ctx) implicitInputs = append(implicitInputs, cannedFsConfig) //////////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -1139,8 +1153,8 @@ func (a *apexBundle) buildLintReports(ctx android.ModuleContext) { a.lintReports = java.BuildModuleLintReportZips(ctx, depSetsBuilder.Build()) } func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext, defaultReadOnlyFiles []string) android.OutputPath { var readOnlyPaths = defaultReadOnlyFiles func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.OutputPath { var readOnlyPaths = []string{"apex_manifest.json", "apex_manifest.pb"} var executablePaths []string // this also includes dirs var appSetDirs []string appSetFiles := make(map[string]android.Path) Loading