Skip to content

Commit e4ac5e8

Browse files
committed
wasi build scripts
1 parent 2b86db4 commit e4ac5e8

File tree

4 files changed

+49
-51
lines changed

4 files changed

+49
-51
lines changed

ci-17_4_WASM.sh

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ export CI=${CI:-false}
1313
export WASI=${WASI:-false}
1414
if $WASI
1515
then
16-
export BUILD_PATH=postgresql-${PG_BRANCH}/build/postgres-wasi
16+
BUILD=wasi
1717
else
18-
export BUILD_PATH=postgresql-${PG_BRANCH}/build/postgres-emscripten
18+
BUILD=emscripten
1919
fi
2020

21+
export BUILD_PATH=postgresql-${PG_BRANCH}/build/postgres-${BUILD}
22+
23+
2124
PG_DIST_EXT="${WORKSPACE}/postgresql-${PG_BRANCH}/dist/extensions-emsdk"
2225
PG_DIST_PGLITE="${WORKSPACE}/postgresql-${PG_BRANCH}/dist/pglite-sandbox"
2326

2427
# for local testing
2528
if [ -d /srv/www/html/pglite-web ]
2629
then
27-
echo "local build"
30+
echo "local ${BUILD} build"
2831
export PG_DIST_WEB="/srv/www/html/pglite-web"
2932
export LOCAL=true
3033
else
@@ -58,11 +61,12 @@ mkdir -p $CONTAINER_PATH/tmp
5861
cat > $CONTAINER_PATH/tmp/portable.opts <<END
5962
export DEBUG=${DEBUG}
6063
export USE_ICU=${USE_ICU}
61-
export PG_VERSION=$PG_VERSION
62-
export PG_BRANCH=$PG_BRANCH
63-
export GETZIC=$GETZIC
64-
export ZIC=$ZIC
65-
export CI=$CI
64+
export PG_VERSION=${PG_VERSION}
65+
export PG_BRANCH=${PG_BRANCH}
66+
export GETZIC=${GETZIC}
67+
export ZIC=${ZIC}
68+
export CI=${CI}
69+
export WASI=${WASI}
6670
END
6771

6872

@@ -85,25 +89,30 @@ ${WORKSPACE}/portable/portable.sh
8589

8690
du -hs $BUILD_PATH $PG_DIST_EXT $PG_DIST_PGLITE
8791

88-
if [ -f ${WORKSPACE}/${BUILD_PATH}/libpgcore.a ]
92+
if $WASI
8993
then
90-
echo "found postgres core static libraries in ${WORKSPACE}/${BUILD_PATH}"
94+
echo "TODO: wasi post link"
9195
else
92-
echo "failed to build libpgcore static at ${WORKSPACE}/postgresql-${PG_BRANCH}/${BUILD_PATH}/libpgcore.a"
93-
exit 85
94-
fi
9596

