Skip to content

Commit

Permalink
rename var: _OS -> _HOSTOS [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
vszakats committed Aug 24, 2023
1 parent 0e6f9eb commit 7fd14fd
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
46 changes: 23 additions & 23 deletions _build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ my_time='time'
[ -n "${CW_NOTIME:-}" ] && my_time=

# Detect host OS
export _OS
export _HOSTOS
case "$(uname)" in
*_NT*) _OS='win';;
Linux*) _OS='linux';;
Darwin*) _OS='mac';;
*BSD) _OS='bsd';;
*) _OS='unrecognized';;
*_NT*) _HOSTOS='win';;
Linux*) _HOSTOS='linux';;
Darwin*) _HOSTOS='mac';;
*BSD) _HOSTOS='bsd';;
*) _HOSTOS='unrecognized';;
esac

# Form suffix for alternate builds
Expand All @@ -238,7 +238,7 @@ fi
# `configure: WARNING: using cross tools not prefixed with host triplet`
# Even with `_CCPREFIX` provided.
# https://clang.llvm.org/docs/CrossCompilation.html
case "${_OS}" in
case "${_HOSTOS}" in
win) _BUILD_HOST="${unamem}-pc-mingw32";;
linux) _BUILD_HOST="${unamem}-pc-linux";;
bsd) _BUILD_HOST="${unamem}-pc-bsd";;
Expand Down Expand Up @@ -271,7 +271,7 @@ export _REVSUFFIX="${_REV}"; [ -z "${_REVSUFFIX}" ] || _REVSUFFIX="_${_REVSUFFIX
. ./_dl.sh

