From e0c4ad23c8a4555fe537ac3c396bf792f00779d7 Mon Sep 17 00:00:00 2001 From: Josh Wong Date: Sun, 5 Dec 2021 13:02:35 -0800 Subject: [PATCH 1/3] Added Chinese and Turkish localizations Thanks to qwe1154323937 and homes on the OBS forums for the Chinese and Turkish localizations respectively --- data/locale/tr-TR.ini | 78 +++++++++++++++++++++++++++++++++++++++++++ data/locale/zh-CN.ini | 78 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 data/locale/tr-TR.ini create mode 100644 data/locale/zh-CN.ini diff --git a/data/locale/tr-TR.ini b/data/locale/tr-TR.ini new file mode 100644 index 0000000..d3c4ac1 --- /dev/null +++ b/data/locale/tr-TR.ini @@ -0,0 +1,78 @@ +TextFreetype2Slideshow="Text Slide Show (Free Type 2)" +TextGdiplusSlideshow="Text Slide Show (GDI+)" + +SlideShow.TransitionSpeed="Geçiş hızı (milisaniye)" +SlideShow.SlideTime="Slaytlar Arasındaki Süre (milisaniye)" +SlideShow.Texts="Slayt Metinleri" +SlideShow.CustomSize="Sınırlayıcı Boyut/En Boy Oranı" +SlideShow.CustomSize.Auto="Otomatik" +SlideShow.Randomize="Rastgele Oynatma" +SlideShow.Loop="Döngü" +SlideShow.Transition="Geçiş" +SlideShow.Transition.Cut="Kes" +SlideShow.Transition.Fade="Soldur" +SlideShow.Transition.Swipe="Kaydır" +SlideShow.Transition.Slide="Slayt" +SlideShow.PlaybackBehavior="Görünürlük Davranışı" +SlideShow.PlaybackBehavior.StopRestart="Görünmediğinde dur, görünür olduğunda yeniden başlat" +SlideShow.PlaybackBehavior.PauseUnpause="Görünmediğinde duraklat, görünür olduğunda duraklat" +SlideShow.PlaybackBehavior.AlwaysPlay="Görünmediğinde bile her zaman oynat" +SlideShow.SlideMode="Slayt Modu" +SlideShow.SlideMode.Auto="Otomatik" +SlideShow.SlideMode.Manual="Manuel (Slayt gösterisini kontrol etmek için kısayol tuşlarını kullanın)" +SlideShow.PlayPause="Oynat/Durdur" +SlideShow.Restart="Tekrar başlat" +SlideShow.Stop="Dur" +SlideShow.NextSlide="Sonraki Slayt" +SlideShow.PreviousSlide="Önceki Slayt" +SlideShow.HideWhenDone="Slayt gösterisi bittiğinde gizle" +SlideShow.ReadFromSingleFile="Tek dosyadan oku" +SlideShow.UseCustomDelim="Özel Sınırlayıcıyı Kullan" +SlideShow.CustomDelim="Özel Sınırlayıcı" +SlideShow.TextFile="Metin dosyası (UTF-8)" +SlideShow.Filter.TextFiles="Metin Dosyaları" +SlideShow.Filter.AllFiles="Tüm dosyalar" +Slideshow.ReadFromMultipleFiles="Birden çok dosyadan okuma" +Slideshow.Files="Metin Dosyaları (UTF-8)" + +Text.Font="Yazı tipi" +Text.Text="Metin" +Text.Color="Renk" +Text.Opacity="Opaklık" +Text.Gradient="Eğim" +Text.Gradient.Color="Eğim Rengi" +Text.Gradient.Opacity="Eğim Saydamlığı" +Text.Gradient.Direction="Eğim Yönü" +Text.BkColor="Arka Plan Rengi" +Text.BkOpacity="Arka Plan Saydamlığı" +Text.Alignment="Hizalama" +Text.Alignment.Left="Sol" +Text.Alignment.Center="Ortala" +Text.Alignment.Right="Sağ" +Text.Vertical="Dikey" +Text.VerticalAlignment="Dikey hizalama" +Text.VerticalAlignment.Top="Üst" +Text.VerticalAlignment.Bottom="Alt" +Text.Outline="Anahat" +Text.Outline.Size="Anahat Boyutu" +Text.Outline.Color="Anahat Rengi" +Text.Outline.Opacity="Anahat Opaklığı" +Text.ChatlogMode="Sohbet Günlük Modu" +Text.ChatlogMode.Lines="Sohbet Günlüğü Hat Sınırı" +Text.UseCustomExtents="İsteğe Bağlı Metin Boyutunu Kullan" +Text.UseCustomExtents.Wrap="Metni Kaydır" +Text.Width="Genişlik" +Text.Height="Yükseklik" +Text.Transform="Metin Dönüştürme" +Text.Transform.None="Hiçbiri" +Text.Transform.Uppercase="Büyük harf" +Text.Transform.Lowercase="Küçük harf" +Text.Transform.Startcase="Davayı Başlat" +Text.Antialiasing="Yumuşatmayı Etkinleştir" +Text.ChatLogLines="Sohbet günlüğü satırları" +Text.Color1="Color 1" +Text.Color2="Color 2" +Text.Outline="Anahat" +Text.DropShadow="Düşen Gölge" +Text.CustomWidth="Özel metin genişliği" +Text.WordWrap="Kelime Sarma" \ No newline at end of file diff --git a/data/locale/zh-CN.ini b/data/locale/zh-CN.ini new file mode 100644 index 0000000..e9ecb33 --- /dev/null +++ b/data/locale/zh-CN.ini @@ -0,0 +1,78 @@ +TextFreetype2Slideshow="文字幻灯片(Free Type 2)" +TextGdiplusSlideshow="文字幻灯片 (GDI+)" + +SlideShow.TransitionSpeed="转换速度(毫秒)" +SlideShow.SlideTime="幻灯片之间的时间(毫秒)" +SlideShow.Texts="幻灯片文本" +SlideShow.CustomSize="边界尺寸/纵横比" +SlideShow.CustomSize.Auto="自动" +SlideShow.Randomize="随机播放" +SlideShow.Loop="循环" +SlideShow.Transition="过渡" +SlideShow.Transition.Cut="切换" +SlideShow.Transition.Fade="淡出" +SlideShow.Transition.Swipe="滑动" +SlideShow.Transition.Slide="飞入" +SlideShow.PlaybackBehavior="可见性行为" +SlideShow.PlaybackBehavior.StopRestart="不可见时停止,可见时重新启动" +SlideShow.PlaybackBehavior.PauseUnpause="不可见时暂停,可见时取消暂停" +SlideShow.PlaybackBehavior.AlwaysPlay="即使不可见也始终播放" +SlideShow.SlideMode="滑动模式" +SlideShow.SlideMode.Auto="自动" +SlideShow.SlideMode.Manual="手动(使用热键控制幻灯片)" +SlideShow.PlayPause="播放/暂停" +SlideShow.Restart="重新开始" +SlideShow.Stop="停止" +SlideShow.NextSlide="下一张幻灯片" +SlideShow.PreviousSlide="上一张幻灯片" +SlideShow.HideWhenDone="文字幻灯片播放完成后隐藏" +SlideShow.ReadFromSingleFile="从单个文件读取" +SlideShow.UseCustomDelim="使用自定义分隔符" +SlideShow.CustomDelim="自定义分隔符" +SlideShow.TextFile="文本文件 (UTF-8)" +SlideShow.Filter.TextFiles="文本文件" +SlideShow.Filter.AllFiles="所有文件" +Slideshow.ReadFromMultipleFiles="从多个文件中读取" +Slideshow.Files="文本文件 (UTF-8)" + +Text.Font="字体" +Text.Text="文本" +Text.Color="颜色" +Text.Opacity="不透明度" +Text.Gradient="渐变" +Text.Gradient.Color="渐变色" +Text.Gradient.Opacity="渐变不透明度" +Text.Gradient.Direction="渐变方向" +Text.BkColor="背景颜色" +Text.BkOpacity="背景不透明度" +Text.Alignment="对齐" +Text.Alignment.Left="靠左侧对齐" +Text.Alignment.Center="居中对齐" +Text.Alignment.Right="靠右侧对齐" +Text.Vertical="垂直" +Text.VerticalAlignment="垂直对齐" +Text.VerticalAlignment.Top="顶部" +Text.VerticalAlignment.Bottom="底部" +Text.Outline="轮廓" +Text.Outline.Size="轮廓大小" +Text.Outline.Color="轮廓颜色" +Text.Outline.Opacity="轮廓不透明度" +Text.ChatlogMode="聊天模式" +Text.ChatlogMode.Lines="聊天行限制" +Text.UseCustomExtents="使用自定义文本范围" +Text.UseCustomExtents.Wrap="自动换行" +Text.Width="宽度" +Text.Height="高度" +Text.Transform="文本变换" +Text.Transform.None="无" +Text.Transform.Uppercase="大写" +Text.Transform.Lowercase="小写" +Text.Transform.Startcase="每词首字母大写" +Text.Antialiasing="启用抗锯齿" +Text.ChatLogLines="聊天记录行" +Text.Color1="颜色 1" +Text.Color2="颜色 2" +Text.Outline="轮廓" +Text.DropShadow="投影" +Text.CustomWidth="自定义文本宽度" +Text.WordWrap="自动换行" \ No newline at end of file From bb071ba5ede04f106f95032e677a8c3b161fd5dc Mon Sep 17 00:00:00 2001 From: Josh Wong Date: Sun, 5 Dec 2021 13:05:41 -0800 Subject: [PATCH 2/3] Fixed Italian localization file name --- data/locale/{it_IT.ini => it-IT.ini} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename data/locale/{it_IT.ini => it-IT.ini} (100%) diff --git a/data/locale/it_IT.ini b/data/locale/it-IT.ini similarity index 100% rename from data/locale/it_IT.ini rename to data/locale/it-IT.ini From a22b2efbbcfd89bf4382c9f4da940d851e792a17 Mon Sep 17 00:00:00 2001 From: Josh Wong <34504936+jbwong05@users.noreply.github.com> Date: Wed, 24 May 2023 21:58:13 -0700 Subject: [PATCH 3/3] Update to support OBS v28.0.0 and v29.0.0 (#53) * Updates from new plugin template * Removed old clang github action * Allowed building on all commits * buildspec updates * Fixed linux build * Fix windows pthread linking * Fix duplicate target_link_libraries calls * Include pthread.h * Try direct w32-pthread linking * Fixed windows build * Fixed CMakeLists.txt formatting * Fixed installation target for Ubuntu 22.04.1 * Refactored manual refresh on frontend startup Issue that was present on gdiplus now showed up in freetype2. Janky existing fix was refactored to be added to text-freetype2 * Re-added cmake installation call for macos cmake on linux will perform the local install after building while macos will not. This re-adds the installation call for macos so the packaging script does not fail * Fixed styling error * Pulled in missing commits from obs-studio main repo * Patch for non-interactive text sources on startup On startup and text creation there was an issue where the slideshow would not be interactable. For freetype2 this was due to the new text source returning a width and height of 0. Subsequent updates after the first update would fix the issue. Some code to dynamically keep track of the width and height when available was added to the video render callback. It is a janky fix until the freetype2 issue of not properly setting the width and height can be fixed * Switched to unordered_set for size patch over DARRAY * Cleared out of date sources and updated comment * Single file delimiter parsing fixes (#49) * Complete rewrite of delim parsing logic Complete rewrite of the delim parsing logic with a custom multi character strtok implmentation to fix a lot of the lingering delim parsing bugs due to strtok limitations * Refactor and rewrite delim file parsing Overhaul and refactor delimeter file reading and parsing * Fixed windows build errors * Fix for multi file support Fix for multi file support which was broken by the empty width/height patch * Attempt to fix Ubuntu locale install path (#50) --- .cmake-format.json | 16 + .github/actions/build-plugin/action.yml | 77 ++ .github/actions/package-plugin/action.yml | 99 ++ .github/scripts/.Aptfile | 9 + .github/scripts/.Brewfile | 6 + .github/scripts/.Wingetfile | 3 + .github/scripts/.build.zsh | 249 +++++ .github/scripts/.package.zsh | 193 ++++ .github/scripts/Build-Windows.ps1 | 101 ++ .github/scripts/Package-Windows.ps1 | 92 ++ .github/scripts/build-linux.sh | 13 + .github/scripts/build-linux.zsh | 1 + .github/scripts/build-macos.zsh | 1 + .../scripts/check-changes.sh | 0 .github/scripts/check-cmake.sh | 53 + .github/scripts/check-format.sh | 60 ++ .github/scripts/package-linux.sh | 13 + .github/scripts/package-linux.zsh | 1 + .github/scripts/package-macos.zsh | 1 + .github/scripts/utils.pwsh/Check-Git.ps1 | 25 + .../scripts/utils.pwsh/Ensure-Location.ps1 | 29 + .../scripts/utils.pwsh/Expand-ArchiveExt.ps1 | 70 ++ .../utils.pwsh/Install-BuildDependencies.ps1 | 60 ++ .../scripts/utils.pwsh/Invoke-External.ps1 | 40 + .../scripts/utils.pwsh/Invoke-GitCheckout.ps1 | 117 +++ .github/scripts/utils.pwsh/Logger.ps1 | 123 +++ .github/scripts/utils.pwsh/Setup-Host.ps1 | 103 ++ .github/scripts/utils.pwsh/Setup-Obs.ps1 | 84 ++ .github/scripts/utils.zsh/check_linux | 36 + .github/scripts/utils.zsh/check_macos | 20 + .github/scripts/utils.zsh/check_packages | 52 + .github/scripts/utils.zsh/log_debug | 3 + .github/scripts/utils.zsh/log_error | 3 + .github/scripts/utils.zsh/log_info | 7 + .github/scripts/utils.zsh/log_output | 7 + .github/scripts/utils.zsh/log_status | 7 + .github/scripts/utils.zsh/log_warning | 5 + .github/scripts/utils.zsh/mkcd | 1 + .github/scripts/utils.zsh/read_codesign | 7 + .../scripts/utils.zsh/read_codesign_installer | 7 + .github/scripts/utils.zsh/read_codesign_pass | 33 + .github/scripts/utils.zsh/read_codesign_user | 7 + .github/scripts/utils.zsh/set_loglevel | 17 + .github/scripts/utils.zsh/setup_ccache | 14 + .github/scripts/utils.zsh/setup_linux | 62 ++ .github/scripts/utils.zsh/setup_macos | 127 +++ .github/scripts/utils.zsh/setup_obs | 122 +++ .github/workflows/clang-format.yml | 20 - .github/workflows/main.yml | 495 +++++++--- .gitignore | 1 + CMakeLists.txt | 268 ++--- buildspec.json | 86 ++ ci/ci_includes.cmd.in | 2 - ci/ci_includes.sh.in | 4 - ci/linux/build-ubuntu.sh | 6 - ci/linux/install-dependencies-ubuntu.sh | 19 - ci/linux/package-ubuntu.sh | 20 - ci/macos/build-macos.sh | 26 - ci/macos/install-build-obs-macos.sh | 40 - ci/macos/install-dependencies-macos.sh | 35 - ci/macos/package-macos.sh | 88 -- ci/macos/qt.rb | 163 ---- ci/windows/download-obs-deps.cmd | 6 - ci/windows/install-qt-win.cmd | 8 - ci/windows/package-windows.cmd | 14 - ci/windows/prepare-obs-windows.cmd | 36 - ci/windows/prepare-windows.cmd | 15 - cmake/ObsPluginHelpers.cmake | 704 ++++++++++++++ cmake/bundle/macos/Plugin-Info.plist.in | 26 + cmake/bundle/macos/entitlements.plist | 17 + cmake/bundle/macos/installer-macos.pkgproj.in | 920 ++++++++++++++++++ .../bundle/windows}/installer-Windows.iss.in | 5 +- cmake/bundle/windows/resource.rc.in | 32 + external/FindLibObs.cmake | 107 -- formatcode.sh | 32 - installer/installer-macOS.pkgproj.in | 726 -------------- src/files.cpp | 174 +--- src/files.h | 6 +- src/obs-text-freetype2-slideshow.cpp | 7 +- src/obs-text-gdiplus-slideshow.cpp | 21 +- src/obs-text-slideshow-dock.cpp | 39 +- src/obs-text-slideshow.cpp | 167 +++- src/obs-text-slideshow.h | 5 + src/utils.cpp | 147 +++ src/utils.h | 17 + 85 files changed, 4777 insertions(+), 1903 deletions(-) create mode 100644 .cmake-format.json create mode 100644 .github/actions/build-plugin/action.yml create mode 100644 .github/actions/package-plugin/action.yml create mode 100644 .github/scripts/.Aptfile create mode 100644 .github/scripts/.Brewfile create mode 100644 .github/scripts/.Wingetfile create mode 100755 .github/scripts/.build.zsh create mode 100755 .github/scripts/.package.zsh create mode 100644 .github/scripts/Build-Windows.ps1 create mode 100644 .github/scripts/Package-Windows.ps1 create mode 100755 .github/scripts/build-linux.sh create mode 120000 .github/scripts/build-linux.zsh create mode 120000 .github/scripts/build-macos.zsh rename ci/check-format.sh => .github/scripts/check-changes.sh (100%) create mode 100755 .github/scripts/check-cmake.sh create mode 100755 .github/scripts/check-format.sh create mode 100755 .github/scripts/package-linux.sh create mode 120000 .github/scripts/package-linux.zsh create mode 120000 .github/scripts/package-macos.zsh create mode 100644 .github/scripts/utils.pwsh/Check-Git.ps1 create mode 100644 .github/scripts/utils.pwsh/Ensure-Location.ps1 create mode 100644 .github/scripts/utils.pwsh/Expand-ArchiveExt.ps1 create mode 100644 .github/scripts/utils.pwsh/Install-BuildDependencies.ps1 create mode 100644 .github/scripts/utils.pwsh/Invoke-External.ps1 create mode 100644 .github/scripts/utils.pwsh/Invoke-GitCheckout.ps1 create mode 100644 .github/scripts/utils.pwsh/Logger.ps1 create mode 100644 .github/scripts/utils.pwsh/Setup-Host.ps1 create mode 100644 .github/scripts/utils.pwsh/Setup-Obs.ps1 create mode 100644 .github/scripts/utils.zsh/check_linux create mode 100644 .github/scripts/utils.zsh/check_macos create mode 100644 .github/scripts/utils.zsh/check_packages create mode 100644 .github/scripts/utils.zsh/log_debug create mode 100644 .github/scripts/utils.zsh/log_error create mode 100644 .github/scripts/utils.zsh/log_info create mode 100644 .github/scripts/utils.zsh/log_output create mode 100644 .github/scripts/utils.zsh/log_status create mode 100644 .github/scripts/utils.zsh/log_warning create mode 100644 .github/scripts/utils.zsh/mkcd create mode 100644 .github/scripts/utils.zsh/read_codesign create mode 100644 .github/scripts/utils.zsh/read_codesign_installer create mode 100644 .github/scripts/utils.zsh/read_codesign_pass create mode 100644 .github/scripts/utils.zsh/read_codesign_user create mode 100644 .github/scripts/utils.zsh/set_loglevel create mode 100644 .github/scripts/utils.zsh/setup_ccache create mode 100644 .github/scripts/utils.zsh/setup_linux create mode 100644 .github/scripts/utils.zsh/setup_macos create mode 100644 .github/scripts/utils.zsh/setup_obs delete mode 100644 .github/workflows/clang-format.yml create mode 100644 buildspec.json delete mode 100644 ci/ci_includes.cmd.in delete mode 100644 ci/ci_includes.sh.in delete mode 100755 ci/linux/build-ubuntu.sh delete mode 100755 ci/linux/install-dependencies-ubuntu.sh delete mode 100755 ci/linux/package-ubuntu.sh delete mode 100755 ci/macos/build-macos.sh delete mode 100755 ci/macos/install-build-obs-macos.sh delete mode 100755 ci/macos/install-dependencies-macos.sh delete mode 100755 ci/macos/package-macos.sh delete mode 100644 ci/macos/qt.rb delete mode 100644 ci/windows/download-obs-deps.cmd delete mode 100644 ci/windows/install-qt-win.cmd delete mode 100644 ci/windows/package-windows.cmd delete mode 100644 ci/windows/prepare-obs-windows.cmd delete mode 100644 ci/windows/prepare-windows.cmd create mode 100644 cmake/ObsPluginHelpers.cmake create mode 100644 cmake/bundle/macos/Plugin-Info.plist.in create mode 100644 cmake/bundle/macos/entitlements.plist create mode 100644 cmake/bundle/macos/installer-macos.pkgproj.in rename {installer => cmake/bundle/windows}/installer-Windows.iss.in (95%) create mode 100644 cmake/bundle/windows/resource.rc.in delete mode 100644 external/FindLibObs.cmake delete mode 100755 formatcode.sh delete mode 100644 installer/installer-macOS.pkgproj.in create mode 100644 src/utils.cpp create mode 100644 src/utils.h diff --git a/.cmake-format.json b/.cmake-format.json new file mode 100644 index 0000000..eb7d554 --- /dev/null +++ b/.cmake-format.json @@ -0,0 +1,16 @@ +{ + "additional_commands": { + "find_qt": { + "flags": [], + "kwargs": { + "COMPONENTS": "+", + "COMPONENTS_WIN": "+", + "COMPONENTS_MACOS": "+", + "COMPONENTS_LINUX": "+" + } + } + }, + "format": { + "line_width": 100 + } +} diff --git a/.github/actions/build-plugin/action.yml b/.github/actions/build-plugin/action.yml new file mode 100644 index 0000000..1e91d15 --- /dev/null +++ b/.github/actions/build-plugin/action.yml @@ -0,0 +1,77 @@ +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.yml b/.github/actions/package-plugin/action.yml new file mode 100644 index 0000000..094803e --- /dev/null +++ b/.github/actions/package-plugin/action.yml @@ -0,0 +1,99 @@ +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/scripts/.Aptfile b/.github/scripts/.Aptfile new file mode 100644 index 0000000..59196f0 --- /dev/null +++ b/.github/scripts/.Aptfile @@ -0,0 +1,9 @@ +package 'cmake' +package 'ccache' +package 'curl' +package 'git' +package 'jq' +package 'ninja-build', bin: 'ninja' +package 'pkg-config' +package 'clang' +package 'clang-format-13' diff --git a/.github/scripts/.Brewfile b/.github/scripts/.Brewfile new file mode 100644 index 0000000..6990ecf --- /dev/null +++ b/.github/scripts/.Brewfile @@ -0,0 +1,6 @@ +brew "ccache" +brew "coreutils" +brew "cmake" +brew "git" +brew "jq" +brew "ninja" diff --git a/.github/scripts/.Wingetfile b/.github/scripts/.Wingetfile new file mode 100644 index 0000000..4e7c46e --- /dev/null +++ b/.github/scripts/.Wingetfile @@ -0,0 +1,3 @@ +package '7zip.7zip', path: '7-zip', bin: '7z' +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 new file mode 100755 index 0000000..c93dfa1 --- /dev/null +++ b/.github/scripts/.build.zsh @@ -0,0 +1,249 @@ +#!/usr/bin/env zsh + +builtin emulate -L zsh +setopt EXTENDED_GLOB +setopt PUSHD_SILENT +setopt ERR_EXIT +setopt ERR_RETURN +setopt NO_UNSET +setopt PIPE_FAIL +setopt NO_AUTO_PUSHD +setopt NO_PUSHD_IGNORE_DUPS +setopt FUNCTION_ARGZERO + +## Enable for script debugging +# setopt WARN_CREATE_GLOBAL +# setopt WARN_NESTED_VAR +# 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." + exit 1 +fi + +_trap_error() { + print -u2 -PR '%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 + + 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 + + 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.' + return 2 + } + + typeset -g -a skips=() + local -i _verbosity=1 + local -r _version='1.0.0' + local -r -a _valid_targets=( + macos-x86_64 + macos-arm64 + macos-universal + linux-x86_64 + linux-aarch64 + ) + 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 -r -a _valid_generators=(Ninja 'Unix Makefiles') + local generator='Ninja' + } + local -r _usage=" +Usage: %B${functrace[1]%:*}%b