-
Notifications
You must be signed in to change notification settings - Fork 10
Add support for GLJPATH environment variable #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
To avoid adding things that are often lying around... The .clj and .glj are to ignore top level scripts for testing stuff. The GNUmakefile and .cache are for alternate Makefile stuff like I do in glojurelang#75 If that doesn't get merged I can just symlink to it since GNUmakefile has precedence over Makefile (for GNU make).
jfhamlin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding the GLJPATH support! left a few comments, mainly on command line parsing and the command line interface
test/glojure/test_glojure/cli.glj
Outdated
| (let [lib1-dir (str (os.Getenv "PWD") "/test_gljpath_priority1") | ||
| lib2-dir (str (os.Getenv "PWD") "/test_gljpath_priority2") | ||
| lib3-dir (str (os.Getenv "PWD") "/test_gljpath_priority3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love that we're testing the edge case here! re test directory, i think it'd be preferable to use a temp directory rather than the working directory. os.TempDir will return the path to use for temporary files on the current platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f4fd0ac
| // parseArgs parses command line arguments and returns an Args struct | ||
| func parseArgs(args []string) (*Args, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i should have called this out in the prior command line flag PR, but as this is getting more involved, let's use the standard library's flag parsing: https://pkg.go.dev/flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8a21eeb
pkg/gljmain/gljmain.go
Outdated
| // Process -I include paths last (add to front of load path, highest priority) | ||
| // Process in reverse order so first -I on command line gets highest priority |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems duplicative with GLJPATH, and "include" evokes C/C++ — i'm not sure the -I command line flag makes sense for clojure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8a21eeb
| for i := len(paths) - 1; i >= 0; i-- { | ||
| path := paths[i] | ||
| if path != "" { | ||
| // Skip non-existent path directories | ||
| if _, err := os.Stat(path); err == nil { | ||
| runtime.AddLoadPath(os.DirFS(path), true) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we could drop the true second arg and start iterating from index 0 to get the same result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all makes sense. I'll update in the morning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want . at the very end of the loadpath (which is what you had).
It seems like there is 1 other entry in the loadpath when we start adding things here, but I was unable to print its value.
The other things need to be added to the front of the loadpath as I'm doing.
I'll refactor to make 2 funcs: AddLoadPath (same as original) and PrependLoadPath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in e5b9a64
$ GLJPATH=foo:bar ./bin/linux_amd64/glj -e '*glojure-load-path*'
("foo" "bar" "<StdLib>" ".")
|
I added a commit to support a Seems useful: c3eb307 |
|
Closing this and revisiting the concept in #123 |
For runtime loading of
.gljfiles.Note: this PR includes #88 commits so that one should probably be sorted first.
I can adjust this one to any changes you want there.