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:
@@ -1470,7 +1470,7 @@ define xml-notice-rule
|
||||
$(1): PRIVATE_PRODUCT := $(2)
|
||||
$(1): PRIVATE_MESSAGE := $(3)
|
||||
$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
|
||||
$(XMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
|
||||
OUT_DIR=$(OUT_DIR) $(XMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
|
||||
|
||||
notice_files: $(1)
|
||||
endef
|
||||
@@ -1486,7 +1486,7 @@ define text-notice-rule
|
||||
$(1): PRIVATE_PRODUCT := $(2)
|
||||
$(1): PRIVATE_MESSAGE := $(3)
|
||||
$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
|
||||
$(TEXTNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
|
||||
OUT_DIR=$(OUT_DIR) $(TEXTNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
|
||||
|
||||
notice_files: $(1)
|
||||
endef
|
||||
@@ -1502,7 +1502,7 @@ define html-notice-rule
|
||||
$(1): PRIVATE_PRODUCT := $(2)
|
||||
$(1): PRIVATE_MESSAGE := $(3)
|
||||
$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
|
||||
$(HTMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
|
||||
OUT_DIR=$(OUT_DIR) $(HTMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
|
||||
|
||||
notice_files: $(1)
|
||||
endef
|
||||
|
@@ -585,14 +585,14 @@ $(strip $(foreach target, $(sort $(1)), \
|
||||
$(ALL_MODULES.$(target).META_LIC), \
|
||||
$(if $(strip $(ALL_TARGETS.$(target).META_LIC)), \
|
||||
$(ALL_TARGETS.$(target).META_LIC), \
|
||||
$(call license-metadata-dir)/$(target).meta_lic))))
|
||||
$(call append-path,$(call license-metadata-dir),$(patsubst $(OUT_DIR)%,out%,$(target).meta_lic))))))
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## License metadata build rule for my_register_name $(1)
|
||||
###########################################################
|
||||
define license-metadata-rule
|
||||
$(foreach meta_lic, $(ALL_MODULES.$(1).DELAYED_META_LIC),$(call _license-metadata-rule,$(1),$(meta_lic)))
|
||||
$(foreach meta_lic, $(subst //,/,$(ALL_MODULES.$(1).DELAYED_META_LIC)),$(call _license-metadata-rule,$(1),$(meta_lic)))
|
||||
$(call notice-rule,$(1))
|
||||
endef
|
||||
|
||||
@@ -632,7 +632,7 @@ $(2): $(BUILD_LICENSE_METADATA)
|
||||
$(2) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
||||
rm -f $$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$(BUILD_LICENSE_METADATA) \
|
||||
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
|
||||
$$(addprefix -mt ,$$(PRIVATE_MODULE_TYPE)) \
|
||||
$$(addprefix -mc ,$$(PRIVATE_MODULE_CLASS)) \
|
||||
$$(addprefix -k ,$$(PRIVATE_KINDS)) \
|
||||
@@ -676,6 +676,7 @@ endef
|
||||
define non-module-license-metadata-rule
|
||||
$(strip $(eval _dir := $(call license-metadata-dir)))
|
||||
$(strip $(eval _tgt := $(strip $(1))))
|
||||
$(strip $(eval _meta := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(_tgt).meta_lic))))
|
||||
$(strip $(eval _deps := $(sort $(filter-out 0p: :,$(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)),$(ALL_TARGETS.$(call word-colon,1,$(d)).META_LIC):$(call wordlist-colon,2,9999,$(d)))))))
|
||||
$(strip $(eval _notices := $(sort $(ALL_NON_MODULES.$(_tgt).NOTICES))))
|
||||
$(strip $(eval _path := $(sort $(ALL_NON_MODULES.$(_tgt).PATH))))
|
||||
@@ -688,21 +689,21 @@ $(strip \
|
||||
) \
|
||||
)
|
||||
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_KINDS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_KINDS))
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_CONDITIONS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS))
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_NOTICES := $(_notices)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_NOTICE_DEPS := $(_deps)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_SOURCES := $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_TARGETS := $(_tgt)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_PATH := $(_path)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_IS_CONTAINER := $(ALL_NON_MODULES.$(_tgt).IS_CONTAINER)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_PACKAGE_NAME := $(strip $(ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME))
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_INSTALL_MAP := $(strip $(_install_map))
|
||||
$(_dir)/$(_tgt).meta_lic: $(BUILD_LICENSE_METADATA)
|
||||
$(_dir)/$(_tgt).meta_lic : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
||||
$(_meta): PRIVATE_KINDS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_KINDS))
|
||||
$(_meta): PRIVATE_CONDITIONS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS))
|
||||
$(_meta): PRIVATE_NOTICES := $(_notices)
|
||||
$(_meta): PRIVATE_NOTICE_DEPS := $(_deps)
|
||||
$(_meta): PRIVATE_SOURCES := $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)
|
||||
$(_meta): PRIVATE_TARGETS := $(_tgt)
|
||||
$(_meta): PRIVATE_PATH := $(_path)
|
||||
$(_meta): PRIVATE_IS_CONTAINER := $(ALL_NON_MODULES.$(_tgt).IS_CONTAINER)
|
||||
$(_meta): PRIVATE_PACKAGE_NAME := $(strip $(ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME))
|
||||
$(_meta): PRIVATE_INSTALL_MAP := $(strip $(_install_map))
|
||||
$(_meta): $(BUILD_LICENSE_METADATA)
|
||||
$(_meta) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
||||
rm -f $$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$(BUILD_LICENSE_METADATA) \
|
||||
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
|
||||
-mt raw -mc unknown \
|
||||
$$(addprefix -k ,$$(PRIVATE_KINDS)) \
|
||||
$$(addprefix -c ,$$(PRIVATE_CONDITIONS)) \
|
||||
@@ -729,7 +730,7 @@ endef
|
||||
###########################################################
|
||||
define declare-license-metadata
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
||||
$(eval ALL_NON_MODULES += $(_tgt)) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
|
||||
@@ -769,7 +770,7 @@ endef
|
||||
###########################################################
|
||||
define declare-container-license-metadata
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
||||
$(eval ALL_NON_MODULES += $(_tgt)) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
|
||||
@@ -787,7 +788,7 @@ endef
|
||||
###########################################################
|
||||
define declare-0p-target
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
||||
$(eval ALL_0P_TARGETS += $(_tgt)) \
|
||||
)
|
||||
endef
|
||||
@@ -904,7 +905,7 @@ reportallnoticelibrarynames: $(_all)
|
||||
$(hide) rm -f $$(PRIVATE_LIST_FILE)
|
||||
$(hide) mkdir -p $$(dir $$(PRIVATE_LIST_FILE))
|
||||
$(hide) find out -name '*meta_lic' -type f -printf '"%p"\n' >$$(PRIVATE_LIST_FILE)
|
||||
$(COMPLIANCENOTICE_SHIPPEDLIBS) @$$(PRIVATE_LIST_FILE)
|
||||
OUT_DIR=$(OUT_DIR) $(COMPLIANCENOTICE_SHIPPEDLIBS) @$$(PRIVATE_LIST_FILE)
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
@@ -929,7 +930,7 @@ $(strip \
|
||||
$(eval ALL_TARGETS.$(t).META_LIC := 0p) \
|
||||
) \
|
||||
$(foreach t,$(sort $(ALL_NON_MODULES)), \
|
||||
$(eval ALL_TARGETS.$(t).META_LIC := $(_dir)/$(t).meta_lic) \
|
||||
$(eval ALL_TARGETS.$(t).META_LIC := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(t).meta_lic))) \
|
||||
) \
|
||||
$(foreach t,$(sort $(ALL_NON_MODULES)),$(eval $(call non-module-license-metadata-rule,$(t)))) \
|
||||
$(foreach m,$(sort $(ALL_MODULES)),$(eval $(call license-metadata-rule,$(m)))) \
|
||||
|
@@ -116,7 +116,7 @@ func main() {
|
||||
ofile = &bytes.Buffer{}
|
||||
}
|
||||
|
||||
ctx := &context{ofile, os.Stderr, os.DirFS("."), *stripPrefix}
|
||||
ctx := &context{ofile, os.Stderr, compliance.FS, *stripPrefix}
|
||||
|
||||
err := billOfMaterials(ctx, flag.Args()...)
|
||||
if err != nil {
|
||||
|
@@ -21,6 +21,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -37,6 +39,7 @@ func Test(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
stripPrefix string
|
||||
expectedOut []string
|
||||
@@ -282,7 +285,7 @@ func Test(t *testing.T) {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
|
||||
ctx := context{stdout, stderr, os.DirFS("."), []string{tt.stripPrefix}}
|
||||
ctx := context{stdout, stderr, compliance.GetFS(tt.outDir), []string{tt.stripPrefix}}
|
||||
|
||||
err := billOfMaterials(&ctx, rootFiles...)
|
||||
if err != nil {
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -68,7 +69,7 @@ func main() {
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
err := checkShare(os.Stdout, os.Stderr, flag.Args()...)
|
||||
err := checkShare(os.Stdout, os.Stderr, compliance.FS, flag.Args()...)
|
||||
if err != nil {
|
||||
if err != failConflicts {
|
||||
if err == failNoneRequested {
|
||||
@@ -82,14 +83,14 @@ func main() {
|
||||
}
|
||||
|
||||
// checkShare implements the checkshare utility.
|
||||
func checkShare(stdout, stderr io.Writer, files ...string) error {
|
||||
func checkShare(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)
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -56,6 +58,7 @@ func Test(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
expectedStdout string
|
||||
expectedOutcomes outcomeList
|
||||
@@ -248,7 +251,7 @@ func Test(t *testing.T) {
|
||||
for _, r := range tt.roots {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
err := checkShare(stdout, stderr, rootFiles...)
|
||||
err := checkShare(stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
|
||||
if err != nil && err != failConflicts {
|
||||
t.Fatalf("checkshare: error = %v, stderr = %v", err, stderr)
|
||||
return
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -36,6 +38,7 @@ func Test_plaintext(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
ctx context
|
||||
expectedOut []string
|
||||
@@ -491,7 +494,7 @@ func Test_plaintext(t *testing.T) {
|
||||
for _, r := range tt.roots {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
err := dumpGraph(&tt.ctx, stdout, stderr, rootFiles...)
|
||||
err := dumpGraph(&tt.ctx, stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
|
||||
if err != nil {
|
||||
t.Fatalf("dumpgraph: error = %v, stderr = %v", err, stderr)
|
||||
return
|
||||
@@ -583,6 +586,7 @@ func Test_graphviz(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
ctx context
|
||||
expectedOut []getMatcher
|
||||
@@ -1217,7 +1221,7 @@ func Test_graphviz(t *testing.T) {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
tt.ctx.graphViz = true
|
||||
err := dumpGraph(&tt.ctx, stdout, stderr, rootFiles...)
|
||||
err := dumpGraph(&tt.ctx, stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
|
||||
if err != nil {
|
||||
t.Fatalf("dumpgraph: error = %v, stderr = %v", err, stderr)
|
||||
return
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -110,7 +111,7 @@ func main() {
|
||||
labelConditions: *labelConditions,
|
||||
stripPrefix: *stripPrefix,
|
||||
}
|
||||
_, err := dumpResolutions(ctx, os.Stdout, os.Stderr, flag.Args()...)
|
||||
_, err := dumpResolutions(ctx, os.Stdout, os.Stderr, compliance.FS, flag.Args()...)
|
||||
if err != nil {
|
||||
if err == failNoneRequested {
|
||||
flag.Usage()
|
||||
@@ -122,13 +123,13 @@ func main() {
|
||||
}
|
||||
|
||||
// dumpResolutions implements the dumpresolutions utility.
|
||||
func dumpResolutions(ctx *context, stdout, stderr io.Writer, files ...string) (*compliance.LicenseGraph, error) {
|
||||
func dumpResolutions(ctx *context, stdout, stderr io.Writer, rootFS fs.FS, files ...string) (*compliance.LicenseGraph, error) {
|
||||
if len(files) < 1 {
|
||||
return nil, 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 nil, fmt.Errorf("Unable to read license metadata file(s) %q: %v\n", files, err)
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ func Test_plaintext(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
ctx context
|
||||
expectedOut []string
|
||||
@@ -902,7 +903,7 @@ func Test_plaintext(t *testing.T) {
|
||||
for _, r := range tt.roots {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
_, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
|
||||
_, err := dumpResolutions(&tt.ctx, stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
|
||||
if err != nil {
|
||||
t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
|
||||
return
|
||||
@@ -1011,6 +1012,7 @@ func Test_graphviz(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
ctx context
|
||||
expectedOut []getMatcher
|
||||
@@ -3298,7 +3300,7 @@ func Test_graphviz(t *testing.T) {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
tt.ctx.graphViz = true
|
||||
lg, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
|
||||
lg, err := dumpResolutions(&tt.ctx, stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
|
||||
if err != nil {
|
||||
t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
|
||||
return
|
||||
|
@@ -141,7 +141,7 @@ func main() {
|
||||
|
||||
var deps []string
|
||||
|
||||
ctx := &context{ofile, os.Stderr, os.DirFS("."), *includeTOC, *product, *stripPrefix, *title, &deps}
|
||||
ctx := &context{ofile, os.Stderr, compliance.FS, *includeTOC, *product, *stripPrefix, *title, &deps}
|
||||
|
||||
err := htmlNotice(ctx, flag.Args()...)
|
||||
if err != nil {
|
||||
|
@@ -24,6 +24,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -54,6 +56,7 @@ func Test(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
includeTOC bool
|
||||
stripPrefix string
|
||||
@@ -651,7 +654,7 @@ func Test(t *testing.T) {
|
||||
|
||||
var deps []string
|
||||
|
||||
ctx := context{stdout, stderr, os.DirFS("."), tt.includeTOC, "", []string{tt.stripPrefix}, tt.title, &deps}
|
||||
ctx := context{stdout, stderr, compliance.GetFS(tt.outDir), tt.includeTOC, "", []string{tt.stripPrefix}, tt.title, &deps}
|
||||
|
||||
err := htmlNotice(&ctx, rootFiles...)
|
||||
if err != nil {
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -54,7 +55,7 @@ func main() {
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
err := listShare(os.Stdout, os.Stderr, flag.Args()...)
|
||||
err := listShare(os.Stdout, os.Stderr, compliance.FS, flag.Args()...)
|
||||
if err != nil {
|
||||
if err == failNoneRequested {
|
||||
flag.Usage()
|
||||
@@ -66,14 +67,14 @@ func main() {
|
||||
}
|
||||
|
||||
// listShare implements the listshare utility.
|
||||
func listShare(stdout, stderr io.Writer, files ...string) error {
|
||||
func listShare(stdout, stderr io.Writer, rootFS fs.FS, files ...string) error {
|
||||
// Must be at least one root file.
|
||||
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: %v\n", files, err)
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -40,6 +42,7 @@ func Test(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
expectedOut []projectShare
|
||||
}{
|
||||
@@ -481,7 +484,7 @@ func Test(t *testing.T) {
|
||||
for _, r := range tt.roots {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
err := listShare(stdout, stderr, rootFiles...)
|
||||
err := listShare(stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
|
||||
if err != nil {
|
||||
t.Fatalf("listshare: error = %v, stderr = %v", err, stderr)
|
||||
return
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -107,7 +108,7 @@ func main() {
|
||||
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 @@ func main() {
|
||||
}
|
||||
|
||||
// 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 @@ func traceRestricted(ctx *context, stdout, stderr io.Writer, files ...string) (*
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -36,6 +38,7 @@ func Test_plaintext(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
ctx context
|
||||
expectedOut []string
|
||||
@@ -289,7 +292,7 @@ func Test_plaintext(t *testing.T) {
|
||||
if len(tt.ctx.sources) < 1 {
|
||||
tt.ctx.sources = rootFiles
|
||||
}
|
||||
_, err := traceRestricted(&tt.ctx, stdout, stderr, rootFiles...)
|
||||
_, err := traceRestricted(&tt.ctx, stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
|
||||
t.Logf("rtrace: stderr = %v", stderr)
|
||||
t.Logf("rtrace: stdout = %v", stdout)
|
||||
if err != nil {
|
||||
|
@@ -117,7 +117,7 @@ Options:
|
||||
ofile = &bytes.Buffer{}
|
||||
}
|
||||
|
||||
ctx := &context{ofile, os.Stderr, os.DirFS(".")}
|
||||
ctx := &context{ofile, os.Stderr, compliance.FS}
|
||||
|
||||
err = shippedLibs(ctx, flags.Args()...)
|
||||
if err != nil {
|
||||
|
@@ -21,6 +21,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -37,6 +39,7 @@ func Test(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
expectedOut []string
|
||||
}{
|
||||
@@ -201,7 +204,7 @@ func Test(t *testing.T) {
|
||||
rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
|
||||
}
|
||||
|
||||
ctx := context{stdout, stderr, os.DirFS(".")}
|
||||
ctx := context{stdout, stderr, compliance.GetFS(tt.outDir)}
|
||||
|
||||
err := shippedLibs(&ctx, rootFiles...)
|
||||
if err != nil {
|
||||
|
@@ -137,7 +137,7 @@ func main() {
|
||||
|
||||
var deps []string
|
||||
|
||||
ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps}
|
||||
ctx := &context{ofile, os.Stderr, compliance.FS, *product, *stripPrefix, *title, &deps}
|
||||
|
||||
err := textNotice(ctx, flag.Args()...)
|
||||
if err != nil {
|
||||
|
@@ -23,6 +23,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -43,6 +45,7 @@ func Test(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
stripPrefix string
|
||||
expectedOut []matcher
|
||||
@@ -564,7 +567,7 @@ func Test(t *testing.T) {
|
||||
|
||||
var deps []string
|
||||
|
||||
ctx := context{stdout, stderr, os.DirFS("."), "", []string{tt.stripPrefix}, "", &deps}
|
||||
ctx := context{stdout, stderr, compliance.GetFS(tt.outDir), "", []string{tt.stripPrefix}, "", &deps}
|
||||
|
||||
err := textNotice(&ctx, rootFiles...)
|
||||
if err != nil {
|
||||
|
@@ -139,7 +139,7 @@ func main() {
|
||||
|
||||
var deps []string
|
||||
|
||||
ctx := &context{ofile, os.Stderr, os.DirFS("."), *product, *stripPrefix, *title, &deps}
|
||||
ctx := &context{ofile, os.Stderr, compliance.FS, *product, *stripPrefix, *title, &deps}
|
||||
|
||||
err := xmlNotice(ctx, flag.Args()...)
|
||||
if err != nil {
|
||||
|
@@ -24,6 +24,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/tools/compliance"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -45,6 +47,7 @@ func Test(t *testing.T) {
|
||||
tests := []struct {
|
||||
condition string
|
||||
name string
|
||||
outDir string
|
||||
roots []string
|
||||
stripPrefix string
|
||||
expectedOut []matcher
|
||||
@@ -459,7 +462,7 @@ func Test(t *testing.T) {
|
||||
|
||||
var deps []string
|
||||
|
||||
ctx := context{stdout, stderr, os.DirFS("."), "", []string{tt.stripPrefix}, "", &deps}
|
||||
ctx := context{stdout, stderr, compliance.GetFS(tt.outDir), "", []string{tt.stripPrefix}, "", &deps}
|
||||
|
||||
err := xmlNotice(&ctx, rootFiles...)
|
||||
if err != nil {
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -31,6 +32,22 @@ var (
|
||||
ConcurrentReaders = 5
|
||||
)
|
||||
|
||||
type globalFS struct{}
|
||||
|
||||
func (s globalFS) Open(name string) (fs.File, error) {
|
||||
return os.Open(name)
|
||||
}
|
||||
|
||||
var FS globalFS
|
||||
|
||||
// GetFS returns a filesystem for accessing files under the OUT_DIR environment variable.
|
||||
func GetFS(outDir string) fs.FS {
|
||||
if len(outDir) > 0 {
|
||||
return os.DirFS(outDir)
|
||||
}
|
||||
return os.DirFS(".")
|
||||
}
|
||||
|
||||
// result describes the outcome of reading and parsing a single license metadata file.
|
||||
type result struct {
|
||||
// file identifies the path to the license metadata file
|
||||
|
Reference in New Issue
Block a user