Try fix build

This commit is contained in:
Exeldro 2024-06-13 12:04:29 +02:00
parent 8ce2bd22d0
commit 87f68f522f
7 changed files with 587 additions and 587 deletions

View File

@ -1,246 +1,246 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
builtin emulate -L zsh builtin emulate -L zsh
setopt EXTENDED_GLOB setopt EXTENDED_GLOB
setopt PUSHD_SILENT setopt PUSHD_SILENT
setopt ERR_EXIT setopt ERR_EXIT
setopt ERR_RETURN setopt ERR_RETURN
setopt NO_UNSET setopt NO_UNSET
setopt PIPE_FAIL setopt PIPE_FAIL
setopt NO_AUTO_PUSHD setopt NO_AUTO_PUSHD
setopt NO_PUSHD_IGNORE_DUPS setopt NO_PUSHD_IGNORE_DUPS
setopt FUNCTION_ARGZERO setopt FUNCTION_ARGZERO
## Enable for script debugging ## Enable for script debugging
# setopt WARN_CREATE_GLOBAL # setopt WARN_CREATE_GLOBAL
# setopt WARN_NESTED_VAR # setopt WARN_NESTED_VAR
# setopt XTRACE # setopt XTRACE
autoload -Uz is-at-least && if ! is-at-least 5.2; then autoload -Uz is-at-least && if ! is-at-least 5.2; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." print -u2 -PR "%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 exit 1
fi fi
_trap_error() { _trap_error() {
print -u2 -PR '%F{1} ✖︎ script execution error%f' print -u2 -PR '%F{1} ✖︎ script execution error%f'
print -PR -e " print -PR -e "
Callstack: Callstack:
${(j:\n :)funcfiletrace} ${(j:\n :)funcfiletrace}
" "
exit 2 exit 2
} }
build() { build() {
if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h}
local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]} local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]}
local target="${host_os}-${CPUTYPE}" local target="${host_os}-${CPUTYPE}"
local project_root=${SCRIPT_HOME:A:h:h} local project_root=${SCRIPT_HOME:A:h:h}
local buildspec_file="${project_root}/buildspec.json" local buildspec_file="${project_root}/buildspec.json"
trap '_trap_error' ZERR trap '_trap_error' ZERR
fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath})
autoload -Uz log_info log_error log_output set_loglevel check_${host_os} setup_${host_os} setup_obs setup_ccache autoload -Uz log_info log_error log_output set_loglevel check_${host_os} setup_${host_os} setup_obs setup_ccache
if [[ ! -r ${buildspec_file} ]] { if [[ ! -r ${buildspec_file} ]] {
log_error \ log_error \
'No buildspec.json found. Please create a build specification for your project.' \ '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.' 'A buildspec.json.template file is provided in the repository to get you started.'
return 2 return 2
} }
typeset -g -a skips=() typeset -g -a skips=()
local -i _verbosity=1 local -i _verbosity=1
local -r _version='1.0.0' local -r _version='1.0.0'
local -r -a _valid_targets=( local -r -a _valid_targets=(
macos-x86_64 macos-x86_64
macos-arm64 macos-arm64
macos-universal macos-universal
linux-x86_64 linux-x86_64
) )
local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
if [[ ${host_os} == 'macos' ]] { if [[ ${host_os} == 'macos' ]] {
local -r -a _valid_generators=(Xcode Ninja 'Unix Makefiles') local -r -a _valid_generators=(Xcode Ninja 'Unix Makefiles')
local generator="${${CI:+Ninja}:-Xcode}" local generator="${${CI:+Ninja}:-Xcode}"
} else { } else {
local -r -a _valid_generators=(Ninja 'Unix Makefiles') local -r -a _valid_generators=(Ninja 'Unix Makefiles')
local generator='Ninja' local generator='Ninja'
} }
local -r _usage=" local -r _usage="
Usage: %B${functrace[1]%:*}%b <option> [<options>] Usage: %B${functrace[1]%:*}%b <option> [<options>]
%BOptions%b: %BOptions%b:
%F{yellow} Build configuration options%f %F{yellow} Build configuration options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-t | --target%b Specify target - default: %B%F{green}${host_os}-${CPUTYPE}%f%b %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-c | --config%b Build configuration - default: %B%F{green}RelWithDebInfo%f%b
%B-s | --codesign%b Enable codesigning (macOS only) %B-s | --codesign%b Enable codesigning (macOS only)
%B--generator%b Specify build system to generate - default: %B%F{green}Ninja%f%b %B--generator%b Specify build system to generate - default: %B%F{green}Ninja%f%b
Available generators: Available generators:
- Ninja - Ninja
- Unix Makefiles - Unix Makefiles
- Xcode (macOS only) - Xcode (macOS only)
%F{yellow} Output options%f %F{yellow} Output options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-q | --quiet%b Quiet (error output only) %B-q | --quiet%b Quiet (error output only)
%B-v | --verbose%b Verbose (more detailed output) %B-v | --verbose%b Verbose (more detailed output)
%B--skip-[all|build|deps|unpack]%b Skip all|building OBS|checking for dependencies|unpacking dependencies %B--skip-[all|build|deps|unpack]%b Skip all|building OBS|checking for dependencies|unpacking dependencies
%B--debug%b Debug (very detailed and added output) %B--debug%b Debug (very detailed and added output)
%F{yellow} General options%f %F{yellow} General options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-h | --help%b Print this usage help %B-h | --help%b Print this usage help
%B-V | --version%b Print script version information" %B-V | --version%b Print script version information"
local -a args local -a args
while (( # )) { while (( # )) {
case ${1} { case ${1} {
-t|--target|-c|--config|--generator) -t|--target|-c|--config|--generator)
if (( # == 1 )) || [[ ${2:0:1} == '-' ]] { if (( # == 1 )) || [[ ${2:0:1} == '-' ]] {
log_error "Missing value for option %B${1}%b" log_error "Missing value for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
;; ;;
} }
case ${1} { case ${1} {
--) --)
shift shift
args+=($@) args+=($@)
break break
;; ;;
-t|--target) -t|--target)
if (( ! ${_valid_targets[(Ie)${2}]} )) { if (( ! ${_valid_targets[(Ie)${2}]} )) {
log_error "Invalid value %B${2}%b for option %B${1}%b" log_error "Invalid value %B${2}%b for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
target=${2} target=${2}
shift 2 shift 2
;; ;;
-c|--config) -c|--config)
if (( ! ${_valid_configs[(Ie)${2}]} )) { if (( ! ${_valid_configs[(Ie)${2}]} )) {
log_error "Invalid value %B${2}%b for option %B${1}%b" log_error "Invalid value %B${2}%b for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
BUILD_CONFIG=${2} BUILD_CONFIG=${2}
shift 2 shift 2
;; ;;
-s|--codesign) CODESIGN=1; shift ;; -s|--codesign) CODESIGN=1; shift ;;
-q|--quiet) (( _verbosity -= 1 )) || true; shift ;; -q|--quiet) (( _verbosity -= 1 )) || true; shift ;;
-v|--verbose) (( _verbosity += 1 )); shift ;; -v|--verbose) (( _verbosity += 1 )); shift ;;
-h|--help) log_output ${_usage}; exit 0 ;; -h|--help) log_output ${_usage}; exit 0 ;;
-V|--version) print -Pr "${_version}"; exit 0 ;; -V|--version) print -Pr "${_version}"; exit 0 ;;
--debug) _verbosity=3; shift ;; --debug) _verbosity=3; shift ;;
--generator) --generator)
if (( ! ${_valid_generators[(Ie)${2}]} )) { if (( ! ${_valid_generators[(Ie)${2}]} )) {
log_error "Invalid value %B${2}%b for option %B${1}%b" log_error "Invalid value %B${2}%b for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
generator=${2} generator=${2}
shift 2 shift 2
;; ;;
--skip-*) --skip-*)
local _skip="${${(s:-:)1}[-1]}" local _skip="${${(s:-:)1}[-1]}"
local _check=(all deps unpack build) local _check=(all deps unpack build)
(( ${_check[(Ie)${_skip}]} )) || log_warning "Invalid skip mode %B${_skip}%b supplied" (( ${_check[(Ie)${_skip}]} )) || log_warning "Invalid skip mode %B${_skip}%b supplied"
typeset -g -a skips=(${skips} ${_skip}) typeset -g -a skips=(${skips} ${_skip})
shift shift
;; ;;
*) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;; *) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;;
} }
} }
set -- ${(@)args} set -- ${(@)args}
set_loglevel ${_verbosity} set_loglevel ${_verbosity}
check_${host_os} check_${host_os}
setup_ccache setup_ccache
typeset -g QT_VERSION typeset -g QT_VERSION
typeset -g DEPLOYMENT_TARGET typeset -g DEPLOYMENT_TARGET
typeset -g OBS_DEPS_VERSION typeset -g OBS_DEPS_VERSION
setup_${host_os} setup_${host_os}
local product_name local product_name
local product_version local product_version
read -r product_name product_version <<< \ read -r product_name product_version <<< \
"$(jq -r '. | {name, version} | join(" ")' ${buildspec_file})" "$(jq -r '. | {name, version} | join(" ")' ${buildspec_file})"
case ${host_os} { case ${host_os} {
macos) macos)
sed -i '' \ sed -i '' \
"s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/" \ "s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/" \
"${project_root}/CMakeLists.txt" "${project_root}/CMakeLists.txt"
;; ;;
linux) linux)
sed -i'' \ sed -i'' \
"s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/"\ "s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/"\
"${project_root}/CMakeLists.txt" "${project_root}/CMakeLists.txt"
;; ;;
} }
setup_obs setup_obs
pushd ${project_root} pushd ${project_root}
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)build]}) )) { if (( ! (${skips[(Ie)all]} + ${skips[(Ie)build]}) )) {
log_info "Configuring ${product_name}..." log_info "Configuring ${product_name}..."
local _plugin_deps="${project_root:h}/obs-build-dependencies/plugin-deps-${OBS_DEPS_VERSION}-qt${QT_VERSION}-${target##*-}" local _plugin_deps="${project_root:h}/obs-build-dependencies/plugin-deps-${OBS_DEPS_VERSION}-qt${QT_VERSION}-${target##*-}"
local -a cmake_args=( local -a cmake_args=(
-DCMAKE_BUILD_TYPE=${BUILD_CONFIG:-RelWithDebInfo} -DCMAKE_BUILD_TYPE=${BUILD_CONFIG:-RelWithDebInfo}
-DQT_VERSION=${QT_VERSION} -DQT_VERSION=${QT_VERSION}
-DCMAKE_PREFIX_PATH="${_plugin_deps}" -DCMAKE_PREFIX_PATH="${_plugin_deps}"
) )
if (( _loglevel == 0 )) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR) if (( _loglevel == 0 )) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR)
if (( _loglevel > 2 )) cmake_args+=(--debug-output) if (( _loglevel > 2 )) cmake_args+=(--debug-output)
local num_procs local num_procs
case ${target} { case ${target} {
macos-*) macos-*)
autoload -Uz read_codesign autoload -Uz read_codesign
if (( ${+CODESIGN} )) { if (( ${+CODESIGN} )) {
read_codesign read_codesign
} }
cmake_args+=( cmake_args+=(
-DCMAKE_FRAMEWORK_PATH="${_plugin_deps}/Frameworks" -DCMAKE_FRAMEWORK_PATH="${_plugin_deps}/Frameworks"
-DCMAKE_OSX_ARCHITECTURES=${${target##*-}//universal/x86_64;arm64} -DCMAKE_OSX_ARCHITECTURES=${${target##*-}//universal/x86_64;arm64}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET:-10.15} -DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET:-10.15}
-DOBS_CODESIGN_LINKER=ON -DOBS_CODESIGN_LINKER=ON
-DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}" -DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}"
) )
num_procs=$(( $(sysctl -n hw.ncpu) + 1 )) num_procs=$(( $(sysctl -n hw.ncpu) + 1 ))
;; ;;
linux-*) linux-*)
if (( ${+CI} )) { if (( ${+CI} )) {
cmake_args+=(-DCMAKE_INSTALL_PREFIX=/usr) cmake_args+=(-DCMAKE_INSTALL_PREFIX=/usr)
} }
num_procs=$(( $(nproc) + 1 )) num_procs=$(( $(nproc) + 1 ))
;; ;;
} }
log_debug "Attempting to configure ${product_name} with CMake arguments: ${cmake_args}" log_debug "Attempting to configure ${product_name} with CMake arguments: ${cmake_args}"
cmake -S . -B build_${target##*-} -G ${generator} ${cmake_args} cmake -S . -B build_${target##*-} -G ${generator} ${cmake_args}
log_info "Building ${product_name}..." log_info "Building ${product_name}..."
local -a cmake_args=() local -a cmake_args=()
if (( _loglevel > 1 )) cmake_args+=(--verbose) if (( _loglevel > 1 )) cmake_args+=(--verbose)
if [[ ${generator} == 'Unix Makefiles' ]] cmake_args+=(--parallel ${num_procs}) if [[ ${generator} == 'Unix Makefiles' ]] cmake_args+=(--parallel ${num_procs})
cmake --build build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} ${cmake_args} cmake --build build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} ${cmake_args}
} }
log_info "Installing ${product_name}..." log_info "Installing ${product_name}..."
local -a cmake_args=() local -a cmake_args=()
if (( _loglevel > 1 )) cmake_args+=(--verbose) if (( _loglevel > 1 )) cmake_args+=(--verbose)
cmake --install build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} --prefix "${project_root}/release" ${cmake_args} cmake --install build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} --prefix "${project_root}/release" ${cmake_args}
popd popd
} }
build ${@} build ${@}

