Extending meson build system to support fast compilation during development stage
Tested compilation against 3 build configurations
- with lto for src and tests/src (for release sw):
all: ~3 min; change in cpp file: ~2 min
- with lto for src and no_lto for tests/src (for release sw):
all: ~2 min; change in cpp file:~ 40 sec
- after using scripts/configure_fast_compilation.sh (for development only):
all: ~1.75 min; change in cpp file: ~20 sec
Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
Change-Id: Idf435d8455260d2d988cb7286d71401f21fd03e2
diff --git a/meson.build b/meson.build
index 0e36ac6..622043c 100644
--- a/meson.build
+++ b/meson.build
@@ -15,6 +15,9 @@
license: 'Apache-2.0',
)
+summary({'Fast build with link-time optimizer disabled':
+ not get_option('b_lto')}, section: 'General')
+
cpp = meson.get_compiler('cpp')
add_project_arguments(
cpp.get_supported_arguments([
diff --git a/scripts/configure_fast_compilation.sh b/scripts/configure_fast_compilation.sh
new file mode 100755
index 0000000..b737615
--- /dev/null
+++ b/scripts/configure_fast_compilation.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+PARAMNAME=b_lto
+PARAMVAL=false
+FLAGTOMOD="-D${PARAMNAME}=$PARAMVAL"
+
+function _apply_mod()
+{
+ local BUILDDIR=$1
+ local RETCODE=1
+
+ if [ -n "$BUILDDIR" ]; then
+ if [ -d $BUILDDIR ]; then
+ meson configure $FLAGTOMOD $BUILDDIR
+ if [ $? -eq 0 ]; then
+ meson --reconfigure $BUILDDIR
+ RETCODE=$?
+ fi
+ else
+ meson $FLAGTOMOD $BUILDDIR
+ RETCODE=$?
+ fi
+ fi
+ return $RETCODE
+}
+
+function _help()
+{
+ local SCRIPTDIR=scripts
+ local SCRIPT="$SCRIPTDIR/$(basename $0)"
+
+ echo "##################### SCRIPT USAGE #####################"
+ echo "Please call this script from telemetry main directory"
+ echo "with parameter specifying name of your build directory"
+ echo "example:"
+ echo "./$SCRIPT BUILDDIRNAME"
+ echo "./$SCRIPT build"
+ echo "########################################################"
+}
+trap _help ERR
+
+### main ###
+
+_apply_mod $@
+exit $?
+
+### end ###
+
diff --git a/tests/meson.build b/tests/meson.build
index 17cd369..a3a78ec 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -56,7 +56,8 @@
phosphor_logging,
sdbusplus,
],
- include_directories: ['../src', 'src']
+ include_directories: ['../src', 'src'],
+ cpp_args: '-fno-lto'
),
timeout: 120,
)