# Install required component
if [ "${_OS}" = 'mac' ]; then
if [ "${_HOSTOS}" = 'mac' ]; then
if [ ! -d .venv ]; then
python3 -m venv .venv
PIP_PROGRESS_BAR=off .venv/bin/python3 -m pip --disable-pip-version-check --no-cache-dir --require-virtualenv install pefile
Expand Down Expand Up @@ -433,7 +433,7 @@ build_single_target() {
# Reset for each target
PATH="${_ori_path}"

if [ "${_OS}" = 'win' ]; then
if [ "${_HOSTOS}" = 'win' ]; then
export PATH
if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then
PATH="${CW_LLVM_MINGW_PATH}/bin:${_ori_path}"
Expand All @@ -448,7 +448,7 @@ build_single_target() {
else
if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then
export PATH="${CW_LLVM_MINGW_PATH}/bin:${_ori_path}"
elif [ "${_CC}" = 'llvm' ] && [ "${_OS}" = 'mac' ]; then
elif [ "${_CC}" = 'llvm' ] && [ "${_HOSTOS}" = 'mac' ]; then
_MAC_LLVM_PATH='/usr/local/opt/llvm/bin'
export PATH="${_MAC_LLVM_PATH}:${_ori_path}"
fi
Expand All @@ -459,16 +459,16 @@ build_single_target() {
_CCPREFIX="${_TRIPLET}-"
# mingw-w64 sysroots
if [ "${_TOOLCHAIN}" != 'llvm-mingw' ]; then
if [ "${_OS}" = 'mac' ]; then
if [ "${_HOSTOS}" = 'mac' ]; then
_SYSROOT="/usr/local/opt/mingw-w64/toolchain-${_machine}"
elif [ "${_OS}" = 'linux' ]; then
elif [ "${_HOSTOS}" = 'linux' ]; then
_SYSROOT="/usr/${_TRIPLET}"
fi
fi

_WINE='echo'
if [ "${_OS}" = 'linux' ] || \
[ "${_OS}" = 'bsd' ]; then
if [ "${_HOSTOS}" = 'linux' ] || \
[ "${_HOSTOS}" = 'bsd' ]; then
# Run x64 targets on same CPU:
if [ "${_CPU}" = 'x64' ] && \
[ "${unamem}" = 'x86_64' ]; then
Expand All @@ -478,13 +478,13 @@ build_single_target() {
_WINE='wine'
fi
fi
elif [ "${_OS}" = 'mac' ]; then
elif [ "${_HOSTOS}" = 'mac' ]; then
# Run x64 targets on Intel and ARM (requires Wine 6.0.1):
if [ "${_CPU}" = 'x64' ] && \
command -v wine64 >/dev/null 2>&1; then
_WINE='wine64'
fi
elif [ "${_OS}" = 'win' ]; then
elif [ "${_HOSTOS}" = 'win' ]; then
# Skip ARM64 target on 64-bit Intel, run all targets on ARM64:
if [ "${unamem}" = 'x86_64' ] && \
[ "${_CPU}" != 'a64' ]; then
Expand Down Expand Up @@ -545,7 +545,7 @@ build_single_target() {
[ "${_CPU}" = 'x64' ] && _RCFLAGS_GLOBAL="${_RCFLAGS_GLOBAL} --target=pe-x86-64"
[ "${_CPU}" = 'a64' ] && _RCFLAGS_GLOBAL="${_RCFLAGS_GLOBAL} --target=${_TRIPLET}" # llvm-windres supports triplets here. https://github.com/llvm/llvm-project/blob/main/llvm/tools/llvm-rc/llvm-rc.cpp

if [ "${_OS}" = 'win' ]; then
if [ "${_HOSTOS}" = 'win' ]; then
# '-G MSYS Makefiles' command-line option is problematic due to spaces
# and unwanted escaping/splitting. Pass it via envvar instead.
export CMAKE_GENERATOR='MSYS Makefiles'
Expand Down Expand Up @@ -577,7 +577,7 @@ build_single_target() {
_CC_GLOBAL="${_CC_GLOBAL} --sysroot=${_SYSROOT}"
_CONFIGURE_GLOBAL="${_CONFIGURE_GLOBAL} --with-sysroot=${_SYSROOT}"
fi
if [ "${_OS}" = 'linux' ]; then
if [ "${_HOSTOS}" = 'linux' ]; then
# We used to pass this via CFLAGS for CMake to make it detect llvm/clang,
# so we need to pass this via CMAKE_C_FLAGS, though meant for the linker.
if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then
Expand Down Expand Up @@ -634,7 +634,7 @@ build_single_target() {
_BINUTILS_PREFIX='llvm-'
_BINUTILS_SUFFIX="${_CCSUFFIX}"
_LDFLAGS_GLOBAL="${_LDFLAGS_GLOBAL} -fuse-ld=lld${_CCSUFFIX}"
if [ "${_OS}" = 'mac' ]; then
if [ "${_HOSTOS}" = 'mac' ]; then
_RCFLAGS_GLOBAL="${_RCFLAGS_GLOBAL} -I${_SYSROOT}/${_TRIPLET}/include"
fi
fi
Expand Down Expand Up @@ -698,7 +698,7 @@ build_single_target() {
export RC="${_BINUTILS_PREFIX}windres${_BINUTILS_SUFFIX}"
if [ "${_CC}" = 'llvm' ] && \
[ "${_TOOLCHAIN}" != 'llvm-mingw' ] && \
[ "${_OS}" = 'linux' ] && \
[ "${_HOSTOS}" = 'linux' ] && \
[ -n "${_BINUTILS_SUFFIX}" ]; then
# FIXME: llvm-windres present, but unable to find its clang counterpart
# when suffixed:
Expand Down Expand Up @@ -734,7 +734,7 @@ build_single_target() {
chmod +x "${AR_NORMALIZE}"
fi

if [ "${_OS}" = 'mac' ]; then
if [ "${_HOSTOS}" = 'mac' ]; then
if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then
_CMAKE_GLOBAL="${_CMAKE_GLOBAL} -DCMAKE_AR=${CW_LLVM_MINGW_PATH}/bin/${AR}"
elif [ "${_CC}" = 'llvm' ]; then
Expand Down Expand Up @@ -776,7 +776,7 @@ build_single_target() {
mingwver="${mingwver} ${CW_LLVM_MINGW_VER_:-?}"
versuffix="${versuffix_llvm_mingw}"
else
case "${_OS}" in
case "${_HOSTOS}" in
mac)
mingwver="$(HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_FROM_API=1 brew info --json=v2 --formula mingw-w64 | jq --raw-output '.formulae[] | select(.name == "mingw-w64") | .versions.stable')";;
linux)
Expand Down Expand Up @@ -908,7 +908,7 @@ if [ "${_BRANCH#*x64*}" = "${_BRANCH}" ] && \
build_single_target x86
fi

case "${_OS}" in
case "${_HOSTOS}" in
mac) rm -f -P "${SIGN_CODE_KEY}";;
linux) [ -w "${SIGN_CODE_KEY}" ] && srm "${SIGN_CODE_KEY}";;
esac
Expand Down
10 changes: 5 additions & 5 deletions _dl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ echo "Build: REV(${_REVSUFFIX})"
# Quit if any of the lines fail
set -e

if [ "${_OS}" = 'mac' ]; then
if [ "${_HOSTOS}" = 'mac' ]; then
tar() { gtar "$@"; }
fi

Expand Down Expand Up @@ -631,13 +631,13 @@ EOF
if [ "${CW_LLVM_MINGW_DL:-}" = '1' ] && \
[ ! -d 'llvm-mingw' ]; then
name=''; vers=''; hash=''; arch="$(uname -m)"
if [ "${_OS}-${arch}" = 'linux-x86_64' ]; then
if [ "${_HOSTOS}-${arch}" = 'linux-x86_64' ]; then
name='llvm-mingw-linux-x86-64'; vers="${LLVM_MINGW_LINUX_X86_64_VER_}"; hash="${LLVM_MINGW_LINUX_X86_64_HASH}"
elif [ "${_OS}-${arch}" = 'linux-aarch64' ]; then
elif [ "${_HOSTOS}-${arch}" = 'linux-aarch64' ]; then
name='llvm-mingw-linux-aarch64'; vers="${LLVM_MINGW_LINUX_AARCH64_VER_}"; hash="${LLVM_MINGW_LINUX_AARCH64_HASH}"
elif [ "${_OS}" = 'mac' ]; then
elif [ "${_HOSTOS}" = 'mac' ]; then
name='llvm-mingw-mac'; vers="${LLVM_MINGW_MAC_VER_}"; hash="${LLVM_MINGW_MAC_HASH}"
elif [ "${_OS}" = 'win' ]; then
elif [ "${_HOSTOS}" = 'win' ]; then
name='llvm-mingw-win'; vers="${LLVM_MINGW_WIN_VER_}"; hash="${LLVM_MINGW_WIN_HASH}"
fi
if [ -n "${name}" ]; then
Expand Down
12 changes: 6 additions & 6 deletions _pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o p

cd "$(dirname "$0")"

if [ "${_OS}" = 'mac' ]; then
if [ "${_HOSTOS}" = 'mac' ]; then
tar() { gtar "$@"; }
fi

Expand Down Expand Up @@ -53,11 +53,11 @@ create_pkg() {
fi
# Alter filename for non-release packages
if [ "${_BRANCH#*main*}" != "${_BRANCH}" ]; then
if [ "${PUBLISH_PROD_FROM}" != "${_OS}" ]; then
_suf="${_suf}-built-on-${_OS}"
if [ "${PUBLISH_PROD_FROM}" != "${_HOSTOS}" ]; then
_suf="${_suf}-built-on-${_HOSTOS}"
fi
else
_suf="${_suf}-test-built-on-${_OS}"
_suf="${_suf}-test-built-on-${_HOSTOS}"
fi

_pkg="${_OUT}${_suf}${arch_ext}"
Expand All @@ -66,7 +66,7 @@ create_pkg() {

(
cd "${_DST}/.."
case "${_OS}" in
case "${_HOSTOS}" in
win) find "${_BAS}" -exec attrib +A -R '{}' \;
esac

Expand All @@ -87,7 +87,7 @@ create_pkg() {
rm -f "${_FLS}"

# <filename>: <size> bytes <YYYY-MM-DD> <HH:MM>
case "${_OS}" in
case "${_HOSTOS}" in
bsd|mac) TZ=UTC stat -f '%N: %z bytes %Sm' -t '%Y-%m-%d %H:%M' "${_pkg}";;
*) TZ=UTC stat --format='%n: %s bytes %y' "${_pkg}";;
esac
Expand Down
2 changes: 1 addition & 1 deletion _sign-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ -s "${SIGN_CODE_KEY}" ] && \
_ref="$1"
shift

case "${_OS}" in
case "${_HOSTOS}" in
bsd|mac) unixts="$(TZ=UTC stat -f '%m' "${_ref}")";;
*) unixts="$(TZ=UTC stat --format='%Y' "${_ref}")";;
esac
Expand Down
4 changes: 2 additions & 2 deletions _ul.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ touch -c -r "${_ALL}" "${_ALL}.txt"

# Official deploy
DEPLOY_KEY="$(realpath '.')/deploy.key"
if [ "${PUBLISH_PROD_FROM}" = "${_OS}" ] && \
if [ "${PUBLISH_PROD_FROM}" = "${_HOSTOS}" ] && \
[ "${_BRANCH#*main*}" != "${_BRANCH}" ] && \
[ -s "${DEPLOY_KEY}.asc" ] && \
[ -n "${DEPLOY_GPG_PASS:+1}" ]; then
Expand Down Expand Up @@ -107,7 +107,7 @@ EOF
'[email protected]:.'
fi

case "${_OS}" in
case "${_HOSTOS}" in
mac) rm -f -P "${DEPLOY_KEY}";;
linux) [ -w "${DEPLOY_KEY}" ] && srm "${DEPLOY_KEY}";;
esac
Expand Down
2 changes: 1 addition & 1 deletion curl-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# Tests

# Show the reference timestamp in UTC.
case "${_OS}" in
case "${_HOSTOS}" in
bsd|mac) TZ=UTC stat -f '%N: %Sm' -t '%Y-%m-%d %H:%M' "${_ref}";;
*) TZ=UTC stat --format='%n: %y' "${_ref}";;
esac
Expand Down
4 changes: 2 additions & 2 deletions openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ _VER="$1"
cd "${_NAM}" || exit 0

# Required on MSYS2 for pod2man and pod2html in 'make install' phase
[ "${_OS}" = 'win' ] && export PATH="${PATH}:/usr/bin/core_perl"
[ "${_HOSTOS}" = 'win' ] && export PATH="${PATH}:/usr/bin/core_perl"

readonly _ref='CHANGES.md'

case "${_OS}" in
case "${_HOSTOS}" in
bsd|mac) unixts="$(TZ=UTC stat -f '%m' "${_ref}")";;
*) unixts="$(TZ=UTC stat --format='%Y' "${_ref}")";;
esac
Expand Down

0 comments on commit 7fd14fd

Please sign in to comment.