Просмотр исходного кода

CI: Add Zsh-based scripts for macOS

PatTheMav 3 лет назад
Родитель
Сommit
014a09527f

+ 182 - 0
.github/scripts/.build.zsh

@@ -0,0 +1,182 @@
+#!/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
+
+  local -i _verbosity=1
+  local -r _version='0.0.1'
+  local -r -a _valid_targets=(
+    macos-x86_64
+    macos-arm64
+    macos-universal
+    linux-x86_64
+  )
+  local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
+  local -r _usage="
+Usage: %B${functrace[1]%:*}%b <option> [<options>]
+
+%BOptions%b:
+
+%F{yellow} Build configuration options%f
+ -----------------------------------------------------------------------------
+  %B-t | --target%b                     Specify target - default: %B%F{green}${host_os}-${CPUTYPE}%f%b
+  %B-c | --config%b                     Build configuration - default: %B%F{green}RelWithDebInfo%f%b
+  %B-s | --codesign%b                   Enable codesigning (macOS only)
+
+%F{yellow} Output options%f
+ -----------------------------------------------------------------------------
+  %B-q | --quiet%b                      Quiet (error output only)
+  %B-v | --verbose%b                    Verbose (more detailed output)
+
+%F{yellow} General options%f
+ -----------------------------------------------------------------------------
+  %B-h | --help%b                       Print this usage help
+  %B-V | --version%b                    Print script version information"
+
+  local -a args
+  while (( # )) {
+    case ${1} {
+      -t|--target|-c|--config)
+        if (( # == 1 )) || [[ ${2:0:1} == '-' ]] {
+          log_error "Missing value for option %B${1}%b"
+          log_output ${_usage}
+          exit 2
+        }
+        ;;
+    }
+    case ${1} {
+      --)
+        shift
+        args+=($@)
+        break
+        ;;
+      -t|--target)
+        if (( ! ${_valid_targets[(Ie)${2}]} )) {
+          log_error "Invalid value %B${2}%b for option %B${1}%b"
+          log_output ${_usage}
+          exit 2
+        }
+        target=${2}
+        shift 2
+        ;;
+      -c|--config)
+        if (( ! ${_valid_configs[(Ie)${2}]} )) {
+          log_error "Invalid value %B${2}%b for option %B${1}%b"
+          log_output ${_usage}
+          exit 2
+        }
+        BUILD_CONFIG=${2}
+        shift 2
+        ;;
+      -s|--codesign) CODESIGN=1; shift ;;
+      -q|--quiet) (( _verbosity -= 1 )) || true; shift ;;
+      -v|--verbose) (( _verbosity += 1 )); shift ;;
+      -h|--help) log_output ${_usage}; exit 0 ;;
+      -V|--version) print -Pr "${_version}"; exit 0 ;;
+      *) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;;
+    }
+  }
+
+  set -- ${(@)args}
+  set_loglevel ${_verbosity}
+
+  check_${host_os}
+  setup_${host_os}
+
+  read -r product_name product_version <<< \
+    "$(jq -r '. | {name, version} | join(" ")' ${project_root}/buildspec.json)"
+
+  case ${host_os} {
+    macos-*)
+      sed -i '' \
+        "s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/" \
+        "${project_root}"/CMakeLists.txt
+      ;;
+    linux-*)
+      sed -i'' \
+        "s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/"\
+        "${project_root}"/CMakeLists.txt
+      ;;
+  }
+
+  setup_obs
+
+  pushd ${project_root}
+  log_info "Configuring ${product_name}..."
+
+  local -a cmake_args=(
+    -DCMAKE_BUILD_TYPE=${BUILD_CONFIG:-RelWithDebInfo}
+    -DCMAKE_PREFIX_PATH="${project_root:h}/obs-build-dependencies/obs-plugin-deps"
+  )
+
+  if (( _loglevel == 0 )) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR)
+
+  case ${target} {
+    macos-*)
+      autoload -Uz read_codesign
+      if (( ${+CODESIGN} )) {
+        read_codesign
+      }
+
+      cmake_args+=(
+        -DCMAKE_OSX_ARCHITECTURES=${${target##*-}//universal/x86_64;arm64}
+        -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-10.15}
+        -DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}"
+        -DCMAKE_FRAMEWORK_PATH="${project_root:h}/obs-build-dependencies/obs-plugin-deps/Frameworks"
+      )
+      ;;
+    linux-*) ;;
+  }
+
+  cmake -S . -B build_${target} -G Ninja ${cmake_args}
+
+  local -a cmake_args=()
+  if (( _loglevel > 1 )) cmake_args+=(--verbose)
+
+  log_info "Building ${product_name}"
+  cmake --build build_${target} --config ${BUILD_CONFIG:-RelWithDebInfo} ${cmake_args}
+
+  log_info "Install ${product_name}"
+  cmake --install build_${target} --config ${BUILD_CONFIG:-RelWithDebInfo} --prefix "${project_root}"/release ${cmake_args}
+  popd
+}
+
+build "${@}"

+ 196 - 0
.github/scripts/.package.zsh

