1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Add (dyn :executable).

Also remove process/args.
This commit is contained in:
Calvin Rose 2019-07-27 09:31:03 -05:00
parent d46bcd5b8f
commit a3a3e4c0dc
5 changed files with 9 additions and 7 deletions

View File

@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
## Unreleased
- Add file associations on windows with default install.
- Add `(dyn :executable)` at top level to get what used to be
`(process/args 0)`.
- Add `:linux` to platforms returned by `(os/which)`.
- Update jpm to build standalone executables. Use `declare-executable` for this.
- Add `use` macro.

View File

@ -83,7 +83,7 @@ Flags are:
"clear-cache" cook/clear-cache
"uninstall" uninstall})
(def args (tuple/slice (dyn :args) 2))
(def args (tuple/slice (dyn :args) 1))
(def len (length args))
(var i 0)

View File

@ -353,8 +353,7 @@
# Load entry environment and get main function.
(def entry-env (dofile source))
(def main ((entry-env 'main) :value))
# Get environments for every native module for the marshalling
# dictionary
# Create marshalling dictionary
(def mdict (invert (env-lookup root-env)))
# Build image
(def image (marshal main mdict))

View File

@ -1,7 +1,5 @@
# Copyright 2017-2019 (C) Calvin Rose
(def process/args "Deprecated. use '(dyn :args)' at script entry instead for process argument array."
(dyn :args))
(do
(var *should-repl* false)
@ -66,7 +64,7 @@
(if h (h i) (do (print "unknown flag -" n) ((get handlers "h")))))
# Process arguments
(var i 1)
(var i 0)
(def lenargs (length args))
(while (< i lenargs)
(def arg (get args i))

View File

@ -61,10 +61,13 @@ int main(int argc, char **argv) {
/* Create args tuple */
args = janet_array(argc);
for (i = 0; i < argc; i++)
for (i = 1; i < argc; i++)
janet_array_push(args, janet_cstringv(argv[i]));
janet_table_put(env, janet_ckeywordv("args"), janet_wrap_array(args));
/* Save current executable path to (dyn :executable) */
janet_table_put(env, janet_ckeywordv("executable"), janet_cstringv(argv[0]));
/* Run startup script */
status = janet_dobytes(env, janet_gen_init, janet_gen_init_size, "init.janet", NULL);