96-
if $LOCAL
97-
then
98-
cp -f pglite/packages/pglite/dist/*.tar.gz $PG_DIST_WEB/
99-
cp -f pglite/packages/pglite/dist/pglite.* $PG_DIST_WEB/
100-
mv -v pglite/packages/pglite/release/pglite.html $PG_DIST_WEB/
101-
echo "TODO: start test server"
102-
else
103-
# gh pages
104-
mkdir -p /tmp/web
105-
cp -f pglite/packages/pglite/dist/*.tar.gz /tmp/web/
106-
cp -f pglite/packages/pglite/dist/pglite.* /tmp/web/
107-
mv -v pglite/packages/pglite/release/pglite.html /tmp/web/index.html
108-
fi
97+
if [ -f ${WORKSPACE}/${BUILD_PATH}/libpgcore.a ]
98+
then
99+
echo "found postgres core static libraries in ${WORKSPACE}/${BUILD_PATH}"
100+
else
101+
echo "failed to build libpgcore static at ${WORKSPACE}/postgresql-${PG_BRANCH}/${BUILD_PATH}/libpgcore.a"
102+
exit 85
103+
fi
109104

105+
if $LOCAL
106+
then
107+
cp -f pglite/packages/pglite/dist/*.tar.gz $PG_DIST_WEB/
108+
cp -f pglite/packages/pglite/dist/pglite.* $PG_DIST_WEB/
109+
mv -v pglite/packages/pglite/release/pglite.html $PG_DIST_WEB/
110+
echo "TODO: start test server"
111+
else
112+
# gh pages
113+
mkdir -p /tmp/web
114+
cp -f pglite/packages/pglite/dist/*.tar.gz /tmp/web/
115+
cp -f pglite/packages/pglite/dist/pglite.* /tmp/web/
116+
mv -v pglite/packages/pglite/release/pglite.html /tmp/web/index.html
117+
fi
118+
fi

portable/portable.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export PG_BRANCH=${PG_BRANCH:-REL_17_4_WASM}
44
export PORTABLE=$(realpath $(dirname $0))
55
export ROOT=$(realpath $(pwd))
66
export SDKROOT=${SDKROOT:-/tmp/sdk}
7+
export WASI=${WASI:-false}
78

89
echo "
910
==================================================================================================
@@ -16,6 +17,7 @@ PG_BRANCH=$PG_BRANCH
1617
SDKROOT=$SDKROOT
1718
DEBUG=$DEBUG
1819
USE_ICU=$USE_ICU
20+
WASI=$WASI
1921
2022
==================================================================================================
2123
==================================================================================================
@@ -24,7 +26,6 @@ USE_ICU=$USE_ICU
2426

2527

2628

27-
2829
export PATH=$PORTABLE:$PATH
2930
export WORKDIR=${ROOT}
3031
export CONTAINER_PATH=${CONTAINER_PATH:-/tmp/fs}

portable/wasi-sdk-25.tar.xz

-13.7 KB
Binary file not shown.

wasm-build.sh

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ export PGUSER=${PGUSER:-postgres}
3939
[ -f /tmp/portable.opts ] && . /tmp/portable.opts
4040
[ -f /tmp/portable.dev ] && . /tmp/portable.dev
4141

42-
# can override from cmdl line
42+
# can override from cmd line
4343
export WASI=${WASI:-false}
44+
export WASI_SDK=${WASI_SDK:-25.0}
45+
export PYBUILD=${PYBUILD:-3.13}
46+
4447

4548

4649
if $WASI
@@ -73,12 +76,13 @@ export BUILD_PATH=${PG_BUILD}/postgres-${BUILD}
7376
export PGDATA=${PGROOT}/base
7477
export PGPATCH=${WORKSPACE}/patches
7578

76-
chmod +x ${PORTABLE}/*.sh ${PORTABLE}/extra/*.sh
77-
78-
# exit on error
79-
EOE=false
79+
chmod +x ${PORTABLE}/*.sh
80+
[ -d ${PORTABLE}/extra ] && ${PORTABLE}/extra/*.sh
8081

8182

83+
# this was set to false on 16.4 to skip some harmless exceptions without messing with core code.
84+
# exit on error
85+
EOE=true
8286

8387

8488
# default to user writeable paths in /tmp/ .
@@ -126,11 +130,9 @@ System node/pnpm ( may interfer) :
126130

127131
if ${WASI}
128132
then
129-
echo "Wasi build (experimental)"
130-
export WASI_SDK=25.0
131-
export WASI_SDK_PREFIX=${SDKROOT}/wasisdk/wasi-sdk-${WASI_SDK}-x86_64-linux
132-
#export WASI_SDK_PREFIX=${SDKROOT}/wasisdk/upstream
133-
export WASI_SYSROOT=${WASI_SDK_PREFIX}/share/wasi-sysroot
133+
pushd ${SDKROOT}
134+
. wasisdk/wasisdk_env.sh
135+
popd
134136

135137
if [ -f ${WASI_SYSROOT}/extra ]
136138
then
@@ -148,20 +150,6 @@ then
148150
touch ${WASI_SYSROOT}/extra
149151
fi
150152

151-
152-
if false
153-
then
154-
. ${SDKROOT}/wasisdk/wasisdk_env.sh
155-
env|grep WASI
156-
export CC=${WASI_SDK_DIR}/bin/clang
157-
export CPP=${WASI_SDK_DIR}/bin/clang-cpp
158-
export CXX=${WASI_SDK_DIR}/bin/clang++
159-
export CFLAGS="-D_WASI_EMULATED_SIGNAL"
160-
export LDFLAGS="-lwasi-emulated-signal"
161-
else
162-
. ${SDKROOT}/wasm32-wasi-shell.sh
163-
fi
164-
165153
# wasi does not use -sGLOBAL_BASE
166154
CC_PGLITE="-DCMA_MB=${CMA_MB}"
167155

0 commit comments

Comments
 (0)