From e00f065534fffc9328a0c15538573d5d66679c46 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Thu, 13 Jun 2024 17:17:25 +0200 Subject: [PATCH] use new plugin template (#1) --- .cmake-format.json | 40 + .github/actions/build-plugin/action.yaml | 106 +++ .github/actions/build-plugin/action.yml | 77 -- .github/actions/package-plugin/action.yaml | 117 +++ .github/actions/package-plugin/action.yml | 99 --- .github/actions/run-clang-format/action.yaml | 61 ++ .github/actions/run-cmake-format/action.yaml | 59 ++ .../setup-macos-codesigning/action.yaml | 154 ++++ .github/scripts/.Aptfile | 15 +- .github/scripts/.Brewfile | 12 +- .github/scripts/.Wingetfile | 5 +- .github/scripts/.build.zsh | 243 +++--- .github/scripts/.package.zsh | 213 ++++-- .github/scripts/Build-Windows.ps1 | 206 +++--- .github/scripts/Package-Windows.ps1 | 189 ++--- .../scripts/{build-linux.zsh => build-linux} | 0 .github/scripts/build-linux.sh | 13 - .../scripts/{build-macos.zsh => build-macos} | 0 .github/scripts/check-changes.sh | 11 - .github/scripts/check-cmake.sh | 53 -- .github/scripts/check-format.sh | 60 -- .../{package-linux.zsh => package-linux} | 0 .github/scripts/package-linux.sh | 13 - .../{package-macos.zsh => package-macos} | 0 .github/scripts/utils.pwsh/Check-Git.ps1 | 25 - .../scripts/utils.pwsh/Ensure-Location.ps1 | 58 +- .../scripts/utils.pwsh/Expand-ArchiveExt.ps1 | 140 ++-- .../utils.pwsh/Install-BuildDependencies.ps1 | 130 ++-- .../scripts/utils.pwsh/Invoke-External.ps1 | 80 +- .../scripts/utils.pwsh/Invoke-GitCheckout.ps1 | 117 --- .github/scripts/utils.pwsh/Logger.ps1 | 272 ++++--- .github/scripts/utils.pwsh/Setup-Host.ps1 | 103 --- .github/scripts/utils.pwsh/Setup-Obs.ps1 | 84 --- .github/scripts/utils.zsh/check_linux | 37 +- .github/scripts/utils.zsh/check_macos | 8 +- .github/scripts/utils.zsh/check_packages | 52 -- .github/scripts/utils.zsh/log_debug | 2 +- .github/scripts/utils.zsh/log_error | 2 +- .github/scripts/utils.zsh/log_group | 16 + .github/scripts/utils.zsh/log_warning | 2 +- .github/scripts/utils.zsh/read_codesign | 4 +- .../scripts/utils.zsh/read_codesign_installer | 2 +- .github/scripts/utils.zsh/read_codesign_pass | 13 +- .github/scripts/utils.zsh/read_codesign_team | 7 + .github/scripts/utils.zsh/read_codesign_user | 4 +- .github/scripts/utils.zsh/setup_ccache | 32 +- .github/scripts/utils.zsh/setup_linux | 67 +- .github/scripts/utils.zsh/setup_macos | 127 ---- .github/scripts/utils.zsh/setup_obs | 122 --- .github/workflows/build-project.yaml | 282 +++++++ .github/workflows/build.yml | 317 -------- .github/workflows/check-format.yaml | 15 + .github/workflows/dispatch.yaml | 18 + .github/workflows/pr-pull.yaml | 27 + .github/workflows/push.yaml | 122 +++ CMakeLists.txt | 121 ++- CMakePresets.json | 190 +++++ build-aux/.functions/log_debug | 3 + build-aux/.functions/log_error | 3 + build-aux/.functions/log_group | 16 + build-aux/.functions/log_info | 7 + build-aux/.functions/log_output | 7 + build-aux/.functions/log_status | 7 + build-aux/.functions/log_warning | 7 + build-aux/.functions/set_loglevel | 17 + build-aux/.run-format.zsh | 188 +++++ build-aux/run-clang-format | 1 + build-aux/run-cmake-format | 1 + build-aux/run-swift-format | 1 + buildspec.json | 86 +-- cmake/Bundle/macos/Plugin-Info.plist.in | 26 - cmake/Bundle/macos/entitlements.plist | 17 - cmake/ObsPluginHelpers.cmake | 699 ------------------ cmake/common/bootstrap.cmake | 75 ++ cmake/common/buildnumber.cmake | 21 + cmake/common/buildspec_common.cmake | 215 ++++++ cmake/common/ccache.cmake | 22 + cmake/common/compiler_common.cmake | 87 +++ cmake/common/helpers_common.cmake | 143 ++++ cmake/common/osconfig.cmake | 22 + cmake/linux/compilerconfig.cmake | 85 +++ cmake/linux/defaults.cmake | 86 +++ cmake/linux/helpers.cmake | 74 ++ .../toolchains/aarch64-linux-clang.cmake | 56 ++ .../linux/toolchains/aarch64-linux-gcc.cmake | 20 + .../linux/toolchains/x86_64-linux-clang.cmake | 56 ++ cmake/linux/toolchains/x86_64-linux-gcc.cmake | 20 + cmake/macos/buildspec.cmake | 34 + cmake/macos/compilerconfig.cmake | 57 ++ cmake/macos/defaults.cmake | 49 ++ cmake/macos/helpers.cmake | 94 +++ cmake/macos/resources/ccache-launcher-c.in | 17 + cmake/macos/resources/ccache-launcher-cxx.in | 17 + cmake/macos/resources/create-package.cmake.in | 35 + cmake/macos/resources/distribution.in | 33 + .../resources}/installer-macos.pkgproj.in | 10 +- cmake/macos/xcode.cmake | 174 +++++ cmake/windows/buildspec.cmake | 24 + cmake/windows/compilerconfig.cmake | 53 ++ cmake/windows/defaults.cmake | 8 + cmake/windows/helpers.cmake | 131 ++++ .../resources/installer-Windows.iss.in | 64 ++ cmake/windows/resources/resource.rc.in | 32 + config-dialog.hpp | 3 - file-updater.c | 26 +- installer.iss.in | 143 ---- multistream.cpp | 7 +- multistream.hpp | 11 +- 108 files changed, 4362 insertions(+), 3072 deletions(-) create mode 100644 .cmake-format.json create mode 100644 .github/actions/build-plugin/action.yaml delete mode 100644 .github/actions/build-plugin/action.yml create mode 100644 .github/actions/package-plugin/action.yaml delete mode 100644 .github/actions/package-plugin/action.yml create mode 100644 .github/actions/run-clang-format/action.yaml create mode 100644 .github/actions/run-cmake-format/action.yaml create mode 100644 .github/actions/setup-macos-codesigning/action.yaml rename .github/scripts/{build-linux.zsh => build-linux} (100%) delete mode 100755 .github/scripts/build-linux.sh rename .github/scripts/{build-macos.zsh => build-macos} (100%) delete mode 100755 .github/scripts/check-changes.sh delete mode 100755 .github/scripts/check-cmake.sh delete mode 100755 .github/scripts/check-format.sh rename .github/scripts/{package-linux.zsh => package-linux} (100%) delete mode 100755 .github/scripts/package-linux.sh rename .github/scripts/{package-macos.zsh => package-macos} (100%) delete mode 100755 .github/scripts/utils.pwsh/Check-Git.ps1 delete mode 100755 .github/scripts/utils.pwsh/Invoke-GitCheckout.ps1 delete mode 100755 .github/scripts/utils.pwsh/Setup-Host.ps1 delete mode 100755 .github/scripts/utils.pwsh/Setup-Obs.ps1 delete mode 100755 .github/scripts/utils.zsh/check_packages create mode 100755 .github/scripts/utils.zsh/log_group create mode 100755 .github/scripts/utils.zsh/read_codesign_team delete mode 100755 .github/scripts/utils.zsh/setup_macos delete mode 100755 .github/scripts/utils.zsh/setup_obs create mode 100644 .github/workflows/build-project.yaml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/check-format.yaml create mode 100644 .github/workflows/dispatch.yaml create mode 100644 .github/workflows/pr-pull.yaml create mode 100644 .github/workflows/push.yaml create mode 100644 CMakePresets.json create mode 100755 build-aux/.functions/log_debug create mode 100755 build-aux/.functions/log_error create mode 100755 build-aux/.functions/log_group create mode 100755 build-aux/.functions/log_info create mode 100755 build-aux/.functions/log_output create mode 100755 build-aux/.functions/log_status create mode 100755 build-aux/.functions/log_warning create mode 100755 build-aux/.functions/set_loglevel create mode 100755 build-aux/.run-format.zsh create mode 120000 build-aux/run-clang-format create mode 120000 build-aux/run-cmake-format create mode 120000 build-aux/run-swift-format delete mode 100644 cmake/Bundle/macos/Plugin-Info.plist.in delete mode 100644 cmake/Bundle/macos/entitlements.plist delete mode 100644 cmake/ObsPluginHelpers.cmake create mode 100644 cmake/common/bootstrap.cmake create mode 100644 cmake/common/buildnumber.cmake create mode 100644 cmake/common/buildspec_common.cmake create mode 100644 cmake/common/ccache.cmake create mode 100644 cmake/common/compiler_common.cmake create mode 100644 cmake/common/helpers_common.cmake create mode 100644 cmake/common/osconfig.cmake create mode 100644 cmake/linux/compilerconfig.cmake create mode 100644 cmake/linux/defaults.cmake create mode 100644 cmake/linux/helpers.cmake create mode 100644 cmake/linux/toolchains/aarch64-linux-clang.cmake create mode 100644 cmake/linux/toolchains/aarch64-linux-gcc.cmake create mode 100644 cmake/linux/toolchains/x86_64-linux-clang.cmake create mode 100644 cmake/linux/toolchains/x86_64-linux-gcc.cmake create mode 100644 cmake/macos/buildspec.cmake create mode 100644 cmake/macos/compilerconfig.cmake create mode 100644 cmake/macos/defaults.cmake create mode 100644 cmake/macos/helpers.cmake create mode 100644 cmake/macos/resources/ccache-launcher-c.in create mode 100644 cmake/macos/resources/ccache-launcher-cxx.in create mode 100644 cmake/macos/resources/create-package.cmake.in create mode 100644 cmake/macos/resources/distribution.in rename cmake/{Bundle/macos => macos/resources}/installer-macos.pkgproj.in (98%) create mode 100644 cmake/macos/xcode.cmake create mode 100644 cmake/windows/buildspec.cmake create mode 100644 cmake/windows/compilerconfig.cmake create mode 100644 cmake/windows/defaults.cmake create mode 100644 cmake/windows/helpers.cmake create mode 100644 cmake/windows/resources/installer-Windows.iss.in create mode 100644 cmake/windows/resources/resource.rc.in delete mode 100644 installer.iss.in diff --git a/.cmake-format.json b/.cmake-format.json new file mode 100644 index 0000000..b70e8c5 --- /dev/null +++ b/.cmake-format.json @@ -0,0 +1,40 @@ +{ + "format": { + "line_width": 120, + "tab_size": 2, + "enable_sort": true, + "autosort": true + }, + "additional_commands": { + "find_qt": { + "flags": [], + "kwargs": { + "COMPONENTS": "+", + "COMPONENTS_WIN": "+", + "COMPONENTS_MACOS": "+", + "COMPONENTS_LINUX": "+" + } + }, + "set_target_properties_obs": { + "pargs": 1, + "flags": [], + "kwargs": { + "PROPERTIES": { + "kwargs": { + "PREFIX": 1, + "OUTPUT_NAME": 1, + "FOLDER": 1, + "VERSION": 1, + "SOVERSION": 1, + "AUTOMOC": 1, + "AUTOUIC": 1, + "AUTORCC": 1, + "AUTOUIC_SEARCH_PATHS": 1, + "BUILD_RPATH": 1, + "INSTALL_RPATH": 1 + } + } + } + } + } +} diff --git a/.github/actions/build-plugin/action.yaml b/.github/actions/build-plugin/action.yaml new file mode 100644 index 0000000..aeede62 --- /dev/null +++ b/.github/actions/build-plugin/action.yaml @@ -0,0 +1,106 @@ +name: 'Set up and build plugin' +description: 'Builds the plugin for specified architecture and build config' +inputs: + target: + description: 'Target architecture for dependencies' + required: true + config: + description: 'Build configuration' + required: false + default: 'RelWithDebInfo' + codesign: + description: 'Enable codesigning (macOS only)' + required: false + default: 'false' + codesignIdent: + description: 'Developer ID for application codesigning (macOS only)' + required: false + default: '-' + workingDirectory: + description: 'Working directory for packaging' + required: false + default: ${{ github.workspace }} +runs: + using: composite + steps: + - name: Run macOS Build + if: runner.os == 'macOS' + shell: zsh --no-rcs --errexit --pipefail {0} + working-directory: ${{ inputs.workingDirectory }} + env: + CODESIGN_IDENT: ${{ inputs.codesignIdent }} + CODESIGN_TEAM: ${{ inputs.codesignTeam }} + run: | + : Run macOS Build + + local -a build_args=(--config ${{ inputs.config }}) + if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) + + if [[ '${{ inputs.codesign }}' == 'true' ]] build_args+=(--codesign) + + .github/scripts/build-macos ${build_args} + + - name: Install Dependencies 🛍️ + if: runner.os == 'Linux' + shell: bash + run: | + : Install Dependencies 🛍️ + echo ::group::Install Dependencies + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + brew install --quiet zsh + echo ::endgroup:: + + - name: Run Ubuntu Build + if: runner.os == 'Linux' + shell: zsh --no-rcs --errexit --pipefail {0} + working-directory: ${{ inputs.workingDirectory }} + run: | + : Run Ubuntu Build + + local -a build_args=( + --target linux-${{ inputs.target }} + --config ${{ inputs.config }} + ) + if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) + + .github/scripts/build-linux ${build_args} + + - name: Run Windows Build + if: runner.os == 'Windows' + shell: pwsh + run: | + # Run Windows Build + if ( $Env:RUNNER_DEBUG -ne $null ) { + Set-PSDebug -Trace 1 + } + + $BuildArgs = @{ + Target = '${{ inputs.target }}' + Configuration = '${{ inputs.config }}' + } + + .github/scripts/Build-Windows.ps1 @BuildArgs + + - name: Create Summary 📊 + if: contains(fromJSON('["Linux", "macOS"]'),runner.os) + shell: zsh --no-rcs --errexit --pipefail {0} + env: + CCACHE_CONFIGPATH: ${{ inputs.workingDirectory }}/.ccache.conf + run: | + : Create Summary 📊 + + local -a ccache_data + if (( ${+RUNNER_DEBUG} )) { + setopt XTRACE + ccache_data=("${(fA)$(ccache -s -vv)}") + } else { + ccache_data=("${(fA)$(ccache -s)}") + } + + print '### ${{ runner.os }} Ccache Stats (${{ inputs.target }})' >> $GITHUB_STEP_SUMMARY + print '```' >> $GITHUB_STEP_SUMMARY + for line (${ccache_data}) { + print ${line} >> $GITHUB_STEP_SUMMARY + } + print '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/actions/build-plugin/action.yml b/.github/actions/build-plugin/action.yml deleted file mode 100644 index 1e91d15..0000000 --- a/.github/actions/build-plugin/action.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: 'Setup and build plugin' -description: 'Builds the plugin for specified architecture and build config.' -inputs: - target: - description: 'Build target for dependencies' - required: true - config: - description: 'Build configuration' - required: false - default: 'Release' - codesign: - description: 'Enable codesigning (macOS only)' - required: false - default: 'false' - codesignIdent: - description: 'Developer ID for application codesigning (macOS only)' - required: false - default: '-' - visualStudio: - description: 'Visual Studio version (Windows only)' - required: false - default: 'Visual Studio 16 2019' - workingDirectory: - description: 'Working directory for packaging' - required: false - default: ${{ github.workspace }} -runs: - using: 'composite' - steps: - - name: Run macOS Build - if: ${{ runner.os == 'macOS' }} - shell: zsh {0} - env: - CODESIGN_IDENT: ${{ inputs.codesignIdent }} - run: | - build_args=( - -c ${{ inputs.config }} - -t macos-${{ inputs.target }} - ) - - if [[ '${{ inputs.codesign }}' == 'true' ]] build_args+=(-s) - if (( ${+CI} && ${+RUNNER_DEBUG} )) build_args+=(--debug) - - ${{ inputs.workingDirectory }}/.github/scripts/build-macos.zsh ${build_args} - - - name: Run Linux Build - if: ${{ runner.os == 'Linux' }} - shell: bash - run: | - build_args=( - -c ${{ inputs.config }} - -t linux-${{ inputs.target }} - ) - - if [[ -n "${CI}" && -n "${RUNNER_DEBUG}" ]]; then - build_args+=(--debug) - fi - - ${{ inputs.workingDirectory }}/.github/scripts/build-linux.sh "${build_args[@]}" - - - name: Run Windows Build - if: ${{ runner.os == 'Windows' }} - shell: pwsh - run: | - $BuildArgs = @{ - Target = '${{ inputs.target }}' - Configuration = '${{ inputs.config }}' - CMakeGenerator = '${{ inputs.visualStudio }}' - } - - if ( ( Test-Path env:CI ) -and ( Test-Path env:RUNNER_DEBUG ) ) { - $BuildArgs += @{ - Debug = $true - } - } - - ${{ inputs.workingDirectory }}/.github/scripts/Build-Windows.ps1 @BuildArgs diff --git a/.github/actions/package-plugin/action.yaml b/.github/actions/package-plugin/action.yaml new file mode 100644 index 0000000..5d31e66 --- /dev/null +++ b/.github/actions/package-plugin/action.yaml @@ -0,0 +1,117 @@ +name: 'Package plugin' +description: 'Packages the plugin for specified architecture and build config.' +inputs: + target: + description: 'Build target for dependencies' + required: true + config: + description: 'Build configuration' + required: false + default: 'RelWithDebInfo' + codesign: + description: 'Enable codesigning (macOS only)' + required: false + default: 'false' + notarize: + description: 'Enable notarization (macOS only)' + required: false + default: 'false' + codesignIdent: + description: 'Developer ID for application codesigning (macOS only)' + required: false + default: '-' + installerIdent: + description: 'Developer ID for installer package codesigning (macOS only)' + required: false + default: '' + codesignTeam: + description: 'Developer team for codesigning (macOS only)' + required: false + default: '' + codesignUser: + description: 'Apple ID username for notarization (macOS only)' + required: false + default: '' + codesignPass: + description: 'Apple ID password for notarization (macOS only)' + required: false + default: '' + package: + description: 'Create Windows or macOS installation package' + required: false + default: 'false' + workingDirectory: + description: 'Working directory for packaging' + required: false + default: ${{ github.workspace }} +runs: + using: composite + steps: + - name: Run macOS Packaging + if: runner.os == 'macOS' + shell: zsh --no-rcs --errexit --pipefail {0} + working-directory: ${{ inputs.workingDirectory }} + env: + CODESIGN_IDENT: ${{ inputs.codesignIdent }} + CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }} + CODESIGN_TEAM: ${{ inputs.codesignTeam }} + CODESIGN_IDENT_USER: ${{ inputs.codesignUser }} + CODESIGN_IDENT_PASS: ${{ inputs.codesignPass }} + run: | + : Run macOS Packaging + + local -a package_args=(--config ${{ inputs.config }}) + if (( ${+RUNNER_DEBUG} )) package_args+=(--debug) + + if [[ '${{ inputs.codesign }}' == 'true' ]] package_args+=(--codesign) + if [[ '${{ inputs.notarize }}' == 'true' ]] package_args+=(--notarize) + if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package) + + .github/scripts/package-macos ${package_args} + + - name: Install Dependencies 🛍️ + if: runner.os == 'Linux' + shell: bash + run: | + : Install Dependencies 🛍️ + echo ::group::Install Dependencies + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + brew install --quiet zsh + echo ::endgroup:: + + - name: Run Ubuntu Packaging + if: runner.os == 'Linux' + shell: zsh --no-rcs --errexit --pipefail {0} + working-directory: ${{ inputs.workingDirectory }} + run: | + : Run Ubuntu Packaging + package_args=( + --target linux-${{ inputs.target }} + --config ${{ inputs.config }} + ) + if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) + + if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package) + + .github/scripts/package-linux ${package_args} + + - name: Run Windows Packaging + if: runner.os == 'Windows' + shell: pwsh + run: | + # Run Windows Packaging + if ( $Env:RUNNER_DEBUG -ne $null ) { + Set-PSDebug -Trace 1 + } + + $PackageArgs = @{ + Target = '${{ inputs.target }}' + Configuration = '${{ inputs.config }}' + } + + if ( '${{ inputs.package }}' -eq 'true' ) { + $PackageArgs += @{BuildInstaller = $true} + } + + .github/scripts/Package-Windows.ps1 @PackageArgs diff --git a/.github/actions/package-plugin/action.yml b/.github/actions/package-plugin/action.yml deleted file mode 100644 index 094803e..0000000 --- a/.github/actions/package-plugin/action.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: 'Package plugin' -description: 'Packages the plugin for specified architecture and build config.' -inputs: - target: - description: 'Build target for dependencies' - required: true - config: - description: 'Build configuration' - required: false - default: 'Release' - codesign: - description: 'Enable codesigning (macOS only)' - required: false - default: 'false' - notarize: - description: 'Enable notarization (macOS only)' - required: false - default: 'false' - codesignIdent: - description: 'Developer ID for application codesigning (macOS only)' - required: false - default: '-' - installerIdent: - description: 'Developer ID for installer package codesigning (macOS only)' - required: false - default: '' - codesignUser: - description: 'Apple ID username for notarization (macOS only)' - required: false - default: '' - codesignPass: - description: 'Apple ID password for notarization (macOS only)' - required: false - default: '' - createInstaller: - description: 'Create InnoSetup installer (Windows only)' - required: false - default: 'false' - workingDirectory: - description: 'Working directory for packaging' - required: false - default: ${{ github.workspace }} -runs: - using: 'composite' - steps: - - name: Run macOS packaging - if: ${{ runner.os == 'macOS' }} - shell: zsh {0} - env: - CODESIGN_IDENT: ${{ inputs.codesignIdent }} - CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }} - CODESIGN_IDENT_USER: ${{ inputs.codesignUser }} - CODESIGN_IDENT_PASS: ${{ inputs.codesignPass }} - run: | - package_args=( - -c ${{ inputs.config }} - -t macos-${{ inputs.target }} - ) - - if [[ '${{ inputs.codesign }}' == 'true' ]] package_args+=(-s) - if [[ '${{ inputs.notarize }}' == 'true' ]] package_args+=(-n) - if (( ${+CI} && ${+RUNNER_DEBUG} )) build_args+=(--debug) - - ${{ inputs.workingDirectory }}/.github/scripts/package-macos.zsh ${package_args} - - - name: Run Linux packaging - if: ${{ runner.os == 'Linux' }} - shell: bash - run: | - package_args=( - -c ${{ inputs.config }} - -t linux-${{ inputs.target }} - ) - if [[ -n "${CI}" && -n "${RUNNER_DEBUG}" ]]; then - build_args+=(--debug) - fi - - ${{ inputs.workingDirectory }}/.github/scripts/package-linux.sh "${package_args[@]}" - - - name: Run Windows packaging - if: ${{ runner.os == 'Windows' }} - shell: pwsh - run: | - $PackageArgs = @{ - Target = '${{ inputs.target }}' - Configuration = '${{ inputs.config }}' - } - - if ( '${{ inputs.createInstaller }}' -eq 'true' ) { - $PackageArgs += @{BuildInstaller = $true} - } - - if ( ( Test-Path env:CI ) -and ( Test-Path env:RUNNER_DEBUG ) ) { - $BuildArgs += @{ - Debug = $true - } - } - - ${{ inputs.workingDirectory }}/.github/scripts/Package-Windows.ps1 @PackageArgs diff --git a/.github/actions/run-clang-format/action.yaml b/.github/actions/run-clang-format/action.yaml new file mode 100644 index 0000000..9e873b4 --- /dev/null +++ b/.github/actions/run-clang-format/action.yaml @@ -0,0 +1,61 @@ +name: Run clang-format +description: Runs clang-format and checks for any changes introduced by it +inputs: + failCondition: + description: Controls whether failed checks also fail the workflow run + required: false + default: 'never' + workingDirectory: + description: Working directory for checks + required: false + default: ${{ github.workspace }} +runs: + using: composite + steps: + - name: Check Runner Operating System 🏃‍♂️ + if: runner.os == 'Windows' + shell: bash + run: | + : Check Runner Operating System 🏃‍♂️ + echo "::notice::run-clang-format action requires a macOS-based or Linux-based runner." + exit 2 + + - name: Install Dependencies 🛍️ + if: runner.os == 'Linux' + shell: bash + run: | + : Install Dependencies 🛍️ + echo ::group::Install Dependencies + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + echo "/home/linuxbrew/.linuxbrew/opt/clang-format@16/bin" >> $GITHUB_PATH + brew install --quiet zsh + echo ::endgroup:: + + - name: Run clang-format 🐉 + id: result + shell: zsh --no-rcs --errexit --pipefail {0} + working-directory: ${{ inputs.workingDirectory }} + env: + GITHUB_EVENT_FORCED: ${{ github.event.forced }} + GITHUB_REF_BEFORE: ${{ github.event.before }} + run: | + : Run clang-format 🐉 + if (( ${+RUNNER_DEBUG} )) setopt XTRACE + + local -a changes=($(git diff --name-only HEAD~1 HEAD)) + case ${GITHUB_EVENT_NAME} { + pull_request) changes=($(git diff --name-only origin/${GITHUB_BASE_REF} HEAD)) ;; + push) if [[ ${GITHUB_EVENT_FORCED} != true ]] changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD)) ;; + *) ;; + } + + if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) { + echo ::group::Install clang-format-16 + brew install --quiet obsproject/tools/clang-format@16 + echo ::endgroup:: + + echo ::group::Run clang-format-16 + ./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check + echo ::endgroup:: + } diff --git a/.github/actions/run-cmake-format/action.yaml b/.github/actions/run-cmake-format/action.yaml new file mode 100644 index 0000000..4036026 --- /dev/null +++ b/.github/actions/run-cmake-format/action.yaml @@ -0,0 +1,59 @@ +name: Run cmake-format +description: Runs cmake-format and checks for any changes introduced by it +inputs: + failCondition: + description: Controls whether failed checks also fail the workflow run + required: false + default: 'never' + workingDirectory: + description: Working directory for checks + required: false + default: ${{ github.workspace }} +runs: + using: composite + steps: + - name: Check Runner Operating System 🏃‍♂️ + if: runner.os == 'Windows' + shell: bash + run: | + : Check Runner Operating System 🏃‍♂️ + echo "::notice::run-cmake-format action requires a macOS-based or Linux-based runner." + exit 2 + + - name: Install Dependencies 🛍️ + if: runner.os == 'Linux' + shell: bash + run: | + : Install Dependencies 🛍️ + echo ::group::Install Dependencies + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + brew install --quiet zsh + echo ::endgroup:: + + - name: Run cmake-format 🎛️ + id: result + shell: zsh --no-rcs --errexit --pipefail {0} + working-directory: ${{ github.workspace }} + env: + GITHUB_EVENT_FORCED: ${{ github.event.forced }} + GITHUB_REF_BEFORE: ${{ github.event.before }} + run: | + : Run cmake-format 🎛️ + if (( ${+RUNNER_DEBUG} )) setopt XTRACE + + local -a changes=($(git diff --name-only HEAD~1 HEAD)) + case ${GITHUB_EVENT_NAME} { + pull_request) changes=($(git diff --name-only origin/${GITHUB_BASE_REF} HEAD)) ;; + push) if [[ ${GITHUB_EVENT_FORCED} != true ]] changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD)) ;; + *) ;; + } + + if (( ${changes[(I)*.cmake|*CMakeLists.txt]} )) { + echo ::group::Install cmakelang + pip3 install cmakelang + echo ::endgroup:: + echo ::group::Run cmake-format + ./build-aux/run-cmake-format --fail-${{ inputs.failCondition }} --check + echo ::endgroup:: + } diff --git a/.github/actions/setup-macos-codesigning/action.yaml b/.github/actions/setup-macos-codesigning/action.yaml new file mode 100644 index 0000000..5f24114 --- /dev/null +++ b/.github/actions/setup-macos-codesigning/action.yaml @@ -0,0 +1,154 @@ +name: Set up macOS codesigning +description: Sets up code signing certificates, provisioning profiles, and notarization information +inputs: + codesignIdentity: + description: Codesigning identity + required: true + installerIdentity: + description: Codesigning identity for package installer + required: false + codesignCertificate: + description: PKCS12 certificate in base64 format + required: true + certificatePassword: + description: Password required to install PKCS12 certificate + required: true + keychainPassword: + description: Password to use for temporary keychain + required: false + notarizationUser: + description: Apple ID to use for notarization + required: false + notarizationPassword: + description: Application password for notarization + provisioningProfile: + description: Provisioning profile in base64 format + required: false +outputs: + haveCodesignIdent: + description: True if necessary codesigning credentials were found + value: ${{ steps.codesign.outputs.haveCodesignIdent }} + haveProvisioningProfile: + description: True if necessary provisioning profile credentials were found + value: ${{ steps.provisioning.outputs.haveProvisioningProfile }} + haveNotarizationUser: + description: True if necessary notarization credentials were found + value: ${{ steps.notarization.outputs.haveNotarizationUser }} + codesignIdent: + description: Codesigning identity + value: ${{ steps.codesign.outputs.codesignIdent }} + installerIdent: + description: Codesigning identity for package installer + value: ${{ steps.codesign.outputs.installerIdent }} + codesignTeam: + description: Codesigning team + value: ${{ steps.codesign.outputs.codesignTeam }} +runs: + using: composite + steps: + - name: Check Runner Operating System 🏃‍♂️ + if: runner.os != 'macOS' + shell: bash + run: | + : Check Runner Operating System 🏃‍♂️ + echo "setup-macos-codesigning action requires a macOS-based runner." + exit 2 + + - name: macOS Codesigning ✍️ + shell: zsh --no-rcs --errexit --pipefail {0} + id: codesign + env: + MACOS_SIGNING_IDENTITY: ${{ inputs.codesignIdentity }} + MACOS_SIGNING_IDENTITY_INSTALLER: ${{ inputs.installerIdentity}} + MACOS_SIGNING_CERT: ${{ inputs.codesignCertificate }} + MAOCS_SIGNING_CERT_PASSWORD: ${{ inputs.certificatePassword }} + MACOS_KEYCHAIN_PASSWORD: ${{ inputs.keychainPassword }} + run: | + : macOS Codesigning ✍️ + if (( ${+RUNNER_DEBUG} )) setopt XTRACE + + if [[ ${MACOS_SIGNING_IDENTITY} && ${MACOS_SIGNING_IDENTITY_INSTALLER} && ${MACOS_SIGNING_CERT} ]] { + print 'haveCodesignIdent=true' >> $GITHUB_OUTPUT + + local -r certificate_path="${RUNNER_TEMP}/build_certificate.p12" + local -r keychain_path="${RUNNER_TEMP}/app-signing.keychain-db" + + print -n "${MACOS_SIGNING_CERT}" | base64 --decode --output="${certificate_path}" + + : "${MACOS_KEYCHAIN_PASSWORD:="$(print ${RANDOM} | shasum | head -c 32)"}" + + print '::group::Keychain setup' + security create-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path} + security set-keychain-settings -lut 21600 ${keychain_path} + security unlock-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path} + + security import "${certificate_path}" -P "${MAOCS_SIGNING_CERT_PASSWORD}" -A \ + -t cert -f pkcs12 -k ${keychain_path} \ + -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun + + security set-key-partition-list -S 'apple-tool:,apple:' -k "${MACOS_KEYCHAIN_PASSWORD}" \ + ${keychain_path} &> /dev/null + + security list-keychain -d user -s ${keychain_path} 'login-keychain' + print '::endgroup::' + + local -r team_id="${${MACOS_SIGNING_IDENTITY##* }//(\(|\))/}" + + print "codesignIdent=${MACOS_SIGNING_IDENTITY}" >> $GITHUB_OUTPUT + print "installerIdent=${MACOS_SIGNING_IDENTITY_INSTALLER}" >> $GITHUB_OUTPUT + print "MACOS_KEYCHAIN_PASSWORD=${MACOS_KEYCHAIN_PASSWORD}" >> $GITHUB_ENV + print "codesignTeam=${team_id}" >> $GITHUB_OUTPUT + } else { + print 'haveCodesignIdent=false' >> $GITHUB_OUTPUT + } + + - name: Provisioning Profile 👤 + shell: zsh --no-rcs --errexit --pipefail {0} + id: provisioning + if: ${{ fromJSON(steps.codesign.outputs.haveCodesignIdent) }} + env: + MACOS_SIGNING_PROVISIONING_PROFILE: ${{ inputs.provisioningProfile }} + run: | + : Provisioning Profile 👤 + if (( ${+RUNNER_DEBUG} )) setopt XTRACE + + if [[ ${MACOS_SIGNING_PROVISIONING_PROFILE} ]] { + print 'haveProvisioningProfile=true' >> $GITHUB_OUTPUT + + local -r profile_path="${RUNNER_TEMP}/build_profile.provisionprofile" + print -n "${MACOS_SIGNING_PROVISIONING_PROFILE}" \ + | base64 --decode --output ${profile_path} + + print '::group::Provisioning Profile Setup' + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + security cms -D -i ${profile_path} -o ${RUNNER_TEMP}/build_profile.plist + local -r uuid="$(plutil -extract UUID raw ${RUNNER_TEMP}/build_profile.plist)" + local -r team_id="$(plutil -extract TeamIdentifier.0 raw -expect string ${RUNNER_TEMP}/build_profile.plist)" + + if [[ ${team_id} != '${{ steps.codesign.codesignTeam }}' ]] { + print '::notice::Code Signing team in provisioning profile does not match certificate.' + } + + cp ${profile_path} ~/Library/MobileDevice/Provisioning\ Profiles/${uuid}.provisionprofile + print "provisioningProfileUUID=${uuid}" >> $GITHUB_OUTPUT + print '::endgroup::' + } else { + print 'haveProvisioningProfile=false' >> $GITHUB_OUTPUT + } + + - name: Notarization 🧑‍💼 + shell: zsh --no-rcs --errexit --pipefail {0} + id: notarization + if: ${{ fromJSON(steps.codesign.outputs.haveCodesignIdent) }} + env: + MACOS_NOTARIZATION_USERNAME: ${{ inputs.notarizationUser }} + MACOS_NOTARIZATION_PASSWORD: ${{ inputs.notarizationPassword }} + run: | + : Notarization 🧑‍💼 + if (( ${+RUNNER_DEBUG} )) setopt XTRACE + + if [[ ${MACOS_NOTARIZATION_USERNAME} && ${MACOS_NOTARIZATION_PASSWORD} ]] { + print 'haveNotarizationUser=true' >> $GITHUB_OUTPUT + } else { + print 'haveNotarizationUser=false' >> $GITHUB_OUTPUT + } diff --git a/.github/scripts/.Aptfile b/.github/scripts/.Aptfile index 9323a77..09efc11 100755 --- a/.github/scripts/.Aptfile +++ b/.github/scripts/.Aptfile @@ -1,9 +1,6 @@ -package 'cmake' -package 'ccache' -package 'curl' -package 'git' -package 'jq' -package 'ninja-build', bin: 'ninja' -package 'pkg-config' -package 'clang' -package 'clang-format-13' +package 'cmake' +package 'ccache' +package 'git' +package 'jq' +package 'ninja-build', bin: 'ninja' +package 'pkg-config' diff --git a/.github/scripts/.Brewfile b/.github/scripts/.Brewfile index db055c3..8368e3d 100755 --- a/.github/scripts/.Brewfile +++ b/.github/scripts/.Brewfile @@ -1,6 +1,6 @@ -brew "ccache" -brew "coreutils" -brew "cmake" -brew "git" -brew "jq" -brew "ninja" +brew "ccache" +brew "coreutils" +brew "cmake" +brew "git" +brew "jq" +brew "xcbeautify" diff --git a/.github/scripts/.Wingetfile b/.github/scripts/.Wingetfile index a89c429..6d6b9ae 100755 --- a/.github/scripts/.Wingetfile +++ b/.github/scripts/.Wingetfile @@ -1,3 +1,2 @@ -package '7zip.7zip', path: '7-zip', bin: '7z' -package 'cmake', path: 'Cmake\bin', bin: 'cmake' -package 'innosetup', path: 'Inno Setup 6', bin: 'iscc' +package 'cmake', path: 'Cmake\bin', bin: 'cmake' +package 'innosetup', path: 'Inno Setup 6', bin: 'iscc' diff --git a/.github/scripts/.build.zsh b/.github/scripts/.build.zsh index b5898ba..708fdcf 100755 --- a/.github/scripts/.build.zsh +++ b/.github/scripts/.build.zsh @@ -17,55 +17,76 @@ setopt FUNCTION_ARGZERO # setopt XTRACE autoload -Uz is-at-least && if ! is-at-least 5.2; then - print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." + print -u2 -PR "${CI:+::error::}%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." exit 1 fi -_trap_error() { - print -u2 -PR '%F{1} ✖︎ script execution error%f' - print -PR -e " +TRAPEXIT() { + local return_value=$? + + if (( ${+CI} )) unset NSUnbufferedIO + + return ${return_value} +} + +TRAPZERR() { + if (( ${_loglevel:-3} > 2 )) { + print -u2 -PR "${CI:+::error::}%F{1} ✖︎ script execution error%f" + print -PR -e " Callstack: ${(j:\n :)funcfiletrace} - " + " + } + exit 2 } build() { if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]} - local target="${host_os}-${CPUTYPE}" local project_root=${SCRIPT_HOME:A:h:h} - local buildspec_file="${project_root}/buildspec.json" - - trap '_trap_error' ZERR + local buildspec_file=${project_root}/buildspec.json fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) - autoload -Uz log_info log_error log_output set_loglevel check_${host_os} setup_${host_os} setup_obs setup_ccache + autoload -Uz log_group log_info log_error log_output set_loglevel check_${host_os} setup_ccache if [[ ! -r ${buildspec_file} ]] { log_error \ - 'No buildspec.json found. Please create a build specification for your project.' \ - 'A buildspec.json.template file is provided in the repository to get you started.' + 'No buildspec.json found. Please create a build specification for your project.' return 2 } typeset -g -a skips=() - local -i _verbosity=1 - local -r _version='1.0.0' + local -i verbosity=1 + local -r _version='2.0.0' local -r -a _valid_targets=( - macos-x86_64 - macos-arm64 macos-universal linux-x86_64 + linux-aarch64 ) + local target + local config='RelWithDebInfo' local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) - if [[ ${host_os} == 'macos' ]] { - local -r -a _valid_generators=(Xcode Ninja 'Unix Makefiles') - local generator="${${CI:+Ninja}:-Xcode}" - } else { + local -i codesign=0 + + if [[ ${host_os} == linux ]] { local -r -a _valid_generators=(Ninja 'Unix Makefiles') local generator='Ninja' + local -r _usage_host=" +%F{yellow} Additional options for Linux builds%f + ----------------------------------------------------------------------------- + %B--generator%b Specify build system to generate + Available generators: + - Ninja + - Unix Makefiles" + } elif [[ ${host_os} == macos ]] { + local -r _usage_host=" +%F{yellow} Additional options for macOS builds%f + ----------------------------------------------------------------------------- + %B-s | --codesign%b Enable codesigning (macOS only)" } + + local -i print_config=0 local -r _usage=" Usage: %B${functrace[1]%:*}%b