From b5a494ad3aace2e1d830a0619de56f404c6be0f0 Mon Sep 17 00:00:00 2001 From: richardg867 Date: Tue, 26 Jul 2022 20:55:58 -0300 Subject: [PATCH] Jenkins: Fix toolchain file path when reusing libraries --- .ci/build.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.ci/build.sh b/.ci/build.sh index 1e62fab96..b5edae736 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -230,6 +230,7 @@ case $arch in *) toolchain="$toolchain_prefix-$arch";; esac [ ! -e "cmake/$toolchain.cmake" ] && toolchain=flags-gcc +toolchain_file="cmake/$toolchain.cmake" # Perform platform-specific setup. strip_binary=strip @@ -380,9 +381,6 @@ then else echo [-] Not installing dependencies again 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 then # macOS lacks nproc, but sysctl can do the same job. @@ -577,9 +575,6 @@ then echo [-] Not installing dependencies again 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 # Determine Debian architecture. case $arch in @@ -634,8 +629,12 @@ else *) libdir="$arch_triplet";; esac - # Create CMake toolchain file. - cat << EOF > toolchain.cmake + # Create CMake cross toolchain file. The file is saved on a fixed location for + # 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_PROCESSOR $arch) @@ -656,9 +655,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(ENV{PKG_CONFIG_PATH} "") set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/$libdir/pkgconfig:/usr/share/$libdir/pkgconfig") -include("$(pwd)/cmake/$toolchain.cmake") +include("$(realpath "$toolchain_file")") EOF - cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake" + toolchain_file="$toolchain_file_new" strip_binary="$arch_triplet-strip" # 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" fi +# Point CMake to the toolchain file. +[ -e "$toolchain_file" ] && cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=$toolchain_file\"" + # Clean workspace. echo [-] Cleaning workspace 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" fi 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 --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" fi 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 --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" fi 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 --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_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 cmake --build "$prefix_build" -j$(nproc) || exit 99 cmake --install "$prefix_build" || exit 99