about summary refs log tree commit diff
path: root/external
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-12T22·58+0000
committerVincent Ambo <mail@tazj.in>2019-12-13T00·39+0000
commitbbf3a418a5a119e2ab6aaaf1e04f42caa1b683a8 (patch)
tree05adc65bda71f963918d0f5038c52e0d0e7e874f /external
parent1fd80fb20175c28bc500e6d889594d1a5ebb6be7 (diff)
feat(external): Add fully qualified import path to analyser output
This is used by Nix to build the derivation names for individual
packages.
Diffstat (limited to 'external')
-rw-r--r--external/main.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/external/main.go b/external/main.go
index 028703e38cad..aac966172b34 100644
--- a/external/main.go
+++ b/external/main.go
@@ -29,7 +29,8 @@ var stdlibList string
 // Return information includes the local (relative from project root)
 // and external (none-stdlib) dependencies of this package.
 type pkg struct {
-	Name        []string   `json:"name"`
+	Name        string     `json:"name"`
+	Locator     []string   `json:"locator"`
 	Files       []string   `json:"files"`
 	LocalDeps   [][]string `json:"localDeps"`
 	ForeignDeps []string   `json:"foreignDeps"`
@@ -95,12 +96,12 @@ func analysePackage(root, source, importpath string, stdlib map[string]bool) (pk
 
 	prefix := strings.TrimPrefix(source, root+"/")
 
-	name := []string{}
+	locator := []string{}
 	if len(prefix) != len(source) {
-		name = strings.Split(prefix, "/")
+		locator = strings.Split(prefix, "/")
 	} else {
-		// Otherwise, the name is empty since its the root package and no
-		// prefix should be added to files.
+		// Otherwise, the locator is empty since its the root package and
+		// no prefix should be added to files.
 		prefix = ""
 	}
 
@@ -110,7 +111,8 @@ func analysePackage(root, source, importpath string, stdlib map[string]bool) (pk
 	}
 
 	return pkg{
-		Name:        name,
+		Name:        path.Join(importpath, prefix),
+		Locator:     locator,
 		Files:       files,
 		LocalDeps:   local,
 		ForeignDeps: foreign,