Merge "Add isFlattenedVariant function" am: d9271cd823
am: e77be60bdc
am: 7dca301944
Change-Id: Ic02d3e98bdd4617de176fba128acdfb7093bf0f1
This commit is contained in:
commit
2e189f5960
44
apex/apex.go
44
apex/apex.go
|
@ -289,11 +289,14 @@ func apexMutator(mctx android.BottomUpMutatorContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if _, ok := mctx.Module().(*apexBundle); ok {
|
if ab, ok := mctx.Module().(*apexBundle); ok {
|
||||||
if !mctx.Config().FlattenApex() || mctx.Config().UnbundledBuild() {
|
if !mctx.Config().FlattenApex() || mctx.Config().UnbundledBuild() {
|
||||||
modules := mctx.CreateLocalVariations("", "flattened")
|
modules := mctx.CreateLocalVariations("", "flattened")
|
||||||
modules[0].(*apexBundle).SetFlattened(false)
|
modules[0].(*apexBundle).SetFlattened(false)
|
||||||
modules[1].(*apexBundle).SetFlattened(true)
|
modules[1].(*apexBundle).SetFlattened(true)
|
||||||
|
} else {
|
||||||
|
ab.SetFlattened(true)
|
||||||
|
ab.SetFlattenedConfigValue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,10 +412,14 @@ type apexBundleProperties struct {
|
||||||
// List of APKs to package inside APEX
|
// List of APKs to package inside APEX
|
||||||
Apps []string
|
Apps []string
|
||||||
|
|
||||||
// To distinguish between flattened and non-flattened variants.
|
// To distinguish between flattened and non-flattened apex.
|
||||||
// if set true, then this variant is flattened variant.
|
// if set true, then output files are flattened.
|
||||||
Flattened bool `blueprint:"mutated"`
|
Flattened bool `blueprint:"mutated"`
|
||||||
|
|
||||||
|
// if true, it means that TARGET_FLATTEN_APEX is true and
|
||||||
|
// TARGET_BUILD_APPS is false
|
||||||
|
FlattenedConfigValue bool `blueprint:"mutated"`
|
||||||
|
|
||||||
// List of SDKs that are used to build this APEX. A reference to an SDK should be either
|
// List of SDKs that are used to build this APEX. A reference to an SDK should be either
|
||||||
// `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
|
// `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
|
||||||
// is implied. This value affects all modules included in this APEX. In other words, they are
|
// is implied. This value affects all modules included in this APEX. In other words, they are
|
||||||
|
@ -576,9 +583,6 @@ type apexBundle struct {
|
||||||
|
|
||||||
// intermediate path for apex_manifest.json
|
// intermediate path for apex_manifest.json
|
||||||
manifestOut android.WritablePath
|
manifestOut android.WritablePath
|
||||||
|
|
||||||
// A config value of (TARGET_FLATTEN_APEX && !TARGET_BUILD_APPS)
|
|
||||||
flattenedConfigValue bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
|
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
|
||||||
|
@ -839,6 +843,20 @@ func (a *apexBundle) SetFlattened(flattened bool) {
|
||||||
a.properties.Flattened = flattened
|
a.properties.Flattened = flattened
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *apexBundle) SetFlattenedConfigValue() {
|
||||||
|
a.properties.FlattenedConfigValue = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// isFlattenedVariant returns true when the current module is the flattened
|
||||||
|
// variant of an apex that has both a flattened and an unflattened variant.
|
||||||
|
// It returns false when the current module is flattened but there is no
|
||||||
|
// unflattened variant, which occurs when ctx.Config().FlattenedApex() returns
|
||||||
|
// true. It can be used to avoid collisions between the install paths of the
|
||||||
|
// flattened and unflattened variants.
|
||||||
|
func (a *apexBundle) isFlattenedVariant() bool {
|
||||||
|
return a.properties.Flattened && !a.properties.FlattenedConfigValue
|
||||||
|
}
|
||||||
|
|
||||||
func getCopyManifestForNativeLibrary(ccMod *cc.Module, config android.Config, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
|
func getCopyManifestForNativeLibrary(ccMod *cc.Module, config android.Config, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
|
||||||
// Decide the APEX-local directory by the multilib of the library
|
// Decide the APEX-local directory by the multilib of the library
|
||||||
// In the future, we may query this to the module.
|
// In the future, we may query this to the module.
|
||||||
|
@ -1160,10 +1178,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
a.flattenedConfigValue = ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
|
|
||||||
if a.flattenedConfigValue {
|
|
||||||
a.properties.Flattened = true
|
|
||||||
}
|
|
||||||
if a.private_key_file == nil {
|
if a.private_key_file == nil {
|
||||||
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
|
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
|
||||||
return
|
return
|
||||||
|
@ -1502,7 +1516,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType ap
|
||||||
})
|
})
|
||||||
|
|
||||||
// Install to $OUT/soong/{target,host}/.../apex
|
// Install to $OUT/soong/{target,host}/.../apex
|
||||||
if a.installable() && (!ctx.Config().FlattenApex() || apexType.zip()) && (!a.properties.Flattened || a.flattenedConfigValue) {
|
if a.installable() && (!ctx.Config().FlattenApex() || apexType.zip()) && !a.isFlattenedVariant() {
|
||||||
ctx.InstallFile(a.installDir, ctx.ModuleName()+suffix, a.outputFiles[apexType])
|
ctx.InstallFile(a.installDir, ctx.ModuleName()+suffix, a.outputFiles[apexType])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1567,7 +1581,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string, apex
|
||||||
}
|
}
|
||||||
|
|
||||||
var suffix string
|
var suffix string
|
||||||
if a.properties.Flattened && !a.flattenedConfigValue {
|
if a.isFlattenedVariant() {
|
||||||
suffix = ".flattened"
|
suffix = ".flattened"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1585,7 +1599,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string, apex
|
||||||
// /system/apex/<name>/{lib|framework|...}
|
// /system/apex/<name>/{lib|framework|...}
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)",
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)",
|
||||||
a.installDir.RelPathString(), name, fi.installDir))
|
a.installDir.RelPathString(), name, fi.installDir))
|
||||||
if a.flattenedConfigValue {
|
if !a.isFlattenedVariant() {
|
||||||
fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated)
|
fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated)
|
||||||
}
|
}
|
||||||
if len(fi.symlinks) > 0 {
|
if len(fi.symlinks) > 0 {
|
||||||
|
@ -1667,7 +1681,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
|
||||||
moduleNames = a.androidMkForFiles(w, name, moduleDir, apexType)
|
moduleNames = a.androidMkForFiles(w, name, moduleDir, apexType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.properties.Flattened && !a.flattenedConfigValue {
|
if a.isFlattenedVariant() {
|
||||||
name = name + ".flattened"
|
name = name + ".flattened"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1682,7 +1696,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
|
||||||
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
||||||
fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): .KATI_IMPLICIT_OUTPUTS :=", a.flattenedOutput.String())
|
fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): .KATI_IMPLICIT_OUTPUTS :=", a.flattenedOutput.String())
|
||||||
|
|
||||||
} else if !a.properties.Flattened || a.flattenedConfigValue {
|
} else if !a.isFlattenedVariant() {
|
||||||
// zip-apex is the less common type so have the name refer to the image-apex
|
// zip-apex is the less common type so have the name refer to the image-apex
|
||||||
// only and use {name}.zip if you want the zip-apex
|
// only and use {name}.zip if you want the zip-apex
|
||||||
if apexType == zipApex && a.apexTypes == both {
|
if apexType == zipApex && a.apexTypes == both {
|
||||||
|
|
Loading…
Reference in New Issue