|
@@ -16,27 +16,22 @@ setopt FUNCTION_ARGZERO
|
|
#setopt WARN_NESTED_VAR
|
|
#setopt WARN_NESTED_VAR
|
|
#setopt XTRACE
|
|
#setopt XTRACE
|
|
|
|
|
|
|
|
+if (( ! ${+CI} )) {
|
|
|
|
+ print -u2 -PR "%F{1} ✖︎ ${ZSH_ARGZERO:t:r} requires CI environment.%f"
|
|
|
|
+ exit 1
|
|
|
|
+}
|
|
|
|
+
|
|
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
|
|
|
|
|
|
-TRAPEXIT() {
|
|
|
|
- local return_value=$?
|
|
|
|
-
|
|
|
|
- if (( ${+CI} )) unset NSUnbufferedIO
|
|
|
|
-
|
|
|
|
- return ${return_value}
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
TRAPZERR() {
|
|
TRAPZERR() {
|
|
- if (( ${_loglevel:-3} > 2 )) {
|
|
|
|
- print -u2 -PR "${CI:+::error::}%F{1} ✖︎ script execution error%f"
|
|
|
|
- print -PR -e "
|
|
|
|
- Callstack:
|
|
|
|
- ${(j:\n :)funcfiletrace}
|
|
|
|
- "
|
|
|
|
- }
|
|
|
|
|
|
+ print -u2 -PR "::error::%F{1} ✖︎ script execution error.%f"
|
|
|
|
+ print -PR -e "
|
|
|
|
+ Callstack:
|
|
|
|
+ ${(j:\n :)funcfiletrace}
|
|
|
|
+ "
|
|
|
|
|
|
exit 2
|
|
exit 2
|
|
}
|
|
}
|
|
@@ -48,91 +43,41 @@ build() {
|
|
local buildspec_file=${project_root}/buildspec.json
|
|
local buildspec_file=${project_root}/buildspec.json
|
|
|
|
|
|
fpath=(${SCRIPT_HOME}/utils.zsh ${fpath})
|
|
fpath=(${SCRIPT_HOME}/utils.zsh ${fpath})
|
|
- autoload -Uz log_group log_info log_status log_error log_output set_loglevel check_${host_os} setup_ccache
|
|
|
|
|
|
+ autoload -Uz log_group log_error log_output check_${host_os} setup_ccache
|
|
|
|
|
|
if [[ ! -r ${buildspec_file} ]] {
|
|
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.'
|
|
|
|
|
|
+ log_error 'Missing buildspec.json in project checkout.'
|
|
return 2
|
|
return 2
|
|
}
|
|
}
|
|
|
|
|
|
- typeset -g -a skips=()
|
|
|
|
- local -i verbosity=1
|
|
|
|
- local -r _version='1.0.0'
|
|
|
|
|
|
+ local -i debug=0
|
|
|
|
+
|
|
|
|
+ local target
|
|
local -r -a _valid_targets=(
|
|
local -r -a _valid_targets=(
|
|
macos-x86_64
|
|
macos-x86_64
|
|
macos-arm64
|
|
macos-arm64
|
|
linux-x86_64
|
|
linux-x86_64
|
|
)
|
|
)
|
|
- local target
|
|
|
|
|
|
+
|
|
local config='RelWithDebInfo'
|
|
local config='RelWithDebInfo'
|
|
local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
|
|
local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
|
|
local -i codesign=0
|
|
local -i codesign=0
|
|
|
|
|
|
- if [[ ${host_os} == linux ]] {
|
|
|
|
- local -r -a _valid_generators=(Ninja 'Unix Makefiles')
|
|
|
|
- local generator='Ninja'
|
|
|
|
- local -r _usage_host="
|
|
|
|
-%F{yellow} Additional options for Linux builds%f
|
|
|
|
- -----------------------------------------------------------------------------
|
|
|
|
- %B--generator%b Specify build system to generate
|
|
|
|
- Available generators:
|
|
|
|
- - Ninja
|
|
|
|
- - Unix Makefiles"
|
|
|
|
- } elif [[ ${host_os} == macos ]] {
|
|
|
|
- local -r _usage_host="
|
|
|
|
-%F{yellow} Additional options for macOS builds%f
|
|
|
|
- -----------------------------------------------------------------------------
|
|
|
|
- %B-s | --codesign%b Enable codesigning (macOS only)"
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- local -i _print_config=0
|
|
|
|
- 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
|
|
|
|
- %B--print-config%b Print composed CMake configuration parameters
|
|
|
|
- %B--skip-[all|build|deps]%b Skip all|building OBS|checking for dependencies
|
|
|
|
-
|
|
|
|
-%F{yellow} Output options%f
|
|
|
|
- -----------------------------------------------------------------------------
|
|
|
|
- %B-q | --quiet%b Quiet (error output only)
|
|
|
|
- %B-v | --verbose%b Verbose (more detailed output)
|
|
|
|
- %B--debug%b Debug (very detailed and added output)
|
|
|
|
-
|
|
|
|
-%F{yellow} General options%f
|
|
|
|
- -----------------------------------------------------------------------------
|
|
|
|
- %B-h | --help%b Print this usage help
|
|
|
|
- %B-V | --version%b Print script version information
|
|
|
|
-${_usage_host:-}"
|
|
|
|
-
|
|
|
|
local -a args
|
|
local -a args
|
|
while (( # )) {
|
|
while (( # )) {
|
|
case ${1} {
|
|
case ${1} {
|
|
-t|--target|--generator|-c|--config)
|
|
-t|--target|--generator|-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}
|
|
|
|
exit 2
|
|
exit 2
|
|
}
|
|
}
|
|
;;
|
|
;;
|
|
}
|
|
}
|
|
case ${1} {
|
|
case ${1} {
|
|
- --)
|
|
|
|
- shift
|
|
|
|
- args+=($@)
|
|
|
|
- break
|
|
|
|
- ;;
|
|
|
|
|
|
+ --) shift; args+=($@); 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}
|
|
|
|
exit 2
|
|
exit 2
|
|
}
|
|
}
|
|
target=${2}
|
|
target=${2}
|
|
@@ -141,37 +86,13 @@ ${_usage_host:-}"
|
|
-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}
|
|
|
|
exit 2
|
|
exit 2
|
|
}
|
|
}
|
|
config=${2}
|
|
config=${2}
|
|
shift 2
|
|
shift 2
|
|
;;
|
|
;;
|
|
-s|--codesign) codesign=1; shift ;;
|
|
-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 ;;
|
|
|
|
- --debug) verbosity=3; shift ;;
|
|
|
|
- --generator)
|
|
|
|
- if [[ ${host_os} == linux ]] {
|
|
|
|
- if (( ! ${_valid_generators[(Ie)${2}]} )) {
|
|
|
|
- log_error "Invalid value %B${2}%b for option %B${1}%b"
|
|
|
|
- log_output ${_usage}
|
|
|
|
- exit 2
|
|
|
|
- }
|
|
|
|
- generator=${2}
|
|
|
|
- }
|
|
|
|
- shift 2
|
|
|
|
- ;;
|
|
|
|
- --print-config) _print_config=1; skips+=(unpack deps); shift ;;
|
|
|
|
- --skip-*)
|
|
|
|
- local _skip="${${(s:-:)1}[-1]}"
|
|
|
|
- local _check=(all deps build)
|
|
|
|
- (( ${_check[(Ie)${_skip}]} )) || log_warning "Invalid skip mode %B${_skip}%b supplied"
|
|
|
|
- skips+=(${_skip})
|
|
|
|
- shift
|
|
|
|
- ;;
|
|
|
|
|
|
+ --debug) debug=1; 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 ;;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -179,11 +100,8 @@ ${_usage_host:-}"
|
|
: "${target:="${host_os}-${CPUTYPE}"}"
|
|
: "${target:="${host_os}-${CPUTYPE}"}"
|
|
|
|
|
|
set -- ${(@)args}
|
|
set -- ${(@)args}
|
|
- set_loglevel ${verbosity}
|
|
|
|
|
|
|
|
- if (( ! (${skips[(Ie)all]} + ${skips[(Ie)deps]}) )) {
|
|
|
|
- check_${host_os}
|
|
|
|
- }
|
|
|
|
|
|
+ check_${host_os}
|
|
setup_ccache
|
|
setup_ccache
|
|
|
|
|
|
if [[ ${host_os} == linux ]] {
|
|
if [[ ${host_os} == linux ]] {
|
|
@@ -191,82 +109,39 @@ ${_usage_host:-}"
|
|
}
|
|
}
|
|
|
|
|
|
local product_name
|
|
local product_name
|
|
- read -r product_name <<< \
|
|
|
|
- "$(jq -r '.name' ${buildspec_file})"
|
|
|
|
|
|
+ read -r product_name <<< "$(jq -r '.name' ${buildspec_file})"
|
|
|
|
|
|
pushd ${project_root}
|
|
pushd ${project_root}
|
|
- if (( ! (${skips[(Ie)all]} + ${skips[(Ie)build]}) )) {
|
|
|
|
- log_group "Configuring ${product_name}..."
|
|
|
|
-
|
|
|
|
- local -a cmake_args=()
|
|
|
|
- local -a cmake_build_args=(--build)
|
|
|
|
- local -a cmake_install_args=(--install)
|
|
|
|
-
|
|
|
|
- case ${_loglevel} {
|
|
|
|
- 0) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR) ;;
|
|
|
|
- 1) ;;
|
|
|
|
- 2) cmake_build_args+=(--verbose) ;;
|
|
|
|
- *) cmake_args+=(--debug-output) ;;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- case ${target} {
|
|
|
|
- macos-*)
|
|
|
|
- cmake_args+=(
|
|
|
|
- --preset "macos${CI:+-ci}"
|
|
|
|
- -DCMAKE_OSX_ARCHITECTURES:STRING=${target##*-}
|
|
|
|
- )
|
|
|
|
|
|
|
|
- if (( ${+CI} )) typeset -gx NSUnbufferedIO=YES
|
|
|
|
|
|
+ local -a cmake_args=()
|
|
|
|
+ local -a cmake_build_args=(--build)
|
|
|
|
+ local -a cmake_install_args=(--install)
|
|
|
|
|
|
- if (( codesign )) {
|
|
|
|
- autoload -Uz read_codesign_team && read_codesign_team
|
|
|
|
|
|
+ if (( debug )) cmake_args+=(--debug-output)
|
|
|
|
|
|
- if [[ -z ${CODESIGN_TEAM} ]] {
|
|
|
|
- autoload -Uz read_codesign && read_codesign
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ case ${target} {
|
|
|
|
+ macos-*)
|
|
|
|
+ cmake_args+=(--preset 'macos-ci' -DCMAKE_OSX_ARCHITECTURES:STRING=${target##*-})
|
|
|
|
|
|
- cmake_args+=(
|
|
|
|
- -DOBS_CODESIGN_TEAM:STRING=${CODESIGN_TEAM:-}
|
|
|
|
- -DOBS_CODESIGN_IDENTITY:STRING=${CODESIGN_IDENT:--}
|
|
|
|
- )
|
|
|
|
- ;;
|
|
|
|
- linux-*)
|
|
|
|
- cmake_args+=(
|
|
|
|
- -S ${PWD} -B "build_${target##*-}"
|
|
|
|
- -G "${generator}"
|
|
|
|
- -DCMAKE_BUILD_TYPE:STRING=${config}
|
|
|
|
- -DCEF_ROOT_DIR:PATH="${project_root}/.deps/cef_binary_${CEF_VERSION}_${target//-/_}"
|
|
|
|
- )
|
|
|
|
|
|
+ typeset -gx NSUnbufferedIO=YES
|
|
|
|
|
|
- local cmake_version
|
|
|
|
- read -r _ _ cmake_version <<< "$(cmake --version)"
|
|
|
|
|
|
+ typeset -gx CODESIGN_IDENT="${CODESIGN_IDENT:--}"
|
|
|
|
+ if (( codesign )) && [[ -z ${CODESIGN_TEAM} ]] {
|
|
|
|
+ typeset -gx CODESIGN_TEAM="$(print "${CODESIGN_IDENT}" | /usr/bin/sed -En 's/.+\((.+)\)/\1/p')"
|
|
|
|
+ }
|
|
|
|
|
|
- cmake_build_args+=("build_${target##*-}" --config ${config})
|
|
|
|
|
|
+ log_group "Configuring ${product_name}..."
|
|
|
|
+ cmake -S ${project_root} ${cmake_args}
|
|
|
|
|
|
- if [[ ${generator} == 'Unix Makefiles' ]] {
|
|
|
|
- cmake_build_args+=(--parallel $(( $(nproc) + 1 )))
|
|
|
|
|
|
+ log_group "Building ${product_name}..."
|
|
|
|
+ run_xcodebuild() {
|
|
|
|
+ if (( debug )) {
|
|
|
|
+ xcodebuild ${@}
|
|
} else {
|
|
} else {
|
|
- cmake_build_args+=(--parallel)
|
|
|
|
|
|
+ xcodebuild ${@} 2>&1 | xcbeautify
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- cmake_args+=(
|
|
|
|
- -DENABLE_AJA:BOOL=OFF
|
|
|
|
- -DENABLE_WEBRTC:BOOL=OFF
|
|
|
|
- )
|
|
|
|
- if (( ! UBUNTU_2210_OR_LATER )) cmake_args+=(-DENABLE_NEW_MPEGTS_OUTPUT:BOOL=OFF)
|
|
|
|
-
|
|
|
|
- cmake_install_args+=(build_${target##*-} --prefix ${project_root}/build_${target##*-}/install/${config})
|
|
|
|
- ;;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (( _print_config )) { log_output "CMake configuration: ${cmake_args}"; exit 0 }
|
|
|
|
-
|
|
|
|
- log_debug "Attempting to configure with CMake arguments: ${cmake_args}"
|
|
|
|
- cmake -S ${project_root} ${cmake_args}
|
|
|
|
-
|
|
|
|
- log_group "Building ${product_name}..."
|
|
|
|
- if [[ ${host_os} == macos ]] {
|
|
|
|
local -a build_args=(
|
|
local -a build_args=(
|
|
ONLY_ACTIVE_ARCH=NO
|
|
ONLY_ACTIVE_ARCH=NO
|
|
-project obs-studio.xcodeproj
|
|
-project obs-studio.xcodeproj
|
|
@@ -296,9 +171,8 @@ ${_usage_host:-}"
|
|
-exportPath ${project_root}/build_macos
|
|
-exportPath ${project_root}/build_macos
|
|
)
|
|
)
|
|
|
|
|
|
- autoload -Uz run_xcodebuild
|
|
|
|
pushd build_macos
|
|
pushd build_macos
|
|
- if (( ${+CI} )) && [[ ${GITHUB_EVENT_NAME} == push && ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]] {
|
|
|
|
|
|
+ if [[ ${GITHUB_EVENT_NAME} == push && ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]] {
|
|
run_xcodebuild ${archive_args}
|
|
run_xcodebuild ${archive_args}
|
|
run_xcodebuild ${export_args}
|
|
run_xcodebuild ${export_args}
|
|
} else {
|
|
} else {
|
|
@@ -309,16 +183,35 @@ ${_usage_host:-}"
|
|
ditto UI/${config}/OBS.app OBS.app
|
|
ditto UI/${config}/OBS.app OBS.app
|
|
}
|
|
}
|
|
popd
|
|
popd
|
|
- } else {
|
|
|
|
|
|
+ ;;
|
|
|
|
+ linux-*)
|
|
|
|
+ cmake_args+=(
|
|
|
|
+ -S ${PWD} -B build_${target##*-}
|
|
|
|
+ -G Ninja
|
|
|
|
+ -DCMAKE_BUILD_TYPE:STRING=${config}
|
|
|
|
+ -DCEF_ROOT_DIR:PATH="${project_root}/.deps/cef_binary_${CEF_VERSION}_${target//-/_}"
|
|
|
|
+ -DENABLE_AJA:BOOL=OFF
|
|
|
|
+ -DENABLE_WEBRTC:BOOL=OFF
|
|
|
|
+ )
|
|
|
|
+ if (( ! UBUNTU_2210_OR_LATER )) cmake_args+=(-DENABLE_NEW_MPEGTS_OUTPUT:BOOL=OFF)
|
|
|
|
+
|
|
|
|
+ cmake_build_args+=(build_${target##*-} --config ${config} --parallel)
|
|
|
|
+ cmake_install_args+=(build_${target##*-} --prefix ${project_root}/build_${target##*-}/install/${config})
|
|
|
|
+
|
|
|
|
+ log_group "Configuring ${product_name}..."
|
|
|
|
+ cmake -S ${project_root} ${cmake_args}
|
|
|
|
+
|
|
|
|
+ log_group "Building ${product_name}..."
|
|
|
|
+ if (( debug )) cmake_build_args+=(--verbose)
|
|
cmake ${cmake_build_args}
|
|
cmake ${cmake_build_args}
|
|
|
|
|
|
log_group "Installing ${product_name}..."
|
|
log_group "Installing ${product_name}..."
|
|
- if (( _loglevel > 1 )) cmake_install_args+=(--verbose)
|
|
|
|
|
|
+ if (( debug )) cmake_install_args+=(--verbose)
|
|
cmake ${cmake_install_args}
|
|
cmake ${cmake_install_args}
|
|
- popd
|
|
|
|
- }
|
|
|
|
- log_group
|
|
|
|
|
|
+ ;;
|
|
}
|
|
}
|
|
|
|
+ popd
|
|
|
|
+ log_group
|
|
}
|
|
}
|
|
|
|
|
|
build ${@}
|
|
build ${@}
|