From f4307168de10b46e8ff3e762b9004c48f7708482 Mon Sep 17 00:00:00 2001 From: Kaito Udagawa Date: Mon, 15 Apr 2024 21:19:40 +0900 Subject: [PATCH] Update build scripts according to the latest obs-plugintemplate (#87) * Update build-project.yaml * Update action.yaml * Update helpers_common.cmake * Update compilerconfig.cmake * Update .clang-format * Fix * Fix * Update build-project.yaml * Update check-format.yaml * Update push.yaml * Update build-project.yaml --- .../setup-macos-codesigning/action.yaml | 2 +- .github/scripts/Package-Windows.ps1 | 24 ++++---- .github/workflows/build-project.yaml | 55 +++++++++++++------ .github/workflows/check-format.yaml | 4 +- .github/workflows/push.yaml | 4 +- buildspec.json | 9 +-- cmake/common/bootstrap.cmake | 2 - cmake/common/helpers_common.cmake | 6 +- cmake/macos/helpers.cmake | 16 ------ cmake/windows/compilerconfig.cmake | 26 +++++++-- 10 files changed, 81 insertions(+), 67 deletions(-) diff --git a/.github/actions/setup-macos-codesigning/action.yaml b/.github/actions/setup-macos-codesigning/action.yaml index 56cdba4..5f24114 100644 --- a/.github/actions/setup-macos-codesigning/action.yaml +++ b/.github/actions/setup-macos-codesigning/action.yaml @@ -75,7 +75,7 @@ runs: print -n "${MACOS_SIGNING_CERT}" | base64 --decode --output="${certificate_path}" - : "${MACOS_KEYCHAIN_PASSWORD:="$(print ${RANDOM} | sha1sum | head -c 32)"}" + : "${MACOS_KEYCHAIN_PASSWORD:="$(print ${RANDOM} | shasum | head -c 32)"}" print '::group::Keychain setup' security create-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path} diff --git a/.github/scripts/Package-Windows.ps1 b/.github/scripts/Package-Windows.ps1 index 3d1a07c..cd12f90 100644 --- a/.github/scripts/Package-Windows.ps1 +++ b/.github/scripts/Package-Windows.ps1 @@ -72,10 +72,20 @@ function Package { Remove-Item @RemoveArgs + Log-Group "Archiving ${ProductName}..." + $CompressArgs = @{ + Path = (Get-ChildItem -Path "${ProjectRoot}/release/${Configuration}" -Exclude "${OutputName}*.*") + CompressionLevel = 'Optimal' + DestinationPath = "${ProjectRoot}/release/${OutputName}.zip" + Verbose = ($Env:CI -ne $null) + } + Compress-Archive -Force @CompressArgs + Log-Group + if ( ( $BuildInstaller ) ) { Log-Group "Packaging ${ProductName}..." - $IsccFile = "${ProjectRoot}/build_${Target}/installer-Windows.generated.iss" + $IsccFile = "${ProjectRoot}/build_${Target}/installer-Windows.generated.iss" if ( ! ( Test-Path -Path $IsccFile ) ) { throw 'InnoSetup install script not found. Run the build script or the CMake build and install procedures first.' } @@ -87,19 +97,9 @@ function Package { Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer" Remove-Item -Path Package -Recurse Pop-Location -Stack BuildTemp - } - Log-Group "Archiving ${ProductName}..." - $CompressArgs = @{ - Path = (Get-ChildItem -Path "${ProjectRoot}/release/${Configuration}" -Exclude "${OutputName}*.*") - CompressionLevel = 'Optimal' - DestinationPath = "${ProjectRoot}/release/${OutputName}.zip" - Verbose = ($Env:CI -ne $null) + Log-Group } - - Compress-Archive -Force @CompressArgs - - Log-Group } Package diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index cdb1a33..21df812 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -1,9 +1,13 @@ name: Build Project on: workflow_call: + outputs: + pluginName: + description: 'Project name detected by parsing build spec file' + value: ${{ jobs.check-event.outputs.pluginName }} jobs: check-event: - name: Check GitHub Event Data 📡 + name: Check GitHub Event Data 🔎 runs-on: ubuntu-22.04 defaults: run: @@ -14,8 +18,9 @@ jobs: notarize: ${{ steps.setup.outputs.notarize }} config: ${{ steps.setup.outputs.config }} commitHash: ${{ steps.setup.outputs.commitHash }} + pluginName: ${{ steps.setup.outputs.pluginName }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Check Event Data ☑️ @@ -29,7 +34,8 @@ jobs: case "${GITHUB_EVENT_NAME}" in pull_request) config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo') - if [[ ${{ contains(github.event.pull_request.labels.*.name, 'Seeking Testers') }} = true ]]; then + if gh pr view ${{ github.event.number }} --json labels \ + | jq -e -r '.labels[] | select(.name == "Seeking Testers")' > /dev/null; then config_data[0]='codesign:true' config_data[2]='package:true' fi @@ -56,9 +62,18 @@ jobs: done echo "commitHash=${GITHUB_SHA:0:9}" >> $GITHUB_OUTPUT + plugin_name="$(grep 'name' buildspec.json | sed -E -e 's/^.+"name":[^"]+"(.+)",?$/\1/g')" + plugin_display_name="$(grep 'displayName' buildspec.json | sed -E -e 's/^.+"displayName":[^"]+"(.+)",?$/\1/g' || echo "")" + + if [[ "${plugin_display_name}" ]]; then + echo "pluginName=${plugin_display_name}" >> $GITHUB_OUTPUT + else + echo "pluginName=${plugin_name}" >> $GITHUB_OUTPUT + fi + macos-build: name: Build for macOS 🍏 - runs-on: macos-13 + runs-on: macos-14 needs: check-event strategy: matrix: @@ -67,7 +82,7 @@ jobs: run: shell: zsh --no-rcs --errexit --pipefail {0} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 @@ -78,10 +93,14 @@ jobs: : Set Up Environment 🔧 if (( ${+RUNNER_DEBUG} )) setopt XTRACE + print '::group::Enable Xcode 15.2' + sudo xcode-select --switch /Applications/Xcode_15.2.app/Contents/Developer + print '::endgroup::' + print '::group::Clean Homebrew Environment' - typeset -a to_remove=() + local -a to_remove=() - if (( #to_remove > 0 )) brew uninstall --ignore-dependencies ${to_remove} + if (( #to_remove )) brew uninstall --ignore-dependencies ${to_remove} print '::endgroup::' local product_name @@ -92,7 +111,7 @@ jobs: print "pluginName=${product_name}" >> $GITHUB_OUTPUT print "pluginVersion=${product_version}" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: ccache-cache with: path: ${{ github.workspace }}/.ccache @@ -102,7 +121,7 @@ jobs: - name: Set Up Codesigning 🔑 uses: ./.github/actions/setup-macos-codesigning - if: ${{ fromJSON(needs.check-event.outputs.codesign) }} + if: fromJSON(needs.check-event.outputs.codesign) id: codesign with: codesignIdentity: ${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }} @@ -141,13 +160,13 @@ jobs: MACOS_ARCH: ${{ matrix.architecture }} - name: Upload Artifacts 📡 - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-${{ needs.check-event.outputs.commitHash }} path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}.* - name: Upload Debug Symbol Artifacts 🪲 - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ needs.check-event.outputs.config == 'Release' }} with: name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-${{ needs.check-event.outputs.commitHash }}-dSYMs @@ -161,7 +180,7 @@ jobs: run: shell: bash steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 @@ -178,7 +197,7 @@ jobs: echo "pluginName=${product_name}" >> $GITHUB_OUTPUT echo "pluginVersion=${product_version}" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: ccache-cache with: path: ${{ github.workspace }}/.ccache @@ -203,19 +222,19 @@ jobs: config: ${{ needs.check-event.outputs.config }} - name: Upload Source Tarball 🗜️ - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }} path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-source.* - name: Upload Artifacts 📡 - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }} path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*.* - name: Upload debug symbol artifacts 🪲 - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ fromJSON(needs.check-event.outputs.package) }} with: name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym @@ -232,7 +251,7 @@ jobs: run: shell: pwsh steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 @@ -268,7 +287,7 @@ jobs: cublas: ${{ matrix.cublas }} - name: Upload Artifacts 📡 - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ matrix.cublas }}-${{ needs.check-event.outputs.commitHash }} path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64*.* diff --git a/.github/workflows/check-format.yaml b/.github/workflows/check-format.yaml index bbb3aa2..e30b916 100644 --- a/.github/workflows/check-format.yaml +++ b/.github/workflows/check-format.yaml @@ -5,7 +5,7 @@ jobs: clang-format: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: clang-format check 🐉 @@ -17,7 +17,7 @@ jobs: cmake-format: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: cmake-format check 🎛️ diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index d8b270b..e71de58 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -59,7 +59,7 @@ jobs: esac - name: Download Build Artifacts 📥 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 if: fromJSON(steps.check.outputs.validTag) id: download @@ -114,7 +114,7 @@ jobs: draft: true prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }} tag_name: ${{ steps.check.outputs.version }} - name: obs-localvocal ${{ steps.check.outputs.version }} + name: ${{ needs.build-project.outputs.pluginName }} ${{ steps.check.outputs.version }} body_path: ${{ github.workspace }}/CHECKSUMS.txt files: | ${{ github.workspace }}/*.exe diff --git a/buildspec.json b/buildspec.json index c89b1ae..dbced59 100644 --- a/buildspec.json +++ b/buildspec.json @@ -31,20 +31,13 @@ } } }, - "tools": { - "packages": { - "version": "1.2.10", - "baseUrl": "http://s.sudre.free.fr/Software/files", - "label": "Packages.app", - "hash": "9d9a73a64317ea6697a380014d2e5c8c8188b59d5fb8ce8872e56cec06cd78e8" - } - }, "platformConfig": { "macos": { "bundleId": "com.royshilkrot.obs-localvocal" } }, "name": "obs-localvocal", + "displayName": "OBS Localvocal", "version": "0.2.2", "author": "Roy Shilkrot", "website": "https://github.com/occ-ai/obs-localvocal", diff --git a/cmake/common/bootstrap.cmake b/cmake/common/bootstrap.cmake index 27ad4a4..c7d015f 100644 --- a/cmake/common/bootstrap.cmake +++ b/cmake/common/bootstrap.cmake @@ -49,8 +49,6 @@ string(JSON _author GET ${buildspec} author) string(JSON _email GET ${buildspec} email) string(JSON _version GET ${buildspec} version) string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId) -string(JSON _macosPackageUUID GET ${buildspec} uuids macosPackage) -string(JSON _macosInstallerUUID GET ${buildspec} uuids macosInstaller) string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp) # cmake-format: on diff --git a/cmake/common/helpers_common.cmake b/cmake/common/helpers_common.cmake index 1d06adb..b61fa54 100644 --- a/cmake/common/helpers_common.cmake +++ b/cmake/common/helpers_common.cmake @@ -134,8 +134,10 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-support.c.in") PRIVATE plugin-support.c PUBLIC src/plugin-support.h) target_include_directories(plugin-support PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src") - if(UNIX AND NOT APPLE) - # add fPIC + if(OS_LINUX + OR OS_FREEBSD + OR OS_OPENBSD) + # add fPIC on Linux to prevent shared object errors set_property(TARGET plugin-support PROPERTY POSITION_INDEPENDENT_CODE ON) endif() endif() diff --git a/cmake/macos/helpers.cmake b/cmake/macos/helpers.cmake index 37b92bf..76541b8 100644 --- a/cmake/macos/helpers.cmake +++ b/cmake/macos/helpers.cmake @@ -57,22 +57,6 @@ function(set_target_properties_plugin target) PREFIX "UI Files" FILES ${target_ui_files}) - set(valid_uuid FALSE) - check_uuid(${_macosPackageUUID} valid_uuid) - if(NOT valid_uuid) - message(FATAL_ERROR "Specified macOS package UUID is not a valid UUID value: ${_macosPackageUUID}") - else() - set(UUID_PACKAGE ${_macosPackageUUID}) - endif() - - set(valid_uuid FALSE) - check_uuid(${_macosInstallerUUID} valid_uuid) - if(NOT valid_uuid) - message(FATAL_ERROR "Specified macOS package UUID is not a valid UUID value: ${_macosInstallerUUID}") - else() - set(UUID_INSTALLER ${_macosInstallerUUID}) - endif() - install(TARGETS ${target} LIBRARY DESTINATION .) install( FILES "$.dsym" diff --git a/cmake/windows/compilerconfig.cmake b/cmake/windows/compilerconfig.cmake index 7af3c4d..55984f4 100644 --- a/cmake/windows/compilerconfig.cmake +++ b/cmake/windows/compilerconfig.cmake @@ -9,6 +9,15 @@ if(CMAKE_VERSION VERSION_EQUAL 3.24.0) set(THREADS_HAVE_PTHREAD_ARG FALSE) endif() +# CMake 3.25 changed the way symbol generation is handled on Windows +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25.0) + if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ProgramDatabase) + else() + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) + endif() +endif() + message(DEBUG "Current Windows API version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM) message(DEBUG "Maximum Windows API version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM}") @@ -20,15 +29,24 @@ if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348) endif() add_compile_options( - /W3 /utf-8 "$<$:/MP>" "$<$:/MP>" + /W3 + /utf-8 + "$<$:/MP>" + "$<$:/MP>" "$<$:${_obs_clang_c_options}>" - "$<$:${_obs_clang_cxx_options}>") + "$<$:${_obs_clang_cxx_options}>" + $<$>:/Gy>) add_compile_definitions(UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS $<$:DEBUG> $<$:_DEBUG>) -add_link_options("$<$>:/OPT:REF>" "$<$:/INCREMENTAL:NO>" - "$<$:/INCREMENTAL:NO>" "$<$:/OPT:ICF>") +# cmake-format: off +add_link_options($<$>:/OPT:REF> + $<$>:/OPT:ICF> + $<$>:/INCREMENTAL:NO> + /DEBUG + /Brepro) +# cmake-format: on if(CMAKE_COMPILE_WARNING_AS_ERROR) add_link_options(/WX)