CI: Simplify build scripts for CI-only use

This commit is contained in:
PatTheMav
2023-08-10 18:21:09 -04:00
committed by Ryan Foster
parent 914392fcc0
commit cf8a8cce72
23 changed files with 255 additions and 708 deletions
+2 -18
View File
@@ -1,4 +1,4 @@
autoload -Uz log_info log_status log_error log_debug log_warning log_group
autoload -Uz log_debug log_group
log_group 'Check Linux build requirements'
log_debug 'Checking Linux distribution name and version...'
@@ -16,14 +16,6 @@ if [[ -f /etc/os_release ]] {
fi
}
log_debug 'Checking for apt-get...'
if (( ! ${+commands[apt-get]} )) {
log_error 'No apt-get command found. Please install apt'
return 2
} else {
log_debug "Apt-get located at ${commands[apt-get]}"
}
local -a dependencies=("${(fA)$(<${SCRIPT_HOME}/.Aptfile)}")
local -a install_list
local binary
@@ -46,15 +38,7 @@ for dependency (${dependencies}) {
log_debug "List of dependencies to install: ${install_list}"
if (( #install_list )) {
if (( ! ${+CI} )) log_warning 'Dependency installation via apt may require elevated privileges'
local -a apt_args=(
${CI:+-y}
--no-install-recommends
)
if (( _loglevel == 0 )) apt_args+=(--quiet)
sudo apt-get ${apt_args} install ${install_list}
sudo apt-get -y --no-install-recommends install ${install_list}
}
rehash
+5 -8
View File
@@ -16,10 +16,7 @@ local output_name=${3}
log_group "Create macOS disk image"
local _hdiutil_flags
if (( _loglevel < 1 )) _hdiutil_flags='-quiet'
trap "safe_hdiutil detach ${_hdiutil_flags} /Volumes/${output_name}; rm temp.dmg; log_group; return 2" ERR
trap "safe_hdiutil detach /Volumes/${output_name}; rm temp.dmg; log_group; return 2" ERR
safe_hdiutil() {
local _status=0
@@ -43,14 +40,14 @@ safe_hdiutil() {
}
}
safe_hdiutil create ${_hdiutil_flags} \
safe_hdiutil create \
-volname "${volume_name}" \
-srcfolder ${source} \
-ov \
-fs APFS \
-format UDRW \
temp.dmg
safe_hdiutil attach ${_hdiutil_flags} \
safe_hdiutil attach \
-noverify \
-readwrite \
-mountpoint /Volumes/${output_name} \
@@ -70,9 +67,9 @@ SetFile -a C /Volumes/${output_name}
rm -rf -- /Volumes/${output_name}/.fseventsd(N)
log_info "Converting disk image..."
safe_hdiutil detach ${_hdiutil_flags} /Volumes/${output_name}
safe_hdiutil detach /Volumes/${output_name}
safe_hdiutil convert ${_hdiutil_flags} \
safe_hdiutil convert \
-format ULMO \
-ov \
-o ${output_name}.dmg temp.dmg
+1 -3
View File
@@ -1,3 +1 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 2 )) print -PR -e "${CI:+::debug::}%F{220}DEBUG: ${@}%f"
if (( debug )) print -PR -e "::debug::%F{220}DEBUG: ${@}%f"
+1 -3
View File
@@ -1,3 +1 @@
local icon=' ✖︎ '
print -u2 -PR "${CI:+::error::}%F{1} ${icon} %f ${@}"
print -u2 -PR "::error::%F{1} ✖︎%f ${@}"
+7 -11
View File
@@ -2,15 +2,11 @@ autoload -Uz log_info
if (( ! ${+_log_group} )) typeset -g _log_group=0
if (( ${+CI} )) {
if (( _log_group )) {
print "::endgroup::"
typeset -g _log_group=0
}
if (( # )) {
print "::group::${@}"
typeset -g _log_group=1
}
} else {
if (( # )) log_info ${@}
if (( _log_group )) {
print "::endgroup::"
typeset -g _log_group=0
}
if (( # )) {
print "::group::${@}"
typeset -g _log_group=1
}
+1 -7
View File
@@ -1,7 +1 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=' =>'
print -PR "%F{4} ${(r:5:)icon}%f %B${@}%b"
}
print -PR "%F{4} =>%f %B${@}%b"
+1 -7
View File
@@ -1,7 +1 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=''
print -PR " ${(r:5:)icon} ${@}"
}
print -PR " ${@}"
+1 -7
View File
@@ -1,7 +1 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=' >'
print -PR "%F{2} ${(r:5:)icon}%f ${@}"
}
print -PR "%F{2} >%f ${@}"
+1 -7
View File
@@ -1,7 +1 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=' =>'
print -PR "${CI:+::warning::}%F{3} ${(r:5:)icon} ${@}%f"
}
print -PR "::warning::%F{3} => ${@}%f"
-9
View File
@@ -1,9 +0,0 @@
autoload -Uz log_info
if (( ! ${+CODESIGN_IDENT} )) {
typeset -g CODESIGN_IDENT
log_info 'Setting up Apple Developer ID for application codesigning...'
read CODESIGN_IDENT'?Apple Developer Application ID: '
}
typeset -g CODESIGN_TEAM=$(print "${CODESIGN_IDENT}" | /usr/bin/sed -En 's/.+\((.+)\)/\1/p')
@@ -1,27 +0,0 @@
autoload -Uz read_codesign read_codesign_user log_info log_warning
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: '
}
print ''
log_info 'Setting up notarization keychain...'
if (( ! ${+CI} )) {
log_warning "
+ Your Apple ID and 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.
"
}
xcrun notarytool store-credentials 'OBS-Codesign-Password' --apple-id "${CODESIGN_IDENT_USER}" --team-id "${CODESIGN_TEAM}" --password "${CODESIGN_IDENT_PASS}"
@@ -1,7 +0,0 @@
autoload -Uz log_info
if (( ! ${+CODESIGN_TEAM} )) {
typeset -g CODESIGN_TEAM
log_info 'Setting up Apple Developer Team ID for codesigning...'
read CODESIGN_TEAM'?Apple Developer Team ID (leave empty to use Apple Developer ID instead): '
}
@@ -1,7 +0,0 @@
autoload -Uz log_info
if (( ! ${+CODESIGN_IDENT_USER} )) {
typeset -g CODESIGN_IDENT_USER
log_info 'Setting up Apple ID for notarization...'
read CODESIGN_IDENT_USER'?Apple ID: '
}
-7
View File
@@ -1,7 +0,0 @@
if (( _loglevel > 1 )) {
xcodebuild ${@}
} else {
local -a xcbeautify_opts=()
if (( _loglevel == 0 )) xcbeautify_opts+=(--quiet)
xcodebuild ${@} 2>&1 | xcbeautify ${xcbeautify_opts}
}
-17
View File
@@ -1,17 +0,0 @@
autoload -Uz log_debug log_error log_output
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}'"
+5 -14
View File
@@ -1,15 +1,8 @@
autoload -Uz log_debug log_warning log_error
if (( ! ${+project_root} )) {
log_error "'project_root' not set. Please set before running ${0}."
return 2
}
autoload -Uz log_debug log_warning
if (( ${+commands[ccache]} )) {
log_debug "Found ccache at ${commands[ccache]}"
typeset -gx CCACHE_CONFIGPATH="${project_root}/.ccache.conf"
ccache --set-config=run_second_cpp=true
ccache --set-config=direct_mode=true
ccache --set-config=inode_cache=true
@@ -32,11 +25,9 @@ if (( ${+commands[ccache]} )) {
ccache --set-config=sloppiness=${(j:,:)sloppiness}
}
if (( ${+CI} )) {
ccache --set-config=cache_dir="${GITHUB_WORKSPACE:-${HOME}}/.ccache"
ccache --set-config=max_size="${CCACHE_SIZE:-1G}"
ccache -z > /dev/null
}
ccache --set-config=cache_dir="${GITHUB_WORKSPACE:-${HOME}}/.ccache"
ccache --set-config=max_size="${CCACHE_SIZE:-1G}"
ccache -z > /dev/null
} else {
log_warning "No ccache found on the system"
log_warning "Ccache not available"
}
+94 -164
View File
@@ -1,32 +1,16 @@
autoload -Uz log_group log_error log_status log_info log_debug
if (( ! ${+commands[curl]} )) {
log_error 'curl not found. Please install curl.'
log_error 'curl not available.'
return 2
}
if (( ! ${+commands[jq]} )) {
log_error 'jq not found. Please install jq.'
log_error 'jq not available.'
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 --continue-at -)
} else {
curl_opts+=(--show-error --silent)
}
curl_opts+=(--location -O ${@})
local -a curl_opts=(--show-error --silent --location -O ${@})
pushd ${project_root}
@@ -36,152 +20,98 @@ read -r QT_VERSION <<< \
'.platformConfig[$target] | { qtVersion } | join(" ")' \
${buildspec_file})"
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)deps]}) )) {
log_group 'Installing obs-studio build dependencies...'
log_group 'Installing obs-studio build dependencies...'
mkdir -p ${project_root}/.deps
local deps_version
local deps_baseurl
local deps_label
local deps_hash
mkdir -p ${project_root}/.deps
local deps_version
local deps_baseurl
local deps_label
local deps_hash
IFS=';' read -r deps_version deps_baseurl deps_label deps_hash <<< \
"$(jq -r --arg target "${target}" \
'.dependencies["cef"] | {version, baseUrl, "label", "hash": .hashes[$target]} | join(";")' \
${buildspec_file})"
IFS=';' read -r deps_version deps_baseurl deps_label deps_hash <<< \
"$(jq -r --arg target "${target}" \
'.dependencies["cef"] | {version, baseUrl, "label", "hash": .hashes[$target]} | join(";")' \
${buildspec_file})"
if (( ! deps_version )) {
log_error 'No valid cef spec found in buildspec.json.'
return 2
}
log_group 'Setting up pre-built Chromium Embedded Framework...'
pushd ${project_root}/.deps
local _filename="cef_binary_${deps_version}_${target//-/_}.tar.xz"
local _url=${deps_baseurl}/${_filename}
local _target="cef_binary_${deps_version}_${target//-/_}"
typeset -g CEF_VERSION=${deps_version}
log_status 'Checking for available wrapper library...'
local -i _skip=0
if [[ -f ${_target}/build/libcef_dll_wrapper/libcef_dll_wrapper.a ]] {
_skip=1
}
if ! (( _skip )) {
if [[ ! -f ${_filename} ]] {
log_debug "Running curl ${curl_opts} ${_url}"
curl ${curl_opts} ${_url} && \
log_status "Downloaded ${deps_label} for ${target}."
} else {
log_status "Found downloaded ${deps_label}"
}
read -r artifact_checksum _ <<< "$(sha256sum ${_filename})"
if [[ ${deps_hash} != ${artifact_checksum} ]] {
log_error "Checksum of downloaded ${deps_label} does not match specification.
Expected : ${deps_hash}
Actual : ${artifact_checksum}"
return 2
}
log_status "Checksum of downloaded ${deps_label} matches."
mkdir -p ${_target} && pushd ${_target}
XZ_OPT=-T0 tar --strip-components 1 -xJf ../${_filename} && log_status "${deps_label} extracted."
if [[ ! -f build/libcef_dll_wrapper/libcef_dll_wrapper.a ]] {
log_group "Configuring CEF wrapper library..."
local -a cmake_args=(
-DPROJECT_ARCH:STRING=${target##*-}
-DCEF_COMPILER_FLAGS:STRING="-Wno-deprecated-copy"
-DCMAKE_BUILD_TYPE:STRING=${config}
-DCMAKE_CXX_FLAGS:STRING="-std=c++11 -Wno-deprecated-declarations -Wno-unknonw-warning-option"
-DCMAKE_EXE_LINKER_FLAGS:STRING="-std=c++11"
)
if (( _loglevel == 0 )) cmake_args+=(-Wno-deprecated -Wno-dev --log-level=ERROR)
if (( ${+commands[ccache]} )) {
cmake_args+=(
-DCMAKE_C_COMPILER_LAUNCHER:STRING=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache
)
}
cmake -S . -B build -G Ninja ${cmake_args}
log_group "Building CEF Wrapper library..."
cmake --build build
}
mkdir -p build/libcef_dll
popd
} else {
log_info 'Found existing Chromium Embedded Framework and loader library...'
}
popd
local -a apt_args=(
${CI:+-y}
--no-install-recommends
)
if (( _loglevel == 0 )) apt_args+=(--quiet)
local suffix
if [[ ${CPUTYPE} != ${target##*-} ]] {
local -A arch_mappings=(
aarch64 arm64
x86_64 amd64
)
suffix=":${arch_mappings[${target##*-}]}"
sudo apt-get install ${apt_args} gcc-${${target##*-}//_/-}-linux-gnu g++-${${target##*-}//_/-}-linux-gnu
}
sudo apt-get install ${apt_args} \
build-essential \
libcurl4-openssl-dev \
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev \
libswresample-dev libswscale-dev \
libjansson-dev \
libx11-xcb-dev \
libgles2-mesa-dev libgles2-mesa \
libwayland-dev \
libpipewire-0.3-dev \
libpulse-dev \
libx264-dev \
libmbedtls-dev \
libgl1-mesa-dev \
libjansson-dev \
libluajit-5.1-dev python3-dev \
libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \
libxcb-composite0-dev libxinerama-dev libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev \
swig libcmocka-dev libxss-dev libglvnd-dev \
libxkbcommon-dev \
libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libjack-jackd2-dev \
libpulse-dev libsndio-dev libspeexdsp-dev libudev-dev libv4l-dev libva-dev libvlc-dev \
libpci-dev libdrm-dev \
nlohmann-json3-dev libwebsocketpp-dev libasio-dev libvpl-dev libqrcodegencpp-dev
if (( UBUNTU_2210_OR_LATER )) sudo apt-get install ${apt_args} librist-dev libsrt-openssl-dev
local -a _qt_packages=()
if (( QT_VERSION == 6 )) {
_qt_packages+=(
qt6-base-dev
libqt6svg6-dev
qt6-base-private-dev
)
} else {
log_error "Unsupported Qt version '${QT_VERSION}' specified."
return 2
}
sudo apt-get install ${apt_args} ${_qt_packages}
} else {
local cef_version
read -r cef_version <<< \
"$(jq -r '.dependencies | [.cef.version] | join(" ")' ${buildspec_file})"
typeset -g CEF_VERSION=${cef_version}
if (( ! deps_version )) {
log_error 'No valid cef spec found in buildspec.json.'
return 2
}
log_group 'Setting up pre-built Chromium Embedded Framework...'
pushd ${project_root}/.deps
local _filename="cef_binary_${deps_version}_${target//-/_}.tar.xz"
local _url=${deps_baseurl}/${_filename}
local _target="cef_binary_${deps_version}_${target//-/_}"
typeset -g CEF_VERSION=${deps_version}
log_debug "Running curl ${curl_opts} ${_url}"
curl ${curl_opts} ${_url} && \
log_status "Downloaded ${deps_label} for ${target}."
read -r artifact_checksum _ <<< "$(sha256sum ${_filename})"
if [[ ${deps_hash} != ${artifact_checksum} ]] {
log_error "Checksum of downloaded ${deps_label} does not match specification.
Expected : ${deps_hash}
Actual : ${artifact_checksum}"
return 2
}
log_status "Checksum of downloaded ${deps_label} matches."
mkdir -p ${_target} && pushd ${_target}
XZ_OPT=-T0 tar --strip-components 1 -xJf ../${_filename} && log_status "${deps_label} extracted."
popd
local suffix
if [[ ${CPUTYPE} != ${target##*-} ]] {
local -A arch_mappings=(
aarch64 arm64
x86_64 amd64
)
suffix=":${arch_mappings[${target##*-}]}"
sudo apt-get install -y --no-install-recommends \
gcc-${${target##*-}//_/-}-linux-gnu g++-${${target##*-}//_/-}-linux-gnu
}
sudo apt-get install -y --no-install-recommends \
build-essential \
libcurl4-openssl-dev \
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev \
libswresample-dev libswscale-dev \
libjansson-dev \
libx11-xcb-dev \
libgles2-mesa-dev libgles2-mesa \
libwayland-dev \
libpipewire-0.3-dev \
libpulse-dev \
libx264-dev \
libmbedtls-dev \
libgl1-mesa-dev \
libjansson-dev \
libluajit-5.1-dev python3-dev \
libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \
libxcb-composite0-dev libxinerama-dev libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev \
swig libcmocka-dev libxss-dev libglvnd-dev \
libxkbcommon-dev \
libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libjack-jackd2-dev \
libpulse-dev libsndio-dev libspeexdsp-dev libudev-dev libv4l-dev libva-dev libvlc-dev \
libpci-dev libdrm-dev \
nlohmann-json3-dev libwebsocketpp-dev libasio-dev libvpl-dev libqrcodegencpp-dev
if (( UBUNTU_2210_OR_LATER )) sudo apt-get install -y --no-install-recommends librist-dev libsrt-openssl-dev
local -a _qt_packages=()
if (( QT_VERSION == 6 )) {
_qt_packages+=(
qt6-base-dev
libqt6svg6-dev
qt6-base-private-dev
)
} else {
log_error "Unsupported Qt version '${QT_VERSION}' specified."
return 2
}
sudo apt-get install -y --no-install-recommends ${_qt_packages}