diff --git a/.gitignore b/.gitignore index 4b4b8ac48..afd55d07e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ build/current build/gba build/debug build/release +build/windows tags diff --git a/Makefile b/Makefile index 6f3bd1fa6..bbbcc17f8 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,8 @@ devenv: --name ${DEVENV} -t wombatant/devenv bash devenv-destroy: docker rm -f ${DEVENV} +devenv-shell: + docker exec -i --user $(shell id -u ${USER}) ${DEVENV} ls /usr/bin/x86_64-w64-mingw32-g++ native: ${ENV_RUN} rm -rf build/release @@ -39,6 +41,12 @@ native_debug: ${ENV_RUN} rm -f build/current ${ENV_RUN} ln -s debug build/current +windows: + ${ENV_RUN} rm -rf build/windows + ${ENV_RUN} ./scripts/setup_build windows + ${ENV_RUN} rm -f build/current + ${ENV_RUN} ln -s windows build/current + gba: ${ENV_RUN} rm -rf build/gba ${ENV_RUN} ./scripts/setup_build_gba diff --git a/build/Makefile b/build/Makefile index dc0c5bb77..1298dd119 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,4 +1,4 @@ -all: gba_build native_build native_debug_build +all: gba_build native_build native_debug_build windows_build gba_build: @if [ -d gba ]; then \ @@ -14,3 +14,8 @@ native_debug_build: @if [ -d debug ]; then \ make -C debug ${ARGS}; \ fi + +windows_build: + @if [ -d windows ]; then \ + make -C windows ${ARGS}; \ + fi diff --git a/cmake/Modules/GBA.cmake b/cmake/Modules/GBA.cmake index a3f82eb9d..6440e2285 100644 --- a/cmake/Modules/GBA.cmake +++ b/cmake/Modules/GBA.cmake @@ -39,5 +39,3 @@ find_path(GBA_INCLUDE_DIR gba.h include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GBA DEFAULT_MSG GBA_LIBRARY) - -set(CMAKE_INSTALL_PREFIX ${DEVKITARM}) diff --git a/cmake/Modules/Mingw.cmake b/cmake/Modules/Mingw.cmake new file mode 100644 index 000000000..bf1d08f16 --- /dev/null +++ b/cmake/Modules/Mingw.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) + +# cross compilers to use for C and C++ +set(CMAKE_C_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_RC_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-windres) + +# target environment on the build host system +# set 1st to dir with the cross compiler's C/C++ headers/libs +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) + +# modify default behavior of FIND_XXX() commands to +# search for headers/libs in the target environment and +# search for programs in the build host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/scripts/setup_build b/scripts/setup_build index ac3924bce..ed586683e 100755 --- a/scripts/setup_build +++ b/scripts/setup_build @@ -1,8 +1,18 @@ #! /usr/bin/env bash project=$(pwd)/ -buildDir="build/release" + +TARGET=$1 + +if [[ $TARGET == windows ]]; then + toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake" + buildDir="build/windows" +else + buildDir="build/release" +fi mkdir -p $buildDir pushd $buildDir -cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release $project +cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release \ + $toolchain \ + $project popd diff --git a/src/ox/std/types.hpp b/src/ox/std/types.hpp index bc4a2607e..d64634d9a 100644 --- a/src/ox/std/types.hpp +++ b/src/ox/std/types.hpp @@ -14,7 +14,7 @@ typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned int uint32_t; typedef unsigned uint_t; -#if defined(_MSC_VER) || defined(__APPLE__) +#if defined(_WIN32) || defined(__APPLE__) typedef long long int64_t; typedef unsigned long long uint64_t; #else