@@ -0,0 +1,196 @@
+#!/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
+}
+
+package() {
+  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 set_loglevel log_info log_error log_output check_${host_os}
+
+  local -i _verbosity=1
+  local -r _version='0.0.1'
+  local -r -a _valid_targets=(
+    macos-x86_64
+    macos-arm64
+    macos-universal
+    linux-x86_64
+  )
+  local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
+  local -r _usage="
+Usage: %B${functrace[1]%:*}%b <option> [<options>]
+
+%BOptions%b:
+
+%F{yellow} Package configuration options%f
+ -----------------------------------------------------------------------------
+  %B-t | --target%b                     Specify target - default: %B%F{green}${host_os}-${CPUTYPE}%f%b
+  %B-c | --config%b                     Build configuration - default: %B%F{green}RelWithDebInfo%f%b
+  %B-s | --codesign%b                   Enable codesigning (macOS only)
+  %B-n | --notarize%b                   Enable notarization (macOS only)
+
+%F{yellow} Output options%f
+ -----------------------------------------------------------------------------
+  %B-q | --quiet%b                      Quiet (error output only)
+  %B-v | --verbose%b                    Verbose (more detailed output)
+
+%F{yellow} General options%f
+ -----------------------------------------------------------------------------
+  %B-h | --help%b                       Print this usage help
+  %B-V | --version%b                    Print script version information"
+
+  local -a args
+  while (( # )) {
+    case ${1} {
+      -t|--target|-c|--config)
+        if (( # == 1 )) || [[ ${2:0:1} == '-' ]] {
+          log_error "Missing value for option %B${1}%b"
+          log_output ${_usage}
+          exit 2
+        }
+        ;;
+    }
+    case ${1} {
+      --)
+        shift
+        args+=($@)
+        break
+        ;;
+      -t|--target)
+        if (( ! ${_valid_targets[(Ie)${2}]} )) {
+          log_error "Invalid value %B${2}%b for option %B${1}%b"
+          log_output ${_usage}
+          exit 2
+        }
+        target=${2}
+        shift 2
+        ;;
+      -c|--config)
+        if (( ! ${_valid_configs[(Ie)${2}]} )) {
+          log_error "Invalid value %B${2}%b for option %B${1}%b"
+          log_output ${_usage}
+          exit 2
+        }
+        BUILD_CONFIG=${2}
+        shift 2
+        ;;
+      -s|--codesign) CODESIGN=1; shift ;;
+      -n|--notarize) NOTARIZE=1; shift ;;
+      -q|--quiet) (( _verbosity -= 1 )) || true; shift ;;
+      -v|--verbose) (( _verbosity += 1 )); shift ;;
+      -h|--help) log_output ${_usage}; exit 0 ;;
+      -V|--version) print -Pr "${_version}"; exit 0 ;;
+      *) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;;
+    }
+  }
+
+  set -- ${(@)args}
+  set_loglevel ${_verbosity}
+
+  check_${host_os}
+
+  read -r product_name product_version <<< \
+    "$(jq -r '. | {name, version} | join(" ")' ${project_root}/buildspec.json)"
+
+  if [[ ${host_os} == 'macos' ]] {
+    autoload -Uz check_packages check_xcnotary read_codesign read_codesign_installer read_codesign_pass
+
+    local output_name="${product_name}-${product_version}-${host_os}-${target##*-}.pkg"
+
+    if [[ ! -d ${project_root}/release/${product_name}.plugin ]] {
+      log_error 'No release artifact found. Run the build script or the CMake install procedure first.'
+      return 2
+    }
+
+    if [[ ! -f ${project_root}/build_${target}/installer-macos.generated.pkgproj ]] {
+      log_error 'Packages project file not found. Run the build script or the CMake build and install procedures first.'
+      return 2
+    }
+
+    check_packages
+
+    log_info "Packaging ${product_name}..."
+    pushd ${project_root}
+    packagesbuild \
+      --build-folder ${project_root}/release \
+      ${project_root}/build_${target}/installer-macos.generated.pkgproj
+
+    if (( ${+CODESIGN} )) {
+      read_codesign_installer
+      productsign \
+        --sign "${CODESIGN_IDENT_INSTALLER}" \
+        "${project_root}/release/${product_name}.pkg" \
+        "${project_root}/release/${output_name}"
+
+      rm "${project_root}/release/${product_name}.pkg"
+    } else {
+      mv "${project_root}/release/${product_name}.pkg" \
+        "${project_root}/release/${output_name}"
+    }
+
+    if (( ${+CODESIGN} + ${+NOTARIZE} > 1 )) {
+      check_xcnotary
+
+      local _error=0
+      if [[ -f "${project_root}/release/${output_name}" ]] {
+        xcnotary precheck "${project_root}/release/${output_name}" || _error=1
+      } else {
+        log_error "No package for notarization found."
+        return 2
+      }
+
+      if (( ! _error )) {
+        read_codesign_installer
+        read_codesign_pass
+
+        xcnotary notarize "${project_root}/release/${output_name}" \
+          --developer-account "${CODESIGN_IDENT_USER}" \
+          --developer-password-keychain-item "OBS-Codesign-Password" \
+          --provider "${CODESIGN_IDENT_SHORT}"
+      }
+    }
+    popd
+  } elif [[ ${host_os} == 'linux' ]] {
+    local -a cmake_args=()
+    if (( _loglevel > 1 )) cmake_args+=(--verbose)
+
+    pushd ${project_root}
+    cmake --build build_${target} --config ${BUILD_CONFIG:-RelWithDebInfo} -t package ${cmake_args}
+    popd
+  }
+}
+
+package "${@}"

+ 1 - 0
.github/scripts/build-macos.zsh

@@ -0,0 +1 @@
+.build.zsh

+ 1 - 0
.github/scripts/package-macos.zsh

@@ -0,0 +1 @@
+.package.zsh

+ 18 - 0
.github/scripts/utils.zsh/check_macos

@@ -0,0 +1,18 @@
+autoload -Uz is-at-least log_info log_error log_status read_codesign
+
+local macos_version=$(sw_vers -productVersion)
+
+log_info 'Checking macOS version...'
+if ! is-at-least 10.15.0 "${macos_version}"; then
+  log_error "Minimum required macOS version is 10.15, but running on macOS ${macos_version}"
+  return 2
+else
+  log_status "macOS ${macos_version} is recent"
+fi
+
+log_info 'Checking for Homebrew...'
+if (( ! ${+commands[brew]} )) {
+  log_error 'No Homebrew command found. Please install Homebrew (https://brew.sh)'
+  return 2
+}
+brew bundle --file "${SCRIPT_HOME}/.Brewfile"

+ 51 - 0
.github/scripts/utils.zsh/check_packages

@@ -0,0 +1,51 @@
+if (( ! ${+commands[packagesbuild]} )) {
+  autoload -Uz 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+=(--progress-bar)
+  } else {
+    curl_opts+=(--show-error --silent)
+  }
+  curl_opts+=(--location -O ${@})
+
+  log_info 'Installing Packages.app...'
+
+  pushd
+  mkcd ${project_root:h}/obs-build-dependencies
+
+  local packages_url='http://s.sudre.free.fr/Software/files/Packages.dmg'
+  local packages_hash='6afdd25386295974dad8f078b8f1e41cabebd08e72d970bf92f707c7e48b16c9'
+
+  if [[ ! -f Packages.dmg ]] {
+    log_status 'Download Packages.app'
+    curl ${curl_opts} ${packages_url}
+  }
+
+  read -r image_checksum _ <<< "$(sha256sum Packages.dmg)"
+
+  if [[ ${packages_hash} != ${image_checksum} ]] {
+    log_error "Checksum mismatch of Packages.app download.
+Expected : ${packages_hash}
+Actual   : ${image_checksum}"
+    return 2
+  }
+
+  hdiutil attach -noverify Packages.dmg &> /dev/null && log_status 'Packages.dmg image mounted.'
+
+  log_info 'Installing Packages.app...'
+  packages_volume=$(hdiutil info -plist | grep '<string>/Volumes/Packages' | sed 's/.*<string>\(\/Volumes\/[^<]*\)<\/string>/\1/')
+
+  sudo installer -pkg "${packages_volume}/packages/Packages.pkg" -target / && rehash
+  hdiutil detach ${packages_volume} &> /dev/null && log_status 'Packages.dmg image unmounted.'
+}

+ 9 - 0
.github/scripts/utils.zsh/check_xcnotary

@@ -0,0 +1,9 @@
+autoload -Uz log_info log_error
+
+log_info 'Checking for Homebrew...'
+if (( ! ${+commands[brew]} )) {
+  log_error 'No Homebrew command found. Please install Homebrew (https://brew.sh)'
+  return 2
+}
+
+if (( ! ${+commands[xcnotary]} )) brew install akeru-inc/tap/xcnotary

+ 3 - 0
.github/scripts/utils.zsh/log_debug

@@ -0,0 +1,3 @@
+if (( ! ${+_loglevel} )) typeset -g _loglevel=1
+
+if (( _loglevel > 2 )) print -PR -e -- "%F{220}DEBUG: ${@}%f"

+ 3 - 0
.github/scripts/utils.zsh/log_error

