summaryrefslogtreecommitdiff
path: root/sync-build.sh
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-02-14 11:02:00 +0100
committerPeter Wu <peter@lekensteyn.nl>2015-02-14 11:02:00 +0100
commitbf9521263ecbe1bd33bbc89a05073ca5680f327c (patch)
tree5c4724b128fca4a07c271665205697646165dc85 /sync-build.sh
parenta24c03ce96e383faf2a624bfabd5cc843e78ab2a (diff)
downloadwireshark-notes-bf9521263ecbe1bd33bbc89a05073ca5680f327c.tar.gz
sync-build.sh: cflags envvar tweaks
Default CXXFLAGS to CFLAGS (previously it would always use CFLAGS anyway due to a typo), do not require schroot, use 2*nproc instead of hardcoded 16 jobs. Document envvars.
Diffstat (limited to 'sync-build.sh')
-rwxr-xr-xsync-build.sh24
1 files changed, 19 insertions, 5 deletions
diff --git a/sync-build.sh b/sync-build.sh
index 9ad6585..a938644 100755
--- a/sync-build.sh
+++ b/sync-build.sh
@@ -18,8 +18,11 @@
# - buildhost defaults to wireshark-builder (you can use user@host)
# - Optional env vars:
# * CC, CXX, CFLAGS, CXXFLAGS - C/C++ compiler binary/flags
+# * CXXFLAGS - C++ compiler flags (defaults to CFLAGS)
+# * EXTRA_CFLAGS - Appended to CFLAGS
# * NOCOPY=1 - do not sync the generated binaries back
# * B32=1 - build 32-bit (using /usr/lib32)
+# * force_cmake - Set to non-empty to run cmake before make.
# LOCAL source dir (on non-volatile storage for reliability)
localsrcdir=$HOME/projects/wireshark/
@@ -46,9 +49,12 @@ CXX=${CXX:-c++}
# For clang, `-O1` (or `-g`?) seems necessary to get something other than
# "<optimized out>".
# -O1 -g -gdwarf-4 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
-_default_flags='-fsanitize=address -fsanitize=undefined -fdiagnostics-color=auto'
-CFLAGS=${CFLAGS:-$_default_flags}
-CXXFLAGS=${CFLAGS:-$_default_flags}
+_default_flags=\ -fsanitize=address
+_default_flags+=\ -fsanitize=undefined
+_default_flags+=\ -fdiagnostics-color=auto
+CFLAGS="${CFLAGS-$_default_flags}${EXTRA_CFLAGS:+ $EXTRA_CFLAGS}"
+# Default to use the same CXXFLAGS as CFLAGS (common case)
+CXXFLAGS="${CXXFLAGS-$CFLAGS}"
LIBDIR=/usr/lib
# Run with `B32=1 ./sync-build.sh` to build for multilib
@@ -69,7 +75,15 @@ fi
# ENABLE_QT5=1: install qt5-tools on Arch Linux
# 32-bit libs on Arch: lib32-libcap lib32-gnutls lib32-gtk3 lib32-krb5
# lib32-portaudio lib32-geoip lib32-libnl lib32-lua
-remotecmd="schroot -c chroot:arch -- sh -c '
+remotecmd="mysh() {
+ if [ -e /etc/arch-release ]; then
+ # In Arch root, so do a build
+ sh \"\$@\"
+ else
+ # Not in Arch root, so enter chroot to ensure matching libs
+ schroot -c chroot:arch -- sh \"\$@\";
+ fi
+}; mysh -c '
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl;
if $force_cmake || [ ! -e $builddir/CMakeCache.txt ]; then
mkdir -p $builddir && cd $builddir &&
@@ -96,7 +110,7 @@ if $force_cmake || [ ! -e $builddir/CMakeCache.txt ]; then
-DCMAKE_CXX_FLAGS=$(printf %q "$CXXFLAGS") \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
fi &&
-time make -C $builddir -j16
+time make -C $builddir -j\$((\$(nproc)*2))
'"