Skip to content

Commit af5f909

Browse files
committed
add nanoX/fltk prebuilts
1 parent e48f4ef commit af5f909

File tree

3 files changed

+166
-0
lines changed

3 files changed

+166
-0
lines changed

scripts/cpython-build-emsdk-deps.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ do
2020
$pkg
2121
done
2222

23+
# those depend on nanoX/microwindows compiled above
24+
if [ -d $ROOT/sources.wasm/x11 ]
25+
then
26+
for pkg in $ROOT/sources.wasm/x11/*.sh
27+
do
28+
cd $ROOT
29+
chmod +x $pkg
30+
echo "
31+
32+
Third party (X11) : $pkg
33+
34+
35+
"
36+
$pkg
37+
done
38+
fi
39+
2340

2441
cd $ROOT
2542

sources.wasm/microwindows.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash
2+
3+
# X11 include dest /opt/python-wasm-sdk/./emsdk/upstream/emscripten/cache/sysroot/include/X11
4+
5+
6+
7+
. ${CONFIG:-config}
8+
9+
10+
cd ${ROOT}/src
11+
12+
PKG=microwindows
13+
14+
15+
if [ -f ${PKG}.patched ]
16+
then
17+
echo "
18+
${PKG} already prepared
19+
"
20+
else
21+
git clone --recursive https://github.com/pmp-p/${PKG}
22+
pushd ${PKG}
23+
popd
24+
touch ${PKG}.patched
25+
fi
26+
27+
28+
if [ -f $PREFIX/lib/libX11.a ]
29+
then
30+
echo "
31+
already built in $PREFIX/lib/libX11.a
32+
"
33+
else
34+
. ${SDKROOT}/scripts/emsdk-fetch.sh
35+
36+
37+
# mkdir -p $ROOT/build/${PKG}
38+
cp -rf $ROOT/src/${PKG} $ROOT/build/
39+
40+
pushd $ROOT/build/${PKG}
41+
42+
patch -p1 <<END
43+
diff --git a/src/nanox/client.c b/src/nanox/client.c
44+
index 5c44e26..1fbe424 100644
45+
--- a/src/nanox/client.c
46+
+++ b/src/nanox/client.c
47+
@@ -77,6 +77,19 @@
48+
*/
49+
#define SHM_BLOCK_SIZE 4096
50+
51+
+
52+
+#if defined(__EMSCRIPTEN__) || defined(__wasi__)
53+
+int nxGlobalLock = 0;
54+
+#undef LOCK_DECLARE
55+
+#undef LOCK
56+
+#undef UNLOCK
57+
+#undef LOCK_FREE
58+
+#define LOCK_DECLARE(x)
59+
+#define LOCK(l)
60+
+#define UNLOCK(l)
61+
+#define LOCK_FREE(l)
62+
+#endif
63+
+
64+
#if !__ECOS
65+
/* exported global data */
66+
int nxSocket = -1; /* The network socket descriptor */
67+
diff --git a/src/nanox/serv.h b/src/nanox/serv.h
68+
index d7379a0..e1968b4 100644
69+
--- a/src/nanox/serv.h
70+
+++ b/src/nanox/serv.h
71+
@@ -134,6 +134,15 @@
72+
* in lock.h) for linked-in mode, or a no-op for client/server mode.
73+
*/
74+
75+
+
76+
+#if defined(__EMSCRIPTEN__) || defined(__wasi__)
77+
+//static int gr_server_mutex = 0;
78+
+#define SERVER_LOCK_DECLARE
79+
+#define SERVER_LOCK_INIT()
80+
+#define SERVER_LOCK()
81+
+#define SERVER_UNLOCK()
82+
+#else
83+
+
84+
#if NONETWORK
85+
/* Use a server-side mutex. */
86+
87+
@@ -153,6 +162,7 @@ LOCK_EXTERN(gr_server_mutex);
88+
#define SERVER_LOCK() do {} while(0) /* no-op, but require a ";" */
89+
#define SERVER_UNLOCK() do {} while(0) /* no-op, but require a ";" */
90+
#endif /* !NONETWORK*/
91+
+#endif /* __EMSCRIPTEN__ __wasi__ */
92+
93+
/*
94+
* Drawing types.
95+
END
96+
97+
# FIXME: use pkg config !!!
98+
99+
EMCC_CFLAGS="-I${SDKROOT}/emsdk/upstream/emscripten/cache/sysroot/include/freetype2" \
100+
CC=emcc CXX=emc++ emmake make -C src NX11=Y NANOX=Y ARCH=EMSCRIPTEN LINK_APP_INTO_SERVER=Y NANOXDEMO=N
101+
102+
103+
if [ -f /pp ]
104+
then
105+
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/
106+
fi
107+
cp ./src/lib/{libNX11.a,libnano-X.a} $PREFIX/lib/
108+
cp -r ./src/nx11/X11-local/X11 $PREFIX/include/
109+
popd
110+
fi
111+
112+
# for fltk build
113+
114+
cat <<END > ${SDKROOT}/emsdk/upstream/emscripten/cache/sysroot/include/X11/Xlocale.h
115+
#define LC_CTYPE "C"
116+
#define setlocale(ct0,ct1)
117+
END
118+
119+

sources.wasm/x11/fltk.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
. ${CONFIG:-config}
4+
5+
6+
cd ${ROOT}/src
7+
8+
9+
PKG=fltk-wasm
10+
11+
12+
if [ -f ${PKG}.patched ]
13+
then
14+
echo "
15+
${PKG} already prepared
16+
"
17+
pushd ${PKG}
18+
else
19+
git clone --recursive https://github.com/pmp-p/${PKG}
20+
pushd ${PKG}
21+
touch ../${PKG}.patched
22+
fi
23+
24+
. ${SDKROOT}/scripts/emsdk-fetch.sh
25+
26+
. fltk-wasm-build.sh
27+
28+
29+
popd
30+

0 commit comments

Comments
 (0)