@@ -0,0 +1,3 @@
+local icon='  ✖︎ '
+
+print -u2 -PR "%F{1} ${icon} %f ${@}"

+ 7 - 0
.github/scripts/utils.zsh/log_info

@@ -0,0 +1,7 @@
+if (( ! ${+_loglevel} )) typeset -g _loglevel=1
+
+if (( _loglevel > 0 )) {
+  local icon=' =>'
+
+  print -PR "%F{4}  ${(r:5:)icon}%f %B${@}%b"
+}

+ 7 - 0
.github/scripts/utils.zsh/log_output

@@ -0,0 +1,7 @@
+if (( ! ${+_loglevel} )) typeset -g _loglevel=1
+
+if (( _loglevel > 0 )) {
+  local icon=''
+
+  print -PR "  ${(r:5:)icon} ${@}"
+}

+ 7 - 0
.github/scripts/utils.zsh/log_status

@@ -0,0 +1,7 @@
+if (( ! ${+_loglevel} )) typeset -g _loglevel=1
+
+if (( _loglevel > 0 )) {
+  local icon='  >'
+
+  print -PR "%F{2}  ${(r:5:)icon}%f ${@}"
+}

+ 5 - 0
.github/scripts/utils.zsh/log_warning

@@ -0,0 +1,5 @@
+if (( _loglevel > 0 )) {
+  local icon=' =>'
+
+  print -PR "%F{3}  ${(r:5:)icon} ${@}%f"
+}

+ 1 - 0
.github/scripts/utils.zsh/mkcd

@@ -0,0 +1 @@
+[[ -n ${1} ]] && mkdir -p ${1} && builtin cd ${1}

+ 7 - 0
.github/scripts/utils.zsh/read_codesign

@@ -0,0 +1,7 @@
+autoload -Uz log_info
+
+if (( ! ${+CODESIGN_IDENT} )) {
+  typeset -g CODESIGN_IDENT
+  log_info 'Setting up identity for application codesigning...'
+  read CODESIGN_IDENT'?Apple Developer Application ID: '
+}

+ 7 - 0
.github/scripts/utils.zsh/read_codesign_installer

@@ -0,0 +1,7 @@
+autoload -Uz log_info
+
+if (( ! ${+CODESIGN_IDENT_INSTALLER} )) {
+  typeset -g CODESIGN_IDENT_INSTALLER
+  log_info 'Setting up identity for installer package codesigning...'
+  read CODESIGN_IDENT_INSTALLER'?Apple Developer Installer ID: '
+}

+ 31 - 0
.github/scripts/utils.zsh/read_codesign_pass

@@ -0,0 +1,31 @@
+##############################################################################
+# Apple Developer credentials necessary:
+#
+#   + Signing for distribution and notarization require an active Apple
+#     Developer membership
+#   + An Apple Development identity is needed for code signing
+#     (i.e. 'Apple Development: YOUR APPLE ID (PROVIDER)')
+#   + Your Apple developer ID is needed for notarization
+#   + An app-specific password is necessary for notarization from CLI
+#   + This password will be stored in your macOS keychain under the identifier
+#     'OBS-Codesign-Password'with access Apple's 'altool' only.
+##############################################################################
+
+autoload -Uz read_codesign read_codesign_user log_info
+
+if (( ! ${+CODESIGN_IDENT} )) {
+  read_codesign
+}
+
+if (( ! ${+CODESIGN_IDENT_USER} )) {
+  read_codesign_user
+}
+
+log_info 'Setting up password for notarization keychain...'
+if (( ! ${+CODESIGN_IDENT_PASS} )) {
+  read -s CODESIGN_IDENT_PASS'?Apple Developer ID password: '
+}
+
+log_info 'Setting up notarization keychain...'
+xcrun altool --store-password-in-keychain-item 'OBS-Codesign-Password' -u "${CODESIGN_IDENT_USER}" -p "${CODESIGN_IDENT_PASS}"
+typeset -g CODESIGN_IDENT_SHORT=$(print "${CODESIGN_IDENT}" | /usr/bin/sed -En 's/.+\((.+)\)/\1/p')

+ 7 - 0
.github/scripts/utils.zsh/read_codesign_user

@@ -0,0 +1,7 @@
+autoload -Uz log_info
+
+if (( ! ${+CODESIGN_IDENT_USER} )) {
+  typeset -g CODESIGN_IDENT_USER
+  log_info 'Setting up developer id for codesigning...'
+  read CODESIGN_IDENT_USER'?Apple Developer ID: '
+}

+ 17 - 0
.github/scripts/utils.zsh/set_loglevel

