|
@@ -16,6 +16,7 @@ package android
|
|
|
|
|
|
import (
|
|
|
"path/filepath"
|
|
|
+ "strings"
|
|
|
|
|
|
"github.com/google/blueprint"
|
|
|
)
|
|
@@ -101,55 +102,15 @@ func BuildNoticeOutput(ctx ModuleContext, installPath InstallPath, installFilena
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// BuildNotices merges the supplied NOTICE files into a single file that lists notices
|
|
|
-// for every key in noticeMap (which would normally be installed files).
|
|
|
-func BuildNotices(ctx ModuleContext, noticeMap map[string]Paths) NoticeOutputs {
|
|
|
- // TODO(jungjw): We should just produce a well-formatted NOTICE.html file in a single pass.
|
|
|
- //
|
|
|
- // generate-notice-files.py, which processes the merged NOTICE file, has somewhat strict rules
|
|
|
- // about input NOTICE file paths.
|
|
|
- // 1. Their relative paths to the src root become their NOTICE index titles. We want to use
|
|
|
- // on-device paths as titles, and so output the merged NOTICE file the corresponding location.
|
|
|
- // 2. They must end with .txt extension. Otherwise, they're ignored.
|
|
|
-
|
|
|
- mergeTool := PathForSource(ctx, "build/soong/scripts/mergenotice.py")
|
|
|
- generateNoticeTool := PathForSource(ctx, "build/soong/scripts/generate-notice-files.py")
|
|
|
-
|
|
|
- outputDir := PathForModuleOut(ctx, "notices")
|
|
|
- builder := NewRuleBuilder(pctx, ctx).
|
|
|
- Sbox(outputDir, PathForModuleOut(ctx, "notices.sbox.textproto"))
|
|
|
- for _, installPath := range SortedStringKeys(noticeMap) {
|
|
|
- noticePath := outputDir.Join(ctx, installPath+".txt")
|
|
|
- // It would be nice if sbox created directories for temporaries, but until then
|
|
|
- // this is simple enough.
|
|
|
- builder.Command().
|
|
|
- Text("(cd").OutputDir().Text("&&").
|
|
|
- Text("mkdir -p").Text(filepath.Dir(installPath)).Text(")")
|
|
|
- builder.Temporary(noticePath)
|
|
|
- builder.Command().
|
|
|
- Tool(mergeTool).
|
|
|
- Flag("--output").Output(noticePath).
|
|
|
- Inputs(noticeMap[installPath])
|
|
|
- }
|
|
|
-
|
|
|
- // Transform the merged NOTICE file into a gzipped HTML file.
|
|
|
- txtOutput := outputDir.Join(ctx, "NOTICE.txt")
|
|
|
- htmlOutput := outputDir.Join(ctx, "NOTICE.html")
|
|
|
- htmlGzOutput := outputDir.Join(ctx, "NOTICE.html.gz")
|
|
|
- title := "\"Notices for " + ctx.ModuleName() + "\""
|
|
|
- builder.Command().Tool(generateNoticeTool).
|
|
|
- FlagWithOutput("--text-output ", txtOutput).
|
|
|
- FlagWithOutput("--html-output ", htmlOutput).
|
|
|
- FlagWithArg("-t ", title).
|
|
|
- Flag("-s").OutputDir()
|
|
|
- builder.Command().BuiltTool("minigzip").
|
|
|
- FlagWithInput("-c ", htmlOutput).
|
|
|
- FlagWithOutput("> ", htmlGzOutput)
|
|
|
- builder.Build("build_notices", "generate notice output")
|
|
|
-
|
|
|
- return NoticeOutputs{
|
|
|
- TxtOutput: OptionalPathForPath(txtOutput),
|
|
|
- HtmlOutput: OptionalPathForPath(htmlOutput),
|
|
|
- HtmlGzOutput: OptionalPathForPath(htmlGzOutput),
|
|
|
- }
|
|
|
+// BuildNoticeTextOutputFromLicenseMetadata writes out a notice text file based on the module's
|
|
|
+// generated license metadata file.
|
|
|
+func BuildNoticeTextOutputFromLicenseMetadata(ctx ModuleContext, outputFile WritablePath) {
|
|
|
+ depsFile := outputFile.ReplaceExtension(ctx, strings.TrimPrefix(outputFile.Ext()+".d", "."))
|
|
|
+ rule := NewRuleBuilder(pctx, ctx)
|
|
|
+ rule.Command().
|
|
|
+ BuiltTool("textnotice").
|
|
|
+ FlagWithOutput("-o ", outputFile).
|
|
|
+ FlagWithDepFile("-d ", depsFile).
|
|
|
+ Input(ctx.Module().base().licenseMetadataFile)
|
|
|
+ rule.Build("container_notice", "container notice file")
|
|
|
}
|