Skip to content

Commit a43077e

Browse files
committed
Update build script and documentation for submodule workflow
1 parent df7e471 commit a43077e

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,33 @@ This project is licensed under the MIT License.
339339

340340
- [libpg_query](https://github.com/pganalyze/libpg_query) - The core PostgreSQL parser library
341341
- PostgreSQL community for the robust SQL grammar
342+
343+
## Development Setup
344+
345+
This repository uses git submodules for the libpg_query dependency. After cloning:
346+
347+
```bash
348+
# Clone the repository
349+
git clone https://github.com/jonatas/pgquery-dotnet.git
350+
cd pgquery-dotnet
351+
352+
# Initialize and fetch submodules
353+
git submodule update --init --recursive
354+
355+
# Build the project
356+
./scripts/build.sh
357+
```
358+
359+
### Working with Submodules
360+
361+
The `libpg_query` directory is a git submodule pointing to the official [libpg_query repository](https://github.com/pganalyze/libpg_query). This keeps our repository lightweight while maintaining access to the PostgreSQL parser.
362+
363+
To update the submodule to a newer version:
364+
```bash
365+
cd libpg_query
366+
git fetch origin
367+
git checkout 17-latest # or desired version
368+
cd ..
369+
git add libpg_query
370+
git commit -m "Update libpg_query submodule"
371+
```

scripts/build.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,16 @@ echo "🏗️ Building PgQuery.NET with libpg_query..."
77
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
88
PROJECT_ROOT="$SCRIPT_DIR/.."
99

10-
# Configuration
11-
LIBPG_QUERY_BRANCH="17-latest"
12-
LIBPG_QUERY_REPO="https://github.com/pganalyze/libpg_query.git"
13-
1410
cd "$PROJECT_ROOT"
1511

16-
# Step 1: Clone and build libpg_query
17-
echo "📥 Setting up libpg_query..."
18-
if [ ! -d "libpg_query" ]; then
19-
echo "Cloning libpg_query (branch: $LIBPG_QUERY_BRANCH)..."
20-
git clone -b "$LIBPG_QUERY_BRANCH" "$LIBPG_QUERY_REPO"
12+
# Step 1: Initialize and update git submodules
13+
echo "📥 Setting up libpg_query submodule..."
14+
if [ ! -f "libpg_query/Makefile" ]; then
15+
echo "Initializing and fetching libpg_query submodule..."
16+
git submodule update --init --recursive
2117
else
22-
echo "libpg_query already exists, updating..."
23-
cd libpg_query
24-
git fetch origin
25-
git checkout "$LIBPG_QUERY_BRANCH"
26-
git pull origin "$LIBPG_QUERY_BRANCH"
27-
cd ..
18+
echo "libpg_query submodule already initialized, updating..."
19+
git submodule update --recursive
2820
fi
2921

3022
cd libpg_query

0 commit comments

Comments
 (0)