diff --git a/auxbin/jpm b/auxbin/jpm index 120632eb..c168cc9e 100755 --- a/auxbin/jpm +++ b/auxbin/jpm @@ -565,12 +565,24 @@ int main(int argc, const char **argv) { (os/shell (string `rmdir /S /Q "` cache `"`)) (rm cache))) +(def- default-pkglist (or (os/getenv "JANET_PKGLIST") "https://github.com/janet-lang/pkgs.git")) + (defn install-git "Install a bundle from git. If the bundle is already installed, the bundle is reinistalled (but not rebuilt if artifacts are cached)." - [repotab] + [repotab &opt recurse] (def repo (if (string? repotab) repotab (repotab :repo))) (def tag (unless (string? repotab) (repotab :tag))) + # prevent infinite recursion (very unlikely, but consider + # 'my-package "my-package" in the package listing) + (when (> (or recurse 0) 100) + (error "too many references resolving package url")) + # Handle short names + (unless (string/find ":" repo) + (install-git (dyn :pkglist default-pkglist)) + (def pkgs (require "pkgs")) + (break (install-git (get-in pkgs ['packages :value (symbol repo)]) + (if recurse (inc recurse) 0)))) (def cache (find-cache)) (os/mkdir cache) (def id (filepath-replace repo)) @@ -832,6 +844,7 @@ Keys are: --compiler : C compiler to use for natives. Defaults to cc (cl on windows). --archiver : C compiler to use for static libraries. Defaults to ar (lib on windows). --linker : C linker to use for linking natives. Defaults to cc (link on windows). + --pkglist : URL of git repository for package listing. Defaults to $JANET_PKGLIST or https://github.com/janet-lang/pkgs.git Flags are: --verbose : Print shell commands as they are executed. diff --git a/jpm.1 b/jpm.1 index 34a0ce83..6ea9216f 100644 --- a/jpm.1 +++ b/jpm.1 @@ -64,6 +64,10 @@ to cc. .BR \-\-linker=ld Sets the linker used to create native modules and executables. +.TP +.BR \-\-pkglist=https://github.com/janet-lang/pkgs.git +Sets the git repository for the package listing used to resolve shorthand package names. + .TP .BR \-\-archiver=ar Sets the command used for creating static libraries, use for linking into the standalone executable. @@ -172,5 +176,11 @@ Defaults to The --binpath=/some/path will override this variable. .RE +.B JANET_PKGLIST +.RS +The git repository URL that contains a listing of packages. This allows installing packages with shortnames, which +is mostly a convenience. However, package dependencies can use short names, package listings +can be used to choose a particular set of dependency versions for a whole project. + .SH AUTHOR Written by Calvin Rose diff --git a/src/core/peg.c b/src/core/peg.c index db4ede53..060e25b8 100644 --- a/src/core/peg.c +++ b/src/core/peg.c @@ -887,10 +887,8 @@ static uint32_t peg_compile1(Builder *b, Janet peg) { JanetTable *grammar = old_grammar; for (; i > 0 && janet_checktype(peg, JANET_KEYWORD); --i) { peg = janet_table_get_ex(grammar, peg, &grammar); - if (!grammar || janet_checktype(peg, JANET_NIL)) { - builder_cleanup(b); - janet_panicf("grammar error in %p, unknown rule", b->form); - } + if (!grammar || janet_checktype(peg, JANET_NIL)) + peg_panic(b, "unkown rule"); b->form = peg; b->grammar = grammar; }