-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathci-17_4_WASM.sh
executable file
·120 lines (97 loc) · 2.96 KB
/
ci-17_4_WASM.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
112
113
114
115
116
117
118
119
120
#!/bin/bash
export PGL_BRANCH=main
export PG_VERSION=${PG_VERSION:-17.4}
export PG_BRANCH=${PG_BRANCH:-REL_17_4_WASM}
export CONTAINER_PATH=${CONTAINER_PATH:-/tmp/fs}
export DEBUG=${DEBUG:-false}
export USE_ICU=${USE_ICU:-false}
export GETZIC=${GETZIC:-false}
export ZIC=${ZIC:-/usr/sbin/zic}
export CI=${CI:-false}
export WORKSPACE=$(pwd)
export WASI=${WASI:-false}
if $WASI
then
BUILD=wasi
else
BUILD=emscripten
fi
export BUILD_PATH=${WORKSPACE}/build-${PG_BRANCH}/${BUILD}
export DIST_PATH=${WORKSPACE}/dist-${PG_BRANCH}
# for local testing
if [ -d /srv/www/html/pglite-web ]
then
echo "local ${BUILD} build"
export PG_DIST_WEB="/srv/www/html/pglite-web"
export LOCAL=true
else
export PG_DIST_WEB="${DIST_PATH}/web"
export LOCAL=false
# is it a pre-patched postgres-pglite release tree ?
if [ -f configure ]
then
[ -f postgresql-${PG_BRANCH}.patched ] && ln -s . postgresql-pglite
[ -f postgresql-${PG_BRANCH}.patched ] && ln -s . postgresql-${PG_BRANCH}
[ -f postgresql-${PG_BRANCH}.patched ] && ln -s . postgresql-${PG_VERSION}
else
# unpatched upstream ( pglite-build case )
[ -f postgresql-${PG_BRANCH}/configure ] \
|| git clone --no-tags --depth 1 --single-branch --branch ${PG_BRANCH} https://github.com/electric-sql/postgres-pglite postgresql-${PG_BRANCH}
fi
fi
if [ -f pglite-wasm/build.sh ]
then
echo "using local pglite files"
else
mkdir -p pglite-wasm
cp -Rv pglite-${PG_BRANCH}/* pglite-wasm/
fi
mkdir -p $CONTAINER_PATH/tmp
#TODO: pglite has .buildconfig in postgres source dir instead.
cat > $CONTAINER_PATH/tmp/portable.opts <<END
export DEBUG=${DEBUG}
export USE_ICU=${USE_ICU}
export PG_VERSION=${PG_VERSION}
export PG_BRANCH=${PG_BRANCH}
export GETZIC=${GETZIC}
export ZIC=${ZIC}
export CI=${CI}
export WASI=${WASI}
END
if [ -d ${WORKSPACE}/pglite/packages/pglite ]
then
echo "using local pglite tree"
else
echo "
* getting pglite branch $PGL_BRANCH
"
git clone --no-tags --depth 1 --single-branch --branch $PGL_BRANCH https://github.com/electric-sql/pglite pglite
fi
# execute prooted build
${WORKSPACE}/portable/portable.sh
if $LOCAL
then
echo "TODO: start a test server for $PG_DIST_WEB"
else
# gh pages publish
PG_DIST_WEB=/tmp/web
mkdir -p $PG_DIST_WEB
touch $PG_DIST_WEB/.nojekyll
fi
[ -f $DIST_PATH/pglite.wasi ] && cp -vf $DIST_PATH/pglite.wasi $PG_DIST_WEB/
[ -f $DIST_PATH/pglite-wasi.tar.xz ] && cp -vf $DIST_PATH/pglite-wasi.tar.xz $PG_DIST_WEB/
if $WASI
then
echo "TODO: wasi post link"
else
if [ -f ${BUILD_PATH}/libpgcore.a ]
then
echo "found postgres core static libraries in ${BUILD_PATH}"
else
echo "failed to build libpgcore static at ${BUILD_PATH}/libpgcore.a"
exit 85
fi
cp -f pglite/packages/pglite/dist/*.tar.gz $PG_DIST_WEB/
cp -f pglite/packages/pglite/dist/pglite.* $PG_DIST_WEB/
mv -v pglite/packages/pglite/release/pglite.html $PG_DIST_WEB/index.html
fi