|
| 1 | +diff --git a/Programs/python.c b/Programs/python.c |
| 2 | +index 84148f7..348207e 100644 |
| 3 | +--- a/Programs/python.c |
| 4 | ++++ b/Programs/python.c |
| 5 | +@@ -2,16 +2,72 @@ |
| 6 | + |
| 7 | + #include "Python.h" |
| 8 | + |
| 9 | +-#ifdef MS_WINDOWS |
| 10 | +-int |
| 11 | +-wmain(int argc, wchar_t **argv) |
| 12 | ++#if __PYDK__ |
| 13 | ++#include "pycore_call.h" // _PyObject_CallNoArgs() |
| 14 | ++#include "pycore_initconfig.h" // _PyArgv |
| 15 | ++#include "pycore_interp.h" // _PyInterpreterState.sysdict |
| 16 | ++#include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0() |
| 17 | ++#include "pycore_pylifecycle.h" // _Py_PreInitializeFromPyArgv() |
| 18 | ++#include "pycore_pystate.h" // _PyInterpreterState_GET() |
| 19 | ++ |
| 20 | ++static PyStatus |
| 21 | ++pymain_init(const _PyArgv *args) |
| 22 | ++{ |
| 23 | ++ PyStatus status; |
| 24 | ++ |
| 25 | ++ status = _PyRuntime_Initialize(); |
| 26 | ++ if (_PyStatus_EXCEPTION(status)) { |
| 27 | ++ return status; |
| 28 | ++ } |
| 29 | ++ |
| 30 | ++ PyPreConfig preconfig; |
| 31 | ++ PyPreConfig_InitPythonConfig(&preconfig); |
| 32 | ++ |
| 33 | ++ status = _Py_PreInitializeFromPyArgv(&preconfig, args); |
| 34 | ++ if (_PyStatus_EXCEPTION(status)) { |
| 35 | ++ return status; |
| 36 | ++ } |
| 37 | ++ |
| 38 | ++ PyConfig config; |
| 39 | ++ PyConfig_InitPythonConfig(&config); |
| 40 | ++ |
| 41 | ++ if (args->use_bytes_argv) { |
| 42 | ++ status = PyConfig_SetBytesArgv(&config, args->argc, args->bytes_argv); |
| 43 | ++ } |
| 44 | ++ else { |
| 45 | ++ status = PyConfig_SetArgv(&config, args->argc, args->wchar_argv); |
| 46 | ++ } |
| 47 | ++ if (_PyStatus_EXCEPTION(status)) { |
| 48 | ++ goto done; |
| 49 | ++ } |
| 50 | ++ |
| 51 | ++ status = Py_InitializeFromConfig(&config); |
| 52 | ++ if (_PyStatus_EXCEPTION(status)) { |
| 53 | ++ goto done; |
| 54 | ++ } |
| 55 | ++ status = _PyStatus_OK(); |
| 56 | ++ |
| 57 | ++done: |
| 58 | ++ PyConfig_Clear(&config); |
| 59 | ++ return status; |
| 60 | ++} |
| 61 | ++ |
| 62 | ++static void |
| 63 | ++pymain_free(void) |
| 64 | + { |
| 65 | +- return Py_Main(argc, argv); |
| 66 | ++ _PyImport_Fini2(); |
| 67 | ++ _PyPathConfig_ClearGlobal(); |
| 68 | ++ _Py_ClearStandardStreamEncoding(); |
| 69 | ++ _Py_ClearArgcArgv(); |
| 70 | ++ _PyRuntime_Finalize(); |
| 71 | + } |
| 72 | ++ |
| 73 | ++#include "/opt/python-wasm-sdk/support/__EMSCRIPTEN__.c" |
| 74 | + #else |
| 75 | + int |
| 76 | + main(int argc, char **argv) |
| 77 | + { |
| 78 | ++ |
| 79 | + return Py_BytesMain(argc, argv); |
| 80 | + } |
| 81 | +-#endif |
| 82 | ++#endif //#if __PYDK__ |
| 83 | +diff --git a/configure b/configure |
| 84 | +index 0e5f3f6..5cf6451 100755 |
| 85 | +--- a/configure |
| 86 | ++++ b/configure |
| 87 | +@@ -9179,7 +9179,7 @@ fi |
| 88 | + |
| 89 | + as_fn_append LDFLAGS_NODIST " -sALLOW_MEMORY_GROWTH -sTOTAL_MEMORY=20971520" |
| 90 | + |
| 91 | +- as_fn_append LDFLAGS_NODIST " -sWASM_BIGINT" |
| 92 | ++ as_fn_append LDFLAGS_NODIST " " |
| 93 | + |
| 94 | + as_fn_append LDFLAGS_NODIST " -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js" |
| 95 | + |
| 96 | +diff --git a/configure.ac b/configure.ac |
| 97 | +index 4938681..ecad731 100644 |
| 98 | +--- a/configure.ac |
| 99 | ++++ b/configure.ac |
| 100 | +@@ -2103,7 +2103,7 @@ AS_CASE([$ac_sys_system], |
| 101 | + AS_VAR_APPEND([LDFLAGS_NODIST], [" -sALLOW_MEMORY_GROWTH -sTOTAL_MEMORY=20971520"]) |
| 102 | + |
| 103 | + dnl map int64_t and uint64_t to JS bigint |
| 104 | +- AS_VAR_APPEND([LDFLAGS_NODIST], [" -sWASM_BIGINT"]) |
| 105 | ++ AS_VAR_APPEND([LDFLAGS_NODIST], [" "]) |
| 106 | + |
| 107 | + dnl Include file system support |
| 108 | + AS_VAR_APPEND([LDFLAGS_NODIST], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"]) |
0 commit comments