diff --git a/.github/scripts/.Aptfile b/.github/scripts/.Aptfile index 09efc11..285d03a 100644 --- a/.github/scripts/.Aptfile +++ b/.github/scripts/.Aptfile @@ -4,3 +4,4 @@ package 'git' package 'jq' package 'ninja-build', bin: 'ninja' package 'pkg-config' +package 'libopenblas-dev' diff --git a/.github/scripts/.Brewfile.lock.json b/.github/scripts/.Brewfile.lock.json deleted file mode 100644 index 64c6b6d..0000000 --- a/.github/scripts/.Brewfile.lock.json +++ /dev/null @@ -1,292 +0,0 @@ -{ - "entries": { - "brew": { - "ccache": { - "version": "4.8.2", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:02ecd933e834f58013d924090d13dafeb46a6f9606bf74b62205d06d47fe4b22", - "sha256": "02ecd933e834f58013d924090d13dafeb46a6f9606bf74b62205d06d47fe4b22" - }, - "arm64_monterey": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:8ce666a0d2258dc9b6cbdf1ca02edc92369e44f36290da3ca13be7336eb0835d", - "sha256": "8ce666a0d2258dc9b6cbdf1ca02edc92369e44f36290da3ca13be7336eb0835d" - }, - "arm64_big_sur": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:c99b876a2c4e912e27f9d2b3cb4a1f7259707bbc58aafe4ed328b73dfb757a76", - "sha256": "c99b876a2c4e912e27f9d2b3cb4a1f7259707bbc58aafe4ed328b73dfb757a76" - }, - "ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:f1bf50fc023daa9fe10c68c66758033e673953c93d3643227a5f50be5b63994b", - "sha256": "f1bf50fc023daa9fe10c68c66758033e673953c93d3643227a5f50be5b63994b" - }, - "monterey": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:40b05ad0704bb9fd3cd1ede4ca7a21ee936c5ce819a77477c1c3ec8d4b62c091", - "sha256": "40b05ad0704bb9fd3cd1ede4ca7a21ee936c5ce819a77477c1c3ec8d4b62c091" - }, - "big_sur": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:5e48876771950ca60fb0e1cb6f708d27efe6d4704b58d275a994180611a4946d", - "sha256": "5e48876771950ca60fb0e1cb6f708d27efe6d4704b58d275a994180611a4946d" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/ccache/blobs/sha256:867e06447d02727a3d24e651a578aa0440920367a1630b7f783ddfe686e1a7e8", - "sha256": "867e06447d02727a3d24e651a578aa0440920367a1630b7f783ddfe686e1a7e8" - } - } - } - }, - "coreutils": { - "version": "9.3", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_ventura": { - "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:cbc188426bc245864378bb96620243cfade681ebb64beb9149717bcb04a55b0a", - "sha256": "cbc188426bc245864378bb96620243cfade681ebb64beb9149717bcb04a55b0a" - }, - "arm64_monterey": { - "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:2db183003c663554e8280280f64294f30d8d7819b1378914173236c2634aacc9", - "sha256": "2db183003c663554e8280280f64294f30d8d7819b1378914173236c2634aacc9" - }, - "arm64_big_sur": { - "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:4a20d93169207bcb131c5cf8deebca08e75be30c042c7c13487a986d61bf3f16", - "sha256": "4a20d93169207bcb131c5cf8deebca08e75be30c042c7c13487a986d61bf3f16" - }, - "ventura": { - "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:5461d665ee6121b4f9c42e17ac6441f77c5db156d3f7a6a6eab095773a2457f9", - "sha256": "5461d665ee6121b4f9c42e17ac6441f77c5db156d3f7a6a6eab095773a2457f9" - }, - "monterey": { - "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:a199c4d7b252b74fdcfb48dc9d9e39cfdbe3b88a9a2da0ce59dfb67d482b46a4", - "sha256": "a199c4d7b252b74fdcfb48dc9d9e39cfdbe3b88a9a2da0ce59dfb67d482b46a4" - }, - "big_sur": { - "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:9786f8f2ae9fd345b401d089887d099c8145590934ca84d9850a3755be0b32a5", - "sha256": "9786f8f2ae9fd345b401d089887d099c8145590934ca84d9850a3755be0b32a5" - }, - "x86_64_linux": { - "cellar": "/home/linuxbrew/.linuxbrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:376674abab0d5c19e3f3db5481a2604adac227f89036c4d58d62fc23f59076ab", - "sha256": "376674abab0d5c19e3f3db5481a2604adac227f89036c4d58d62fc23f59076ab" - } - } - } - }, - "cmake": { - "version": "3.27.1", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:6e5eb8797d854a1874a0822db10975a4c04de2d821a1c58dfb61a74fd666b2a0", - "sha256": "6e5eb8797d854a1874a0822db10975a4c04de2d821a1c58dfb61a74fd666b2a0" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:0342d846bff736b3fa37b459b64487f564dd4b884ec4495b4e8025d1f4f82874", - "sha256": "0342d846bff736b3fa37b459b64487f564dd4b884ec4495b4e8025d1f4f82874" - }, - "arm64_big_sur": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:63b57ee981fec3ae511471d970c7d4bd426a3f51650a18994033291f811973ac", - "sha256": "63b57ee981fec3ae511471d970c7d4bd426a3f51650a18994033291f811973ac" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:89ffad1003a0c4ce5f0a0a7fd3a7fd9f06dadd0eaaa2d5786a242e8d8ccef955", - "sha256": "89ffad1003a0c4ce5f0a0a7fd3a7fd9f06dadd0eaaa2d5786a242e8d8ccef955" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:f8ffaa39f9adeb673de7719c2e815c75a665c8778fa52594e4defff1307c0af0", - "sha256": "f8ffaa39f9adeb673de7719c2e815c75a665c8778fa52594e4defff1307c0af0" - }, - "big_sur": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:25a297bbc9e5ebb237dd8c8fe9b0c84c2cc32a4e4520932698c83189d62c256e", - "sha256": "25a297bbc9e5ebb237dd8c8fe9b0c84c2cc32a4e4520932698c83189d62c256e" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:d71baf318f1a02cdc0b6fb8d5c710258b28097687993868ec318f479a561e328", - "sha256": "d71baf318f1a02cdc0b6fb8d5c710258b28097687993868ec318f479a561e328" - } - } - } - }, - "git": { - "version": "2.41.0_2", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_ventura": { - "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:da6d23d518ee5148c4c1308406b4eabba0b2c5ba1f653d63e9fe8f56de59bc29", - "sha256": "da6d23d518ee5148c4c1308406b4eabba0b2c5ba1f653d63e9fe8f56de59bc29" - }, - "arm64_monterey": { - "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:7682a7436bd8e9889170b09b30b999a7cb082e83235c124f32bd5ae7e59273f6", - "sha256": "7682a7436bd8e9889170b09b30b999a7cb082e83235c124f32bd5ae7e59273f6" - }, - "arm64_big_sur": { - "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:4b278fea7ff2d4cc450f62b5d1f6de05dfbb4892ed8ecc226e547e45390c0aed", - "sha256": "4b278fea7ff2d4cc450f62b5d1f6de05dfbb4892ed8ecc226e547e45390c0aed" - }, - "ventura": { - "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:623bea9a6c510f6c36d718f656957c93a65a2a8b81b77cfc02c622bc41f596f7", - "sha256": "623bea9a6c510f6c36d718f656957c93a65a2a8b81b77cfc02c622bc41f596f7" - }, - "monterey": { - "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:ecbadeb2cbd9e2752d656327fc69f2f3144add145c24f4edb6bea9f96aac0376", - "sha256": "ecbadeb2cbd9e2752d656327fc69f2f3144add145c24f4edb6bea9f96aac0376" - }, - "big_sur": { - "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:016ea10f78c7a5d90c230beea4df74116280f4dddae9ebdf311cca5121ab563a", - "sha256": "016ea10f78c7a5d90c230beea4df74116280f4dddae9ebdf311cca5121ab563a" - }, - "x86_64_linux": { - "cellar": "/home/linuxbrew/.linuxbrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/git/blobs/sha256:59a972b97c2396da07630256954731319b7faeb28ac7de5b791af5213a7a48d8", - "sha256": "59a972b97c2396da07630256954731319b7faeb28ac7de5b791af5213a7a48d8" - } - } - } - }, - "jq": { - "version": "1.6", - "bottle": { - "rebuild": 1, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:4622927182fbc7bf27c4b706e005fbae2700d15e69a68ef7002aed2676b8a4f7", - "sha256": "4622927182fbc7bf27c4b706e005fbae2700d15e69a68ef7002aed2676b8a4f7" - }, - "arm64_monterey": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:f70e1ae8df182b242ca004492cc0a664e2a8195e2e46f30546fe78e265d5eb87", - "sha256": "f70e1ae8df182b242ca004492cc0a664e2a8195e2e46f30546fe78e265d5eb87" - }, - "arm64_big_sur": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:674b3ae41c399f1e8e44c271b0e6909babff9fcd2e04a2127d25e2407ea4dd33", - "sha256": "674b3ae41c399f1e8e44c271b0e6909babff9fcd2e04a2127d25e2407ea4dd33" - }, - "ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:b70ec02353c5f6cb69d947e1506e71c96d2952ed4099ae3948c6c61420b16ef9", - "sha256": "b70ec02353c5f6cb69d947e1506e71c96d2952ed4099ae3948c6c61420b16ef9" - }, - "monterey": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:7fee6ea327062b37d34ef5346a84810a1752cc7146fff1223fab76c9b45686e0", - "sha256": "7fee6ea327062b37d34ef5346a84810a1752cc7146fff1223fab76c9b45686e0" - }, - "big_sur": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:bf0f8577632af7b878b6425476f5b1ab9c3bf66d65affb0c455048a173a0b6bf", - "sha256": "bf0f8577632af7b878b6425476f5b1ab9c3bf66d65affb0c455048a173a0b6bf" - }, - "catalina": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:820a3c85fcbb63088b160c7edf125d7e55fc2c5c1d51569304499c9cc4b89ce8", - "sha256": "820a3c85fcbb63088b160c7edf125d7e55fc2c5c1d51569304499c9cc4b89ce8" - }, - "mojave": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:71f0e76c5b22e5088426c971d5e795fe67abee7af6c2c4ae0cf4c0eb98ed21ff", - "sha256": "71f0e76c5b22e5088426c971d5e795fe67abee7af6c2c4ae0cf4c0eb98ed21ff" - }, - "high_sierra": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:dffcffa4ea13e8f0f2b45c5121e529077e135ae9a47254c32182231662ee9b72", - "sha256": "dffcffa4ea13e8f0f2b45c5121e529077e135ae9a47254c32182231662ee9b72" - }, - "sierra": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:bb4d19dc026c2d72c53eed78eaa0ab982e9fcad2cd2acc6d13e7a12ff658e877", - "sha256": "bb4d19dc026c2d72c53eed78eaa0ab982e9fcad2cd2acc6d13e7a12ff658e877" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:2beea2c2c372ccf1081e9a5233fc3020470803254284aeecc071249d76b62338", - "sha256": "2beea2c2c372ccf1081e9a5233fc3020470803254284aeecc071249d76b62338" - } - } - } - }, - "xcbeautify": { - "version": "1.0.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcbeautify/blobs/sha256:bacf88c0dd3a4132e5cf01dc9af94d69678e8adc9faadc0b55eca53dfeb4edd6", - "sha256": "bacf88c0dd3a4132e5cf01dc9af94d69678e8adc9faadc0b55eca53dfeb4edd6" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcbeautify/blobs/sha256:6a46df2ced30543c8ec0fb7ea53a1ffd45f69db7ed9b59a5ca5fbc6885606f9c", - "sha256": "6a46df2ced30543c8ec0fb7ea53a1ffd45f69db7ed9b59a5ca5fbc6885606f9c" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcbeautify/blobs/sha256:2d7d8323275c3d5f808434c84808a59c4d8eabb128053f05630f298b592d5bfe", - "sha256": "2d7d8323275c3d5f808434c84808a59c4d8eabb128053f05630f298b592d5bfe" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcbeautify/blobs/sha256:4688cfc59364db9efa881f2cb4c99f2304149c0f69e2bc4164cbae5d525ca7ed", - "sha256": "4688cfc59364db9efa881f2cb4c99f2304149c0f69e2bc4164cbae5d525ca7ed" - }, - "x86_64_linux": { - "cellar": "/home/linuxbrew/.linuxbrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/xcbeautify/blobs/sha256:4f4ed4b6e2367b3ac361e4916186778de7aef1b6a2dd772e4609437f05ec3f3f", - "sha256": "4f4ed4b6e2367b3ac361e4916186778de7aef1b6a2dd772e4609437f05ec3f3f" - } - } - } - } - } - }, - "system": { - "macos": { - "ventura": { - "HOMEBREW_VERSION": "4.1.2-11-g4c612ab", - "HOMEBREW_PREFIX": "/usr/local", - "Homebrew/homebrew-core": "api", - "CLT": "14.3.1.0.1.1683849156", - "Xcode": "14.3.1", - "macOS": "13.4.1" - } - } - } -} diff --git a/.github/scripts/.build.zsh b/.github/scripts/.build.zsh index d86ab03..f3c3588 100755 --- a/.github/scripts/.build.zsh +++ b/.github/scripts/.build.zsh @@ -230,7 +230,15 @@ ${_usage_host:-}" -DCODESIGN_IDENTITY=${CODESIGN_IDENT:--} ) - cmake_build_args+=(--preset ${_preset} --parallel --config ${config} -- ONLY_ACTIVE_ARCH=NO -arch x86_64) # -arch arm64 + cmake_build_args+=(--preset ${_preset} --parallel --config ${config} -- ONLY_ACTIVE_ARCH=YES) + # check the MACOS_ARCH env var to determine the build architecture + if [[ -n ${MACOS_ARCH} ]] { + cmake_build_args+=(-arch ${MACOS_ARCH}) + } else { + # error out + log_error "No MACOS_ARCH environment variable set. Please set it to the desired architecture." + exit 2 + } cmake_install_args+=(build_macos --config ${config} --prefix "${project_root}/release/${config}") local -a xcbeautify_opts=() @@ -242,6 +250,7 @@ ${_usage_host:-}" -G "${generator}" -DQT_VERSION=${QT_VERSION:-6} -DCMAKE_BUILD_TYPE=${config} + -DCMAKE_INSTALL_PREFIX=/usr ) local cmake_version diff --git a/.github/scripts/.package.zsh b/.github/scripts/.package.zsh index cb6313e..cefb007 100755 --- a/.github/scripts/.package.zsh +++ b/.github/scripts/.package.zsh @@ -168,8 +168,10 @@ ${_usage_host:-}" if [[ ${host_os} == macos ]] { autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass + # get the arch from MACOS_ARCH env var + local -r macos_arch=${MACOS_ARCH:-$(uname -m)} - local output_name="${product_name}-${product_version}-${host_os}-universal" + local output_name="${product_name}-${product_version}-${host_os}-${macos_arch}" if [[ ! -d ${project_root}/release/${config}/${product_name}.plugin ]] { log_error 'No release artifact found. Run the build script or the CMake install procedure first.' @@ -180,18 +182,13 @@ ${_usage_host:-}" if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}" if (( package )) { - if [[ ! -f ${project_root}/build_macos/installer-macos.generated.pkgproj ]] { - log_error 'Packages project file not found. Run the build script or the CMake build and install procedures first.' + if [[ ! -f ${project_root}/release/${config}/${product_name}.pkg ]] { + log_error 'Installer Package not found. Run the build script or the CMake build and install procedures first.' return 2 } - check_packages - log_group "Packaging ${product_name}..." pushd ${project_root} - packagesbuild \ - --build-folder ${project_root}/release/${config} \ - ${project_root}/build_macos/installer-macos.generated.pkgproj if (( codesign )) { read_codesign_installer diff --git a/.github/scripts/Build-Windows.ps1 b/.github/scripts/Build-Windows.ps1 index 5f32296..875ea0a 100644 --- a/.github/scripts/Build-Windows.ps1 +++ b/.github/scripts/Build-Windows.ps1 @@ -4,9 +4,12 @@ param( [string] $Target = 'x64', [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] [string] $Configuration = 'RelWithDebInfo', + [ValidateSet('cpu', '12.2.0', '11.8.0')] + [string] $Cublas = 'cpu', [switch] $SkipAll, [switch] $SkipBuild, - [switch] $SkipDeps + [switch] $SkipDeps, + [string[]] $ExtraCmakeArgs ) $ErrorActionPreference = 'Stop' @@ -56,7 +59,8 @@ function Build { if ( ! ( ( $SkipAll ) -or ( $SkipBuild ) ) ) { Ensure-Location $ProjectRoot - $CmakeArgs = @() + # take cmake args from $ExtraCmakeArgs + $CmakeArgs = $ExtraCmakeArgs $CmakeBuildArgs = @() $CmakeInstallArgs = @() @@ -75,6 +79,13 @@ function Build { '--preset', $Preset ) + if ( $Cublas -ne 'cpu' ) { + $CmakeArgs += @( + '-DLOCALVOCAL_WITH_CUDA=ON', + "-DCUDA_TOOLKIT_ROOT_DIR=$Env:CUDA_TOOLKIT_ROOT_DIR" + ) + } + $CmakeBuildArgs += @( '--build' '--preset', $Preset diff --git a/.github/scripts/Package-Windows.ps1 b/.github/scripts/Package-Windows.ps1 index 52317be..a09f54a 100644 --- a/.github/scripts/Package-Windows.ps1 +++ b/.github/scripts/Package-Windows.ps1 @@ -4,6 +4,8 @@ param( [string] $Target = 'x64', [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] [string] $Configuration = 'RelWithDebInfo', + [ValidateSet('cpu', '12.2.0', '11.8.0')] + [string] $Cublas = 'cpu', [switch] $BuildInstaller, [switch] $SkipDeps ) @@ -47,8 +49,9 @@ function Package { $BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json $ProductName = $BuildSpec.name $ProductVersion = $BuildSpec.version + $CudaName = "cuda${Cublas}" - $OutputName = "${ProductName}-${ProductVersion}-windows-${Target}" + $OutputName = "${ProductName}-${ProductVersion}-windows-${Target}-${CudaName}" if ( ! $SkipDeps ) { Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile" diff --git a/.github/scripts/utils.zsh/check_macos b/.github/scripts/utils.zsh/check_macos index 54b5fbf..9c63496 100644 --- a/.github/scripts/utils.zsh/check_macos +++ b/.github/scripts/utils.zsh/check_macos @@ -17,6 +17,6 @@ if (( ! ${+commands[brew]} )) { return 2 } -brew bundle --file ${SCRIPT_HOME}/.Brewfile +brew bundle --no-upgrade --file ${SCRIPT_HOME}/.Brewfile rehash log_group diff --git a/.github/scripts/utils.zsh/check_packages b/.github/scripts/utils.zsh/check_packages deleted file mode 100644 index 76652c3..0000000 --- a/.github/scripts/utils.zsh/check_packages +++ /dev/null @@ -1,62 +0,0 @@ -if (( ! ${+commands[packagesbuild]} )) { - autoload -Uz log_group log_info log_status mkcd - - if (( ! ${+commands[curl]} )) { - log_error 'curl not found. Please install curl.' - return 2 - } - - if (( ! ${+project_root} )) { - log_error "'project_root' not set. Please set before running ${0}." - return 2 - } - - local -a curl_opts=() - if (( ${+CI} )) { - curl_opts+=(--show-error --silent) - } else { - curl_opts+=(--progress-bar) - } - curl_opts+=(--location -O) - - log_group 'Installing Packages.app...' - - local version - local base_url - local hash - IFS=';' read -r version base_url hash <<< \ - "$(jq -r '.tools.packages | {version, baseUrl, hash} | join(";")' buildspec.json)" - - mkdir -p ${project_root}/.deps && pushd ${project_root}/.deps - curl ${curl_opts} "${base_url}/Packages.dmg" - - local checksum="$(sha256sum Packages.dmg | cut -d " " -f 1)" - - if [[ ${hash} != ${checksum} ]] { - log_error "Checksum mismatch of Packages.dmg download. -Expected : ${hash} -Actual : ${checksum}" - return 2 - } - - hdiutil attach -readonly -noverify -noautoopen -plist Packages.dmg > .result.plist - local -i num_entities=$(( $(plutil -extract system-entities raw -- .result.plist) - 1 )) - local keys - local mount_point - for i ({0..${num_entities}}) { - keys=($(plutil -extract system-entities.${i} raw -- .result.plist)) - if [[ ${keys} == *mount-point* ]] { - mount_point=$(plutil -extract system-entities.${i}.mount-point raw -- .result.plist) - break - } - } - rm .result.plist - - log_status 'Installing Packages.app requires elevated privileges!' - - sudo installer -pkg ${mount_point}/packages/Packages.pkg -target / && rehash - hdiutil detach ${mount_point} &> /dev/null && log_status 'Packages.dmg image unmounted.' - popd - - log_group -} diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index 556ec4f..c99f07c 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -29,8 +29,7 @@ jobs: case "${GITHUB_EVENT_NAME}" in pull_request) config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo') - if gh pr view --json labels \ - | jq -e -r '.labels[] | select(.name == "Seeking Testers")' > /dev/null; then + if [[ ${{ contains(github.event.pull_request.labels.*.name, 'Seeking Testers') }} = true ]]; then config_data[0]='codesign:true' config_data[2]='package:true' fi @@ -61,6 +60,9 @@ jobs: name: Build for macOS 🍏 runs-on: macos-13 needs: check-event + strategy: + matrix: + architecture: [x86_64, arm64] defaults: run: shell: zsh --no-rcs --errexit --pipefail {0} @@ -115,15 +117,17 @@ jobs: - name: Build Plugin 🧱 uses: ./.github/actions/build-plugin with: - target: macos-universal + target: macos-${{ matrix.architecture }} config: ${{ needs.check-event.outputs.config }} codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }} codesignIdent: ${{ steps.codesign.outputs.codesignIdent }} + env: + MACOS_ARCH: ${{ matrix.architecture }} - name: Package Plugin 📀 uses: ./.github/actions/package-plugin with: - target: macos-universal + target: macos-${{ matrix.architecture }} config: ${{ needs.check-event.outputs.config }} package: ${{ fromJSON(needs.check-event.outputs.package) }} codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }} @@ -133,19 +137,21 @@ jobs: notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }} codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }} codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }} + env: + MACOS_ARCH: ${{ matrix.architecture }} - name: Upload Artifacts 📡 uses: actions/upload-artifact@v3 with: - name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }} - path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal.* + 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 if: ${{ needs.check-event.outputs.config == 'Release' }} with: - name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs - path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-dSYMs.* + name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-${{ needs.check-event.outputs.commitHash }}-dSYMs + path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-dSYMs.* ubuntu-build: name: Build for Ubuntu 🐧 @@ -219,6 +225,9 @@ jobs: name: Build for Windows 🪟 runs-on: windows-2022 needs: check-event + strategy: + matrix: + cublas: [cpu] # , 12.2.0, 11.8.0 defaults: run: shell: pwsh @@ -228,6 +237,20 @@ jobs: submodules: recursive fetch-depth: 0 + - name: Install CUDA Toolkit + if: ${{ matrix.cublas != 'cpu' }} + id: cuda-toolkit + uses: Jimver/cuda-toolkit@v0.2.11 + with: + cuda: '${{ matrix.cublas }}' + + - name: Set CUDA_TOOLKIT_ROOT_DIR if CUDA is installed + if: ${{ matrix.cublas != 'cpu' }} + run: | + ls "$env:CUDA_PATH\bin" + ls -d 2 "$env:CUDA_PATH\lib" + "CUDA_TOOLKIT_ROOT_DIR=$env:CUDA_PATH" >> $env:GITHUB_ENV + - name: Set Up Environment 🔧 id: setup run: | @@ -248,6 +271,7 @@ jobs: with: target: x64 config: ${{ needs.check-event.outputs.config }} + cublas: ${{ matrix.cublas }} - name: Package Plugin 📀 uses: ./.github/actions/package-plugin @@ -255,9 +279,10 @@ jobs: target: x64 config: ${{ needs.check-event.outputs.config }} package: ${{ fromJSON(needs.check-event.outputs.package) }} + cublas: ${{ matrix.cublas }} - name: Upload Artifacts 📡 uses: actions/upload-artifact@v3 with: - name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }} + 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/cmake/BuildMyCurl.cmake b/cmake/BuildMyCurl.cmake index 26b26bd..10d3e05 100644 --- a/cmake/BuildMyCurl.cmake +++ b/cmake/BuildMyCurl.cmake @@ -1,29 +1,73 @@ -set(LIBCURL_SOURCE_DIR ${CMAKE_SOURCE_DIR}/vendor/curl) +include(FetchContent) -find_package(Git QUIET) -execute_process( - COMMAND ${GIT_EXECUTABLE} checkout curl-8_2_0 - WORKING_DIRECTORY ${LIBCURL_SOURCE_DIR} - RESULT_VARIABLE GIT_SUBMOD_RESULT) +set(LibCurl_VERSION "8.4.0-3") +set(LibCurl_BASEURL "https://github.com/occ-ai/obs-ai-libcurl-dep/releases/download/${LibCurl_VERSION}") -if(OS_MACOS) - set(CURL_USE_OPENSSL OFF) - set(CURL_USE_SECTRANSP ON) -elseif(OS_WINDOWS) - set(CURL_USE_OPENSSL OFF) - set(CURL_USE_SCHANNEL ON) -elseif(OS_LINUX) - add_compile_options(-fPIC) - set(CURL_USE_OPENSSL ON) +if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo) + set(LibCurl_BUILD_TYPE Release) +else() + set(LibCurl_BUILD_TYPE Debug) endif() -set(BUILD_CURL_EXE OFF) -set(BUILD_SHARED_LIBS OFF) -set(HTTP_ONLY OFF) -set(CURL_USE_LIBSSH2 OFF) -add_subdirectory(${LIBCURL_SOURCE_DIR} EXCLUDE_FROM_ALL) -if(OS_MACOS) - target_compile_options( - libcurl PRIVATE -Wno-error=ambiguous-macro -Wno-error=deprecated-declarations -Wno-error=unreachable-code - -Wno-error=unused-parameter -Wno-error=unused-variable) + +if(APPLE) + if(LibCurl_BUILD_TYPE STREQUAL Release) + set(LibCurl_URL "${LibCurl_BASEURL}/libcurl-macos-${LibCurl_VERSION}-Release.tar.gz") + set(LibCurl_HASH SHA256=5ef7bfed2c2bca17ba562aede6a3c3eb465b8d7516cff86ca0f0d0337de951e1) + else() + set(LibCurl_URL "${LibCurl_BASEURL}/libcurl-macos-${LibCurl_VERSION}-Debug.tar.gz") + set(LibCurl_HASH SHA256=da0801168eac5103e6b27bfd0f56f82e0617f85e4e6c69f476071dbba273403b) + endif() +elseif(MSVC) + if(LibCurl_BUILD_TYPE STREQUAL Release) + set(LibCurl_URL "${LibCurl_BASEURL}/libcurl-windows-${LibCurl_VERSION}-Release.zip") + set(LibCurl_HASH SHA256=bf4d4cd7d741712a2913df0994258d11aabe22c9a305c9f336ed59e76f351adf) + else() + set(LibCurl_URL "${LibCurl_BASEURL}/libcurl-windows-${LibCurl_VERSION}-Debug.zip") + set(LibCurl_HASH SHA256=9fe20e677ffb0d7dd927b978d532e23574cdb1923e2d2ca7c5e42f1fff2ec529) + endif() +else() + if(LibCurl_BUILD_TYPE STREQUAL Release) + set(LibCurl_URL "${LibCurl_BASEURL}/libcurl-linux-${LibCurl_VERSION}-Release.tar.gz") + set(LibCurl_HASH SHA256=f2cd80b7d3288fe5b4c90833bcbf0bde7c9574bc60eddb13015df19c5a09f56b) + else() + set(LibCurl_URL "${LibCurl_BASEURL}/libcurl-linux-${LibCurl_VERSION}-Debug.tar.gz") + set(LibCurl_HASH SHA256=6a41d3daef98acc3172b3702118dcf1cccbde923f3836ed2f4f3ed7301e47b8b) + endif() +endif() + +FetchContent_Declare( + libcurl_fetch + URL ${LibCurl_URL} + URL_HASH ${LibCurl_HASH}) +FetchContent_MakeAvailable(libcurl_fetch) + +if(MSVC) + set(libcurl_fetch_lib_location "${libcurl_fetch_SOURCE_DIR}/lib/libcurl.lib") + set(libcurl_fetch_link_libs "\$;\$;\$;\$") +else() + find_package(ZLIB REQUIRED) + set(libcurl_fetch_lib_location "${libcurl_fetch_SOURCE_DIR}/lib/libcurl.a") + if(UNIX AND NOT APPLE) + find_package(OpenSSL REQUIRED) + set(libcurl_fetch_link_libs "\$;\$;\$") + else() + set(libcurl_fetch_link_libs + "-framework SystemConfiguration;-framework Security;-framework CoreFoundation;-framework CoreServices;ZLIB::ZLIB" + ) + endif() endif() -include_directories(SYSTEM ${LIBCURL_SOURCE_DIR}/include) + +# Create imported target +add_library(libcurl STATIC IMPORTED) + +set_target_properties( + libcurl + PROPERTIES INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB" + INTERFACE_INCLUDE_DIRECTORIES "${libcurl_fetch_SOURCE_DIR}/include" + INTERFACE_LINK_LIBRARIES "${libcurl_fetch_link_libs}") +set_property( + TARGET libcurl + APPEND + PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(libcurl PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" IMPORTED_LOCATION_RELEASE + ${libcurl_fetch_lib_location}) diff --git a/cmake/BuildWhispercpp.cmake b/cmake/BuildWhispercpp.cmake index 8cce7f1..31e83d0 100644 --- a/cmake/BuildWhispercpp.cmake +++ b/cmake/BuildWhispercpp.cmake @@ -1,6 +1,8 @@ include(ExternalProject) -string(REPLACE ";" "$" CMAKE_OSX_ARCHITECTURES_ "${CMAKE_OSX_ARCHITECTURES}") +set(CMAKE_OSX_ARCHITECTURES_ "arm64$x86_64") + +set(Whispercpp_Build_GIT_TAG "f22d27a385d34b1e544031efe8aa2e3d73922791") if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo) set(Whispercpp_BUILD_TYPE Release) @@ -8,43 +10,158 @@ else() set(Whispercpp_BUILD_TYPE Debug) endif() -# On linux add the `-fPIC` flag to the compiler if(UNIX AND NOT APPLE) + # On linux add the `-fPIC` flag to the compiler set(WHISPER_EXTRA_CXX_FLAGS "-fPIC") + set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_BLAS=OFF -DWHISPER_CUBLAS=OFF -DWHISPER_OPENBLAS=OFF -DWHISPER_NO_AVX=ON + -DWHISPER_NO_AVX2=ON) +endif() +if(APPLE) + # check the "MACOS_ARCH" env var to figure out if this is x86 or arm64 + if(NOT DEFINED ENV{MACOS_ARCH}) + message(FATAL_ERROR "The MACOS_ARCH environment variable is not set. Please set it to either `x86` or `arm64`") + endif(NOT DEFINED ENV{MACOS_ARCH}) + set(CMAKE_OSX_ARCHITECTURES_ "$ENV{MACOS_ARCH}") + if($ENV{MACOS_ARCH} STREQUAL "x86_64") + set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_METAL=OFF -DWHISPER_COREML=OFF -DWHISPER_NO_AVX=OFF + -DWHISPER_NO_AVX2=OFF -DWHISPER_NO_F16C=OFF) + else() + set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_METAL=OFF -DWHISPER_COREML=OFF -DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON + -DWHISPER_NO_F16C=ON -DWHISPER_NO_FMA=ON) + endif() + set(WHISPER_EXTRA_CXX_FLAGS + "-Wno-shorten-64-to-32 -Wno-unused-parameter -Wno-unused-function -Wno-unguarded-availability-new") endif() -ExternalProject_Add( - Whispercpp_Build - DOWNLOAD_EXTRACT_TIMESTAMP true - GIT_REPOSITORY https://github.com/ggerganov/whisper.cpp.git - GIT_TAG 7b374c9ac9b9861bb737eec060e4dfa29d229259 - BUILD_COMMAND ${CMAKE_COMMAND} --build --config ${Whispercpp_BUILD_TYPE} - BUILD_BYPRODUCTS /lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX} - CMAKE_GENERATOR ${CMAKE_GENERATOR} - INSTALL_COMMAND ${CMAKE_COMMAND} --install --config ${Whispercpp_BUILD_TYPE} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=${Whispercpp_BUILD_TYPE} - -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} - -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} - -DCMAKE_CXX_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} - -DCMAKE_C_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} - -DBUILD_SHARED_LIBS=OFF - -DWHISPER_BUILD_TESTS=OFF - -DWHISPER_BUILD_EXAMPLES=OFF - -DWHISPER_OPENBLAS=ON) +if(WIN32) + if(LOCALVOCAL_WITH_CUDA) + # Build with CUDA Check that CUDA_TOOLKIT_ROOT_DIR is set + if(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) + message(FATAL_ERROR "CUDA_TOOLKIT_ROOT_DIR is not set. Please set it to the root directory of your CUDA " + "installation, e.g. `C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4`") + endif(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) + + set(WHISPER_ADDITIONAL_ENV "CUDAToolkit_ROOT=${CUDA_TOOLKIT_ROOT_DIR}") + set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_CUBLAS=ON -DWHISPER_OPENBLAS=OFF + -DCMAKE_GENERATOR_TOOLSET=cuda=${CUDA_TOOLKIT_ROOT_DIR}) + else() + # Build with OpenBLAS + set(OpenBLAS_URL "https://github.com/xianyi/OpenBLAS/releases/download/v0.3.24/OpenBLAS-0.3.24-x64.zip") + set(OpenBLAS_SHA256 "6335128ee7117ea2dd2f5f96f76dafc17256c85992637189a2d5f6da0c608163") + ExternalProject_Add( + OpenBLAS + URL ${OpenBLAS_URL} + URL_HASH SHA256=${OpenBLAS_SHA256} + DOWNLOAD_NO_PROGRESS true + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ) + ExternalProject_Get_Property(OpenBLAS INSTALL_DIR) + set(OpenBLAS_DIR ${INSTALL_DIR}) + set(WHISPER_ADDITIONAL_ENV "OPENBLAS_PATH=${OpenBLAS_DIR}") + set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_BLAS=ON -DWHISPER_CUBLAS=OFF) + endif() + + ExternalProject_Add( + Whispercpp_Build + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/ggerganov/whisper.cpp.git + GIT_TAG ${Whispercpp_Build_GIT_TAG} + BUILD_COMMAND ${CMAKE_COMMAND} --build --config ${Whispercpp_BUILD_TYPE} + BUILD_BYPRODUCTS + /lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX} + /bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX} + /lib/${CMAKE_IMPORT_LIBRARY_PREFIX}whisper${CMAKE_IMPORT_LIBRARY_SUFFIX} + CMAKE_GENERATOR ${CMAKE_GENERATOR} + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config ${Whispercpp_BUILD_TYPE} && ${CMAKE_COMMAND} -E copy + /${Whispercpp_BUILD_TYPE}/whisper.lib /lib && ${CMAKE_COMMAND} -E copy + /ggml.h /include + CONFIGURE_COMMAND + ${CMAKE_COMMAND} -E env ${WHISPER_ADDITIONAL_ENV} ${CMAKE_COMMAND} -B -G + ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=${Whispercpp_BUILD_TYPE} + -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} -DCMAKE_CXX_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} + -DCMAKE_C_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} -DBUILD_SHARED_LIBS=ON -DWHISPER_BUILD_TESTS=OFF + -DWHISPER_BUILD_EXAMPLES=OFF ${WHISPER_ADDITIONAL_CMAKE_ARGS}) + + if(NOT LOCALVOCAL_WITH_CUDA) + add_dependencies(Whispercpp_Build OpenBLAS) + endif(NOT LOCALVOCAL_WITH_CUDA) +else() + # On Linux and MacOS build a static Whisper library + ExternalProject_Add( + Whispercpp_Build + DOWNLOAD_EXTRACT_TIMESTAMP true + GIT_REPOSITORY https://github.com/ggerganov/whisper.cpp.git + GIT_TAG ${Whispercpp_Build_GIT_TAG} + BUILD_COMMAND ${CMAKE_COMMAND} --build --config ${Whispercpp_BUILD_TYPE} + BUILD_BYPRODUCTS /lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX} + CMAKE_GENERATOR ${CMAKE_GENERATOR} + INSTALL_COMMAND ${CMAKE_COMMAND} --install --config ${Whispercpp_BUILD_TYPE} && ${CMAKE_COMMAND} -E + copy /ggml.h /include + CONFIGURE_COMMAND + ${CMAKE_COMMAND} -E env ${WHISPER_ADDITIONAL_ENV} ${CMAKE_COMMAND} -B -G + ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=${Whispercpp_BUILD_TYPE} + -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} -DCMAKE_CXX_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} + -DCMAKE_C_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} -DBUILD_SHARED_LIBS=OFF -DWHISPER_BUILD_TESTS=OFF + -DWHISPER_BUILD_EXAMPLES=OFF ${WHISPER_ADDITIONAL_CMAKE_ARGS}) +endif(WIN32) ExternalProject_Get_Property(Whispercpp_Build INSTALL_DIR) -add_library(Whispercpp::Whisper STATIC IMPORTED) -set_target_properties( - Whispercpp::Whisper - PROPERTIES IMPORTED_LOCATION - ${INSTALL_DIR}/lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX}) +# add the Whisper library to the link line +if(WIN32) + add_library(Whispercpp::Whisper SHARED IMPORTED) + set_target_properties( + Whispercpp::Whisper + PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX}) + set_target_properties( + Whispercpp::Whisper + PROPERTIES IMPORTED_IMPLIB ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX}) + + install(FILES ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX} + DESTINATION "obs-plugins/64bit") + + if(NOT LOCALVOCAL_WITH_CUDA) + # add openblas to the link line + add_library(Whispercpp::OpenBLAS STATIC IMPORTED) + set_target_properties(Whispercpp::OpenBLAS PROPERTIES IMPORTED_LOCATION ${OpenBLAS_DIR}/lib/libopenblas.dll.a) + install(FILES ${OpenBLAS_DIR}/bin/libopenblas.dll DESTINATION "obs-plugins/64bit") + else(NOT LOCALVOCAL_WITH_CUDA) + # normalize CUDA path with file(TO_CMAKE_PATH) + file(TO_CMAKE_PATH ${CUDA_TOOLKIT_ROOT_DIR} CUDA_TOOLKIT_ROOT_DIR) + # find the CUDA DLLs for cuBLAS in the bin directory of the CUDA installation e.g. cublas64_NN.dll + file(GLOB CUBLAS_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cublas64_*.dll") + # find cublasLt DLL, e.g. cublasLt64_11.dll + file(GLOB CUBLASLT_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cublasLt64_*.dll") + # find cudart DLL, e.g. cudart64_110.dll + file(GLOB CUDART_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cudart64_*.dll") + # if any of the files cannot be found, abort + if(NOT CUBLAS_DLLS + OR NOT CUBLASLT_DLLS + OR NOT CUDART_DLLS) + message(FATAL_ERROR "Could not find cuBLAS, cuBLASLt or cuDART DLLs in ${CUDA_TOOLKIT_ROOT_DIR}/bin") + endif() + # copy the DLLs to the OBS plugin directory + install(FILES ${CUBLAS_DLLS} ${CUBLASLT_DLLS} ${CUDART_DLLS} DESTINATION "obs-plugins/64bit") + endif(NOT LOCALVOCAL_WITH_CUDA) +else() + # on Linux and MacOS add the static Whisper library to the link line + add_library(Whispercpp::Whisper STATIC IMPORTED) + set_target_properties( + Whispercpp::Whisper + PROPERTIES IMPORTED_LOCATION + ${INSTALL_DIR}/lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX}) +endif(WIN32) add_library(Whispercpp INTERFACE) add_dependencies(Whispercpp Whispercpp_Build) target_link_libraries(Whispercpp INTERFACE Whispercpp::Whisper) +if(WIN32 AND NOT LOCALVOCAL_WITH_CUDA) + target_link_libraries(Whispercpp INTERFACE Whispercpp::OpenBLAS) +endif() set_target_properties(Whispercpp::Whisper PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) if(APPLE) target_link_libraries(Whispercpp INTERFACE "-framework Accelerate") diff --git a/cmake/bundle/macos/Distribution.xml b/cmake/bundle/macos/Distribution.xml deleted file mode 100644 index 0526261..0000000 --- a/cmake/bundle/macos/Distribution.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - obs-cleanstream-flat.pkg - - diff --git a/cmake/bundle/macos/Plugin-Info.plist.in b/cmake/bundle/macos/Plugin-Info.plist.in deleted file mode 100644 index 1b0f234..0000000 --- a/cmake/bundle/macos/Plugin-Info.plist.in +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleName - ${MACOSX_PLUGIN_BUNDLE_NAME} - CFBundleIdentifier - ${MACOSX_PLUGIN_GUI_IDENTIFIER} - CFBundleVersion - ${MACOSX_PLUGIN_BUNDLE_VERSION} - CFBundleShortVersionString - ${MACOSX_PLUGIN_SHORT_VERSION_STRING} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleExecutable - ${MACOSX_PLUGIN_EXECUTABLE_NAME} - CFBundlePackageType - ${MACOSX_PLUGIN_BUNDLE_TYPE} - CFBundleSupportedPlatforms - - MacOSX - - LSMinimumSystemVersion - 10.13 - - diff --git a/cmake/bundle/macos/entitlements.plist b/cmake/bundle/macos/entitlements.plist deleted file mode 100644 index 516d0d5..0000000 --- a/cmake/bundle/macos/entitlements.plist +++ /dev/null @@ -1,17 +0,0 @@ - - - - - com.apple.security.cs.allow-unsigned-executable-memory - - com.apple.security.device.camera - - com.apple.security.device.audio-input - - com.apple.security.cs.disable-library-validation - - - com.apple.security.cs.allow-dyld-environment-variables - - - diff --git a/cmake/bundle/macos/installer-macos.pkgproj.in b/cmake/bundle/macos/installer-macos.pkgproj.in deleted file mode 100644 index 2a1f643..0000000 --- a/cmake/bundle/macos/installer-macos.pkgproj.in +++ /dev/null @@ -1,920 +0,0 @@ - - - - - PACKAGES - - - MUST-CLOSE-APPLICATION-ITEMS - - MUST-CLOSE-APPLICATIONS - - PACKAGE_FILES - - DEFAULT_INSTALL_LOCATION - / - HIERARCHY - - CHILDREN - - - CHILDREN - - GID - 80 - PATH - Applications - PATH_TYPE - 0 - PERMISSIONS - 509 - TYPE - 1 - UID - 0 - - - CHILDREN - - - CHILDREN - - - CHILDREN - - - CHILDREN - - - BUNDLE_CAN_DOWNGRADE - - BUNDLE_POSTINSTALL_PATH - - PATH_TYPE - 0 - - BUNDLE_PREINSTALL_PATH - - PATH_TYPE - 0 - - CHILDREN - - GID - 80 - PATH - ../@RELATIVE_INSTALL_PATH@/@CMAKE_PROJECT_NAME@.plugin - PATH_TYPE - 1 - PERMISSIONS - 493 - TYPE - 3 - UID - 0 - - - GID - 80 - PATH - plugins - PATH_TYPE - 2 - PERMISSIONS - 509 - TYPE - 2 - UID - 0 - - - GID - 80 - PATH - obs-studio - PATH_TYPE - 2 - PERMISSIONS - 509 - TYPE - 2 - UID - 0 - - - GID - 80 - PATH - Application Support - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Automator - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Documentation - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Extensions - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Filesystems - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Frameworks - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Input Methods - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Internet Plug-Ins - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - LaunchAgents - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - LaunchDaemons - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - PreferencePanes - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Preferences - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 80 - PATH - Printers - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - PrivilegedHelperTools - PATH_TYPE - 0 - PERMISSIONS - 1005 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - QuickLook - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - QuickTime - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Screen Savers - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Scripts - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Services - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - Widgets - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - GID - 0 - PATH - Library - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - CHILDREN - - - CHILDREN - - GID - 0 - PATH - Shared - PATH_TYPE - 0 - PERMISSIONS - 1023 - TYPE - 1 - UID - 0 - - - GID - 80 - PATH - Users - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - - GID - 0 - PATH - / - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 1 - UID - 0 - - PAYLOAD_TYPE - 0 - PRESERVE_EXTENDED_ATTRIBUTES - - SHOW_INVISIBLE - - SPLIT_FORKS - - TREAT_MISSING_FILES_AS_WARNING - - VERSION - 5 - - PACKAGE_SCRIPTS - - POSTINSTALL_PATH - - PATH_TYPE - 0 - - PREINSTALL_PATH - - PATH_TYPE - 0 - - RESOURCES - - - PACKAGE_SETTINGS - - AUTHENTICATION - 0 - CONCLUSION_ACTION - 0 - FOLLOW_SYMBOLIC_LINKS - - IDENTIFIER - @MACOS_BUNDLEID@ - LOCATION - 0 - NAME - @CMAKE_PROJECT_NAME@ - OVERWRITE_PERMISSIONS - - PAYLOAD_SIZE - -1 - REFERENCE_PATH - - RELOCATABLE - - USE_HFS+_COMPRESSION - - VERSION - @CMAKE_PROJECT_VERSION@ - - TYPE - 0 - UUID - 0B7A74BC-65CF-4FF1-AC34-5C743E8A48F5 - - - PROJECT - - PROJECT_COMMENTS - - NOTES - - - - PROJECT_PRESENTATION - - BACKGROUND - - APPAREANCES - - DARK_AQUA - - LIGHT_AQUA - - - SHARED_SETTINGS_FOR_ALL_APPAREANCES - - - INSTALLATION TYPE - - HIERARCHIES - - INSTALLER - - LIST - - - CHILDREN - - DESCRIPTION - - OPTIONS - - HIDDEN - - STATE - 1 - - PACKAGE_UUID - 0B7A74BC-65CF-4FF1-AC34-5C743E8A48F5 - TITLE - - TYPE - 0 - UUID - 52B6084A-F58D-45C3-BE37-76AD45F16072 - - - REMOVED - - - - MODE - 0 - - INSTALLATION_STEPS - - - ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS - ICPresentationViewIntroductionController - INSTALLER_PLUGIN - Introduction - LIST_TITLE_KEY - InstallerSectionTitle - - - ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS - ICPresentationViewReadMeController - INSTALLER_PLUGIN - ReadMe - LIST_TITLE_KEY - InstallerSectionTitle - - - ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS - ICPresentationViewLicenseController - INSTALLER_PLUGIN - License - LIST_TITLE_KEY - InstallerSectionTitle - - - ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS - ICPresentationViewDestinationSelectController - INSTALLER_PLUGIN - TargetSelect - LIST_TITLE_KEY - InstallerSectionTitle - - - ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS - ICPresentationViewInstallationTypeController - INSTALLER_PLUGIN - PackageSelection - LIST_TITLE_KEY - InstallerSectionTitle - - - ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS - ICPresentationViewInstallationController - INSTALLER_PLUGIN - Install - LIST_TITLE_KEY - InstallerSectionTitle - - - ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS - ICPresentationViewSummaryController - INSTALLER_PLUGIN - Summary - LIST_TITLE_KEY - InstallerSectionTitle - - - INTRODUCTION - - LOCALIZATIONS - - - LICENSE - - LOCALIZATIONS - - MODE - 0 - - README - - LOCALIZATIONS - - - SUMMARY - - LOCALIZATIONS - - - TITLE - - LOCALIZATIONS - - - - PROJECT_REQUIREMENTS - - LIST - - - BEHAVIOR - 3 - DICTIONARY - - IC_REQUIREMENT_OS_DISK_TYPE - 1 - IC_REQUIREMENT_OS_DISTRIBUTION_TYPE - 0 - IC_REQUIREMENT_OS_MINIMUM_VERSION - 101300 - - IC_REQUIREMENT_CHECK_TYPE - 0 - IDENTIFIER - fr.whitebox.Packages.requirement.os - MESSAGE - - NAME - Operating System - STATE - - - - RESOURCES - - ROOT_VOLUME_ONLY - - - PROJECT_SETTINGS - - ADVANCED_OPTIONS - - installer-script.domains:enable_currentUserHome - 1 - - BUILD_FORMAT - 0 - BUILD_PATH - - PATH - ../@RELATIVE_BUILD_PATH@ - PATH_TYPE - 1 - - EXCLUDED_FILES - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - .DS_Store - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Remove .DS_Store files - PROXY_TOOLTIP - Remove ".DS_Store" files created by the Finder. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - .pbdevelopment - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Remove .pbdevelopment files - PROXY_TOOLTIP - Remove ".pbdevelopment" files created by ProjectBuilder or Xcode. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - CVS - TYPE - 1 - - - REGULAR_EXPRESSION - - STRING - .cvsignore - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - .cvspass - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - .svn - TYPE - 1 - - - REGULAR_EXPRESSION - - STRING - .git - TYPE - 1 - - - REGULAR_EXPRESSION - - STRING - .gitignore - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Remove SCM metadata - PROXY_TOOLTIP - Remove helper files and folders used by the CVS, SVN or Git Source Code Management systems. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - classes.nib - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - designable.db - TYPE - 0 - - - REGULAR_EXPRESSION - - STRING - info.nib - TYPE - 0 - - - PROTECTED - - PROXY_NAME - Optimize nib files - PROXY_TOOLTIP - Remove "classes.nib", "info.nib" and "designable.nib" files within .nib bundles. - STATE - - - - PATTERNS_ARRAY - - - REGULAR_EXPRESSION - - STRING - Resources Disabled - TYPE - 1 - - - PROTECTED - - PROXY_NAME - Remove Resources Disabled folders - PROXY_TOOLTIP - Remove "Resources Disabled" folders. - STATE - - - - SEPARATOR - - - - NAME - @CMAKE_PROJECT_NAME@ - PAYLOAD_ONLY - - TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING - - - - TYPE - 0 - VERSION - 2 - - diff --git a/cmake/bundle/macos/scripts/postinstall b/cmake/bundle/macos/scripts/postinstall deleted file mode 100755 index 84612e5..0000000 --- a/cmake/bundle/macos/scripts/postinstall +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -if [[ "$2" = "/Library/Application Support/obs-studio/plugins" ]] -then - /usr/bin/su "$USER" -c "/usr/sbin/installer -pkg $(printf %q "$1") -target CurrentUserHomeDirectory" -fi diff --git a/cmake/bundle/windows/installer-Windows.iss.in b/cmake/bundle/windows/installer-Windows.iss.in deleted file mode 100644 index f9d73e6..0000000 --- a/cmake/bundle/windows/installer-Windows.iss.in +++ /dev/null @@ -1,64 +0,0 @@ -#define MyAppName "@CMAKE_PROJECT_NAME@" -#define MyAppVersion "@CMAKE_PROJECT_VERSION@" -#define MyAppPublisher "@PLUGIN_AUTHOR@" -#define MyAppURL "https://github.com/royshil/obs-cleanstream" - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{CD703FE5-1F2C-4837-BD3D-DD840D83C3E3} -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -DefaultDirName={code:GetDirName} -DefaultGroupName={#MyAppName} -OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer -Compression=lzma -SolidCompression=yes -DirExistsWarning=no - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Files] -Source: "..\release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "..\LICENSE"; Flags: dontcopy -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[Icons] -Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" -Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" - -[Code] -procedure InitializeWizard(); -var - GPLText: AnsiString; - Page: TOutputMsgMemoWizardPage; -begin - ExtractTemporaryFile('LICENSE'); - LoadStringFromFile(ExpandConstant('{tmp}\LICENSE'), GPLText); - Page := CreateOutputMsgMemoPage(wpWelcome, - 'License Information', 'Please review the license terms before installing {#MyAppName}', - 'Press Page Down to see the rest of the agreement. Once you are aware of your rights, click Next to continue.', - String(GPLText) - ); -end; - -// credit where it's due : -// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45 -function GetDirName(Value: string): string; -var - InstallPath: string; -begin - // initialize default path, which will be returned when the following registry - // key queries fail due to missing keys or for some different reason - Result := '{autopf}\obs-studio'; - // query the first registry value; if this succeeds, return the obtained value - if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then - Result := InstallPath -end; - diff --git a/cmake/bundle/windows/resource.rc.in b/cmake/bundle/windows/resource.rc.in deleted file mode 100644 index fc4a5b4..0000000 --- a/cmake/bundle/windows/resource.rc.in +++ /dev/null @@ -1,32 +0,0 @@ -1 VERSIONINFO - FILEVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0 - PRODUCTVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0 - FILEFLAGSMASK 0x0L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x0L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "${PLUGIN_AUTHOR}" - VALUE "FileDescription", "${PROJECT_NAME}" - VALUE "FileVersion", "${PROJECT_VERSION}" - VALUE "InternalName", "${PROJECT_NAME}" - VALUE "LegalCopyright", "(C) ${PLUGIN_AUTHOR}" - VALUE "OriginalFilename", "${PROJECT_NAME}" - VALUE "ProductName", "${PROJECT_NAME}" - VALUE "ProductVersion", "${PROJECT_VERSION}" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/cmake/common/buildspec_common.cmake b/cmake/common/buildspec_common.cmake index f995246..d0f43c7 100644 --- a/cmake/common/buildspec_common.cmake +++ b/cmake/common/buildspec_common.cmake @@ -75,10 +75,9 @@ function(_setup_obs_studio) message(STATUS "Patch libobs") execute_process( - COMMAND patch "${dependencies_dir}/${_obs_destination}/libobs/CMakeLists.txt" - "${CMAKE_CURRENT_SOURCE_DIR}/patch_libobs.diff" - RESULT_VARIABLE _process_result COMMAND_ERROR_IS_FATAL ANY - OUTPUT_QUIET) + COMMAND patch --forward "libobs/CMakeLists.txt" "${CMAKE_CURRENT_SOURCE_DIR}/patch_libobs.diff" + RESULT_VARIABLE _process_result + WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}") message(STATUS "Patch - done") message(STATUS "Configure ${label} (${arch})") diff --git a/cmake/common/compiler_common.cmake b/cmake/common/compiler_common.cmake index da4e144..8ac423f 100644 --- a/cmake/common/compiler_common.cmake +++ b/cmake/common/compiler_common.cmake @@ -3,7 +3,7 @@ include_guard(GLOBAL) # Set C and C++ language standards to C17 and C++17 -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21) set(CMAKE_C_STANDARD 17) else() set(CMAKE_C_STANDARD 11) diff --git a/cmake/common/helpers_common.cmake b/cmake/common/helpers_common.cmake index 702cb81..1d06adb 100644 --- a/cmake/common/helpers_common.cmake +++ b/cmake/common/helpers_common.cmake @@ -134,4 +134,8 @@ 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 + set_property(TARGET plugin-support PROPERTY POSITION_INDEPENDENT_CODE ON) + endif() endif() diff --git a/cmake/linux/compilerconfig.cmake b/cmake/linux/compilerconfig.cmake index 67d2b74..3d1c95f 100644 --- a/cmake/linux/compilerconfig.cmake +++ b/cmake/linux/compilerconfig.cmake @@ -21,6 +21,7 @@ set(_obs_gcc_c_options -Wformat -Wformat-security -Wno-conversion + -Wno-error=deprecated-declarations -Wno-float-conversion -Wno-implicit-fallthrough -Wno-missing-braces diff --git a/cmake/linux/defaults.cmake b/cmake/linux/defaults.cmake index 72437a1..223756d 100644 --- a/cmake/linux/defaults.cmake +++ b/cmake/linux/defaults.cmake @@ -32,7 +32,7 @@ set(CPACK_SOURCE_IGNORE_FILES # cmake-format: sortable ".*~$" \\.git/ - \\.github/ + # \\.github/ \\.gitignore build_.* cmake/\\.CMakeBuildNumber diff --git a/cmake/macos/helpers.cmake b/cmake/macos/helpers.cmake index b0a8ce4..37b92bf 100644 --- a/cmake/macos/helpers.cmake +++ b/cmake/macos/helpers.cmake @@ -79,7 +79,8 @@ function(set_target_properties_plugin target) CONFIGURATIONS Release DESTINATION . OPTIONAL) - configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake") + configure_file(cmake/macos/resources/distribution.in "${CMAKE_CURRENT_BINARY_DIR}/distribution" @ONLY) + configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake" @ONLY) install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake") endfunction() diff --git a/cmake/macos/resources/create-package.cmake.in b/cmake/macos/resources/create-package.cmake.in index b30a8a3..a2f1b11 100644 --- a/cmake/macos/resources/create-package.cmake.in +++ b/cmake/macos/resources/create-package.cmake.in @@ -1,7 +1,35 @@ -set(CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME}) -set(CMAKE_PROJECT_VERSION ${CMAKE_PROJECT_VERSION}) -set(MACOS_BUNDLEID ${MACOS_BUNDLEID}) -set(UUID_PACKAGE ${UUID_PACKAGE}) -set(UUID_INSTALLER ${UUID_INSTALLER}) -configure_file(cmake/macos/resources/installer-macos.pkgproj.in - "${CMAKE_CURRENT_BINARY_DIR}/installer-macos.generated.pkgproj") +make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins") + +if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin") + file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" + TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" USE_SOURCE_PERMISSIONS) + + if(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$" OR CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$") + if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM") + file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" USE_SOURCE_PERMISSIONS) + endif() + endif() +endif() + +make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp") + +execute_process( + COMMAND /usr/bin/pkgbuild + --identifier '@MACOS_BUNDLEID@' + --version '@CMAKE_PROJECT_VERSION@' + --root "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package" + "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp/@CMAKE_PROJECT_NAME@.pkg" + COMMAND_ERROR_IS_FATAL ANY + ) + +execute_process( + COMMAND /usr/bin/productbuild + --distribution "@CMAKE_CURRENT_BINARY_DIR@/distribution" + --package-path "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp" + "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg" + COMMAND_ERROR_IS_FATAL ANY) + +if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg") + file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp") + file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package") +endif() diff --git a/cmake/macos/resources/distribution.in b/cmake/macos/resources/distribution.in new file mode 100644 index 0000000..016043b --- /dev/null +++ b/cmake/macos/resources/distribution.in @@ -0,0 +1,33 @@ + + + + + @CMAKE_PROJECT_NAME@ + + + + + + + #@CMAKE_PROJECT_NAME@.pkg + + + diff --git a/src/cleanstream-filter.cpp b/src/cleanstream-filter.cpp index eb74607..857d67d 100644 --- a/src/cleanstream-filter.cpp +++ b/src/cleanstream-filter.cpp @@ -2,7 +2,13 @@ #include #include #include -#include + +#ifdef _WIN32 +#include +#define NOMINMAX +#include +#undef max +#endif #include #include @@ -18,6 +24,8 @@ #include "model-utils/model-downloader.h" #include "whisper-utils/whisper-language.h" +#include "plugin-support.h" + #define do_log(level, format, ...) \ blog(level, "[cleanstream filter: '%s'] " format, __func__, ##__VA_ARGS__) @@ -226,9 +234,47 @@ inline enum speaker_layout convert_speaker_layout(uint8_t channels) } } -struct whisper_context *init_whisper_context(const std::string &model_path) +struct whisper_context *init_whisper_context(const std::string &model_path_) { - struct whisper_context *ctx = whisper_init_from_file(obs_module_file(model_path.c_str())); + struct whisper_context_params cparams; +#ifdef LOCALVOCAL_WITH_CUDA + cparams.use_gpu = true; +#else + cparams.use_gpu = false; +#endif + + char *model_path_ctr = obs_module_file(model_path_.c_str()); + std::string model_path(model_path_ctr); + bfree(model_path_ctr); + +#ifdef _WIN32 + // convert model path UTF8 to wstring (wchar_t) for whisper + int count = MultiByteToWideChar(CP_UTF8, 0, model_path.c_str(), (int)model_path.length(), + NULL, 0); + std::wstring model_path_ws(count, 0); + MultiByteToWideChar(CP_UTF8, 0, model_path.c_str(), (int)model_path.length(), + &model_path_ws[0], count); + + // Read model into buffer + std::ifstream modelFile(model_path_ws, std::ios::binary); + if (!modelFile.is_open()) { + obs_log(LOG_ERROR, "Failed to open whisper model file %s", model_path.c_str()); + return nullptr; + } + modelFile.seekg(0, std::ios::end); + const size_t modelFileSize = modelFile.tellg(); + modelFile.seekg(0, std::ios::beg); + std::vector modelBuffer(modelFileSize); + modelFile.read(modelBuffer.data(), modelFileSize); + modelFile.close(); + + // Initialize whisper + struct whisper_context *ctx = + whisper_init_from_buffer_with_params(modelBuffer.data(), modelFileSize, cparams); +#else + struct whisper_context *ctx = + whisper_init_from_file_with_params(model_path.c_str(), cparams); +#endif if (ctx == nullptr) { error("Failed to load whisper model"); return nullptr;