Documenting apex/apex.go
Mostly documentation changes, but includes a few refactorings like changing the variable names, reording functions, reordering statements in logical order, etc. Bug: 173472337 Test: m Change-Id: Ie1799c0972d63da823ad375f008018de782529d1
This commit is contained in:
parent
b26070efef
commit
c0ec6f99d7
3 changed files with 971 additions and 810 deletions
|
@ -36,6 +36,33 @@ func (a *apexBundle) AndroidMk() android.AndroidMkData {
|
|||
return a.androidMkForType()
|
||||
}
|
||||
|
||||
// nameInMake converts apexFileClass into the corresponding class name in Make.
|
||||
func (class apexFileClass) nameInMake() string {
|
||||
switch class {
|
||||
case etc:
|
||||
return "ETC"
|
||||
case nativeSharedLib:
|
||||
return "SHARED_LIBRARIES"
|
||||
case nativeExecutable, shBinary, pyBinary, goBinary:
|
||||
return "EXECUTABLES"
|
||||
case javaSharedLib:
|
||||
return "JAVA_LIBRARIES"
|
||||
case nativeTest:
|
||||
return "NATIVE_TESTS"
|
||||
case app, appSet:
|
||||
// b/142537672 Why isn't this APP? We want to have full control over
|
||||
// the paths and file names of the apk file under the flattend APEX.
|
||||
// If this is set to APP, then the paths and file names are modified
|
||||
// by the Make build system. For example, it is installed to
|
||||
// /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
|
||||
// /system/apex/<apexname>/app/<Appname> because the build system automatically
|
||||
// appends module name (which is <apexname>.<Appname> to the path.
|
||||
return "ETC"
|
||||
default:
|
||||
panic(fmt.Errorf("unknown class %d", class))
|
||||
}
|
||||
}
|
||||
|
||||
func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, moduleDir string,
|
||||
apexAndroidMkData android.AndroidMkData) []string {
|
||||
|
||||
|
@ -68,10 +95,10 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
|
||||
var postInstallCommands []string
|
||||
for _, fi := range a.filesInfo {
|
||||
if a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() {
|
||||
if a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform() {
|
||||
// TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here
|
||||
linkTarget := filepath.Join("/system", fi.Path())
|
||||
linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexBundleName, fi.Path())
|
||||
linkTarget := filepath.Join("/system", fi.path())
|
||||
linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexBundleName, fi.path())
|
||||
mkdirCmd := "mkdir -p " + filepath.Dir(linkPath)
|
||||
linkCmd := "ln -sfn " + linkTarget + " " + linkPath
|
||||
postInstallCommands = append(postInstallCommands, mkdirCmd, linkCmd)
|
||||
|
@ -85,7 +112,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
continue
|
||||
}
|
||||
|
||||
linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform()
|
||||
linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform()
|
||||
|
||||
var moduleName string
|
||||
if linkToSystemLib {
|
||||
|
@ -151,7 +178,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
|
||||
}
|
||||
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.nameInMake())
|
||||
if fi.module != nil {
|
||||
archStr := fi.module.Target().Arch.ArchType.String()
|
||||
host := false
|
||||
|
@ -189,7 +216,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
// soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
|
||||
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
|
||||
// we will have foo.jar.jar
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".jar"))
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.stem(), ".jar"))
|
||||
if javaModule, ok := fi.module.(java.ApexDependency); ok {
|
||||
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
|
||||
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
|
||||
|
@ -205,7 +232,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
// soong_app_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .apk Therefore
|
||||
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
|
||||
// we will have foo.apk.apk
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".apk"))
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.stem(), ".apk"))
|
||||
if app, ok := fi.module.(*java.AndroidApp); ok {
|
||||
if jniCoverageOutputs := app.JniCoverageOutputs(); len(jniCoverageOutputs) > 0 {
|
||||
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", strings.Join(jniCoverageOutputs.Strings(), " "))
|
||||
|
@ -224,7 +251,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
fmt.Fprintln(w, "LOCAL_APKCERTS_FILE :=", as.APKCertsFile().String())
|
||||
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_android_app_set.mk")
|
||||
case nativeSharedLib, nativeExecutable, nativeTest:
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.stem())
|
||||
if ccMod, ok := fi.module.(*cc.Module); ok {
|
||||
if ccMod.UnstrippedOutputFile() != nil {
|
||||
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", ccMod.UnstrippedOutputFile().String())
|
||||
|
@ -236,7 +263,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
}
|
||||
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
|
||||
default:
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.stem())
|
||||
if fi.builtFile == a.manifestPbOut && apexType == flattenedApex {
|
||||
if a.primaryApexType {
|
||||
// To install companion files (init_rc, vintf_fragments)
|
||||
|
|
1707
apex/apex.go
1707
apex/apex.go
File diff suppressed because it is too large
Load diff
|
@ -195,8 +195,8 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs,
|
|||
// collect jniLibs. Notice that a.filesInfo is already sorted
|
||||
var jniLibs []string
|
||||
for _, fi := range a.filesInfo {
|
||||
if fi.isJniLib && !android.InList(fi.Stem(), jniLibs) {
|
||||
jniLibs = append(jniLibs, fi.Stem())
|
||||
if fi.isJniLib && !android.InList(fi.stem(), jniLibs) {
|
||||
jniLibs = append(jniLibs, fi.stem())
|
||||
}
|
||||
}
|
||||
if len(jniLibs) > 0 {
|
||||
|
@ -363,7 +363,7 @@ func (a *apexBundle) buildBundleConfig(ctx android.ModuleContext) android.Output
|
|||
config.Apex_config.Apex_embedded_apk_config,
|
||||
ApkConfig{
|
||||
Package_name: packageName,
|
||||
Apk_path: fi.Path(),
|
||||
Apk_path: fi.path(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -396,15 +396,15 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
// TODO(jiyong): construct the copy rules using RuleBuilder
|
||||
var copyCommands []string
|
||||
for _, fi := range a.filesInfo {
|
||||
destPath := android.PathForModuleOut(ctx, "image"+suffix, fi.Path()).String()
|
||||
destPath := android.PathForModuleOut(ctx, "image"+suffix, fi.path()).String()
|
||||
destPathDir := filepath.Dir(destPath)
|
||||
if fi.class == appSet {
|
||||
copyCommands = append(copyCommands, "rm -rf "+destPathDir)
|
||||
}
|
||||
copyCommands = append(copyCommands, "mkdir -p "+destPathDir)
|
||||
if a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() {
|
||||
if a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform() {
|
||||
// TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here
|
||||
pathOnDevice := filepath.Join("/system", fi.Path())
|
||||
pathOnDevice := filepath.Join("/system", fi.path())
|
||||
copyCommands = append(copyCommands, "ln -sfn "+pathOnDevice+" "+destPath)
|
||||
} else {
|
||||
if fi.class == appSet {
|
||||
|
@ -416,7 +416,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
implicitInputs = append(implicitInputs, fi.builtFile)
|
||||
}
|
||||
// create additional symlinks pointing the file inside the APEX
|
||||
for _, symlinkPath := range fi.SymlinkPaths() {
|
||||
for _, symlinkPath := range fi.symlinkPaths() {
|
||||
symlinkDest := android.PathForModuleOut(ctx, "image"+suffix, symlinkPath).String()
|
||||
copyCommands = append(copyCommands, "ln -sfn "+filepath.Base(destPath)+" "+symlinkDest)
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
|
||||
}
|
||||
for _, fi := range a.filesInfo {
|
||||
emitCommands = append(emitCommands, "echo './"+fi.Path()+"' >> "+imageContentFile.String())
|
||||
emitCommands = append(emitCommands, "echo './"+fi.path()+"' >> "+imageContentFile.String())
|
||||
}
|
||||
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
|
||||
implicitInputs = append(implicitInputs, a.manifestPbOut)
|
||||
|
@ -489,7 +489,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
var extractedAppSetPaths android.Paths
|
||||
var extractedAppSetDirs []string
|
||||
for _, f := range a.filesInfo {
|
||||
pathInApex := f.Path()
|
||||
pathInApex := f.path()
|
||||
if f.installDir == "bin" || strings.HasPrefix(f.installDir, "bin/") {
|
||||
executablePaths = append(executablePaths, pathInApex)
|
||||
for _, d := range f.dataPaths {
|
||||
|
@ -697,6 +697,15 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
a.installedFilesFile = a.buildInstalledFilesFile(ctx, a.outputFile, imageDir)
|
||||
}
|
||||
|
||||
// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
|
||||
type flattenedApexContext struct {
|
||||
android.ModuleContext
|
||||
}
|
||||
|
||||
func (c *flattenedApexContext) InstallBypassMake() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
|
||||
// Temporarily wrap the original `ctx` into a `flattenedApexContext` to have it
|
||||
// reply true to `InstallBypassMake()` (thus making the call
|
||||
|
@ -742,7 +751,7 @@ func (a *apexBundle) buildFilesInfo(ctx android.ModuleContext) {
|
|||
apexBundleName := a.Name()
|
||||
for _, fi := range a.filesInfo {
|
||||
dir := filepath.Join("apex", apexBundleName, fi.installDir)
|
||||
target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.Stem(), fi.builtFile)
|
||||
target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.stem(), fi.builtFile)
|
||||
for _, sym := range fi.symlinks {
|
||||
ctx.InstallSymlink(android.PathForModuleInstall(ctx, dir), sym, target)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue