Merge "Fix strip_prefix flags to strip install paths." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d23c863fae
@@ -15,31 +15,97 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BuildNoticeTextOutputFromLicenseMetadata writes out a notice text file based on the module's
|
func modulesOutputDirs(ctx BuilderContext, modules ...Module) []string {
|
||||||
// generated license metadata file.
|
dirs := make([]string, 0, len(modules))
|
||||||
func BuildNoticeTextOutputFromLicenseMetadata(ctx ModuleContext, outputFile WritablePath) {
|
for _, module := range modules {
|
||||||
depsFile := outputFile.ReplaceExtension(ctx, strings.TrimPrefix(outputFile.Ext()+".d", "."))
|
paths, err := outputFilesForModule(ctx, module, "")
|
||||||
rule := NewRuleBuilder(pctx, ctx)
|
if err != nil {
|
||||||
rule.Command().
|
continue
|
||||||
BuiltTool("textnotice").
|
}
|
||||||
FlagWithOutput("-o ", outputFile).
|
for _, path := range paths {
|
||||||
FlagWithDepFile("-d ", depsFile).
|
if path != nil {
|
||||||
Input(ctx.Module().base().licenseMetadataFile)
|
dirs = append(dirs, filepath.Dir(path.String()))
|
||||||
rule.Build("text_notice", "container notice file")
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SortedUniqueStrings(dirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildNoticeHtmlOutputFromLicenseMetadata writes out a notice text file based on the module's
|
func modulesLicenseMetadata(ctx BuilderContext, modules ...Module) Paths {
|
||||||
// generated license metadata file.
|
result := make(Paths, 0, len(modules))
|
||||||
func BuildNoticeHtmlOutputFromLicenseMetadata(ctx ModuleContext, outputFile WritablePath) {
|
for _, module := range modules {
|
||||||
|
if mf := module.base().licenseMetadataFile; mf != nil {
|
||||||
|
result = append(result, mf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildNoticeOutputFromLicenseMetadata writes out a notice file.
|
||||||
|
func buildNoticeOutputFromLicenseMetadata(
|
||||||
|
ctx BuilderContext, tool, ruleName string, outputFile WritablePath,
|
||||||
|
libraryName string, stripPrefix []string, modules ...Module) {
|
||||||
depsFile := outputFile.ReplaceExtension(ctx, strings.TrimPrefix(outputFile.Ext()+".d", "."))
|
depsFile := outputFile.ReplaceExtension(ctx, strings.TrimPrefix(outputFile.Ext()+".d", "."))
|
||||||
rule := NewRuleBuilder(pctx, ctx)
|
rule := NewRuleBuilder(pctx, ctx)
|
||||||
rule.Command().
|
if len(modules) == 0 {
|
||||||
BuiltTool("htmlnotice").
|
if mctx, ok := ctx.(ModuleContext); ok {
|
||||||
|
modules = []Module{mctx.Module()}
|
||||||
|
} else {
|
||||||
|
panic(fmt.Errorf("%s %q needs a module to generate the notice for", ruleName, libraryName))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if libraryName == "" {
|
||||||
|
libraryName = modules[0].Name()
|
||||||
|
}
|
||||||
|
cmd := rule.Command().
|
||||||
|
BuiltTool(tool).
|
||||||
FlagWithOutput("-o ", outputFile).
|
FlagWithOutput("-o ", outputFile).
|
||||||
FlagWithDepFile("-d ", depsFile).
|
FlagWithDepFile("-d ", depsFile)
|
||||||
Input(ctx.Module().base().licenseMetadataFile)
|
if len(stripPrefix) > 0 {
|
||||||
rule.Build("html_notice", "container notice file")
|
cmd = cmd.FlagForEachArg("--strip_prefix ", stripPrefix)
|
||||||
|
}
|
||||||
|
outputs := modulesOutputDirs(ctx, modules...)
|
||||||
|
if len(outputs) > 0 {
|
||||||
|
cmd = cmd.FlagForEachArg("--strip_prefix ", outputs)
|
||||||
|
}
|
||||||
|
if libraryName != "" {
|
||||||
|
cmd = cmd.FlagWithArg("--product ", libraryName)
|
||||||
|
}
|
||||||
|
cmd = cmd.Inputs(modulesLicenseMetadata(ctx, modules...))
|
||||||
|
rule.Build(ruleName, "container notice file")
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildNoticeTextOutputFromLicenseMetadata writes out a notice text file based
|
||||||
|
// on the license metadata files for the input `modules` defaulting to the
|
||||||
|
// current context module if none given.
|
||||||
|
func BuildNoticeTextOutputFromLicenseMetadata(
|
||||||
|
ctx BuilderContext, outputFile WritablePath, ruleName, libraryName string,
|
||||||
|
stripPrefix []string, modules ...Module) {
|
||||||
|
buildNoticeOutputFromLicenseMetadata(ctx, "textnotice", "text_notice_"+ruleName,
|
||||||
|
outputFile, libraryName, stripPrefix, modules...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildNoticeHtmlOutputFromLicenseMetadata writes out a notice text file based
|
||||||
|
// on the license metadata files for the input `modules` defaulting to the
|
||||||
|
// current context module if none given.
|
||||||
|
func BuildNoticeHtmlOutputFromLicenseMetadata(
|
||||||
|
ctx BuilderContext, outputFile WritablePath, ruleName, libraryName string,
|
||||||
|
stripPrefix []string, modules ...Module) {
|
||||||
|
buildNoticeOutputFromLicenseMetadata(ctx, "htmlnotice", "html_notice_"+ruleName,
|
||||||
|
outputFile, libraryName, stripPrefix, modules...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildNoticeXmlOutputFromLicenseMetadata writes out a notice text file based
|
||||||
|
// on the license metadata files for the input `modules` defaulting to the
|
||||||
|
// current context module if none given.
|
||||||
|
func BuildNoticeXmlOutputFromLicenseMetadata(
|
||||||
|
ctx BuilderContext, outputFile WritablePath, ruleName, libraryName string,
|
||||||
|
stripPrefix []string, modules ...Module) {
|
||||||
|
buildNoticeOutputFromLicenseMetadata(ctx, "xmlnotice", "xml_notice_"+ruleName,
|
||||||
|
outputFile, libraryName, stripPrefix, modules...)
|
||||||
}
|
}
|
||||||
|
@@ -107,6 +107,7 @@ func (s *sdkRepoHost) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
func (s *sdkRepoHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (s *sdkRepoHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
dir := android.PathForModuleOut(ctx, "zip")
|
dir := android.PathForModuleOut(ctx, "zip")
|
||||||
|
outputZipFile := dir.Join(ctx, "output.zip")
|
||||||
builder := android.NewRuleBuilder(pctx, ctx).
|
builder := android.NewRuleBuilder(pctx, ctx).
|
||||||
Sbox(dir, android.PathForModuleOut(ctx, "out.sbox.textproto")).
|
Sbox(dir, android.PathForModuleOut(ctx, "out.sbox.textproto")).
|
||||||
SandboxInputs()
|
SandboxInputs()
|
||||||
@@ -123,7 +124,12 @@ func (s *sdkRepoHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
s.CopySpecsToDir(ctx, builder, packageSpecs, dir)
|
s.CopySpecsToDir(ctx, builder, packageSpecs, dir)
|
||||||
|
|
||||||
noticeFile := android.PathForModuleOut(ctx, "NOTICES.txt")
|
noticeFile := android.PathForModuleOut(ctx, "NOTICES.txt")
|
||||||
android.BuildNoticeTextOutputFromLicenseMetadata(ctx, noticeFile)
|
android.BuildNoticeTextOutputFromLicenseMetadata(
|
||||||
|
ctx, noticeFile, "", "",
|
||||||
|
[]string{
|
||||||
|
android.PathForModuleInstall(ctx, "sdk-repo").String() + "/",
|
||||||
|
outputZipFile.String(),
|
||||||
|
})
|
||||||
builder.Command().Text("cp").
|
builder.Command().Text("cp").
|
||||||
Input(noticeFile).
|
Input(noticeFile).
|
||||||
Text(filepath.Join(dir.String(), "NOTICE.txt"))
|
Text(filepath.Join(dir.String(), "NOTICE.txt"))
|
||||||
@@ -209,7 +215,6 @@ func (s *sdkRepoHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Zip up our temporary directory as the sdk-repo
|
// Zip up our temporary directory as the sdk-repo
|
||||||
outputZipFile := dir.Join(ctx, "output.zip")
|
|
||||||
builder.Command().
|
builder.Command().
|
||||||
BuiltTool("soong_zip").
|
BuiltTool("soong_zip").
|
||||||
FlagWithOutput("-o ", outputZipFile).
|
FlagWithOutput("-o ", outputZipFile).
|
||||||
|
@@ -618,7 +618,12 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
// Create a NOTICE file, and embed it as an asset file in the APEX.
|
// Create a NOTICE file, and embed it as an asset file in the APEX.
|
||||||
a.htmlGzNotice = android.PathForModuleOut(ctx, "NOTICE.html.gz")
|
a.htmlGzNotice = android.PathForModuleOut(ctx, "NOTICE.html.gz")
|
||||||
android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, a.htmlGzNotice)
|
android.BuildNoticeHtmlOutputFromLicenseMetadata(
|
||||||
|
ctx, a.htmlGzNotice, "", "",
|
||||||
|
[]string{
|
||||||
|
android.PathForModuleInstall(ctx).String() + "/",
|
||||||
|
android.PathForModuleInPartitionInstall(ctx, "apex").String() + "/",
|
||||||
|
})
|
||||||
noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
|
noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
|
||||||
builder := android.NewRuleBuilder(pctx, ctx)
|
builder := android.NewRuleBuilder(pctx, ctx)
|
||||||
builder.Command().Text("cp").
|
builder.Command().Text("cp").
|
||||||
|
30
java/app.go
30
java/app.go
@@ -587,18 +587,6 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
a.onDeviceDir = android.InstallPathToOnDevicePath(ctx, a.installDir)
|
a.onDeviceDir = android.InstallPathToOnDevicePath(ctx, a.installDir)
|
||||||
|
|
||||||
if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
|
|
||||||
noticeFile := android.PathForModuleOut(ctx, "NOTICE.html.gz")
|
|
||||||
android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, noticeFile)
|
|
||||||
noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
|
|
||||||
builder := android.NewRuleBuilder(pctx, ctx)
|
|
||||||
builder.Command().Text("cp").
|
|
||||||
Input(noticeFile).
|
|
||||||
Output(noticeAssetPath)
|
|
||||||
builder.Build("notice_dir", "Building notice dir")
|
|
||||||
a.aapt.noticeFile = android.OptionalPathForPath(noticeAssetPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
|
a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
|
||||||
|
|
||||||
// Process all building blocks, from AAPT to certificates.
|
// Process all building blocks, from AAPT to certificates.
|
||||||
@@ -675,6 +663,24 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
|
a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
|
||||||
|
noticeFile := android.PathForModuleOut(ctx, "NOTICE.html.gz")
|
||||||
|
android.BuildNoticeHtmlOutputFromLicenseMetadata(
|
||||||
|
ctx, noticeFile, "", "",
|
||||||
|
[]string{
|
||||||
|
a.installDir.String() + "/",
|
||||||
|
android.PathForModuleInstall(ctx).String() + "/",
|
||||||
|
a.outputFile.String(),
|
||||||
|
})
|
||||||
|
noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
|
||||||
|
builder := android.NewRuleBuilder(pctx, ctx)
|
||||||
|
builder.Command().Text("cp").
|
||||||
|
Input(noticeFile).
|
||||||
|
Output(noticeAssetPath)
|
||||||
|
builder.Build("notice_dir", "Building notice dir")
|
||||||
|
a.aapt.noticeFile = android.OptionalPathForPath(noticeAssetPath)
|
||||||
|
}
|
||||||
|
|
||||||
for _, split := range a.aapt.splits {
|
for _, split := range a.aapt.splits {
|
||||||
// Sign the split APKs
|
// Sign the split APKs
|
||||||
packageFile := android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk")
|
packageFile := android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk")
|
||||||
|
Reference in New Issue
Block a user