From 1a13e0b66833c9c207a1fcaf5a4d60a65786bc7f Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 15 Mar 2022 10:36:47 -0500 Subject: [PATCH] updating build systems --- .github/workflows/windows-build.yml | 2 +- build.sh | 62 +++++++++++++++++++---------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 6620d3c5..6aebf436 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -39,7 +39,7 @@ jobs: path: | core examples - lib/windows_x86_64 + lib/windows_x86_64/lib/wasmer.dll misc modules onyx_runtime.dll diff --git a/build.sh b/build.sh index 03687aaf..7cbc9c0d 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,7 @@ #!/bin/sh +# The base path for the installation. +# This is typcially /usr or /usr/local. INSTALL_DIR="/usr" # Where the core libraries for Onyx will go. @@ -8,8 +10,16 @@ CORE_DIR="$INSTALL_DIR/share/onyx" # Where the onyx executable will be placed. BIN_DIR="$INSTALL_DIR/bin" +# The compiler to use. Only GCC and TCC have been tested. +CC='gcc' + +# The architecture of your system. If your not sure, leave this alone. ARCH="$(uname -m)" +# Comment this line if you do not want the Wamser libraries installed, +# and do not with to have the Onyx runtime. +ENABLE_BUNDLING_WASMER=1 + # Where the Wasmer library files can be found. # They are bundled with the project, but if a different version is available, these can be changed. WASMER_INCLUDE_DIR="$(pwd)/lib/common/include" @@ -18,23 +28,19 @@ WASMER_LIBRARY_DIR="$(pwd)/lib/linux_$ARCH/lib" # Where the intermediate build files go. BUILD_DIR='./build' + + + echo "Installing core libs" sudo mkdir -p "$CORE_DIR" sudo cp -r ./core/ "$CORE_DIR" -[ "$1" = "libs_only" ] && exit 0 +# This is a development feature to allow for quickly reinstalling core libraries +# without have to recompile the entire compiler +[ "$1" = "core" ] && exit 0 -if [ ! -f "$CORE_DIR/lib/libwasmer.so" ]; then - sudo mkdir -p "$CORE_DIR/lib" - - echo "Copying libwasmer to $CORE_DIR/lib (first install)" - # sudo cp "$WASMER_LIBRARY_DIR/libiwasm.so" "$CORE_DIR/lib/libiwasm.so" - sudo cp "$WASMER_LIBRARY_DIR/libwasmer.so" "$CORE_DIR/lib/libwasmer.so" - sudo cp "$WASMER_LIBRARY_DIR/libwasmer.a" "$CORE_DIR/lib/libwasmer.a" -fi C_FILES="onyx astnodes builtins checker clone doc entities errors lex parser symres types utils wasm_emit" -CC='gcc' LIBS= INCLUDES= @@ -48,10 +54,22 @@ else TARGET='./bin/onyx' fi -C_FILES="$C_FILES wasm_runtime" -FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER" -LIBS="-L$CORE_DIR/lib -lwasmer -Wl,-rpath=$CORE_DIR/lib:./ -lpthread -ldl" -INCLUDES="-I$WASMER_INCLUDE_DIR" + +if [ ! -z "$ENABLE_BUNDLING_WASMER" ]; then + C_FILES="$C_FILES wasm_runtime" + FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER" + LIBS="$LIBS -L$CORE_DIR/lib -lwasmer -Wl,-rpath=$CORE_DIR/lib:./ -lpthread -ldl" + INCLUDES="$INCLUDES -I$WASMER_INCLUDE_DIR" + + if [ ! -f "$CORE_DIR/lib/libwasmer.so" ]; then + sudo mkdir -p "$CORE_DIR/lib" + + echo "Copying libwasmer to $CORE_DIR/lib (first install)" + # sudo cp "$WASMER_LIBRARY_DIR/libiwasm.so" "$CORE_DIR/lib/libiwasm.so" + sudo cp "$WASMER_LIBRARY_DIR/libwasmer.so" "$CORE_DIR/lib/libwasmer.so" + sudo cp "$WASMER_LIBRARY_DIR/libwasmer.a" "$CORE_DIR/lib/libwasmer.a" + fi +fi mkdir -p "$BUILD_DIR" @@ -77,15 +95,17 @@ echo "Installing onyx executable" sudo mkdir -p "$BIN_DIR" sudo cp ./bin/onyx "$BIN_DIR/onyx" -C_FILES="onyxrun wasm_runtime" -TARGET="./bin/onyxrun" +if [ ! -z "$ENABLE_BUNDLING_WASMER" ]; then + C_FILES="onyxrun wasm_runtime" + TARGET="./bin/onyxrun" -compile -echo "Installing onyxrun executable" -sudo cp ./bin/onyxrun "$BIN_DIR/onyxrun" + compile + echo "Installing onyxrun executable" + sudo cp ./bin/onyxrun "$BIN_DIR/onyxrun" -./modules/onyx_runtime/build.sh -sudo mv "./onyx_runtime.so" "$CORE_DIR/lib/onyx_runtime.so" + ./modules/onyx_runtime/build.sh + sudo mv "./onyx_runtime.so" "$CORE_DIR/lib/onyx_runtime.so" +fi # Otherwise the prompt ends on the same line printf "\n" -- 2.25.1