Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Oct 14, 2024
1 parent cf50f47 commit 0cdb657
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .buildconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PG_VERSION=16.4
SDK_VERSION=3.1.68.3bi
SDK_VERSION=3.1.69.6bi
2 changes: 1 addition & 1 deletion .github/workflows/build_wasm_postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
TOTAL_MEMORY: 128MB
DEBUG: false
OBJDUMP: true
EXTRA_EXT: vector
EXTRA_EXT: vector postgis

steps:
- uses: actions/checkout@v4
Expand Down
11 changes: 11 additions & 0 deletions extra/postgis.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- postgis-3.5.0/configure
+++ postgis-3.5.0-wasm/configure
@@ -18972,7 +18972,7 @@

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking PROJ version via compiled code" >&5
$as_echo_n "checking PROJ version via compiled code... " >&6; }
- if test "$cross_compiling" = yes; then :
+ if test "$cross_compiling_not_a_problem" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run test program while cross compiling
73 changes: 73 additions & 0 deletions extra/postgis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

BUILD=build
mkdir -p ${BUILD}



pushd ${BUILD}
if [ -d postgis-3.5.0 ]
then
echo -n
else
[ -f postgis-3.5.0.tar.gz ] || wget -c https://download.osgeo.org/postgis/source/postgis-3.5.0.tar.gz
tar xfz postgis-3.5.0.tar.gz && rm postgis-3.5.0.tar.gz
pushd postgis-3.5.0
patch -p1 < ${WORKSPACE}/extra/postgis.diff
popd
fi
popd

if which emcc
then
echo -n
else
reset;
. /opt/python-wasm-sdk/wasm32-bi-emscripten-shell.sh
export PGROOT=${PGROOT:-/tmp/pglite}
export PATH=${PGROOT}/bin:$PATH
fi

pushd ${BUILD}/postgis-3.5.0

cat > config.site <<END
ac_cv_exeext=.cjs
POSTGIS_PROJ_VERSION=94
ICONV_CFLAGS=
ICONV_LDFLAGS=
with_libiconv=$PREFIX
ac_cv_func_iconv=no
ac_cv_func_iconvctl=no
cross_compiling=yes
ac_cv_lib_proj_pj_get_release=no
ac_cv_header_proj_api_h=no
END

# --without-raster --without-topology --without-address-standardizer
# --without-raster => --with-gdalconfig=
# --with-gdalconfig=$PREFIX/bin/gdal-config
CONFIG_SITE=config.site emconfigure ./configure \
--without-raster --without-topology --without-address-standardizer \
--with-gdalconfig=$PREFIX/bin/gdal-config \
--without-gui --without-phony-revision --without-protobuf \
--without-interrupt-tests --without-json \
--without-libiconv --without-libiconv-prefix \
--with-pgconfig=/tmp/pglite/bin/pg_config \
--with-xml2config=$SDKROOT/devices/emsdk/usr/bin/xml2-config \
--with-projdir=$SDKROOT/devices/emsdk/usr \
--with-geosconfig=$SDKROOT/devices/emsdk/usr/bin/geos-config $@

# workaround iconv
mkdir -p loader/no/lib

# or would fail on some frontend functions linking.
sed -i 's/PGSQL_FE_LDFLAGS=-L/PGSQL_FE_LDFLAGS=-O0 -g3 -sERROR_ON_UNDEFINED_SYMBOLS=0 -L/g' loader/Makefile
#DEFAULT_LIBRARY_FUNCS_TO_INCLUDE="_emscripten_memcpy_js"
EMCC_CFLAGS="-O0 -g3 -sERROR_ON_UNDEFINED_SYMBOLS=0 -Wno-unused-function -lpng -ljpeg" emmake make
# /opt/python-wasm-sdk/devices/emsdk/usr/lib/libgeos.a
rm postgis/postgis-3.s*
PATH=/tmp/pglite/bin:$PATH PG_LINK="em++ $PREFIX/lib/libgeos.a $EMSDK/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/libsqlite3.a" emmake make install
rm $PGROOT/share/postgresql/extension/postgis*.sql
cp ./extensions/postgis/sql/postgis--3.5.0.sql $PGROOT/share/postgresql/extension/postgis--3.5.0.sql

popd

0 comments on commit 0cdb657

Please sign in to comment.