Skip to content

Commit

Permalink
Automatically detect DuckDB update in Makefile (#406)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JelteF authored Nov 7, 2024
1 parent 3e9b0a3 commit e811143
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.git
!.git/modules/third_party/duckdb/HEAD
*.o
*.so
*.dylib
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)" \
Expand Down

0 comments on commit e811143

Please sign in to comment.