@@ -0,0 +1,17 @@
+autoload -Uz log_debug log_error
+
+local -r _usage="Usage: %B${0}%b <loglevel>
+
+Set log level, following levels are supported: 0 (quiet), 1 (normal), 2 (verbose), 3 (debug)"
+
+if (( ! # )); then
+  log_error 'Called without arguments.'
+  log_output ${_usage}
+  return 2
+elif (( ${1} >= 4 )); then
+  log_error 'Called with loglevel > 3.'
+  log_output ${_usage}
+fi
+
+typeset -g -i -r _loglevel=${1}
+log_debug "Log level set to '${1}'"

+ 104 - 0
.github/scripts/utils.zsh/setup_macos

@@ -0,0 +1,104 @@
+autoload -Uz log_error log_status log_info mkcd
+
+if (( ! ${+commands[curl]} )) {
+  log_error 'curl not found. Please install curl.'
+  return 2
+}
+
+if (( ! ${+commands[jq]} )) {
+  log_error 'jq not found. Please install jq.'
+  return 2
+}
+
+if (( ! ${+project_root} )) {
+  log_error "'project_root' not set. Please set before running ${0}."
+  return 2
+}
+
+if (( ! ${+target} )) {
+  log_error "'target' not set. Please set before running ${0}."
+  return 2
+}
+
+local -a curl_opts=()
+if (( ! ${+CI} )) {
+    curl_opts+=(--progress-bar)
+} else {
+    curl_opts+=(--show-error --silent)
+}
+curl_opts+=(--location -O ${@})
+
+pushd ${project_root}
+log_info 'Setting up obs-deps...'
+read -r deps_version deps_hash <<< \
+  "$(jq -r --arg key "obs-deps" --arg target "${target}" \
+    '.dependencies[$key][$target] | {version, hash} | join(" ")' \
+    ${buildspec_file})"
+
+if [[ -z "${deps_version}" ]] {
+  log_error 'No obs-deps version found in buildspec.json.'
+  return 2
+}
+log_status 'Found obs-deps specification.'
+
+mkcd ${project_root:h}/obs-build-dependencies
+
+if [[ ! -f macos-deps-${deps_version}-${target##*-}.tar.xz ]] {
+  curl ${curl_opts} \
+    "https://github.com/obsproject/obs-deps/releases/download/${deps_version}/macos-deps-${deps_version}-${target##*-}.tar.xz" && \
+    log_status "Downloaded obs-deps for ${target}."
+} else {
+  log_status 'Found downloaded obs-deps.'
+}
+
+read -r artifact_checksum _ <<< "$(sha256sum macos-deps-${deps_version}-${target##*-}.tar.xz)"
+if [[ ${deps_hash} != ${artifact_checksum} ]] {
+  log_error "Checksum of downloaded obs-deps does not match specification.
+Expected : ${deps_hash}
+Actual   : ${artifact_checksum}"
+  return 2
+}
+log_status 'Checksum of downloaded obs-deps matches.'
+
+mkcd obs-plugin-deps
+XZ_OPT=-T0 tar -xzf ../macos-deps-${deps_version}-${target##*-}.tar.xz && log_status 'obs-deps extracted.'
+popd
+
+pushd ${project_root}
+log_info 'Setting up Qt...'
+read -r qt_version qt_hash <<< \
+  "$(jq -r --arg key "obs-deps-qt" --arg target "${target}" \
+    '.dependencies[$key][$target] | {version, hash} | join(" ")' \
+    ${buildspec_file})"
+
+if [[ -z "${qt_version}" ]] {
+  log_error 'No obs-deps version found in buildspec.json.'
+  return 2
+}
+log_status 'Found Qt specification.'
+
+mkcd ${project_root:h}/obs-build-dependencies
+
+if [[ ! -f macos-deps-qt-${deps_version}-${target##*-}.tar.xz ]] {
+  curl ${curl_opts} \
+    "https://github.com/obsproject/obs-deps/releases/download/${deps_version}/macos-deps-qt-${deps_version}-${target##*-}.tar.xz" && \
+    log_status "Downloaded Qt for ${target}"
+} else {
+  log_status 'Found downloaded Qt.'
+}
+
+read -r artifact_checksum _ <<< "$(sha256sum macos-deps-qt-${deps_version}-${target##*-}.tar.xz)"
+if [[ ${qt_hash} != ${artifact_checksum} ]] {
+  log_error "Checksum of downloaded Qt does not match specification.
+Expected : ${qt_hash}
+Actual   : ${artifact_checksum}"
+  return 2
+}
+log_status 'Checksum of downloaded Qt matches.'
+
+mkcd obs-plugin-deps
+XZ_OPT=-T0 tar -xzf ../macos-deps-qt-${qt_version}-${target##*-}.tar.xz && log_status 'Qt extracted.'
+
+xattr -r -d com.apple.quarantine *
+log_status 'Removed quarantine flag from downloaded dependencies...'
+popd

+ 105 - 0
.github/scripts/utils.zsh/setup_obs

@@ -0,0 +1,105 @@
+autoload -Uz log_error log_info log_status
+
+if (( ! ${+buildspec_file} )) {
+  log_error "'buildspec_file' not set. Please set before running ${0}."
+  return 2
+}
+
+if (( ! ${+commands[git]} )) {
+  log_error 'git not found. Please install git.'
+  return 2
+}
+
+if (( ! ${+commands[jq]} )) {
+  log_error 'jq not found. Please install jq.'
+  return 2
+}
+
+if (( ! ${+project_root} )) {
+  log_error "'project_root' not set. Please set before running ${0}."
+  return 2
+}
+
+if (( ! ${+target} )) {
+  log_error "'target' not set. Please set before running ${0}."
+  return 2
+}
+
+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
+}
+
+log_info 'Setting up OBS-Studio...'
+
+read -r obs_version obs_repo obs_branch obs_hash <<< \
+  "$(jq -r --arg key "obs-studio" \
+     '.dependencies[$key] | {version, repository, branch, hash} | join(" ")' \
+     ${buildspec_file})"
+
+if [[ -z ${obs_version} ]] {
+  log_error "No obs-studio version found in buildspec.json"
+  return 2
+}
+
+pushd
+mkcd ${project_root:h}/obs-studio
+
+if [[ -d .git ]] {
+  git config advice.detachedHead false
+  git config remote.pluginbuild.url "${obs_repo:-https://github.com/obsproject/obs-studio.git}"
+  git config remote.pluginbuild.fetch "+refs/heads/${obs_branch:-master}:refs/remotes/origin/${obs_branch:-master}"
+
+  git rev-parse -q --verify "${obs_hash}^{commit}" > /dev/null || git fetch pluginbuild
+  git checkout ${obs_branch:-master} -B ${product_name}
+  git reset --hard "${obs_hash}"
+  log_status 'Found existing obs-studio repository.'
+} else {
+  git clone "${obs_repo:-https://github.com/obsproject/obs-studio.git}" "${PWD}"
+  git config advice.detachedHead false
+  git checkout -f "${obs_hash}" --
+  git checkout ${obs_branch:-master} -b ${product_name}
+  log_status 'obs-studio checked out.'
+}
+
+git submodule foreach --recursive git submodule sync
+git submodule update --init --recursive
+
+log_info 'Configuring obs-studio...'
+
+local -a cmake_args=(
+  -DCMAKE_BUILD_TYPE=${BUILD_CONFIG:-Release}
+  -DENABLE_PLUGINS=OFF
+  -DENABLE_UI=OFF
+  -DENABLE_SCRIPTING=OFF
+  -DCMAKE_INSTALL_PREFIX="${project_root:h}/obs-build-dependencies/obs-plugin-deps"
+  -DCMAKE_PREFIX_PATH="${project_root:h}/obs-build-dependencies/obs-plugin-deps"
+)
+
+if (( _loglevel == 0 )) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR)
+
+case ${target} {
+  macos-*)
+    cmake_args+=(
+      -DCMAKE_OSX_ARCHITECTURES=${${target##*-}//universal/x86_64;arm64}
+      -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-10.15}
+    )
+    ;;
+  linux-*)
+    cmake_args+=(
+      -DENABLE_PIPEWIRE=OFF
+    )
+    ;;
+}
+
+cmake -S . -B plugin_build_${target##*-} -G Ninja ${cmake_args}
+
+log_info 'Building libobs and obs-frontend-api...'
+local -a cmake_args=()
+if (( _loglevel > 1 )) cmake_args+=(--verbose)
+
+cmake --build plugin_build_${target##*-} --config ${BUILD_CONFIG:-Release} ${cmake_args} -t obs-frontend-api
+cmake --install plugin_build_${target##*-} --config ${BUILD_CONFIG:-Release} --component obs_libraries ${cmake_args}
+popd

+ 0 - 129
CI/build-macos.sh

@@ -1,129 +0,0 @@
-#!/bin/bash
-
-##############################################################################
-# macOS plugin build script
-##############################################################################
-#
-# This script contains all steps necessary to:
-#
-#   * Build libobs and obs-frontend-api with all required dependencies
-#   * Build your plugin
-#   * Create macOS module bundle
-#   * Create macOS plugin installer package
-#   * Notarize macOS plugin installer package
-#
-# Parameters:
-#   -h, --help                      : Print usage help
-#   -q, --quiet                     : Suppress most build process output
-#   -v, --verbose                   : Enable more verbose build process output
-#   -d, --skip-dependency-checks    : Skip dependency checks
-#   -p, --package                   : Create installer for plugin
-#   -c, --codesign                  : Codesign plugin and installer
-#   -n, --notarize                  : Notarize plugin installer
-#                                     (implies --codesign)
-#   -b, --build-dir                 : Specify alternative build directory
-#                                     (default: build)
-#
-# Environment Variables (optional):
-#   MACOS_DEPS_VERSION  : Pre-compiled macOS dependencies version
-#   QT_VERSION          : Pre-compiled Qt version
-#   OBS_VERSION         : OBS version
-#
-##############################################################################
-
-# Halt on errors
-set -eE
-
-## SET UP ENVIRONMENT ##
-_RUN_OBS_BUILD_SCRIPT=TRUE
-
-CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
-if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
-    source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
-fi
-PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
-DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
-OBS_BUILD_DIR="${CHECKOUT_DIR}/../obs-studio"
-source "${CHECKOUT_DIR}/CI/include/build_support.sh"
-source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
-
-## DEPENDENCY INSTALLATION ##
-source "${CHECKOUT_DIR}/CI/macos/01_install_dependencies.sh"
-
-## OBS LIBRARY BUILD ##
-source "${CHECKOUT_DIR}/CI/macos/02_build_obs_libs.sh"
-
-## PLUGIN BUILD ##
-source "${CHECKOUT_DIR}/CI/macos/03_build_plugin.sh"
-
-## PLUGIN PACKAGE AND NOTARIZE ##
-source "${CHECKOUT_DIR}/CI/macos/04_package_plugin.sh"
-
-## MAIN SCRIPT FUNCTIONS ##
-print_usage() {
-    echo -e "build_macos.sh - Build script for ${PRODUCT_NAME}\n"
-    echo -e "Usage: ${0}\n" \
-        "-h, --help                     : Print this help\n" \
-        "-q, --quiet                    : Suppress most build process output\n" \
-        "-v, --verbose                  : Enable more verbose build process output\n" \
-        "-a, --architecture             : Specify build architecture (default: universal, alternative: x86_64, arm64)\n" \
-        "-d, --skip-dependency-checks   : Skip dependency checks\n" \
-        "-p, --package                  : Create installer for plugin\n" \
-        "-c, --codesign                 : Codesign plugin and installer\n" \
-        "-n, --notarize                 : Notarize plugin installer (implies --codesign)\n" \
-        "-b, --build-dir                : Specify alternative build directory (default: build)\n"
-}
-
-obs-build-main() {
-    while true; do
-        case "${1}" in
-            -h | --help ) print_usage; exit 0 ;;
-            -q | --quiet ) export QUIET=TRUE; shift ;;
-            -v | --verbose ) export VERBOSE=TRUE; shift ;;
-            -a | --architecture ) ARCH="${2}"; shift 2 ;;
-            -d | --skip-dependency-checks ) SKIP_DEP_CHECKS=TRUE; shift ;;
-            -p | --package ) PACKAGE=TRUE; shift ;;
-            -c | --codesign ) CODESIGN=TRUE; shift ;;
-            -n | --notarize ) NOTARIZE=TRUE; PACKAGE=TRUE CODESIGN=TRUE; shift ;;
-            -b | --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
-            -- ) shift; break ;;
-            * ) break ;;
-        esac
-    done
-
-    ensure_dir "${CHECKOUT_DIR}"
-    check_macos_version
-    check_archs
-    step "Fetching version tags..."
-    /usr/bin/git fetch origin --tags
-    GIT_BRANCH=$(/usr/bin/git rev-parse --abbrev-ref HEAD)
-    GIT_HASH=$(/usr/bin/git rev-parse --short HEAD)
-    GIT_TAG=$(/usr/bin/git describe --tags --abbrev=0 2&>/dev/null || true)
-
-    if [ "${ARCH}" = "arm64" ]; then
-        FILE_NAME="${PRODUCT_NAME}-${GIT_TAG:-${PRODUCT_VERSION}}-${GIT_HASH}-macOS-Apple.pkg"
-    elif [ "${ARCH}" = "x86_64" ]; then
-        FILE_NAME="${PRODUCT_NAME}-${GIT_TAG:-${PRODUCT_VERSION}}-${GIT_HASH}-macOS-Intel.pkg"
-    else
-        FILE_NAME="${PRODUCT_NAME}-${GIT_TAG:-${PRODUCT_VERSION}}-${GIT_HASH}-macOS-Universal.pkg"
-    fi
-
-    if [ -z "${SKIP_DEP_CHECKS}" ]; then
-        install_dependencies
-    fi
-
-    build_obs_libs
-    build_obs_plugin
-
-    if [ -n "${PACKAGE}" ]; then
-        package_obs_plugin
-    fi
-
-    if [ -n "${NOTARIZE}" ]; then
-        notarize_obs_plugin
-    fi
-
-    cleanup
-}
-
-obs-build-main $*

