diff --git a/.github/workflows/libdmdutil.yml b/.github/workflows/libdmdutil.yml index 9e2d74bb..cf96f59a 100644 --- a/.github/workflows/libdmdutil.yml +++ b/.github/workflows/libdmdutil.yml @@ -3,6 +3,9 @@ on: push: pull_request: +permissions: + contents: write + defaults: run: shell: bash @@ -14,7 +17,7 @@ jobs: outputs: tag: ${{ steps.version.outputs.tag }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: 0 - id: version @@ -45,6 +48,7 @@ jobs: include: - { os: windows-2025, platform: win, arch: x64 } - { os: windows-2025, platform: win, arch: x86 } + - { os: windows-2025, platform: win-mingw, arch: x64 } - { os: macos-15, platform: macos, arch: arm64 } - { os: macos-15, platform: macos, arch: x64 } - { os: ubuntu-24.04, platform: linux, arch: x64 } @@ -54,168 +58,284 @@ jobs: - { os: macos-15, platform: ios-simulator, arch: arm64 } - { os: macos-15, platform: tvos, arch: arm64 } steps: - - uses: actions/checkout@v4 - - if: (matrix.os == 'windows-2025') - name: Add msbuild to path (win runner) + - uses: actions/checkout@v6 + # + # install dependencies + # + - if: (matrix.platform == 'win') uses: microsoft/setup-msbuild@v2 - - if: (matrix.os == 'macos-15') - name: Add autoconf and automake (mac runner) + - if: (matrix.platform == 'win') run: | - brew install autoconf automake libtool + if [[ "${{ matrix.arch }}" == "x64" ]]; then + /c/msys64/usr/bin/bash.exe -l -c "pacman -S --noconfirm \ + make diffutils \ + mingw-w64-ucrt-x86_64-gcc \ + mingw-w64-ucrt-x86_64-libwinpthread \ + mingw-w64-ucrt-x86_64-cmake" + else + /c/msys64/usr/bin/bash.exe -l -c "pacman -S --noconfirm \ + make diffutils \ + mingw-w64-i686-gcc \ + mingw-w64-i686-libwinpthread \ + mingw-w64-i686-cmake" + fi + - if: (matrix.platform == 'win-mingw') + run: | + /c/msys64/usr/bin/bash.exe -l -c "pacman -S --noconfirm \ + make diffutils autoconf automake libtool \ + mingw-w64-ucrt-x86_64-gcc \ + mingw-w64-ucrt-x86_64-libwinpthread \ + mingw-w64-ucrt-x86_64-cmake" + - if: (matrix.platform == 'macos' || matrix.platform == 'ios' || matrix.platform == 'ios-simulator' || matrix.platform == 'tvos') + run: brew install autoconf automake libtool - if: (matrix.platform == 'linux') - name: Add libudev and autotools (linux runner) run: | - sudo apt-get update - sudo apt install libudev-dev autoconf automake libtool pkg-config + sudo apt-get update + sudo apt install libudev-dev autoconf automake libtool pkg-config - if: (matrix.platform == 'linux' && matrix.arch == 'aarch64') - name: Add libgpiod (Raspberry Pi Linux) run: | sudo apt-get install -y libgpiod-dev - - name: Build libdmdutil-${{ matrix.platform }}-${{ matrix.arch }} + # + # build (win) + # + - if: (matrix.platform == 'win') + name: Build (win) run: | ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh - if [[ "${{ matrix.platform }}" == "win" ]]; then - if [[ "${{ matrix.arch }}" == "x64" ]]; then - cmake -G "Visual Studio 17 2022" -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build - elif [[ "${{ matrix.arch }}" == "x86" ]]; then - cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build - elif [[ "${{ matrix.arch }}" == "arm64" ]]; then - cmake -G "Visual Studio 17 2022" -A ARM64 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build - fi - cmake --build build --config Release + if [[ "${{ matrix.arch }}" == "x64" ]]; then + cmake \ + -G "Visual Studio 17 2022" \ + -DPLATFORM=${{ matrix.platform }} \ + -DARCH=${{ matrix.arch }} \ + -B build else - if [[ "$(uname)" == "Darwin" ]]; then - NUM_PROCS=$(sysctl -n hw.ncpu) - else - NUM_PROCS=$(nproc) - fi - cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build - cmake --build build -- -j${NUM_PROCS} + cmake \ + -G "Visual Studio 17 2022" \ + -A Win32 \ + -DPLATFORM=${{ matrix.platform }} \ + -DARCH=${{ matrix.arch }} \ + -B build fi - - if: (!(matrix.arch == 'arm64' || matrix.arch == 'arm64-v8a' || matrix.arch == 'aarch64' || matrix.platform == 'win')) + cmake --build build --config Release + # + # build (win-mingw) + # + - if: (matrix.platform == 'win-mingw') + name: Build (win-mingw) + run: | + CURRENT_DIR="$(pwd)" + MSYSTEM=UCRT64 /c/msys64/usr/bin/bash.exe -l -c " + cd \"${CURRENT_DIR}\" && + ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh && + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DPLATFORM=${{ matrix.platform }} \ + -DARCH=${{ matrix.arch }} \ + -B build && + cmake --build build -- -j\$(nproc) + " + # + # build (macos) + # + - if: (matrix.platform == 'macos') + name: Build (macos) + run: | + ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DPLATFORM=${{ matrix.platform }} \ + -DARCH=${{ matrix.arch }} \ + -B build + cmake --build build -- -j$(sysctl -n hw.ncpu) + # + # build (linux) + # + - if: (matrix.platform == 'linux') + name: Build (linux) + run: | + ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DPLATFORM=${{ matrix.platform }} \ + -DARCH=${{ matrix.arch }} \ + -B build + cmake --build build -- -j$(nproc) + # + # build (ios/tvos) + # + - if: (matrix.platform == 'ios' || matrix.platform == 'ios-simulator' || matrix.platform == 'tvos') + name: Build (ios/tvos) + run: | + ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DPLATFORM=${{ matrix.platform }} \ + -DARCH=${{ matrix.arch }} \ + -B build + cmake --build build -- -j$(sysctl -n hw.ncpu) + # + # build (android) + # + - if: (matrix.platform == 'android') + name: Build (android) + run: | + ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DPLATFORM=${{ matrix.platform }} \ + -DARCH=${{ matrix.arch }} \ + -B build + cmake --build build -- -j$(nproc) + # + # test + # + - if: (!(matrix.arch == 'arm64' || matrix.arch == 'arm64-v8a' || matrix.arch == 'aarch64' || matrix.platform == 'win' || matrix.platform == 'win-mingw')) name: dmdutil_test run: build/dmdutil_test - - name: Prepare artifacts - id: artifacts + # + # prepare artifacts + # + - if: (matrix.platform == 'win') + name: Prepare artifacts (win) run: | mkdir tmp - if [[ "${{ matrix.platform }}" == "win" ]]; then - ARTIFACT_PATH="tmp" - if [[ "${{ matrix.arch }}" == "x64" ]]; then - LIBS=(dmdutil64 cargs64 zedmd64 serum64 libusb64-1.0 libserialport64 sockpp64 pupdmd64 vni64) - else - LIBS=(dmdutil cargs zedmd serum libusb-1.0 libserialport sockpp pupdmd vni) - fi - for LIB in "${LIBS[@]}"; do - cp "build/Release/${LIB}.lib" tmp - cp "build/Release/${LIB}.dll" tmp - done - cp build/Release/dmdserver.exe tmp - cp build/Release/dmdserver_test.exe tmp - cp build/Release/dmdutil_static.lib tmp - cp build/Release/dmdutil_test_s.exe tmp - cp build/Release/dmdutil_test.exe tmp - cp build/Release/dmdutil-generate-scenes.exe tmp - cp build/Release/dmdutil-play-dump.exe tmp - cp -r test tmp/ + if [[ "${{ matrix.arch }}" == "x64" ]]; then + LIBS=(dmdutil64 cargs64 zedmd64 serum64 libusb64-1.0 libserialport64 sockpp64 pupdmd64 vni64) else - ARTIFACT_PATH="libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz" - if [[ "${{ matrix.platform }}" == "macos" ]]; then - cp build/libdmdutil.a tmp - cp -a build/*.dylib tmp - cp build/dmdserver tmp - cp build/dmdserver_test tmp - cp build/dmdutil_test_s tmp - cp build/dmdutil_test tmp - cp build/dmdutil-generate-scenes tmp - cp build/dmdutil-play-dump tmp - elif [[ "${{ matrix.platform }}" == "linux" ]]; then - cp build/libdmdutil.a tmp - cp -a build/*.{so,so.*} tmp - cp build/dmdserver tmp - cp build/dmdserver_test tmp - cp build/dmdutil_test_s tmp - cp build/dmdutil_test tmp - cp build/dmdutil-generate-scenes tmp - cp build/dmdutil-play-dump tmp - elif [[ "${{ matrix.platform }}" == "ios" || "${{ matrix.platform }}" == "ios-simulator" || "${{ matrix.platform }}" == "tvos" ]]; then - cp build/libdmdutil.a tmp - cp -a build/*.dylib tmp - elif [[ "${{ matrix.platform }}" == "android" ]]; then - cp build/libdmdutil.a tmp - cp build/libdmdutil.so tmp - fi - cp -r test tmp/ - cd tmp - tar -czvf ../${ARTIFACT_PATH} * + LIBS=(dmdutil cargs zedmd serum libusb-1.0 libserialport sockpp pupdmd vni) fi - echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT - - name: Upload artifacts - uses: actions/upload-artifact@v4 + for LIB in "${LIBS[@]}"; do + cp "build/Release/${LIB}.lib" tmp + cp "build/Release/${LIB}.dll" tmp + done + cp build/Release/dmdserver.exe tmp + cp build/Release/dmdserver_test.exe tmp + cp build/Release/dmdutil_static.lib tmp + cp build/Release/dmdutil_test_s.exe tmp + cp build/Release/dmdutil_test.exe tmp + cp build/Release/dmdutil-generate-scenes.exe tmp + cp build/Release/dmdutil-play-dump.exe tmp + cp -r test tmp/ + cd tmp && 7z a -r ../libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip * + - if: (matrix.platform == 'win-mingw') + name: Prepare artifacts (win-mingw) + run: | + mkdir tmp + cp build/*.dll tmp/ + cp build/*.dll.a tmp/ + cp build/dmdutil_static.a tmp/ + cp build/*.exe tmp/ + cp -r test tmp/ + cd tmp && 7z a -r ../libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip * + - if: (matrix.platform == 'macos') + name: Prepare artifacts (macos) + run: | + mkdir tmp + cp build/libdmdutil.a tmp + cp -a build/*.dylib tmp + cp build/dmdserver tmp + cp build/dmdserver_test tmp + cp build/dmdutil_test_s tmp + cp build/dmdutil_test tmp + cp build/dmdutil-generate-scenes tmp + cp build/dmdutil-play-dump tmp + cp -r test tmp/ + cd tmp && tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz * + - if: (matrix.platform == 'linux') + name: Prepare artifacts (linux) + run: | + mkdir tmp + cp build/libdmdutil.a tmp + cp -a build/*.so tmp + cp -a build/*.so.* tmp + cp build/dmdserver tmp + cp build/dmdserver_test tmp + cp build/dmdutil_test_s tmp + cp build/dmdutil_test tmp + cp build/dmdutil-generate-scenes tmp + cp build/dmdutil-play-dump tmp + cp -r test tmp/ + cd tmp && tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz * + - if: (matrix.platform == 'ios' || matrix.platform == 'ios-simulator' || matrix.platform == 'tvos') + name: Prepare artifacts (ios/tvos) + run: | + mkdir tmp + cp build/libdmdutil.a tmp + cp -a build/*.dylib tmp + cd tmp && tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz * + - if: (matrix.platform == 'android') + name: Prepare artifacts (android) + run: | + mkdir tmp + cp build/libdmdutil.a tmp + cp build/libdmdutil.so tmp + cd tmp && tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz * + # + # upload artifacts + # + - if: (matrix.platform == 'win' || matrix.platform == 'win-mingw') + uses: actions/upload-artifact@v7 + with: + name: libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip + path: libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip + archive: false + - if: (matrix.platform != 'win' && matrix.platform != 'win-mingw') + uses: actions/upload-artifact@v7 with: - name: libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }} - path: ${{ steps.artifacts.outputs.artifact_path }} + name: libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz + path: libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz + archive: false post-build: runs-on: macos-15 needs: [ version, build ] name: Build libdmdutil-macos steps: - - uses: actions/download-artifact@v4 - - name: Unpack artifacts - run: | - cd libdmdutil-${{ needs.version.outputs.tag }}-macos-x64 - tar -xzvf libdmdutil-${{ needs.version.outputs.tag }}-macos-x64.tar.gz - cd .. - cd libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64 - tar -xzvf libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz + - uses: actions/download-artifact@v8 + with: + name: libdmdutil-${{ needs.version.outputs.tag }}-macos-x64.tar.gz + skip-decompress: true + - uses: actions/download-artifact@v8 + with: + name: libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz + skip-decompress: true - name: Combine macos architectures run: | + mkdir macos-x64 macos-arm64 + tar -xzvf libdmdutil-${{ needs.version.outputs.tag }}-macos-x64.tar.gz -C macos-x64 + tar -xzvf libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz -C macos-arm64 mkdir tmp - find "libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64" -name "*.dylib" | while read -r file; do + find macos-arm64 -name "*.dylib" | while read -r file; do if [ -L "$file" ]; then cp -a "$file" "tmp/" elif [ -f "$file" ]; then filename=$(basename "$file") lipo -create -output "tmp/$filename" \ - "libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/$filename" \ - "libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/$filename" + "macos-arm64/$filename" \ + "macos-x64/$filename" fi done - for filename in dmdserver dmdserver_test dmdutil_test_s dmdutil_test; do + for filename in dmdserver dmdserver_test dmdutil_test_s dmdutil_test dmdutil-generate-scenes dmdutil-play-dump; do lipo -create -output "tmp/$filename" \ - "libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/$filename" \ - "libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/$filename" + "macos-arm64/$filename" \ + "macos-x64/$filename" done - cp -r libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/test tmp - - name: Prepare artifacts - run: | - cd tmp - tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz * + cp -r macos-arm64/test tmp + cd tmp && tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz * && cd .. - name: Upload artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: - name: libdmdutil-${{ needs.version.outputs.tag }}-macos + name: libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz path: libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz - - name: Package - if: startsWith(github.ref, 'refs/tags/') - run: | - zip -r libdmdutil-${{ needs.version.outputs.tag }}-win-x64.zip libdmdutil-${{ needs.version.outputs.tag }}-win-x64 - zip -r libdmdutil-${{ needs.version.outputs.tag }}-win-x86.zip libdmdutil-${{ needs.version.outputs.tag }}-win-x86 + archive: false + - if: startsWith(github.ref, 'refs/tags/') + uses: actions/download-artifact@v8 + with: + path: release + skip-decompress: true - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: draft: true - files: | - libdmdutil-${{ needs.version.outputs.tag }}-win-x64.zip - libdmdutil-${{ needs.version.outputs.tag }}-win-x86.zip - libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/libdmdutil-${{ needs.version.outputs.tag }}-macos-x64.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-linux-x64/libdmdutil-${{ needs.version.outputs.tag }}-linux-x64.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-linux-aarch64/libdmdutil-${{ needs.version.outputs.tag }}-linux-aarch64.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-ios-arm64/libdmdutil-${{ needs.version.outputs.tag }}-ios-arm64.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-ios-simulator-arm64/libdmdutil-${{ needs.version.outputs.tag }}-ios-simulator-arm64.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-tvos-arm64/libdmdutil-${{ needs.version.outputs.tag }}-tvos-arm64.tar.gz - libdmdutil-${{ needs.version.outputs.tag }}-android-arm64-v8a/libdmdutil-${{ needs.version.outputs.tag }}-android-arm64-v8a.tar.gz + files: release/**/* diff --git a/CMakeLists.txt b/CMakeLists.txt index a53b7956..b5cacd87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,8 @@ if(PLATFORM STREQUAL "win") if(ARCH STREQUAL "x86") add_compile_definitions(WIN32) endif() +elseif(PLATFORM STREQUAL "win-mingw") + add_compile_options(-Wa,-mbig-obj) elseif(PLATFORM STREQUAL "macos") if (ARCH STREQUAL "arm64") set(CMAKE_OSX_ARCHITECTURES arm64) @@ -97,7 +99,7 @@ set(DMDUTIL_SOURCES set(DMDUTIL_COMPILE_DEFINITIONS "") -if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux") +if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "win-mingw" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux") list(APPEND DMDUTIL_SOURCES src/PixelcadeDMD.cpp src/PIN2DMD.cpp @@ -127,6 +129,12 @@ if(BUILD_SHARED) else() target_link_libraries(dmdutil_shared PUBLIC cargs zedmd serum vni libusb-1.0 libserialport sockpp pupdmd ws2_32) endif() + elseif(PLATFORM STREQUAL "win-mingw") + target_link_directories(dmdutil_shared PUBLIC + third-party/build-libs/${PLATFORM}/${ARCH} + third-party/runtime-libs/${PLATFORM}/${ARCH} + ) + target_link_libraries(dmdutil_shared PUBLIC cargs64 zedmd64 serum64 vni64 usb64-1.0 serialport64 sockpp64 pupdmd64 ws2_32) elseif(PLATFORM STREQUAL "macos") target_link_directories(dmdutil_shared PUBLIC third-party/runtime-libs/${PLATFORM}/${ARCH} @@ -149,23 +157,32 @@ if(BUILD_SHARED) target_link_libraries(dmdutil_shared PUBLIC zedmd serum vni sockpp pupdmd) endif() - if(PLATFORM STREQUAL "win" AND ARCH STREQUAL "x64") + if((PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "win-mingw") AND ARCH STREQUAL "x64") set(DMDUTIL_OUTPUT_NAME "dmdutil64") else() set(DMDUTIL_OUTPUT_NAME "dmdutil") endif() - set_target_properties(dmdutil_shared PROPERTIES - OUTPUT_NAME ${DMDUTIL_OUTPUT_NAME} - VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} - ) + if(PLATFORM STREQUAL "win-mingw") + set_target_properties(dmdutil_shared PROPERTIES + PREFIX "" + IMPORT_PREFIX "" + OUTPUT_NAME ${DMDUTIL_OUTPUT_NAME} + VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + ) + else() + set_target_properties(dmdutil_shared PROPERTIES + OUTPUT_NAME ${DMDUTIL_OUTPUT_NAME} + VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + ) + endif() install(TARGETS dmdutil_shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ) install(DIRECTORY include/DMDUtil DESTINATION ${CMAKE_INSTALL_PREFIX}/include) - if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux") + if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "win-mingw" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux") add_executable(dmdserver src/server.cpp src/Logger.cpp @@ -210,8 +227,9 @@ if(BUILD_STATIC) target_compile_definitions(dmdutil_static PUBLIC ${DMDUTIL_COMPILE_DEFINITIONS}) endif() - if(PLATFORM STREQUAL "win") + if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "win-mingw") set_target_properties(dmdutil_static PROPERTIES + PREFIX "" OUTPUT_NAME "dmdutil_static" ) else() @@ -225,7 +243,7 @@ if(BUILD_STATIC) ) install(DIRECTORY include/DMDUtil DESTINATION ${CMAKE_INSTALL_PREFIX}/include) - if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux") + if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "win-mingw" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux") add_executable(dmdutil_test_s src/test.cpp ) @@ -240,6 +258,12 @@ if(BUILD_STATIC) else() target_link_libraries(dmdutil_test_s PUBLIC dmdutil_static cargs zedmd serum vni libusb-1.0 libserialport sockpp pupdmd ws2_32) endif() + elseif(PLATFORM STREQUAL "win-mingw") + target_link_directories(dmdutil_test_s PUBLIC + third-party/build-libs/${PLATFORM}/${ARCH} + third-party/runtime-libs/${PLATFORM}/${ARCH} + ) + target_link_libraries(dmdutil_test_s PUBLIC dmdutil_static cargs64 zedmd64 serum64 vni64 usb64-1.0 serialport64 sockpp64 pupdmd64 ws2_32) elseif(PLATFORM STREQUAL "macos") target_link_directories(dmdutil_test_s PUBLIC third-party/runtime-libs/${PLATFORM}/${ARCH} @@ -258,7 +282,7 @@ if(BUILD_STATIC) endif() endif() -if(POST_BUILD_COPY_EXT_LIBS AND (PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")) +if(POST_BUILD_COPY_EXT_LIBS AND (PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "win-mingw" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")) add_custom_target(copy_ext_libs ALL) if(PLATFORM STREQUAL "win") @@ -302,6 +326,21 @@ if(POST_BUILD_COPY_EXT_LIBS AND (PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "m COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/vni.dll" "$" ) endif() + elseif(PLATFORM STREQUAL "win-mingw") + add_dependencies(copy_ext_libs dmdutil_shared) + add_custom_command(TARGET copy_ext_libs POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libusb64-1.0.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libcargs64.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/zedmd64.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/serum64.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/vni64.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libserialport64-0.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libsockpp64.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/pupdmd64.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libgcc_s_seh-1.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libstdc++-6.dll" "$" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libwinpthread-1.dll" "$" + ) elseif(PLATFORM STREQUAL "macos") add_custom_command(TARGET copy_ext_libs POST_BUILD COMMAND cp -a "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/*.dylib" "${CMAKE_BINARY_DIR}/" diff --git a/README.md b/README.md index 9c8f0533..b4d2ccbf 100644 --- a/README.md +++ b/README.md @@ -262,7 +262,12 @@ timings from the dump. Use `--delay-ms` to cap the per-frame delay; if a frame's ## Building: -#### Windows (x64) +#### Windows x64 (MSVC) + +Requires [MSYS2](https://www.msys2.org/) dependencies: +```shell +pacman -S make diffutils mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-libwinpthread mingw-w64-ucrt-x86_64-cmake +``` ```shell platforms/win/x64/external.sh @@ -270,7 +275,12 @@ cmake -G "Visual Studio 17 2022" -DPLATFORM=win -DARCH=x64 -B build cmake --build build --config Release ``` -#### Windows (x86) +#### Windows x86 (MSVC) + +Requires [MSYS2](https://www.msys2.org/) dependencies: +```shell +pacman -S make diffutils mingw-w64-i686-gcc mingw-w64-i686-libwinpthread mingw-w64-i686-cmake +``` ```shell platforms/win/x86/external.sh @@ -278,6 +288,17 @@ cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=win -DARCH=x86 -B build cmake --build build --config Release ``` +#### Windows MinGW / MSYS2 UCRT64 (x64) + +Requires [MSYS2](https://www.msys2.org/) dependencies: +```shell +pacman -S make diffutils autoconf automake libtool mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-libwinpthread mingw-w64-ucrt-x86_64-cmake +``` + +```shell +MSYSTEM=UCRT64 /usr/bin/bash -l -c "cd $(pwd) && platforms/win-mingw/x64/external.sh && cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=win-mingw -DARCH=x64 -B build && cmake --build build -- -j$(nproc)" +``` + #### Linux (x64) ```shell platforms/linux/x64/external.sh diff --git a/platforms/config.sh b/platforms/config.sh index 20298adf..9b6c46bd 100755 --- a/platforms/config.sh +++ b/platforms/config.sh @@ -2,10 +2,10 @@ set -e -LIBZEDMD_SHA=2a1e5da64a8a2b991a57f971e62bd417a9766608 -LIBSERUM_SHA=e0f6937df82a434653aeb5d72ef33e95861519fd -LIBPUPDMD_SHA=124f45e5ddd59ceb339591de88fcca72f8c54612 -LIBVNI_SHA=44375cf1e9d25c7063e52068f6915cb7a3c888d6 +LIBZEDMD_SHA=31f81378af4f7d74bed94c15e6e90adb4908d3a3 +LIBSERUM_SHA=1a0d912fb4166b5b1181d54d8312e8ce28058ab3 +LIBPUPDMD_SHA=cd186754ba0dcc1ea418d5557d59d7bf2ed628a3 +LIBVNI_SHA=ba43c5abff7fbbb831a4beb9be54447df1532f0c LIBUSB_SHA=15a7ebb4d426c5ce196684347d2b7cafad862626 if [ -z "${BUILD_TYPE}" ]; then diff --git a/platforms/win-mingw/x64/external.sh b/platforms/win-mingw/x64/external.sh new file mode 100755 index 00000000..e6e56480 --- /dev/null +++ b/platforms/win-mingw/x64/external.sh @@ -0,0 +1,155 @@ +#!/bin/bash + +set -e + +source ./platforms/config.sh + +echo "Building libraries..." +echo " LIBUSB_SHA: ${LIBUSB_SHA}" +echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" +echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" +echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBVNI_SHA: ${LIBVNI_SHA}" +echo "" + +NUM_PROCS=$(nproc) + +rm -rf external +mkdir external +cd external + +# +# build libusb and copy to third-party +# + +curl -sL https://github.com/libusb/libusb/archive/${LIBUSB_SHA}.tar.gz -o libusb-${LIBUSB_SHA}.tar.gz +tar xzf libusb-${LIBUSB_SHA}.tar.gz +mv libusb-${LIBUSB_SHA} libusb +cd libusb +sed -i.bak 's/libusb-1\.0/libusb64-1.0/g' libusb/Makefile.am +sed -i.bak 's/libusb_1_0/libusb64_1_0/g' libusb/Makefile.am +mv libusb/libusb-1.0.def libusb/libusb64-1.0.def +mv libusb/libusb-1.0.rc libusb/libusb64-1.0.rc +sed -i.bak 's/libusb-1\.0/libusb64-1.0/g' libusb/libusb64-1.0.def +sed -i.bak 's/libusb-1\.0/libusb64-1.0/g' libusb/libusb64-1.0.rc +./autogen.sh +./configure \ + --enable-shared +make -j${NUM_PROCS} +mkdir -p ../../third-party/include/libusb-1.0 +cp libusb/libusb.h ../../third-party/include/libusb-1.0 +cp libusb/.libs/libusb64-1.0.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp libusb/.libs/libusb64-1.0.dll ../../third-party/runtime-libs/win-mingw/x64/ +cd .. + +# +# build libzedmd and copy to external +# + +curl -sL https://github.com/PPUC/libzedmd/archive/${LIBZEDMD_SHA}.tar.gz -o libzedmd-${LIBZEDMD_SHA}.tar.gz +tar xzf libzedmd-${LIBZEDMD_SHA}.tar.gz +mv libzedmd-${LIBZEDMD_SHA} libzedmd +cd libzedmd +BUILD_TYPE=${BUILD_TYPE} platforms/win-mingw/x64/external.sh +cmake \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DPLATFORM=win-mingw \ + -DARCH=x64 \ + -DBUILD_SHARED=ON \ + -DBUILD_STATIC=OFF \ + -B build +cmake --build build -- -j${NUM_PROCS} +cp src/ZeDMD.h ../../third-party/include/ +cp third-party/include/cargs.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ +cp -r third-party/include/sockpp ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ +cp third-party/include/libserialport.h ../../third-party/include/ +cp third-party/build-libs/win-mingw/x64/libcargs64.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp third-party/runtime-libs/win-mingw/x64/libcargs64.dll ../../third-party/runtime-libs/win-mingw/x64/ +cp third-party/build-libs/win-mingw/x64/libserialport64.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp third-party/runtime-libs/win-mingw/x64/libserialport64-0.dll ../../third-party/runtime-libs/win-mingw/x64/ +cp third-party/build-libs/win-mingw/x64/libsockpp64.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp third-party/runtime-libs/win-mingw/x64/libsockpp64.dll ../../third-party/runtime-libs/win-mingw/x64/ +cp build/zedmd64.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp build/zedmd64.dll ../../third-party/runtime-libs/win-mingw/x64/ +cp -r test ../../ +cd .. + +# +# build libserum and copy to external +# + +curl -sL https://github.com/PPUC/libserum/archive/${LIBSERUM_SHA}.tar.gz -o libserum-${LIBSERUM_SHA}.tar.gz +tar xzf libserum-${LIBSERUM_SHA}.tar.gz +mv libserum-${LIBSERUM_SHA} libserum +cd libserum +cmake \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DPLATFORM=win-mingw \ + -DARCH=x64 \ + -DBUILD_SHARED=ON \ + -DBUILD_STATIC=OFF \ + -B build +cmake --build build -- -j${NUM_PROCS} +cp -r third-party/include/lz4 ../../third-party/include/ +cp src/LZ4Stream.h ../../third-party/include/ +cp src/SceneGenerator.h ../../third-party/include/ +cp src/serum.h ../../third-party/include/ +cp src/TimeUtils.h ../../third-party/include/ +cp src/serum-decode.h ../../third-party/include/ +cp build/serum64.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp build/serum64.dll ../../third-party/runtime-libs/win-mingw/x64/ +cd .. + +# +# build libpupdmd and copy to external +# + +curl -sL https://github.com/PPUC/libpupdmd/archive/${LIBPUPDMD_SHA}.tar.gz -o libpupdmd-${LIBPUPDMD_SHA}.tar.gz +tar xzf libpupdmd-${LIBPUPDMD_SHA}.tar.gz +mv libpupdmd-${LIBPUPDMD_SHA} libpupdmd +cd libpupdmd +cmake \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DPLATFORM=win-mingw \ + -DARCH=x64 \ + -DBUILD_SHARED=ON \ + -DBUILD_STATIC=OFF \ + -B build +cmake --build build -- -j${NUM_PROCS} +cp src/pupdmd.h ../../third-party/include/ +cp build/pupdmd64.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp build/pupdmd64.dll ../../third-party/runtime-libs/win-mingw/x64/ +cd .. + +# +# build libvni and copy to external +# + +curl -sL https://github.com/PPUC/libvni/archive/${LIBVNI_SHA}.tar.gz -o libvni-${LIBVNI_SHA}.tar.gz +tar xzf libvni-${LIBVNI_SHA}.tar.gz +mv libvni-${LIBVNI_SHA} libvni +cd libvni +cmake \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DPLATFORM=win-mingw \ + -DARCH=x64 \ + -DBUILD_SHARED=ON \ + -DBUILD_STATIC=OFF \ + -B build +cmake --build build -- -j${NUM_PROCS} +cp src/vni.h ../../third-party/include/ +cp build/vni64.dll.a ../../third-party/build-libs/win-mingw/x64/ +cp build/vni64.dll ../../third-party/runtime-libs/win-mingw/x64/ +cd .. + +# +# copy UCRT64 runtime DLLs +# + +UCRT64_BIN="${MINGW_PREFIX}/bin" + +cp "${UCRT64_BIN}/libgcc_s_seh-1.dll" ../third-party/runtime-libs/win-mingw/x64/ +cp "${UCRT64_BIN}/libstdc++-6.dll" ../third-party/runtime-libs/win-mingw/x64/ +cp "${UCRT64_BIN}/libwinpthread-1.dll" ../third-party/runtime-libs/win-mingw/x64/ diff --git a/third-party/build-libs/win-mingw/x64/.gitkeep b/third-party/build-libs/win-mingw/x64/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/third-party/runtime-libs/win-mingw/x64/.gitkeep b/third-party/runtime-libs/win-mingw/x64/.gitkeep new file mode 100644 index 00000000..e69de29b