Skip to content

Commit

Permalink
adjust dyld patch
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Aug 23, 2023
1 parent fb7c11f commit 9881f68
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 38 deletions.
9 changes: 5 additions & 4 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PYTHONDONTWRITEBYTECODE=1
export REBUILD=${REBUILD:-false}
export CI=${CI:-false}

export PYBUILD=${PYBUILD:-3.11}
export PYBUILD=${PYBUILD:-3.12}
export PYMAJOR=$(echo -n $PYBUILD|cut -d. -f1)
export PYMINOR=$(echo -n $PYBUILD|cut -d. -f2)

Expand Down Expand Up @@ -42,11 +42,12 @@ fi


#stable
# EMFLAVOUR=latest
# EMFLAVOUR=${EMFLAVOUR:-latest}
# embind broke after 3.1.34
# export EMFLAVOUR=${EMFLAVOUR:-3.1.34}
# export EMFLAVOUR=${EMFLAVOUR:latest}

export EMFLAVOUR=${EMFLAVOUR:-3.1.34}

EMFLAVOUR=${EMFLAVOUR:-tot}

# no extra wasm features
export WASMFLAVOUR=mvp
Expand Down
12 changes: 7 additions & 5 deletions scripts/cpython-build-emsdk-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
. ${CONFIG:-config}