+ 0 - 149
CI/include/build_support_macos.sh

@@ -1,149 +0,0 @@
-#!/bin/bash
-
-##############################################################################
-# macOS support functions
-##############################################################################
-#
-# This script file can be included in build scripts for macOS.
-#
-##############################################################################
-
-# Setup build environment
-
-CI_DEPS_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+DEPS_VERSION_MAC: '([0-9\-]+)'/\1/p")
-CI_DEPS_HASH=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+DEPS_HASH_MAC: '([0-9a-f]+)'/\1/p")
-CI_QT_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+QT_VERSION_MAC: '([0-9\.]+)'/\1/p" | /usr/bin/head -1)
-CI_QT_HASH=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+QT_HASH_MAC: '([0-9a-f]+)'/\1/p")
-CI_MACOSX_DEPLOYMENT_TARGET=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+MACOSX_DEPLOYMENT_TARGET: '([0-9\.]+)'/\1/p")
-CI_OBS_VERSION=$(/bin/cat "${CI_WORKFLOW}" | /usr/bin/sed -En "s/[ ]+OBS_VERSION: '([0-9\.]+)'/\1/p")
-
-MACOS_VERSION="$(/usr/bin/sw_vers -productVersion)"
-MACOS_MAJOR="$(echo ${MACOS_VERSION} | /usr/bin/cut -d '.' -f 1)"
-MACOS_MINOR="$(echo ${MACOS_VERSION} | /usr/bin/cut -d '.' -f 2)"
-
-if [ "${TERM-}" -a -z "${CI}" ]; then
-    COLOR_RED=$(/usr/bin/tput setaf 1)
-    COLOR_GREEN=$(/usr/bin/tput setaf 2)
-    COLOR_BLUE=$(/usr/bin/tput setaf 4)
-    COLOR_ORANGE=$(/usr/bin/tput setaf 3)
-    COLOR_RESET=$(/usr/bin/tput sgr0)
-else
-    COLOR_RED=""
-    COLOR_GREEN=""
-    COLOR_BLUE=""
-    COLOR_ORANGE=""
-    COLOR_RESET=""
-fi
-
-## DEFINE UTILITIES ##
-check_macos_version() {
-    step "Check macOS version..."
-    MIN_VERSION=${MACOSX_DEPLOYMENT_TARGET:-${CI_MACOSX_DEPLOYMENT_TARGET}}
-    MIN_MAJOR=$(echo ${MIN_VERSION} | /usr/bin/cut -d '.' -f 1)
-    MIN_MINOR=$(echo ${MIN_VERSION} | /usr/bin/cut -d '.' -f 2)
-
-    if [ "${MACOS_MAJOR}" -lt "11" ] && [ "${MACOS_MINOR}" -lt "${MIN_MINOR}" ]; then
-        error "WARNING: Minimum required macOS version is ${MIN_VERSION}, but running on ${MACOS_VERSION}"
-    fi
-
-    if [ "${MACOS_MAJOR}" -ge "11" ]; then
-        export CODESIGN_LINKER="ON"
-    fi
-}
-
-install_homebrew_deps() {
-    if ! exists brew; then
-        error "Homebrew not found - please install homebrew (https://brew.sh)"
-        exit 1
-    fi
-
-    brew bundle --file "${CHECKOUT_DIR}/CI/include/Brewfile" ${QUIET:+--quiet}
-
-    check_curl
-}
-
-check_curl() {
-    if [ "${MACOS_MAJOR}" -lt "11" ] && [ "${MACOS_MINOR}" -lt "15" ]; then
-        if [ ! -d /usr/local/opt/curl ]; then
-            step "Installing Homebrew curl.."
-            brew install curl
-        fi
-
-        CURLCMD="/usr/local/opt/curl/bin/curl"
-    else
-        CURLCMD="curl"
-    fi
-
-    if [ "${CI}" -o "${QUIET}" ]; then
-        export CURLCMD="${CURLCMD} --silent --show-error --location -O"
-    else
-        export CURLCMD="${CURLCMD} --progress-bar --location --continue-at - -O"
-    fi
-}
-
-check_archs() {
-    step "Check Architecture..."
-    ARCH="${ARCH:-universal}"
-    if [ "${ARCH}" = "universal" ]; then
-        CMAKE_ARCHS="x86_64;arm64"
-    elif [ "${ARCH}" != "x86_64" -a "${ARCH}" != "arm64" ]; then
-        caught_error "Unsupported architecture '${ARCH}' provided"
-    else
-        CMAKE_ARCHS="${ARCH}"
-    fi
-}
-
-## SET UP CODE SIGNING AND NOTARIZATION CREDENTIALS ##
-##############################################################################
-# Apple Developer Identity needed:
-#
-#    + Signing the code requires a developer identity in the system's keychain
-#    + codesign will look up and find the identity automatically
-#
-##############################################################################
-read_codesign_ident() {
-    if [ ! -n "${CODESIGN_IDENT}" ]; then
-        step "Code-signing Setup"
-        read -p "${COLOR_ORANGE}  + Apple developer application identity: ${COLOR_RESET}" CODESIGN_IDENT
-    fi
-}
-
-read_codesign_ident_installer() {
-    if [ ! -n "${CODESIGN_IDENT_INSTALLER}" ]; then
-        step "Code-signing Setup for Installer"
-        read -p "${COLOR_ORANGE}  + Apple developer installer identity: ${COLOR_RESET}" CODESIGN_IDENT_INSTALLER
-    fi
-}
-
-##############################################################################
-# Apple Developer credentials necessary:
-#
-#   + Signing for distribution and notarization require an active Apple
-#     Developer membership
-#   + An Apple Development identity is needed for code signing
-#     (i.e. 'Apple Development: YOUR APPLE ID (PROVIDER)')
-#   + Your Apple developer ID is needed for notarization
-#   + An app-specific password is necessary for notarization from CLI
-#   + This password will be stored in your macOS keychain under the identifier
-#     'OBS-Codesign-Password'with access Apple's 'altool' only.
-##############################################################################
-
-read_codesign_pass() {
-    step "Notarization Setup"
-
-    if [ -z "${CODESIGN_IDENT_USER}" ]; then
-        read -p "${COLOR_ORANGE}  + Apple account id: ${COLOR_RESET}" CODESIGN_IDENT_USER
-    fi
-
-    if [ -z "${CODESIGN_IDENT_PASS}" ]; then
-        CODESIGN_IDENT_PASS=$(stty -echo; read -p "${COLOR_ORANGE}  + Apple developer password: ${COLOR_RESET}" secret; stty echo; echo $secret)
-        echo ""
-    fi
-
-    step "Updating notarization keychain"
-
-    echo -n "${COLOR_ORANGE}"
-    /usr/bin/xcrun altool --store-password-in-keychain-item "OBS-Codesign-Password" -u "${CODESIGN_IDENT_USER}" -p "${CODESIGN_IDENT_PASS}"
-    echo -n "${COLOR_RESET}"
-    CODESIGN_IDENT_SHORT=$(echo "${CODESIGN_IDENT}" | /usr/bin/sed -En "s/.+\((.+)\)/\1/p")
-}

