Skip to content

Commit

Permalink
Update build scripts according to the latest obs-plugintemplate (#87)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
umireon authored Apr 15, 2024
1 parent f79571f commit f430716
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-macos-codesigning/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
24 changes: 12 additions & 12 deletions .github/scripts/Package-Windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
}
Expand All @@ -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
55 changes: 37 additions & 18 deletions .github/workflows/build-project.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 ☑️
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -161,7 +180,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand All @@ -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
Expand All @@ -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
Expand All @@ -232,7 +251,7 @@ jobs:
run:
shell: pwsh
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand Down Expand Up @@ -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*.*
4 changes: 2 additions & 2 deletions .github/workflows/check-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 🐉
Expand All @@ -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 🎛️
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions cmake/common/bootstrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions cmake/common/helpers_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
16 changes: 0 additions & 16 deletions cmake/macos/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<TARGET_BUNDLE_DIR:${target}>.dsym"
Expand Down
26 changes: 22 additions & 4 deletions cmake/windows/compilerconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -20,15 +29,24 @@ if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348)
endif()

add_compile_options(
/W3 /utf-8 "$<$<COMPILE_LANG_AND_ID:C,MSVC>:/MP>" "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/MP>"
/W3
/utf-8
"$<$<COMPILE_LANG_AND_ID:C,MSVC>:/MP>"
"$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/MP>"
"$<$<COMPILE_LANG_AND_ID:C,Clang>:${_obs_clang_c_options}>"
"$<$<COMPILE_LANG_AND_ID:CXX,Clang>:${_obs_clang_cxx_options}>")
"$<$<COMPILE_LANG_AND_ID:CXX,Clang>:${_obs_clang_cxx_options}>"
$<$<NOT:$<CONFIG:Debug>>:/Gy>)

add_compile_definitions(UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS $<$<CONFIG:DEBUG>:DEBUG>
$<$<CONFIG:DEBUG>:_DEBUG>)

add_link_options("$<$<NOT:$<CONFIG:Debug>>:/OPT:REF>" "$<$<CONFIG:Debug>:/INCREMENTAL:NO>"
"$<$<CONFIG:RelWithDebInfo>:/INCREMENTAL:NO>" "$<$<CONFIG:RelWithDebInfo>:/OPT:ICF>")
# cmake-format: off
add_link_options($<$<NOT:$<CONFIG:Debug>>:/OPT:REF>
$<$<NOT:$<CONFIG:Debug>>:/OPT:ICF>
$<$<NOT:$<CONFIG:Debug>>:/INCREMENTAL:NO>
/DEBUG
/Brepro)
# cmake-format: on

if(CMAKE_COMPILE_WARNING_AS_ERROR)
add_link_options(/WX)
Expand Down

0 comments on commit f430716

Please sign in to comment.