Skip to content

Commit

Permalink
fix glfw hints
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Mar 5, 2024
1 parent 66fd3b8 commit 427aaec
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ see https://github.com/pygame-community/pygame-ce/blob/main/.github/workflows/bu
for how to use it

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

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

or

`/opt/python-wasm-sdk/python3-wasm -m build --no-isolation .`

7 changes: 7 additions & 0 deletions scripts/emsdk-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ then
# wget https://raw.githubusercontent.com/paradust7/minetest-wasm/main/emsdk_emcc.patch
# patch -p1 < emsdk_emcc.patch

echo "FIXME: Applying https://github.com/emscripten-core/emscripten/pull/21472 glfw3: gl level version major/minor hints"

pushd upstream/emscripten
wget https://patch-diff.githubusercontent.com/raw/emscripten-core/emscripten/pull/21472.diff
patch -p1 < 21472.diff
popd

echo "FIXME: Applying https://github.com/emscripten-core/emscripten/pull/20442 fix mouse position for 3D canvas"

pushd upstream/emscripten
wget https://patch-diff.githubusercontent.com/raw/emscripten-core/emscripten/pull/20442.diff
patch -p1 < 20442.diff
Expand Down
3 changes: 2 additions & 1 deletion scripts/wasisdk-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pushd ${SDKROOT}
wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK}/wasi-sdk-${WASI_SDK}.0-linux.tar.gz
tar xfz wasi-sdk-${WASI_SDK}.0-linux.tar.gz
mv wasi-sdk-${WASI_SDK}.0 upstream && rm wasi-sdk-${WASI_SDK}.0-linux.tar.gz


ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/cc
ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/wasi-c
ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/wasi-cpp
ln ${SDKROOT}/wasisdk/bin/wasi ${SDKROOT}/wasisdk/bin/wasi-c++
Expand Down
11 changes: 11 additions & 0 deletions wasisdk/bin/wasi-binfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
if [ -f /proc/sys/fs/binfmt_misc/wasm32-wasi ]
then
WASM=$1
shift
else
echo ':wasm32-wasi:M::\x00asm:\xff\xff\xff\xff:/opt/python-wasm-sdk/wasisdk/bin/wasi-binfmt:' > /proc/sys/fs/binfmt_misc/register
exit 0
fi
wasmtime --env PYTHONDONTWRITEBYTECODE=1 --dir /::/ -- $WASM $@

42 changes: 42 additions & 0 deletions wasisdk/hotfix/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ mktemp(char *tmpl)
return tmpl;
}

static int
mkstemp(char *tmpl) {
FILE *ftemp = fopen(mktemp(tmpl),"w");
return fileno(ftemp);
}


#if 0

static char *
Expand Down Expand Up @@ -129,3 +136,38 @@ lockf(int fd, int cmd, off_t len) {
return 0;
}

static int
pclose(FILE *stream){
(void)stream;
return 0;
}


static pid_t
getpid(void) {
char *val = getenv("WASIX_PID");
char *end = val + strlen(val);
if (val && val[0] != '\0') {
return (pid_t)strtol(val, &end, 10);
}
#ifdef _WASIX_PID
return (pid_t)(_WASIX_PID);
#else
return 66600;
#endif
}


static pid_t
getppid(void) {
char *val = getenv("WASIX_PPID");
char *end = val + strlen(val);
if (val && val[0] != '\0') {
return (pid_t)strtol(val, &end, 10);
}
#ifdef _WASIX_PPID
return (pid_t)(_WASIX_PPID);
#else
return 1;
#endif
}
16 changes: 16 additions & 0 deletions wasisdk/hotfix/wasi-setjmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef _WASIX_SETJMP_H
#define _WASIX_SETJMP_H

typedef void *jmp_buf;

static int
setjmp(jmp_buf env) {
return 0;
}
static
void longjmp(jmp_buf env, int value) {
(void)env;
(void)value;
}

#endif
22 changes: 22 additions & 0 deletions wasisdk/hotfix/wasi-wait.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#ifndef _WASIX_SYS_WAIT_H
#define _WASIX_SYS_WAIT_H

#include <bits/alltypes.h>

#define WNOHANG 1
#define WUNTRACED 2

#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
#define WTERMSIG(s) ((s) & 0x7f)
#define WSTOPSIG(s) WEXITSTATUS(s)
#define WIFEXITED(s) (!WTERMSIG(s))
#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)

typedef int pid_t;

pid_t wait(int *wstatus);
pid_t waitpid(pid_t pid, int *status, int options);

#endif

0 comments on commit 427aaec

Please sign in to comment.