From 85e64c76744b4ca7ea2f25a81cf0efd487edb39c Mon Sep 17 00:00:00 2001 From: Dextinfire <> Date: Fri, 6 Sep 2024 00:41:52 -0700 Subject: [PATCH] Convert azure pipeline to github actions. Make better enums constexpr since we use VS2019+ now. Build deps now checks if atrac9 is cached and we're in CI, If it is, skip upgrade. CMake to use Ninja on Windows for faster builds. Added CI options for macOS ARM64 and x86_64 builds. CI uses vcpkg for dependencies on Windows, Linux and macOS. Added vcpkg.json for manifest based dependency management. Added CMakePresets.json for easier default CMake configuration, users can supply CMakeUsersPresets.json if they want their own. --- .github/workflows/pipeline.yml | 206 +++++++++++++++++ .gitignore | 2 + CMakeLists.txt | 4 - CMakePresets.json | 70 ++++++ azure-pipelines.yml | 393 --------------------------------- build-deps.ps1 | 36 +-- doc/vs2019_build.md | 101 --------- doc/vs_build.md | 27 +++ vcpkg.json | 22 ++ 9 files changed, 349 insertions(+), 512 deletions(-) create mode 100644 .github/workflows/pipeline.yml create mode 100644 CMakePresets.json delete mode 100644 azure-pipelines.yml delete mode 100644 doc/vs2019_build.md create mode 100644 doc/vs_build.md create mode 100644 vcpkg.json diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 00000000..09ccc345 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,206 @@ +name: impacto +on: + push: + branches: + - "*" + - "!separate_renderer" + tags: + - "*" + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + get_version: + name: Get Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v3 + - name: Git Version + id: version + uses: codacy/git-version@2.5.4 + job-matrix: + name: ${{ matrix.os_name }} + runs-on: ${{ matrix.os }} + needs: get_version + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest, macos-13] + include: + - os: windows-latest + os_name: windows + triplet: x64-windows-release + - os: ubuntu-latest + os_name: linux + triplet: x64-linux-dynamic + - os: macos-latest + os_name: macos-arm64 + triplet: arm64-osx-dynamic + - os: macos-13 + os_name: macos-x64 + triplet: x64-osx-dynamic + env: + VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }} + vcpkgCommitId: '0f88ecb8528605f91980b90a2c5bad88e3cb565f' + + steps: + - uses: actions/checkout@v3 + + - name: Cache LibAtrac9 + uses: actions/cache@v3 + with: + key: libatrac9 | ${{ matrix.os_name }} + path: vendor/LibAtrac9 + + - uses: lukka/get-cmake@latest + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + id: runvcpkg + with: + vcpkgDirectory: '${{ runner.workspace }}/build/vcpkg' + vcpkgGitCommitId: '${{ env.vcpkgCommitId }}' + vcpkgJsonGlob: '**/vcpkg.json' + - name: Build Atrac9 Windows + if: matrix.os == 'windows-latest' + run: | + ./build-deps.ps1 -Arg1 x64 + shell: pwsh + - name: Setup Dependencies Linux/MacOS + if: contains(matrix.os_name, 'macos') || contains(matrix.os_name, 'linux') + run: |- + pushd vendor + if [ ! -d "LibAtrac9" ]; then + git clone https://github.com/Thealexbarney/LibAtrac9.git --depth 1 + fi + cd LibAtrac9/C + if [[ "${{ matrix.os_name }}" == "macos"* ]]; then + sed -i '' -e 's/,--version-script=libatrac9.version//g' Makefile + fi + make + mkdir -p ../include/libatrac9 + mkdir -p ../libs + cp bin/libatrac9.a ../libs/ + cp src/libatrac9.h ../include/libatrac9/ + popd + echo "LIBATRAC9DIR=${{ github.workspace }}/vendor/LibAtrac9" >> $GITHUB_ENV + - name: Install Dependencies Linux + run: sudo apt-get install nasm libx11-dev libxft-dev libxext-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev libxrandr-dev + if: matrix.os_name == 'linux' + - name: Install Dependencies Mac + run: brew install nasm + if: contains(matrix.os_name, 'macos') + - name: Run CMake with vcpkg.json manifest + uses: lukka/run-cmake@v10 + with: + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + configurePreset: ci-release + configurePresetAdditionalArgs: "['-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}', '-DVCPKG_HOST_TRIPLET=${{ matrix.triplet }}', '-DVCPKG_BUILD_TYPE=release']" + buildPreset: CI-Build + + - name: Copy docs + run: | + cp THIRDPARTY.md README.md LICENSE "${{ github.workspace }}/release/ci-release" + shell: bash + - name: Archive Artifacts + run: | + 7z u impacto-${{ matrix.os_name }}-${{ needs.get_version.outputs.version }}-${{ github.sha }}.zip release/ci-release/* + - name: Upload Artifact + uses: actions/upload-artifact@v4.1.0 + with: + path: impacto-${{ matrix.os_name }}-${{ needs.get_version.outputs.version }}-${{ github.sha }}.zip + name: release-${{ matrix.os_name }} + + + publish_artifacts: + name: Publish Artifacts + runs-on: ubuntu-22.04 + needs: + - get_version + - job-matrix + if: (needs.job-matrix.result == 'success') && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') + steps: + - uses: actions/download-artifact@v4 + with: + pattern: release-* + path: "${{ github.workspace }}/release" + merge-multiple: true + - name: Upload Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags') || (github.ref == 'refs/heads/master') + with: + Name: Latest ${{ env.BRANCH_NAME }} build + tag_name: ${{ needs.get_version.outputs.version }} + files: + ${{ github.workspace }}/release/*.zip + prerelease: true + fail_on_unmatched_files: true + target_commitish: ${{ github.sha }} + - name: Get current date + id: date + run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV + + # - uses: tsickert/discord-webhook@v5.3.0 + # with: + # thread-id: ${{ secrets.discordChannelId }} + # webhook-url: ${{ secrets.discordWebhookKey }} + # username: IMPACTO + # avatar-url: https://cdn.discordapp.com/emojis/766988033127481344.png + # embed-title : "${{ github.event.commits[0].author.name }}" + # embed-color: 3659647 + # embed-timestamp: ${{ env.NOW }} + # embed-description: > + # "Commit\n + # `${{ github.event.head_commit.message }} (${{ github.sha }})`\n + # from branch `${{ env.BRANCH_NAME }}` has been successfully built.\n\n + # Release URL:\n + # https://github.com/CommitteeOfZero/impacto/releases/tag/${{ needs.get_version.outputs.version }}\n\n + # Details:\n + # ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + notify_fail: + name: Notify failure + runs-on: ubuntu-22.04 + needs: + - job-matrix + if: always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) + steps: + - uses: actions/checkout@v2 + - name: 'Get Jobs Status' + id: get_jobs_status + run: | + echo "Fetch workflow run jobs" + json_data=$(curl -s -H "Authorization: Bearer ${{ github.token }}" \ + "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs") + + name_conclusion_array=($(echo "$json_data" | jq -r '.jobs[] | select(.name | startswith("job-matrix")) | "\(.name).\(.conclusion)"')) + + for item in "${name_conclusion_array[@]}"; do + IFS='.' read -r name conclusion <<< "$item" + echo "$name=$conclusion" >> $GITHUB_OUTPUT + done + + - name: Get current date + id: date + run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT + + # - uses: tsickert/discord-webhook@v5.3.0 + # with: + # thread-id: ${{ secrets.discordChannelId }} + # webhook-url: ${{ secrets.discordWebhookKey }} + # username: IMPACTO + # avatar-url: https://cdn.discordapp.com/emojis/766988033127481344.png + # embed-title : "${{ github.event.commits[0].author.name }}" + # embed-color: 16711680 + # embed-timestamp: ${{ steps.date.outputs.NOW }} + # embed-description: > + # "Commit\n + # `${{ github.event.head_commit.message }} (${{ github.sha }})`\n + # from branch `${{ env.BRANCH_NAME }}` has failed build.\n\n + # Job status:\n + + # ${{join(steps.get_jobs_status.outputs.*, '\n')}}\n\n + # Details:\n + # ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6e41928a..58e94577 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ bld/ [Ll]og/ [Ii]nstall/ cmake-build-*/ +impacto-build/ # Visual Studio 2015 cache/options directory .vs/ @@ -274,5 +275,6 @@ __pycache__/ ### /CMakeSettings.json +CMakeUserPresets.json vendor/LibAtrac9 vendor/imgui diff --git a/CMakeLists.txt b/CMakeLists.txt index 28c78534..649ad696 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1012,10 +1012,6 @@ if (EMSCRIPTEN) set(CMAKE_EXECUTABLE_SUFFIX ".html") endif () -if (MSVC) - add_definitions(-DBETTER_ENUMS_NO_CONSTEXPR) # broken in MSVC 2017 apparently -endif () - if (NX) set_property(TARGET impacto PROPERTY NO_SYSTEM_FROM_IMPORTED ON) # to avoid -isystem add_definitions(-DENV64BIT) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..600b299f --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,70 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23 + }, + "configurePresets": [ + { + "name": "ninja-multi-default", + "description": "Multi-Config Ninja Configure Preset", + "hidden": false, + "generator": "Ninja Multi-Config", + "binaryDir": "impacto-build/${presetName}", + "installDir": "install/${presetName}", + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "YES" + } + }, + { + "name": "ci-release", + "description": "Release build for CI", + "hidden": false, + "generator": "Ninja", + "binaryDir": "ci-build/${presetName}", + "installDir": "release/${presetName}", + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + } + ], + "buildPresets": [ + { + "name": "CI-Build", + "description": "x64 Release", + "configurePreset": "ci-release", + "targets": [ + "install" + ] + }, + { + "name": "x64-Release-Symbols", + "description": "x64 Release with Debug Symbols", + "configurePreset": "ninja-multi-default", + "configuration": "RelWithDebInfo", + "targets": [ + "install" + ] + }, + { + "name": "x64-Release", + "description": "x64 Release", + "configurePreset": "ninja-multi-default", + "configuration": "Release", + "targets": [ + "install" + ] + }, + { + "name": "x64-Debug", + "description": "x64 Debug", + "configurePreset": "ninja-multi-default", + "configuration": "Debug", + "targets": [ + "install" + ] + } + ] +} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 4c5f616f..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,393 +0,0 @@ -jobs: -- job: win_x64_build - displayName: Windows x64 Build - timeoutInMinutes: 120 - - pool: - vmImage: 'windows-2019' - - steps: - - script: | - cd /d C:\vcpkg - git log -1 - git pull - git log -1 - .\bootstrap-vcpkg.bat - displayName: git pull vcpkg and bootstrap-vcpkg - - task: Cache@2 - displayName: Cache vcpkg packages - inputs: - key: 'vcpkg-deps' - path: 'C:/vcpkg/installed' - - task: Cache@2 - displayName: Cache LibAtrac9 - inputs: - key: 'libatrac9' - path: '$(Build.Repository.LocalPath)/vendor/LibAtrac9' - - task: PowerShell@2 - displayName: Setup Vulkan - inputs: - targetType: 'inline' - script: | - Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.268.0/windows/VulkanSDK-1.3.268.0-Installer.exe" -OutFile VulkanSDK.exe - $installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList "--accept-licenses", "--default-answer", "--confirm-command install" - $installer.WaitForExit() - - task: PowerShell@2 - displayName: Build dependencies - env: - VULKAN_SDK: 'C:\\VulkanSDK\\1.3.268.0' - inputs: - filePath: 'build-deps.ps1' - errorActionPreference: 'silentlyContinue' - - task: run-cmake@0 - displayName: CMake build - env: - VULKAN_SDK: 'C:\\VulkanSDK\\1.3.268.0' - inputs: - cmakeListsOrSettingsJson: 'CMakeListsTxtBasic' - cmakeToolchainPath: 'C:/vcpkg/scripts/buildsystems/vcpkg.cmake' - cmakeBuildType: 'Release' - cmakeGenerator: 'VS16Win64' - buildDirectory: '$(Build.ArtifactStagingDirectory)/out/build' - buildWithCMakeArgs: '--config Release --target install' - - - task: CopyFiles@2 - displayName: Copy dlls - inputs: - SourceFolder: 'C:/Program Files/impacto/Release' - Contents: '**' - TargetFolder: 'C:/Program Files/impacto' - - task: CopyFiles@2 - displayName: Copy docs - inputs: - SourceFolder: '$(Build.Repository.LocalPath)' - Contents: | - THIRDPARTY.md - README.md - LICENSE - TargetFolder: 'C:/Program Files/impacto' - - task: DeleteFiles@1 - displayName: Remove leftovers - inputs: - SourceFolder: 'C:/Program Files/impacto/Release' - Contents: '**' - RemoveSourceFolder: true - - task: DeleteFiles@1 - displayName: Remove leftovers - inputs: - SourceFolder: 'C:/Program Files/impacto/impacto.dir' - Contents: '**' - RemoveSourceFolder: true - - task: DeleteFiles@1 - displayName: Remove leftovers - inputs: - SourceFolder: 'C:/Program Files/impacto/x64' - Contents: '**' - RemoveSourceFolder: true - - task: ArchiveFiles@2 - displayName: Archive artifact - inputs: - rootFolderOrFile: 'C:/Program Files/impacto' - includeRootFolder: true - archiveType: 'zip' - archiveFile: '$(Build.ArtifactStagingDirectory)/impacto-win-x64-$(version)-$(Build.SourceVersion).zip' - replaceExistingArchive: true - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)/impacto-win-x64-$(version)-$(Build.SourceVersion).zip' - ArtifactName: 'release' - publishLocation: 'Container' - -- job: linux_x64_build - displayName: Linux x64 Build - - pool: - vmImage: 'ubuntu-22.04' - - container: 'mrrevo3d/impacto-build:latest' - - steps: - - script: | - dpkg -l | grep sdl - pushd vendor - git clone https://github.com/Thealexbarney/LibAtrac9.git --depth 1 - cd LibAtrac9/C && make - mkdir -p ../include/libatrac9 - mkdir -p ../libs - cp bin/libatrac9.a ../libs/ - cp src/libatrac9.h ../include/libatrac9/ - popd - pushd vendor - git clone -b "0.9.9.3" https://github.com/g-truc/glm.git --depth 1 - cd glm - cmake -DGLM_TEST_ENABLE=false . - make -j2 - popd - LIBATRAC9DIR=vendor/LibAtrac9 cmake . - make -j2 - - task: CopyFiles@2 - displayName: Copy artifact - inputs: - Contents: | - impacto - profiles/**/* - games/**/* - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: CopyFiles@2 - displayName: Copy artifact - inputs: - SourceFolder: 'src' - Contents: 'shaders/**/*' - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: CopyFiles@2 - displayName: Copy docs - inputs: - SourceFolder: '$(Build.Repository.LocalPath)' - Contents: | - THIRDPARTY.md - README.md - LICENSE - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: ArchiveFiles@2 - displayName: Archive artifact - inputs: - rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/impacto' - includeRootFolder: true - archiveType: 'zip' - archiveFile: '$(Build.ArtifactStagingDirectory)/impacto-linux-$(version)-$(Build.SourceVersion).zip' - replaceExistingArchive: true - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)/impacto-linux-$(version)-$(Build.SourceVersion).zip' - ArtifactName: 'release' - publishLocation: 'Container' - -- job: macos_build - displayName: macOS Build - - pool: - vmImage: 'macOS-latest' - -# mac os vulkan sdk temp -# pushd ~/Downloads -# curl https://sdk.lunarg.com/sdk/download/1.3.250.0/mac/vulkansdk-macos-1.3.250.0.dmg -o vulkansdk.dmg -# hdiutil attach vulkansdk.dmg -# pushd /Volumes/VulkanSDK -# sudo ./InstallVulkan.app/Contents/MacOS/InstallVulkan --root ~/VulkanSDK/1.3.250.0 --accept-licenses --default-answer --confirm-command install -# popd -# popd - - steps: - - script: | - brew install openal-soft sdl2 glm ffmpeg webp - pushd vendor - git clone https://github.com/Thealexbarney/LibAtrac9.git --depth 1 - cd LibAtrac9/C && make - mkdir -p ../include/libatrac9 - mkdir -p ../libs - cp bin/libatrac9.a ../libs/ - cp src/libatrac9.h ../include/libatrac9/ - popd - LIBATRAC9DIR=vendor/LibAtrac9 cmake -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include/AL -DIMPACTO_DISABLE_VULKAN=ON . - make -j2 - - task: CopyFiles@2 - displayName: Copy artifact - inputs: - Contents: | - impacto - profiles/**/* - games/**/* - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: CopyFiles@2 - displayName: Copy artifact - inputs: - SourceFolder: 'src' - Contents: 'shaders/**/*' - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: CopyFiles@2 - displayName: Copy docs - inputs: - SourceFolder: '$(Build.Repository.LocalPath)' - Contents: | - THIRDPARTY.md - README.md - LICENSE - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: ArchiveFiles@2 - displayName: Archive artifact - inputs: - rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/impacto' - includeRootFolder: true - archiveType: 'zip' - archiveFile: '$(Build.ArtifactStagingDirectory)/impacto-macos-$(version)-$(Build.SourceVersion).zip' - replaceExistingArchive: true - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)/impacto-macos-$(version)-$(Build.SourceVersion).zip' - ArtifactName: 'release' - publishLocation: 'Container' - -- job: switch_build - displayName: Switch Build - - pool: - vmImage: 'ubuntu-22.04' - - steps: - - task: DownloadGitHubRelease@0 - inputs: - connection: 'github' - userRepository: 'MrRevo3D/impacto' - defaultVersionType: 'specificTag' - version: 'buildtag' - downloadPath: '$(System.ArtifactsDirectory)' - - task: ExtractFiles@1 - inputs: - archiveFilePatterns: '$(System.ArtifactsDirectory)/devkitpro.tar.gz' - destinationFolder: '/opt' - cleanDestinationFolder: false - overwriteExistingFiles: false - - script: | - export DEVKITPRO=/opt/devkitpro - export DEVKITARM=/opt/devkitpro/devkitARM - export PATH="/opt/devkitpro/tools/bin:$PATH" - cmake . -DCMAKE_TOOLCHAIN_FILE=HorizonNX.toolchain - make -j2 - elf2nro impacto impacto.nro - - task: CopyFiles@2 - displayName: Copy artifact - inputs: - Contents: | - impacto.nro - profiles/**/* - games/**/* - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: CopyFiles@2 - displayName: Copy artifact - inputs: - SourceFolder: 'src' - Contents: 'shaders/**/*' - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: CopyFiles@2 - displayName: Copy docs - inputs: - SourceFolder: '$(Build.Repository.LocalPath)' - Contents: | - THIRDPARTY.md - README.md - LICENSE - TargetFolder: '$(Build.ArtifactStagingDirectory)/impacto' - - task: ArchiveFiles@2 - displayName: Archive artifact - inputs: - rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/impacto' - includeRootFolder: true - archiveType: 'zip' - archiveFile: '$(Build.ArtifactStagingDirectory)/impacto-switch-$(version)-$(Build.SourceVersion).zip' - replaceExistingArchive: true - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)/impacto-switch-$(version)-$(Build.SourceVersion).zip' - ArtifactName: 'release' - publishLocation: 'Container' - -- job: publish_artifacts - displayName: Publish Artifacts - dependsOn: - - win_x64_build - - linux_x64_build - - macos_build - - switch_build - condition: succeeded() - - pool: - vmImage: 'ubuntu-22.04' - - steps: - - task: DownloadBuildArtifacts@0 - inputs: - buildType: 'current' - downloadType: 'single' - artifactName: 'release' - downloadPath: '$(System.ArtifactsDirectory)' - - task: GitHubRelease@1 - inputs: - gitHubConnection: 'github' - repositoryName: 'CommitteeOfZero/impacto' - action: 'create' - target: '$(Build.SourceVersion)' - tagSource: 'userSpecifiedTag' - tag: '$(version)' - title: 'Latest $(Build.SourceBranchName) build' - releaseNotesSource: 'inline' - assets: '$(System.ArtifactsDirectory)/release/*.zip' - isPreRelease: true - addChangeLog: false - - powershell: | - $gituser=$(git log -1 --pretty=format:'%an') - Write-Host "Setting up the date time for build variable" - $date=$(Get-Date -Format o) - Write-Host "##vso[task.setvariable variable=timestamp]$date" - Write-Host "##vso[task.setvariable variable=commitAuthor]$gituser" - displayName: 'PowerShell Script' - - task: ado-discord-webhook@1 - inputs: - channelId: $(discordChannelId) - webhookKey: $(discordWebhookKey) - name: 'IMPACTO' - avatar: 'https://cdn.discordapp.com/emojis/766988033127481344.png' - messageType: 'embeds' - embeds: | - [{ - "title": "$(commitAuthor)", - "description": "Commit\n`$(Build.SourceVersionMessage) ($(Build.SourceVersion))`\nfrom branch `$(Build.SourceBranchName)` has been successfully built.\n\nRelease URL:\nhttps://github.com/CommitteeOfZero/impacto/releases/tag/$(version)\n\nDetails:\n$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results", - "color": 3659647, - "timestamp": "$(timestamp)" - }] - -- job: notify_fail - displayName: Notify failure - dependsOn: - - win_x64_build - - linux_x64_build - - macos_build - - switch_build - variables: - winBuildStatus: $[ dependencies.win_x64_build.result ] - linuxBuildStatus: $[ dependencies.linux_x64_build.result ] - macOSBuildStatus: $[ dependencies.macos_build.result ] - switchBuildStatus: $[ dependencies.switch_build.result ] - condition: | - or - ( - in(dependencies.win_x64_build.result, 'Failed', 'Canceled'), - in(dependencies.linux_x64_build.result, 'Failed', 'Canceled'), - in(dependencies.macos_build.result, 'Failed', 'Canceled'), - in(dependencies.switch_build.result, 'Failed', 'Canceled') - ) - - pool: - vmImage: 'ubuntu-22.04' - - steps: - - powershell: | - $gituser=$(git log -1 --pretty=format:'%an') - Write-Host "Setting up the date time for build variable" - $date=$(Get-Date -Format o) - Write-Host "##vso[task.setvariable variable=timestamp]$date" - Write-Host "##vso[task.setvariable variable=commitAuthor]$gituser" - displayName: 'PowerShell Script' - - task: ado-discord-webhook@1 - inputs: - channelId: $(discordChannelId) - webhookKey: $(discordWebhookKey) - name: 'IMPACTO' - avatar: 'https://cdn.discordapp.com/emojis/766988033127481344.png' - messageType: 'embeds' - embeds: | - [{ - "title": "$(commitAuthor)", - "description": "Commit\n`$(Build.SourceVersionMessage) ($(Build.SourceVersion))`\nfrom branch `$(Build.SourceBranchName)` has failed build.\n\nJob status:\nwin_x64_build: $(winBuildStatus)\nlinux_x64_build: $(linuxBuildStatus)\nmacos_build: $(macOSBuildStatus)\nswitch_build: $(switchBuildStatus)\n\nDetails:\n$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=results", - "color": 16711680, - "timestamp": "$(timestamp)" - }] diff --git a/build-deps.ps1 b/build-deps.ps1 index 8e7b82a5..b173c459 100644 --- a/build-deps.ps1 +++ b/build-deps.ps1 @@ -1,6 +1,5 @@ param( - [ValidateSet("x64", "x86")][string]$Arch = "x64", - [string]$VcpkgDir = $env:VCPKG_INSTALLATION_ROOT + [ValidateSet("x64", "x86")][string]$Arch = "x64" ) function SetEnv() { @@ -15,19 +14,26 @@ function SetEnv() { } function BuildLibatrac9() { + echo "Starting LibAtrac9 Build..." if (!(Get-Command msbuild -ErrorAction SilentlyContinue)) { SetEnv } + pushd "vendor" $repo_root = "LibAtrac9" - if (!(Test-Path $repo_root)) { - & git clone https://github.com/Thealexbarney/LibAtrac9.git --depth 1 + $libatrac9_exists = Test-Path $repo_root + if (-not $libatrac9_exists) { + echo "Cloning LibAtrac9..." + & git clone https://github.com/Thealexbarney/LibAtrac9.git --depth 1 } - pushd $repo_root pushd "C" - & devenv /Upgrade libatrac9.sln + if ($env:AZURE_EXTENSION_DIR -eq $null -or -not $libatrac9_exists) { + echo "Upgrading LibAtrac9 project..." + & devenv /Upgrade libatrac9.sln + } + $args = @( "/m", "/p:Configuration=Release", @@ -35,9 +41,11 @@ function BuildLibatrac9() { "/p:WindowsTargetPlatformVersion=10.0", "/p:PlatformToolset=v142" ) + echo "Building LibAtrac9..." & msbuild $args popd + echo "Copying LibAtrac9 dlls and headers..." $includedir = "include/libatrac9" mkdir $includedir -Force | Out-Null Get-ChildItem -Path "./C/src/*" -Include *.h | Copy-Item -Destination $includedir @@ -54,13 +62,15 @@ function BuildLibatrac9() { } function InstallPackages() { - $vcpkg = "$VcpkgDir/vcpkg.exe" + $vcpkg = "$env:VCPKG_ROOT/vcpkg.exe" if (!(Get-Command $vcpkg -ErrorAction SilentlyContinue)) { $vcpkg = "vcpkg" } - # Visual studio's vcpkg doesn't support classic mode - if(("${env:VSINSTALLDIR}VC\vcpkg" -eq "${env:VCPKG_ROOT}") -or !(Get-Command $vcpkg -ErrorAction SilentlyContinue)) { + + $local_vcpkg = $false + if(!(Get-Command $vcpkg -ErrorAction SilentlyContinue)) { if (!(Test-Path build/vcpkg)) { + echo "Cloning vcpkg..." mkdir build -Force | Out-Null pushd build & git clone https://github.com/Microsoft/vcpkg.git --depth 1 @@ -68,15 +78,13 @@ function InstallPackages() { ./bootstrap-vcpkg -disableMetrics popd popd + $vcpkg = "build/vcpkg/vcpkg.exe" } - $vcpkg = "build/vcpkg/vcpkg.exe" $local_vcpkg = $true } - - & $vcpkg install sdl2 sdl2[vulkan] vulkan openal-soft libogg libvorbis zlib glm ffmpeg libwebp --triplet $Arch-windows + & $vcpkg integrate install if ($local_vcpkg) { - & $vcpkg integrate install Write-Output "Cleaning up..." Remove-Item build/vcpkg/downloads -Recurse Remove-Item build/vcpkg/buildtrees -Recurse @@ -84,4 +92,4 @@ function InstallPackages() { } BuildLibatrac9 -InstallPackages +InstallPackages \ No newline at end of file diff --git a/doc/vs2019_build.md b/doc/vs2019_build.md deleted file mode 100644 index a4ea5bda..00000000 --- a/doc/vs2019_build.md +++ /dev/null @@ -1,101 +0,0 @@ -# Building with Visual Studio 2019 - -## Dependencies - -Visual Studio must have the "Desktop development with C++" optional features installed (you can check if you have them installed by going into the "Tools" menu and selecting "Get Tools and Features..."). - -Git command-line tool must be available from within PowerShell. If you don't have it installed, you can download it from https://git-scm.com/downloads - -Enable execution of PowerShell scripts by running the following command in an elevated PowerShell prompt: - -`Set-ExecutionPolicy RemoteSigned` - -Run `.\build-deps.ps1` from a PowerShell prompt. - -## Visual Studio 2019 CMake project setup - -- Put following `CMakePresets.json` in the repository root (don't worry, it's gitignored) and change paths if necessary (the directories will be created automatically upon building): - - -```json -{ - "version": 3, - "cmakeMinimumRequired": { - "major": 3, - "minor": 11 - }, - "configurePresets": [ - { - "name": "x64-Release", - "description": "x64 Release", - "hidden": false, - "generator": "Ninja", - "binaryDir": "${sourceDir}/impacto-build/build/${presetName}", - "environment": { - "VCPKG_ROOT": "${sourceDir}/build/vcpkg/" - }, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_TOOLCHAIN_FILE": { - "type": "FILEPATH", - "value": "${sourceDir}/build/vcpkg/scripts/buildsystems/vcpkg.cmake" - }, - "CMAKE_PREFIX_PATH": "${sourceDir}/build/vcpkg/installed/x64-windows/", - "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/impacto-build/build/${presetName}", - "CMAKE_C_COMPILER": "cl.exe", - "CMAKE_CXX_COMPILER": "cl.exe" - } - }, - { - "name": "x64-Debug", - "description": "x64 Debug", - "hidden": false, - "generator": "Ninja", - "binaryDir": "${sourceDir}/impacto-build/build/${presetName}", - "environment": { - "VCPKG_ROOT": "${sourceDir}/impacto/build/vcpkg/" - }, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_TOOLCHAIN_FILE": { - "type": "FILEPATH", - "value": "${sourceDir}/build/vcpkg/scripts/buildsystems/vcpkg.cmake" - }, - "CMAKE_PREFIX_PATH": "${sourceDir}/build/vcpkg/installed/x64-windows/", - "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/impacto-build/build/${presetName}", - "CMAKE_C_COMPILER": "cl.exe", - "CMAKE_CXX_COMPILER": "cl.exe" - } - } - ], - "buildPresets": [ - { - "name": "x64-Release", - "description": "x64 Release", - "configurePreset": "x64-Release", - "targets": [ - "install" - ] - }, - { - "name": "x64-Debug", - "description": "x64 Debug", - "configurePreset": "x64-Debug", - "targets": [ - "install" - ] - } - ] -} -``` - -- You may have to enable CMakePresets in VS Options -> Cmake - -- Open the project with *File->Open->Folder...* in VS2019 -- When picking a startup item, make sure to use `impacto.exe (Install)` - -## Cry - -about the absolute state of C++ dependency management \ No newline at end of file diff --git a/doc/vs_build.md b/doc/vs_build.md new file mode 100644 index 00000000..625704d4 --- /dev/null +++ b/doc/vs_build.md @@ -0,0 +1,27 @@ +# Building with Visual Studio + +## Dependencies + +Visual Studio must have the "Desktop development with C++" optional features installed (you can check if you have them installed by going into the "Tools" menu and selecting "Get Tools and Features..."). + +Git command-line tool must be available from within PowerShell. If you don't have it installed, you can download it from https://git-scm.com/downloads + +Enable execution of PowerShell scripts by running the following command in an elevated PowerShell prompt: + +`Set-ExecutionPolicy RemoteSigned` + +- If running on a version of Visual Studio older than 2022 (or vcpkg isn't installed), make sure to set the environment variable `VCPKG_ROOT` to `${impactoDir}/build/vcpkg`, or wherever else your vcpkg root directory is located. + +Run `.\build-deps.ps1` from a PowerShell prompt, addings args for architecture [`x64`, `x86`] if needed + +## Visual Studio CMake project setup +- You may have to enable CMakePresets in VS Options -> Cmake + +- The included `CMakePresets.json` in the repository root should already have several default build configurations. If you need to make any changes, create a `CMakeUserPresets.json`, of the same format, in the repository root (don't worry, it's gitignored) and change paths if necessary (the directories will be created automatically upon building). Make sure to name the presets differently from the default presets, since user presets cannot override existing presets. + +- Open the project with *File->Open->Folder...* in Visual Studio +- When picking a startup item, make sure to use `impacto.exe (Install)` + +## Cry + +about the absolute state of C++ dependency management \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..5d91f313 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "builtin-baseline": "0f88ecb8528605f91980b90a2c5bad88e3cb565f", + "dependencies": [ + "sdl2", + { + "name": "sdl2", + "default-features": true, + "features": [ + "vulkan" + ] + }, + "vulkan", + "openal-soft", + "libogg", + "libvorbis", + "zlib", + "glm", + "ffmpeg", + "libwebp" + ] +} \ No newline at end of file