for pkg in $ROOT/sources.wasm/*.sh
do
pushd $ROOT/src
cd $ROOT
chmod +x $pkg
echo "
Third party : $pkg
"
$pkg
popd
done


cd $ROOT/src

cd $ROOT

. ./scripts/emsdk-fetch.sh
Expand Down
1 change: 1 addition & 0 deletions scripts/cpython-build-emsdk-prebuilt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ echo "

$PIP install --upgrade pip

$PIP install --upgrade build

# make wheels
# /opt/python-wasm-sdk/python3-wasm setup.py bdist_wheel
Expand Down
15 changes: 7 additions & 8 deletions scripts/cpython-build-emsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,17 @@ mkdir -p $PYTHONPYCACHEPREFIX/sysconfig


# FIXME: seems CI cannot locate that one with python3-wasm
cp $PREFIX/lib/python${PYBUILD}/_sysconfigdata__emscripten_wasm32-emscripten.py \
${SDKROOT}/prebuilt/emsdk/${PYBUILD}/_sysconfigdata__emscripten_debug.py

sed -i 's|-Os|-O0|g' ${SDKROOT}/prebuilt/emsdk/${PYBUILD}/_sysconfigdata__emscripten_debug.py
sed -i 's|-g0|-g3|g' ${SDKROOT}/prebuilt/emsdk/${PYBUILD}/_sysconfigdata__emscripten_debug.py
MODSYSCONFIG="${SDKROOT}/prebuilt/emsdk/${PYBUILD}/_sysconfigdata__emscripten_debug.py"

#cp ${SDKROOT}/prebuilt/emsdk/${PYBUILD}/_sysconfigdata__emscripten_debug.py \
# $PREFIX/lib/python${PYBUILD}/
cp $PREFIX/lib/python${PYBUILD}/_sysconfigdata__emscripten_wasm32-emscripten.py \
${MODSYSCONFIG}

# python setup.py install --single-version-externally-managed --root=/
# pip3 install .
sed -i 's|-Os|-O0|g' ${MODSYSCONFIG}
sed -i 's|-g0|-g3|g' ${MODSYSCONFIG}

# this one is required for `python3-wasm -mbuild` venv
ln ${MODSYSCONFIG} ${SDKROOT}/devices/$(arch)/usr/lib/python${PYBUILD}/

# cmake usually wants cc
ln ${SDKROOT}/emsdk/upstream/emscripten/emcc ${SDKROOT}/emsdk/upstream/emscripten/cc
Expand Down
7 changes: 4 additions & 3 deletions sources.wasm/assimp.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash



. ${CONFIG:-config}
. scripts/emsdk-fetch.sh

export ASSIMP="assimpjs-wasm"

cd ${ROOT}/src

export ASSIMP="assimpjs-wasm"

if [ -f assimp.patched ]
then
Expand Down Expand Up @@ -38,4 +40,3 @@ else
popd
fi

cd $SDKROOT
5 changes: 5 additions & 0 deletions sources.wasm/ncurses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

. ${CONFIG:-config}

. scripts/emsdk-fetch.sh


cd ${ROOT}/src

# --disable-database --enable-termcap

NCOPTS="--enable-ext-colors --enable-ext-mouse --prefix=$PREFIX --disable-echo --without-pthread \
Expand Down
5 changes: 4 additions & 1 deletion sources.wasm/openssl.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/bin/bash

. ${CONFIG:-config}
. scripts/emsdk-fetch.sh

cd ${ROOT}/src
export OPENSSL="openssl-1.1.1s"
export URL_OPENSSL=${URL_OPENSSL:-"URL https://ftp.openssl.org/source/$OPENSSL.tar.gz"}
export HASH_OPENSSL="URL_HASH SHA256=c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa"

. scripts/emsdk-fetch.sh


if [ -f openssl.patched ]
then
Expand Down Expand Up @@ -72,3 +74,4 @@ else
cp libcrypto.a libssl.a "$PREFIX/lib"
popd
fi

34 changes: 17 additions & 17 deletions support/__EMSCRIPTEN__.embed/browsermodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Object_await(Object *self) {
wrapper->asyncio_future_blocking = 0;

wrapper->result = (EM_VAL)EM_ASM_INT({
var value = emval_handle_array[$0].value;
var value = Emval.toValue($0);
if (value && typeof value.then === "function") {
value.then(function (result) {
__py_notify_done($1, Emval.toHandle(result));
Expand Down Expand Up @@ -324,7 +324,7 @@ Object_await(Object *self) {
static PyObject *
Object_repr(Object *self) {
char *str = (char *)EM_ASM_INT({
var value = emval_handle_array[$0].value;
var value = Emval.toValue($0);
var str = value.constructor ? value.constructor.name : 'Object';
var len = lengthBytesUTF8(str) + 1;
var buffer = _malloc(len);
Expand All @@ -351,7 +351,7 @@ Object_hash(Object *self) {
static PyObject *
Object_str(Object *self) {
char *str = (char *)EM_ASM_INT({
var str = emval_handle_array[$0].value.toString();
var str = Emval.toValue($0).toString();
var len = lengthBytesUTF8(str) + 1;
var buffer = _malloc(len);
stringToUTF8(str, buffer, len);
Expand All @@ -369,7 +369,7 @@ Object_str(Object *self) {
static Py_ssize_t
Object_length(Object *self) {
int len = EM_ASM_INT({
var val = emval_handle_array[$0].value;
var val = Emval.toValue($0);
if (val[Symbol.iterator] && val.length !== undefined) {
return val.length;
}
Expand Down Expand Up @@ -399,7 +399,7 @@ Object_getprop(Object *self, PyObject *item) {

EM_VAL result = (EM_VAL)EM_ASM_INT({
try {
return Emval.toHandle(emval_handle_array[$0].value[emval_handle_array[$1].value]);
return Emval.toHandle(Emval.toValue($0)[Emval.toValue($1)]);
}
catch (ex) {
return -Emval.toHandle(ex);
Expand Down Expand Up @@ -490,7 +490,7 @@ Object_richcompare(Object *self, PyObject *other, int op) {
static PyObject *
Object_iter(Object *self) {
EM_VAL val = (EM_VAL)EM_ASM_INT({
var val = emval_handle_array[$0].value;
var val = Emval.toValue($0);
if (val[Symbol.iterator]) {
return Emval.toHandle(val[Symbol.iterator]());
} else {
Expand Down Expand Up @@ -518,7 +518,7 @@ Object_iter(Object *self) {
static PyObject *
Object_next(Object *self) {
EM_VAL val = (EM_VAL)EM_ASM_INT({
var val = emval_handle_array[$0].value;
var val = Emval.toValue($0);
if (!val.next) {
return 0;
}
Expand All @@ -545,7 +545,7 @@ static PyObject *
Object_dir(Object *self, PyObject *noarg) {
return emval_to_py((EM_VAL)EM_ASM_INT({
var props = [];
for (var prop in emval_handle_array[$0].value) {
for (var prop in Emval.toValue($0)) {
props.push(prop);
}
return Emval.toHandle(props);
Expand Down Expand Up @@ -620,7 +620,7 @@ Function_call(Function *self, PyObject *args, PyObject *kwargs) {
case 0:
result = (EM_VAL)EM_ASM_INT({
try {
return Emval.toHandle(emval_handle_array[$0].value.call(emval_handle_array[$1].value));
return Emval.toHandle(Emval.toValue($0).call(Emval.toValue($1)));
}
catch (ex) {
return -Emval.toHandle(ex);
Expand All @@ -635,7 +635,7 @@ Function_call(Function *self, PyObject *args, PyObject *kwargs) {
}
result = (EM_VAL)EM_ASM_INT({
try {
return Emval.toHandle(emval_handle_array[$0].value.call(emval_handle_array[$1].value, emval_handle_array[$2].value));
return Emval.toHandle(Emval.toValue($0).call(Emval.toValue($1), Emval.toValue($2)));
}
catch (ex) {
return -Emval.toHandle(ex);
Expand Down Expand Up @@ -668,9 +668,9 @@ Function_call(Function *self, PyObject *args, PyObject *kwargs) {
for (var i = 0; i < $2; ++i) {
var arg_handle = getValue($3+i*4, 'i32');
arg_handles.push(arg_handle);
arg_values.push(emval_handle_array[arg_handle].value);
arg_values.push(Emval.toValue(arg_handle));
}
return Emval.toHandle(emval_handle_array[$0].value.apply(emval_handle_array[$1].value, arg_values));
return Emval.toHandle(Emval.toValue($0).apply(Emval.toValue($1), arg_values));
}
catch (ex) {
return -Emval.toHandle(ex);
Expand Down Expand Up @@ -709,7 +709,7 @@ static PyTypeObject Function_Type = {
static PyObject *
Symbol_description(Symbol *self, void *unused) {
char *str = (char *)EM_ASM_INT({
var str = emval_handle_array[$0].value.description;
var str = Emval.toValue($0).description;
var len = lengthBytesUTF8(str) + 1;
var buffer = _malloc(len);
stringToUTF8(str, buffer, len);
Expand Down Expand Up @@ -896,7 +896,7 @@ static EM_VAL py_to_emval(PyObject *val) {
setValue(argv+i*4, Emval.toHandle(arguments[i]), 'i32');
}
var result = __py_call($1, $2, Emval.toHandle(this), argc, argv);
return emval_handle_array[result].value;
return Emval.toValue(result);
}
});
}, callback_id, func, self, max_args);
Expand Down Expand Up @@ -933,7 +933,7 @@ static PyObject *emval_to_py(EM_VAL handle) {

// Extract the message and the exception type.
int type = EM_ASM_INT({
var exc = emval_handle_array[$0].value;
var exc = Emval.toValue($0);
try {
if (exc.message) {
stringToUTF8(exc.message, $1, 512);
Expand Down Expand Up @@ -978,7 +978,7 @@ static PyObject *emval_to_py(EM_VAL handle) {
} target;

int type = EM_ASM_INT(({
var value = emval_handle_array[$0].value;
var value = Emval.toValue($0);
var type = typeof value;
if (type === "number") {
// Check whether it fits in an int.
Expand Down Expand Up @@ -1061,7 +1061,7 @@ browser_getattr(PyObject *self, PyObject *arg) {
}
EM_VAL result = (EM_VAL)EM_ASM_INT({
try {
return Emval.toHandle(window[emval_handle_array[$0].value]);
return Emval.toHandle(window[Emval.toValue($0)]);
}
catch (ex) {
return -Emval.toHandle(ex);
Expand Down

0 comments on commit 9881f68

Please sign in to comment.