summaryrefslogtreecommitdiff
path: root/apex/builder.go
diff options
context:
space:
mode:
Diffstat (limited to 'apex/builder.go')
-rw-r--r--apex/builder.go516
1 files changed, 258 insertions, 258 deletions
diff --git a/apex/builder.go b/apex/builder.go
index db66a72ce..1204dbb97 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -75,6 +75,8 @@ func init() {
pctx.HostBinToolVariable("deapexer", "deapexer")
pctx.HostBinToolVariable("debugfs_static", "debugfs_static")
pctx.SourcePathVariable("genNdkUsedbyApexPath", "build/soong/scripts/gen_ndk_usedby_apex.sh")
+ pctx.HostBinToolVariable("conv_linker_config", "conv_linker_config")
+ pctx.HostBinToolVariable("assemble_vintf", "assemble_vintf")
}
var (
@@ -179,19 +181,6 @@ var (
}, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key",
"opt_flags", "manifest", "libs_to_trim")
- zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{
- Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
- `(. ${out}.copy_commands) && ` +
- `APEXER_TOOL_PATH=${tool_path} ` +
- `${apexer} --force --manifest ${manifest} ` +
- `--payload_type zip ` +
- `${image_dir} ${out} `,
- CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"},
- Rspfile: "${out}.copy_commands",
- RspfileContent: "${copy_commands}",
- Description: "ZipAPEX ${image_dir} => ${out}",
- }, "tool_path", "image_dir", "copy_commands", "manifest")
-
apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
blueprint.RuleParams{
Command: `${aapt2} convert --output-format proto $in -o $out`,
@@ -235,6 +224,18 @@ var (
CommandDeps: []string{"${apex_sepolicy_tests}", "${deapexer}", "${debugfs_static}"},
Description: "run apex_sepolicy_tests",
})
+
+ apexLinkerconfigValidationRule = pctx.StaticRule("apexLinkerconfigValidationRule", blueprint.RuleParams{
+ Command: `${conv_linker_config} validate --type apex ${image_dir} && touch ${out}`,
+ CommandDeps: []string{"${conv_linker_config}"},
+ Description: "run apex_linkerconfig_validation",
+ }, "image_dir")
+
+ apexVintfFragmentsValidationRule = pctx.StaticRule("apexVintfFragmentsValidationRule", blueprint.RuleParams{
+ Command: `/bin/bash -c '(shopt -s nullglob; for f in ${image_dir}/etc/vintf/*.xml; do VINTF_IGNORE_TARGET_FCM_VERSION=true ${assemble_vintf} -i "$$f" > /dev/null; done)' && touch ${out}`,
+ CommandDeps: []string{"${assemble_vintf}"},
+ Description: "run apex_vintf_validation",
+ }, "image_dir")
)
// buildManifest creates buile rules to modify the input apex_manifest.json to add information
@@ -369,21 +370,16 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output
// even though VNDK APEX is supposed to be installed on /system. (See com.android.vndk.current.on_vendor)
forceLabel = "u:object_r:vendor_apex_metadata_file:s0"
}
- switch a.properties.ApexType {
- case imageApex:
- // remove old file
- rule.Command().Text("rm").FlagWithOutput("-f ", output)
- // copy file_contexts
- rule.Command().Text("cat").Input(fileContexts).Text(">>").Output(output)
- // new line
- rule.Command().Text("echo").Text(">>").Output(output)
- if !useFileContextsAsIs {
- // force-label /apex_manifest.pb and /
- rule.Command().Text("echo").Text("/apex_manifest\\\\.pb").Text(forceLabel).Text(">>").Output(output)
- rule.Command().Text("echo").Text("/").Text(forceLabel).Text(">>").Output(output)
- }
- default:
- panic(fmt.Errorf("unsupported type %v", a.properties.ApexType))
+ // remove old file
+ rule.Command().Text("rm").FlagWithOutput("-f ", output)
+ // copy file_contexts
+ rule.Command().Text("cat").Input(fileContexts).Text(">>").Output(output)
+ // new line
+ rule.Command().Text("echo").Text(">>").Output(output)
+ if !useFileContextsAsIs {
+ // force-label /apex_manifest.pb and /
+ rule.Command().Text("echo").Text("/apex_manifest\\\\.pb").Text(forceLabel).Text(">>").Output(output)
+ rule.Command().Text("echo").Text("/").Text(forceLabel).Text(">>").Output(output)
}
rule.Build("file_contexts."+a.Name(), "Generate file_contexts")
@@ -464,8 +460,7 @@ func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android
// buildApex creates build rules to build an APEX using apexer.
func (a *apexBundle) buildApex(ctx android.ModuleContext) {
- apexType := a.properties.ApexType
- suffix := apexType.suffix()
+ suffix := imageApexSuffix
apexName := a.BaseModuleName()
////////////////////////////////////////////////////////////////////////////////////////////
@@ -604,263 +599,247 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
outHostBinDir := ctx.Config().HostToolPath(ctx, "").String()
prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin")
- if apexType == imageApex {
-
- ////////////////////////////////////////////////////////////////////////////////////
- // 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)
- implicitInputs = append(implicitInputs, cannedFsConfig)
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Step 3: Prepare option flags for apexer and invoke it to create an unsigned APEX.
- // TODO(jiyong): use the RuleBuilder
- optFlags := []string{}
+ ////////////////////////////////////////////////////////////////////////////////////
+ // 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)
+ implicitInputs = append(implicitInputs, cannedFsConfig)
- fileContexts := a.buildFileContexts(ctx)
- implicitInputs = append(implicitInputs, fileContexts)
+ ////////////////////////////////////////////////////////////////////////////////////
+ // Step 3: Prepare option flags for apexer and invoke it to create an unsigned APEX.
+ // TODO(jiyong): use the RuleBuilder
+ optFlags := []string{}
- implicitInputs = append(implicitInputs, a.privateKeyFile, a.publicKeyFile)
- optFlags = append(optFlags, "--pubkey "+a.publicKeyFile.String())
+ fileContexts := a.buildFileContexts(ctx)
+ implicitInputs = append(implicitInputs, fileContexts)
- manifestPackageName := a.getOverrideManifestPackageName(ctx)
- if manifestPackageName != "" {
- optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
- }
+ implicitInputs = append(implicitInputs, a.privateKeyFile, a.publicKeyFile)
+ optFlags = append(optFlags, "--pubkey "+a.publicKeyFile.String())
- if a.properties.AndroidManifest != nil {
- androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest))
+ manifestPackageName := a.getOverrideManifestPackageName(ctx)
+ if manifestPackageName != "" {
+ optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
+ }
- if a.testApex {
- androidManifestFile = markManifestTestOnly(ctx, androidManifestFile)
- }
+ if a.properties.AndroidManifest != nil {
+ androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest))
- implicitInputs = append(implicitInputs, androidManifestFile)
- optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String())
- } else if a.testApex {
- optFlags = append(optFlags, "--test_only")
+ if a.testApex {
+ androidManifestFile = markManifestTestOnly(ctx, androidManifestFile)
}
- // Determine target/min sdk version from the context
- // TODO(jiyong): make this as a function
- moduleMinSdkVersion := a.minSdkVersion(ctx)
- minSdkVersion := moduleMinSdkVersion.String()
+ implicitInputs = append(implicitInputs, androidManifestFile)
+ optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String())
+ } else if a.testApex {
+ optFlags = append(optFlags, "--test_only")
+ }
- // bundletool doesn't understand what "current" is. We need to transform it to
- // codename
- if moduleMinSdkVersion.IsCurrent() || moduleMinSdkVersion.IsNone() {
- minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
+ // Determine target/min sdk version from the context
+ // TODO(jiyong): make this as a function
+ moduleMinSdkVersion := a.minSdkVersion(ctx)
+ minSdkVersion := moduleMinSdkVersion.String()
- if java.UseApiFingerprint(ctx) {
- minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
- implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
- }
- }
- // apex module doesn't have a concept of target_sdk_version, hence for the time
- // being targetSdkVersion == default targetSdkVersion of the branch.
- targetSdkVersion := strconv.Itoa(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt())
+ // bundletool doesn't understand what "current" is. We need to transform it to
+ // codename
+ if moduleMinSdkVersion.IsCurrent() || moduleMinSdkVersion.IsNone() {
+ minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
if java.UseApiFingerprint(ctx) {
- targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
+ minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
}
- optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
- optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
-
- if a.overridableProperties.Logging_parent != "" {
- optFlags = append(optFlags, "--logging_parent ", a.overridableProperties.Logging_parent)
- }
-
- // Create a NOTICE file, and embed it as an asset file in the APEX.
- htmlGzNotice := android.PathForModuleOut(ctx, "NOTICE.html.gz")
- android.BuildNoticeHtmlOutputFromLicenseMetadata(
- ctx, htmlGzNotice, "", "",
- []string{
- android.PathForModuleInstall(ctx).String() + "/",
- android.PathForModuleInPartitionInstall(ctx, "apex").String() + "/",
- })
- noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
- builder := android.NewRuleBuilder(pctx, ctx)
- builder.Command().Text("cp").
- Input(htmlGzNotice).
- Output(noticeAssetPath)
- builder.Build("notice_dir", "Building notice dir")
- implicitInputs = append(implicitInputs, noticeAssetPath)
- optFlags = append(optFlags, "--assets_dir "+filepath.Dir(noticeAssetPath.String()))
-
- // Apexes which are supposed to be installed in builtin dirs(/system, etc)
- // don't need hashtree for activation. Therefore, by removing hashtree from
- // apex bundle (filesystem image in it, to be specific), we can save storage.
- needHashTree := moduleMinSdkVersion.LessThanOrEqualTo(android.SdkVersion_Android10) ||
- a.shouldGenerateHashtree()
- if ctx.Config().ApexCompressionEnabled() && a.isCompressable() {
- needHashTree = true
- }
- if !needHashTree {
- optFlags = append(optFlags, "--no_hashtree")
- }
+ }
+ // apex module doesn't have a concept of target_sdk_version, hence for the time
+ // being targetSdkVersion == default targetSdkVersion of the branch.
+ targetSdkVersion := strconv.Itoa(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt())
- if a.testOnlyShouldSkipPayloadSign() {
- optFlags = append(optFlags, "--unsigned_payload")
- }
+ if java.UseApiFingerprint(ctx) {
+ targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
+ implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
+ }
+ optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
+ optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
- if moduleMinSdkVersion == android.SdkVersion_Android10 {
- implicitInputs = append(implicitInputs, a.manifestJsonOut)
- optFlags = append(optFlags, "--manifest_json "+a.manifestJsonOut.String())
- }
+ if a.overridableProperties.Logging_parent != "" {
+ optFlags = append(optFlags, "--logging_parent ", a.overridableProperties.Logging_parent)
+ }
- optFlags = append(optFlags, "--payload_fs_type "+a.payloadFsType.string())
-
- if a.dynamic_common_lib_apex() {
- ctx.Build(pctx, android.BuildParams{
- Rule: DCLAApexRule,
- Implicits: implicitInputs,
- Output: unsignedOutputFile,
- Description: "apex (" + apexType.name() + ")",
- Args: map[string]string{
- "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
- "image_dir": imageDir.String(),
- "copy_commands": strings.Join(copyCommands, " && "),
- "manifest": a.manifestPbOut.String(),
- "file_contexts": fileContexts.String(),
- "canned_fs_config": cannedFsConfig.String(),
- "key": a.privateKeyFile.String(),
- "opt_flags": strings.Join(optFlags, " "),
- },
- })
- } else if ctx.Config().ApexTrimEnabled() && len(a.libs_to_trim(ctx)) > 0 {
- ctx.Build(pctx, android.BuildParams{
- Rule: TrimmedApexRule,
- Implicits: implicitInputs,
- Output: unsignedOutputFile,
- Description: "apex (" + apexType.name() + ")",
- Args: map[string]string{
- "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
- "image_dir": imageDir.String(),
- "copy_commands": strings.Join(copyCommands, " && "),
- "manifest": a.manifestPbOut.String(),
- "file_contexts": fileContexts.String(),
- "canned_fs_config": cannedFsConfig.String(),
- "key": a.privateKeyFile.String(),
- "opt_flags": strings.Join(optFlags, " "),
- "libs_to_trim": strings.Join(a.libs_to_trim(ctx), ","),
- },
- })
- } else {
- ctx.Build(pctx, android.BuildParams{
- Rule: apexRule,
- Implicits: implicitInputs,
- Output: unsignedOutputFile,
- Description: "apex (" + apexType.name() + ")",
- Args: map[string]string{
- "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
- "image_dir": imageDir.String(),
- "copy_commands": strings.Join(copyCommands, " && "),
- "manifest": a.manifestPbOut.String(),
- "file_contexts": fileContexts.String(),
- "canned_fs_config": cannedFsConfig.String(),
- "key": a.privateKeyFile.String(),
- "opt_flags": strings.Join(optFlags, " "),
- },
- })
- }
+ // Create a NOTICE file, and embed it as an asset file in the APEX.
+ htmlGzNotice := android.PathForModuleOut(ctx, "NOTICE.html.gz")
+ android.BuildNoticeHtmlOutputFromLicenseMetadata(
+ ctx, htmlGzNotice, "", "",
+ []string{
+ android.PathForModuleInstall(ctx).String() + "/",
+ android.PathForModuleInPartitionInstall(ctx, "apex").String() + "/",
+ })
+ noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
+ builder := android.NewRuleBuilder(pctx, ctx)
+ builder.Command().Text("cp").
+ Input(htmlGzNotice).
+ Output(noticeAssetPath)
+ builder.Build("notice_dir", "Building notice dir")
+ implicitInputs = append(implicitInputs, noticeAssetPath)
+ optFlags = append(optFlags, "--assets_dir "+filepath.Dir(noticeAssetPath.String()))
+
+ // Apexes which are supposed to be installed in builtin dirs(/system, etc)
+ // don't need hashtree for activation. Therefore, by removing hashtree from
+ // apex bundle (filesystem image in it, to be specific), we can save storage.
+ needHashTree := moduleMinSdkVersion.LessThanOrEqualTo(android.SdkVersion_Android10) ||
+ a.shouldGenerateHashtree()
+ if ctx.Config().ApexCompressionEnabled() && a.isCompressable() {
+ needHashTree = true
+ }
+ if !needHashTree {
+ optFlags = append(optFlags, "--no_hashtree")
+ }
- // TODO(jiyong): make the two rules below as separate functions
- apexProtoFile := android.PathForModuleOut(ctx, a.Name()+".pb"+suffix)
- bundleModuleFile := android.PathForModuleOut(ctx, a.Name()+suffix+"-base.zip")
- a.bundleModuleFile = bundleModuleFile
+ if a.testOnlyShouldSkipPayloadSign() {
+ optFlags = append(optFlags, "--unsigned_payload")
+ }
- ctx.Build(pctx, android.BuildParams{
- Rule: apexProtoConvertRule,
- Input: unsignedOutputFile,
- Output: apexProtoFile,
- Description: "apex proto convert",
- })
+ if moduleMinSdkVersion == android.SdkVersion_Android10 {
+ implicitInputs = append(implicitInputs, a.manifestJsonOut)
+ optFlags = append(optFlags, "--manifest_json "+a.manifestJsonOut.String())
+ }
- implicitInputs = append(implicitInputs, unsignedOutputFile)
+ optFlags = append(optFlags, "--payload_fs_type "+a.payloadFsType.string())
- // Run coverage analysis
- apisUsedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_using.txt")
+ if a.dynamic_common_lib_apex() {
ctx.Build(pctx, android.BuildParams{
- Rule: generateAPIsUsedbyApexRule,
+ Rule: DCLAApexRule,
Implicits: implicitInputs,
- Description: "coverage",
- Output: apisUsedbyOutputFile,
+ Output: unsignedOutputFile,
+ Description: "apex",
Args: map[string]string{
- "image_dir": imageDir.String(),
- "readelf": "${config.ClangBin}/llvm-readelf",
+ "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
+ "image_dir": imageDir.String(),
+ "copy_commands": strings.Join(copyCommands, " && "),
+ "manifest": a.manifestPbOut.String(),
+ "file_contexts": fileContexts.String(),
+ "canned_fs_config": cannedFsConfig.String(),
+ "key": a.privateKeyFile.String(),
+ "opt_flags": strings.Join(optFlags, " "),
},
})
- a.nativeApisUsedByModuleFile = apisUsedbyOutputFile
-
- var nativeLibNames []string
- for _, f := range a.filesInfo {
- if f.class == nativeSharedLib {
- nativeLibNames = append(nativeLibNames, f.stem())
- }
- }
- apisBackedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_backing.txt")
- rule := android.NewRuleBuilder(pctx, ctx)
- rule.Command().
- Tool(android.PathForSource(ctx, "build/soong/scripts/gen_ndk_backedby_apex.sh")).
- Output(apisBackedbyOutputFile).
- Flags(nativeLibNames)
- rule.Build("ndk_backedby_list", "Generate API libraries backed by Apex")
- a.nativeApisBackedByModuleFile = apisBackedbyOutputFile
-
- var javaLibOrApkPath []android.Path
- for _, f := range a.filesInfo {
- if f.class == javaSharedLib || f.class == app {
- javaLibOrApkPath = append(javaLibOrApkPath, f.builtFile)
- }
- }
- javaApiUsedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_using.xml")
- javaUsedByRule := android.NewRuleBuilder(pctx, ctx)
- javaUsedByRule.Command().
- Tool(android.PathForSource(ctx, "build/soong/scripts/gen_java_usedby_apex.sh")).
- BuiltTool("dexdeps").
- Output(javaApiUsedbyOutputFile).
- Inputs(javaLibOrApkPath)
- javaUsedByRule.Build("java_usedby_list", "Generate Java APIs used by Apex")
- a.javaApisUsedByModuleFile = javaApiUsedbyOutputFile
-
- bundleConfig := a.buildBundleConfig(ctx)
-
- var abis []string
- for _, target := range ctx.MultiTargets() {
- if len(target.Arch.Abi) > 0 {
- abis = append(abis, target.Arch.Abi[0])
- }
- }
-
- abis = android.FirstUniqueStrings(abis)
-
+ } else if ctx.Config().ApexTrimEnabled() && len(a.libs_to_trim(ctx)) > 0 {
ctx.Build(pctx, android.BuildParams{
- Rule: apexBundleRule,
- Input: apexProtoFile,
- Implicit: bundleConfig,
- Output: a.bundleModuleFile,
- Description: "apex bundle module",
+ Rule: TrimmedApexRule,
+ Implicits: implicitInputs,
+ Output: unsignedOutputFile,
+ Description: "apex",
Args: map[string]string{
- "abi": strings.Join(abis, "."),
- "config": bundleConfig.String(),
+ "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
+ "image_dir": imageDir.String(),
+ "copy_commands": strings.Join(copyCommands, " && "),
+ "manifest": a.manifestPbOut.String(),
+ "file_contexts": fileContexts.String(),
+ "canned_fs_config": cannedFsConfig.String(),
+ "key": a.privateKeyFile.String(),
+ "opt_flags": strings.Join(optFlags, " "),
+ "libs_to_trim": strings.Join(a.libs_to_trim(ctx), ","),
},
})
- } else { // zipApex
+ } else {
ctx.Build(pctx, android.BuildParams{
- Rule: zipApexRule,
+ Rule: apexRule,
Implicits: implicitInputs,
Output: unsignedOutputFile,
- Description: "apex (" + apexType.name() + ")",
+ Description: "apex",
Args: map[string]string{
- "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
- "image_dir": imageDir.String(),
- "copy_commands": strings.Join(copyCommands, " && "),
- "manifest": a.manifestPbOut.String(),
+ "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
+ "image_dir": imageDir.String(),
+ "copy_commands": strings.Join(copyCommands, " && "),
+ "manifest": a.manifestPbOut.String(),
+ "file_contexts": fileContexts.String(),
+ "canned_fs_config": cannedFsConfig.String(),
+ "key": a.privateKeyFile.String(),
+ "opt_flags": strings.Join(optFlags, " "),
},
})
}
+ // TODO(jiyong): make the two rules below as separate functions
+ apexProtoFile := android.PathForModuleOut(ctx, a.Name()+".pb"+suffix)
+ bundleModuleFile := android.PathForModuleOut(ctx, a.Name()+suffix+"-base.zip")
+ a.bundleModuleFile = bundleModuleFile
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexProtoConvertRule,
+ Input: unsignedOutputFile,
+ Output: apexProtoFile,
+ Description: "apex proto convert",
+ })
+
+ implicitInputs = append(implicitInputs, unsignedOutputFile)
+
+ // Run coverage analysis
+ apisUsedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_using.txt")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: generateAPIsUsedbyApexRule,
+ Implicits: implicitInputs,
+ Description: "coverage",
+ Output: apisUsedbyOutputFile,
+ Args: map[string]string{
+ "image_dir": imageDir.String(),
+ "readelf": "${config.ClangBin}/llvm-readelf",
+ },
+ })
+ a.nativeApisUsedByModuleFile = apisUsedbyOutputFile
+
+ var nativeLibNames []string
+ for _, f := range a.filesInfo {
+ if f.class == nativeSharedLib {
+ nativeLibNames = append(nativeLibNames, f.stem())
+ }
+ }
+ apisBackedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_backing.txt")
+ rb := android.NewRuleBuilder(pctx, ctx)
+ rb.Command().
+ Tool(android.PathForSource(ctx, "build/soong/scripts/gen_ndk_backedby_apex.sh")).
+ Output(apisBackedbyOutputFile).
+ Flags(nativeLibNames)
+ rb.Build("ndk_backedby_list", "Generate API libraries backed by Apex")
+ a.nativeApisBackedByModuleFile = apisBackedbyOutputFile
+
+ var javaLibOrApkPath []android.Path
+ for _, f := range a.filesInfo {
+ if f.class == javaSharedLib || f.class == app {
+ javaLibOrApkPath = append(javaLibOrApkPath, f.builtFile)
+ }
+ }
+ javaApiUsedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_using.xml")
+ javaUsedByRule := android.NewRuleBuilder(pctx, ctx)
+ javaUsedByRule.Command().
+ Tool(android.PathForSource(ctx, "build/soong/scripts/gen_java_usedby_apex.sh")).
+ BuiltTool("dexdeps").
+ Output(javaApiUsedbyOutputFile).
+ Inputs(javaLibOrApkPath)
+ javaUsedByRule.Build("java_usedby_list", "Generate Java APIs used by Apex")
+ a.javaApisUsedByModuleFile = javaApiUsedbyOutputFile
+
+ bundleConfig := a.buildBundleConfig(ctx)
+
+ var abis []string
+ for _, target := range ctx.MultiTargets() {
+ if len(target.Arch.Abi) > 0 {
+ abis = append(abis, target.Arch.Abi[0])
+ }
+ }
+
+ abis = android.FirstUniqueStrings(abis)
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexBundleRule,
+ Input: apexProtoFile,
+ Implicit: bundleConfig,
+ Output: a.bundleModuleFile,
+ Description: "apex bundle module",
+ Args: map[string]string{
+ "abi": strings.Join(abis, "."),
+ "config": bundleConfig.String(),
+ },
+ })
+
////////////////////////////////////////////////////////////////////////////////////
// Step 4: Sign the APEX using signapk
signedOutputFile := android.PathForModuleOut(ctx, a.Name()+suffix)
@@ -878,6 +857,10 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
args["outCommaList"] = signedOutputFile.String()
}
var validations android.Paths
+ validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath))
+ if !a.testApex && a.SocSpecific() {
+ validations = append(validations, runApexVintfFragmentsValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath))
+ }
// TODO(b/279688635) deapexer supports [ext4]
if suffix == imageApexSuffix && ext4 == a.payloadFsType {
validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath))
@@ -987,21 +970,12 @@ func (a *apexBundle) getOverrideManifestPackageName(ctx android.ModuleContext) s
}
func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
- if !a.primaryApexType {
- return
- }
-
if a.properties.IsCoverageVariant {
// Otherwise, we will have duplicated rules for coverage and
// non-coverage variants of the same APEX
return
}
- if ctx.Host() {
- // No need to generate dependency info for host variant
- return
- }
-
depInfos := android.DepNameToDepInfoMap{}
a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
if from.Name() == to.Name() {
@@ -1141,6 +1115,32 @@ func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.Outp
return cannedFsConfig.OutputPath
}
+func runApexLinkerconfigValidation(ctx android.ModuleContext, apexFile android.OutputPath, imageDir android.OutputPath) android.Path {
+ timestamp := android.PathForModuleOut(ctx, "apex_linkerconfig_validation.timestamp")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexLinkerconfigValidationRule,
+ Input: apexFile,
+ Output: timestamp,
+ Args: map[string]string{
+ "image_dir": imageDir.String(),
+ },
+ })
+ return timestamp
+}
+
+func runApexVintfFragmentsValidation(ctx android.ModuleContext, apexFile android.OutputPath, imageDir android.OutputPath) android.Path {
+ timestamp := android.PathForModuleOut(ctx, "apex_vintf_fragments_validation.timestamp")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexVintfFragmentsValidationRule,
+ Input: apexFile,
+ Output: timestamp,
+ Args: map[string]string{
+ "image_dir": imageDir.String(),
+ },
+ })
+ return timestamp
+}
+
// Runs apex_sepolicy_tests
//
// $ deapexer list -Z {apex_file} > {file_contexts}