Skip to content

Commit

Permalink
add nanoX/fltk prebuilts
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Jan 17, 2024
1 parent e48f4ef commit af5f909
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/cpython-build-emsdk-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ do
$pkg
done

# those depend on nanoX/microwindows compiled above
if [ -d $ROOT/sources.wasm/x11 ]
then
for pkg in $ROOT/sources.wasm/x11/*.sh
do
cd $ROOT
chmod +x $pkg
echo "
Third party (X11) : $pkg
"
$pkg
done
fi


cd $ROOT

Expand Down
119 changes: 119 additions & 0 deletions sources.wasm/microwindows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash

# X11 include dest /opt/python-wasm-sdk/./emsdk/upstream/emscripten/cache/sysroot/include/X11



. ${CONFIG:-config}


cd ${ROOT}/src

PKG=microwindows


if [ -f ${PKG}.patched ]
then
echo "
${PKG} already prepared
"
else
git clone --recursive https://github.com/pmp-p/${PKG}
pushd ${PKG}
popd
touch ${PKG}.patched
fi


if [ -f $PREFIX/lib/libX11.a ]
then
echo "
already built in $PREFIX/lib/libX11.a
"
else
. ${SDKROOT}/scripts/emsdk-fetch.sh


# mkdir -p $ROOT/build/${PKG}
cp -rf $ROOT/src/${PKG} $ROOT/build/

pushd $ROOT/build/${PKG}

patch -p1 <<END
diff --git a/src/nanox/client.c b/src/nanox/client.c
index 5c44e26..1fbe424 100644
--- a/src/nanox/client.c
+++ b/src/nanox/client.c
@@ -77,6 +77,19 @@
*/
#define SHM_BLOCK_SIZE 4096
+
+#if defined(__EMSCRIPTEN__) || defined(__wasi__)
+int nxGlobalLock = 0;
+#undef LOCK_DECLARE
+#undef LOCK
+#undef UNLOCK
+#undef LOCK_FREE
+#define LOCK_DECLARE(x)
+#define LOCK(l)
+#define UNLOCK(l)
+#define LOCK_FREE(l)
+#endif
+
#if !__ECOS
/* exported global data */
int nxSocket = -1; /* The network socket descriptor */
diff --git a/src/nanox/serv.h b/src/nanox/serv.h
index d7379a0..e1968b4 100644
--- a/src/nanox/serv.h
+++ b/src/nanox/serv.h
@@ -134,6 +134,15 @@
* in lock.h) for linked-in mode, or a no-op for client/server mode.
*/
+
+#if defined(__EMSCRIPTEN__) || defined(__wasi__)
+//static int gr_server_mutex = 0;
+#define SERVER_LOCK_DECLARE
+#define SERVER_LOCK_INIT()
+#define SERVER_LOCK()
+#define SERVER_UNLOCK()
+#else
+
#if NONETWORK
/* Use a server-side mutex. */
@@ -153,6 +162,7 @@ LOCK_EXTERN(gr_server_mutex);
#define SERVER_LOCK() do {} while(0) /* no-op, but require a ";" */
#define SERVER_UNLOCK() do {} while(0) /* no-op, but require a ";" */
#endif /* !NONETWORK*/
+#endif /* __EMSCRIPTEN__ __wasi__ */
/*
* Drawing types.
END

# FIXME: use pkg config !!!

EMCC_CFLAGS="-I${SDKROOT}/emsdk/upstream/emscripten/cache/sysroot/include/freetype2" \
CC=emcc CXX=emc++ emmake make -C src NX11=Y NANOX=Y ARCH=EMSCRIPTEN LINK_APP_INTO_SERVER=Y NANOXDEMO=N


if [ -f /pp ]
then
emcc -sASYNCIFY -o xhello.html -I./src/nx11/X11-local ./src/contrib/nx11-test/xhello.c -L./src/lib -lNX11 -lnano-X -lz -lfreetype -lSDL2; mv xhello.* /srv/www/html/wasm/x11/
fi
cp ./src/lib/{libNX11.a,libnano-X.a} $PREFIX/lib/
cp -r ./src/nx11/X11-local/X11 $PREFIX/include/
popd
fi

# for fltk build

cat <<END > ${SDKROOT}/emsdk/upstream/emscripten/cache/sysroot/include/X11/Xlocale.h
#define LC_CTYPE "C"
#define setlocale(ct0,ct1)
END


30 changes: 30 additions & 0 deletions sources.wasm/x11/fltk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

. ${CONFIG:-config}


cd ${ROOT}/src


PKG=fltk-wasm


if [ -f ${PKG}.patched ]
then
echo "
${PKG} already prepared
"
pushd ${PKG}
else
git clone --recursive https://github.com/pmp-p/${PKG}
pushd ${PKG}
touch ../${PKG}.patched
fi

. ${SDKROOT}/scripts/emsdk-fetch.sh

. fltk-wasm-build.sh


popd

0 comments on commit af5f909

Please sign in to comment.