Support OUT_DIR for license graph.

Bug: 226066987

Test: OUT_DIR=/tmp/outdir m all listshare checkshare htmlnotice rtrace dumpgraph dumpresolutions compliancenotice_bom compliancenotice_shippedlibs
Test: OUT_DIR=/tmp/outdir m /tmp/outdir/target/product/bonito/obj/NOTICE.xml.gz
Test: m all listshare checkshare htmlnotice rtrace dumpgraph dumpresolutions compliancenotice_bom compliancenotice_shippedlibs
Test: m out/target/product/bonito/obj/NOTICE.xml.gz

Change-Id: I6282c647a389c5935d5ce7c79193f86d32c76365
This commit is contained in:
Bob Badour
2022-03-22 13:05:19 -07:00
parent fb042449e0
commit c778e4cba4
23 changed files with 109 additions and 56 deletions

View File

@@ -18,6 +18,7 @@ import (
"flag"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"sort"
@@ -97,7 +98,7 @@ func main() {
ctx := &context{*graphViz, *labelConditions, *stripPrefix}
err := dumpGraph(ctx, os.Stdout, os.Stderr, flag.Args()...)
err := dumpGraph(ctx, os.Stdout, os.Stderr, compliance.FS, flag.Args()...)
if err != nil {
if err == failNoneRequested {
flag.Usage()
@@ -109,13 +110,13 @@ func main() {
}
// dumpGraph implements the dumpgraph utility.
func dumpGraph(ctx *context, stdout, stderr io.Writer, files ...string) error {
func dumpGraph(ctx *context, stdout, stderr io.Writer, rootFS fs.FS, files ...string) error {
if len(files) < 1 {
return failNoneRequested
}
// Read the license graph from the license metadata files (*.meta_lic).
licenseGraph, err := compliance.ReadLicenseGraph(os.DirFS("."), stderr, files)
licenseGraph, err := compliance.ReadLicenseGraph(rootFS, stderr, files)
if err != nil {
return fmt.Errorf("Unable to read license metadata file(s) %q: %w\n", files, err)
}