Add support for a product name as well as title.
Bug: 68860345
Bug: 151177513
Bug: 151953481
Bug: 213388645
Bug: 210912771
Test: m all
Test: m systemlicense
Test: m htmlnotice; out/soong/host/linux-x85/htmlnotice ...
Test: m textnotice; out/soong/host/linux-x85/textnotice ...
Test: m xmlnotice; out/soong/host/linux-x85/xmlnotice ...
where ... is the path to the .meta_lic file for the system image. In my
case if
$ export PRODUCT=$(realpath $ANDROID_PRODUCT_OUT --relative-to=$PWD)
... can be expressed as:
${PRODUCT}/gen/META/lic_intermediates/${PRODUCT}/system.img.meta_lic
Change-Id: Id5b2ebe3752081e3a89bba1d717cf103f7846043
diff --git a/tools/compliance/cmd/htmlnotice/htmlnotice.go b/tools/compliance/cmd/htmlnotice/htmlnotice.go
index 938bb7d..0e3ba09 100644
--- a/tools/compliance/cmd/htmlnotice/htmlnotice.go
+++ b/tools/compliance/cmd/htmlnotice/htmlnotice.go
@@ -35,6 +35,7 @@
outputFile = flag.String("o", "-", "Where to write the NOTICE text file. (default stdout)")
depsFile = flag.String("d", "", "Where to write the deps file")
includeTOC = flag.Bool("toc", true, "Whether to include a table of contents.")
+ product = flag.String("product", "", "The name of the product for which the notice is generated.")
stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)")
title = flag.String("title", "", "The title of the notice file.")
@@ -47,6 +48,7 @@
stderr io.Writer
rootFS fs.FS
includeTOC bool
+ product string
stripPrefix []string
title string
deps *[]string
@@ -57,7 +59,7 @@
if strings.HasPrefix(installPath, prefix) {
p := strings.TrimPrefix(installPath, prefix)
if 0 == len(p) {
- p = ctx.title
+ p = ctx.product
}
if 0 == len(p) {
continue
@@ -139,7 +141,7 @@
var deps []string
- ctx := &context{ofile, os.Stderr, os.DirFS("."), *includeTOC, *stripPrefix, *title, &deps}
+ ctx := &context{ofile, os.Stderr, os.DirFS("."), *includeTOC, *product, *stripPrefix, *title, &deps}
err := htmlNotice(ctx, flag.Args()...)
if err != nil {
@@ -204,12 +206,16 @@
fmt.Fprintln(ctx.stdout, "</style>")
if 0 < len(ctx.title) {
fmt.Fprintf(ctx.stdout, "<title>%s</title>\n", html.EscapeString(ctx.title))
+ } else if 0 < len(ctx.product) {
+ fmt.Fprintf(ctx.stdout, "<title>%s</title>\n", html.EscapeString(ctx.product))
}
fmt.Fprintln(ctx.stdout, "</head>")
fmt.Fprintln(ctx.stdout, "<body>")
if 0 < len(ctx.title) {
fmt.Fprintf(ctx.stdout, " <h1>%s</h1>\n", html.EscapeString(ctx.title))
+ } else if 0 < len(ctx.product) {
+ fmt.Fprintf(ctx.stdout, " <h1>%s</h1>\n", html.EscapeString(ctx.product))
}
ids := make(map[string]string)
if ctx.includeTOC {
diff --git a/tools/compliance/cmd/htmlnotice/htmlnotice_test.go b/tools/compliance/cmd/htmlnotice/htmlnotice_test.go
index 9863b6d..b8bc47f 100644
--- a/tools/compliance/cmd/htmlnotice/htmlnotice_test.go
+++ b/tools/compliance/cmd/htmlnotice/htmlnotice_test.go
@@ -651,7 +651,7 @@
var deps []string
- ctx := context{stdout, stderr, os.DirFS("."), tt.includeTOC, []string{tt.stripPrefix}, tt.title, &deps}
+ ctx := context{stdout, stderr, os.DirFS("."), tt.includeTOC, "", []string{tt.stripPrefix}, tt.title, &deps}
err := htmlNotice(&ctx, rootFiles...)
if err != nil {
diff --git a/tools/compliance/cmd/textnotice/textnotice.go b/tools/compliance/cmd/textnotice/textnotice.go
index 35c5c24..9e9229f 100644
--- a/tools/compliance/cmd/textnotice/textnotice.go
+++ b/tools/compliance/cmd/textnotice/textnotice.go
@@ -33,6 +33,7 @@
var (
outputFile = flag.String("o", "-", "Where to write the NOTICE text file. (default stdout)")
depsFile = flag.String("d", "", "Where to write the deps file")
+ product = flag.String("product", "", "The name of the product for which the notice is generated.")
stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)")
title = flag.String("title", "", "The title of the notice file.")
@@ -44,6 +45,7 @@
stdout io.Writer
stderr io.Writer
rootFS fs.FS
+ product string
stripPrefix []string
title string
deps *[]string
@@ -54,7 +56,7 @@
if strings.HasPrefix(installPath, prefix) {
p := strings.TrimPrefix(installPath, prefix)
if 0 == len(p) {
- p = ctx.title
+ p = ctx.product
}
if 0 == len(p) {
continue
@@ -135,7 +137,7 @@
var deps []string
- ctx := &context{ofile, os.Stderr, os.DirFS("."), *stripPrefix, *title, &deps}
+ ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps}
err := textNotice(ctx, flag.Args()...)
if err != nil {
@@ -190,6 +192,9 @@
return fmt.Errorf("Unable to read license text file(s) for %q: %v\n", files, err)
}
+ if 0 < len(ctx.title) {
+ fmt.Fprintf(ctx.stdout, "%s\n\n", ctx.title)
+ }
for h := range ni.Hashes() {
fmt.Fprintln(ctx.stdout, "==============================================================================")
for _, libName := range ni.HashLibs(h) {
diff --git a/tools/compliance/cmd/textnotice/textnotice_test.go b/tools/compliance/cmd/textnotice/textnotice_test.go
index 0ed3394..9d8d0ca 100644
--- a/tools/compliance/cmd/textnotice/textnotice_test.go
+++ b/tools/compliance/cmd/textnotice/textnotice_test.go
@@ -564,7 +564,7 @@
var deps []string
- ctx := context{stdout, stderr, os.DirFS("."), []string{tt.stripPrefix}, "", &deps}
+ ctx := context{stdout, stderr, os.DirFS("."), "", []string{tt.stripPrefix}, "", &deps}
err := textNotice(&ctx, rootFiles...)
if err != nil {
diff --git a/tools/compliance/cmd/xmlnotice/xmlnotice.go b/tools/compliance/cmd/xmlnotice/xmlnotice.go
index eb169f3..1c712cb 100644
--- a/tools/compliance/cmd/xmlnotice/xmlnotice.go
+++ b/tools/compliance/cmd/xmlnotice/xmlnotice.go
@@ -34,6 +34,7 @@
var (
outputFile = flag.String("o", "-", "Where to write the NOTICE xml or xml.gz file. (default stdout)")
depsFile = flag.String("d", "", "Where to write the deps file")
+ product = flag.String("product", "", "The name of the product for which the notice is generated.")
stripPrefix = newMultiString("strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)")
title = flag.String("title", "", "The title of the notice file.")
@@ -45,6 +46,7 @@
stdout io.Writer
stderr io.Writer
rootFS fs.FS
+ product string
stripPrefix []string
title string
deps *[]string
@@ -55,7 +57,7 @@
if strings.HasPrefix(installPath, prefix) {
p := strings.TrimPrefix(installPath, prefix)
if 0 == len(p) {
- p = ctx.title
+ p = ctx.product
}
if 0 == len(p) {
continue
@@ -137,7 +139,7 @@
var deps []string
- ctx := &context{ofile, os.Stderr, os.DirFS("."), *stripPrefix, *title, &deps}
+ ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps}
err := xmlNotice(ctx, flag.Args()...)
if err != nil {
diff --git a/tools/compliance/cmd/xmlnotice/xmlnotice_test.go b/tools/compliance/cmd/xmlnotice/xmlnotice_test.go
index 3a62438..424c95e 100644
--- a/tools/compliance/cmd/xmlnotice/xmlnotice_test.go
+++ b/tools/compliance/cmd/xmlnotice/xmlnotice_test.go
@@ -459,7 +459,7 @@
var deps []string
- ctx := context{stdout, stderr, os.DirFS("."), []string{tt.stripPrefix}, "", &deps}
+ ctx := context{stdout, stderr, os.DirFS("."), "", []string{tt.stripPrefix}, "", &deps}
err := xmlNotice(&ctx, rootFiles...)
if err != nil {