bt2: Fix Makefile dependency tracking when building out of tree
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 3 May 2019 19:58:04 +0000 (15:58 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 4 May 2019 01:52:28 +0000 (21:52 -0400)
The problem, from the point of view of the developer:

1. Build out of tree, python bindings enabled.
2. Modify a bindings source file (e.g. trace_class.py,
   native_bt_trace.i).
3. Type "make" in the builddir.
4. The bindings are not rebuilt from the new source files.
5. Sad.

When we build out of tree, it's done in two steps (assume $builddir is
$top_builddir/bindings/python):

1. Copy all the static files (those checked in the repo, not generated
   at runtime) from $srcdir/bt2 to $builddir/bt2.  Those files are placed
   next to other files that are generated (__init__.py, setup.py).
   Together, they form the complete source of the bt2 package.
2. Run setup.py, which runs SWIG and outputs the built package in
   $builddir/build_lib.

The problem described above happens because of how the dependencies are
stated for step #1:

    STATIC_BINDINGS_DEPS = ... bt2/native_bt_trace.i ...
    copy-static-deps.stamp: $(STATIC_BINDINGS_DEPS)

When nothing exists yet in the build directory, bt2/native_bt_trace.i is
resolved to the version in the srcdir (because of make's VPATH, I
believe), so it works fine.  But once the copied files exist, and you
try to change the source files and "make" again, the dependency
bt2/native_bt_trace.i will be resolved to the version in the build dir.
Since that version is not newer than copy-static-deps.stamp, nothing is
done.

The fix it, we can force the dependency to be the one in the source
directory, by prepending $(srcdir) to each file.

Change-Id: Ic09d430e53b59e5afa9ebb19d98ba219dff16537
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1250
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
bindings/python/bt2/Makefile.am

index 6482d0c217b67ef2172b923abc0a7d7fc2498193..bc5c7f187a337390a0a92714293fba9096b2fc37 100644 (file)
@@ -70,7 +70,7 @@ BUILD_FLAGS=CC="$(CC)" \
 
 all-local: build-python-bindings.stamp
 
-copy-static-deps.stamp: $(STATIC_BINDINGS_DEPS)
+copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS))
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
                for file in $(STATIC_BINDINGS_DEPS); do \
                        cp -f $(srcdir)/$$file $(builddir)/$$file; \
This page took 0.024908 seconds and 4 git commands to generate.