1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 02:59:54 +00:00

Add JANET_GIT to jpm.

This should allow work arounds for some windows installs.
Also, be clever about finding the location of te current git
executable on windows to avoid some path issues that seem to
occur on some windows installations.
This commit is contained in:
Calvin Rose 2020-05-19 18:36:58 -04:00
parent ccd8b71c4b
commit b72845609f
4 changed files with 25 additions and 6 deletions

View File

@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.
## Unreleased - ???
- Add JANET_GIT environment variable to jpm to use a specific git binary (useful mainly on windows).
- `asm` and `disasm` functions now use keywords instead of macros for keys. Also
some slight changes to the way constants are encoded (remove wrapping `quote` in some cases).
- Expose current macro form inside macros as (dyn :macro-form)

23
jpm
View File

@ -647,6 +647,19 @@ int main(int argc, const char **argv) {
# Installation and Dependencies
#
(var- stored-git-path nil)
(defn- git-path
"Get the location of git such that it can be passed as an argument to os/execute."
"(Some builds/configurations of windows don't like just the string 'git')"
[]
(if stored-git-path (break stored-git-path))
(set stored-git-path
(if is-win
(or (os/getenv "JANET_GIT") (pslurp "where git"))
(os/getenv "JANET_GIT" "git"))))
(if is-win (pslurp "where git") "git"))
(defn uninstall
"Uninstall bundle named name"
[name]
@ -707,11 +720,11 @@ int main(int argc, const char **argv) {
:binpath (abspath (dyn :binpath JANET_BINPATH))]
(os/cd module-dir)
(unless fresh
(os/execute ["git" "pull" "origin" "master"] :p))
(os/execute [(git-path) "pull" "origin" "master"] :p))
(when tag
(os/execute ["git" "reset" "--hard" tag] :p))
(os/execute [(git-path) "reset" "--hard" tag] :p))
(unless (dyn :offline)
(os/execute ["git" "submodule" "update" "--init" "--recursive"] :p))
(os/execute [(git-path) "submodule" "update" "--init" "--recursive"] :p))
(import-rules "./project.janet")
(unless no-deps (do-rule "install-deps"))
(do-rule "build")
@ -955,8 +968,8 @@ int main(int argc, const char **argv) {
(phony "manifest" []
(print "generating " manifest "...")
(mkdir manifests)
(def sha (pslurp "git rev-parse HEAD"))
(def url (pslurp "git remote get-url origin"))
(def sha (pslurp (string "\"" (git-path) "\" rev-parse HEAD")))
(def url (pslurp (string "\"" (git-path) "\" remote get-url origin"))
(def man
{:sha (if-not (empty? sha) sha)
:repo (if-not (empty? url) url)

5
jpm.1
View File

@ -237,5 +237,10 @@ The git repository URL that contains a listing of packages. This allows installi
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.
.B JANET_GIT
.RS
An optional path to a git executable to use to clone git dependencies. By default, uses "git" on the current $PATH. You shouldn't need to set this
if you have a normal install of git.
.SH AUTHOR
Written by Calvin Rose <calsrose@gmail.com>

View File

@ -339,7 +339,7 @@ static Janet os_execute(int32_t argc, Janet *argv) {
JanetBuffer *buf = os_exec_escape(exargs);
if (buf->count > 8191) {
janet_panic("command line string too long");
janet_panic("command line string too long (max 8191 characters)");
}
const char *path = (const char *) janet_unwrap_string(exargs.items[0]);
char *cargv[2] = {(char *) buf->data, NULL};