From f18f6bb1d5dead6b3f20c757cc969a5334fb6d0f Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 4 Sep 2022 19:28:09 -0500 Subject: [PATCH] restructured folders as this project has grown --- build.sh | 134 +++----------------- compiler/build.sh | 54 ++++++++ {include => compiler/include}/astnodes.h | 0 {include => compiler/include}/doc.h | 0 {include => compiler/include}/errors.h | 0 {include => compiler/include}/lex.h | 0 {include => compiler/include}/parser.h | 0 {include => compiler/include}/types.h | 0 {include => compiler/include}/utils.h | 0 {include => compiler/include}/wasm_emit.h | 0 {src => compiler/src}/astnodes.c | 0 {src => compiler/src}/builtins.c | 0 {src => compiler/src}/checker.c | 0 {src => compiler/src}/clone.c | 0 {src => compiler/src}/doc.c | 0 {src => compiler/src}/entities.c | 0 {src => compiler/src}/errors.c | 0 {src => compiler/src}/lex.c | 0 {src => compiler/src}/onyx.c | 0 {src => compiler/src}/onyxrun.c | 0 {src => compiler/src}/parser.c | 0 {src => compiler/src}/polymorph.h | 0 {src => compiler/src}/symres.c | 0 {src => compiler/src}/types.c | 0 {src => compiler/src}/utils.c | 0 {src => compiler/src}/wasm_emit.c | 0 {src => compiler/src}/wasm_intrinsics.h | 0 {src => compiler/src}/wasm_output.h | 0 {src => compiler/src}/wasm_runtime.c | 0 {src => compiler/src}/wasm_type_table.h | 0 runtime/build.sh | 12 ++ {src => runtime}/onyx_runtime.c | 0 settings.sh | 24 ++++ {include => shared/include}/bh.h | 0 {include => shared/include}/onyx_library.h | 0 {include => shared/include}/small_windows.h | 0 {include => shared/include}/stb_ds.h | 0 37 files changed, 110 insertions(+), 114 deletions(-) create mode 100755 compiler/build.sh rename {include => compiler/include}/astnodes.h (100%) rename {include => compiler/include}/doc.h (100%) rename {include => compiler/include}/errors.h (100%) rename {include => compiler/include}/lex.h (100%) rename {include => compiler/include}/parser.h (100%) rename {include => compiler/include}/types.h (100%) rename {include => compiler/include}/utils.h (100%) rename {include => compiler/include}/wasm_emit.h (100%) rename {src => compiler/src}/astnodes.c (100%) rename {src => compiler/src}/builtins.c (100%) rename {src => compiler/src}/checker.c (100%) rename {src => compiler/src}/clone.c (100%) rename {src => compiler/src}/doc.c (100%) rename {src => compiler/src}/entities.c (100%) rename {src => compiler/src}/errors.c (100%) rename {src => compiler/src}/lex.c (100%) rename {src => compiler/src}/onyx.c (100%) rename {src => compiler/src}/onyxrun.c (100%) rename {src => compiler/src}/parser.c (100%) rename {src => compiler/src}/polymorph.h (100%) rename {src => compiler/src}/symres.c (100%) rename {src => compiler/src}/types.c (100%) rename {src => compiler/src}/utils.c (100%) rename {src => compiler/src}/wasm_emit.c (100%) rename {src => compiler/src}/wasm_intrinsics.h (100%) rename {src => compiler/src}/wasm_output.h (100%) rename {src => compiler/src}/wasm_runtime.c (100%) rename {src => compiler/src}/wasm_type_table.h (100%) create mode 100755 runtime/build.sh rename {src => runtime}/onyx_runtime.c (100%) create mode 100644 settings.sh rename {include => shared/include}/bh.h (100%) rename {include => shared/include}/onyx_library.h (100%) rename {include => shared/include}/small_windows.h (100%) rename {include => shared/include}/stb_ds.h (100%) diff --git a/build.sh b/build.sh index 5f529668..7b685b80 100755 --- a/build.sh +++ b/build.sh @@ -1,132 +1,38 @@ #!/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. -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)" - -# RUNTIME_LIBRARY="ovmwasm" -RUNTIME_LIBRARY="wasmer" - -# Comment this line if you do not want the above library installed, -# and do not with to have the Onyx runtime. -ENABLE_BUNDLING_WASM_RUNTIME=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" -WASMER_LIBRARY_DIR="$(pwd)/lib/linux_$ARCH/lib" - -# Where the intermediate build files go. -BUILD_DIR='./build' - -# Temporary flag -ENABLE_DEBUG_INFO=0 - - - +. ./settings.sh echo "Installing core libs" sudo mkdir -p "$CORE_DIR" sudo cp -r ./core/ "$CORE_DIR" -# 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/lib$RUNTIME_LIBRARY.so" ] || true; then + echo "Copying lib$RUNTIME_LIBRARY to $CORE_DIR/lib (first install)" + sudo mkdir -p "$CORE_DIR/lib" + sudo mkdir -p "$CORE_DIR/include" -C_FILES="onyx astnodes builtins checker clone doc entities errors lex parser symres types utils wasm_emit" -LIBS= -INCLUDES="-I./include" + sudo cp "$WASMER_LIBRARY_DIR/lib$RUNTIME_LIBRARY.so" "$CORE_DIR/lib/lib$RUNTIME_LIBRARY.so" -WARNINGS='-Wimplicit -Wmisleading-indentation -Wparentheses -Wsequence-point -Wreturn-type -Wshift-negative-value -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wmaybe-uninitialized -Wsign-compare -Wstrict-overflow -Wduplicated-branches -Wduplicated-cond -Wtrigraphs -Waddress -Wlogical-op' - -TARGET="./bin/onyx" -if [ "$1" = "debug" ]; then - FLAGS="$WARNINGS -g3" -else - FLAGS="$WARNINGS -O3" -fi - -if [ "$RUNTIME_LIBRARY" = "ovmwasm" ]; then - FLAGS="$FLAGS -DUSE_OVM_DEBUGGER" + sudo cp "shared/include/onyx_library.h" "$CORE_DIR/include/onyx_library.h" + sudo cp "$WASMER_INCLUDE_DIR/wasm.h" "$CORE_DIR/include/wasm.h" fi -if [ "$ENABLE_DEBUG_INFO" = "1" ]; then - FLAGS="$FLAGS -DENABLE_DEBUG_INFO" -fi - - -if [ ! -z "$ENABLE_BUNDLING_WASM_RUNTIME" ]; then - C_FILES="$C_FILES wasm_runtime" - FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER" - LIBS="$LIBS -L$CORE_DIR/lib -l$RUNTIME_LIBRARY -Wl,-rpath=$CORE_DIR/lib:./ -lpthread -ldl -lm" - INCLUDES="$INCLUDES -I$WASMER_INCLUDE_DIR" - - if [ ! -f "$CORE_DIR/lib/lib$RUNTIME_LIBRARY.so" ] || true; then - echo "Copying lib$RUNTIME_LIBRARY to $CORE_DIR/lib (first install)" - - sudo mkdir -p "$CORE_DIR/lib" - sudo mkdir -p "$CORE_DIR/include" - - sudo cp "$WASMER_LIBRARY_DIR/lib$RUNTIME_LIBRARY.so" "$CORE_DIR/lib/lib$RUNTIME_LIBRARY.so" - - sudo cp "include/onyx_library.h" "$CORE_DIR/include/onyx_library.h" - sudo cp "lib/common/include/wasm.h" "$CORE_DIR/include/wasm.h" - fi -fi - -mkdir -p "$BUILD_DIR" - -compile() { - for file in $C_FILES ; do - echo "Compiling $file.c" - $CC -o $BUILD_DIR/$file.o \ - $FLAGS \ - "-DCORE_INSTALLATION=\"$CORE_DIR\"" \ - -c src/$file.c \ - $INCLUDES $LIBS - done - - echo "Linking $TARGET" - $CC -o $TARGET $FLAGS $(for file in $C_FILES ; do printf "$BUILD_DIR/%s.o " $file ; done) $LIBS - - echo "Removing object files" - for file in $C_FILES ; do rm -f "$BUILD_DIR/$file".o 2>/dev/null ; done -} - -compile -echo "Installing onyx executable" -sudo mkdir -p "$BIN_DIR" -sudo cp ./bin/onyx "$BIN_DIR/onyx" - -if [ ! -z "$ENABLE_BUNDLING_WASM_RUNTIME" ]; then - C_FILES="onyxrun wasm_runtime" - TARGET="./bin/onyx-run" - - compile - echo "Installing onyxrun executable" - sudo cp ./bin/onyx-run "$BIN_DIR/onyx-run" +# This is a development feature to allow for quickly reinstalling core libraries +# without have to recompile the entire compiler +[ "$1" = "core" ] && exit 0 - $CC -shared -fpic -I include -I lib/common/include src/onyx_runtime.c -o onyx_runtime.so -lpthread - sudo mv "./onyx_runtime.so" "$CORE_DIR/lib/onyx_runtime.so" +sudo cp ./bin/onyx-pkg "$BIN_DIR/onyx-pkg" +sudo mkdir -p "$CORE_DIR/tools" +sudo cp ./scripts/onyx-pkg.onyx "$CORE_DIR/tools" +cd compiler +./build.sh +cd .. - sudo cp ./bin/onyx-pkg "$BIN_DIR/onyx-pkg" - sudo mkdir -p "$CORE_DIR/tools" - sudo cp ./scripts/onyx-pkg.onyx "$CORE_DIR/tools" -fi +cd runtime +./build.sh +cd .. # Otherwise the prompt ends on the same line printf "\n" diff --git a/compiler/build.sh b/compiler/build.sh new file mode 100755 index 00000000..2bf9a64f --- /dev/null +++ b/compiler/build.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +. ../settings.sh + +# Temporary flag +ENABLE_DEBUG_INFO=1 + +C_FILES="onyx astnodes builtins checker clone doc entities errors lex parser symres types utils wasm_emit wasm_runtime " +LIBS="-L$CORE_DIR/lib -l$RUNTIME_LIBRARY -Wl,-rpath=$CORE_DIR/lib:./ -lpthread -ldl -lm" +INCLUDES="-I./include -I../shared/include -I../lib/common/include" + +WARNINGS='-Wimplicit -Wmisleading-indentation -Wparentheses -Wsequence-point -Wreturn-type -Wshift-negative-value -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wmaybe-uninitialized -Wsign-compare -Wstrict-overflow -Wduplicated-branches -Wduplicated-cond -Wtrigraphs -Waddress -Wlogical-op' + +if [ "$1" = "debug" ]; then + FLAGS="$WARNINGS -g3" +else + FLAGS="$WARNINGS -O3" +fi + +if [ "$RUNTIME_LIBRARY" = "ovmwasm" ]; then + FLAGS="$FLAGS -DUSE_OVM_DEBUGGER" +fi + +if [ "$ENABLE_DEBUG_INFO" = "1" ]; then + FLAGS="$FLAGS -DENABLE_DEBUG_INFO" +fi + +FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER" + +sudo mkdir -p "$BIN_DIR" + +echo "Compiling onyx..." +$CC -o "../bin/onyx" \ + $FLAGS \ + "-DCORE_INSTALLATION=\"$CORE_DIR\"" \ + $INCLUDES \ + $(echo "$C_FILES" | sed 's/ /\n/g;s/\([a-zA-Z_0-9]*\)\n/src\/\1.c\n/g;s/\n/ /g') \ + $LIBS + +echo "Installing onyx executable" +sudo cp "../bin/onyx" "$BIN_DIR/onyx" + +C_FILES="onyxrun wasm_runtime " + +echo "Compiling onyx-run..." +$CC -o "../bin/onyx-run" \ + $FLAGS \ + "-DCORE_INSTALLATION=\"CORE_DIR\"" \ + $INCLUDES \ + $(echo "$C_FILES" | sed 's/ /\n/g;s/\([a-zA-Z_0-9]*\)\n/src\/\1.c\n/g;s/\n/ /g') \ + $LIBS + +echo "Installing onyx-run executable" +sudo cp "../bin/onyx-run" "$BIN_DIR/onyx-run" diff --git a/include/astnodes.h b/compiler/include/astnodes.h similarity index 100% rename from include/astnodes.h rename to compiler/include/astnodes.h diff --git a/include/doc.h b/compiler/include/doc.h similarity index 100% rename from include/doc.h rename to compiler/include/doc.h diff --git a/include/errors.h b/compiler/include/errors.h similarity index 100% rename from include/errors.h rename to compiler/include/errors.h diff --git a/include/lex.h b/compiler/include/lex.h similarity index 100% rename from include/lex.h rename to compiler/include/lex.h diff --git a/include/parser.h b/compiler/include/parser.h similarity index 100% rename from include/parser.h rename to compiler/include/parser.h diff --git a/include/types.h b/compiler/include/types.h similarity index 100% rename from include/types.h rename to compiler/include/types.h diff --git a/include/utils.h b/compiler/include/utils.h similarity index 100% rename from include/utils.h rename to compiler/include/utils.h diff --git a/include/wasm_emit.h b/compiler/include/wasm_emit.h similarity index 100% rename from include/wasm_emit.h rename to compiler/include/wasm_emit.h diff --git a/src/astnodes.c b/compiler/src/astnodes.c similarity index 100% rename from src/astnodes.c rename to compiler/src/astnodes.c diff --git a/src/builtins.c b/compiler/src/builtins.c similarity index 100% rename from src/builtins.c rename to compiler/src/builtins.c diff --git a/src/checker.c b/compiler/src/checker.c similarity index 100% rename from src/checker.c rename to compiler/src/checker.c diff --git a/src/clone.c b/compiler/src/clone.c similarity index 100% rename from src/clone.c rename to compiler/src/clone.c diff --git a/src/doc.c b/compiler/src/doc.c similarity index 100% rename from src/doc.c rename to compiler/src/doc.c diff --git a/src/entities.c b/compiler/src/entities.c similarity index 100% rename from src/entities.c rename to compiler/src/entities.c diff --git a/src/errors.c b/compiler/src/errors.c similarity index 100% rename from src/errors.c rename to compiler/src/errors.c diff --git a/src/lex.c b/compiler/src/lex.c similarity index 100% rename from src/lex.c rename to compiler/src/lex.c diff --git a/src/onyx.c b/compiler/src/onyx.c similarity index 100% rename from src/onyx.c rename to compiler/src/onyx.c diff --git a/src/onyxrun.c b/compiler/src/onyxrun.c similarity index 100% rename from src/onyxrun.c rename to compiler/src/onyxrun.c diff --git a/src/parser.c b/compiler/src/parser.c similarity index 100% rename from src/parser.c rename to compiler/src/parser.c diff --git a/src/polymorph.h b/compiler/src/polymorph.h similarity index 100% rename from src/polymorph.h rename to compiler/src/polymorph.h diff --git a/src/symres.c b/compiler/src/symres.c similarity index 100% rename from src/symres.c rename to compiler/src/symres.c diff --git a/src/types.c b/compiler/src/types.c similarity index 100% rename from src/types.c rename to compiler/src/types.c diff --git a/src/utils.c b/compiler/src/utils.c similarity index 100% rename from src/utils.c rename to compiler/src/utils.c diff --git a/src/wasm_emit.c b/compiler/src/wasm_emit.c similarity index 100% rename from src/wasm_emit.c rename to compiler/src/wasm_emit.c diff --git a/src/wasm_intrinsics.h b/compiler/src/wasm_intrinsics.h similarity index 100% rename from src/wasm_intrinsics.h rename to compiler/src/wasm_intrinsics.h diff --git a/src/wasm_output.h b/compiler/src/wasm_output.h similarity index 100% rename from src/wasm_output.h rename to compiler/src/wasm_output.h diff --git a/src/wasm_runtime.c b/compiler/src/wasm_runtime.c similarity index 100% rename from src/wasm_runtime.c rename to compiler/src/wasm_runtime.c diff --git a/src/wasm_type_table.h b/compiler/src/wasm_type_table.h similarity index 100% rename from src/wasm_type_table.h rename to compiler/src/wasm_type_table.h diff --git a/runtime/build.sh b/runtime/build.sh new file mode 100755 index 00000000..25cfb9ac --- /dev/null +++ b/runtime/build.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. ../settings.sh + +$CC -shared -fpic -w \ + -o ../bin/onyx_runtime.so \ + -I ../shared/include -I ../compiler/include -I ../lib/common/include \ + ./onyx_runtime.c \ + -lpthread + +echo "Installing onyx_runtime.so" +sudo mv "../bin/onyx_runtime.so" "$CORE_DIR/lib/onyx_runtime.so" diff --git a/src/onyx_runtime.c b/runtime/onyx_runtime.c similarity index 100% rename from src/onyx_runtime.c rename to runtime/onyx_runtime.c diff --git a/settings.sh b/settings.sh new file mode 100644 index 00000000..7ab78ec9 --- /dev/null +++ b/settings.sh @@ -0,0 +1,24 @@ + +# The base path for the installation. +# This is typcially /usr or /usr/local. +INSTALL_DIR="/usr" + +# Where the core libraries for Onyx will go. +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)" + +RUNTIME_LIBRARY="ovmwasm" +# RUNTIME_LIBRARY="wasmer" + +# 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" +WASMER_LIBRARY_DIR="$(pwd)/lib/linux_$ARCH/lib" diff --git a/include/bh.h b/shared/include/bh.h similarity index 100% rename from include/bh.h rename to shared/include/bh.h diff --git a/include/onyx_library.h b/shared/include/onyx_library.h similarity index 100% rename from include/onyx_library.h rename to shared/include/onyx_library.h diff --git a/include/small_windows.h b/shared/include/small_windows.h similarity index 100% rename from include/small_windows.h rename to shared/include/small_windows.h diff --git a/include/stb_ds.h b/shared/include/stb_ds.h similarity index 100% rename from include/stb_ds.h rename to shared/include/stb_ds.h -- 2.25.1