From 3b6ffd9c27f7c36ace2804fbd279455771918d1c Mon Sep 17 00:00:00 2001 From: Vitor K Date: Sat, 19 Nov 2022 17:22:10 -0300 Subject: [PATCH] Add MSVC binaries for Windows on releases (#6190) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improve directory creation in WindowsCopyFiles.cmake * Release msvc compiled binaries as an alternative to mingw releases * msvc: do not ship .pdb files * msvc: Copy necessary files to the release * windows-msvc: enable compatibility reporting translation was disabled because the bundled qt doesn't have the necessary component Co-authored-by: MichaƂ Janiszewski --- .ci/windows-msvc/build.sh | 13 +++++- .ci/windows-msvc/upload.ps1 | 41 +++++++++++++++++++ .github/workflows/ci.yml | 12 +++++- .../cmake-modules/WindowsCopyFiles.cmake | 4 +- 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 .ci/windows-msvc/upload.ps1 diff --git a/.ci/windows-msvc/build.sh b/.ci/windows-msvc/build.sh index 19428b49b..de7c7f2fb 100644 --- a/.ci/windows-msvc/build.sh +++ b/.ci/windows-msvc/build.sh @@ -1,7 +1,18 @@ #!/bin/sh -ex mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MSVCCache.cmake" -DCITRA_USE_CCACHE=ON -DCITRA_USE_BUNDLED_QT=1 -DCITRA_USE_BUNDLED_SDL2=1 -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DENABLE_FFMPEG_VIDEO_DUMPER=ON +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -G Ninja \ + -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MSVCCache.cmake" \ + -DCITRA_USE_CCACHE=ON \ + -DCITRA_USE_BUNDLED_QT=1 \ + -DENABLE_QT_TRANSLATION=OFF \ + -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \ + -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \ + -DUSE_DISCORD_PRESENCE=ON \ + -DENABLE_MF=ON \ + -DENABLE_FFMPEG_VIDEO_DUMPER=ON ninja # show the caching efficiency diff --git a/.ci/windows-msvc/upload.ps1 b/.ci/windows-msvc/upload.ps1 new file mode 100644 index 000000000..0fbe649a7 --- /dev/null +++ b/.ci/windows-msvc/upload.ps1 @@ -0,0 +1,41 @@ + +$GITDATE = $(git show -s --date=short --format='%ad') -replace "-", "" +$GITREV = $(git show -s --format='%h') + +# Find out what release we are building +if ( $GIT_TAG_NAME ) { + $RELEASE_NAME = ${GIT_TAG_NAME}.split("-")[0] + $RELEASE_NAME = "${RELEASE_NAME}-msvc" +} +else { + $RELEASE_NAME = "head" +} + +$MSVC_BUILD_ZIP = "citra-windows-msvc-$GITDATE-$GITREV.zip" -replace " ", "" +$MSVC_SEVENZIP = "citra-windows-msvc-$GITDATE-$GITREV.7z" -replace " ", "" + +$BUILD_DIR = ".\build\bin\Release" + +# Create artifact directories +mkdir $RELEASE_NAME +mkdir "artifacts" + +echo "Starting to pack ${RELEASE_NAME}" + +Copy-Item $BUILD_DIR\* -Destination $RELEASE_NAME -Recurse +Remove-Item $RELEASE_NAME\tests.* -ErrorAction ignore +Remove-Item $RELEASE_NAME\*.pdb -ErrorAction ignore + +# Copy documentation +Copy-Item license.txt -Destination $RELEASE_NAME +Copy-Item README.md -Destination $RELEASE_NAME + +# Copy cross-platform scripting support +Copy-Item dist\scripting -Destination $RELEASE_NAME -Recurse + +# Build the final release artifacts +7z a -tzip $MSVC_BUILD_ZIP $RELEASE_NAME\* +7z a $MSVC_SEVENZIP $RELEASE_NAME + +Copy-Item $MSVC_BUILD_ZIP -Destination "artifacts" +Copy-Item $MSVC_SEVENZIP -Destination "artifacts" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a829b2a20..1c29f508c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,6 +108,9 @@ jobs: key: ${{ runner.os }}-win-${{ github.sha }} restore-keys: | ${{ runner.os }}-win- + - name: Query tag name + uses: little-core-labs/get-git-tag@v3.0.2 + id: tagName - name: Install dependencies run: ./.ci/windows-msvc/deps.sh shell: bash @@ -118,6 +121,13 @@ jobs: shell: bash env: ENABLE_COMPATIBILITY_REPORTING: "ON" + - name: Pack + run: ./.ci/windows-msvc/upload.ps1 + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: msvc + path: artifacts/ android: runs-on: ubuntu-latest steps: @@ -168,7 +178,7 @@ jobs: TRANSIFEX_API_TOKEN: ${{ secrets.TRANSIFEX_API_TOKEN }} release: runs-on: ubuntu-latest - needs: [build, android, macos, source] + needs: [build, android, macos, source, windows] if: ${{ startsWith(github.ref, 'refs/tags/') }} steps: - uses: actions/download-artifact@v3 diff --git a/externals/cmake-modules/WindowsCopyFiles.cmake b/externals/cmake-modules/WindowsCopyFiles.cmake index cd0c2ce47..a21b2e2d7 100644 --- a/externals/cmake-modules/WindowsCopyFiles.cmake +++ b/externals/cmake-modules/WindowsCopyFiles.cmake @@ -22,7 +22,7 @@ function(windows_copy_files TARGET SOURCE_DIR DEST_DIR) # cmake adds an extra check for command success which doesn't work too well with robocopy # so trick it into thinking the command was successful with the || cmd /c "exit /b 0" add_custom_command(TARGET ${TARGET} POST_BUILD - COMMAND if not exist ${DEST_DIR} mkdir ${DEST_DIR} 2> nul + COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR} COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0" ) -endfunction() \ No newline at end of file +endfunction()