Adapt build script to the new new Jenkins pipeline
This commit is contained in:
422
.ci/build.sh
422
.ci/build.sh
@@ -33,6 +33,7 @@
|
|||||||
# - TBD
|
# - TBD
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Define common functions.
|
||||||
alias is_windows='[ ! -z "$MSYSTEM" ]'
|
alias is_windows='[ ! -z "$MSYSTEM" ]'
|
||||||
alias is_mac='uname -s | grep -q Darwin'
|
alias is_mac='uname -s | grep -q Darwin'
|
||||||
|
|
||||||
@@ -104,40 +105,84 @@ make_tar() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
# Set common variables.
|
||||||
# Create a line gap between builds.
|
project=86Box
|
||||||
[ $first_build -eq 0 ] && echo
|
cwd=$(pwd)
|
||||||
first_build=0
|
|
||||||
|
|
||||||
# Set argument and environment variables.
|
# Parse arguments.
|
||||||
local job_name=$JOB_BASE_NAME
|
package_name=
|
||||||
local build_type=$BUILD_TYPE
|
arch=
|
||||||
local git_hash=$(echo $GIT_COMMIT | cut -c1-8)
|
tarball_name=
|
||||||
local arch=$1
|
while [ $# -gt 0 ]
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
-b)
|
||||||
shift
|
shift
|
||||||
local cmake_flags=$*
|
package_name="$1"
|
||||||
local cmake_flags_extra=
|
shift
|
||||||
|
arch="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
# Check if at least the job name was received.
|
-s)
|
||||||
if [ -z "$job_name" ]
|
shift
|
||||||
|
tarball_name="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
cmake_flags=$*
|
||||||
|
cmake_flags_extra=
|
||||||
|
|
||||||
|
# Check if mandatory arguments were specified.
|
||||||
|
if [ -z "$package_name" -a -z "$tarball_name" ]
|
||||||
then
|
then
|
||||||
echo [!] Missing environment variables: received JOB_BASE_NAME=[$JOB_BASE_NAME] BUILD_TYPE=[$BUILD_TYPE] BUILD_NUMBER=[$BUILD_NUMBER] GIT_COMMIT=[$GIT_COMMIT]
|
echo '[!] Usage: build.sh -b {package_name} {architecture} [cmake_flags...]'
|
||||||
job_status=1
|
echo ' build.sh -s {source_tarball_name}'
|
||||||
return 1
|
exit 100
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo [-] Building [$job_name] [$build_type] [$build_qualifier] [$git_hash] for [$arch] with flags [$cmake_flags]
|
|
||||||
|
|
||||||
# Switch to the correct directory.
|
# Switch to the correct directory.
|
||||||
cd "$cwd"
|
|
||||||
[ -e "build.sh" ] && cd ..
|
[ -e "build.sh" ] && cd ..
|
||||||
|
|
||||||
|
# Make source tarball if requested.
|
||||||
|
if [ ! -z "$tarball_name" ]
|
||||||
|
then
|
||||||
|
echo [-] Making source tarball [$tarball_name]
|
||||||
|
|
||||||
|
# Clean local tree of gitignored files.
|
||||||
|
git clean -dfX
|
||||||
|
|
||||||
|
# Save current HEAD commit to VERSION.
|
||||||
|
git log --stat -1 > VERSION || rm -f VERSION
|
||||||
|
|
||||||
|
# Archive source.
|
||||||
|
make_tar $tarball_name.tar
|
||||||
|
status=$?
|
||||||
|
|
||||||
|
# Check if the archival succeeded.
|
||||||
|
if [ $status -ne 0 ]
|
||||||
|
then
|
||||||
|
echo [!] Tarball creation failed with status [$status]
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo [-] Source tarball [$tarball_name] created successfully
|
||||||
|
[ -z "$package_name" ] && exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo [-] Building [$package_name] for [$arch] with flags [$cmake_flags]
|
||||||
|
|
||||||
# Perform platform-specific setup.
|
# Perform platform-specific setup.
|
||||||
if is_windows
|
if is_windows
|
||||||
then
|
then
|
||||||
# Switch into the correct MSYSTEM if required.
|
# Switch into the correct MSYSTEM if required.
|
||||||
local msys=MINGW$arch
|
msys=MINGW$arch
|
||||||
[ ! -d "/$msys" ] && local msys=CLANG$arch
|
[ ! -d "/$msys" ] && msys=CLANG$arch
|
||||||
if [ -d "/$msys" ]
|
if [ -d "/$msys" ]
|
||||||
then
|
then
|
||||||
if [ "$MSYSTEM" != "$msys" ]
|
if [ "$MSYSTEM" != "$msys" ]
|
||||||
@@ -145,14 +190,12 @@ build() {
|
|||||||
# Call build with the correct MSYSTEM.
|
# Call build with the correct MSYSTEM.
|
||||||
echo [-] Switching to MSYSTEM [$msys]
|
echo [-] Switching to MSYSTEM [$msys]
|
||||||
cd "$cwd"
|
cd "$cwd"
|
||||||
CHERE_INVOKING=yes MSYSTEM="$msys" JOB_BASE_NAME="$JOB_BASE_NAME" BUILD_TYPE="$BUILD_TYPE" BUILD_NUMBER="$BUILD_NUMBER" GIT_COMMIT="$GIT_COMMIT" \
|
CHERE_INVOKING=yes MSYSTEM="$msys" bash -lc 'exec "'"$0"'" -b "'"$package_name"'" "'"$arch"'" '"$cmake_flags"
|
||||||
bash -lc 'exec "'$0'" -b "'$arch'" '"$cmake_flags"
|
exit $?
|
||||||
return $?
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo [!] No MSYSTEM for architecture [$arch]
|
echo [!] No MSYSTEM for architecture [$arch]
|
||||||
job_status=1
|
exit 2
|
||||||
return 2
|
|
||||||
fi
|
fi
|
||||||
echo [-] Using MSYSTEM [$MSYSTEM]
|
echo [-] Using MSYSTEM [$MSYSTEM]
|
||||||
elif is_mac
|
elif is_mac
|
||||||
@@ -162,36 +205,36 @@ build() {
|
|||||||
else
|
else
|
||||||
# Determine Debian architecture.
|
# Determine Debian architecture.
|
||||||
case $arch in
|
case $arch in
|
||||||
x86) local arch_deb="i386";;
|
x86) arch_deb="i386";;
|
||||||
x86_64) local arch_deb="amd64";;
|
x86_64) arch_deb="amd64";;
|
||||||
arm32) local arch_deb="armhf";;
|
arm32) arch_deb="armhf";;
|
||||||
*) local arch_deb="$arch";;
|
*) arch_deb="$arch";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Establish general and architecture-specific dependencies.
|
# Establish general and architecture-specific dependencies.
|
||||||
local pkgs="cmake git tar xz-utils dpkg-dev rpm"
|
pkgs="cmake git tar xz-utils dpkg-dev rpm"
|
||||||
if [ "$(dpkg --print-architecture)" = "$arch_deb" ]
|
if [ "$(dpkg --print-architecture)" = "$arch_deb" ]
|
||||||
then
|
then
|
||||||
local pkgs="$pkgs build-essential"
|
pkgs="$pkgs build-essential"
|
||||||
else
|
else
|
||||||
sudo dpkg --add-architecture $arch_deb
|
sudo dpkg --add-architecture $arch_deb
|
||||||
local pkgs="$pkgs crossbuild-essential-$arch_deb"
|
pkgs="$pkgs crossbuild-essential-$arch_deb"
|
||||||
fi
|
fi
|
||||||
local libpkgs=""
|
libpkgs=""
|
||||||
local longest_libpkg=0
|
longest_libpkg=0
|
||||||
for pkg in libc6-dev linux-libc-dev libopenal-dev libfreetype6-dev libsdl2-dev libpng-dev
|
for pkg in libc6-dev linux-libc-dev libopenal-dev libfreetype6-dev libsdl2-dev libpng-dev
|
||||||
do
|
do
|
||||||
local libpkgs="$libpkgs $pkg:$arch_deb"
|
libpkgs="$libpkgs $pkg:$arch_deb"
|
||||||
local length=$(echo -n $pkg | sed 's/-dev$//g' | wc -c)
|
length=$(echo -n $pkg | sed 's/-dev$//g' | wc -c)
|
||||||
[ $length -gt $longest_libpkg ] && longest_libpkg=$length
|
[ $length -gt $longest_libpkg ] && longest_libpkg=$length
|
||||||
done
|
done
|
||||||
|
|
||||||
# Determine GNU toolchain architecture.
|
# Determine GNU toolchain architecture.
|
||||||
case $arch in
|
case $arch in
|
||||||
x86) local arch_gnu="i686-linux-gnu";;
|
x86) arch_gnu="i686-linux-gnu";;
|
||||||
arm32) local arch_gnu="arm-linux-gnueabihf";;
|
arm32) arch_gnu="arm-linux-gnueabihf";;
|
||||||
arm64) local arch_gnu="aarch64-linux-gnu";;
|
arm64) arch_gnu="aarch64-linux-gnu";;
|
||||||
*) local arch_gnu="$arch-linux-gnu";;
|
*) arch_gnu="$arch-linux-gnu";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Create CMake toolchain file.
|
# Create CMake toolchain file.
|
||||||
@@ -213,7 +256,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
EOF
|
EOF
|
||||||
local cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake"
|
cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake"
|
||||||
|
|
||||||
# Install or update dependencies.
|
# Install or update dependencies.
|
||||||
echo [-] Installing dependencies through apt
|
echo [-] Installing dependencies through apt
|
||||||
@@ -228,46 +271,38 @@ EOF
|
|||||||
rm -rf build
|
rm -rf build
|
||||||
find . \( -name Makefile -o -name CMakeCache.txt -o -name CMakeFiles \) -exec rm -rf "{}" \; 2> /dev/null
|
find . \( -name Makefile -o -name CMakeCache.txt -o -name CMakeFiles \) -exec rm -rf "{}" \; 2> /dev/null
|
||||||
|
|
||||||
# Determine available dynarec types for this architecture, and
|
# Determine ARCH to skip the arch_detect process.
|
||||||
# also specify ARCH right away to skip the arch_detect process.
|
|
||||||
case $arch in
|
case $arch in
|
||||||
# old dynarec available
|
32 | x86) cmake_flags_extra="$cmake_flags_extra -D ARCH=i386";;
|
||||||
32 | x86) local cmake_flags_extra="$cmake_flags_extra -D ARCH=i386";;
|
64 | x86_64) cmake_flags_extra="$cmake_flags_extra -D ARCH=x86_64";;
|
||||||
64 | x86_64) local cmake_flags_extra="$cmake_flags_extra -D ARCH=x86_64";;
|
ARM32 | arm32) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm";;
|
||||||
# new dynarec only
|
ARM64 | arm64) cmake_flags_extra="$cmake_flags_extra -D ARCH=arm64";;
|
||||||
ARM32 | arm32) local cmake_flags_extra="$cmake_flags_extra -D NEW_DYNAREC=ON -D ARCH=arm";;
|
*) cmake_flags_extra="$cmake_flags_extra -D ARCH=$arch";;
|
||||||
ARM64 | arm64) local cmake_flags_extra="$cmake_flags_extra -D NEW_DYNAREC=ON -D ARCH=arm64";;
|
|
||||||
# no dynarec
|
|
||||||
*) local cmake_flags_extra="$cmake_flags_extra -D DYNAREC=OFF";;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Determine additional CMake flags.
|
# Add git hash and copyright year.
|
||||||
[ ! -z "$build_type" ] && local cmake_flags_extra="$cmake_flags_extra -D BUILD_TYPE=\"$build_type\""
|
git_hash="$(git rev-parse --short HEAD 2> /dev/null)"
|
||||||
[ ! -z "$build_qualifier" ] && local cmake_flags_extra="$cmake_flags_extra -D EMU_BUILD=\"$build_qualifier\""
|
[ ! -z "$git_hash" ] && cmake_flags_extra="$cmake_flags_extra -D EMU_GIT_HASH=\"$git_hash\""
|
||||||
[ ! -z "$build_number" ] && local cmake_flags_extra="$cmake_flags_extra -D EMU_BUILD_NUM=\"$build_number\""
|
cmake_flags_extra="$cmake_flags_extra -D EMU_COPYRIGHT_YEAR=\"$(date +%Y)\""
|
||||||
[ ! -z "$git_hash" ] && local cmake_flags_extra="$cmake_flags_extra -D EMU_GIT_HASH=\"$git_hash\""
|
|
||||||
local cmake_flags_extra="$cmake_flags_extra -D EMU_COPYRIGHT_YEAR=\"$(date +%Y)\""
|
|
||||||
|
|
||||||
# Run CMake.
|
# Run CMake.
|
||||||
echo [-] Running CMake with flags [$cmake_flags $cmake_flags_extra]
|
echo [-] Running CMake with flags [$cmake_flags $cmake_flags_extra]
|
||||||
eval cmake -G \"Unix Makefiles\" $cmake_flags $cmake_flags_extra .
|
eval cmake -G \"Unix Makefiles\" $cmake_flags $cmake_flags_extra .
|
||||||
local status=$?
|
status=$?
|
||||||
if [ $? -gt 0 ]
|
if [ $status -ne 0 ]
|
||||||
then
|
then
|
||||||
echo [!] CMake failed with status [$status]
|
echo [!] CMake failed with status [$status]
|
||||||
job_status=1
|
exit 3
|
||||||
return 3
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run actual build.
|
# Run actual build.
|
||||||
echo [-] Running build
|
echo [-] Running build
|
||||||
try_make
|
try_make
|
||||||
local status=$?
|
status=$?
|
||||||
if [ $status -gt 0 ]
|
if [ $status -ne 0 ]
|
||||||
then
|
then
|
||||||
echo [!] Make failed with status [$status]
|
echo [!] Make failed with status [$status]
|
||||||
job_status=1
|
exit 4
|
||||||
return 4
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create temporary directory for archival.
|
# Create temporary directory for archival.
|
||||||
@@ -277,19 +312,18 @@ EOF
|
|||||||
if [ ! -d "archive_tmp" ]
|
if [ ! -d "archive_tmp" ]
|
||||||
then
|
then
|
||||||
echo [!] Archive directory creation failed
|
echo [!] Archive directory creation failed
|
||||||
job_status=1
|
exit 5
|
||||||
return 5
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Archive the executable and its dependencies.
|
# Archive the executable and its dependencies.
|
||||||
# The executable should always be archived last for the check after this block.
|
# The executable should always be archived last for the check after this block.
|
||||||
local status=$?
|
status=0
|
||||||
if is_windows
|
if is_windows
|
||||||
then
|
then
|
||||||
# Determine Program Files directory for Ghostscript and 7-Zip.
|
# Determine Program Files directory for Ghostscript and 7-Zip.
|
||||||
# Manual checks because MSYS is bad at passing the ProgramFiles variables.
|
# Manual checks because MSYS is bad at passing the ProgramFiles variables.
|
||||||
local pf="/c/Program Files"
|
pf="/c/Program Files"
|
||||||
local sevenzip="$pf/7-Zip/7z.exe"
|
sevenzip="$pf/7-Zip/7z.exe"
|
||||||
[ "$arch" = "32" -a -d "/c/Program Files (x86)" ] && pf="/c/Program Files (x86)"
|
[ "$arch" = "32" -a -d "/c/Program Files (x86)" ] && pf="/c/Program Files (x86)"
|
||||||
|
|
||||||
# Archive freetype from local MSYS installation.
|
# Archive freetype from local MSYS installation.
|
||||||
@@ -302,9 +336,9 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Archive Discord Game SDK DLL from their CDN.
|
# Archive Discord Game SDK DLL from their CDN.
|
||||||
local discordarch=
|
discordarch=
|
||||||
[ "$arch" = "32" ] && local discordarch=x86
|
[ "$arch" = "32" ] && discordarch=x86
|
||||||
[ "$arch" = "64" ] && local discordarch=x86_64
|
[ "$arch" = "64" ] && discordarch=x86_64
|
||||||
if [ ! -z "$discordarch" ]
|
if [ ! -z "$discordarch" ]
|
||||||
then
|
then
|
||||||
[ ! -e "discord_game_sdk.zip" ] && wget -qOdiscord_game_sdk.zip https://dl-game-sdk.discordapp.net/2.5.6/discord_game_sdk.zip
|
[ ! -e "discord_game_sdk.zip" ] && wget -qOdiscord_game_sdk.zip https://dl-game-sdk.discordapp.net/2.5.6/discord_game_sdk.zip
|
||||||
@@ -316,7 +350,7 @@ EOF
|
|||||||
|
|
||||||
# Archive executable.
|
# Archive executable.
|
||||||
mv "$build_dir"/src/$project.exe archive_tmp/
|
mv "$build_dir"/src/$project.exe archive_tmp/
|
||||||
local status=$?
|
status=$?
|
||||||
elif is_mac
|
elif is_mac
|
||||||
then
|
then
|
||||||
# TBD
|
# TBD
|
||||||
@@ -335,15 +369,14 @@ EOF
|
|||||||
|
|
||||||
# Archive executable.
|
# Archive executable.
|
||||||
mv "$build_dir"/src/$project archive_tmp/
|
mv "$build_dir"/src/$project archive_tmp/
|
||||||
local status=$?
|
status=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the executable move succeeded.
|
# Check if the executable move succeeded.
|
||||||
if [ $status -gt 0 ]
|
if [ $status -ne 0 ]
|
||||||
then
|
then
|
||||||
echo [!] Executable move failed with status [$status]
|
echo [!] Executable move failed with status [$status]
|
||||||
job_status=1
|
exit 6
|
||||||
return 6
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Produce artifact archive.
|
# Produce artifact archive.
|
||||||
@@ -352,241 +385,26 @@ EOF
|
|||||||
if is_windows
|
if is_windows
|
||||||
then
|
then
|
||||||
# Create zip.
|
# Create zip.
|
||||||
"$sevenzip" a -y -mx9 "..\\$job_name-Windows-$arch$build_fn.zip" *
|
"$sevenzip" a -y -mx9 "..\\$package_name.zip" *
|
||||||
local status=$?
|
status=$?
|
||||||
elif is_mac
|
elif is_mac
|
||||||
then
|
then
|
||||||
# TBD
|
# TBD
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
# Create binary tarball.
|
# Create binary tarball.
|
||||||
VERBOSE=1 make_tar ../$job_name-Linux-$arch$build_fn.tar
|
VERBOSE=1 make_tar ../$package_name.tar
|
||||||
local status=$?
|
status=$?
|
||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Check if the archival succeeded.
|
# Check if the archival succeeded.
|
||||||
if [ $status -gt 0 ]
|
if [ $status -ne 0 ]
|
||||||
then
|
then
|
||||||
echo [!] Artifact archive creation failed with status [$status]
|
echo [!] Artifact archive creation failed with status [$status]
|
||||||
job_status=1
|
exit 7
|
||||||
return 7
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# All good.
|
# All good.
|
||||||
echo [-] Build of [$job_name] [$build_type] [$build_qualifier] [$git_hash] for [$arch] with flags [$cmake_flags] successful
|
echo [-] Build of [$package_name] for [$arch] with flags [$cmake_flags] successful
|
||||||
}
|
exit 0
|
||||||
|
|
||||||
tarball() {
|
|
||||||
# Create a line gap between builds.
|
|
||||||
[ $first_build -eq 0 ] && echo
|
|
||||||
first_build=0
|
|
||||||
|
|
||||||
# Set argument and environment variables.
|
|
||||||
local job_name=$JOB_BASE_NAME
|
|
||||||
|
|
||||||
# Check if the job name was received.
|
|
||||||
if [ -z "$job_name" ]
|
|
||||||
then
|
|
||||||
echo [!] Missing environment variable: received JOB_BASE_NAME=[$JOB_BASE_NAME]
|
|
||||||
job_status=1
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo [-] Making source tarball for [$job_name]
|
|
||||||
|
|
||||||
# Switch to the correct directory.
|
|
||||||
cd "$cwd"
|
|
||||||
[ -e "build.sh" ] && cd ..
|
|
||||||
|
|
||||||
# Clean local tree of gitignored files.
|
|
||||||
git clean -dfX
|
|
||||||
|
|
||||||
# Save current HEAD commit to VERSION.
|
|
||||||
git log -1 > VERSION || rm -f VERSION
|
|
||||||
|
|
||||||
# Archive source.
|
|
||||||
make_tar $job_name-Source$build_fn.tar
|
|
||||||
|
|
||||||
# Check if the archival succeeded.
|
|
||||||
if [ $? -gt 0 ]
|
|
||||||
then
|
|
||||||
echo [!] Tarball creation failed with status [$status]
|
|
||||||
job_status=1
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo [-] Source tarball for [$job_name] created successfully
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set common variables.
|
|
||||||
project=86Box
|
|
||||||
cwd=$(pwd)
|
|
||||||
first_build=1
|
|
||||||
job_status=0
|
|
||||||
|
|
||||||
# Parse arguments.
|
|
||||||
single_build=0
|
|
||||||
tarball=0
|
|
||||||
args=0
|
|
||||||
while [ $# -gt 0 ]
|
|
||||||
do
|
|
||||||
case $1 in
|
|
||||||
-b)
|
|
||||||
# Execute single build.
|
|
||||||
[ -z "$JOB_BASE_NAME" ] && JOB_BASE_NAME=$project-Custom
|
|
||||||
single_build=1
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
|
|
||||||
-t)
|
|
||||||
# Create tarball.
|
|
||||||
[ -z "$JOB_BASE_NAME" ] && JOB_BASE_NAME=$project
|
|
||||||
tarball=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
# Allow for manually specifying Jenkins variables.
|
|
||||||
if [ $args -eq 0 ]
|
|
||||||
then
|
|
||||||
JOB_BASE_NAME=$1
|
|
||||||
args=1
|
|
||||||
elif [ $args -eq 1 ]
|
|
||||||
then
|
|
||||||
BUILD_TYPE=$1
|
|
||||||
args=2
|
|
||||||
elif [ $args -eq 2 ]
|
|
||||||
then
|
|
||||||
BUILD_NUMBER=$1
|
|
||||||
args=3
|
|
||||||
elif [ $args -eq 3 ]
|
|
||||||
then
|
|
||||||
GIT_COMMIT=$1
|
|
||||||
args=4
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check if at least the job name was specified.
|
|
||||||
if [ -z "$JOB_BASE_NAME" ]
|
|
||||||
then
|
|
||||||
echo [!] Manual usage: build.sh [{job_name} [{build_type} [{build_number'|"'build_qualifier'"'} [git_hash]]]] [-t] [-b {architecture} [cmake_flags...]]
|
|
||||||
exit 100
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate build information. Note that variable names are case sensitive.
|
|
||||||
build_number=$BUILD_NUMBER
|
|
||||||
if echo $build_number | grep -q " "
|
|
||||||
then
|
|
||||||
# A full build qualifier was specified.
|
|
||||||
build_qualifier="$build_number"
|
|
||||||
build_fn="-"$(echo "$build_number" | rev | cut -f1 -d" " | rev | tr '\\/:*?"<>|' '_')
|
|
||||||
build_number= # no build number
|
|
||||||
elif [ ! -z "$build_number" ]
|
|
||||||
then
|
|
||||||
# A build number was specified.
|
|
||||||
build_qualifier="build $build_number"
|
|
||||||
build_fn="-b$build_number"
|
|
||||||
build_number=$(echo "$build_number" | sed "s/[^0-9]//g") # remove non-numeric characters from build number
|
|
||||||
else
|
|
||||||
# No build data was specified.
|
|
||||||
build_number=
|
|
||||||
build_qualifier=
|
|
||||||
build_fn=
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make tarball if requested.
|
|
||||||
if [ $tarball -ne 0 ]
|
|
||||||
then
|
|
||||||
tarball
|
|
||||||
status=$?
|
|
||||||
[ $single_build -eq 0 ] && exit $status
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run single build if requested.
|
|
||||||
if [ $single_build -ne 0 ]
|
|
||||||
then
|
|
||||||
build $*
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run builds according to the Jenkins job name.
|
|
||||||
case $JOB_BASE_NAME in
|
|
||||||
$project | $project-TestBuildPleaseIgnore*)
|
|
||||||
if is_windows
|
|
||||||
then
|
|
||||||
build 32 --preset=regular
|
|
||||||
build 64 --preset=regular
|
|
||||||
elif is_mac
|
|
||||||
then
|
|
||||||
build Universal --preset=regular
|
|
||||||
else
|
|
||||||
tarball
|
|
||||||
build x86 --preset=regular
|
|
||||||
build x86_64 --preset=regular
|
|
||||||
build arm32 --preset=regular
|
|
||||||
build arm64 --preset=regular
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
$project-Debug)
|
|
||||||
if is_windows
|
|
||||||
then
|
|
||||||
build 32 --preset=debug
|
|
||||||
build 64 --preset=debug
|
|
||||||
elif is_mac
|
|
||||||
then
|
|
||||||
build Universal --preset=debug
|
|
||||||
else
|
|
||||||
build x86 --preset=debug
|
|
||||||
build x86_64 --preset=debug
|
|
||||||
build arm32 --preset=debug
|
|
||||||
build arm64 --preset=debug
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
$project-Dev)
|
|
||||||
if is_windows
|
|
||||||
then
|
|
||||||
build 32 --preset=experimental -D NEW_DYNAREC=ON -D VNC=OFF
|
|
||||||
build 64 --preset=experimental -D NEW_DYNAREC=ON -D VNC=OFF
|
|
||||||
elif is_mac
|
|
||||||
then
|
|
||||||
build Universal --preset=experimental -D NEW_DYNAREC=ON -D VNC=OFF
|
|
||||||
else
|
|
||||||
build x86 --preset=experimental -D NEW_DYNAREC=ON -D VNC=OFF
|
|
||||||
build x86_64 --preset=experimental -D NEW_DYNAREC=ON -D VNC=OFF
|
|
||||||
build arm32 --preset=experimental -D NEW_DYNAREC=ON -D VNC=OFF
|
|
||||||
build arm64 --preset=experimental -D NEW_DYNAREC=ON -D VNC=OFF
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
$project-DevODR)
|
|
||||||
if is_windows
|
|
||||||
then
|
|
||||||
build 32 --preset=experimental -D NEW_DYNAREC=OFF -D VNC=OFF
|
|
||||||
build 64 --preset=experimental -D NEW_DYNAREC=OFF -D VNC=OFF
|
|
||||||
elif is_mac
|
|
||||||
then
|
|
||||||
build Universal --preset=experimental -D NEW_DYNAREC=OFF -D VNC=OFF
|
|
||||||
else
|
|
||||||
build x86 --preset=experimental -D NEW_DYNAREC=OFF -D VNC=OFF
|
|
||||||
build x86_64 --preset=experimental -D NEW_DYNAREC=OFF -D VNC=OFF
|
|
||||||
build arm32 --preset=experimental -D NEW_DYNAREC=OFF -D VNC=OFF
|
|
||||||
build arm64 --preset=experimental -D NEW_DYNAREC=OFF -D VNC=OFF
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo [!] Unknown job name $JOB_BASE_NAME
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo [-] Exiting with status [$job_status]
|
|
||||||
exit $job_status
|
|
||||||
|
|||||||
Reference in New Issue
Block a user