From 75948c32af7168b25c864db28e8c695bb797a0dd Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 16 Jul 2019 23:54:29 -0400 Subject: [PATCH] bt2: don't copy swig interface files to build directory A pet peeve of mine is that if you touch a bt2 py file (e.g. `touch src/bindings/python/bt2/bt2/event.py`) and re-build, it will re-run swig and rebuild the native module, even though it's not necessary (all that is needed is to copy the .py files over to the build directory). This takes precious seconds from my development cycle. This is done because the .i files are copied over to the build directory (as they are in STATIC_BINDINGS_DEPS), along with the .py files. And since the modification time of the .i files has changed, it triggers the bt2/native_bt.i -> bt2/native_bt.c conversion to run again. Fix this by not copying the .i files to the build directory. This is not necessary anyway, as swig can read them perfectly fine from the source directory. And while at it, the logging.h/logging.c files don't need to be copied to the build directory either, so make it so they are not copied and read from the source directory (I don't think this provides any advantage other than it being "cleaner"). Change-Id: Ib1ee03cd7795e0f9f3eaedb8476c052221acb9ee Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1712 Tested-by: jenkins Reviewed-by: Philippe Proulx Reviewed-by: Michael Jeanson --- src/bindings/python/bt2/Makefile.am | 14 ++++++++------ src/bindings/python/bt2/setup.py.in | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/bindings/python/bt2/Makefile.am b/src/bindings/python/bt2/Makefile.am index a3f0d88f..799670cd 100644 --- a/src/bindings/python/bt2/Makefile.am +++ b/src/bindings/python/bt2/Makefile.am @@ -32,10 +32,12 @@ SWIG_INTERFACE_FILES = \ bt2/native_bt_value.i \ bt2/native_bt_version.i -STATIC_BINDINGS_DEPS = \ - $(SWIG_INTERFACE_FILES) \ +# Non-generated files built into the native library. +STATIC_NATIVE_LIB_SRCS = \ bt2/logging.c \ - bt2/logging.h \ + bt2/logging.h + +STATIC_BINDINGS_DEPS = \ bt2/clock_class.py \ bt2/clock_snapshot.py \ bt2/component.py \ @@ -70,7 +72,7 @@ GENERATED_BINDINGS_DEPS = \ BUILD_FLAGS=CC="$(CC)" \ CFLAGS="$(GLIB_CFLAGS) $(AM_CFLAGS) $(CFLAGS)" \ - CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" \ + CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS) -I$(srcdir)/bt2" \ LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS) $(GLIB_LIBS) $(LIBS)" all-local: build-python-bindings.stamp @@ -83,7 +85,7 @@ copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS)) fi touch $@ -build-python-bindings.stamp: copy-static-deps.stamp $(GENERATED_BINDINGS_DEPS) +build-python-bindings.stamp: copy-static-deps.stamp $(GENERATED_BINDINGS_DEPS) $(STATIC_NATIVE_LIB_SRCS) $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build --force touch $@ @@ -121,7 +123,7 @@ uninstall-local: rm -f $(INSTALLED_FILES) # distribute: extra Python modules and SWIG interface files -EXTRA_DIST = $(STATIC_BINDINGS_DEPS) +EXTRA_DIST = $(STATIC_BINDINGS_DEPS) $(SWIG_INTERFACE_FILES) $(STATIC_NATIVE_LIB_SRCS) # clean: generated C and Python files (by SWIG) CLEANFILES = bt2/native_bt.py bt2/native_bt.c build-python-bindings.stamp copy-static-deps.stamp diff --git a/src/bindings/python/bt2/setup.py.in b/src/bindings/python/bt2/setup.py.in index 682cbbc0..0182305d 100644 --- a/src/bindings/python/bt2/setup.py.in +++ b/src/bindings/python/bt2/setup.py.in @@ -36,7 +36,7 @@ following command to your .bashrc/.zshrc: def main(): babeltrace_ext = Extension('bt2._native_bt', - sources=['bt2/native_bt.c', 'bt2/logging.c'], + sources=['bt2/native_bt.c', '@srcdir@/bt2/logging.c'], libraries=['babeltrace2', 'glib-2.0'], extra_objects=['@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a', '@top_builddir@/src/common/.libs/libbabeltrace2-common.a', -- 2.34.1