mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-09 11:33:21 +02:00
macOS: fix qrencode build
Sometimes qrencode failed when built from Jenkins. This patch: - Uses cmake for build. - Automatically detect host architecture if none is specified. Change-Id: I18dc90099e3b9efc531c7887b00fc615f69c50fa
This commit is contained in:
parent
bfe9128755
commit
b69d703e56
1 changed files with 69 additions and 41 deletions
|
@ -1,9 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
# Flags:
|
# Usage:
|
||||||
|
# ./build_qrencode.sh -a <architecture>
|
||||||
# -a: architecture to build. Accepted values arm64, x86_64, unified
|
# Accepted architectures: arm64, x86_64, unified
|
||||||
|
# If no architecture is specified, the script builds for the host architecture.
|
||||||
|
|
||||||
|
# Initialize variables
|
||||||
arch=''
|
arch=''
|
||||||
while getopts "a:" OPT; do
|
while getopts "a:" OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
|
@ -11,51 +14,76 @@ while getopts "a:" OPT; do
|
||||||
arch="${OPTARG}"
|
arch="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
\?)
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
|
echo "Usage: $0 [-a architecture]"
|
||||||
|
echo "Accepted architectures: arm64, x86_64, unified"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Determine architectures to build
|
||||||
if [[ "$arch" == 'unified' ]]; then
|
if [[ "$arch" == 'unified' ]]; then
|
||||||
ARCHS=("arm64" "x86_64")
|
ARCHS=("arm64" "x86_64")
|
||||||
elif [[ "$arch" == '' ]]; then
|
elif [[ "$arch" == '' ]]; then
|
||||||
ARCHS=("arm64")
|
# Detect host architecture
|
||||||
|
HOST_ARCH=$(uname -m)
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
x86_64|arm64)
|
||||||
|
ARCHS=("$HOST_ARCH")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported host architecture: $HOST_ARCH"
|
||||||
|
echo "Supported architectures are: arm64, x86_64, unified"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
|
# Validate specified architecture
|
||||||
|
case "$arch" in
|
||||||
|
x86_64|arm64)
|
||||||
ARCHS=("$arch")
|
ARCHS=("$arch")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid architecture specified: $arch"
|
||||||
|
echo "Accepted architectures are: arm64, x86_64, unified"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TOP="$(pwd)"
|
TOP="$(pwd)"
|
||||||
QRENCODEDIR="${TOP}/3rdparty/libqrencode"
|
QRENCODEDIR="${TOP}/3rdparty/libqrencode"
|
||||||
if [ -z "$NPROC" ]; then
|
BUILDDIR="${QRENCODEDIR}/build-libqrencode"
|
||||||
NPROC=$(sysctl -n hw.ncpu || echo -n 1)
|
LIBDIR="${QRENCODEDIR}/lib"
|
||||||
fi
|
INCLUDEDIR="${QRENCODEDIR}/include"
|
||||||
|
|
||||||
for ARCH in "${ARCHS[@]}"; do
|
# Clean up build directory
|
||||||
cd "$QRENCODEDIR" || exit 1
|
echo "Preparing clean build directory"
|
||||||
BUILDDIR="$ARCH-libqrencode"
|
rm -rf "$BUILDDIR"
|
||||||
mkdir "$BUILDDIR"
|
mkdir -p "$BUILDDIR"
|
||||||
make clean
|
|
||||||
./autogen.sh
|
|
||||||
./configure --host="$ARCH" --without-png --prefix="${QRENCODEDIR}/${BUILDDIR}" CFLAGS=" -arch $ARCH $CFLAGS"
|
|
||||||
make -j"$NPROC"
|
|
||||||
make install
|
|
||||||
done
|
|
||||||
mkdir -p "$QRENCODEDIR"/lib
|
|
||||||
mkdir -p "$QRENCODEDIR"/include
|
|
||||||
|
|
||||||
if ((${#ARCHS[@]} == "2")); then
|
# Clean output directories
|
||||||
echo "Making fat lib for ${ARCHS[0]} and ${ARCHS[1]}"
|
rm -rf "$LIBDIR" "$INCLUDEDIR"
|
||||||
LIBFILES="$QRENCODEDIR/${ARCHS[0]}-libqrencode/lib/*.a"
|
mkdir -p "$LIBDIR"
|
||||||
for f in $LIBFILES; do
|
mkdir -p "$INCLUDEDIR"
|
||||||
libFile=${f##*/}
|
|
||||||
echo "$libFile"
|
|
||||||
lipo -create "$QRENCODEDIR/${ARCHS[0]}-libqrencode/lib/$libFile" \
|
|
||||||
"$QRENCODEDIR/${ARCHS[1]}-libqrencode/lib/$libFile" \
|
|
||||||
-output "${QRENCODEDIR}/lib/$libFile"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "No need for fat lib"
|
|
||||||
rsync -ar --delete "$QRENCODEDIR/${ARCHS[0]}-libqrencode/lib/"*.a "${QRENCODEDIR}/lib/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rsync -ar --delete "$QRENCODEDIR/${ARCHS[0]}-libqrencode/include/"* "${QRENCODEDIR}/include/"
|
# Convert architectures to semicolon-separated format for cmake
|
||||||
|
ARCHS_SEMICOLON_SEPARATED=$(IFS=";"; echo "${ARCHS[*]}")
|
||||||
|
|
||||||
|
echo "Configuring CMake for architectures: ${ARCHS[*]}"
|
||||||
|
cd "$BUILDDIR"
|
||||||
|
cmake "$QRENCODEDIR" \
|
||||||
|
-DCMAKE_OSX_ARCHITECTURES="$ARCHS_SEMICOLON_SEPARATED" \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="$QRENCODEDIR" \
|
||||||
|
-DWITHOUT_PNG=ON \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-G "Xcode"
|
||||||
|
|
||||||
|
echo "Building libqrencode for architectures: ${ARCHS[*]}"
|
||||||
|
cmake --build . --config Release
|
||||||
|
|
||||||
|
echo "Installing libqrencode to $LIBDIR and $INCLUDEDIR"
|
||||||
|
cmake --install . --config Release
|
||||||
|
|
||||||
|
echo "Build and installation completed successfully, with outputs in $LIBDIR and $INCLUDEDIR."
|
||||||
|
|
Loading…
Add table
Reference in a new issue