Merge "Add F2FS support for APEX build system"

This commit is contained in:
Nikita Ioffe 2020-08-28 21:55:24 +00:00 committed by Gerrit Code Review
commit a0254b5289
2 changed files with 42 additions and 2 deletions

View File

@ -41,6 +41,9 @@ const (
imageApexType = "image" imageApexType = "image"
zipApexType = "zip" zipApexType = "zip"
flattenedApexType = "flattened" flattenedApexType = "flattened"
ext4FsType = "ext4"
f2fsFsType = "f2fs"
) )
type dependencyTag struct { type dependencyTag struct {
@ -1040,6 +1043,10 @@ type apexBundleProperties struct {
// Should be only used in non-system apexes (e.g. vendor: true). // Should be only used in non-system apexes (e.g. vendor: true).
// Default is false. // Default is false.
Use_vndk_as_stable *bool Use_vndk_as_stable *bool
// The type of filesystem to use for an image apex. Either 'ext4' or 'f2fs'.
// Default 'ext4'.
Payload_fs_type *string
} }
type apexTargetBundleProperties struct { type apexTargetBundleProperties struct {
@ -1247,6 +1254,24 @@ func (af *apexFile) AvailableToPlatform() bool {
return false return false
} }
type fsType int
const (
ext4 fsType = iota
f2fs
)
func (f fsType) string() string {
switch f {
case ext4:
return ext4FsType
case f2fs:
return f2fsFsType
default:
panic(fmt.Errorf("unknown APEX payload type %d", f))
}
}
type apexBundle struct { type apexBundle struct {
android.ModuleBase android.ModuleBase
android.DefaultableModuleBase android.DefaultableModuleBase
@ -1312,6 +1337,8 @@ type apexBundle struct {
// Optional list of lint report zip files for apexes that contain java or app modules // Optional list of lint report zip files for apexes that contain java or app modules
lintReports android.Paths lintReports android.Paths
payloadFsType fsType
} }
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
@ -2284,6 +2311,15 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.installDir = android.PathForModuleInstall(ctx, "apex") a.installDir = android.PathForModuleInstall(ctx, "apex")
a.filesInfo = filesInfo a.filesInfo = filesInfo
switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) {
case ext4FsType:
a.payloadFsType = ext4
case f2fsFsType:
a.payloadFsType = f2fs
default:
ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs]", *a.properties.Payload_fs_type)
}
// Optimization. If we are building bundled APEX, for the files that are gathered due to the // Optimization. If we are building bundled APEX, for the files that are gathered due to the
// transitive dependencies, don't place them inside the APEX, but place a symlink pointing // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
// the same library in the system partition, thus effectively sharing the same libraries // the same library in the system partition, thus effectively sharing the same libraries

View File

@ -63,6 +63,8 @@ func init() {
pctx.HostBinToolVariable("jsonmodify", "jsonmodify") pctx.HostBinToolVariable("jsonmodify", "jsonmodify")
pctx.HostBinToolVariable("conv_apex_manifest", "conv_apex_manifest") pctx.HostBinToolVariable("conv_apex_manifest", "conv_apex_manifest")
pctx.HostBinToolVariable("extract_apks", "extract_apks") pctx.HostBinToolVariable("extract_apks", "extract_apks")
pctx.HostBinToolVariable("make_f2fs", "make_f2fs")
pctx.HostBinToolVariable("sload_f2fs", "sload_f2fs")
} }
var ( var (
@ -116,12 +118,12 @@ var (
`--payload_type image ` + `--payload_type image ` +
`--key ${key} ${opt_flags} ${image_dir} ${out} `, `--key ${key} ${opt_flags} ${image_dir} ${out} `,
CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}", CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}",
"${mke2fs}", "${resize2fs}", "${sefcontext_compile}", "${mke2fs}", "${resize2fs}", "${sefcontext_compile}", "${make_f2fs}", "${sload_f2fs}",
"${soong_zip}", "${zipalign}", "${aapt2}", "prebuilts/sdk/current/public/android.jar"}, "${soong_zip}", "${zipalign}", "${aapt2}", "prebuilts/sdk/current/public/android.jar"},
Rspfile: "${out}.copy_commands", Rspfile: "${out}.copy_commands",
RspfileContent: "${copy_commands}", RspfileContent: "${copy_commands}",
Description: "APEX ${image_dir} => ${out}", Description: "APEX ${image_dir} => ${out}",
}, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest") }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest", "payload_fs_type")
zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{ zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{
Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` + Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
@ -582,6 +584,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
optFlags = append(optFlags, "--manifest_json "+a.manifestJsonOut.String()) optFlags = append(optFlags, "--manifest_json "+a.manifestJsonOut.String())
} }
optFlags = append(optFlags, "--payload_fs_type "+a.payloadFsType.string())
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
Rule: apexRule, Rule: apexRule,
Implicits: implicitInputs, Implicits: implicitInputs,