mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 08:30:26 +00:00
Add the quickbin command to jpm.
This is useful for making one off executable scripts without needing to set up a project.janet file.
This commit is contained in:
parent
03824dd9f7
commit
cf19cd5292
@ -2,6 +2,7 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## Unreleased
|
||||
- Add the `quickbin` command to jpm.
|
||||
- Create shell.c when making the amlagamated source. This can be compiled with
|
||||
janet.c to make the janet interpreter.
|
||||
- Add `cli-main` function to the core, which invokes Janet's CLI interface.
|
||||
|
2
Makefile
2
Makefile
@ -346,6 +346,8 @@ test-install:
|
||||
&& jpm --verbose build \
|
||||
&& jpm --verbose test \
|
||||
&& build/testexec \
|
||||
&& jpm --verbose quickbin testexec.janet build/testexec2 \
|
||||
&& build/testexec2 \
|
||||
&& jpm --verbose --modpath=. install https://github.com/janet-lang/json.git
|
||||
|
||||
build/embed_janet.o: build/janet.c $(JANET_HEADERS)
|
||||
|
19
auxbin/jpm
19
auxbin/jpm
@ -464,17 +464,17 @@ int main(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
/* Create enviornment */
|
||||
JanetTable *runtimeEnv = janet_table(0);
|
||||
runtimeEnv->proto = env;
|
||||
janet_table_put(runtimeEnv, janet_ckeywordv("args"), janet_wrap_array(args));
|
||||
janet_gcroot(janet_wrap_table(runtimeEnv));
|
||||
temptab = janet_table(0);
|
||||
temptab = env;
|
||||
janet_table_put(temptab, janet_ckeywordv("args"), janet_wrap_array(args));
|
||||
janet_gcroot(janet_wrap_table(temptab));
|
||||
|
||||
/* Unlock GC */
|
||||
janet_gcunlock(handle);
|
||||
|
||||
/* Run everything */
|
||||
JanetFiber *fiber = janet_fiber(janet_unwrap_function(marsh_out), 64, argc, args->data);
|
||||
fiber->env = runtimeEnv;
|
||||
fiber->env = temptab;
|
||||
Janet out;
|
||||
JanetSignal result = janet_continue(fiber, janet_wrap_nil(), &out);
|
||||
if (result) {
|
||||
@ -843,6 +843,7 @@ Subcommands are:
|
||||
or (rule "ouput.file" [deps...] ...).
|
||||
rules : list rules available with run.
|
||||
update-pkgs : Update the current package listing from the remote git repository selected.
|
||||
quickbin entry executable : Create an executable from a janet script with a main function.
|
||||
|
||||
Keys are:
|
||||
--modpath : The directory to install modules to. Defaults to $JANET_MODPATH, $JANET_PATH, or (dyn :syspath)
|
||||
@ -900,6 +901,11 @@ Flags are:
|
||||
[]
|
||||
(install-git (dyn :pkglist default-pkglist)))
|
||||
|
||||
(defn- quickbin
|
||||
[input output]
|
||||
(create-executable @{} input output)
|
||||
(do-rule output))
|
||||
|
||||
(def- subcommands
|
||||
{"build" build
|
||||
"clean" clean
|
||||
@ -912,7 +918,8 @@ Flags are:
|
||||
"run" local-rule
|
||||
"rules" list-rules
|
||||
"update-pkgs" update-pkgs
|
||||
"uninstall" uninstall-cmd})
|
||||
"uninstall" uninstall-cmd
|
||||
"quickbin" quickbin})
|
||||
|
||||
(def- args (tuple/slice (dyn :args) 1))
|
||||
(def- len (length args))
|
||||
|
@ -179,6 +179,10 @@ call jpm --verbose --modpath=. install https://github.com/janet-lang/json.git
|
||||
@if errorlevel 1 goto :TESTFAIL
|
||||
call build\testexec
|
||||
@if errorlevel 1 goto :TESTFAIL
|
||||
call jpm --verbose quickbin testexec.janet build\testexec2
|
||||
@if errorlevel 1 goto :TESTFAIL
|
||||
call build\testexec2
|
||||
@if errorlevel 1 goto :TESTFAIL
|
||||
popd
|
||||
exit /b 0
|
||||
|
||||
|
7
jpm.1
7
jpm.1
@ -138,6 +138,13 @@ List all rules that can be run via run. This is useful for exploring rules in th
|
||||
.BR update-pkgs
|
||||
Update the package listing by installing the 'pkgs' package. Same as jpm install pkgs
|
||||
|
||||
.TP
|
||||
.BR quickbin [\fBentry\fR] [\fBexecutable\fR]
|
||||
Create a standalone, statically linked executable from a Janet source file that contains a main function.
|
||||
The main function is the entry point of the program and will receive command line arguments
|
||||
as function arguments. The entry file can import other modules, including native C modules, and
|
||||
jpm will attempt to include the dependencies into the generated executable.
|
||||
|
||||
.SH ENVIRONMENT
|
||||
|
||||
.B JANET_PATH
|
||||
|
Loading…
Reference in New Issue
Block a user