Merge changes from topic "apex-elf-checker" into main am: a19c9141aa
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2817254 Change-Id: I9684c763a617df22a0ab45d1b370d6926099972f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
492abae6c7
2 changed files with 48 additions and 0 deletions
|
@ -61,17 +61,39 @@ func JoinWithPrefix(strs []string, prefix string) string {
|
||||||
// JoinWithPrefixAndSeparator prepends the prefix to each string in the list and
|
// JoinWithPrefixAndSeparator prepends the prefix to each string in the list and
|
||||||
// returns them joined together with the given separator.
|
// returns them joined together with the given separator.
|
||||||
func JoinWithPrefixAndSeparator(strs []string, prefix string, sep string) string {
|
func JoinWithPrefixAndSeparator(strs []string, prefix string, sep string) string {
|
||||||
|
return JoinWithPrefixSuffixAndSeparator(strs, prefix, "", sep)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JoinWithSuffixAndSeparator appends the suffix to each string in the list and
|
||||||
|
// returns them joined together with the given separator.
|
||||||
|
func JoinWithSuffixAndSeparator(strs []string, suffix string, sep string) string {
|
||||||
|
return JoinWithPrefixSuffixAndSeparator(strs, "", suffix, sep)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JoinWithPrefixSuffixAndSeparator appends the prefix/suffix to each string in the list and
|
||||||
|
// returns them joined together with the given separator.
|
||||||
|
func JoinWithPrefixSuffixAndSeparator(strs []string, prefix, suffix, sep string) string {
|
||||||
if len(strs) == 0 {
|
if len(strs) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pre-calculate the length of the result
|
||||||
|
length := 0
|
||||||
|
for _, s := range strs {
|
||||||
|
length += len(s)
|
||||||
|
}
|
||||||
|
length += (len(prefix)+len(suffix))*len(strs) + len(sep)*(len(strs)-1)
|
||||||
|
|
||||||
var buf strings.Builder
|
var buf strings.Builder
|
||||||
|
buf.Grow(length)
|
||||||
buf.WriteString(prefix)
|
buf.WriteString(prefix)
|
||||||
buf.WriteString(strs[0])
|
buf.WriteString(strs[0])
|
||||||
|
buf.WriteString(suffix)
|
||||||
for i := 1; i < len(strs); i++ {
|
for i := 1; i < len(strs); i++ {
|
||||||
buf.WriteString(sep)
|
buf.WriteString(sep)
|
||||||
buf.WriteString(prefix)
|
buf.WriteString(prefix)
|
||||||
buf.WriteString(strs[i])
|
buf.WriteString(strs[i])
|
||||||
|
buf.WriteString(suffix)
|
||||||
}
|
}
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,11 @@ func init() {
|
||||||
pctx.HostBinToolVariable("apex_sepolicy_tests", "apex_sepolicy_tests")
|
pctx.HostBinToolVariable("apex_sepolicy_tests", "apex_sepolicy_tests")
|
||||||
pctx.HostBinToolVariable("deapexer", "deapexer")
|
pctx.HostBinToolVariable("deapexer", "deapexer")
|
||||||
pctx.HostBinToolVariable("debugfs_static", "debugfs_static")
|
pctx.HostBinToolVariable("debugfs_static", "debugfs_static")
|
||||||
|
pctx.HostBinToolVariable("fsck_erofs", "fsck.erofs")
|
||||||
pctx.SourcePathVariable("genNdkUsedbyApexPath", "build/soong/scripts/gen_ndk_usedby_apex.sh")
|
pctx.SourcePathVariable("genNdkUsedbyApexPath", "build/soong/scripts/gen_ndk_usedby_apex.sh")
|
||||||
pctx.HostBinToolVariable("conv_linker_config", "conv_linker_config")
|
pctx.HostBinToolVariable("conv_linker_config", "conv_linker_config")
|
||||||
pctx.HostBinToolVariable("assemble_vintf", "assemble_vintf")
|
pctx.HostBinToolVariable("assemble_vintf", "assemble_vintf")
|
||||||
|
pctx.HostBinToolVariable("apex_elf_checker", "apex_elf_checker")
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -237,6 +239,12 @@ var (
|
||||||
CommandDeps: []string{"${assemble_vintf}"},
|
CommandDeps: []string{"${assemble_vintf}"},
|
||||||
Description: "run assemble_vintf",
|
Description: "run assemble_vintf",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
apexElfCheckerUnwantedRule = pctx.StaticRule("apexElfCheckerUnwantedRule", blueprint.RuleParams{
|
||||||
|
Command: `${apex_elf_checker} --tool_path ${tool_path} --unwanted ${unwanted} ${in} && touch ${out}`,
|
||||||
|
CommandDeps: []string{"${apex_elf_checker}", "${deapexer}", "${debugfs_static}", "${fsck_erofs}", "${config.ClangBin}/llvm-readelf"},
|
||||||
|
Description: "run apex_elf_checker --unwanted",
|
||||||
|
}, "tool_path", "unwanted")
|
||||||
)
|
)
|
||||||
|
|
||||||
// buildManifest creates buile rules to modify the input apex_manifest.json to add information
|
// buildManifest creates buile rules to modify the input apex_manifest.json to add information
|
||||||
|
@ -886,6 +894,10 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
|
||||||
if suffix == imageApexSuffix && ext4 == a.payloadFsType {
|
if suffix == imageApexSuffix && ext4 == a.payloadFsType {
|
||||||
validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath))
|
validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath))
|
||||||
}
|
}
|
||||||
|
if !a.testApex && len(a.properties.Unwanted_transitive_deps) > 0 {
|
||||||
|
validations = append(validations,
|
||||||
|
runApexElfCheckerUnwanted(ctx, unsignedOutputFile.OutputPath, a.properties.Unwanted_transitive_deps))
|
||||||
|
}
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: rule,
|
Rule: rule,
|
||||||
Description: "signapk",
|
Description: "signapk",
|
||||||
|
@ -1164,3 +1176,17 @@ func runApexSepolicyTests(ctx android.ModuleContext, apexFile android.OutputPath
|
||||||
})
|
})
|
||||||
return timestamp
|
return timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runApexElfCheckerUnwanted(ctx android.ModuleContext, apexFile android.OutputPath, unwanted []string) android.Path {
|
||||||
|
timestamp := android.PathForModuleOut(ctx, "apex_elf_unwanted.timestamp")
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: apexElfCheckerUnwantedRule,
|
||||||
|
Input: apexFile,
|
||||||
|
Output: timestamp,
|
||||||
|
Args: map[string]string{
|
||||||
|
"unwanted": android.JoinWithSuffixAndSeparator(unwanted, ".so", ":"),
|
||||||
|
"tool_path": ctx.Config().HostToolPath(ctx, "").String() + ":${config.ClangBin}",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return timestamp
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue