From ece2f622e89650b1772e6b5b809bdea06d0d52e5 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 31 Dec 2018 02:43:27 +0100 Subject: [PATCH] Improve meson build setup --- build-package.sh | 114 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 37 deletions(-) diff --git a/build-package.sh b/build-package.sh index 7fe5d7c7b..2b1c214bf 100755 --- a/build-package.sh +++ b/build-package.sh @@ -132,7 +132,7 @@ termux_setup_ninja() { # Utility function to setup a current meson build system. termux_setup_meson() { termux_setup_ninja - local MESON_VERSION=0.48.0 + local MESON_VERSION=0.49.0 local MESON_FOLDER=$TERMUX_COMMON_CACHEDIR/meson-$MESON_VERSION-v1 if [ ! -d "$MESON_FOLDER" ]; then local MESON_TAR_NAME=meson-$MESON_VERSION.tar.gz @@ -141,47 +141,87 @@ termux_setup_meson() { termux_download \ "https://github.com/mesonbuild/meson/releases/download/$MESON_VERSION/meson-$MESON_VERSION.tar.gz" \ "$MESON_TAR_FILE" \ - 982937ba5b380abe13f3a0c4dff944dd19d08b72870e3b039f5037c91f82835f + fb0395c4ac208eab381cd1a20571584bdbba176eb562a7efa9cb17cace0e1551 tar xf "$MESON_TAR_FILE" -C "$TERMUX_PKG_TMPDIR" mv "$MESON_TMP_FOLDER" "$MESON_FOLDER" fi TERMUX_MESON="$MESON_FOLDER/meson.py" - TERMUX_MESON_CROSSFILE=$TERMUX_COMMON_CACHEDIR/meson-crossfile-$TERMUX_ARCH-v2.txt - if [ ! -f "$TERMUX_MESON_CROSSFILE" ]; then - local MESON_CPU MESON_CPU_FAMILY - if [ "$TERMUX_ARCH" = "arm" ]; then - MESON_CPU_FAMILY="arm" - MESON_CPU="armv7" - elif [ "$TERMUX_ARCH" = "i686" ]; then - MESON_CPU_FAMILY="x86" - MESON_CPU="i686" - elif [ "$TERMUX_ARCH" = "x86_64" ]; then - MESON_CPU_FAMILY="x86_64" - MESON_CPU="x86_64" - elif [ "$TERMUX_ARCH" = "aarch64" ]; then - MESON_CPU_FAMILY="arm" - MESON_CPU="aarch64" - else - termux_error_exit "Unsupported arch: $TERMUX_ARCH" - fi - - cat > "$TERMUX_MESON_CROSSFILE" <<-HERE - [binaries] - ar = '$AR' - c = '$CC' - cpp = '$CXX' - ld = '$LD' - pkgconfig = '$PKG_CONFIG' - strip = '$STRIP' - [properties] - needs_exe_wrapper = true - [host_machine] - cpu_family = '$MESON_CPU_FAMILY' - cpu = '$MESON_CPU' - endian = 'little' - system = 'android' - HERE + TERMUX_MESON_CROSSFILE=$TERMUX_PKG_TMPDIR/meson-crossfile-$TERMUX_ARCH.txt + local MESON_CPU MESON_CPU_FAMILY + if [ "$TERMUX_ARCH" = "arm" ]; then + MESON_CPU_FAMILY="arm" + MESON_CPU="armv7" + elif [ "$TERMUX_ARCH" = "i686" ]; then + MESON_CPU_FAMILY="x86" + MESON_CPU="i686" + elif [ "$TERMUX_ARCH" = "x86_64" ]; then + MESON_CPU_FAMILY="x86_64" + MESON_CPU="x86_64" + elif [ "$TERMUX_ARCH" = "aarch64" ]; then + MESON_CPU_FAMILY="arm" + MESON_CPU="aarch64" + else + termux_error_exit "Unsupported arch: $TERMUX_ARCH" fi + + local CONTENT="" + echo "[binaries]" > $TERMUX_MESON_CROSSFILE + echo "ar = '$AR'" >> $TERMUX_MESON_CROSSFILE + echo "c = '$CC'" >> $TERMUX_MESON_CROSSFILE + echo "cpp = '$CXX'" >> $TERMUX_MESON_CROSSFILE + echo "ld = '$LD'" >> $TERMUX_MESON_CROSSFILE + echo "pkgconfig = '$PKG_CONFIG'" >> $TERMUX_MESON_CROSSFILE + echo "strip = '$STRIP'" >> $TERMUX_MESON_CROSSFILE + + echo '' >> $TERMUX_MESON_CROSSFILE + echo "[properties]" >> $TERMUX_MESON_CROSSFILE + echo "needs_exe_wrapper = true" >> $TERMUX_MESON_CROSSFILE + + echo -n "c_args = [" >> $TERMUX_MESON_CROSSFILE + local word first=true + for word in $CFLAGS $CPPFLAGS; do + if [ "$first" = "true" ]; then + first=false + else + echo -n ", " >> $TERMUX_MESON_CROSSFILE + fi + echo -n "'$word'" >> $TERMUX_MESON_CROSSFILE + done + echo ']' >> $TERMUX_MESON_CROSSFILE + + echo -n "cpp_args = [" >> $TERMUX_MESON_CROSSFILE + local word first=true + for word in $CXXFLAGS $CPPFLAGS; do + if [ "$first" = "true" ]; then + first=false + else + echo -n ", " >> $TERMUX_MESON_CROSSFILE + fi + echo -n "'$word'" >> $TERMUX_MESON_CROSSFILE + done + echo ']' >> $TERMUX_MESON_CROSSFILE + + local property + for property in c_link_args cpp_link_args; do + echo -n "$property = [" >> $TERMUX_MESON_CROSSFILE + first=true + for word in $LDFLAGS; do + if [ "$first" = "true" ]; then + first=false + else + echo -n ", " >> $TERMUX_MESON_CROSSFILE + fi + echo -n "'$word'" >> $TERMUX_MESON_CROSSFILE + done + echo ']' >> $TERMUX_MESON_CROSSFILE + done + + echo '' >> $TERMUX_MESON_CROSSFILE + echo "[host_machine]" >> $TERMUX_MESON_CROSSFILE + echo "cpu_family = '$MESON_CPU_FAMILY'" >> $TERMUX_MESON_CROSSFILE + echo "cpu = '$MESON_CPU'" >> $TERMUX_MESON_CROSSFILE + echo "endian = 'little'" >> $TERMUX_MESON_CROSSFILE + echo "system = 'android'" >> $TERMUX_MESON_CROSSFILE } # Utility function to setup a current cmake build system