Skip to content

Commit

Permalink
feat: better makefile dependency management
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnr committed Feb 20, 2024
1 parent 649d850 commit 8b5a22e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
WASM_OUT_DIR := wasm
WASM_OUT_NAME := libpg-query
WASM_MODULE_NAME := PgQueryModule
LIBPG_QUERY_REPO := https://github.com/gregnr/libpg_query.git
LIBPG_QUERY_BRANCH := fix/ar-command-in-makefile
LIBPG_QUERY_REPO := https://github.com/pganalyze/libpg_query.git
LIBPG_QUERY_BRANCH := 15-latest
CACHE_DIR := .cache

OS ?= $(shell uname -s)
Expand All @@ -24,7 +24,9 @@ endif

PLATFORM_ARCH := $(PLATFORM)-$(ARCH)
SRC_FILES := $(wildcard src/*.cc)
LIBPG_QUERY_DIR := $(CACHE_DIR)/$(PLATFORM_ARCH)/libpg_query
LIBPG_QUERY_DIR := $(CACHE_DIR)/$(PLATFORM_ARCH)/libpg_query/$(LIBPG_QUERY_BRANCH)
LIBPG_QUERY_ARCHIVE := $(LIBPG_QUERY_DIR)/libpg_query.a
LIBPG_QUERY_HEADER := $(LIBPG_QUERY_DIR)/pg_query.h
CXXFLAGS := -O3

ifdef EMSCRIPTEN
Expand All @@ -47,12 +49,19 @@ clean:
clean-cache:
-@ rm -rf $(LIBPG_QUERY_DIR)

# Clone libpg_query source (lives in CACHE_DIR)
$(LIBPG_QUERY_DIR):
mkdir -p $(CACHE_DIR)
git clone -b $(LIBPG_QUERY_BRANCH) --single-branch $(LIBPG_QUERY_REPO) $(LIBPG_QUERY_DIR)

$(LIBPG_QUERY_HEADER): $(LIBPG_QUERY_DIR)

# Build libpg_query
$(LIBPG_QUERY_ARCHIVE): $(LIBPG_QUERY_DIR)
cd $(LIBPG_QUERY_DIR); $(MAKE) build

$(OUT_FILES): $(LIBPG_QUERY_DIR) $(SRC_FILES)
# Build libpg-query-node (based on platform)
$(OUT_FILES): $(LIBPG_QUERY_ARCHIVE) $(LIBPG_QUERY_HEADER) $(SRC_FILES)
ifdef EMSCRIPTEN
@ $(CXX) \
$(CXXFLAGS) \
Expand Down

0 comments on commit 8b5a22e

Please sign in to comment.