From f580d2e41abcb43f33aeeb6387da88b8e2d5d00e Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 6 Jul 2020 19:25:34 -0500 Subject: [PATCH 1/6] Add forever macro and add names to anon fns. Adding names to anon functions that may error improves stack traces, especially for user visible traces. --- CHANGELOG.md | 1 + src/boot/boot.janet | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aeb32da7..2a5a2c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? +- Add `forever` macro. - Add `any?` predicate to core. - Add `jpm list-pkgs` subcommand to see which package aliases are in the listing. - Add `jpm list-installed` subcommand to see which packages are installed. diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 3fc8bcd0..ec4e8e29 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -516,6 +516,11 @@ (with-syms [iter] ~(do (var ,iter ,n) (while (> ,iter 0) ,;body (-- ,iter))))) +(defmacro forever + "Evaluate body forever in a loop, or until a break statement." + [& body] + ~(while true ,;body)) + (defmacro each "Loop over each value in ds. Returns nil." [x ds & body] @@ -2173,12 +2178,12 @@ (buffer/push-string buf "\n"))) (var returnval nil) (run-context {:chunks chunks - :on-compile-error (fn [msg errf &] + :on-compile-error (fn compile-error [msg errf &] (error (string "compile error: " msg))) - :on-parse-error (fn [p x] + :on-parse-error (fn parse-error [p x] (error (string "parse error: " (parser/error p)))) :fiber-flags :i - :on-status (fn [f val] + :on-status (fn on-status [f val] (if-not (= (fiber/status f) :dead) (error val)) (set returnval val)) @@ -2770,17 +2775,17 @@ "k" (fn [&] (set *compile-only* true) (set *exit-on-error* false) 1) "n" (fn [&] (set *colorize* false) 1) "m" (fn [i &] (setdyn :syspath (in args (+ i 1))) 2) - "c" (fn [i &] + "c" (fn c-switch [i &] (def e (dofile (in args (+ i 1)))) (spit (in args (+ i 2)) (make-image e)) (set *no-file* false) 3) "-" (fn [&] (set *handleopts* false) 1) - "l" (fn [i &] + "l" (fn l-switch [i &] (import* (in args (+ i 1)) :prefix "" :exit *exit-on-error*) 2) - "e" (fn [i &] + "e" (fn e-switch [i &] (set *no-file* false) (eval-string (in args (+ i 1))) 2) From b4f5e5bc009a7a315c25c0f61fc7fb782f764a4f Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 6 Jul 2020 21:24:49 -0500 Subject: [PATCH 2/6] Update docs for -l option. --- janet.1 | 4 ++-- src/boot/boot.janet | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/janet.1 b/janet.1 index 4f39eb75..21b38e46 100644 --- a/janet.1 +++ b/janet.1 @@ -194,8 +194,8 @@ Source should be a path to the Janet module to compile, and output should be the resulting image. Output should usually end with the .jimage extension. .TP -.BR \-l\ path -Load a Janet file before running a script or repl. Multiple files can be loaded +.BR \-l\ lib +Import a Janet module before running a script or repl. Multiple files can be loaded in this manner, and exports from each file will be made available to the script or repl. diff --git a/src/boot/boot.janet b/src/boot/boot.janet index ec4e8e29..1aad1f1c 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -2763,7 +2763,7 @@ -m syspath : Set system path for loading global modules -c source output : Compile janet source code into an image -n : Disable ANSI color output in the repl - -l path : Execute code in a file before running the main script + -l lib : Import a module before processing more arguments -- : Stop handling options`) (os/exit 0) 1) From 3ba2c7e7e870c54fdf9c355dfc9ad72c38d7645a Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 18 Jul 2020 13:09:53 -0500 Subject: [PATCH 3/6] Address #394 and #451 - Prepare for 1.11.0 Prefix MANPATH and PKG_CONFIG_PATH variables with JANET_ to disassociate with standard env variables that have a different format. --- CHANGELOG.md | 1 + Makefile | 20 ++++++++++---------- meson.build | 2 +- src/boot/boot.janet | 10 +++++++--- src/conf/janetconf.h | 8 ++++---- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5a2c6a..b081a767 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - Add `repeat` macro for iterating something n times. - Add `eachy` (each yield) macro for iterating a fiber. - Fix `:generate` verb in loop macro to accept non symbols as bindings. +- Add `:h`, `:h+`, and `:h*` in `default-peg-grammar` for hexidecimal digits. - Fix `%j` formatter to print numbers precisely (using the `%.17g` format string to printf). ## 1.10.1 - 2020-06-18 diff --git a/Makefile b/Makefile index 64f49047..670f408b 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,8 @@ JANET_TARGET=build/janet JANET_LIBRARY=build/libjanet.so JANET_STATIC_LIBRARY=build/libjanet.a JANET_PATH?=$(LIBDIR)/janet -MANPATH?=$(PREFIX)/share/man/man1/ -PKG_CONFIG_PATH?=$(LIBDIR)/pkgconfig +JANET_MANPATH?=$(PREFIX)/share/man/man1/ +JANET_PKG_CONFIG_PATH?=$(LIBDIR)/pkgconfig DEBUGGER=gdb SONAME_SETTER=-Wl,-soname, @@ -272,11 +272,11 @@ install: $(JANET_TARGET) build/janet.pc build/jpm ln -sf $(SONAME) '$(DESTDIR)$(LIBDIR)/libjanet.so' ln -sf libjanet.so.$(shell $(JANET_TARGET) -e '(print janet/version)') $(DESTDIR)$(LIBDIR)/$(SONAME) cp -rf build/jpm '$(DESTDIR)$(BINDIR)' - mkdir -p '$(DESTDIR)$(MANPATH)' - cp janet.1 '$(DESTDIR)$(MANPATH)' - cp jpm.1 '$(DESTDIR)$(MANPATH)' - mkdir -p '$(DESTDIR)$(PKG_CONFIG_PATH)' - cp build/janet.pc '$(DESTDIR)$(PKG_CONFIG_PATH)/janet.pc' + mkdir -p '$(DESTDIR)$(JANET_MANPATH)' + cp janet.1 '$(DESTDIR)$(JANET_MANPATH)' + cp jpm.1 '$(DESTDIR)$(JANET_MANPATH)' + mkdir -p '$(DESTDIR)$(JANET_PKG_CONFIG_PATH)' + cp build/janet.pc '$(DESTDIR)$(JANET_PKG_CONFIG_PATH)/janet.pc' [ -z '$(DESTDIR)' ] && $(LDCONFIG) || true uninstall: @@ -284,9 +284,9 @@ uninstall: -rm '$(DESTDIR)$(BINDIR)/jpm' -rm -rf '$(DESTDIR)$(INCLUDEDIR)/janet' -rm -rf '$(DESTDIR)$(LIBDIR)'/libjanet.* - -rm '$(DESTDIR)$(PKG_CONFIG_PATH)/janet.pc' - -rm '$(DESTDIR)$(MANPATH)/janet.1' - -rm '$(DESTDIR)$(MANPATH)/jpm.1' + -rm '$(DESTDIR)$(JANET_PKG_CONFIG_PATH)/janet.pc' + -rm '$(DESTDIR)$(JANET_MANPATH)/janet.1' + -rm '$(DESTDIR)$(JANET_MANPATH)/jpm.1' # -rm -rf '$(DESTDIR)$(JANET_PATH)'/* - err on the side of correctness here ################# diff --git a/meson.build b/meson.build index 78625ec2..56d3476a 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,7 @@ project('janet', 'c', default_options : ['c_std=c99', 'b_lundef=false', 'default_library=both'], - version : '1.10.2') + version : '1.11.0') # Global settings janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 1aad1f1c..0b74e3ca 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -383,13 +383,17 @@ [i start stop step comparison delta body] (with-syms [s] (def st (if (idempotent? step) step (gensym))) + (def loop-body + ~(while (,comparison ,i ,s) + ,;body + (set ,i (,delta ,i ,st)))) ~(do (var ,i ,start) (def ,s ,stop) ,;(if (= st step) [] [~(def ,st ,step)]) - (while (,comparison ,i ,s) - ,;body - (set ,i (,delta ,i ,st)))))) + ,(if (and (number? st) (> st 0)) + loop-body + ~(if (,> ,st 0) ,loop-body))))) (defn- for-template [binding start stop step comparison delta body] diff --git a/src/conf/janetconf.h b/src/conf/janetconf.h index eae3caa7..5f2b4a64 100644 --- a/src/conf/janetconf.h +++ b/src/conf/janetconf.h @@ -27,10 +27,10 @@ #define JANETCONF_H #define JANET_VERSION_MAJOR 1 -#define JANET_VERSION_MINOR 10 -#define JANET_VERSION_PATCH 2 -#define JANET_VERSION_EXTRA "-dev" -#define JANET_VERSION "1.10.2-dev" +#define JANET_VERSION_MINOR 11 +#define JANET_VERSION_PATCH 0 +#define JANET_VERSION_EXTRA "" +#define JANET_VERSION "1.11.0" /* #define JANET_BUILD "local" */ From 286230f477728b5dfff9229a35148794d5c0ed99 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 18 Jul 2020 15:44:04 -0500 Subject: [PATCH 4/6] Fix meson paths. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 56d3476a..cec15317 100644 --- a/meson.build +++ b/meson.build @@ -257,6 +257,6 @@ if get_option('peg') and not get_option('reduced_os') and get_option('processes' output : ['jpm'], command : [janet_nativeclient, '@INPUT@', '@OUTPUT@', '--binpath=' + join_paths(get_option('prefix'), get_option('bindir')), - '--libpath=' + join_paths(get_option('prefix'), get_option('libdir'), 'janet'), + '--libpath=' + join_paths(get_option('prefix'), get_option('libdir')), '--headerpath=' + join_paths(get_option('prefix'), get_option('includedir'))]) endif From 9e163db491e54d9bae0495411d479b3b9bab58c2 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 18 Jul 2020 15:47:13 -0500 Subject: [PATCH 5/6] Test building binaries with jpm. Test in CI with both meson and normal build. Also test windows. --- .builds/meson.yml | 2 ++ Makefile | 1 + build_win.bat | 2 ++ 3 files changed, 5 insertions(+) diff --git a/.builds/meson.yml b/.builds/meson.yml index 04e9152f..889decd7 100644 --- a/.builds/meson.yml +++ b/.builds/meson.yml @@ -10,3 +10,5 @@ tasks: cd build ninja ninja test + mkdir modpath + jpm --verbose --modpath=./modpath install https://github.com/bakpakin/x43bot.git diff --git a/Makefile b/Makefile index 670f408b..e9c02b4f 100644 --- a/Makefile +++ b/Makefile @@ -317,6 +317,7 @@ test-install: cd test/install && jpm --verbose --test --modpath=./modpath install https://github.com/janet-lang/jhydro.git cd test/install && jpm --verbose --test --modpath=./modpath install https://github.com/janet-lang/path.git cd test/install && jpm --verbose --test --modpath=./modpath install https://github.com/janet-lang/argparse.git + cd test/install && jpm --verbose --modpath=./modpath install https://github.com/bakpakin/x43bot.git help: @echo diff --git a/build_win.bat b/build_win.bat index 0e002019..abb5ee2e 100644 --- a/build_win.bat +++ b/build_win.bat @@ -168,6 +168,8 @@ call jpm --verbose --test --modpath=. install https://github.com/janet-lang/path @if errorlevel 1 goto :TESTINSTALLFAIL call jpm --verbose --test --modpath=. install https://github.com/janet-lang/argparse.git @if errorlevel 1 goto :TESTINSTALLFAIL +call jpm --verbose --modpath=. install https://github.com/bakpakin/x43bot.git +@if errorlevel 1 goto :TESTINSTALLFAIL popd exit /b 0 From fa55283f62f88493f47b00cf20b34a0b84c64620 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 18 Jul 2020 16:21:01 -0500 Subject: [PATCH 6/6] Release 1.11.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b081a767..ece21574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog All notable changes to this project will be documented in this file. -## Unreleased - ??? +## 1.11.0 - 2020-07-18 - Add `forever` macro. - Add `any?` predicate to core. - Add `jpm list-pkgs` subcommand to see which package aliases are in the listing.