forked from postgres/postgres
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpgbuild.emscripten.sh
executable file
·111 lines (77 loc) · 2.87 KB
/
pgbuild.emscripten.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
echo "
pgbuild.wasm:begin
CC_PGLITE=$CC_PGLITE
"
mkdir -p build/postgres
pushd build/postgres
# create empty package.json to avoid emsdk node conflicts
# with root package.json of project
echo "{}" > package.json
export MAIN_MODULE="-sMAIN_MODULE=1"
export XML2_CONFIG=$PREFIX/bin/xml2-config
export ZIC=$(pwd)/bin/zic
export EXT=wasm
cp -r ${PGSRC}/pglite/other/* /tmp/pglite/
echo " ==== building wasm MVP:$MVP Debug=${PGDEBUG} with opts : $@ == "
mkdir -p bin
cat > bin/zic <<END
#!/bin/bash
TZ=UTC PGTZ=UTC node $(pwd)/src/timezone/zic.cjs \$@
END
export CONFIG_SITE=${PGSRC}/pglite/config.site
if emconfigure ${PGSRC}/configure
then
echo configure ok
else
echo configure failed
exit 76
fi
mkdir -p /tmp/pglite/bin
ln -sf /tmp/pglite/bin/emsdk-shared bin/emsdk-shared
chmod +x bin/zic /tmp/pglite/bin/emsdk-shared
# for zic and emsdk-shared/wasi-shared called from makefile
export PATH=$(pwd)/bin:$PATH
EMCC_NODE="-sEXIT_RUNTIME=1 -DEXIT_RUNTIME -sNODERAWFS -sENVIRONMENT=node"
# EMCC_ENV="${EMCC_NODE} -sFORCE_FILESYSTEM=0"
EMCC_ENV="${EMCC_NODE} -sERROR_ON_UNDEFINED_SYMBOLS"
# PREFIX only required for static initdb
EMCC_CFLAGS="-sERROR_ON_UNDEFINED_SYMBOLS=1 ${CC_PGLITE} -DPREFIX=/tmp/pglite -Wno-macro-redefined -Wno-unused-function"
# ZIC=${ZIC:-$(realpath bin/zic)}
if EMCC_CFLAGS="${EMCC_ENV} ${EMCC_CFLAGS}" emmake make emscripten=1 -j $(nproc) 2>&1 > /tmp/build.log
then
echo build ok
cp -vf src/backend/postgres src/backend/postgres.cjs
# if running a 32bits zic from current build
unset LD_PRELOAD
if EMCC_CFLAGS="${EMCC_ENV} ${EMCC_CFLAGS}" emmake make emscripten=1 install 2>&1 > /tmp/install.log
then
echo install ok
pushd /tmp/pglite
find . -type f | grep -v plpgsql > /tmp/pglite/pg.installed
popd
goback=$(pwd)
popd
python3 cibuild/pack_extension.py builtin
pushd $goback
pushd /tmp/pglite
find . -type f > /tmp/pglite/pg.installed
popd
else
cat /tmp/install.log
echo "install failed"
exit 225
fi
else
cat /tmp/build.log
echo "build failed"
exit 230
fi
# wip
mv -vf ./src/bin/psql/psql.$EXT ./src/bin/pg_config/pg_config.$EXT /tmp/pglite/bin/
mv -vf ./src/bin/pg_dump/pg_restore.$EXT ./src/bin/pg_dump/pg_dump.$EXT ./src/bin/pg_dump/pg_dumpall.$EXT /tmp/pglite/bin/
mv -vf ./src/bin/pg_resetwal/pg_resetwal.$EXT ./src/bin/initdb/initdb.$EXT ./src/backend/postgres.$EXT /tmp/pglite/bin/
# force node wasm version
cp -vf /tmp/pglite/postgres /tmp/pglite/bin/postgres && chmod +x /tmp/pglite/postgres /tmp/pglite/bin/postgres
popd
echo "pgbuild:end
"