From f29215a167556f9c4faa04067ebca8e68b2b259d Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Fri, 1 Oct 2021 09:36:47 +0100 Subject: [PATCH] CI: Manually build & install SMPQ on Vita CI --- .circleci/build-and-install-smpq.sh | 42 +++++++++++++++++++++++++++++ .circleci/config.yml | 4 ++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 .circleci/build-and-install-smpq.sh diff --git a/.circleci/build-and-install-smpq.sh b/.circleci/build-and-install-smpq.sh new file mode 100755 index 000000000..ce452c73b --- /dev/null +++ b/.circleci/build-and-install-smpq.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +set -ex + +PARALLELISM="$(getconf _NPROCESSORS_ONLN)" +STORMLIB_VERSION=9.23 +STORMLIB_SRC="/tmp/stormlib-src-$STORMLIB_VERSION" +SMPQ_VERSION=1.6 +SMPQ_SRC="/tmp/smpq-src-$SMPQ_VERSION" + +# Download, build, and install the static version of StormLib, an SMPQ dependency, to the staging prefix. +if ! [ -d "$STORMLIB_SRC" ]; then + mkdir "$STORMLIB_SRC" + curl -L -s "https://github.com/ladislav-zezula/StormLib/tarball/v${STORMLIB_VERSION}" | tar -C "$STORMLIB_SRC" --strip-components=1 -xvzf - +fi + +cmake -S"$STORMLIB_SRC" -B"$STORMLIB_SRC"/build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/smpq-staging -DBUILD_SHARED_LIBS=OFF \ + -DWITH_STATIC=ON -DSTORM_BUILD_TESTS=OFF -DWITH_LIBTOMCRYPT=OFF +cmake --build "$STORMLIB_SRC"/build --config Release --target install -j"$PARALLELISM" + +# Download, build, and install SMPQ. +if ! [ -d "$SMPQ_SRC" ]; then + mkdir "$SMPQ_SRC" + curl -L -s "https://launchpad.net/smpq/trunk/${SMPQ_VERSION}/+download/smpq_${SMPQ_VERSION}.orig.tar.gz" | tar -C "$SMPQ_SRC" --strip-components=1 -xvzf - + + # StormLib.a is C++ and must be linked with a C++ linker (e.g. via g++ instead of gcc). + sed -i '/^project/a file(GLOB_RECURSE CFILES "${CMAKE_SOURCE_DIR}/*.c")\ +SET_SOURCE_FILES_PROPERTIES(${CFILES} PROPERTIES LANGUAGE CXX)' "$SMPQ_SRC"/CMakeLists.txt + + # StormLib is linked statically, so we need to add links its dynamic link dependencies to smpq itself. + sed -i 's|target_link_libraries(smpq ${STORMLIB_LIBRARY})|find_package(ZLIB REQUIRED)\ + find_package(BZip2 REQUIRED)\ + target_link_libraries(smpq ${STORMLIB_LIBRARY} ${ZLIB_LIBRARY} ${BZIP2_LIBRARIES})|' "$SMPQ_SRC"/CMakeLists.txt + + # Do not generate the manual. + sed -i 's|if(NOT CMAKE_CROSSCOMPILING)|if(FALSE)|' "$SMPQ_SRC"/CMakeLists.txt +fi + +# The StormLib version check in SMPQ CMake is broken. We bypass it by passing the paths to StormLib explicitly. +cmake -S"$SMPQ_SRC" -B"$SMPQ_SRC"/build -GNinja -DCMAKE_BUILD_TYPE=Release -DWITH_KDE=OFF -DCMAKE_PREFIX_PATH=/tmp/smpq-staging \ + -DSTORMLIB_INCLUDE_DIR=/tmp/smpq-staging/include -DSTORMLIB_LIBRARY=/tmp/smpq-staging/lib/libstorm.a +cmake --build "$SMPQ_SRC"/build --config Release --target install -j"$PARALLELISM" diff --git a/.circleci/config.yml b/.circleci/config.yml index 9a0351b91..1d39e1eab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,7 +85,9 @@ jobs: - checkout # Work around https://github.com/vitasdk/vdpm/issues/69 - run: mkdir -p /usr/local && ln -sf /home/user/vitasdk /usr/local/vitasdk - - run: apk --no-cache add git cmake ninja bash pkgconfig + # curl, zlib-dev, bzip2-dev, and build-base are only needed by build-and-install-smpq.sh + - run: apk --no-cache add git cmake ninja bash pkgconfig curl zlib-dev bzip2-dev build-base + - run: .circleci/build-and-install-smpq.sh - run: cmake -S. -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DNIGHTLY_BUILD=ON - run: cmake --build build -j 2 - store_artifacts: {path: ./build/devilutionx.vpk, destination: devilutionx.vpk}