+ 0 - 120
CI/macos/01_install_dependencies.sh

@@ -1,120 +0,0 @@
-#!/bin/bash
-
-##############################################################################
-# macOS dependency management function
-##############################################################################
-#
-# This script file can be included in build scripts for macOS or run directly
-#
-##############################################################################
-
-# Halt on errors
-set -eE
-
-install_obs-deps() {
-    status "Set up precompiled macOS OBS dependencies v${1}"
-    ensure_dir "${DEPS_BUILD_DIR}"
-    step "Download..."
-    check_and_fetch "https://github.com/obsproject/obs-deps/releases/download/${1}/macos-deps-${1}-universal.tar.xz" "${2}"
-    mkdir -p obs-deps
-    step "Unpack..."
-    /usr/bin/tar -xf "./macos-deps-${1}-universal.tar.xz" -C ./obs-deps
-    /usr/bin/xattr -r -d com.apple.quarantine ./obs-deps
-}
-
-install_qt-deps() {
-    status "Set up precompiled dependency Qt v${1}"
-    ensure_dir "${DEPS_BUILD_DIR}"
-    step "Download..."
-    check_and_fetch "https://github.com/obsproject/obs-deps/releases/download/${1}/macos-deps-qt-${1}-universal.tar.xz" "${2}"
-    mkdir -p obs-deps
-    step "Unpack..."
-    /usr/bin/tar -xf "./macos-deps-qt-${1}-universal.tar.xz" -C ./obs-deps
-    /usr/bin/xattr -r -d com.apple.quarantine ./obs-deps
-}
-
-install_obs-studio() {
-    if [ "${OBS_BRANCH}" ]; then
-        CHECKOUT_REF="${OBS_BRANCH}"
-    else
-        CHECKOUT_REF="tags/${OBS_VERSION:-${CI_OBS_VERSION}}"
-    fi
-
-    ensure_dir "${OBS_BUILD_DIR}"
-
-    if [ ! -d "${OBS_BUILD_DIR}/.git" ]; then
-        /usr/bin/git clone --recursive https://github.com/obsproject/obs-studio "$(pwd)"
-        /usr/bin/git fetch origin --tags
-        /usr/bin/git checkout ${CHECKOUT_REF} -b obs-plugin-build
-    else
-        if ! /usr/bin/git show-ref --verify --quiet refs/heads/obs-plugin-build; then
-            /usr/bin/git checkout ${CHECKOUT_REF} -b obs-plugin-build
-        else
-            /usr/bin/git checkout obs-plugin-build
-        fi
-    fi
-}
-
-install_dependencies() {
-    status "Installing Homebrew dependencies"
-    trap "caught_error 'install_dependencies'" ERR
-
-    BUILD_DEPS=(
-        "obs-deps ${MACOS_DEPS_VERSION:-${CI_DEPS_VERSION}} ${MACOS_DEPS_HASH:-${CI_DEPS_HASH}}"
-        "qt-deps ${MACOS_DEPS_VERSION:-${CI_DEPS_VERSION}} ${QT_HASH:-${CI_QT_HASH}}"
-        "obs-studio ${OBS_VERSION:-${CI_OBS_VERSION}}"
-    )
-
-    install_homebrew_deps
-
-    for DEPENDENCY in "${BUILD_DEPS[@]}"; do
-        set -- ${DEPENDENCY}
-        trap "caught_error ${DEPENDENCY}" ERR
-        FUNC_NAME="install_${1}"
-        ${FUNC_NAME} ${2} ${3}
-    done
-}
-
-install-dependencies-standalone() {
-    CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
-    if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
-        source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
-    fi
-    PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
-    DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
-    OBS_BUILD_DIR="${CHECKOUT_DIR}/../obs-studio"
-    source "${CHECKOUT_DIR}/CI/include/build_support.sh"
-    source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
-
-    status "Setting up plugin build dependencies"
-    check_macos_version
-    check_archs
-    install_dependencies
-}
-
-print_usage() {
-    echo -e "Usage: ${0}\n" \
-            "-h, --help                     : Print this help\n" \
-            "-q, --quiet                    : Suppress most build process output\n" \
-            "-v, --verbose                  : Enable more verbose build process output\n" \
-            "-a, --architecture             : Specify build architecture (default: universal, alternative: x86_64, arm64)\n"
-}
-
-install-dependencies-main() {
-    if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
-        while true; do
-            case "${1}" in
-                -h | --help ) print_usage; exit 0 ;;
-                -q | --quiet ) export QUIET=TRUE; shift ;;
-                -v | --verbose ) export VERBOSE=TRUE; shift ;;
-                -a | --architecture ) ARCH="${2}"; shift 2 ;;
-                -- ) shift; break ;;
-                * ) break ;;
-            esac
-        done
-
-        install-dependencies-standalone
-    fi
-}
-
-install-dependencies-main $*

