Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
364 changes: 242 additions & 122 deletions .github/workflows/libdmdutil.yml

Large diffs are not rendered by default.

59 changes: 49 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
)
Expand All @@ -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}
Expand All @@ -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")
Expand Down Expand Up @@ -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" "$<TARGET_FILE_DIR:dmdutil_shared>"
)
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" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libcargs64.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/zedmd64.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/serum64.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/vni64.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libserialport64-0.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libsockpp64.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/pupdmd64.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libgcc_s_seh-1.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libstdc++-6.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libwinpthread-1.dll" "$<TARGET_FILE_DIR:dmdutil_shared>"
)
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}/"
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,43 @@ 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
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
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
Expand Down
8 changes: 4 additions & 4 deletions platforms/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
155 changes: 155 additions & 0 deletions platforms/win-mingw/x64/external.sh
Original file line number Diff line number Diff line change
@@ -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/
Empty file.
Empty file.
Loading