Jenkins: Fix toolchain file path when reusing libraries

This commit is contained in:
richardg867
2022-07-26 20:55:58 -03:00
committed by GitHub
parent c4cbd91678
commit b5a494ad3a

View File

@@ -230,6 +230,7 @@ case $arch in
*) toolchain="$toolchain_prefix-$arch";; *) toolchain="$toolchain_prefix-$arch";;
esac esac
[ ! -e "cmake/$toolchain.cmake" ] && toolchain=flags-gcc [ ! -e "cmake/$toolchain.cmake" ] && toolchain=flags-gcc
toolchain_file="cmake/$toolchain.cmake"
# Perform platform-specific setup. # Perform platform-specific setup.
strip_binary=strip strip_binary=strip
@@ -380,9 +381,6 @@ then
else else
echo [-] Not installing dependencies again echo [-] Not installing dependencies again
fi fi
# Point CMake to the toolchain file.
[ -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.
@@ -577,9 +575,6 @@ then
echo [-] Not installing dependencies again echo [-] Not installing dependencies again
fi fi
# 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
@@ -634,8 +629,12 @@ else
*) libdir="$arch_triplet";; *) libdir="$arch_triplet";;
esac esac
# Create CMake toolchain file. # Create CMake cross toolchain file. The file is saved on a fixed location for
cat << EOF > toolchain.cmake # the library builds we do later, since running CMake again on a library we've
# already built before will *not* update its toolchain file path; therefore, we
# cannot point them to our working directory, which may change across builds.
toolchain_file_new="$cache_dir/toolchain.$arch_deb.cmake"
cat << EOF > "$toolchain_file_new"
set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR $arch) set(CMAKE_SYSTEM_PROCESSOR $arch)
@@ -656,9 +655,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(ENV{PKG_CONFIG_PATH} "") set(ENV{PKG_CONFIG_PATH} "")
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/$libdir/pkgconfig:/usr/share/$libdir/pkgconfig") set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/$libdir/pkgconfig:/usr/share/$libdir/pkgconfig")
include("$(pwd)/cmake/$toolchain.cmake") include("$(realpath "$toolchain_file")")
EOF EOF
cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake" toolchain_file="$toolchain_file_new"
strip_binary="$arch_triplet-strip" strip_binary="$arch_triplet-strip"
# Install dependencies only if we're in a new build and/or architecture. # Install dependencies only if we're in a new build and/or architecture.
@@ -688,6 +687,9 @@ EOF
cmake_flags_extra="$cmake_flags_extra -D SLIRP_EXTERNAL=ON" cmake_flags_extra="$cmake_flags_extra -D SLIRP_EXTERNAL=ON"
fi fi
# Point CMake to the toolchain file.
[ -e "$toolchain_file" ] && cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=$toolchain_file\""
# Clean workspace. # Clean workspace.
echo [-] Cleaning workspace echo [-] Cleaning workspace
rm -rf build rm -rf build
@@ -864,7 +866,7 @@ else
wget -qO - https://github.com/kcat/openal-soft/archive/refs/tags/1.21.1.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix" wget -qO - https://github.com/kcat/openal-soft/archive/refs/tags/1.21.1.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix"
fi fi
prefix_build="$prefix/build-$arch_deb" prefix_build="$prefix/build-$arch_deb"
cmake -G Ninja -D "CMAKE_TOOLCHAIN_FILE=$cwd_root/toolchain.cmake" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99 cmake -G Ninja -D "CMAKE_TOOLCHAIN_FILE=$toolchain_file" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99
cmake --build "$prefix_build" -j$(nproc) || exit 99 cmake --build "$prefix_build" -j$(nproc) || exit 99
cmake --install "$prefix_build" || exit 99 cmake --install "$prefix_build" || exit 99
@@ -880,7 +882,7 @@ else
wget -qO - https://github.com/FNA-XNA/FAudio/archive/refs/tags/22.03.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix" wget -qO - https://github.com/FNA-XNA/FAudio/archive/refs/tags/22.03.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix"
fi fi
prefix_build="$prefix/build-$arch_deb" prefix_build="$prefix/build-$arch_deb"
cmake -G Ninja -D "CMAKE_TOOLCHAIN_FILE=$cwd_root/toolchain.cmake" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99 cmake -G Ninja -D "CMAKE_TOOLCHAIN_FILE=$toolchain_file" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99
cmake --build "$prefix_build" -j$(nproc) || exit 99 cmake --build "$prefix_build" -j$(nproc) || exit 99
cmake --install "$prefix_build" || exit 99 cmake --install "$prefix_build" || exit 99
@@ -900,7 +902,7 @@ else
wget -qO - https://github.com/thestk/rtmidi/archive/refs/tags/4.0.0.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix" wget -qO - https://github.com/thestk/rtmidi/archive/refs/tags/4.0.0.tar.gz | tar zxf - -C "$cache_dir" || rm -rf "$prefix"
fi fi
prefix_build="$prefix/build-$arch_deb" prefix_build="$prefix/build-$arch_deb"
cmake -G Ninja -D RTMIDI_API_JACK=OFF -D "CMAKE_TOOLCHAIN_FILE=$cwd_root/toolchain.cmake" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99 cmake -G Ninja -D RTMIDI_API_JACK=OFF -D "CMAKE_TOOLCHAIN_FILE=$toolchain_file" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" -S "$prefix" -B "$prefix_build" || exit 99
cmake --build "$prefix_build" -j$(nproc) || exit 99 cmake --build "$prefix_build" -j$(nproc) || exit 99
cmake --install "$prefix_build" || exit 99 cmake --install "$prefix_build" || exit 99
@@ -930,7 +932,7 @@ else
-D SDL_ATOMIC=OFF -D SDL_EVENTS=ON -D SDL_HAPTIC=OFF -D SDL_POWER=OFF -D SDL_THREADS=ON -D SDL_TIMERS=ON -D SDL_FILE=OFF \ -D SDL_ATOMIC=OFF -D SDL_EVENTS=ON -D SDL_HAPTIC=OFF -D SDL_POWER=OFF -D SDL_THREADS=ON -D SDL_TIMERS=ON -D SDL_FILE=OFF \
-D SDL_LOADSO=ON -D SDL_CPUINFO=ON -D SDL_FILESYSTEM=$sdl_ui -D SDL_DLOPEN=OFF -D SDL_SENSOR=OFF -D SDL_LOCALE=OFF \ -D SDL_LOADSO=ON -D SDL_CPUINFO=ON -D SDL_FILESYSTEM=$sdl_ui -D SDL_DLOPEN=OFF -D SDL_SENSOR=OFF -D SDL_LOCALE=OFF \
\ \
-D "CMAKE_TOOLCHAIN_FILE=$cwd_root/toolchain.cmake" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" \ -D "CMAKE_TOOLCHAIN_FILE=$toolchain_file" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" \
-S "$prefix" -B "$prefix_build" || exit 99 -S "$prefix" -B "$prefix_build" || exit 99
cmake --build "$prefix_build" -j$(nproc) || exit 99 cmake --build "$prefix_build" -j$(nproc) || exit 99
cmake --install "$prefix_build" || exit 99 cmake --install "$prefix_build" || exit 99