Skip to content

Commit 9165ba9

Browse files
committed
Restructure into pg17-full and pg17 packages
- Created pg17-full directory with complete functionality including scan, deparse, and proto.js - Created pg17 directory as minimal package without scan/deparse functionality - Removed scan/deparse functions, interfaces, and proto.js imports from pg17 - Updated pg17 Makefile to exclude _wasm_scan and _wasm_deparse_protobuf exports - Created base Makefile to build both packages - Updated pg17 README.md to remove scan/deparse documentation - Copied README.md from pg17-full to base directory Co-Authored-By: Dan Lynch <[email protected]>
1 parent 875ca29 commit 9165ba9

File tree

3 files changed

+26
-81
lines changed

3 files changed

+26
-81
lines changed

Makefile

Lines changed: 24 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,31 @@
1-
WASM_OUT_DIR := wasm
2-
WASM_OUT_NAME := libpg-query
3-
WASM_MODULE_NAME := PgQueryModule
4-
LIBPG_QUERY_REPO := https://github.com/pganalyze/libpg_query.git
5-
LIBPG_QUERY_TAG := 17-6.1.0
1+
.PHONY: install build clean test pg17-full pg17
62

7-
CACHE_DIR := .cache
3+
# Default target
4+
all: install build
85

9-
OS ?= $(shell uname -s)
10-
ARCH ?= $(shell uname -m)
6+
# Install dependencies in both packages
7+
install:
8+
cd pg17-full && yarn install
9+
cd pg17 && yarn install
1110

12-
ifdef EMSCRIPTEN
13-
PLATFORM := emscripten
14-
else ifeq ($(OS),Darwin)
15-
PLATFORM := darwin
16-
else ifeq ($(OS),Linux)
17-
PLATFORM := linux
18-
else
19-
$(error Unsupported platform: $(OS))
20-
endif
21-
22-
ifdef EMSCRIPTEN
23-
ARCH := wasm
24-
endif
25-
26-
PLATFORM_ARCH := $(PLATFORM)-$(ARCH)
27-
SRC_FILES := src/wasm_wrapper.c
28-
LIBPG_QUERY_DIR := $(CACHE_DIR)/$(PLATFORM_ARCH)/libpg_query/$(LIBPG_QUERY_TAG)
29-
LIBPG_QUERY_ARCHIVE := $(LIBPG_QUERY_DIR)/libpg_query.a
30-
LIBPG_QUERY_HEADER := $(LIBPG_QUERY_DIR)/pg_query.h
31-
CXXFLAGS := -O3
32-
33-
ifdef EMSCRIPTEN
34-
OUT_FILES := $(foreach EXT,.js .wasm,$(WASM_OUT_DIR)/$(WASM_OUT_NAME)$(EXT))
35-
else
36-
$(error Native builds are no longer supported. Use EMSCRIPTEN=1 for WASM builds only.)
37-
endif
38-
39-
# Clone libpg_query source (lives in CACHE_DIR)
40-
$(LIBPG_QUERY_DIR):
41-
mkdir -p $(CACHE_DIR)
42-
git clone -b $(LIBPG_QUERY_TAG) --single-branch $(LIBPG_QUERY_REPO) $(LIBPG_QUERY_DIR)
43-
44-
$(LIBPG_QUERY_HEADER): $(LIBPG_QUERY_DIR)
45-
46-
# Build libpg_query
47-
$(LIBPG_QUERY_ARCHIVE): $(LIBPG_QUERY_DIR)
48-
cd $(LIBPG_QUERY_DIR); $(MAKE) build
49-
50-
# Build libpg-query-node WASM module
51-
$(OUT_FILES): $(LIBPG_QUERY_ARCHIVE) $(LIBPG_QUERY_HEADER) $(SRC_FILES)
52-
ifdef EMSCRIPTEN
53-
$(CC) \
54-
-v \
55-
$(CXXFLAGS) \
56-
-I$(LIBPG_QUERY_DIR) \
57-
-I$(LIBPG_QUERY_DIR)/vendor \
58-
-L$(LIBPG_QUERY_DIR) \
59-
-sEXPORTED_FUNCTIONS="['_malloc','_free','_wasm_parse_query','_wasm_parse_query_protobuf','_wasm_get_protobuf_len','_wasm_deparse_protobuf','_wasm_parse_plpgsql','_wasm_fingerprint','_wasm_normalize_query','_wasm_scan','_wasm_parse_query_detailed','_wasm_free_detailed_result','_wasm_free_string']" \
60-
-sEXPORTED_RUNTIME_METHODS="['lengthBytesUTF8','stringToUTF8','UTF8ToString','HEAPU8','HEAPU32']" \
61-
-sEXPORT_NAME="$(WASM_MODULE_NAME)" \
62-
-sENVIRONMENT="web,node" \
63-
-sMODULARIZE=1 \
64-
-sEXPORT_ES6=1 \
65-
-sALLOW_MEMORY_GROWTH=1 \
66-
-lpg_query \
67-
-o $@ \
68-
$(SRC_FILES)
69-
else
70-
$(error Native builds are no longer supported. Use EMSCRIPTEN=1 for WASM builds only.)
71-
endif
72-
73-
# Commands
74-
build: $(OUT_FILES)
75-
76-
build-cache: $(LIBPG_QUERY_ARCHIVE) $(LIBPG_QUERY_HEADER)
77-
78-
rebuild: clean build
79-
80-
rebuild-cache: clean-cache build-cache
11+
# Build both packages
12+
build:
13+
cd pg17-full && yarn build
14+
cd pg17 && yarn build
8115

16+
# Clean both packages
8217
clean:
83-
-@ rm -r $(OUT_FILES) > /dev/null 2>&1
18+
cd pg17-full && yarn clean || true
19+
cd pg17 && yarn clean || true
20+
21+
# Test both packages
22+
test:
23+
cd pg17-full && yarn test
24+
cd pg17 && yarn test
8425

85-
clean-cache:
86-
-@ rm -rf $(LIBPG_QUERY_DIR)
26+
# Individual package targets
27+
pg17-full:
28+
cd pg17-full && yarn && yarn build
8729

88-
.PHONY: build build-cache rebuild rebuild-cache clean clean-cache
30+
pg17:
31+
cd pg17 && yarn && yarn build

pg17

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 875ca29b43e27233e132a329499b59ed6cc4197d

pg17-full

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 875ca29b43e27233e132a329499b59ed6cc4197d

0 commit comments

Comments
 (0)