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
diff --git a/tools/compliance/cmd/rtrace/rtrace.go b/tools/compliance/cmd/rtrace/rtrace.go
index 7c63979..91171c4 100644
--- a/tools/compliance/cmd/rtrace/rtrace.go
+++ b/tools/compliance/cmd/rtrace/rtrace.go
@@ -18,6 +18,7 @@
"flag"
"fmt"
"io"
+ "io/fs"
"os"
"path/filepath"
"sort"
@@ -107,7 +108,7 @@
sources: *sources,
stripPrefix: *stripPrefix,
}
- _, err := traceRestricted(ctx, os.Stdout, os.Stderr, flag.Args()...)
+ _, err := traceRestricted(ctx, os.Stdout, os.Stderr, compliance.FS, flag.Args()...)
if err != nil {
if err == failNoneRequested {
flag.Usage()
@@ -119,7 +120,7 @@
}
// traceRestricted implements the rtrace utility.
-func traceRestricted(ctx *context, stdout, stderr io.Writer, files ...string) (*compliance.LicenseGraph, error) {
+func traceRestricted(ctx *context, stdout, stderr io.Writer, rootFS fs.FS, files ...string) (*compliance.LicenseGraph, error) {
if len(files) < 1 {
return nil, failNoneRequested
}
@@ -129,7 +130,7 @@
}
// 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 nil, fmt.Errorf("Unable to read license metadata file(s) %q: %v\n", files, err)
}