diff --git a/CHANGELOG.md b/CHANGELOG.md index 29af2365..47b22886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file. - Use `(doc)` with no arguments to see available bindings and dynamic bindings. - `jpm` will use `CC` and `AR` environment variables when compiling programs. - Add `comptime` macro for compile time evaluation. +- Run `main` functions in scripts if they exist, just like jpm standalone binaries. - Numerous small bug fixes and usability improvements. ### 1.5.1 - 2019-11-16 diff --git a/src/boot/boot.janet b/src/boot/boot.janet index a2255de4..c11bcac8 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1866,7 +1866,6 @@ [image] (unmarshal image (env-lookup _env))) -(def- nati (if (= :windows (os/which)) ".dll" ".so")) (defn- check-. [x] (if (string/has-prefix? "." x) x)) (defn- not-check-. [x] (unless (string/has-prefix? "." x) x)) @@ -1883,19 +1882,19 @@ [":cur:/:all:.jimage" :image check-.] [":cur:/:all:.janet" :source check-.] [":cur:/:all:/init.janet" :source check-.] - [(string ":cur:/:all:" nati) :native check-.] + [":cur:/:all::native:" :native check-.] # As a path from (os/cwd) [":all:.jimage" :image not-check-.] [":all:.janet" :source not-check-.] [":all:/init.janet" :source not-check-.] - [(string ":all:" nati) :native not-check-.] + [":all::native:" :native not-check-.] # System paths [":sys:/:all:.jimage" :image not-check-.] [":sys:/:all:.janet" :source not-check-.] [":sys:/:all:/init.janet" :source not-check-.] - [(string ":sys:/:all:" nati) :native not-check-.]]) + [":sys:/:all::native:" :native not-check-.]]) (setdyn :syspath (boot/opts "JANET_PATH")) (setdyn :headerpath (boot/opts "JANET_HEADERPATH")) @@ -1949,7 +1948,6 @@ [nil (string "could not find module " path ":\n " ;str-parts)]))) (put _env 'fexists nil) -(put _env 'nati nil) (put _env 'mod-filter nil) (put _env 'check-. nil) (put _env 'not-check-. nil) diff --git a/src/core/corelib.c b/src/core/corelib.c index afcb0bfc..7e2b3ced 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -177,6 +177,13 @@ static Janet janet_core_expand_path(int32_t argc, Janet *argv) { } else if (strncmp(template + i, ":name:", 6) == 0) { janet_buffer_push_cstring(out, name); i += 5; + } else if (strncmp(template + i, ":native:", 8) == 0) { +#ifdef JANET_WINDOWS + janet_buffer_push_cstring(out, ".dll"); +#else + janet_buffer_push_cstring(out, ".so"); +#endif + i += 7; } else { janet_buffer_push_u8(out, (uint8_t) template[i]); } @@ -668,7 +675,13 @@ static const JanetReg corelib_cfuns[] = { "Expands a path template as found in module/paths for module/find. " "This takes in a path (the argument to require) and a template string, template, " "to expand the path to a path that can be " - "used for importing files.") + "used for importing files. The replacements are as follows:\n\n" + "\t:all:\tthe value of path verbatim\n" + "\t:cur:\tthe current file, or (dyn :current-file)\n" + "\t:dir:\tthe directory containing the current file\n" + "\t:name:\tthe filename component of path, with extenion if given\n" + "\t:native:\tthe extension used to load natives, .so or .dll\n" + "\t:sys:\tthe system path, or (syn :syspath)") }, { "int?", janet_core_check_int,