changed: build variables
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 17 Nov 2023 19:37:14 +0000 (13:37 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 17 Nov 2023 19:37:14 +0000 (13:37 -0600)
build.bat
compiler/build.sh
compiler/include/wasm_emit.h
compiler/src/onyx.c

index adc2a0ad354c6cfa60b59932bc21a91f5402b48e..4f0e4b3355425379a39a4cf6b901b669499b9dfa 100644 (file)
--- a/build.bat
+++ b/build.bat
@@ -12,7 +12,7 @@ if "%1" == "1" (
 for /f "delims=" %%i in ('cd') do set PWD=%%i
 
 set LINK_OPTIONS="%PWD%\shared\lib\windows_x86_64\lib\wasmer.lib" ws2_32.lib Advapi32.lib userenv.lib bcrypt.lib kernel32.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib
-set FLAGS=%FLAGS% "/I%PWD%\shared\include" /DENABLE_RUN_WITH_WASMER=1
+set FLAGS=%FLAGS% "/I%PWD%\shared\include" /DONYX_RUNTIME_LIBRARY=wasmer
 
 rc.exe misc/icon_resource.rc
 cl.exe %FLAGS% /Icompiler/include /std:c17 /TC %SOURCE_FILES% /link /IGNORE:4217 %LINK_OPTIONS% /DEBUG /OUT:onyx.exe /incremental:no /opt:ref /subsystem:console misc\icon_resource.res
@@ -32,7 +32,13 @@ if "%1" == "dist" (
     mkdir dist
     xcopy core dist\core /s /e /h /I
     xcopy examples dist\examples /s /e /h /I
-    @REM xcopy misc dist\misc /s /e /h /I
+
+    mkdir dist\misc
+    copy misc\onyx-windows.sublime-build dist\misc\onyx-windows.sublime-build
+    copy misc\onyx-mode.el dist\misc\onyx-mode.el
+    copy misc\onyx.sublime-syntax dist\misc\onyx.sublime-syntax
+    copy misc\vscode\onyx-0.1.8.vsix dist\misc\onyx-0.1.8.vsix
+
     copy onyx_runtime.dll dist\onyx_runtime.dll
     xcopy tests dist\tests /s /e /h /I
     copy onyx.exe dist\onyx.exe
index 651104b591dd511a7cb6454473532825e2cb1afe..215d9458ad2e24b3c07fc26515078e7ccae7ce12 100755 (executable)
@@ -19,7 +19,7 @@ if [ ! -z ${ONYX_TARGET+x} ]; then
 fi
 
 if [ ! -z ${ONYX_RUNTIME_LIBRARY+x} ]; then
-    FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER"
+    FLAGS="$FLAGS -DONYX_RUNTIME_LIBRARY=$ONYX_RUNTIME_LIBRARY"
     C_FILES="${C_FILES}wasm_runtime "
     case "${ONYX_RUNTIME_LIBRARY}" in
         ovmwasm)
index ee5cfcc298871000f7c56a495e986641bb27eddb..d3cfe966de2d98b3cf822575cf81470d75f27239 100644 (file)
@@ -792,7 +792,7 @@ void onyx_wasm_module_free(OnyxWasmModule* module);
 void onyx_wasm_module_write_to_buffer(OnyxWasmModule* module, bh_buffer* buffer);
 void onyx_wasm_module_write_to_file(OnyxWasmModule* module, bh_file file);
 
-#ifdef ENABLE_RUN_WITH_WASMER
+#ifdef ONYX_RUNTIME_LIBRARY 
 void onyx_run_initialize(b32 debug_enabled);
 b32 onyx_run_wasm(bh_buffer code_buffer, int argc, char *argv[]);
 #endif
index a7e1c14164482926ce4cf81674e418d062d63d47..2e6eec7fc63d279fe824de239e3f4861e3d02396 100644 (file)
@@ -21,11 +21,21 @@ extern struct bh_allocator global_heap_allocator;
 
 #define VERSION "v0.1.8"
 
+#ifdef ONYX_RUNTIME_LIBRARY
+    #define ONYX_RUNTIME_LIBRARY_MAPPED ONYX_RUNTIME_LIBRARY
+#else
+    #define ONYX_RUNTIME_LIBRARY_MAPPED none
+#endif
+
+#define STRINGIFY_(x) #x
+#define STRINGIFY(x) STRINGIFY_(x)
+
 
 Context context;
 
 #define VERSION_STRING "Onyx toolchain version " VERSION "\n" \
-    "Built on " __TIMESTAMP__ "\n"
+    "Built on " __TIMESTAMP__ "\n" \
+    "Runtime: " STRINGIFY(ONYX_RUNTIME_LIBRARY_MAPPED) "\n"
 
 #define DOCSTRING_HEADER VERSION_STRING \
     "\n" \
@@ -40,11 +50,13 @@ static const char* top_level_docstring = DOCSTRING_HEADER
     "Subcommands:\n"
     "\thelp      Shows this help message. Use \"onyx help <subcommand>\".\n"
     "\tbuild     Compiles an Onyx program into an executable.\n"
-#ifdef ENABLE_RUN_WITH_WASMER
+#ifdef ONYX_RUNTIME_LIBRARY
     "\trun       Compiles and runs an Onyx program, all at once.\n"
 #endif
     "\tcheck     Checks syntax and types of an Onyx program.\n"
+#ifdef _BH_LINUX
     "\twatch     Continuously rebuilds an Onyx program on file changes.\n"
+#endif
     "\tpackage   Package manager\n"
     "\tversion   Prints version information\n";
     // "\tdoc <input files>\n"
@@ -178,7 +190,7 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg
         bh_arr_push(options.files, bh_aprintf(alloc, "%s/tools/onyx-pkg.onyx", core_installation));
         goto skip_parsing_arguments;
     }
-    #ifdef ENABLE_RUN_WITH_WASMER
+    #ifdef ONYX_RUNTIME_LIBRARY
     else if (!strcmp(argv[1], "run")) {
         options.action = ONYX_COMPILE_ACTION_RUN;
         arg_parse_start = 2;
@@ -189,7 +201,7 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg
         options.action = ONYX_COMPILE_ACTION_WATCH;
         arg_parse_start = 2;
     }
-        // `#ifdef ENABLE_RUN_WITH_WASMER
+        // `#ifdef ONYX_RUNTIME_LIBRARY
         // `else if (!strcmp(argv[1], "run-watch")) {
         // `    options.action = ONYX_COMPILE_ACTION_RUN_WATCH;
         // `    arg_parse_start = 2;
@@ -348,8 +360,8 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg
 
   skip_parsing_arguments:
 
-    // NOTE: Always enable multi-threading for the Onyx runtime.
-    if (options.runtime == Runtime_Onyx) {
+    // NOTE: Always enable multi-threading for the Onyx and WASI runtime.
+    if (options.runtime == Runtime_Onyx || options.runtime == Runtime_Wasi) {
         options.use_multi_threading = 1;
     }
 
@@ -1037,7 +1049,7 @@ static CompilerProgress onyx_flush_module() {
     return ONYX_COMPILER_PROGRESS_SUCCESS;
 }
 
-#ifdef ENABLE_RUN_WITH_WASMER
+#ifdef ONYX_RUNTIME_LIBRARY
 static b32 onyx_run_module(bh_buffer code_buffer) {
     onyx_run_initialize(context.options->debug_session);
 
@@ -1185,7 +1197,7 @@ int main(int argc, char *argv[]) {
             break;
         #endif
 
-        #ifdef ENABLE_RUN_WITH_WASMER
+        #ifdef ONYX_RUNTIME_LIBRARY
         case ONYX_COMPILE_ACTION_RUN:
             compiler_progress = do_compilation(&compile_opts);
             if (compiler_progress == ONYX_COMPILER_PROGRESS_SUCCESS) {
@@ -1196,7 +1208,7 @@ int main(int argc, char *argv[]) {
             break;
         #endif
 
-        #ifdef ENABLE_RUN_WITH_WASMER
+        #ifdef ONYX_RUNTIME_LIBRARY
         case ONYX_COMPILE_ACTION_RUN_WASM:
             global_heap_allocator = bh_heap_allocator();
             context_init(&compile_opts);