From 274f2fe10d4ac4ae4c5d95509fac88b8bab7e5fe Mon Sep 17 00:00:00 2001 From: scribam Date: Thu, 23 Dec 2021 22:31:13 +0100 Subject: [PATCH] ci: add ninja, update actions and ccache support --- .github/workflows/android.yml | 13 +-- .github/workflows/c-cpp.yml | 143 ++++++++---------------- .github/workflows/crowdin_prep.yml | 6 +- .github/workflows/crowdin_translate.yml | 6 +- .github/workflows/switch.yml | 6 +- .github/workflows/uwp.yml | 7 +- CMakeLists.txt | 12 +- core/types.h | 1 - 8 files changed, 73 insertions(+), 121 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index fb1ca9280..9527b32d0 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -10,21 +10,20 @@ jobs: - name: Set up build environment run: | sudo apt-get update - sudo apt-get -y install ccache ninja-build libcurl4-openssl-dev - echo "CCACHE_DIR=/tmp/ccache" >> $GITHUB_ENV + sudo apt-get -y install ccache libcurl4-openssl-dev ninja-build - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 submodules: true - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: - path: /tmp/ccache + path: ~/.ccache key: android-ccache-${{ github.sha }} restore-keys: android-ccache- - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/.gradle/caches @@ -36,7 +35,7 @@ jobs: working-directory: shell/android-studio run: ./gradlew assembleRelease --parallel - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: flycast-release.apk path: shell/android-studio/flycast/build/outputs/apk/release/flycast-release.apk diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 3602d8353..0596cd701 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -7,131 +7,86 @@ jobs: name: ${{ matrix.config.name }} runs-on: ${{ matrix.config.os }} + defaults: + run: + shell: ${{ matrix.config.shell }} + + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + strategy: matrix: config: - - {name: i686-pc-windows-msvc, os: windows-latest, cmakeArgs: -G "Visual Studio 17 2022" -A Win32 -DVCPKG_TARGET_TRIPLET=x86-windows-static, buildType: Release} - - {name: apple-darwin, os: macos-latest, cmakeArgs: -G "Xcode", destDir: osx, buildType: Release} - - {name: apple-ios, os: macos-latest, cmakeArgs: -DCMAKE_SYSTEM_NAME=iOS -G "Xcode", destDir: ios, buildType: Release} - - {name: x86_64-pc-linux-gnu, os: ubuntu-latest, buildType: Release} - - {name: x86_64-pc-windows-msvc, os: windows-latest, cmakeArgs: -G "Visual Studio 17 2022" -A x64 -DVCPKG_TARGET_TRIPLET=x64-windows-static, buildType: Release} - - {name: x86_64-w64-mingw32, os: windows-latest, cmakeArgs: -G "MinGW Makefiles", destDir: win, buildType: RelWithDebInfo} - - {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, cmakeArgs: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE, buildType: Release} - - {name: libretro-x86_64-w64-mingw32, os: windows-latest, cmakeArgs: -DLIBRETRO=ON -G "MinGW Makefiles", buildType: Release} - - env: - VCPKG_ROOT: ${{ github.workspace }}/vcpkg - VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache + - {name: i686-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x86, cmakeArgs: -G Ninja, buildType: Release} + - {name: apple-darwin, os: macos-latest, shell: sh, cmakeArgs: -G Ninja, destDir: osx, buildType: Release} + - {name: apple-ios, os: macos-latest, shell: sh, cmakeArgs: -DCMAKE_SYSTEM_NAME=iOS -G Xcode, destDir: ios, buildType: Release} + - {name: x86_64-pc-linux-gnu, os: ubuntu-latest, shell: sh, cmakeArgs: -G Ninja, buildType: Release} + - {name: x86_64-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x64, cmakeArgs: -G Ninja, buildType: Release} + - {name: x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -G Ninja, destDir: win, buildType: RelWithDebInfo} + - {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, shell: sh, cmakeArgs: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -G Ninja, buildType: Release} + - {name: libretro-x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -DLIBRETRO=ON -G Ninja, buildType: Release} steps: - - name: Set up build environment (macos-latest) + - name: Set up build environment (macOS) run: | - brew install ccache libao libomp pulseaudio zlib ldid - curl https://sdk.lunarg.com/sdk/download/1.2.189.0/mac/vulkansdk-macos-1.2.189.0.dmg --output vulkansdk-macos-1.2.189.0.dmg - hdiutil attach ./vulkansdk-macos-1.2.189.0.dmg - pushd /Volumes/vulkansdk-macos-1.2.189.0 - sudo ./InstallVulkan.app/Contents/MacOS/InstallVulkan --root ~/VulkanSDK/1.2.189.0 --accept-licenses --default-answer --confirm-command install - popd - echo "VULKAN_SDK=$HOME/VulkanSDK/1.2.189.0/macOS" >> $GITHUB_ENV + brew update + brew install ccache libao ldid libomp ninja pulseaudio echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - echo "CCACHE_DIR=/tmp/ccache" >> $GITHUB_ENV - if: matrix.config.os == 'macos-latest' + wget https://sdk.lunarg.com/sdk/download/1.3.204.1/mac/vulkansdk-macos-1.3.204.1.dmg + hdiutil attach ./vulkansdk-macos-*.dmg + sudo /Volumes/vulkansdk-macos-*/InstallVulkan.app/Contents/MacOS/InstallVulkan --root $HOME/VulkanSDK --accept-licenses --default-answer --confirm-command install + hdiutil detach /Volumes/vulkansdk-macos-* + echo "VULKAN_SDK=$HOME/VulkanSDK/macOS" >> $GITHUB_ENV + if: runner.os == 'macOS' - - name: Set up build environment (ubuntu-latest) + - name: Set up build environment (Linux) run: | sudo apt-get update - sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libgl1-mesa-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev libminiupnpc-dev liblua5.3-dev - echo "CCACHE_DIR=/tmp/ccache" >> $GITHUB_ENV - if: matrix.config.os == 'ubuntu-latest' + sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libgl1-mesa-dev liblua5.3-dev libminiupnpc-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev ninja-build + if: runner.os == 'Linux' - - name: Set up build environment (windows-latest) - run: echo "DXSDK_DIR=${Env:HOMEDRIVE}${Env:HOMEPATH}\ccache\" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append - if: matrix.config.os == 'windows-latest' && matrix.config.name != 'libretro-x86_64-w64-mingw32' - - - uses: actions/cache@v2 - with: - path: /tmp/ccache - key: ccache-${{ matrix.config.name }}-${{ github.sha }} - restore-keys: ccache-${{ matrix.config.name }}- - if: matrix.config.os != 'windows-latest' - - - uses: actions/cache@v2 - id: cache - with: - path: $HOME/ccache - key: ccache-${{ matrix.config.name }}-${{ github.sha }} - restore-keys: ccache-${{ matrix.config.name }}- - if: matrix.config.os == 'windows-latest' - - - name: Download DX2010 - if: matrix.config.os == 'windows-latest' && matrix.config.name != 'libretro-x86_64-w64-mingw32' - run: | - curl -L https://download.microsoft.com/download/a/e/7/ae743f1f-632b-4809-87a9-aa1bb3458e31/DXSDK_Jun10.exe -o _DX2010_.exe - 7z x _DX2010_.exe DXSDK/Include -o_DX2010_ - 7z x _DX2010_.exe DXSDK/Lib/x86 -o_DX2010_ - 7z x _DX2010_.exe DXSDK/Lib/x64 -o_DX2010_ - mv _DX2010_/DXSDK $HOME/ccache - rm -fR _DX*_ _DX*_.exe - shell: bash - - - name: Install MSYS2 + - name: Set up build environment (Windows, MinGW) uses: msys2/setup-msys2@v2 with: msystem: MINGW64 - install: git base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-lua mingw-w64-x86_64-SDL2 - if: endsWith(matrix.config.name, 'w64-mingw32') + install: git make mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-lua mingw-w64-x86_64-ninja mingw-w64-x86_64-SDL2 mingw-w64-x86_64-toolchain + if: matrix.config.shell == 'msys2 {0}' - - uses: actions/checkout@v2 + - name: Set up build environment (Windows, Visual Studio) + run: | + choco install ccache directx-sdk ninja + echo DXSDK_DIR=C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)>> %GITHUB_ENV% + if: matrix.config.shell == 'cmd' + + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.config.arch }} + if: matrix.config.shell == 'cmd' + + - uses: actions/checkout@v3 with: fetch-depth: 0 submodules: true - - name: Bootstrap vcpkg (msvc) - run: | - git clone https://github.com/microsoft/vcpkg - mkdir vcpkg\bincache - vcpkg\bootstrap-vcpkg.bat - if: endsWith(matrix.config.name, 'msvc') - - - uses: actions/cache@v2 - id: cache-vcpkg + - uses: actions/cache@v3 with: - path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: vcpkg-${{ hashFiles( 'vcpkg.json' ) }} - if: endsWith(matrix.config.name, 'msvc') + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ matrix.config.name }}-${{ github.sha }} + restore-keys: ccache-${{ matrix.config.name }}- - name: CMake run: | cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact ${{ matrix.config.cmakeArgs }} - cmake --build build --config ${{ matrix.config.buildType }} --parallel 2 cmake --build build --config ${{ matrix.config.buildType }} --target install - if: endsWith(matrix.config.name, 'w64-mingw32') != true && endsWith(matrix.config.name, 'msvc') != true - - - name: CMake (windows) - shell: msys2 {0} - run: | - unset temp tmp - cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact ${{ matrix.config.cmakeArgs }} - cmake --build build --config ${{ matrix.config.buildType }} --parallel 2 - cmake --build build --config ${{ matrix.config.buildType }} --target install - if: endsWith(matrix.config.name, 'w64-mingw32') - - - name: CMake (windows-msvc) - run: | - cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}\scripts\buildsystems\vcpkg.cmake ${{ matrix.config.cmakeArgs }} - cmake --build build --config ${{ matrix.config.buildType }} --parallel 2 - cmake --build build --config ${{ matrix.config.buildType }} --target install - if: endsWith(matrix.config.name, 'msvc') - name: Unit Tests run: | - cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DENABLE_CTEST=ON ${{ matrix.config.cmakeArgs }} - cmake --build build --config ${{ matrix.config.buildType }} --parallel 2 + cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact -DENABLE_CTEST=ON ${{ matrix.config.cmakeArgs }} + cmake --build build --config ${{ matrix.config.buildType }} ./build/flycast if: matrix.config.name == 'x86_64-pc-linux-gnu' - name: Dump symbols - shell: msys2 {0} run: | core/deps/breakpad/bin/dump_syms artifact/bin/flycast.exe > flycast.exe.sym 2>/dev/null BUILD_ID=`head -1 flycast.exe.sym | awk '{ print $4 }'` @@ -140,7 +95,7 @@ jobs: strip artifact/bin/flycast.exe if: matrix.config.name == 'x86_64-w64-mingw32' - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: flycast-${{ matrix.config.name }} path: artifact/bin diff --git a/.github/workflows/crowdin_prep.yml b/.github/workflows/crowdin_prep.yml index 973dd1253..0e76551b8 100644 --- a/.github/workflows/crowdin_prep.yml +++ b/.github/workflows/crowdin_prep.yml @@ -15,15 +15,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Java JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 1.8 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Upload Source shell: bash diff --git a/.github/workflows/crowdin_translate.yml b/.github/workflows/crowdin_translate.yml index 2d9065b56..64809ba30 100644 --- a/.github/workflows/crowdin_translate.yml +++ b/.github/workflows/crowdin_translate.yml @@ -12,15 +12,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Java JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 1.8 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. diff --git a/.github/workflows/switch.yml b/.github/workflows/switch.yml index 4aa5ff213..fcf56f1a9 100644 --- a/.github/workflows/switch.yml +++ b/.github/workflows/switch.yml @@ -20,12 +20,12 @@ jobs: sudo apt-get update sudo apt-get -y install awscli ccache ninja-build - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 submodules: true - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.ccache key: ccache-switch-${{ matrix.config.name }}-${{ github.sha }} @@ -36,7 +36,7 @@ jobs: $DEVKITPRO/portlibs/switch/bin/aarch64-none-elf-cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=artifact -G Ninja ${{ matrix.config.cmakeArgs }} cmake --build build --config Release --target install - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: flycast-switch-${{ matrix.config.name }} path: artifact/bin diff --git a/.github/workflows/uwp.yml b/.github/workflows/uwp.yml index 2ad4275ad..bd2127a7e 100644 --- a/.github/workflows/uwp.yml +++ b/.github/workflows/uwp.yml @@ -11,7 +11,7 @@ jobs: VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 submodules: true @@ -22,8 +22,7 @@ jobs: mkdir vcpkg\bincache vcpkg\bootstrap-vcpkg.bat - - uses: actions/cache@v2 - id: cache + - uses: actions/cache@v3 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} key: vcpkg-${{ hashFiles( 'vcpkg.json' ) }} @@ -50,7 +49,7 @@ jobs: run: signtool sign /f shell\uwp\sign_cert.pfx /p '${{ secrets.SIGN_CERT_PWD }}' /v /fd SHA256 build\artifact\flycast.appx if: github.repository == 'flyinghead/flycast' && github.event_name == 'push' - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: flycast-uwp path: build/artifact diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bdbe4fcb..aa355df8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.10.2) -find_program(CCACHE_FOUND ccache) -if(CCACHE_FOUND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "Compiler launcher for C.") + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "Compiler launcher for CXX.") endif() option(ENABLE_CTEST "Enables unit tests" OFF) @@ -45,7 +45,7 @@ if(ENABLE_CTEST) include(CTest) endif() -if(APPLE AND NOT LIBRETRO) +if(IOS AND NOT LIBRETRO) set(CMAKE_Swift_LANGUAGE_VERSION 5.0) enable_language(Swift) endif() @@ -1235,8 +1235,8 @@ if(NOT LIBRETRO) target_link_libraries(${PROJECT_NAME} PRIVATE android EGL GLESv2 log) elseif(APPLE) - set_property(TARGET ${PROJECT_NAME} PROPERTY XCODE_ATTRIBUTE_SWIFT_VERSION "5.0") if(IOS) + set_property(TARGET ${PROJECT_NAME} PROPERTY XCODE_ATTRIBUTE_SWIFT_VERSION "5.0") add_subdirectory(shell/apple/emulator-ios/AltKit) target_link_libraries(${PROJECT_NAME} PRIVATE AltKit) diff --git a/core/types.h b/core/types.h index 7218e5be2..672638d49 100644 --- a/core/types.h +++ b/core/types.h @@ -193,7 +193,6 @@ inline static void JITWriteProtect(bool enabled) { #include "log/Log.h" #define VER_EMUNAME "Flycast" -#define VER_FULLNAME VER_EMUNAME " (built " __DATE__ "@" __TIME__ ")" #define VER_SHORTNAME VER_EMUNAME void os_DebugBreak();