Jenkins: Add macOS to the build script
This commit is contained in:
86
.ci/build.sh
86
.ci/build.sh
@@ -28,9 +28,13 @@
|
|||||||
# - Packaging the Discord DLL requires wget (MSYS should come with it)
|
# - Packaging the Discord DLL requires wget (MSYS should come with it)
|
||||||
# - For Linux builds:
|
# - For Linux builds:
|
||||||
# - Only Debian and derivatives are supported
|
# - Only Debian and derivatives are supported
|
||||||
# - dpkg and apt-get are called through sudo to manage dependencies
|
# - dpkg and apt-get are called through sudo to manage dependencies; make sure those
|
||||||
|
# are configured as NOPASSWD in /etc/sudoers if you're doing unattended builds
|
||||||
# - For macOS builds:
|
# - For macOS builds:
|
||||||
# - TBD
|
# - A standard MacPorts installation is required, with the following macports.conf settings:
|
||||||
|
#
|
||||||
|
# - port is called through sudo to manage dependencies; make sure it is configured
|
||||||
|
# as NOPASSWD in /etc/sudoers if you're doing unattended builds
|
||||||
#
|
#
|
||||||
|
|
||||||
# Define common functions.
|
# Define common functions.
|
||||||
@@ -178,13 +182,16 @@ fi
|
|||||||
echo [-] Building [$package_name] for [$arch] with flags [$cmake_flags]
|
echo [-] Building [$package_name] for [$arch] with flags [$cmake_flags]
|
||||||
|
|
||||||
# Determine CMake toolchain file for this architecture.
|
# Determine CMake toolchain file for this architecture.
|
||||||
|
toolchain_prefix=flags-gcc
|
||||||
|
is_mac && toolchain_prefix=llvm-macos
|
||||||
case $arch in
|
case $arch in
|
||||||
32 | x86) toolchain="flags-gcc-i686";;
|
32 | x86) toolchain="$toolchain_prefix-i686";;
|
||||||
64 | x86_64) toolchain="flags-gcc-x86_64";;
|
64 | x86_64) toolchain="$toolchain_prefix-x86_64";;
|
||||||
ARM32 | arm32) toolchain="flags-gcc-armv7";;
|
ARM32 | arm32) toolchain="$toolchain_prefix-armv7";;
|
||||||
ARM64 | arm64) toolchain="flags-gcc-aarch64";;
|
ARM64 | arm64) toolchain="$toolchain_prefix-aarch64";;
|
||||||
*) toolchain="flags-gcc-$arch";;
|
*) toolchain="$toolchain_prefix-$arch";;
|
||||||
esac
|
esac
|
||||||
|
[ ! -e "cmake/$toolchain.cmake" ] && toolchain=flags-gcc
|
||||||
|
|
||||||
# Perform platform-specific setup.
|
# Perform platform-specific setup.
|
||||||
strip_binary=strip
|
strip_binary=strip
|
||||||
@@ -313,11 +320,19 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Point CMake to the toolchain file.
|
# Point CMake to the toolchain file.
|
||||||
cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=cmake/$toolchain.cmake\""
|
[ -e "cmake/$toolchain.cmake" ] && cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=cmake/$toolchain.cmake\""
|
||||||
elif is_mac
|
elif is_mac
|
||||||
then
|
then
|
||||||
# macOS lacks nproc, but sysctl can do the same job.
|
# macOS lacks nproc, but sysctl can do the same job.
|
||||||
alias nproc='sysctl -n hw.logicalcpu'
|
alias nproc='sysctl -n hw.logicalcpu'
|
||||||
|
|
||||||
|
# Install dependencies.
|
||||||
|
echo [-] Installing dependencies through MacPorts
|
||||||
|
sudo port selfupdate
|
||||||
|
sudo port install $(cat .ci/dependencies_macports.txt)
|
||||||
|
|
||||||
|
# Point CMake to the toolchain file.
|
||||||
|
[ -e "cmake/$toolchain.cmake" ] && cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=cmake/$toolchain.cmake\""
|
||||||
else
|
else
|
||||||
# Determine Debian architecture.
|
# Determine Debian architecture.
|
||||||
case $arch in
|
case $arch in
|
||||||
@@ -350,18 +365,18 @@ else
|
|||||||
[ $length -gt $longest_libpkg ] && longest_libpkg=$length
|
[ $length -gt $longest_libpkg ] && longest_libpkg=$length
|
||||||
done
|
done
|
||||||
|
|
||||||
# Determine GNU toolchain architecture.
|
# Determine toolchain architecture triplet.
|
||||||
case $arch in
|
case $arch in
|
||||||
x86) arch_gnu="i686-linux-gnu";;
|
x86) arch_triplet="i686-linux-gnu";;
|
||||||
arm32) arch_gnu="arm-linux-gnueabihf";;
|
arm32) arch_triplet="arm-linux-gnueabihf";;
|
||||||
arm64) arch_gnu="aarch64-linux-gnu";;
|
arm64) arch_triplet="aarch64-linux-gnu";;
|
||||||
*) arch_gnu="$arch-linux-gnu";;
|
*) arch_triplet="$arch-linux-gnu";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Determine library directory name for this architecture.
|
# Determine library directory name for this architecture.
|
||||||
case $arch in
|
case $arch in
|
||||||
x86) libdir="i386-linux-gnu";;
|
x86) libdir="i386-linux-gnu";;
|
||||||
*) libdir="$arch_gnu";;
|
*) libdir="$arch_triplet";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Create CMake toolchain file.
|
# Create CMake toolchain file.
|
||||||
@@ -369,15 +384,15 @@ else
|
|||||||
set(CMAKE_SYSTEM_NAME Linux)
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
set(CMAKE_SYSTEM_PROCESSOR $arch)
|
set(CMAKE_SYSTEM_PROCESSOR $arch)
|
||||||
|
|
||||||
set(CMAKE_AR $arch_gnu-ar)
|
set(CMAKE_AR $arch_triplet-ar)
|
||||||
set(CMAKE_ASM_COMPILER $arch_gnu-gcc)
|
set(CMAKE_ASM_COMPILER $arch_triplet-gcc)
|
||||||
set(CMAKE_C_COMPILER $arch_gnu-gcc)
|
set(CMAKE_C_COMPILER $arch_triplet-gcc)
|
||||||
set(CMAKE_CXX_COMPILER $arch_gnu-g++)
|
set(CMAKE_CXX_COMPILER $arch_triplet-g++)
|
||||||
set(CMAKE_LINKER $arch_gnu-ld)
|
set(CMAKE_LINKER $arch_triplet-ld)
|
||||||
set(CMAKE_OBJCOPY $arch_gnu-objcopy)
|
set(CMAKE_OBJCOPY $arch_triplet-objcopy)
|
||||||
set(CMAKE_RANLIB $arch_gnu-ranlib)
|
set(CMAKE_RANLIB $arch_triplet-ranlib)
|
||||||
set(CMAKE_SIZE $arch_gnu-size)
|
set(CMAKE_SIZE $arch_triplet-size)
|
||||||
set(CMAKE_STRIP $arch_gnu-strip)
|
set(CMAKE_STRIP $arch_triplet-strip)
|
||||||
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
@@ -389,7 +404,7 @@ set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/$libdir/pkgconfig:/usr/share/$libdir/pkgcon
|
|||||||
include("$(pwd)/cmake/$toolchain.cmake")
|
include("$(pwd)/cmake/$toolchain.cmake")
|
||||||
EOF
|
EOF
|
||||||
cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake"
|
cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake"
|
||||||
strip_binary="$arch_gnu-strip"
|
strip_binary="$arch_triplet-strip"
|
||||||
|
|
||||||
# Install or update dependencies.
|
# Install or update dependencies.
|
||||||
echo [-] Installing dependencies through apt
|
echo [-] Installing dependencies through apt
|
||||||
@@ -524,8 +539,21 @@ then
|
|||||||
fi
|
fi
|
||||||
elif is_mac
|
elif is_mac
|
||||||
then
|
then
|
||||||
# TBD
|
# Archive app bundle with libraries.
|
||||||
:
|
cmake_flags_install=
|
||||||
|
[ $strip -ne 0 ] && cmake_flags_install="$cmake_flags_install --strip"
|
||||||
|
cmake --install build --prefix "$(pwd)/archive_tmp" $cmake_flags_install
|
||||||
|
status=$?
|
||||||
|
|
||||||
|
if [ $status -eq 0 ]
|
||||||
|
then
|
||||||
|
# Archive Discord Game SDK library.
|
||||||
|
unzip discord_game_sdk.zip "lib/$arch_discord/discord_game_sdk.dylib" -d "archive_tmp/"*".app/Contents/Frameworks"
|
||||||
|
[ ! -e "archive_tmp/"*".app/Contents/Frameworks/discord_game_sdk.dylib" ] && echo [!] No Discord Game SDK for architecture [$arch_discord]
|
||||||
|
|
||||||
|
# Sign app bundle.
|
||||||
|
codesign --force --deep -s - "archive_tmp/"*".app"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
cwd_root=$(pwd)
|
cwd_root=$(pwd)
|
||||||
|
|
||||||
@@ -643,8 +671,10 @@ then
|
|||||||
status=$?
|
status=$?
|
||||||
elif is_mac
|
elif is_mac
|
||||||
then
|
then
|
||||||
# TBD
|
# Create zip. (TODO: dmg)
|
||||||
:
|
cd archive_tmp
|
||||||
|
zip -r "$cwd/$package_name.zip" .
|
||||||
|
status=$?
|
||||||
else
|
else
|
||||||
# Determine AppImage runtime architecture.
|
# Determine AppImage runtime architecture.
|
||||||
case $arch in
|
case $arch in
|
||||||
|
Reference in New Issue
Block a user