+ 0 - 79
CI/macos/02_build_obs_libs.sh

@@ -1,79 +0,0 @@
-#!/bin/bash
-
-##############################################################################
-# macOS libobs library build function
-##############################################################################
-#
-# This script file can be included in build scripts for macOS or run directly
-#
-##############################################################################
-
-# Halt on errors
-set -eE
-
-build_obs_libs() {
-    status "Build libobs and obs-frontend-api"
-    trap "caught_error 'build_obs_libs'" ERR
-
-    ensure_dir "${OBS_BUILD_DIR}"
-
-    step "Configuring OBS build system"
-    check_ccache
-    cmake -S . -B plugin_${BUILD_DIR} -G Ninja ${CMAKE_CCACHE_OPTIONS} \
-        -DCMAKE_OSX_ARCHITECTURES="${CMAKE_ARCHS}" \
-        -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-${CI_MACOSX_DEPLOYMENT_TARGET}} \
-        -DOBS_CODESIGN_LINKER=${CODESIGN_LINKER:-OFF} \
-        -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} \
-        -DENABLE_PLUGINS=OFF \
-        -DENABLE_UI=ON \
-        -DENABLE_SCRIPTING=OFF \
-        -DCMAKE_PREFIX_PATH="${DEPS_BUILD_DIR}/obs-deps" \
-        ${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR}
-
-    step "Building libobs and obs-frontend-api"
-    cmake --build plugin_${BUILD_DIR} -t obs-frontend-api
-}
-
-build-obs-libs-standalone() {
-    CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
-    if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
-        source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
-    fi
-    PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
-    OBS_BUILD_DIR="${CHECKOUT_DIR}/../obs-studio"
-    source "${CHECKOUT_DIR}/CI/include/build_support.sh"
-    source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
-
-    check_macos_version
-    check_archs
-    build_obs_libs
-}
-
-print_usage() {
-    echo -e "Usage: ${0}\n" \
-            "-h, --help                     : Print this help\n" \
-            "-q, --quiet                    : Suppress most build process output\n" \
-            "-v, --verbose                  : Enable more verbose build process output\n" \
-            "-a, --architecture             : Specify build architecture (default: universal, alternative: x86_64, arm64)\n" \
-            "--build-dir                    : Specify alternative build directory (default: build)\n"
-}
-
-build-obs-libs-main() {
-    if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
-        while true; do
-            case "${1}" in
-                -h | --help ) print_usage; exit 0 ;;
-                -q | --quiet ) export QUIET=TRUE; shift ;;
-                -v | --verbose ) export VERBOSE=TRUE; shift ;;
-                -a | --architecture ) ARCH="${2}"; shift 2 ;;
-                --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
-                -- ) shift; break ;;
-                * ) break ;;
-            esac
-        done
-
-        build-obs-libs-standalone
-    fi
-}
-
-build-obs-libs-main $*

+ 0 - 85
CI/macos/03_build_plugin.sh

@@ -1,85 +0,0 @@
-#!/bin/bash
-
-##############################################################################
-# macOS libobs plugin build function
-##############################################################################
-#
-# This script file can be included in build scripts for macOS or run directly
-#
-##############################################################################
-
-# Halt on errors
-set -eE
-
-build_obs_plugin() {
-    status "Build plugin ${PRODUCT_NAME}"
-    trap "caught_error 'builds_obs_plugin'" ERR
-
-    if [ "${CODESIGN}" ]; then
-        read_codesign_ident
-    fi
-
-    ensure_dir "${CHECKOUT_DIR}"
-    step "Configuring OBS plugin build system"
-    check_ccache
-
-    cmake -S . -B ${BUILD_DIR} -G Ninja ${CMAKE_CCACHE_OPTIONS} \
-        -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-${CI_MACOSX_DEPLOYMENT_TARGET}} \
-        -DCMAKE_OSX_ARCHITECTURES="${CMAKE_ARCHS}" \
-        -DOBS_CODESIGN_LINKER=${CODESIGN_LINKER:-OFF} \
-        -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} \
-        -DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}" \
-        -DCMAKE_PREFIX_PATH="${DEPS_BUILD_DIR}/obs-deps" \
-        ${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR}
-
-    step "Building OBS plugin"
-    cmake --build ${BUILD_DIR}
-
-}
-
-build-plugin-standalone() {
-    CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
-    if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
-        source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
-    fi
-    PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
-    DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
-    source "${CHECKOUT_DIR}/CI/include/build_support.sh"
-    source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
-
-    check_macos_version
-    check_archs
-
-    build_obs_plugin
-}
-
-print_usage() {
-    echo -e "Usage: ${0}\n" \
-            "-h, --help                     : Print this help\n" \
-            "-q, --quiet                    : Suppress most build process output\n" \
-            "-v, --verbose                  : Enable more verbose build process output\n" \
-            "-a, --architecture             : Specify build architecture (default: x86_64, alternative: arm64)\n" \
-            "-c, --codesign                 : Codesign OBS and all libraries (default: ad-hoc only)\n" \
-            "--build-dir                    : Specify alternative build directory (default: build)\n"
-}
-
-build-plugin-main() {
-    if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
-        while true; do
-            case "${1}" in
-                -h | --help ) print_usage; exit 0 ;;
-                -q | --quiet ) export QUIET=TRUE; shift ;;
-                -v | --verbose ) export VERBOSE=TRUE; shift ;;
-                -c | --codesign ) CODESIGN=TRUE; shift ;;
-                -a | --architecture ) ARCH="${2}"; shift 2 ;;
-                --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
-                -- ) shift; break ;;
-                * ) break ;;
-            esac
-        done
-
-        build-plugin-standalone
-    fi
-}
-
-build-plugin-main $*

