From 0cdb657f37cc94ff203a89c7b0810e2213b42905 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Mon, 14 Oct 2024 10:50:14 +0200 Subject: [PATCH] wip --- .buildconfig | 2 +- .github/workflows/build_wasm_postgres.yml | 2 +- extra/postgis.diff | 11 ++++ extra/postgis.sh | 73 +++++++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 extra/postgis.diff create mode 100755 extra/postgis.sh diff --git a/.buildconfig b/.buildconfig index 77092486..a3e21e91 100644 --- a/.buildconfig +++ b/.buildconfig @@ -1,2 +1,2 @@ PG_VERSION=16.4 -SDK_VERSION=3.1.68.3bi +SDK_VERSION=3.1.69.6bi diff --git a/.github/workflows/build_wasm_postgres.yml b/.github/workflows/build_wasm_postgres.yml index 1d309c39..2558f8a1 100644 --- a/.github/workflows/build_wasm_postgres.yml +++ b/.github/workflows/build_wasm_postgres.yml @@ -21,7 +21,7 @@ jobs: TOTAL_MEMORY: 128MB DEBUG: false OBJDUMP: true - EXTRA_EXT: vector + EXTRA_EXT: vector postgis steps: - uses: actions/checkout@v4 diff --git a/extra/postgis.diff b/extra/postgis.diff new file mode 100644 index 00000000..a302bf55 --- /dev/null +++ b/extra/postgis.diff @@ -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 diff --git a/extra/postgis.sh b/extra/postgis.sh new file mode 100755 index 00000000..80d3e584 --- /dev/null +++ b/extra/postgis.sh @@ -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 < --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 +