From e811143507e5c47934e7d812e268d23d03365d74 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Thu, 7 Nov 2024 16:14:08 +0100 Subject: [PATCH] Automatically detect DuckDB update in Makefile (#406) After updating my submodules for #400 I had to call `make clean-duckdb` to trigger a rebuild of duckdb. This changes our Makefile to automatically detect changes in the submodule. --- .dockerignore | 1 + Dockerfile | 1 + Makefile | 14 ++++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index ed07cac8..5e8e080d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ .git +!.git/modules/third_party/duckdb/HEAD *.o *.so *.dylib diff --git a/Dockerfile b/Dockerfile index 9b341492..36ebac8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ USER postgres # for each directory, because docker puts only the contents of the source # directory into the target directory, and not the directory itself too. COPY --chown=postgres:postgres Makefile Makefile.global pg_duckdb.control . +COPY --chown=postgres:postgres .git/modules/third_party/duckdb/HEAD .git/modules/third_party/duckdb/HEAD COPY --chown=postgres:postgres sql sql COPY --chown=postgres:postgres src src COPY --chown=postgres:postgres include include diff --git a/Makefile b/Makefile index de6a21f3..afef3475 100644 --- a/Makefile +++ b/Makefile @@ -42,10 +42,12 @@ SHLIB_LINK += -Wl,-rpath,$(PG_LIB)/ -lpq -Lthird_party/duckdb/build/$(DUCKDB_BUI include Makefile.global -# We need the DuckDB header files to build the .o files. We depend on the -# duckdb Makefile, because that target pulls in the submodule which includes -# those header files. -$(OBJS): third_party/duckdb/Makefile +# We need the DuckDB header files to build our own .o files. We depend on the +# duckdb submodule HEAD, because that target pulls in the submodule which +# includes those header files. This does mean that we rebuild our .o files +# whenever we change the DuckDB version, but that seems like a fairly +# reasonable thing to do anyway, even if not always strictly necessary always. +$(OBJS): .git/modules/third_party/duckdb/HEAD COMPILE.cc.bc += $(PG_CPPFLAGS) COMPILE.cxx.bc += $(PG_CXXFLAGS) @@ -73,10 +75,10 @@ check: installcheck pycheck duckdb: $(FULL_DUCKDB_LIB) -third_party/duckdb/Makefile: +.git/modules/third_party/duckdb/HEAD: git submodule update --init --recursive -$(FULL_DUCKDB_LIB): third_party/duckdb/Makefile +$(FULL_DUCKDB_LIB): .git/modules/third_party/duckdb/HEAD OVERRIDE_GIT_DESCRIBE=$(DUCKDB_VERSION) \ GEN=$(DUCKDB_GEN) \ CMAKE_VARS="$(DUCKDB_CMAKE_VARS)" \