+ 0 - 150
CI/macos/04_package_plugin.sh

@@ -1,150 +0,0 @@
-#!/bin/bash
-
-##############################################################################
-# macOS libobs plugin package function
-##############################################################################
-#
-# This script file can be included in build scripts for macOS or run directly
-#
-##############################################################################
-
-# Halt on errors
-set -eE
-
-package_obs_plugin() {
-    if [ "${CODESIGN}" ]; then
-        read_codesign_ident
-    fi
-
-    status "Package OBS plugin ${PRODUCT_NAME}"
-    trap "caught_error 'package_obs_plugin'" ERR
-
-    ensure_dir "${CHECKOUT_DIR}"
-
-    if [ -d "${BUILD_DIR}/rundir/${PRODUCT_NAME}.plugin" ]; then
-        rm -rf "${BUILD_DIR}/rundir/${PRODUCT_NAME}.plugin"
-    fi
-
-    cmake --install ${BUILD_DIR}
-
-    if ! type packagesbuild &>/dev/null; then
-        status "Setting up dependency Packages.app"
-        step "Download..."
-        check_and_fetch "http://s.sudre.free.fr/Software/files/Packages.dmg" "70ac111417728c17b1f27d5520afd87c33f899f12de8ace0f703e3e1c500b28e"
-
-        step "Mount disk image..."
-        hdiutil attach -noverify Packages.dmg
-
-        step "Install Packages.app"
-        PACKAGES_VOLUME=$(hdiutil info -plist | grep "/Volumes/Packages" | sed 's/<string>\/Volumes\/\([^<]*\)<\/string>/\1/' | sed -e 's/^[[:space:]]*//')
-        sudo installer -pkg "/Volumes/${PACKAGES_VOLUME}/packages/Packages.pkg" -target /
-        hdiutil detach "/Volumes/${PACKAGES_VOLUME}"
-    fi
-
-    step "Package ${PRODUCT_NAME}..."
-    packagesbuild ./bundle/installer-macOS.generated.pkgproj
-
-    step "Codesigning installer package..."
-    read_codesign_ident_installer
-
-    /usr/bin/productsign --sign "${CODESIGN_IDENT_INSTALLER}" "${BUILD_DIR}/${PRODUCT_NAME}.pkg" "${FILE_NAME}"
-}
-
-notarize_obs_plugin() {
-    status "Notarize ${PRODUCT_NAME}"
-    trap "caught_error 'notarize_obs_plugin'" ERR
-
-    if ! exists brew; then
-        error "Homebrew not found - please install homebrew (https://brew.sh)"
-        exit 1
-    fi
-
-    if ! exists xcnotary; then
-        step "Install notarization dependency 'xcnotary'"
-        brew install akeru-inc/tap/xcnotary
-    fi
-
-    ensure_dir "${CHECKOUT_DIR}"
-
-    if [ -f "${FILE_NAME}" ]; then
-        xcnotary precheck "${FILE_NAME}"
-    else
-        error "No notarization package installer ('${FILE_NAME}') found"
-        return
-    fi
-
-    if [ "$?" -eq 0 ]; then
-        read_codesign_ident_installer
-        read_codesign_pass
-
-        step "Run xcnotary with ${FILE_NAME}..."
-        xcnotary notarize "${FILE_NAME}" --developer-account "${CODESIGN_IDENT_USER}" --developer-password-keychain-item "OBS-Codesign-Password" --provider "${CODESIGN_IDENT_SHORT}"
-    fi
-}
-
-package-plugin-standalone() {
-    CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
-    ensure_dir "${CHECKOUT_DIR}"
-    if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
-        source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
-    fi
-    PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
-    source "${CHECKOUT_DIR}/CI/include/build_support.sh"
-    source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"
-
-    GIT_BRANCH=$(/usr/bin/git rev-parse --abbrev-ref HEAD)
-    GIT_HASH=$(/usr/bin/git rev-parse --short HEAD)
-    GIT_TAG=$(/usr/bin/git describe --tags --abbrev=0 2&>/dev/null || true)
-
-    check_macos_version
-    check_archs
-
-    if [ "${ARCH}" = "arm64" ]; then
-        FILE_NAME="${PRODUCT_NAME}-${GIT_TAG:-${PRODUCT_VERSION}}-${GIT_HASH}-macOS-Apple.pkg"
-    elif [ "${ARCH}" = "x86_64" ]; then
-        FILE_NAME="${PRODUCT_NAME}-${GIT_TAG:-${PRODUCT_VERSION}}-${GIT_HASH}-macOS-Intel.pkg"
-    else
-        FILE_NAME="${PRODUCT_NAME}-${GIT_TAG:-${PRODUCT_VERSION}}-${GIT_HASH}-macOS-Universal.pkg"
-    fi
-
-    check_curl
-    package_obs_plugin
-
-    if [ "${NOTARIZE}" ]; then
-        notarize_obs_plugin
-    fi
-}
-
-print_usage() {
-    echo -e "Usage: ${0}\n" \
-            "-h, --help                     : Print this help\n" \
-            "-q, --quiet                    : Suppress most build process output\n" \
-            "-v, --verbose                  : Enable more verbose build process output\n" \
-            "-a, --architecture             : Specify build architecture (default: x86_64, alternative: arm64)\n" \
-            "-c, --codesign                 : Codesign OBS and all libraries (default: ad-hoc only)\n" \
-            "-n, --notarize                 : Notarize OBS (default: off)\n" \
-            "--build-dir                    : Specify alternative build directory (default: build)\n"
-}
-
-package-plugin-main() {
-    if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
-        while true; do
-            case "${1}" in
-                -h | --help ) print_usage; exit 0 ;;
-                -q | --quiet ) export QUIET=TRUE; shift ;;
-                -v | --verbose ) export VERBOSE=TRUE; shift ;;
-                -a | --architecture ) ARCH="${2}"; shift 2 ;;
-                -c | --codesign ) CODESIGN=TRUE; shift ;;
-                -n | --notarize ) NOTARIZE=TRUE; CODESIGN=TRUE; shift ;;
-                -s | --standalone ) STANDALONE=TRUE; shift ;;
-                --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
-                -- ) shift; break ;;
-                * ) break ;;
-            esac
-        done
-
-        package-plugin-standalone
-    fi
-}
-
-package-plugin-main $*