View File

@ -1,192 +1,192 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
builtin emulate -L zsh builtin emulate -L zsh
setopt EXTENDED_GLOB setopt EXTENDED_GLOB
setopt PUSHD_SILENT setopt PUSHD_SILENT
setopt ERR_EXIT setopt ERR_EXIT
setopt ERR_RETURN setopt ERR_RETURN
setopt NO_UNSET setopt NO_UNSET
setopt PIPE_FAIL setopt PIPE_FAIL
setopt NO_AUTO_PUSHD setopt NO_AUTO_PUSHD
setopt NO_PUSHD_IGNORE_DUPS setopt NO_PUSHD_IGNORE_DUPS
setopt FUNCTION_ARGZERO setopt FUNCTION_ARGZERO
## Enable for script debugging ## Enable for script debugging
# setopt WARN_CREATE_GLOBAL # setopt WARN_CREATE_GLOBAL
# setopt WARN_NESTED_VAR # setopt WARN_NESTED_VAR
# setopt XTRACE # setopt XTRACE
autoload -Uz is-at-least && if ! is-at-least 5.2; then autoload -Uz is-at-least && if ! is-at-least 5.2; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." print -u2 -PR "%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 exit 1
fi fi
_trap_error() { _trap_error() {
print -u2 -PR '%F{1} ✖︎ script execution error%f' print -u2 -PR '%F{1} ✖︎ script execution error%f'
print -PR -e " print -PR -e "
Callstack: Callstack:
${(j:\n :)funcfiletrace} ${(j:\n :)funcfiletrace}
" "
exit 2 exit 2
} }
package() { package() {
if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h}
local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]} local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]}
local target="${host_os}-${CPUTYPE}" local target="${host_os}-${CPUTYPE}"
local project_root=${SCRIPT_HOME:A:h:h} local project_root=${SCRIPT_HOME:A:h:h}
local buildspec_file="${project_root}/buildspec.json" local buildspec_file="${project_root}/buildspec.json"
trap '_trap_error' ZERR trap '_trap_error' ZERR
fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath})
autoload -Uz set_loglevel log_info log_error log_output check_${host_os} autoload -Uz set_loglevel log_info log_error log_output check_${host_os}
local -i _verbosity=1 local -i _verbosity=1
local -r _version='1.0.0' local -r _version='1.0.0'
local -r -a _valid_targets=( local -r -a _valid_targets=(
macos-x86_64 macos-x86_64
macos-arm64 macos-arm64
macos-universal macos-universal
linux-x86_64 linux-x86_64
) )
local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
local -r _usage=" local -r _usage="
Usage: %B${functrace[1]%:*}%b <option> [<options>] Usage: %B${functrace[1]%:*}%b <option> [<options>]
%BOptions%b: %BOptions%b:
%F{yellow} Package configuration options%f %F{yellow} Package configuration options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-t | --target%b Specify target - default: %B%F{green}${host_os}-${CPUTYPE}%f%b %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-c | --config%b Build configuration - default: %B%F{green}RelWithDebInfo%f%b
%B-s | --codesign%b Enable codesigning (macOS only) %B-s | --codesign%b Enable codesigning (macOS only)
%B-n | --notarize%b Enable notarization (macOS only) %B-n | --notarize%b Enable notarization (macOS only)
%F{yellow} Output options%f %F{yellow} Output options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-q | --quiet%b Quiet (error output only) %B-q | --quiet%b Quiet (error output only)
%B-v | --verbose%b Verbose (more detailed output) %B-v | --verbose%b Verbose (more detailed output)
%B--debug%b Debug (very detailed and added output) %B--debug%b Debug (very detailed and added output)
%F{yellow} General options%f %F{yellow} General options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-h | --help%b Print this usage help %B-h | --help%b Print this usage help
%B-V | --version%b Print script version information" %B-V | --version%b Print script version information"
local -a args local -a args
while (( # )) { while (( # )) {
case ${1} { case ${1} {
-t|--target|-c|--config) -t|--target|-c|--config)
if (( # == 1 )) || [[ ${2:0:1} == '-' ]] { if (( # == 1 )) || [[ ${2:0:1} == '-' ]] {
log_error "Missing value for option %B${1}%b" log_error "Missing value for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
;; ;;
} }
case ${1} { case ${1} {
--) --)
shift shift
args+=($@) args+=($@)
break break
;; ;;
-t|--target) -t|--target)
if (( ! ${_valid_targets[(Ie)${2}]} )) { if (( ! ${_valid_targets[(Ie)${2}]} )) {
log_error "Invalid value %B${2}%b for option %B${1}%b" log_error "Invalid value %B${2}%b for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
target=${2} target=${2}
shift 2 shift 2
;; ;;
-c|--config) -c|--config)
if (( ! ${_valid_configs[(Ie)${2}]} )) { if (( ! ${_valid_configs[(Ie)${2}]} )) {
log_error "Invalid value %B${2}%b for option %B${1}%b" log_error "Invalid value %B${2}%b for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
BUILD_CONFIG=${2} BUILD_CONFIG=${2}
shift 2 shift 2
;; ;;
-s|--codesign) typeset -g CODESIGN=1; shift ;; -s|--codesign) typeset -g CODESIGN=1; shift ;;
-n|--notarize) typeset -g NOTARIZE=1; typeset -g CODESIGN=1; shift ;; -n|--notarize) typeset -g NOTARIZE=1; typeset -g CODESIGN=1; shift ;;
-q|--quiet) (( _verbosity -= 1 )) || true; shift ;; -q|--quiet) (( _verbosity -= 1 )) || true; shift ;;
-v|--verbose) (( _verbosity += 1 )); shift ;; -v|--verbose) (( _verbosity += 1 )); shift ;;
-h|--help) log_output ${_usage}; exit 0 ;; -h|--help) log_output ${_usage}; exit 0 ;;
-V|--version) print -Pr "${_version}"; exit 0 ;; -V|--version) print -Pr "${_version}"; exit 0 ;;
--debug) _verbosity=3; shift ;; --debug) _verbosity=3; shift ;;
*) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;; *) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;;
} }
} }
set -- ${(@)args} set -- ${(@)args}
set_loglevel ${_verbosity} set_loglevel ${_verbosity}
check_${host_os} check_${host_os}
local product_name local product_name
local product_version local product_version
read -r product_name product_version <<< \ read -r product_name product_version <<< \
"$(jq -r '. | {name, version} | join(" ")' ${project_root}/buildspec.json)" "$(jq -r '. | {name, version} | join(" ")' ${project_root}/buildspec.json)"
if [[ ${host_os} == 'macos' ]] { if [[ ${host_os} == 'macos' ]] {
autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass
local output_name="${product_name}-${product_version}-${host_os}-${target##*-}.pkg" local output_name="${product_name}-${product_version}-${host_os}-${target##*-}.pkg"
if [[ ! -d ${project_root}/release/${product_name}.plugin ]] { if [[ ! -d ${project_root}/release/${product_name}.plugin ]] {
log_error 'No release artifact found. Run the build script or the CMake install procedure first.' log_error 'No release artifact found. Run the build script or the CMake install procedure first.'
return 2 return 2
} }
if [[ ! -f ${project_root}/build_${target##*-}/installer-macos.generated.pkgproj ]] { 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.' log_error 'Packages project file not found. Run the build script or the CMake build and install procedures first.'
return 2 return 2
} }
check_packages check_packages
log_info "Packaging ${product_name}..." log_info "Packaging ${product_name}..."
pushd ${project_root} pushd ${project_root}
packagesbuild \ packagesbuild \
--build-folder ${project_root}/release \ --build-folder ${project_root}/release \
${project_root}/build_${target##*-}/installer-macos.generated.pkgproj ${project_root}/build_${target##*-}/installer-macos.generated.pkgproj
if (( ${+CODESIGN} )) { if (( ${+CODESIGN} )) {
read_codesign_installer read_codesign_installer
productsign \ productsign \
--sign "${CODESIGN_IDENT_INSTALLER}" \ --sign "${CODESIGN_IDENT_INSTALLER}" \
"${project_root}/release/${product_name}.pkg" \ "${project_root}/release/${product_name}.pkg" \
"${project_root}/release/${output_name}" "${project_root}/release/${output_name}"
rm "${project_root}/release/${product_name}.pkg" rm "${project_root}/release/${product_name}.pkg"
} else { } else {
mv "${project_root}/release/${product_name}.pkg" \ mv "${project_root}/release/${product_name}.pkg" \
"${project_root}/release/${output_name}" "${project_root}/release/${output_name}"
} }
if (( ${+CODESIGN} && ${+NOTARIZE} )) { if (( ${+CODESIGN} && ${+NOTARIZE} )) {
if [[ ! -f "${project_root}/release/${output_name}" ]] { if [[ ! -f "${project_root}/release/${output_name}" ]] {
log_error "No package for notarization found." log_error "No package for notarization found."
return 2 return 2
} }
read_codesign_installer read_codesign_installer
read_codesign_pass read_codesign_pass
xcrun notarytool submit "${project_root}/release/${output_name}" \ xcrun notarytool submit "${project_root}/release/${output_name}" \
--keychain-profile "OBS-Codesign-Password" --wait --keychain-profile "OBS-Codesign-Password" --wait
xcrun stapler staple "${project_root}/release/${output_name}" xcrun stapler staple "${project_root}/release/${output_name}"
} }
popd popd
} elif [[ ${host_os} == 'linux' ]] { } elif [[ ${host_os} == 'linux' ]] {
local -a cmake_args=() local -a cmake_args=()
if (( _loglevel > 1 )) cmake_args+=(--verbose) if (( _loglevel > 1 )) cmake_args+=(--verbose)
pushd ${project_root} pushd ${project_root}
cmake --build build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} -t package ${cmake_args} cmake --build build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} -t package ${cmake_args}
popd popd
} }
} }
package ${@} package ${@}

