diff --git a/.github/workflows/ecode-nightly.yml b/.github/workflows/ecode-nightly.yml index 22ee2b89c..022d64d67 100644 --- a/.github/workflows/ecode-nightly.yml +++ b/.github/workflows/ecode-nightly.yml @@ -212,6 +212,47 @@ jobs: files: | projects/mingw32/ecode/ecode-windows-${{ env.INSTALL_REF }}-${{ env.RARCH }}.zip + build_windows_arm64_cross: + name: Windows arm64 Nightly + needs: release + strategy: + matrix: + config: + - compiler: default + arch: arm64 + container: ubuntu-22.04 + runs-on: ${{ matrix.config.container }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: { fetch-depth: 0, submodules: 'recursive' } + - name: Set Environment Variables + run: | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + echo "INSTALL_REF=${{ needs.release.outputs.version }}" >> "$GITHUB_ENV" + - name: Update Packages + run: | + sudo add-apt-repository -y universe + sudo add-apt-repository -y multiverse + sudo apt-get update + - name: Install dependencies + run: | + sudo apt-get install -y libfuse2 fuse + wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz + tar xvzf premake-5.0.0-beta2-linux.tar.gz + - name: Build ecode + run: | + bash projects/scripts/patch_commit_number.sh + bash projects/mingw32/ecode/build.app.sh --arch=arm64 --version ${{ env.INSTALL_REF }} + - name: Upload Files + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.release.outputs.version }} + draft: false + prerelease: true + files: | + projects/mingw32/ecode/ecode-windows-${{ env.INSTALL_REF }}-arm64.zip + build_macos: name: macOS arm64 Nightly needs: release diff --git a/.gitignore b/.gitignore index 1f455fdfb..b3e0fce0b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ projects/android-project-ant/data projects/android-project-ant/gen projects/android-project-ant/assets projects/android-project-ant/libs +projects/mingw32/llvm* src/examples/strobe src/thirdparty/SDL2-* *.dll diff --git a/premake5.lua b/premake5.lua index b9d676d0a..99019ed61 100644 --- a/premake5.lua +++ b/premake5.lua @@ -27,6 +27,7 @@ newoption { { "SDL2", "SDL2" }, } } +newoption { trigger = "arch", description = "Used exclusively to indicate premake the architecture of the dependencies that need to be downloaded" } function get_dll_extension() if os.target() == "macosx" then @@ -155,6 +156,7 @@ remote_sdl2_version = "SDL2-2.30.8" remote_sdl2_devel_src_url = "https://libsdl.org/release/SDL2-2.30.8.zip" remote_sdl2_devel_vc_url = "https://www.libsdl.org/release/SDL2-devel-2.30.8-VC.zip" remote_sdl2_devel_mingw_url = "https://www.libsdl.org/release/SDL2-devel-2.30.8-mingw.zip" +remote_sdl2_arm64_cross_tools_path = "/usr/local/cross-tools/aarch64-w64-mingw32" function incdirs( dirs ) if is_xcode() then @@ -189,7 +191,7 @@ function copy_sdl() if _OPTIONS["windows-vc-build"] then os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/lib/x64/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/SDL2.dll" ) os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/lib/x64/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/unit_tests/SDL2.dll" ) - elseif _OPTIONS["windows-mingw-build"] then + elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["arch"] ~= "arm64" then os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/bin/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/SDL2.dll" ) os.copyfile( _MAIN_SCRIPT_DIR .. "/src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/bin/SDL2.dll", _MAIN_SCRIPT_DIR .. "/bin/unit_tests/SDL2.dll" ) end @@ -216,9 +218,11 @@ function download_and_extract_dependencies() if _OPTIONS["windows-vc-build"] then download_and_extract_sdl(remote_sdl2_devel_vc_url) copy_sdl() - elseif _OPTIONS["windows-mingw-build"] then + elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["arch"] ~= "arm64" then download_and_extract_sdl(remote_sdl2_devel_mingw_url) copy_sdl() + elseif _OPTIONS["windows-mingw-build"] and _OPTIONS["arch"] == "arm64" then + download_and_extract_sdl(remote_sdl2_devel_src_url) elseif os.istarget("ios") then download_and_extract_sdl(remote_sdl2_devel_src_url) end @@ -230,7 +234,9 @@ function build_arch_configuration() buildoptions { "-D__USE_MINGW_ANSI_STDIO=1 -B /usr/bin/i686-w64-mingw32-" } filter {"architecture:x86_64", "options:cc=mingw"} - buildoptions { "-D__USE_MINGW_ANSI_STDIO=1 -B /usr/bin/x86_64-w64-mingw32-" } + if _OPTIONS["arch"] ~= "arm64" then + buildoptions { "-D__USE_MINGW_ANSI_STDIO=1 -B /usr/bin/x86_64-w64-mingw32-" } + end filter {} end @@ -441,7 +447,12 @@ function build_link_configuration( package_name, use_ee_icon ) syslibdirs { "src/thirdparty/" .. remote_sdl2_version .."/i686-w64-mingw32/lib/", "/usr/i686-w64-mingw32/sys-root/mingw/lib/" } filter { "options:windows-mingw-build", "architecture:x86_64" } - syslibdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/lib/", "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/" } + if _OPTIONS["arch"] ~= "arm64" then + syslibdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/lib/", "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/" } + end + + filter { "options:windows-mingw-build", "options:arch=arm64" } + syslibdirs { remote_sdl2_arm64_cross_tools_path.. "/lib/" } filter "system:emscripten" targetname ( package_name .. extension ) @@ -811,7 +822,12 @@ function build_eepp( build_name ) incdirs { "src/thirdparty/" .. remote_sdl2_version .."/i686-w64-mingw32/include/" } filter { "options:windows-mingw-build", "architecture:x86_64" } - incdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/include/" } + if _OPTIONS["arch"] ~= "arm64" then + incdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/include/" } + end + + filter { "options:windows-mingw-build", "options:arch=arm64" } + incdirs { remote_sdl2_arm64_cross_tools_path .. "/include/" } filter "action:vs*" incdirs { "src/thirdparty/libzip/vs" } @@ -1051,7 +1067,6 @@ workspace "eepp" buildoptions { "/TP" } filter "action:not vs*" language "C" - filter {} project "jpeg-compressor-static" kind "StaticLib" @@ -1078,10 +1093,13 @@ workspace "eepp" filter "options:windows-vc-build" incdirs { "src/thirdparty/" .. remote_sdl2_version .. "/include" } filter { "options:windows-mingw-build", "architecture:x86" } - incdirs { "src/thirdparty/" .. remote_sdl2_version .."/i686-w64-mingw32/include/" } + incdirs { "src/thirdparty/" .. remote_sdl2_version .."/i686-w64-mingw32/include/" } filter { "options:windows-mingw-build", "architecture:x86_64" } - incdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/include/" } - filter {} + if _OPTIONS["arch"] ~= "arm64" then + incdirs { "src/thirdparty/" .. remote_sdl2_version .."/x86_64-w64-mingw32/include/" } + end + filter { "options:windows-mingw-build", "options:arch=arm64" } + incdirs { remote_sdl2_arm64_cross_tools_path .."/include/" } project "efsw-static" kind "StaticLib" @@ -1128,7 +1146,6 @@ workspace "eepp" } filter "system:not windows" files { "src/thirdparty/efsw/src/efsw/platform/posix/*.cpp" } - filter {} project "eepp-maps-static" kind "StaticLib" @@ -1144,7 +1161,6 @@ workspace "eepp" target_dir_lib("") filter "action:not vs*" buildoptions { "-Wall" } - filter {} project "eepp-maps" kind "SharedLib" @@ -1159,7 +1175,6 @@ workspace "eepp" target_dir_lib("") filter "action:not vs*" buildoptions { "-Wall" } - filter {} project "eepp-physics-static" kind "StaticLib" @@ -1175,7 +1190,6 @@ workspace "eepp" target_dir_lib("") filter "action:not vs*" buildoptions { "-Wall" } - filter {} project "eepp-physics" kind "SharedLib" @@ -1190,7 +1204,6 @@ workspace "eepp" target_dir_lib("") filter "action:not vs*" buildoptions { "-Wall" } - filter {} project "eterm-static" kind "StaticLib" @@ -1210,7 +1223,6 @@ workspace "eepp" buildoptions { "-Wall" } filter { "action:export-compile-commands", "system:macosx" } buildoptions { "-std=c++17" } - filter {} -- Library if not _OPTIONS["disable-static-build"] then @@ -1352,7 +1364,6 @@ workspace "eepp" links { "CoreFoundation.framework", "CoreServices.framework" } filter { "system:not windows", "system:not haiku" } links { "pthread" } - filter {} if os.istarget("macosx") then project "ecode-macos-helper-static" @@ -1409,7 +1420,6 @@ workspace "eepp" links { "bsd" } filter "system:bsd" links { "util" } - filter {} project "eterm" set_kind() @@ -1429,7 +1439,6 @@ workspace "eepp" links { "util" } filter "system:haiku" links { "bsd" } - filter {} project "eepp-texturepacker" kind "ConsoleApp" diff --git a/projects/mingw32/build_sdl2.sh b/projects/mingw32/build_sdl2.sh new file mode 100644 index 000000000..cf0e66258 --- /dev/null +++ b/projects/mingw32/build_sdl2.sh @@ -0,0 +1,46 @@ +#!/bin/bash +cd "$(dirname "$0")" || exit + +ARCH=x86_64 +for i in "$@"; do + case $i in + --arch=*) + ARCH="${i#*=}" + shift + ;; + *) + ;; + esac +done + +uname -a + +if [[ "$ARCH" == "arm64" ]]; then +echo "Building SDL2 for arch $ARCH" +HOST="--host=aarch64-w64-mingw32" + +if [ ! -f "/usr/local/cross-tools/aarch64-w64-mingw32/bin/SDL2.dll" ]; then +echo "SDL2 found in cross-tools folder" +# exit 0 +fi + +else +echo "Building SDL2 for arch $(uname -m)" +HOST= +fi + +SDLVER=$(grep "remote_sdl2_version =" ../../premake5.lua | awk '{print $3}' | tr -d '"') + +echo "SDL2 version $SDLVER" +echo "$PATH" + +cd "../../src/thirdparty/$SDLVER/" || exit 1 + +echo "SDL2 running autogen" +./autogen.sh || exit 1 + +echo "SDL2 running configure" +./configure $HOST || exit 1 + +echo "SDL2 make..." +sudo PATH="$PATH" make -j"$(nproc)" install || exit 1 diff --git a/projects/mingw32/ecode/build.app.sh b/projects/mingw32/ecode/build.app.sh index 42785ca3d..4c558fe5a 100755 --- a/projects/mingw32/ecode/build.app.sh +++ b/projects/mingw32/ecode/build.app.sh @@ -14,11 +14,11 @@ for i in "$@"; do shift shift ;; - arch=*) + --arch=*) ARCH_CONFIG="${i#*=}" shift ;; - buildtype=*) + --buildtype=*) BUILDTYPE_CONFIG="${i#*=}" shift ;; @@ -34,16 +34,25 @@ fi if [[ "$ARCH_CONFIG" == "x86" ]]; then ARCH=x86 ARCHI=i686 +elif [[ "$ARCH_CONFIG" == "arm64" ]]; then + ARCH=arm64 + ARCHI=arm64 fi -../make.sh -e config="$BUILDTYPE"_"$ARCH" -j"$(nproc)" ecode +../make.sh -e config="$BUILDTYPE"_"$ARCH" -j"$(nproc)" ecode || exit SDLVER=$(grep "remote_sdl2_version =" ../../../premake5.lua | awk '{print $3}' | tr -d '"') rm -rf ./ecode mkdir -p ecode/assets cp ../../../bin/ecode.exe ecode/ cp ../../../bin/eepp.dll ecode/ + +if [[ "$ARCH_CONFIG" == "arm64" ]]; then +cp "/usr/local/cross-tools/aarch64-w64-mingw32/bin/SDL2.dll" ecode/ +else cp ../../../src/thirdparty/"$SDLVER"/$ARCHI-w64-mingw32/bin/SDL2.dll ecode/ +fi + mkdir -p ecode/assets/colorschemes mkdir -p ecode/assets/fonts mkdir -p ecode/assets/i18n diff --git a/projects/mingw32/make.sh b/projects/mingw32/make.sh index 3facded68..7d4efff06 100755 --- a/projects/mingw32/make.sh +++ b/projects/mingw32/make.sh @@ -6,34 +6,73 @@ for i in "$@"; do case $i in config=*) CONFIG="${i#*=}" - shift ;; *) ;; esac done +PREMAKE5_ARCH= if [[ "$CONFIG" == *"x86_64"* ]]; then ARCH=64 +elif [[ "$CONFIG" == *"arm64"* && "$(uname -m)" == "x86_64" ]]; then + LLVM_MINGW_V="20241015" + URL="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_MINGW_V/llvm-mingw-$LLVM_MINGW_V-ucrt-ubuntu-20.04-x86_64.tar.xz" + FILE_NAME="llvm-mingw-$LLVM_MINGW_V-ucrt-ubuntu-20.04-x86_64" + TAR_FILE_NAME="$FILE_NAME.tar.xz" + RENAMED_FOLDER="llvm-mingw" + BIN_PATH="$(pwd)/$RENAMED_FOLDER/bin" + + if [[ ! -f "$TAR_FILE_NAME" ]]; then + echo "Downloading $TAR_FILE_NAME..." + curl -LO "$URL" || { echo "Download failed!"; exit 1; } + else + echo "$TAR_FILE_NAME already exists. Skipping download." + fi + + if [[ ! -d "$RENAMED_FOLDER" ]]; then + echo "Extracting $TAR_FILE_NAME..." + tar -xf "$TAR_FILE_NAME" || { echo "Extraction failed!"; exit 1; } + mv "$FILE_NAME" "$RENAMED_FOLDER" + else + echo "$RENAMED_FOLDER directory already exists. Skipping extraction." + fi + + + export PATH="$PATH:$BIN_PATH" + export CC="aarch64-w64-mingw32-gcc" + export CXX="aarch64-w64-mingw32-g++" + export AR="aarch64-w64-mingw32-ar" + echo "Added $BIN_PATH to PATH." + + PREMAKE5_ARCH="--arch=arm64" fi +PREMAKE5_ARGS="--file=../../premake5.lua --os=windows --cc=mingw --windows-mingw-build $PREMAKE5_ARCH gmake2" + if command -v premake5 &> /dev/null then - premake5 --file=../../premake5.lua --os=windows --cc=mingw --windows-mingw-build gmake2 + premake5 $PREMAKE5_ARGS elif [ -f ../../premake5 ]; then - ../../premake5 --file=../../premake5.lua --os=windows --cc=mingw --windows-mingw-build gmake2 + ../../premake5 $PREMAKE5_ARGS else - echo "Neither premake5 nor premake4 is available. Please install one." + echo "premake5 is not available. Please install one." exit 1 fi +if [[ "$CONFIG" == *"arm64"* ]]; then +bash ./build_sdl2.sh --arch=arm64 || exit 1 +else +export CC=x86_64-w64-mingw32-gcc-posix +export CXX=x86_64-w64-mingw32-g++-posix +fi + cd ../../make/windows/ || exit if command -v mingw"$ARCH"-make &> /dev/null then mingw"$ARCH"-make "$@" else - export CC=x86_64-w64-mingw32-gcc-posix - export CXX=x86_64-w64-mingw32-g++-posix + # Use x86_64 or arm64 toolchain based on CONFIG make "$@" fi