forked from launchql/libpg-query-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildAddon.sh
executable file
·58 lines (42 loc) · 1.2 KB
/
buildAddon.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
commit=1097b2c33e54a37c0d2c0f2d498c7d1cf967eae9
rDIR=$(pwd)
tmpDir=$(mktemp -d 2>/dev/null || mktemp -d -t 'tmpdir.XXXX')
makeTarget=build
cd "$tmpDir"
git clone -b 13-latest --single-branch https://github.com/pganalyze/libpg_query.git
cd libpg_query
git checkout $commit
# needed if being invoked from within gyp
unset MAKEFLAGS
unset MFLAGS
if [ "$(uname)" == "Darwin" ]; then
make CFLAGS='-mmacosx-version-min=10.7' PG_CFLAGS='-mmacosx-version-min=10.7' $makeTarget
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
make CFLAGS='' PG_CFLAGS='' $makeTarget
fi
if [ $? -ne 0 ]; then
echo "ERROR: 'make' command failed";
exit 1;
fi
file=$(ls | grep 'libpg_query.a')
if [ ! $file ]; then
echo "ERROR: libpg_query.a not found";
exit 1;
fi
file=$(ls | grep 'pg_query.h')
if [ ! $file ]; then
echo "ERROR: pg_query.h not found";
exit 1;
fi
#copy queryparser.cc, binding.gyp to current directory
#
#
if [ "$(uname)" == "Darwin" ]; then
cp $(pwd)/libpg_query.a $rDIR/libpg_query/osx/
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
cp $(pwd)/libpg_query.a $rDIR/libpg_query/linux/
fi
cp $(pwd)/pg_query.h $rDIR/libpg_query/include/
cd "$rDIR"
rm -rf "$tmpDir"