Add option to specify module search paths manually
This commit is contained in:
parent
2caed5b4ae
commit
76615df4d4
|
@ -47,6 +47,13 @@ func main () {
|
||||||
'O', "optimization",
|
'O', "optimization",
|
||||||
"Optimization level (0-3)", "0",
|
"Optimization level (0-3)", "0",
|
||||||
cli.NewValSet("0", "1", "2", "3"))
|
cli.NewValSet("0", "1", "2", "3"))
|
||||||
|
includePath := cli.NewInputFlag (
|
||||||
|
'u', "unit-directory",
|
||||||
|
"Extra directory(s) to search for units in", "",
|
||||||
|
cli.ValString)
|
||||||
|
includePath.Found = func (application *cli.Cli, value string) {
|
||||||
|
comp.Resolver.AddPathFront(value)
|
||||||
|
}
|
||||||
|
|
||||||
application := cli.New (
|
application := cli.New (
|
||||||
"Compile FSPL source files",
|
"Compile FSPL source files",
|
||||||
|
@ -55,7 +62,8 @@ func main () {
|
||||||
quiet,
|
quiet,
|
||||||
filetype,
|
filetype,
|
||||||
output,
|
output,
|
||||||
optimization)
|
optimization,
|
||||||
|
includePath)
|
||||||
|
|
||||||
application.Syntax = "[OPTION]... ADDRESS"
|
application.Syntax = "[OPTION]... ADDRESS"
|
||||||
application.ParseOrExit(os.Args)
|
application.ParseOrExit(os.Args)
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (resolver *Resolver) AddPathFront (path ...string) {
|
||||||
// - If the address starts with '/', it is treated as an absolute path from
|
// - If the address starts with '/', it is treated as an absolute path from
|
||||||
// the fs root
|
// the fs root
|
||||||
// - Else, the address is searched for in the resolver's paths
|
// - Else, the address is searched for in the resolver's paths
|
||||||
func (resolver Resolver) Resolve (context string, address entity.Address) (string, error) {
|
func (resolver *Resolver) Resolve (context string, address entity.Address) (string, error) {
|
||||||
strAddr := string(address)
|
strAddr := string(address)
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(strAddr, "."):
|
case strings.HasPrefix(strAddr, "."):
|
||||||
|
@ -71,7 +71,7 @@ func (resolver Resolver) Resolve (context string, address entity.Address) (strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resolver Resolver) search (needle string) (string, error) {
|
func (resolver *Resolver) search (needle string) (string, error) {
|
||||||
for _, dirPath := range resolver.Path {
|
for _, dirPath := range resolver.Path {
|
||||||
// attempt to open the file as dir.
|
// attempt to open the file as dir.
|
||||||
// if we can't open the dir, just skip it, because it is
|
// if we can't open the dir, just skip it, because it is
|
||||||
|
@ -98,7 +98,7 @@ func (resolver Resolver) search (needle string) (string, error) {
|
||||||
|
|
||||||
// ResolveCwd resolves the address within the context of the current working
|
// ResolveCwd resolves the address within the context of the current working
|
||||||
// directory.
|
// directory.
|
||||||
func (resolver Resolver) ResolveCwd (address entity.Address) (string, error) {
|
func (resolver *Resolver) ResolveCwd (address entity.Address) (string, error) {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil { return "", err }
|
if err != nil { return "", err }
|
||||||
return resolver.Resolve(wd, address)
|
return resolver.Resolve(wd, address)
|
||||||
|
|
Loading…
Reference in New Issue