From: Brendan Hansen Date: Thu, 16 Nov 2023 20:40:38 +0000 (-0600) Subject: added: `onyx version` subcommand X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=bcb1d4088259c85f69aac9c0ccb9054d04c36c22;p=onyx.git added: `onyx version` subcommand --- diff --git a/.github/workflows/onyx-build.yml b/.github/workflows/onyx-build.yml index e1a4bb14..5bf3ded6 100644 --- a/.github/workflows/onyx-build.yml +++ b/.github/workflows/onyx-build.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - dev pull_request: branches: - master @@ -30,6 +29,10 @@ jobs: os: ubuntu-latest runtime_library: ':libwasmer.a' artifact_name: 'onyx-linux-wasmer-amd64' + - build: linux-amd64 + os: ubuntu-latest + runtime_library: none + artifact_name: 'onyx-linux-none-amd64' - build: windows-amd64 os: windows-latest artifact_name: 'onyx-windows-amd64' @@ -61,7 +64,7 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Build Onyx for ${{ matrix.build }} - if: matrix.build == 'linux-amd64' + if: (matrix.build == 'linux-amd64') && (matrix.runtime_library != 'none') run: | ./build.sh compile package env: @@ -71,6 +74,15 @@ jobs: ONYX_INCLUDE_DIR: ../shared/include ONYX_LIBRARY_DIR: ${{ env.ONYX_LIBRARY_DIR }} ONYX_USE_DYNCALL: '1' + + - name: Build Onyx for ${{ matrix.build }} + if: (matrix.build == 'linux-amd64') && (matrix.runtime_library == 'none') + run: | + ./build.sh compile package + env: + ONYX_CC: gcc + ONYX_ARCH: x86_64 + ONYX_INCLUDE_DIR: ../shared/include - name: Build Onyx for ${{ matrix.build }} if: matrix.build == 'windows-amd64' diff --git a/compiler/include/astnodes.h b/compiler/include/astnodes.h index 21bed634..136ae2a3 100644 --- a/compiler/include/astnodes.h +++ b/compiler/include/astnodes.h @@ -1751,6 +1751,7 @@ enum CompileAction { ONYX_COMPILE_ACTION_WATCH, ONYX_COMPILE_ACTION_DOCUMENT, ONYX_COMPILE_ACTION_PRINT_HELP, + ONYX_COMPILE_ACTION_PRINT_VERSION }; diff --git a/compiler/src/onyx.c b/compiler/src/onyx.c index 96095e29..a7e1c141 100644 --- a/compiler/src/onyx.c +++ b/compiler/src/onyx.c @@ -24,13 +24,15 @@ extern struct bh_allocator global_heap_allocator; Context context; -#define DOCSTRING_HEADER "Onyx toolchain version " VERSION "\n" \ +#define VERSION_STRING "Onyx toolchain version " VERSION "\n" \ + "Built on " __TIMESTAMP__ "\n" + +#define DOCSTRING_HEADER VERSION_STRING \ "\n" \ "The toolchain for the Onyx programming language, created by Brendan Hansen.\n" \ "\n" - static const char* top_level_docstring = DOCSTRING_HEADER "Usage:\n" "\tonyx \n" @@ -43,7 +45,8 @@ static const char* top_level_docstring = DOCSTRING_HEADER #endif "\tcheck Checks syntax and types of an Onyx program.\n" "\twatch Continuously rebuilds an Onyx program on file changes.\n" - "\tpackage Package manager\n"; + "\tpackage Package manager\n" + "\tversion Prints version information\n"; // "\tdoc \n" static const char *build_docstring = DOCSTRING_HEADER @@ -132,8 +135,10 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg core_installation = getenv("ONYX_PATH"); #endif #ifdef _BH_WINDOWS - core_installation = bh_alloc_array(alloc, u8, 512); - GetEnvironmentVariableA("ONYX_PATH", core_installation, 512); + char *tmp_core_installation = bh_alloc_array(alloc, u8, 512); + if (GetEnvironmentVariableA("ONYX_PATH", tmp_core_installation, 512) > 0) { + core_installation = tmp_core_installation; + } #endif if (core_installation == NULL) { @@ -152,6 +157,10 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg options.action = ONYX_COMPILE_ACTION_PRINT_HELP; options.help_subcommand = argc > 2 ? argv[2] : NULL; } + else if (!strcmp(argv[1], "version")) { + options.action = ONYX_COMPILE_ACTION_PRINT_VERSION; + goto skip_parsing_arguments; + } else if (!strcmp(argv[1], "compile") || !strcmp(argv[1], "build")) { options.action = ONYX_COMPILE_ACTION_COMPILE; arg_parse_start = 2; @@ -1154,6 +1163,11 @@ int main(int argc, char *argv[]) { return 1; } + case ONYX_COMPILE_ACTION_PRINT_VERSION: { + bh_printf(VERSION_STRING); + return 0; + } + case ONYX_COMPILE_ACTION_CHECK: compiler_progress = do_compilation(&compile_opts); break; diff --git a/runtime/src/ort_os.h b/runtime/src/ort_os.h index 93954a83..e6ef5e88 100644 --- a/runtime/src/ort_os.h +++ b/runtime/src/ort_os.h @@ -149,7 +149,7 @@ ONYX_DEF(__random_get, (WASM_PTR, WASM_I32), ()) { ONYX_DEF(__futex_wait, (WASM_PTR, WASM_I32, WASM_I32), (WASM_I32)) { int *addr = ONYX_PTR(params->data[0].of.i32); - #if defined(_BH_LINUX) || defined(_BH_DARWIN) + #if defined(_BH_LINUX) struct timespec delay; struct timespec *t = NULL; @@ -181,7 +181,7 @@ ONYX_DEF(__futex_wait, (WASM_PTR, WASM_I32, WASM_I32), (WASM_I32)) { ONYX_DEF(__futex_wake, (WASM_PTR, WASM_I32), (WASM_I32)) { int *addr = ONYX_PTR(params->data[0].of.i32); - #if defined(_BH_LINUX) || defined(_BH_DARWIN) + #if defined(_BH_LINUX) int res = syscall(SYS_futex, addr, FUTEX_WAKE, params->data[1].of.i32, NULL, NULL, 0); results->data[0] = WASM_I32_VAL(res);