Skip to content

Commit

Permalink
Add helper to ensure we're not including PG files
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-- committed Nov 11, 2024
1 parent 1b4514d commit a8157ee
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include/generated/
.clangd
.depend
.deps
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ DUCKDB_CMAKE_VARS = -DBUILD_SHELL=0 -DBUILD_PYTHON=0 -DBUILD_UNITTESTS=0
# DuckDB agains the release build of MotherDuck.
DUCKDB_DISABLE_ASSERTIONS ?= 0

CPP_ONLY_FILE = include/generated/cpp_only_file.hpp

DUCKDB_BUILD_CXX_FLAGS=
DUCKDB_BUILD_TYPE=
ifeq ($(DUCKDB_BUILD), Debug)
Expand All @@ -47,7 +49,7 @@ include Makefile.global
# 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
$(OBJS): .git/modules/third_party/duckdb/HEAD $(CPP_ONLY_FILE)

COMPILE.cc.bc += $(PG_CPPFLAGS)
COMPILE.cxx.bc += $(PG_CXXFLAGS)
Expand Down Expand Up @@ -97,6 +99,16 @@ clean-duckdb:
install: install-duckdb

clean-all: clean clean-regression clean-duckdb
rm -f $(CPP_ONLY_FILE)

$(CPP_ONLY_FILE):
@rm -f $(CPP_ONLY_FILE)
@echo "// Auto-generated file, run 'make update_cpp_guard' to update" > $(CPP_ONLY_FILE)
@echo "#if \\" >> $(CPP_ONLY_FILE)
for m in $$(grep -R '_H$$' "$(INCLUDEDIR)" | grep define | cut -d \: -f 2 | cut -d \ -f 2 | sort); do echo "defined($$m) || \\"; done >> $(CPP_ONLY_FILE)
@echo "false" >> $(CPP_ONLY_FILE)
@echo "static_assert(false, \"No Postgres header should be included in this file.\");" >> $(CPP_ONLY_FILE)
@echo "#endif" >> $(CPP_ONLY_FILE)

lintcheck:
clang-tidy $(SRCS) -- -I$(INCLUDEDIR) -I$(INCLUDEDIR_SERVER) -Iinclude $(CPPFLAGS) -std=c++17
Expand Down
2 changes: 2 additions & 0 deletions src/catalog/pgduckdb_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "pgduckdb/catalog/pgduckdb_storage.hpp"
#include "pgduckdb/catalog/pgduckdb_transaction.hpp"

#include "generated/cpp_only_file.hpp" // Must be last include.

namespace pgduckdb {

PostgresCatalog::PostgresCatalog(duckdb::AttachedDatabase &db, const duckdb::string &connection_string,
Expand Down
2 changes: 2 additions & 0 deletions src/catalog/pgduckdb_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "pgduckdb/catalog/pgduckdb_transaction.hpp"
#include "duckdb/parser/parsed_data/create_table_info.hpp"

#include "generated/cpp_only_file.hpp" // Must be last include.

namespace pgduckdb {

PostgresSchema::PostgresSchema(duckdb::Catalog &catalog, duckdb::CreateSchemaInfo &info, Snapshot snapshot)
Expand Down
2 changes: 2 additions & 0 deletions src/catalog/pgduckdb_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "pgduckdb/catalog/pgduckdb_catalog.hpp"
#include "pgduckdb/catalog/pgduckdb_transaction_manager.hpp"

#include "generated/cpp_only_file.hpp" // Must be last include.

namespace pgduckdb {

static duckdb::unique_ptr<duckdb::TransactionManager>
Expand Down

0 comments on commit a8157ee

Please sign in to comment.