From 55b853a7bf2d815b173c57ccaada24b8ad6f49dc Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 17 Nov 2023 13:37:14 -0600 Subject: [PATCH] changed: build variables --- build.bat | 10 ++++++++-- compiler/build.sh | 2 +- compiler/include/wasm_emit.h | 2 +- compiler/src/onyx.c | 30 +++++++++++++++++++++--------- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/build.bat b/build.bat index adc2a0ad..4f0e4b33 100644 --- 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 diff --git a/compiler/build.sh b/compiler/build.sh index 651104b5..215d9458 100755 --- a/compiler/build.sh +++ b/compiler/build.sh @@ -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) diff --git a/compiler/include/wasm_emit.h b/compiler/include/wasm_emit.h index ee5cfcc2..d3cfe966 100644 --- a/compiler/include/wasm_emit.h +++ b/compiler/include/wasm_emit.h @@ -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 diff --git a/compiler/src/onyx.c b/compiler/src/onyx.c index a7e1c141..2e6eec7f 100644 --- a/compiler/src/onyx.c +++ b/compiler/src/onyx.c @@ -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 \".\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 \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); -- 2.25.1