View File

@ -1,13 +1,13 @@
#!/bin/sh #!/bin/sh
if ! type zsh > /dev/null 2>&1; then if ! type zsh > /dev/null 2>&1; then
echo ' => Installing script dependency Zsh.' echo ' => Installing script dependency Zsh.'
sudo apt-get -y update sudo apt-get -y update
sudo apt-get -y install zsh sudo apt-get -y install zsh
fi fi
SCRIPT=$(readlink -f "${0}") SCRIPT=$(readlink -f "${0}")
SCRIPT_DIR=$(dirname "${SCRIPT}") SCRIPT_DIR=$(dirname "${SCRIPT}")
zsh ${SCRIPT_DIR}/build-linux.zsh "${@}" zsh ${SCRIPT_DIR}/build-linux.zsh "${@}"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
dirty=$(git ls-files --modified) dirty=$(git ls-files --modified)
set +x set +x
if [[ $dirty ]]; then if [[ $dirty ]]; then
echo "=================================" echo "================================="
echo "Files were not formatted properly" echo "Files were not formatted properly"
echo "$dirty" echo "$dirty"
echo "=================================" echo "================================="
exit 1 exit 1
fi fi

View File

@ -1,53 +1,53 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit set -o errexit
set -o pipefail set -o pipefail
if [ ${#} -eq 1 -a "${1}" = "VERBOSE" ]; then if [ ${#} -eq 1 -a "${1}" = "VERBOSE" ]; then
VERBOSITY="-l debug" VERBOSITY="-l debug"
else else
VERBOSITY="" VERBOSITY=""
fi fi
if [ "${CI}" ]; then if [ "${CI}" ]; then
MODE="--check" MODE="--check"
else else
MODE="-i" MODE="-i"
fi fi
# Runs the formatter in parallel on the code base. # Runs the formatter in parallel on the code base.
# Return codes: # Return codes:
# - 1 there are files to be formatted # - 1 there are files to be formatted
# - 0 everything looks fine # - 0 everything looks fine
# Get CPU count # Get CPU count
OS=$(uname) OS=$(uname)
NPROC=1 NPROC=1
if [[ ${OS} = "Linux" ]] ; then if [[ ${OS} = "Linux" ]] ; then
NPROC=$(nproc) NPROC=$(nproc)
elif [[ ${OS} = "Darwin" ]] ; then elif [[ ${OS} = "Darwin" ]] ; then
NPROC=$(sysctl -n hw.physicalcpu) NPROC=$(sysctl -n hw.physicalcpu)
fi fi
# Discover clang-format # Discover clang-format
if ! type cmake-format 2> /dev/null ; then if ! type cmake-format 2> /dev/null ; then
echo "Required cmake-format not found" echo "Required cmake-format not found"
exit 1 exit 1
fi fi
find . -type d \( \ find . -type d \( \
-path ./\*build\* -o \ -path ./\*build\* -o \
-path ./release -o \ -path ./release -o \
-path ./deps/jansson -o \ -path ./deps/jansson -o \
-path ./plugins/decklink/\*/decklink-sdk -o \ -path ./plugins/decklink/\*/decklink-sdk -o \
-path ./plugins/enc-amf -o \ -path ./plugins/enc-amf -o \
-path ./plugins/mac-syphon/syphon-framework -o \ -path ./plugins/mac-syphon/syphon-framework -o \
-path ./plugins/obs-outputs/ftl-sdk -o \ -path ./plugins/obs-outputs/ftl-sdk -o \
-path ./plugins/obs-vst -o \ -path ./plugins/obs-vst -o \
-path ./plugins/obs-browser -o \ -path ./plugins/obs-browser -o \
-path ./plugins/win-dshow/libdshowcapture -o \ -path ./plugins/win-dshow/libdshowcapture -o \
-path ./plugins/obs-websocket/deps \ -path ./plugins/obs-websocket/deps \
\) -prune -false -type f -o \ \) -prune -false -type f -o \
-name 'CMakeLists.txt' -or \ -name 'CMakeLists.txt' -or \
-name '*.cmake' \ -name '*.cmake' \
| xargs -L10 -P ${NPROC} cmake-format ${MODE} ${VERBOSITY} | xargs -L10 -P ${NPROC} cmake-format ${MODE} ${VERBOSITY}

View File

@ -1,60 +1,60 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Original source https://github.com/Project-OSRM/osrm-backend/blob/master/scripts/format.sh # Original source https://github.com/Project-OSRM/osrm-backend/blob/master/scripts/format.sh
set -o errexit set -o errexit
set -o pipefail set -o pipefail
set -o nounset set -o nounset
if [ ${#} -eq 1 ]; then if [ ${#} -eq 1 ]; then
VERBOSITY="--verbose" VERBOSITY="--verbose"
else else
VERBOSITY="" VERBOSITY=""
fi fi
# Runs the Clang Formatter in parallel on the code base. # Runs the Clang Formatter in parallel on the code base.
# Return codes: # Return codes:
# - 1 there are files to be formatted # - 1 there are files to be formatted
# - 0 everything looks fine # - 0 everything looks fine
# Get CPU count # Get CPU count
OS=$(uname) OS=$(uname)
NPROC=1 NPROC=1
if [[ ${OS} = "Linux" ]] ; then if [[ ${OS} = "Linux" ]] ; then
NPROC=$(nproc) NPROC=$(nproc)
elif [[ ${OS} = "Darwin" ]] ; then elif [[ ${OS} = "Darwin" ]] ; then
NPROC=$(sysctl -n hw.physicalcpu) NPROC=$(sysctl -n hw.physicalcpu)
fi fi
# Discover clang-format # Discover clang-format
if type clang-format-13 2> /dev/null ; then if type clang-format-13 2> /dev/null ; then
CLANG_FORMAT=clang-format-13 CLANG_FORMAT=clang-format-13
elif type clang-format 2> /dev/null ; then elif type clang-format 2> /dev/null ; then
# Clang format found, but need to check version # Clang format found, but need to check version
CLANG_FORMAT=clang-format CLANG_FORMAT=clang-format
V=$(clang-format --version) V=$(clang-format --version)
if [[ $V != *"version 13.0"* ]]; then if [[ $V != *"version 13.0"* ]]; then
echo "clang-format is not 13.0 (returned ${V})" echo "clang-format is not 13.0 (returned ${V})"
exit 1 exit 1
fi fi
else else
echo "No appropriate clang-format found (expected clang-format-13.0.0, or clang-format)" echo "No appropriate clang-format found (expected clang-format-13.0.0, or clang-format)"
exit 1 exit 1
fi fi
find . -type d \( \ find . -type d \( \
-path ./\*build\* -o \ -path ./\*build\* -o \
-path ./release -o \ -path ./release -o \
-path ./cmake -o \ -path ./cmake -o \
-path ./plugins/decklink/\*/decklink-sdk -o \ -path ./plugins/decklink/\*/decklink-sdk -o \
-path ./plugins/enc-amf -o \ -path ./plugins/enc-amf -o \
-path ./plugins/mac-syphon/syphon-framework -o \ -path ./plugins/mac-syphon/syphon-framework -o \
-path ./plugins/obs-outputs/ftl-sdk -o \ -path ./plugins/obs-outputs/ftl-sdk -o \
-path ./plugins/obs-websocket/deps \ -path ./plugins/obs-websocket/deps \
\) -prune -false -type f -o \ \) -prune -false -type f -o \
-name '*.h' -or \ -name '*.h' -or \
-name '*.hpp' -or \ -name '*.hpp' -or \
-name '*.m' -or \ -name '*.m' -or \
-name '*.mm' -or \ -name '*.mm' -or \
-name '*.c' -or \ -name '*.c' -or \
-name '*.cpp' \ -name '*.cpp' \
| xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -i -style=file -fallback-style=none | xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -i -style=file -fallback-style=none

View File

@ -1,13 +1,13 @@
#!/bin/sh #!/bin/sh
if ! type zsh > /dev/null 2>&1; then if ! type zsh > /dev/null 2>&1; then
echo ' => Installing script dependency Zsh.' echo ' => Installing script dependency Zsh.'
sudo apt-get update sudo apt-get update
sudo apt-get install zsh sudo apt-get install zsh
fi fi
SCRIPT=$(readlink -f "${0}") SCRIPT=$(readlink -f "${0}")
SCRIPT_DIR=$(dirname "${SCRIPT}") SCRIPT_DIR=$(dirname "${SCRIPT}")
zsh ${SCRIPT_DIR}/package-linux.zsh "${@}" zsh ${SCRIPT_DIR}/package-linux.zsh "${@}"