Skip to content

Commit 427aaec

Browse files
committed
fix glfw hints
1 parent 66fd3b8 commit 427aaec

File tree

7 files changed

+104
-2
lines changed

7 files changed

+104
-2
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ see https://github.com/pygame-community/pygame-ce/blob/main/.github/workflows/bu
77
for how to use it
88

99
or use as a cross compiler, after being unpacked in /opt/python-wasm-sdk, from within
10-
a source module distribution :
10+
a module source distribution :
1111

1212
eg `/opt/python-wasm-sdk/python3-wasm setup.py bdist_wheel`
1313

14+
or
15+
16+
`/opt/python-wasm-sdk/python3-wasm -m build --no-isolation .`
1417

scripts/emsdk-fetch.sh

+7
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,15 @@ then
4646
# wget https://raw.githubusercontent.com/paradust7/minetest-wasm/main/emsdk_emcc.patch
4747
# patch -p1 < emsdk_emcc.patch
4848

49+
echo "FIXME: Applying https://github.com/emscripten-core/emscripten/pull/21472 glfw3: gl level version major/minor hints"
50+
51+
pushd upstream/emscripten
52+
wget https://patch-diff.githubusercontent.com/raw/emscripten-core/emscripten/pull/21472.diff
53+
patch -p1 < 21472.diff
54+
popd
4955

5056
echo "FIXME: Applying https://github.com/emscripten-core/emscripten/pull/20442 fix mouse position for 3D canvas"
57+
5158
pushd upstream/emscripten
5259
wget https://patch-diff.githubusercontent.com/raw/emscripten-core/emscripten/pull/20442.diff
5360
patch -p1 < 20442.diff

scripts/wasisdk-fetch.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pushd ${SDKROOT}
1616
wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK}/wasi-sdk-${WASI_SDK}.0-linux.tar.gz
1717
tar xfz wasi-sdk-${WASI_SDK}.0-linux.tar.gz
1818
mv wasi-sdk-${WASI_SDK}.0 upstream && rm wasi-sdk-${WASI_SDK}.0-linux.tar.gz
19-
19+
20+
ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/cc
2021
ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/wasi-c
2122
ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/wasi-cpp
2223
ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/wasi-c++

wasisdk/bin/wasi-binfmt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
if [ -f /proc/sys/fs/binfmt_misc/wasm32-wasi ]
3+
then
4+
WASM=$1
5+
shift
6+
else
7+
echo ':wasm32-wasi:M::\x00asm:\xff\xff\xff\xff:/opt/python-wasm-sdk/wasisdk/bin/wasi-binfmt:' > /proc/sys/fs/binfmt_misc/register
8+
exit 0
9+
fi
10+
wasmtime --env PYTHONDONTWRITEBYTECODE=1 --dir /::/ -- $WASM $@
11+

wasisdk/hotfix/patch.h

+42
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ mktemp(char *tmpl)
5959
return tmpl;
6060
}
6161

62+
static int
63+
mkstemp(char *tmpl) {
64+
FILE *ftemp = fopen(mktemp(tmpl),"w");
65+
return fileno(ftemp);
66+
}
67+
68+
6269
#if 0
6370

6471
static char *
@@ -129,3 +136,38 @@ lockf(int fd, int cmd, off_t len) {
129136
return 0;
130137
}
131138

139+
static int
140+
pclose(FILE *stream){
141+
(void)stream;
142+
return 0;
143+
}
144+
145+
146+
static pid_t
147+
getpid(void) {
148+
char *val = getenv("WASIX_PID");
149+
char *end = val + strlen(val);
150+
if (val && val[0] != '\0') {
151+
return (pid_t)strtol(val, &end, 10);
152+
}
153+
#ifdef _WASIX_PID
154+
return (pid_t)(_WASIX_PID);
155+
#else
156+
return 66600;
157+
#endif
158+
}
159+
160+
161+
static pid_t
162+
getppid(void) {
163+
char *val = getenv("WASIX_PPID");
164+
char *end = val + strlen(val);
165+
if (val && val[0] != '\0') {
166+
return (pid_t)strtol(val, &end, 10);
167+
}
168+
#ifdef _WASIX_PPID
169+
return (pid_t)(_WASIX_PPID);
170+
#else
171+
return 1;
172+
#endif
173+
}

wasisdk/hotfix/wasi-setjmp.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef _WASIX_SETJMP_H
2+
#define _WASIX_SETJMP_H
3+
4+
typedef void *jmp_buf;
5+
6+
static int
7+
setjmp(jmp_buf env) {
8+
return 0;
9+
}
10+
static
11+
void longjmp(jmp_buf env, int value) {
12+
(void)env;
13+
(void)value;
14+
}
15+
16+
#endif

wasisdk/hotfix/wasi-wait.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
#ifndef _WASIX_SYS_WAIT_H
3+
#define _WASIX_SYS_WAIT_H
4+
5+
#include <bits/alltypes.h>
6+
7+
#define WNOHANG 1
8+
#define WUNTRACED 2
9+
10+
#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
11+
#define WTERMSIG(s) ((s) & 0x7f)
12+
#define WSTOPSIG(s) WEXITSTATUS(s)
13+
#define WIFEXITED(s) (!WTERMSIG(s))
14+
#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
15+
#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
16+
17+
typedef int pid_t;
18+
19+
pid_t wait(int *wstatus);
20+
pid_t waitpid(pid_t pid, int *status, int options);
21+
22+
#endif

0 commit comments

Comments
 (0)