Refactoring of CI configurations and build scripts
Now, CI builds for macOS involve three separate builds for a range of macOS versions, and a final Universal macOS Binary made on Big Sur. It should work with the M1 chip and x86_64 Intel Macs. I have also renamed osx_environment->macOS_environment.sh to reflect the new name change of Apple's desktop OS. In terms of the clean_builds.sh script, this has also been refactored to be more resilient, and efficient (marginally). Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
This commit is contained in:
parent
dc7aa012d5
commit
4b373ba82b
|
@ -79,22 +79,22 @@ jobs:
|
||||||
- script: sh -x ./clean_build.sh
|
- script: sh -x ./clean_build.sh
|
||||||
displayName: Clean Build
|
displayName: Clean Build
|
||||||
|
|
||||||
- job: MacBuild
|
- job: macOStests
|
||||||
displayName: Mac Build
|
displayName: macOS Tests
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
big-sur-Release:
|
big-sur:
|
||||||
imageName: "macOS-11"
|
imageName: "macOS-11"
|
||||||
B_BUILD_TYPE: Release
|
B_BUILD_TYPE: Debug
|
||||||
BARRIER_VERSION_STAGE: Release
|
BARRIER_VERSION_STAGE: Debug
|
||||||
catalina-Release:
|
catalina-Release:
|
||||||
imageName: "macOS-10.15"
|
imageName: "macOS-10.15"
|
||||||
B_BUILD_TYPE: Release
|
B_BUILD_TYPE: Debug
|
||||||
BARRIER_VERSION_STAGE: Release
|
BARRIER_VERSION_STAGE: Debug
|
||||||
mojave-Release:
|
mojave-Release:
|
||||||
imageName: "macOS-10.14"
|
imageName: "macOS-10.14"
|
||||||
B_BUILD_TYPE: Release
|
B_BUILD_TYPE: Debug
|
||||||
BARRIER_VERSION_STAGE: Release
|
BARRIER_VERSION_STAGE: Debug
|
||||||
pool:
|
pool:
|
||||||
vmImage: $(imageName)
|
vmImage: $(imageName)
|
||||||
variables:
|
variables:
|
||||||
|
@ -109,9 +109,28 @@ jobs:
|
||||||
displayName: Install Qt5 and pkg-config prereqs
|
displayName: Install Qt5 and pkg-config prereqs
|
||||||
- script: sh -x ./clean_build.sh
|
- script: sh -x ./clean_build.sh
|
||||||
displayName: Clean Build
|
displayName: Clean Build
|
||||||
|
|
||||||
|
- job: macOSRelease
|
||||||
|
displayName: macOS Universal Binary Release Builds
|
||||||
|
pool:
|
||||||
|
vmImage: "macOS-11"
|
||||||
|
variables:
|
||||||
|
VERBOSE: 1
|
||||||
|
TERM: xterm-256color
|
||||||
|
B_BUILD_TYPE: Release
|
||||||
|
BARRIER_VERSION_STAGE: Release
|
||||||
|
steps:
|
||||||
|
- script: rm -rf /usr/local/opt/openssl
|
||||||
|
displayName: Remove incompatible OpenSSL 1.0.2t from macOS-10.14 vmImage
|
||||||
|
- script: brew reinstall openssl
|
||||||
|
displayName: Installed newer OpenSSL 1.1.x
|
||||||
|
- script: brew install pkg-config qt5
|
||||||
|
displayName: Install Qt5 and pkg-config prereqs
|
||||||
|
- script: sh -x ./clean_build.sh
|
||||||
|
displayName: Clean Build
|
||||||
- task: PublishBuildArtifacts@1
|
- task: PublishBuildArtifacts@1
|
||||||
displayName: Publish Release DMG
|
displayName: Publish Release DMG
|
||||||
condition: eq(variables['B_BUILD_TYPE'], 'Release')
|
condition: eq(variables['B_BUILD_TYPE'], 'Release')
|
||||||
inputs:
|
inputs:
|
||||||
pathtoPublish: build/bundle
|
pathtoPublish: build/bundle
|
||||||
artifactName: Mac Release Disk Image and App $(imageName)
|
artifactName: Universal Binary for macOS
|
||||||
|
|
|
@ -1,32 +1,77 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cd "$(dirname "$0")" || exit 1
|
cd "$(dirname "$0")" || exit 1
|
||||||
|
|
||||||
# some environments have cmake v2 as 'cmake' and v3 as 'cmake3'
|
# some environments have cmake v2 as 'cmake' and v3 as 'cmake3'
|
||||||
# check for cmake3 first then fallback to just cmake
|
# check for cmake3 first then fallback to just cmake
|
||||||
B_CMAKE=`type cmake3 2>/dev/null`
|
|
||||||
if [ $? -eq 0 ]; then
|
B_CMAKE=$(command -v cmake3 2>/dev/null)
|
||||||
B_CMAKE=`echo "$B_CMAKE" | cut -d' ' -f3`
|
if [ "$?" -eq 0 ]; then
|
||||||
|
# Continue, cmake3 exists in $PATH.
|
||||||
|
continue
|
||||||
else
|
else
|
||||||
B_CMAKE=cmake
|
# OK, so cmake3 isn't in path, so let's test to see if `cmake` itself exists, before proceeding.
|
||||||
|
if command -v cmake 2>/dev/null; then
|
||||||
|
B_CMAKE=$(command -v cmake)
|
||||||
|
# We have a cmake executable available, now let's proceed!
|
||||||
|
else
|
||||||
|
# As self-explanatory, the cmake executable isn't available, so we should fail here.
|
||||||
|
echo "ERROR: CMake not in $PATH, cannot build! Please install CMake, or if this persists, file a bug report."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# default build configuration
|
|
||||||
|
# Set default build type, but in CI, this is set to Release.
|
||||||
|
# For downstream distributions, our recommendation is to set this type in your build scripts to Release, and supply Debug build types in your debug packages.
|
||||||
|
|
||||||
B_BUILD_TYPE=${B_BUILD_TYPE:-Debug}
|
B_BUILD_TYPE=${B_BUILD_TYPE:-Debug}
|
||||||
|
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
# OSX needs a lot of extra help, poor thing
|
# macOS needs a little help, so we source this environment script to fix paths.
|
||||||
# run the osx_environment.sh script to fix paths
|
if [ ! -e "./macOS_environment.sh" ]; then
|
||||||
. ./osx_environment.sh
|
echo "macOS environment script not found, this isn't meant to happen!"
|
||||||
B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 $B_CMAKE_FLAGS"
|
exit 1
|
||||||
|
else
|
||||||
|
. ./macOS_environment.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We build a Universal macOS Binary, which supports M1 and Intel processors (64-bit)
|
||||||
|
CMAKE_OSX_ARCHITECTURES="arm64;x86_64"
|
||||||
|
|
||||||
|
B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 ${B_CMAKE_FLAGS:-}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source local build variables to the environment, if available.
|
||||||
|
# If not, continue as normal, and silently.
|
||||||
|
if [ -e "./build_env.sh" ]; then
|
||||||
|
. "./build_env.sh"
|
||||||
fi
|
fi
|
||||||
# allow local customizations to build environment
|
|
||||||
[ -r ./build_env.sh ] && . ./build_env.sh
|
|
||||||
|
|
||||||
# Initialise Git submodules
|
# Initialise Git submodules
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
B_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=$B_BUILD_TYPE $B_CMAKE_FLAGS"
|
B_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=${B_BUILD_TYPE} ${B_CMAKE_FLAGS:-}"
|
||||||
rm -rf build
|
|
||||||
mkdir build || exit 1
|
# Clear build directory, but do a conditional first!
|
||||||
cd build || exit 1
|
|
||||||
echo "Starting Barrier $B_BUILD_TYPE build..."
|
if [ -d "./build" ]; then
|
||||||
$B_CMAKE $B_CMAKE_FLAGS .. || exit 1
|
rm -rf ./build
|
||||||
make || exit 1
|
fi
|
||||||
echo "Build completed successfully"
|
|
||||||
|
# Previous versions of this script created the build directory, and CD'd into it - CMake allows us to do this another way...
|
||||||
|
|
||||||
|
# Note: If you use Ninja (i.e, cmake -GNinja -B build), run Ninja like: "ninja -C build", just like you would with Meson.
|
||||||
|
|
||||||
|
$B_CMAKE "$B_CMAKE_FLAGS" -B build || exit 1
|
||||||
|
|
||||||
|
|
||||||
|
echo "INFO: Now commencing Barrier build process..."
|
||||||
|
echo "INFO: We're building an $B_BUILD_TYPE output type."
|
||||||
|
$(command -v make) -C build || exit 1
|
||||||
|
|
||||||
|
# Implictly, we assume the build was successful due to no exits.
|
||||||
|
# Later revisions of this script should do conditionals. TODO.
|
||||||
|
|
||||||
|
echo "INFO: Success! The build completed successfully!"
|
||||||
|
|
||||||
|
exit
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Refactor CI builds, and build scripts to be more resilient, and effective
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Checks if directory exists, otherwise asks to install package.
|
||||||
|
check_dir_exists() {
|
||||||
|
local path=$1
|
||||||
|
local package=$2
|
||||||
|
|
||||||
|
if [ ! -d "$path" ]; then
|
||||||
|
echo "Please install $package"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$BARRIER_BUILD_ENV" ]; then
|
||||||
|
check_dir_exists '/Applications/Xcode.app' 'Xcode'
|
||||||
|
|
||||||
|
printf "Modifying environment for Barrier build...\n"
|
||||||
|
|
||||||
|
if command -v port; then
|
||||||
|
printf "Detected Macports\n"
|
||||||
|
|
||||||
|
check_dir_exists '/opt/local/lib/cmake/Qt5' 'qt5-qtbase port'
|
||||||
|
|
||||||
|
export BARRIER_BUILD_MACPORTS=1
|
||||||
|
export CMAKE_PREFIX_PATH="/opt/local/lib/cmake/Qt5:$CMAKE_PREFIX_PATH"
|
||||||
|
export LD_LIBRARY_PATH="/opt/local/lib:$LD_LIBRARY_PATH"
|
||||||
|
export CPATH="/opt/local/include:$CPATH"
|
||||||
|
export PKG_CONFIG_PATH="/opt/local/libexec/qt5/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
|
|
||||||
|
elif command -v brew; then
|
||||||
|
printf "Detected Homebrew\n"
|
||||||
|
QT_PATH=$(brew --prefix qt@5)
|
||||||
|
|
||||||
|
check_dir_exists "$QT_PATH" 'qt5'
|
||||||
|
|
||||||
|
export BARRIER_BUILD_BREW=1
|
||||||
|
export CMAKE_PREFIX_PATH="/opt/procursus:$QT_PATH:$CMAKE_PREFIX_PATH"
|
||||||
|
export LD_LIBRARY_PATH="/opt/procursus/lib:$LD_LIBRARY_PATH"
|
||||||
|
export CPATH="/opt/procursus/include:$CPATH"
|
||||||
|
export PKG_CONFIG_PATH="/opt/procursus/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
|
else
|
||||||
|
printf "Neither Homebrew nor Macports is installed. Can't get dependency paths\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export BARRIER_BUILD_ENV=1
|
||||||
|
|
||||||
|
printf "done\n"
|
||||||
|
fi
|
Loading…
Reference in New Issue