mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Add shorthand package name support in jpm.
Package installation checks in the package listing if the package name is not a url. The package listsing can be specified via switch or env variable.
This commit is contained in:
		
							
								
								
									
										15
									
								
								auxbin/jpm
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								auxbin/jpm
									
									
									
									
									
								
							| @@ -565,12 +565,24 @@ int main(int argc, const char **argv) { | |||||||
|     (os/shell (string `rmdir /S /Q "` cache `"`)) |     (os/shell (string `rmdir /S /Q "` cache `"`)) | ||||||
|     (rm cache))) |     (rm cache))) | ||||||
|  |  | ||||||
|  | (def- default-pkglist (or (os/getenv "JANET_PKGLIST") "https://github.com/janet-lang/pkgs.git")) | ||||||
|  |  | ||||||
| (defn install-git | (defn install-git | ||||||
|   "Install a bundle from git. If the bundle is already installed, the bundle |   "Install a bundle from git. If the bundle is already installed, the bundle | ||||||
|   is reinistalled (but not rebuilt if artifacts are cached)." |   is reinistalled (but not rebuilt if artifacts are cached)." | ||||||
|   [repotab] |   [repotab &opt recurse] | ||||||
|   (def repo (if (string? repotab) repotab (repotab :repo))) |   (def repo (if (string? repotab) repotab (repotab :repo))) | ||||||
|   (def tag (unless (string? repotab) (repotab :tag))) |   (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)) |   (def cache (find-cache)) | ||||||
|   (os/mkdir cache) |   (os/mkdir cache) | ||||||
|   (def id (filepath-replace repo)) |   (def id (filepath-replace repo)) | ||||||
| @@ -832,6 +844,7 @@ Keys are: | |||||||
|   --compiler : C compiler to use for natives. Defaults to cc (cl on windows). |   --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). |   --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). |   --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: | Flags are: | ||||||
|   --verbose : Print shell commands as they are executed. |   --verbose : Print shell commands as they are executed. | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								jpm.1
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								jpm.1
									
									
									
									
									
								
							| @@ -64,6 +64,10 @@ to cc. | |||||||
| .BR \-\-linker=ld | .BR \-\-linker=ld | ||||||
| Sets the linker used to create native modules and executables. | 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 | .TP | ||||||
| .BR \-\-archiver=ar | .BR \-\-archiver=ar | ||||||
| Sets the command used for creating static libraries, use for linking into the standalone executable. | 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. | The --binpath=/some/path will override this variable. | ||||||
| .RE | .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 | .SH AUTHOR | ||||||
| Written by Calvin Rose <calsrose@gmail.com> | Written by Calvin Rose <calsrose@gmail.com> | ||||||
|   | |||||||
| @@ -887,10 +887,8 @@ static uint32_t peg_compile1(Builder *b, Janet peg) { | |||||||
|     JanetTable *grammar = old_grammar; |     JanetTable *grammar = old_grammar; | ||||||
|     for (; i > 0 && janet_checktype(peg, JANET_KEYWORD); --i) { |     for (; i > 0 && janet_checktype(peg, JANET_KEYWORD); --i) { | ||||||
|         peg = janet_table_get_ex(grammar, peg, &grammar); |         peg = janet_table_get_ex(grammar, peg, &grammar); | ||||||
|         if (!grammar || janet_checktype(peg, JANET_NIL)) { |         if (!grammar || janet_checktype(peg, JANET_NIL)) | ||||||
|             builder_cleanup(b); |             peg_panic(b, "unkown rule"); | ||||||
|             janet_panicf("grammar error in %p, unknown rule", b->form); |  | ||||||
|         } |  | ||||||
|         b->form = peg; |         b->form = peg; | ||||||
|         b->grammar = grammar; |         b->grammar = grammar; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose