diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3bb10018 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,137 @@ +name: CI + +on: [push, pull_request] + +jobs: + clang-format: + name: 'clang-format' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run clang-format + run: | + find CONFIG LEGO1 ISLE miniwin -iname '*.h' -o -iname '*.cpp' | xargs \ + pipx run "clang-format>=17,<18" \ + --style=file \ + -i + - name: Check diff + run: | + git diff --exit-code + + build: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + defaults: + run: + shell: ${{ matrix.shell || 'sh' }} + + strategy: + fail-fast: false + matrix: + include: + - { name: 'Linux', os: 'ubuntu-latest', dx5: false, build-type: 'Debug', linux: true, werror: true, clang-tify: true } + - { name: 'MSVC (x86)', os: 'windows-latest', dx5: true, build-type: 'Debug', msvc: true, werror: false, clang-tify: false, vc-arch: 'amd64_x86' } + - { name: 'MSVC (x64)', os: 'windows-latest', dx5: false, build-type: 'Debug', msvc: true, werror: false, clang-tify: false, vc-arch: 'amd64' } + - { name: 'MSVC (arm64)', os: 'windows-latest', dx5: false, build-type: 'Debug', msvc: true, werror: false, clang-tify: false, vc-arch: 'amd64_arm64' } + - { name: 'msys2 mingw32', os: 'windows-latest', dx5: false, build-type: 'Debug', mingw: true, werror: true, clang-tify: true, msystem: 'mingw32', msys-env: 'mingw-w64-i686', shell: 'msys2 {0}' } + - { name: 'msys2 mingw64', os: 'windows-latest', dx5: false, build-type: 'Debug', mingw: true, werror: true, clang-tify: true, msystem: 'mingw64', msys-env: 'mingw-w64-x86_64', shell: 'msys2 {0}' } + - { name: 'macOS', os: 'macos-latest', dx5: false, build-type: 'Debug', brew: true, werror: true, clang-tify: true } + steps: + - name: Setup vcvars + if: ${{ !!matrix.msvc }} + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.vc-arch }} + + - name: Set up MSYS2 + if: ${{ !!matrix.msystem }} + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.msystem }} + install: >- + ${{ matrix.msys-env }}-cc + ${{ matrix.msys-env }}-cmake + ${{ matrix.msys-env }}-ninja + ${{ matrix.msys-env }}-clang-tools-extra + + - name: Install Linux dependencies (apt-get) + if: ${{ matrix.linux }} + run: | + sudo apt-get update + sudo apt-get install -y \ + libx11-dev libxext-dev libxrandr-dev libxrender-dev libxfixes-dev libxi-dev libxinerama-dev libxcursor-dev libwayland-dev libxkbcommon-dev wayland-protocols + + - name: Install macOS dependencies (brew) + if: ${{ matrix.brew }} + run: | + brew update + brew install cmake ninja llvm + echo "LLVM_ROOT=$(brew --prefix llvm)/bin" >> $GITHUB_ENV + + - name: Setup ninja + if: ${{ matrix.msvc }} + uses: ashutoshvarma/setup-ninja@master + + - uses: actions/checkout@v4 + + - name: Configure (CMake) + run: | + cmake -S . -B build -GNinja \ + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ + -DISLE_USE_DX5=${{ !!matrix.dx5 }} \ + -DENABLE_CLANG_TIDY=${{ !!matrix.clang-tidy }} \ + -DISLE_WERROR=${{ !!matrix.werror }} \ + -Werror=dev + + - name: Build (CMake) + run: cmake --build build --verbose -- -k0 + + - name: Package (CPack) + run: | + cd build + cpack . + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: '${{ matrix.name }} ${{ matrix.build-type }}' + path: build/dist/isle-* + + ncc: + name: 'C++' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1 + with: + version: "16" + + - name: Install python libraries + run: | + pip install -r tools/requirements.txt + + - name: Run ncc + run: | + action_headers=$(find LEGO1/lego/legoomni/include/actions \ + -name '*.h' -print0 | xargs -0 echo) + + python3 tools/ncc/ncc.py \ + --clang-lib ${{ env.LLVM_PATH }}/lib/libclang.so \ + --recurse \ + --style tools/ncc/ncc.style \ + --skip tools/ncc/skip.yml \ + --definition WINAPI FAR BOOL CALLBACK HWND__=HWND SDLCALL \ + --include \ + util \ + LEGO1 \ + LEGO1/omni/include \ + LEGO1/lego/legoomni/include \ + LEGO1/lego/sources \ + --exclude \ + LEGO1/omni/include/flic.h \ + LEGO1/omni/src/video/flic.cpp \ + $action_headers \ + --path LEGO1/omni LEGO1/lego/legoomni diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index e5f2d4de..00000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Format - -on: [push, pull_request] - -jobs: - clang-format: - name: 'C++' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Run clang-format - run: | - find CONFIG LEGO1 ISLE miniwin -iname '*.h' -o -iname '*.cpp' | xargs \ - pipx run "clang-format>=17,<18" \ - --style=file \ - -i - git diff --exit-code diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index 242ca537..00000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Linux - -on: [push, pull_request] - -jobs: - build-linux: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - build-type: [Release, Debug] - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y \ - libx11-dev libxext-dev libxrandr-dev libxrender-dev libxfixes-dev libxi-dev libxinerama-dev libxcursor-dev libwayland-dev libxkbcommon-dev wayland-protocols - - - name: Configure - run: | - cmake -S . -B build -GNinja \ - -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DISLE_USE_DX5=OFF \ - -DENABLE_CLANG_TIDY=ON \ - -DISLE_WERROR=ON \ - -Werror=dev - - - name: Build - run: cmake --build build -- -k0 - - - name: Make Artifact Archive - run: | - cd build - zip "isle-portable-linux-${{ matrix.build-type }}.zip" \ - config isle liblego1.so - - - name: Upload Build Artifacts - uses: actions/upload-artifact@v4 - with: - name: linux-artifacts-${{ matrix.build-type }} - path: build/isle-portable-linux-${{ matrix.build-type }}.zip diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml deleted file mode 100644 index f8f97029..00000000 --- a/.github/workflows/mac.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: macOS - -on: [push, pull_request] - -jobs: - build-macos: - runs-on: macos-latest - - strategy: - fail-fast: false - matrix: - build-type: [Release, Debug] - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - brew update - brew install cmake ninja llvm - echo "CLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy" >> $GITHUB_ENV - - - name: Configure - run: | - cmake -S . -B build -GNinja \ - -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DISLE_USE_DX5=OFF \ - -DENABLE_CLANG_TIDY=ON \ - -DCLANG_TIDY_BIN=$CLANG_TIDY \ - -DISLE_WERROR=ON \ - -Werror=dev - - - name: Build - run: cmake --build build -- -k0 - - - name: Make Artifact Archive - run: | - cd build - zip "isle-portable-macos-${{ matrix.build-type }}.zip" \ - config isle liblego1.dylib - - - name: Upload Build Artifacts - uses: actions/upload-artifact@v4 - with: - name: macos-artifacts-${{ matrix.build-type }} - path: build/isle-portable-macos-${{ matrix.build-type }}.zip diff --git a/.github/workflows/naming.yml b/.github/workflows/naming.yml deleted file mode 100644 index 20ffddff..00000000 --- a/.github/workflows/naming.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Naming - -on: [push, pull_request] - -jobs: - ncc: - name: 'C++' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install LLVM and Clang - uses: KyleMayes/install-llvm-action@v1 - with: - version: "16" - - - name: Install python libraries - run: | - pip install -r tools/requirements.txt - - - name: Run ncc - run: | - action_headers=$(find LEGO1/lego/legoomni/include/actions \ - -name '*.h' -print0 | xargs -0 echo) - - python3 tools/ncc/ncc.py \ - --clang-lib ${{ env.LLVM_PATH }}/lib/libclang.so \ - --recurse \ - --style tools/ncc/ncc.style \ - --skip tools/ncc/skip.yml \ - --definition WINAPI FAR BOOL CALLBACK HWND__=HWND SDLCALL \ - --include \ - util \ - LEGO1 \ - LEGO1/omni/include \ - LEGO1/lego/legoomni/include \ - LEGO1/lego/sources \ - --exclude \ - LEGO1/omni/include/flic.h \ - LEGO1/omni/src/video/flic.cpp \ - $action_headers \ - --path LEGO1/omni LEGO1/lego/legoomni diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 9d63a110..00000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: Windows - -on: [push, pull_request] - -jobs: - build-current-toolchain: - name: 'Current ${{ matrix.toolchain.name }}' - runs-on: windows-latest - defaults: - run: - shell: ${{ matrix.toolchain.shell }} - strategy: - fail-fast: false - matrix: - toolchain: - - { name: 'MSVC (32-bit, Release)', shell: 'sh', setup-cmake: true, setup-ninja: true, setup-msvc: true, vc-arch: 'amd64_x86', dx5-libs: true, build-type: 'Release' } - - { name: 'MSVC (32-bit, Debug)', shell: 'sh', setup-cmake: true, setup-ninja: true, setup-msvc: true, vc-arch: 'amd64_x86', dx5-libs: true, build-type: 'Debug' } - - { name: 'MSVC (64-bit, Debug)', shell: 'sh', setup-cmake: true, setup-ninja: true, setup-msvc: true, vc-arch: 'amd64', dx5-libs: false, build-type: 'Debug' } - - { name: 'MSVC (ARM64, Debug)', shell: 'sh', setup-cmake: true, setup-ninja: true, setup-msvc: true, vc-arch: 'amd64_arm64', dx5-libs: false, build-type: 'Debug' } - - { name: 'msys2 mingw32 (Debug)', shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686, clang-tidy: true, werror: true, dx5-libs: false, build-type: 'Debug' } - - { name: 'msys2 mingw64 (Debug)', shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, clang-tidy: true, werror: true, dx5-libs: false, build-type: 'Debug' } - # - { name: 'msys2 clang32', shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686, clang-tidy: true, werror: true, dx5-libs: true, d3drm-from-wine: true } - - steps: - - name: Setup vcvars - if: matrix.toolchain.setup-msvc - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: ${{ matrix.toolchain.vc-arch }} - # Figure out how to build for 32-bit arch - # - name: Set up SDL - # id: sdl - # uses: libsdl-org/setup-sdl@main - # with: - # version: sdl3-head - - - name: Set up MSYS2 - if: ${{ !!matrix.toolchain.msystem }} - uses: msys2/setup-msys2@v2 - with: - msystem: ${{ matrix.toolchain.msystem }} - install: >- - ${{ matrix.toolchain.msys-env }}-cc - ${{ matrix.toolchain.msys-env }}-cmake - ${{ matrix.toolchain.msys-env }}-ninja - ${{ matrix.toolchain.msys-env }}-clang-tools-extra - - - name: Setup cmake - if: matrix.toolchain.setup-cmake - uses: jwlawson/actions-setup-cmake@v1.13 - - - name: Setup ninja - if: matrix.toolchain.setup-ninja - uses: ashutoshvarma/setup-ninja@master - - - uses: actions/checkout@v4 - with: - submodules: true - - - name: Build - # Add -DDOWNLOAD_DEPENDENCIES=OFF once setup-sdl works - run: | - cmake -S . -B build -GNinja \ - -DCMAKE_BUILD_TYPE=${{ matrix.toolchain.build-type }} \ - -DISLE_USE_DX5=${{ matrix.toolchain.dx5-libs }} \ - -DENABLE_CLANG_TIDY=${{ !!matrix.toolchain.clang-tidy }} \ - -DISLE_WERROR=${{ !!matrix.toolchain.werror }} \ - -Werror=dev - cmake --build build -- -k0 - - # Needs to be reworked when cross-platform building is achieved - - - name: Make Artifact Archive - shell: bash - run: | - cd build - 7z a "isle-portable (${{ matrix.toolchain.name }}).zip" \ - isle.exe lego1.dll sdl3.dll - - - name: Upload Build Artifacts (MSVC (32-bit)) - if: ${{ matrix.toolchain.name == 'MSVC (32-bit, Release)' || matrix.toolchain.name == 'MSVC (32-bit, Debug)' }} - uses: actions/upload-artifact@v4 - with: - name: msvc32-artifacts-${{ matrix.toolchain.name }} - path: | - build/isle-portable (${{ matrix.toolchain.name }}).zip - - merge-artifacts: - name: 'Merge artifacts' - runs-on: ubuntu-latest - needs: build-current-toolchain - steps: - - name: Merge Artifacts - uses: actions/upload-artifact/merge@v4 - with: - name: msvc32-artifacts - pattern: msvc32-artifacts-* - - upload: - name: 'Upload artifacts' - needs: merge-artifacts - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'isledecomp/isle-portable' }} - steps: - - uses: actions/checkout@v4 - with: - repository: 'probonopd/uploadtool' - - - uses: actions/download-artifact@v4 - with: - name: msvc32-artifacts - path: build - - - name: Upload Continuous Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - UPLOAD_KEY: ${{ secrets.UPLOAD_KEY }} - run: | - ./upload.sh \ - build/*.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index b0a952a4..3b523183 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25...4.0 FATAL_ERROR) -project(isle CXX C) +project(isle LANGUAGES CXX C VERSION 0.1) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") @@ -69,7 +69,7 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if (ENABLE_CLANG_TIDY) - find_program(CLANG_TIDY_BIN NAMES "clang-tidy") + find_program(CLANG_TIDY_BIN NAMES "clang-tidy" ENV "LLVM_ROOT" REQUIRED) set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_BIN}") set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_BIN}") endif() @@ -573,3 +573,33 @@ if (EXISTS "${CLANGFORMAT_BIN}") endif() endif() endif() + +set(install_extra_targets) +if(DOWNLOAD_DEPENDENCIES) + get_property(sdl3_type TARGET SDL3::SDL3 PROPERTY TYPE) + if(sdl3_type STREQUAL "SHARED_LIBRARY") + list(APPEND install_extra_targets "SDL3-shared") + endif() +endif() + +if(MSVC) + set(CMAKE_INSTALL_BINDIR "." CACHE PATH "Binary install directory") + set(CMAKE_INSTALL_LIBDIR "." CACHE PATH "Binary install directory") +else() + include(GNUInstallDirs) +endif() + +set(ISLE_PACKAGE_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "Platform name of the package") +install(TARGETS isle lego1 ${install_extra_targets} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +set(CPACK_PACKAGE_DIRECTORY "dist") +set(CPACK_PACKAGE_FILE_NAME "isle-${PROJECT_VERSION}-${ISLE_PACKAGE_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +if(MSVC) + set(CPACK_GENERATOR ZIP) +else() + set(CPACK_GENERATOR TGZ) +endif() +include(CPack)