#!/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 "${CI:+::error::}%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 TRAPEXIT() { local return_value=$? if (( ${+CI} )) unset NSUnbufferedIO return ${return_value} } TRAPZERR() { if (( ${_loglevel:-3} > 2 )) { print -u2 -PR "${CI:+::error::}%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 project_root=${SCRIPT_HOME:A:h:h} local buildspec_file=${project_root}/buildspec.json fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) autoload -Uz log_group log_info log_error log_output set_loglevel check_${host_os} setup_ccache if [[ ! -r ${buildspec_file} ]] { log_error \ 'No buildspec.json found. Please create a build specification for your project.' return 2 } typeset -g -a skips=() local -i verbosity=1 local -r _version='2.0.0' local -r -a _valid_targets=( macos-universal linux-x86_64 linux-aarch64 ) local target local config='RelWithDebInfo' local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) 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