bt2: don't copy swig interface files to build directory
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Jul 2019 03:54:29 +0000 (23:54 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 18 Jul 2019 05:26:40 +0000 (01:26 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1712
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
src/bindings/python/bt2/Makefile.am
src/bindings/python/bt2/setup.py.in

index a3f0d88f18e9097e585107ac78b1263bf44c7ddf..799670cd04bd22a5ab30b620d0dbe01baca2c6ef 100644 (file)
@@ -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
index 682cbbc0c52ac7630af93624be84bfd9d387e16b..0182305dd6c73947b08775eda7c75dd4f0954268 100644 (file)
@@ -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',
This page took 0.025818 seconds and 4 git commands to generate.