mirror of
https://github.com/janet-lang/janet
synced 2025-11-27 20:45:13 +00:00
Add experimental meson build.
Should help with IDE integration.
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
extern const unsigned char *janet_gen_boot;
|
||||
extern int32_t janet_gen_boot_size;
|
||||
|
||||
int main() {
|
||||
int main(int argc, const char **argv) {
|
||||
|
||||
/* Init janet */
|
||||
janet_init();
|
||||
@@ -46,6 +46,12 @@ int main() {
|
||||
|
||||
env = janet_core_env(NULL);
|
||||
|
||||
/* Create args tuple */
|
||||
JanetArray *args = janet_array(argc);
|
||||
for (int i = 0; i < argc; i++)
|
||||
janet_array_push(args, janet_cstringv(argv[i]));
|
||||
janet_def(env, "process/args", janet_wrap_array(args), "Command line arguments.");
|
||||
|
||||
/* Run bootstrap script to generate core image */
|
||||
status = janet_dobytes(env, janet_gen_boot, janet_gen_boot_size, "boot.janet", NULL);
|
||||
|
||||
|
||||
@@ -16,6 +16,15 @@
|
||||
# everything else goes. Cfunctions and abstracts will be referenced from a registry
|
||||
# table which will be generated on janet startup.
|
||||
(do
|
||||
|
||||
# Get process options
|
||||
(def- process/opts @{})
|
||||
(each [k v] (partition 2 (tuple/slice process/args 2))
|
||||
(put process/opts k v))
|
||||
|
||||
# Set up default config from arguments
|
||||
(set module/*syspath* (or (process/opts "JANET_PATH") ""))
|
||||
|
||||
(def image (let [env-pairs (pairs (env-lookup *env*))
|
||||
essential-pairs (filter (fn [[k v]] (or (cfunction? v) (abstract? v))) env-pairs)
|
||||
lookup (table ;(mapcat identity essential-pairs))
|
||||
@@ -26,7 +35,7 @@
|
||||
# can be compiled and linked statically into the main janet library
|
||||
# and example client.
|
||||
(def chunks (string/bytes image))
|
||||
(def image-file (file/open "build/core_image.c" :w))
|
||||
(def image-file (file/open (process/args 1) :w))
|
||||
(file/write image-file
|
||||
"#ifndef JANET_AMALG\n"
|
||||
"#include <janet.h>\n"
|
||||
|
||||
@@ -1584,7 +1584,7 @@
|
||||
"The path where globally installed libraries are located.
|
||||
The default is set at build time and is /usr/local/lib/janet on linux/posix, and
|
||||
on Windows is C:/Janet/Library."
|
||||
(or (os/getenv "JANET_PATH") ""))
|
||||
"")
|
||||
|
||||
(defn- fexists [path]
|
||||
(def f (file/open path))
|
||||
|
||||
@@ -831,12 +831,10 @@ JanetTable *janet_core_env(JanetTable *replacements) {
|
||||
janet_lib_inttypes(env);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef JANET_BOOTSTRAP
|
||||
/* Run bootstrap source */
|
||||
janet_dobytes(env, janet_gen_core, janet_gen_core_size, "core.janet", NULL);
|
||||
#else
|
||||
|
||||
/* Unmarshal from core image */
|
||||
Janet marsh_out = janet_unmarshal(
|
||||
janet_core_image,
|
||||
|
||||
Reference in New Issue
Block a user