Skip to content

Commit badd4c8

Browse files
authored
Merge pull request #46 from launchql/16-latest-windows
16 latest windows
2 parents 378c5c4 + dee1770 commit badd4c8

5 files changed

Lines changed: 112 additions & 15 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ libs/
44
npm-debug.log
55
libpg_query/**/*.a
66
libpg_query/**/*.h
7+
libpg_query/windows/*.lib

‎binding.gyp‎

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
"src/sync.cc",
99
"src/async.cc"
1010
],
11-
"actions": [
12-
{
13-
"outputs": ['libpg_query/include/pg_query.h'],
14-
"inputs": [],
15-
"action": ['script/buildAddon.sh'],
16-
"action_name": 'prebuild_dependencies'
17-
}
18-
],
1911
'cflags!': [ '-fno-exceptions' ],
2012
'cflags_cc!': [ '-fno-exceptions' ],
2113
'include_dirs': [
@@ -25,22 +17,58 @@
2517
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
2618
'conditions': [
2719
['OS=="linux"', {
28-
"libraries": [ "-L<!(pwd)/libpg_query/linux", "-lpg_query" ]
20+
"libraries": [ "-L<!(pwd)/libpg_query/linux", "-lpg_query" ],
21+
"actions": [
22+
{
23+
"outputs": ['libpg_query/include/pg_query.h'],
24+
"inputs": [],
25+
"action": ['script/buildAddon.sh'],
26+
"action_name": 'prebuild_dependencies'
27+
}
28+
],
2929
}],
3030
['OS=="mac"', {
3131
"libraries": [ "-L<!(pwd)/libpg_query/osx", "-lpg_query" ],
3232
"xcode_settings": {
3333
"CLANG_CXX_LIBRARY": "libc++",
3434
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
3535
'MACOSX_DEPLOYMENT_TARGET': '10.7'
36-
}
36+
},
37+
"actions": [
38+
{
39+
"outputs": ['libpg_query/include/pg_query.h'],
40+
"inputs": [],
41+
"action": ['script/buildAddon.sh'],
42+
"action_name": 'prebuild_dependencies'
43+
}
44+
],
3745
}],
3846
['OS=="win"', {
47+
"link_settings": {
48+
"library_dirs": [
49+
"../libpg_query/windows"
50+
],
51+
"libraries": [
52+
"../libpg_query/windows/pg_query.lib"
53+
],
54+
},
3955
"msvs_settings": {
4056
"VCCLCompilerTool": {
41-
"ExceptionHandling": 1
57+
"ExceptionHandling": 0,
58+
"AdditionalOptions": ["/EHsc"]
59+
}
60+
},
61+
"defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
62+
"actions":[
63+
{
64+
"outputs": [
65+
""
66+
],
67+
"inputs": [],
68+
"action": ['../script/buildAddon.bat'],
69+
"action_name": 'prebuild_dependencies'
4270
}
43-
}
71+
]
4472
}]
4573
]
4674
}

‎docker/readme.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ docker run \
1818
# build inside the docker image
1919

2020
```sh
21-
branch=15-latest
21+
branch=16-latest
2222
mkdir git_clone_dir && cd git_clone_dir
2323
git clone -b $branch --single-branch https://github.com/launchql/libpg-query-node
2424
cd libpg-query-node/
@@ -39,7 +39,7 @@ npm publish
3939
to build manually using `libpg_query`
4040

4141
```sh
42-
branch=15-latest
42+
branch=16-latest
4343
mkdir git_clone_dir && cd git_clone_dir
4444
git clone -b $branch --single-branch https://github.com/pganalyze/libpg_query.git
4545
cd libpg_query/

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "libpg-query",
3-
"version": "16.0.1",
3+
"version": "16.1.0",
44
"description": "The real PostgreSQL query parser",
55
"homepage": "https://github.com/launchql/libpg-query-node",
66
"main": "index.js",

‎script/buildAddon.bat‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@echo off
2+
3+
set commit=1ec38940e5c6f09a4c1d17a46d839a881c4f2db7
4+
set branch=16-latest
5+
6+
setlocal enabledelayedexpansion
7+
8+
rem Remember current's parent directory and create a new, unique, temporary directory
9+
set buildDir=%cd%
10+
set projectDir=%cd%\..
11+
set tmpDir=%temp%\tmpdir.libpg_query
12+
rmdir /s /q %tmpDir%
13+
md %tmpDir%
14+
15+
16+
rem Define the make target
17+
set makeTarget=build
18+
19+
rem Change to the newly created temp directory
20+
cd /D %tmpDir%
21+
22+
23+
rem Clone the selected branch of the libpg_query Git repo
24+
git clone -b %branch% --single-branch https://github.com/pganalyze/libpg_query.git
25+
cd libpg_query
26+
27+
rem Checkout the desired commit
28+
git checkout %commit%
29+
30+
rem needed if being invoked from within gyp
31+
set MAKEFLAGS=
32+
set MFLAGS=
33+
34+
rem set path with Windows Developer Command Prompt
35+
echo "please ensure you are running at Windows Developer Command Prompt environments"
36+
nmake /F Makefile.msvc clean
37+
nmake /F Makefile.msvc build
38+
39+
40+
rem Terminate if build fails
41+
if %errorlevel% NEQ 0 (
42+
echo ERROR: 'nmake' command failed
43+
)
44+
45+
rem Search for pg_query.obj (libpg_query.a), error if not found
46+
for /f "delims=" %%f in ('dir /b /s pg_query.lib') do set file=%%f
47+
if not defined file (
48+
echo "ERROR: pg_query.lib not found"
49+
50+
)
51+
52+
rem Error if pg_query.h is missing
53+
for /f "delims=" %%f in ('dir /b /s pg_query.h') do set file=%%f
54+
if not defined file (
55+
echo "ERROR: pg_query.h not found"
56+
57+
)
58+
59+
rem Copy pg_query.lib to windows dir
60+
copy /Y pg_query.lib "%projectDir%\libpg_query\windows\"
61+
62+
rem Copy header
63+
copy /Y pg_query.h "%projectDir%\libpg_query\include\"
64+
65+
rem Cleanup: revert to original directory
66+
cd /D %buildDir%
67+
68+
exit /B 0

0 commit comments

Comments
 (0)