Improve Jenkins build flow, now with symbol stripping for regular builds
This commit is contained in:
2
.ci/Jenkinsfile
vendored
2
.ci/Jenkinsfile
vendored
@@ -73,7 +73,7 @@ def presetSlugs = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
def presetFlags = [
|
def presetFlags = [
|
||||||
'Regular': '--preset=regular',
|
'Regular': '-t --preset=regular',
|
||||||
'Debug': '--preset=debug',
|
'Debug': '--preset=debug',
|
||||||
'Dev': '--preset=experimental -D VNC=OFF'
|
'Dev': '--preset=experimental -D VNC=OFF'
|
||||||
]
|
]
|
||||||
|
83
.ci/build.sh
83
.ci/build.sh
@@ -37,28 +37,6 @@
|
|||||||
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'
|
||||||
|
|
||||||
try_make() {
|
|
||||||
# Try makefiles on two locations. I don't know what causes
|
|
||||||
# CMake to pick ./ instead of build/, but :worksonmymachine:
|
|
||||||
if [ -e "build/Makefile" ]
|
|
||||||
then
|
|
||||||
build_dir="$(pwd)/build"
|
|
||||||
cd build
|
|
||||||
make -j$(nproc) $*
|
|
||||||
local status=$?
|
|
||||||
cd ..
|
|
||||||
return $status
|
|
||||||
elif [ -e "Makefile" ]
|
|
||||||
then
|
|
||||||
build_dir="$(pwd)"
|
|
||||||
make -j$(nproc) $*
|
|
||||||
return $?
|
|
||||||
else
|
|
||||||
echo [!] No makefile found
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
make_tar() {
|
make_tar() {
|
||||||
# Install dependencies.
|
# Install dependencies.
|
||||||
if ! which tar xz > /dev/null 2>&1
|
if ! which tar xz > /dev/null 2>&1
|
||||||
@@ -113,6 +91,7 @@ cwd=$(pwd)
|
|||||||
package_name=
|
package_name=
|
||||||
arch=
|
arch=
|
||||||
tarball_name=
|
tarball_name=
|
||||||
|
strip=0
|
||||||
cmake_flags=
|
cmake_flags=
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
@@ -131,6 +110,11 @@ do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
-t)
|
||||||
|
shift
|
||||||
|
strip=1
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
if echo $1 | grep -q " "
|
if echo $1 | grep -q " "
|
||||||
then
|
then
|
||||||
@@ -153,7 +137,7 @@ cmake_flags_extra=
|
|||||||
# Check if mandatory arguments were specified.
|
# Check if mandatory arguments were specified.
|
||||||
if [ -z "$package_name" -a -z "$tarball_name" ] || [ ! -z "$package_name" -a -z "$arch" ]
|
if [ -z "$package_name" -a -z "$tarball_name" ] || [ ! -z "$package_name" -a -z "$arch" ]
|
||||||
then
|
then
|
||||||
echo '[!] Usage: build.sh -b {package_name} {architecture} [cmake_flags...]'
|
echo '[!] Usage: build.sh -b {package_name} {architecture} [-t] [cmake_flags...]'
|
||||||
echo ' build.sh -s {source_tarball_name}'
|
echo ' build.sh -s {source_tarball_name}'
|
||||||
exit 100
|
exit 100
|
||||||
fi
|
fi
|
||||||
@@ -193,6 +177,7 @@ fi
|
|||||||
echo [-] Building [$package_name] for [$arch] with flags [$cmake_flags]
|
echo [-] Building [$package_name] for [$arch] with flags [$cmake_flags]
|
||||||
|
|
||||||
# Perform platform-specific setup.
|
# Perform platform-specific setup.
|
||||||
|
strip_binary=strip
|
||||||
if is_windows
|
if is_windows
|
||||||
then
|
then
|
||||||
# Switch into the correct MSYSTEM if required.
|
# Switch into the correct MSYSTEM if required.
|
||||||
@@ -240,7 +225,7 @@ else
|
|||||||
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
|
||||||
libpkgs="$libpkgs $pkg:$arch_deb"
|
libpkgs="$libpkgs $pkg:$arch_deb"
|
||||||
length=$(echo -n $pkg | sed 's/-dev$//g' | wc -c)
|
length=$(echo -n $pkg | sed 's/-dev$//' | wc -c)
|
||||||
[ $length -gt $longest_libpkg ] && longest_libpkg=$length
|
[ $length -gt $longest_libpkg ] && longest_libpkg=$length
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -272,6 +257,7 @@ 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
|
||||||
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"
|
||||||
|
|
||||||
# Install or update dependencies.
|
# Install or update dependencies.
|
||||||
echo [-] Installing dependencies through apt
|
echo [-] Installing dependencies through apt
|
||||||
@@ -282,11 +268,14 @@ fi
|
|||||||
|
|
||||||
# Clean workspace.
|
# Clean workspace.
|
||||||
echo [-] Cleaning workspace
|
echo [-] Cleaning workspace
|
||||||
try_make clean > /dev/null
|
if [ -d "build" ]
|
||||||
|
then
|
||||||
|
MAKEFLAGS=-j$(nproc) cmake --build build --target clean 2> /dev/null
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
fi
|
||||||
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 ARCH to skip the arch_detect process.
|
# Add ARCH to skip the arch_detect process.
|
||||||
case $arch in
|
case $arch in
|
||||||
32 | x86) cmake_flags_extra="$cmake_flags_extra -D ARCH=i386";;
|
32 | x86) 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) cmake_flags_extra="$cmake_flags_extra -D ARCH=x86_64";;
|
||||||
@@ -295,7 +284,7 @@ case $arch in
|
|||||||
*) cmake_flags_extra="$cmake_flags_extra -D \"ARCH=$arch\"";;
|
*) cmake_flags_extra="$cmake_flags_extra -D \"ARCH=$arch\"";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Add git hash and copyright year.
|
# Add git hash.
|
||||||
git_hash=$(git rev-parse --short HEAD 2> /dev/null)
|
git_hash=$(git rev-parse --short HEAD 2> /dev/null)
|
||||||
if [ "$CI" = "true" ]
|
if [ "$CI" = "true" ]
|
||||||
then
|
then
|
||||||
@@ -307,11 +296,14 @@ then
|
|||||||
git diff --quiet 2> /dev/null || git_hash="$git_hash+"
|
git diff --quiet 2> /dev/null || git_hash="$git_hash+"
|
||||||
fi
|
fi
|
||||||
[ ! -z "$git_hash" ] && cmake_flags_extra="$cmake_flags_extra -D \"EMU_GIT_HASH=$git_hash\""
|
[ ! -z "$git_hash" ] && cmake_flags_extra="$cmake_flags_extra -D \"EMU_GIT_HASH=$git_hash\""
|
||||||
cmake_flags_extra="$cmake_flags_extra -D \"EMU_COPYRIGHT_YEAR=$(date +%Y)\""
|
|
||||||
|
# Add copyright year.
|
||||||
|
year=$(date +%Y)
|
||||||
|
[ ! -z "$year" ] && cmake_flags_extra="$cmake_flags_extra -D \"EMU_COPYRIGHT_YEAR=$year\""
|
||||||
|
|
||||||
# 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\" -B build $cmake_flags $cmake_flags_extra .
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status -ne 0 ]
|
if [ $status -ne 0 ]
|
||||||
then
|
then
|
||||||
@@ -320,8 +312,9 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run actual build.
|
# Run actual build.
|
||||||
echo [-] Running build
|
make_flags=-j$(nproc)
|
||||||
try_make
|
echo [-] Running build with make flags [$make_flags]
|
||||||
|
MAKEFLAGS=$make_flags cmake --build build
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status -ne 0 ]
|
if [ $status -ne 0 ]
|
||||||
then
|
then
|
||||||
@@ -370,11 +363,17 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Archive other DLLs from local directory.
|
# Archive other DLLs from local directory.
|
||||||
cp -p /home/$project/dll$arch/* archive_tmp/
|
cp -p "/home/$project/dll$arch/"* archive_tmp/
|
||||||
|
|
||||||
# Archive executable.
|
# Archive executable, while also stripping it if requested.
|
||||||
mv "$build_dir"/src/$project.exe archive_tmp/
|
if [ $strip -ne 0 ]
|
||||||
|
then
|
||||||
|
"$strip_binary" -o "archive_tmp/$project.exe" "build/src/$project.exe"
|
||||||
status=$?
|
status=$?
|
||||||
|
else
|
||||||
|
mv "build/src/$project.exe" "archive_tmp/$project.exe"
|
||||||
|
status=$?
|
||||||
|
fi
|
||||||
elif is_mac
|
elif is_mac
|
||||||
then
|
then
|
||||||
# TBD
|
# TBD
|
||||||
@@ -382,7 +381,7 @@ then
|
|||||||
else
|
else
|
||||||
# Archive readme with library package versions.
|
# Archive readme with library package versions.
|
||||||
echo Libraries used to compile this $arch build of $project: > archive_tmp/README
|
echo Libraries used to compile this $arch build of $project: > archive_tmp/README
|
||||||
dpkg-query -f '${Package} ${Version}\n' -W $libpkgs | sed "s/-dev / /g" | while IFS=" " read pkg version
|
dpkg-query -f '${Package} ${Version}\n' -W $libpkgs | sed "s/-dev / /" | while IFS=" " read pkg version
|
||||||
do
|
do
|
||||||
for i in $(seq $(expr $longest_libpkg - $(echo -n $pkg | wc -c)))
|
for i in $(seq $(expr $longest_libpkg - $(echo -n $pkg | wc -c)))
|
||||||
do
|
do
|
||||||
@@ -391,15 +390,21 @@ else
|
|||||||
echo $pkg $version >> archive_tmp/README
|
echo $pkg $version >> archive_tmp/README
|
||||||
done
|
done
|
||||||
|
|
||||||
# Archive executable.
|
# Archive executable, while also stripping it if requested.
|
||||||
mv "$build_dir"/src/$project archive_tmp/
|
if [ $strip -ne 0 ]
|
||||||
|
then
|
||||||
|
"$strip_binary" -o "archive_tmp/$project" "build/src/$project"
|
||||||
|
status=$?
|
||||||
|
else
|
||||||
|
mv "build/src/$project" "archive_tmp/$project"
|
||||||
status=$?
|
status=$?
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if the executable move succeeded.
|
# Check if the executable strip/move succeeded.
|
||||||
if [ $status -ne 0 ]
|
if [ $status -ne 0 ]
|
||||||
then
|
then
|
||||||
echo [!] Executable move failed with status [$status]
|
echo [!] Executable strip/move failed with status [$status]
|
||||||
exit 6
|
exit 6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user