Loading apex/androidmk.go +12 −17 Original line number Diff line number Diff line Loading @@ -24,8 +24,6 @@ import ( "android/soong/cc" "android/soong/java" "android/soong/rust" "github.com/google/blueprint/proptools" ) func (a *apexBundle) AndroidMk() android.AndroidMkData { Loading Loading @@ -74,12 +72,15 @@ func (a *apexBundle) fullModuleName(apexBundleName string, fi *apexFile) string return fi.androidMkModuleName + "." + apexBundleName + a.suffix } func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, moduleDir string, func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir string, apexAndroidMkData android.AndroidMkData) []string { // apexBundleName comes from the 'name' property; apexName comes from 'apex_name' property. // apexBundleName comes from the 'name' property or soong module. // apexName comes from 'name' property of apex_manifest. // An apex is installed to /system/apex/<apexBundleName> and is activated at /apex/<apexName> // In many cases, the two names are the same, but could be different in general. // However, symbol files for apex files are installed under /apex/<apexBundleName> to avoid // conflicts between two apexes with the same apexName. moduleNames := []string{} apexType := a.properties.ApexType Loading @@ -90,11 +91,6 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo return moduleNames } // b/162366062. Prevent GKI APEXes to emit make rules to avoid conflicts. if strings.HasPrefix(apexName, "com.android.gki.") && apexType != flattenedApex { return moduleNames } seenDataOutPaths := make(map[string]bool) for _, fi := range a.filesInfo { Loading Loading @@ -131,15 +127,15 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo if fi.module != nil && fi.module.Owner() != "" { fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", fi.module.Owner()) } // /apex/<apex_name>/{lib|framework|...} pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir) // /apex/<apexBundleName>/{lib|framework|...} pathForSymbol := filepath.Join("$(PRODUCT_OUT)", "apex", apexBundleName, fi.installDir) var modulePath string if apexType == flattenedApex { // /system/apex/<name>/{lib|framework|...} // /system/apex/<apexBundleName>/{lib|framework|...} modulePath = filepath.Join(a.installDir.String(), apexBundleName, fi.installDir) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", modulePath) if a.primaryApexType { fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated) fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathForSymbol) } android.AndroidMkEmitAssignList(w, "LOCAL_MODULE_SYMLINKS", fi.symlinks) newDataPaths := []android.DataPath{} Loading @@ -152,8 +148,8 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo } android.AndroidMkEmitAssignList(w, "LOCAL_TEST_DATA", android.AndroidMkDataPaths(newDataPaths)) } else { modulePath = pathWhenActivated fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated) modulePath = pathForSymbol fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", modulePath) // For non-flattend APEXes, the merged notice file is attached to the APEX itself. // We don't need to have notice file for the individual modules in it. Otherwise, Loading Loading @@ -311,8 +307,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { moduleNames := []string{} apexType := a.properties.ApexType if a.installable() { apexName := proptools.StringDefault(a.properties.Apex_name, name) moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data) moduleNames = a.androidMkForFiles(w, name, moduleDir, data) } if apexType == flattenedApex { Loading apex/apex.go +1 −5 Original line number Diff line number Diff line Loading @@ -94,10 +94,6 @@ type apexBundleProperties struct { // a default one is automatically generated. AndroidManifest *string `android:"path"` // Canonical name of this APEX bundle. Used to determine the path to the activated APEX on // device (/apex/<apex_name>). If unspecified, follows the name property. Apex_name *string // 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: // /system/sepolicy/apex/<module_name>_file_contexts. Loading Loading @@ -1037,7 +1033,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { // This is the main part of this mutator. Mark the collected dependencies that they need to // be built for this apexBundle. apexVariationName := proptools.StringDefault(a.properties.Apex_name, mctx.ModuleName()) // could be com.android.foo apexVariationName := mctx.ModuleName() // could be com.android.foo a.properties.ApexVariationName = apexVariationName apexInfo := android.ApexInfo{ ApexVariationName: apexVariationName, Loading apex/apex_test.go +1 −42 Original line number Diff line number Diff line Loading @@ -4105,52 +4105,11 @@ func TestDependenciesInApexManifest(t *testing.T) { ensureListEmpty(t, requireNativeLibs) } func TestApexName(t *testing.T) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", apex_name: "com.android.myapex", native_shared_libs: ["mylib"], updatable: false, } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } cc_library { name: "mylib", srcs: ["mylib.cpp"], system_shared_libs: [], stl: "none", apex_available: [ "//apex_available:platform", "myapex", ], } `) module := ctx.ModuleForTests("myapex", "android_common_com.android.myapex_image") apexBundle := module.Module().(*apexBundle) data := android.AndroidMkDataForTest(t, ctx, apexBundle) name := apexBundle.BaseModuleName() prefix := "TARGET_" var builder strings.Builder data.Custom(&builder, name, prefix, "", data) androidMk := builder.String() ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n") ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n") } func TestOverrideApexManifestDefaultVersion(t *testing.T) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", apex_name: "com.android.myapex", native_shared_libs: ["mylib"], updatable: false, } Loading @@ -4175,7 +4134,7 @@ func TestOverrideApexManifestDefaultVersion(t *testing.T) { "OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION": "1234", })) module := ctx.ModuleForTests("myapex", "android_common_com.android.myapex_image") module := ctx.ModuleForTests("myapex", "android_common_myapex_image") apexManifestRule := module.Rule("apexManifestRule") ensureContains(t, apexManifestRule.Args["default_version"], "1234") } Loading apex/builder.go +7 −7 Original line number Diff line number Diff line Loading @@ -446,7 +446,7 @@ func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { apexType := a.properties.ApexType suffix := apexType.suffix() apexName := proptools.StringDefault(a.properties.Apex_name, a.BaseModuleName()) apexName := a.BaseModuleName() //////////////////////////////////////////////////////////////////////////////////////////// // Step 1: copy built files to appropriate directories under the image directory Loading @@ -461,7 +461,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { // TODO(jiyong): use the RuleBuilder var copyCommands []string var implicitInputs []android.Path pathWhenActivated := android.PathForModuleInPartitionInstall(ctx, "apex", apexName) apexDir := android.PathForModuleInPartitionInstall(ctx, "apex", apexName) for _, fi := range a.filesInfo { destPath := imageDir.Join(ctx, fi.path()).String() // Prepare the destination path Loading Loading @@ -491,12 +491,12 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { fmt.Sprintf("unzip -qDD -d %s %s", destPathDir, fi.module.(*java.AndroidAppSet).PackedAdditionalOutputs().String())) if installSymbolFiles { installedPath = ctx.InstallFileWithExtraFilesZip(pathWhenActivated.Join(ctx, fi.installDir), installedPath = ctx.InstallFileWithExtraFilesZip(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile, fi.module.(*java.AndroidAppSet).PackedAdditionalOutputs()) } } else { if installSymbolFiles { installedPath = ctx.InstallFile(pathWhenActivated.Join(ctx, fi.installDir), fi.stem(), fi.builtFile) installedPath = ctx.InstallFile(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile) } } implicitInputs = append(implicitInputs, fi.builtFile) Loading @@ -510,7 +510,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { symlinkDest := imageDir.Join(ctx, symlinkPath).String() copyCommands = append(copyCommands, "ln -sfn "+filepath.Base(destPath)+" "+symlinkDest) if installSymbolFiles { installedSymlink := ctx.InstallSymlink(pathWhenActivated.Join(ctx, filepath.Dir(symlinkPath)), filepath.Base(symlinkPath), installedPath) installedSymlink := ctx.InstallSymlink(apexDir.Join(ctx, filepath.Dir(symlinkPath)), filepath.Base(symlinkPath), installedPath) implicitInputs = append(implicitInputs, installedSymlink) } } Loading @@ -537,8 +537,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { } implicitInputs = append(implicitInputs, a.manifestPbOut) if installSymbolFiles { installedManifest := ctx.InstallFile(pathWhenActivated, "apex_manifest.pb", a.manifestPbOut) installedKey := ctx.InstallFile(pathWhenActivated, "apex_pubkey", a.publicKeyFile) installedManifest := ctx.InstallFile(apexDir, "apex_manifest.pb", a.manifestPbOut) installedKey := ctx.InstallFile(apexDir, "apex_pubkey", a.publicKeyFile) implicitInputs = append(implicitInputs, installedManifest, installedKey) } Loading Loading
apex/androidmk.go +12 −17 Original line number Diff line number Diff line Loading @@ -24,8 +24,6 @@ import ( "android/soong/cc" "android/soong/java" "android/soong/rust" "github.com/google/blueprint/proptools" ) func (a *apexBundle) AndroidMk() android.AndroidMkData { Loading Loading @@ -74,12 +72,15 @@ func (a *apexBundle) fullModuleName(apexBundleName string, fi *apexFile) string return fi.androidMkModuleName + "." + apexBundleName + a.suffix } func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, moduleDir string, func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir string, apexAndroidMkData android.AndroidMkData) []string { // apexBundleName comes from the 'name' property; apexName comes from 'apex_name' property. // apexBundleName comes from the 'name' property or soong module. // apexName comes from 'name' property of apex_manifest. // An apex is installed to /system/apex/<apexBundleName> and is activated at /apex/<apexName> // In many cases, the two names are the same, but could be different in general. // However, symbol files for apex files are installed under /apex/<apexBundleName> to avoid // conflicts between two apexes with the same apexName. moduleNames := []string{} apexType := a.properties.ApexType Loading @@ -90,11 +91,6 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo return moduleNames } // b/162366062. Prevent GKI APEXes to emit make rules to avoid conflicts. if strings.HasPrefix(apexName, "com.android.gki.") && apexType != flattenedApex { return moduleNames } seenDataOutPaths := make(map[string]bool) for _, fi := range a.filesInfo { Loading Loading @@ -131,15 +127,15 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo if fi.module != nil && fi.module.Owner() != "" { fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", fi.module.Owner()) } // /apex/<apex_name>/{lib|framework|...} pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir) // /apex/<apexBundleName>/{lib|framework|...} pathForSymbol := filepath.Join("$(PRODUCT_OUT)", "apex", apexBundleName, fi.installDir) var modulePath string if apexType == flattenedApex { // /system/apex/<name>/{lib|framework|...} // /system/apex/<apexBundleName>/{lib|framework|...} modulePath = filepath.Join(a.installDir.String(), apexBundleName, fi.installDir) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", modulePath) if a.primaryApexType { fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated) fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathForSymbol) } android.AndroidMkEmitAssignList(w, "LOCAL_MODULE_SYMLINKS", fi.symlinks) newDataPaths := []android.DataPath{} Loading @@ -152,8 +148,8 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo } android.AndroidMkEmitAssignList(w, "LOCAL_TEST_DATA", android.AndroidMkDataPaths(newDataPaths)) } else { modulePath = pathWhenActivated fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated) modulePath = pathForSymbol fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", modulePath) // For non-flattend APEXes, the merged notice file is attached to the APEX itself. // We don't need to have notice file for the individual modules in it. Otherwise, Loading Loading @@ -311,8 +307,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { moduleNames := []string{} apexType := a.properties.ApexType if a.installable() { apexName := proptools.StringDefault(a.properties.Apex_name, name) moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data) moduleNames = a.androidMkForFiles(w, name, moduleDir, data) } if apexType == flattenedApex { Loading
apex/apex.go +1 −5 Original line number Diff line number Diff line Loading @@ -94,10 +94,6 @@ type apexBundleProperties struct { // a default one is automatically generated. AndroidManifest *string `android:"path"` // Canonical name of this APEX bundle. Used to determine the path to the activated APEX on // device (/apex/<apex_name>). If unspecified, follows the name property. Apex_name *string // 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: // /system/sepolicy/apex/<module_name>_file_contexts. Loading Loading @@ -1037,7 +1033,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { // This is the main part of this mutator. Mark the collected dependencies that they need to // be built for this apexBundle. apexVariationName := proptools.StringDefault(a.properties.Apex_name, mctx.ModuleName()) // could be com.android.foo apexVariationName := mctx.ModuleName() // could be com.android.foo a.properties.ApexVariationName = apexVariationName apexInfo := android.ApexInfo{ ApexVariationName: apexVariationName, Loading
apex/apex_test.go +1 −42 Original line number Diff line number Diff line Loading @@ -4105,52 +4105,11 @@ func TestDependenciesInApexManifest(t *testing.T) { ensureListEmpty(t, requireNativeLibs) } func TestApexName(t *testing.T) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", apex_name: "com.android.myapex", native_shared_libs: ["mylib"], updatable: false, } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } cc_library { name: "mylib", srcs: ["mylib.cpp"], system_shared_libs: [], stl: "none", apex_available: [ "//apex_available:platform", "myapex", ], } `) module := ctx.ModuleForTests("myapex", "android_common_com.android.myapex_image") apexBundle := module.Module().(*apexBundle) data := android.AndroidMkDataForTest(t, ctx, apexBundle) name := apexBundle.BaseModuleName() prefix := "TARGET_" var builder strings.Builder data.Custom(&builder, name, prefix, "", data) androidMk := builder.String() ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n") ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n") } func TestOverrideApexManifestDefaultVersion(t *testing.T) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", apex_name: "com.android.myapex", native_shared_libs: ["mylib"], updatable: false, } Loading @@ -4175,7 +4134,7 @@ func TestOverrideApexManifestDefaultVersion(t *testing.T) { "OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION": "1234", })) module := ctx.ModuleForTests("myapex", "android_common_com.android.myapex_image") module := ctx.ModuleForTests("myapex", "android_common_myapex_image") apexManifestRule := module.Rule("apexManifestRule") ensureContains(t, apexManifestRule.Args["default_version"], "1234") } Loading
apex/builder.go +7 −7 Original line number Diff line number Diff line Loading @@ -446,7 +446,7 @@ func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { apexType := a.properties.ApexType suffix := apexType.suffix() apexName := proptools.StringDefault(a.properties.Apex_name, a.BaseModuleName()) apexName := a.BaseModuleName() //////////////////////////////////////////////////////////////////////////////////////////// // Step 1: copy built files to appropriate directories under the image directory Loading @@ -461,7 +461,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { // TODO(jiyong): use the RuleBuilder var copyCommands []string var implicitInputs []android.Path pathWhenActivated := android.PathForModuleInPartitionInstall(ctx, "apex", apexName) apexDir := android.PathForModuleInPartitionInstall(ctx, "apex", apexName) for _, fi := range a.filesInfo { destPath := imageDir.Join(ctx, fi.path()).String() // Prepare the destination path Loading Loading @@ -491,12 +491,12 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { fmt.Sprintf("unzip -qDD -d %s %s", destPathDir, fi.module.(*java.AndroidAppSet).PackedAdditionalOutputs().String())) if installSymbolFiles { installedPath = ctx.InstallFileWithExtraFilesZip(pathWhenActivated.Join(ctx, fi.installDir), installedPath = ctx.InstallFileWithExtraFilesZip(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile, fi.module.(*java.AndroidAppSet).PackedAdditionalOutputs()) } } else { if installSymbolFiles { installedPath = ctx.InstallFile(pathWhenActivated.Join(ctx, fi.installDir), fi.stem(), fi.builtFile) installedPath = ctx.InstallFile(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile) } } implicitInputs = append(implicitInputs, fi.builtFile) Loading @@ -510,7 +510,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { symlinkDest := imageDir.Join(ctx, symlinkPath).String() copyCommands = append(copyCommands, "ln -sfn "+filepath.Base(destPath)+" "+symlinkDest) if installSymbolFiles { installedSymlink := ctx.InstallSymlink(pathWhenActivated.Join(ctx, filepath.Dir(symlinkPath)), filepath.Base(symlinkPath), installedPath) installedSymlink := ctx.InstallSymlink(apexDir.Join(ctx, filepath.Dir(symlinkPath)), filepath.Base(symlinkPath), installedPath) implicitInputs = append(implicitInputs, installedSymlink) } } Loading @@ -537,8 +537,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { } implicitInputs = append(implicitInputs, a.manifestPbOut) if installSymbolFiles { installedManifest := ctx.InstallFile(pathWhenActivated, "apex_manifest.pb", a.manifestPbOut) installedKey := ctx.InstallFile(pathWhenActivated, "apex_pubkey", a.publicKeyFile) installedManifest := ctx.InstallFile(apexDir, "apex_manifest.pb", a.manifestPbOut) installedKey := ctx.InstallFile(apexDir, "apex_pubkey", a.publicKeyFile) implicitInputs = append(implicitInputs, installedManifest, installedKey) } Loading