fixed bugs on windows

This commit is contained in:
Timerix 2024-08-10 00:51:34 +03:00
parent 2710e5fc9d
commit 1859b432df
6 changed files with 46 additions and 15 deletions

View File

@ -17,6 +17,14 @@ git clone --recurse-submodules https://timerix.ddns.net:3322/Timerix/ougge.git
Location of the headers can be found by `pkg-config --cflags --libs sdl2`. Location of the headers can be found by `pkg-config --cflags --libs sdl2`.
Mingw installs SDL2 headers to `/mingw64/include/SDL2`. Mingw installs SDL2 headers to `/mingw64/include/SDL2`.
5. Install [mono](https://github.com/mono/mono). 5. Install [mono](https://github.com/mono/mono).
**Windows:**
1. Install mono from official website
2. Copy `*.dll` files from `C:\Program Files\Mono\bin` to `dependencies/precompiled/`
3. Copy `config` from `C:\Program Files\Mono\etc\mono` to `dependencies/precompiled/mono-libs` and rename to `config.xml`
4. Copy `mscorlib.dll` from `C:\Program Files\Mono\lib\mono\4.5\` to `dependencies/precompiled/mono-libs`
**Linux:**
1. Download and extract [sources](https://download.mono-project.com/sources/mono/index.html) 1. Download and extract [sources](https://download.mono-project.com/sources/mono/index.html)
```sh ```sh
mkdir mono mkdir mono
@ -42,6 +50,7 @@ git clone --recurse-submodules https://timerix.ddns.net:3322/Timerix/ougge.git
cd .. cd ..
cbuild get_mono_files_from=mono/mono_prefix cbuild get_mono_files_from=mono/mono_prefix
``` ```
5. Now you can delete `mono` directory and save 3 gigabytes of disk space :3
7. Compile the program 7. Compile the program
```sh ```sh
cbuild build_exec_dbg cbuild build_exec_dbg

View File

@ -11,12 +11,12 @@ PRESERVE_OUT_DIRECTORY_STRUCTURE=true
# will be copied tp project $OUTDIR # will be copied tp project $OUTDIR
case $OS in case $OS in
WINDOWS) WINDOWS)
DEP_DYNAMIC_OUT_FILES="$(find dependencies/precompiled -name '*.dll' | sed 's,dependencies/precompiled/,,')" DEP_DYNAMIC_OUT_FILES=$(find dependencies/precompiled -maxdepth 1 -name '*.dll' | sed 's,dependencies/precompiled/,,')
DEP_OTHER_OUT_FILES="" DEP_OTHER_OUT_FILES="mono-libs/mscorlib.dll mono-libs/config.xml"
# DEP_STATIC_OUT_FILES+=" mono-libs/libmono-static-sgen.lib"
;; ;;
LINUX) 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" DEP_OTHER_OUT_FILES="mono-libs/mscorlib.dll mono-libs/config.xml"
;; ;;
*) *)

View File

@ -58,7 +58,7 @@ case "$TASK" in
# -fprofile-use enables compiler to use profiling info files to optimize executable # -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 # -fprofile-prefix-path sets path where profiling info about objects are be saved
# -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code # -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code
C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" C_ARGS="-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" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
@ -67,16 +67,16 @@ case "$TASK" in
;; ;;
# creates executable with debug info and no optimizations # creates executable with debug info and no optimizations
build_exec_dbg) build_exec_dbg)
C_ARGS="-rdynamic -O0 -g3" C_ARGS="-O0 -g3"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-rpath=mono-libs" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
;; ;;
# creates shared library # creates shared library
build_shared_lib) build_shared_lib)
C_ARGS="-rdynamic -O2 -fpic -flto -shared" C_ARGS="-O2 -fpic -flto -shared"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
@ -85,7 +85,7 @@ case "$TASK" in
;; ;;
# creates shared library with debug symbols and no optimizations # creates shared library with debug symbols and no optimizations
build_shared_lib_dbg) build_shared_lib_dbg)
C_ARGS="-rdynamic -O0 -g3 -fpic -shared" C_ARGS="-O0 -g3 -fpic -shared"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
@ -94,7 +94,7 @@ case "$TASK" in
;; ;;
# creates static library # creates static library
build_static_lib) build_static_lib)
C_ARGS="-rdynamic -O2 -fpic -fdata-sections -ffunction-sections" C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh 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 # creates static library with debug symbols and no optimizations
build_static_lib_dbg) build_static_lib_dbg)
C_ARGS="-rdynamic -O0 -g3" C_ARGS="-O0 -g3"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh 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) # -pg adds code to executable, that generates file containing function call info (gmon.out)
# -fprofile-generate generates executable with profiling code # -fprofile-generate generates executable with profiling code
# -fprofile-prefix-path sets path where profiling info about objects will be saved # -fprofile-prefix-path sets path where profiling info about objects will be saved
C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
@ -139,7 +139,7 @@ case "$TASK" in
gprof) gprof)
OUTDIR="$OUTDIR/gprof" OUTDIR="$OUTDIR/gprof"
# -pg adds code to executable, that generates file containing function call info (gmon.out) # -pg adds code to executable, that generates file containing function call info (gmon.out)
C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin -pg" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
@ -153,7 +153,7 @@ case "$TASK" in
callgrind) callgrind)
OUTDIR="$OUTDIR/callgrind" OUTDIR="$OUTDIR/callgrind"
# -pg adds code to executable, that generates file containing function call info (gmon.out) # -pg adds code to executable, that generates file containing function call info (gmon.out)
C_ARGS="-rdynamic -O2 -flto=auto -fuse-linker-plugin" C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh 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 # compiles executable with sanitizers and executes it to find errors and warnings
sanitize) sanitize)
OUTDIR="$OUTDIR/sanitize" OUTDIR="$OUTDIR/sanitize"
C_ARGS="-rdynamic -O0 -g3 -fsanitize=undefined,address" C_ARGS="-O0 -g3 -fsanitize=undefined,address"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh

View File

@ -6,6 +6,7 @@
#include "../format.hpp" #include "../format.hpp"
#include "../Resources/fonts.hpp" #include "../Resources/fonts.hpp"
#include "../Resources/textures.hpp" #include "../Resources/textures.hpp"
#include "../math.hpp"
namespace ougge::GUI { namespace ougge::GUI {

View File

@ -3,6 +3,22 @@
#include "std.hpp" #include "std.hpp"
#include <cmath> #include <cmath>
#ifndef M_PI
#define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074
#define M_LOG10E 0.43429448190325182765
#define M_LN2 0.69314718055994530942
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.78539816339744830962
#define M_1_PI 0.31830988618379067154
#define M_2_PI 0.63661977236758134308
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.70710678118654752440
#endif
struct Vec2 { struct Vec2 {
f32 x = 0, y = 0; f32 x = 0, y = 0;
}; };

View File

@ -32,6 +32,11 @@ case "$OS" in
mv -v "$l" "dependencies/precompiled/mono-libs/$soname_without_version" mv -v "$l" "dependencies/precompiled/mono-libs/$soname_without_version"
done done
myprint "${BLUE}stripping debug symbols from mono shared libraries"
for l in $(find "dependencies/precompiled/mono-libs" -name '*.so') ; do
strip -g "$l"
done
# copy mono c# libraries # copy mono c# libraries
managed_libraries="mscorlib.dll" managed_libraries="mscorlib.dll"
myprint "${BLUE}copying mono managed libraries" myprint "${BLUE}copying mono managed libraries"