diff --git a/.gitignore b/.gitignore index 625b1dc..edc45cb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ temp/ logs/ log/ *.log +mono/ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index b198f99..f29000d 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -7,6 +7,7 @@ "DEBUG=1" ], "includePath": [ + "dependencies/include", "dependencies/include/SDL2", "dependencies/imgui", "${default}" diff --git a/README.md b/README.md index 2a0fd14..ac4047b 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,37 @@ git clone --recurse-submodules https://timerix.ddns.net:3322/Timerix/ougge.git - On **Windows** download pre-built dll's from github releases and put them into `dependencies/precompiled/`. 4. Symlink SDL headers directory to `dependencies/include`. ```sh - cd ../ougge ln -s SDL2_HEADERS_DIRECTORY_ABSOLUTE_PATH -T dependencies/include/SDL2 ``` Location of the headers can be found by `pkg-config --cflags --libs sdl2`. Mingw installs SDL2 headers to `/mingw64/include/SDL2`. -5. Compile the program +5. Install [mono](https://github.com/mono/mono). + 1. Download and extract [sources](https://download.mono-project.com/sources/mono/index.html) + ```sh + mkdir mono + cd mono + wget https://download.mono-project.com/sources/mono/mono-6.12.0.199.tar.xz + tar xJf mono-6.12.0.199.tar.xz + mv mono-6.12.0.199/* ./ + rm -r mono-6.12.0.199 + rm mono-6.12.0.199.tar.xz + ``` + 2. Install `libz autoconf automake libtool gettext cmake python3 curl` and + 3. Build mono. If something doesn't work, read [documentation](https://www.mono-project.com/docs/compiling-mono/) + ```sh + mkdir -p mono_prefix + ./autogen.sh --prefix=$(realpath mono_prefix) --disable-boehm + make get-monolite-latest + make -j8 + make install + ``` + 3. Install `patchelf` + 4. Install mono files in project. + ```sh + cd .. + cbuild get_mono_files_from=mono/mono_prefix + ``` +7. Compile the program ```sh cbuild build_exec_dbg ``` diff --git a/dependencies/precompiled.config b/dependencies/precompiled.config index 352b745..6733da2 100644 --- a/dependencies/precompiled.config +++ b/dependencies/precompiled.config @@ -7,13 +7,17 @@ DEP_POST_BUILD_COMMAND='' DEP_CLEAN_COMMAND='' # won't be copied to project $OUTDIR DEP_STATIC_OUT_FILES=$(find dependencies/precompiled -name '*.a' | sed 's,dependencies/precompiled/,,') +PRESERVE_OUT_DIRECTORY_STRUCTURE=true # will be copied tp project $OUTDIR case $OS in WINDOWS) - DEP_DYNAMIC_OUT_FILES=$(find dependencies/precompiled -name '*.dll' | sed 's,dependencies/precompiled/,,') + DEP_DYNAMIC_OUT_FILES="$(find dependencies/precompiled -name '*.dll' | sed 's,dependencies/precompiled/,,')" + DEP_OTHER_OUT_FILES="" ;; LINUX) - DEP_DYNAMIC_OUT_FILES=$(find dependencies/precompiled -name '*.so' | sed 's,dependencies/precompiled/,,') + DEP_DYNAMIC_OUT_FILES="$(find dependencies/precompiled -name '*.so' | sed 's,dependencies/precompiled/,,') + $(find dependencies/precompiled -name '*.so.*' | sed 's,dependencies/precompiled/,,')" + DEP_OTHER_OUT_FILES="mono-libs/mscorlib.dll mono-libs/config.xml" ;; *) error "operating system $OS has no configuration variants" diff --git a/project.config b/project.config index ee7dc2b..9795e05 100644 --- a/project.config +++ b/project.config @@ -1,5 +1,5 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.1.2 +CBUILD_VERSION=2.1.4 CONFIG_VERSION=1 PROJECT="ougge" @@ -28,7 +28,7 @@ OUTDIR="bin" STATIC_LIB_FILE="lib$PROJECT.a" # header include directories -INCLUDE="-I./dependencies/imgui -I./dependencies/include/SDL2" +INCLUDE="-I./dependencies/imgui -I./dependencies/include -I./dependencies/include/SDL2" # OS-specific options case "$OS" in @@ -58,7 +58,7 @@ case "$TASK" in # -fprofile-use enables compiler to use profiling info files to optimize executable # -fprofile-prefix-path sets path where profiling info about objects are be saved # -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code - C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" + C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" PRE_TASK_SCRIPT= @@ -67,16 +67,16 @@ case "$TASK" in ;; # creates executable with debug info and no optimizations build_exec_dbg) - C_ARGS="-O0 -g3" + C_ARGS="-rdynamic -O0 -g3" CPP_ARGS="$C_ARGS" - LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" + LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-rpath=mono-libs" PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_exec.sh POST_TASK_SCRIPT= ;; # creates shared library build_shared_lib) - C_ARGS="-O2 -fpic -flto -shared" + C_ARGS="-rdynamic -O2 -fpic -flto -shared" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" PRE_TASK_SCRIPT= @@ -85,7 +85,7 @@ case "$TASK" in ;; # creates shared library with debug symbols and no optimizations build_shared_lib_dbg) - C_ARGS="-O0 -g3 -fpic -shared" + C_ARGS="-rdynamic -O0 -g3 -fpic -shared" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" PRE_TASK_SCRIPT= @@ -94,7 +94,7 @@ case "$TASK" in ;; # creates static library build_static_lib) - C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections" + C_ARGS="-rdynamic -O2 -fpic -fdata-sections -ffunction-sections" CPP_ARGS="$C_ARGS" PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh @@ -102,7 +102,7 @@ case "$TASK" in ;; # creates static library with debug symbols and no optimizations build_static_lib_dbg) - C_ARGS="-O0 -g3" + C_ARGS="-rdynamic -O0 -g3" CPP_ARGS="$C_ARGS" PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh @@ -126,7 +126,7 @@ case "$TASK" in # -pg adds code to executable, that generates file containing function call info (gmon.out) # -fprofile-generate generates executable with profiling code # -fprofile-prefix-path sets path where profiling info about objects will be saved - C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" + C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh @@ -139,7 +139,7 @@ case "$TASK" in gprof) OUTDIR="$OUTDIR/gprof" # -pg adds code to executable, that generates file containing function call info (gmon.out) - C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg" + C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin -pg" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh @@ -153,7 +153,7 @@ case "$TASK" in callgrind) OUTDIR="$OUTDIR/callgrind" # -pg adds code to executable, that generates file containing function call info (gmon.out) - C_ARGS="-O2 -flto=auto -fuse-linker-plugin" + C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh @@ -163,7 +163,7 @@ case "$TASK" in # compiles executable with sanitizers and executes it to find errors and warnings sanitize) OUTDIR="$OUTDIR/sanitize" - C_ARGS="-O0 -g3 -fsanitize=undefined,address" + C_ARGS="-rdynamic -O0 -g3 -fsanitize=undefined,address" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh @@ -176,6 +176,9 @@ case "$TASK" in rebuild_dependencies) TASK_SCRIPT=cbuild/default_tasks/rebuild_dependencies.sh ;; + get_mono_files_from) + TASK_SCRIPT=tasks/get_mono_files_from.sh + ;; # deletes generated files clean) TASK_SCRIPT=cbuild/default_tasks/clean.sh diff --git a/src/main.cpp b/src/main.cpp index c0393ce..449740b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,9 @@ #include "Game/Scene.hpp" #include "format.hpp" #include "exceptions.hpp" +#include +#include +#include using namespace ougge; @@ -15,6 +18,26 @@ void update(f64 deltaTime){ int main(int argc, const char** argv){ try { Resources::init(); + mono_set_dirs("mono-libs", "mono-libs"); + mono_set_assemblies_path("mono-libs"); + mono_config_parse("mono-libs/config.xml"); + std::cout<<"mono_root_dir: "<