forked from pyodide/pyodide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.envs
188 lines (154 loc) · 5.66 KB
/
Makefile.envs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
export PYVERSION ?= 3.11.3
export PYODIDE_EMSCRIPTEN_VERSION ?= 3.1.39
ifdef CPYTHON_DEBUG
export CPYTHON_ABI_FLAGS=d
endif
export PLATFORM_TRIPLET=wasm32-emscripten
export SYSCONFIG_NAME=_sysconfigdata_$(CPYTHON_ABI_FLAGS)_emscripten_$(PLATFORM_TRIPLET)
# BASH_ENV tells bash to run pyodide_env.sh on startup, which sets various
# environment variables. The next line instructs make to use bash to run each
# command.
export BASH_ENV := $(PYODIDE_ROOT)/pyodide_env.sh
SHELL := /bin/bash
version_tmp_1 := $(subst ., ,$(PYVERSION:v%=%))
# Handle alpha, beta, and release candidate versions
version_tmp_2 := $(subst a, ,$(version_tmp_1))
version_tmp_3 := $(subst b, ,$(version_tmp_2))
version_tuple := $(subst r, ,$(version_tmp_3))
export PYMAJOR=$(word 1,$(version_tuple))
export PYMINOR=$(word 2,$(version_tuple))
export PYMICRO=$(word 3,$(version_tuple))
export PYSTABLEVERSION=$(PYMAJOR).$(PYMINOR).$(PYMICRO)
export HOSTPYTHONROOT=$(shell python${PYMAJOR}.${PYMINOR} -c "import sys; print(sys.prefix)")
export HOSTPYTHON=$(HOSTPYTHONROOT)/bin/python$(PYMAJOR).$(PYMINOR)
export PYTHON_ARCHIVE_URL=https://www.python.org/ftp/python/$(PYSTABLEVERSION)/Python-$(PYVERSION).tgz
export PYTHON_ARCHIVE_SHA256=1a79f3df32265d9e6625f1a0b31c28eb1594df911403d11f3320ee1da1b3e048
export CPYTHONROOT=$(PYODIDE_ROOT)/cpython
export CPYTHONINSTALL=$(CPYTHONROOT)/installs/python-$(PYVERSION)
export CPYTHONLIB=$(CPYTHONINSTALL)/lib/python$(PYMAJOR).$(PYMINOR)
export SYSCONFIGDATA_DIR=$(CPYTHONINSTALL)/sysconfigdata/
export CPYTHONBUILD=$(CPYTHONROOT)/build/Python-$(PYVERSION)/
export TARGETINSTALLDIR=$(PYODIDE_ROOT)/cpython/installs/python-$(PYVERSION)
export HOSTINSTALLDIR=$(PYODIDE_ROOT)/packages/.artifacts
export HOSTSITEPACKAGES=$(PYODIDE_ROOT)/packages/.artifacts/lib/python$(PYMAJOR).$(PYMINOR)/site-packages
export WASM_LIBRARY_DIR=$(PYODIDE_ROOT)/packages/.libs
export PKG_CONFIG_PATH=$(PYODIDE_ROOT)/packages/.libs/lib/pkgconfig
export PYTHONINCLUDE=$(PYODIDE_ROOT)/cpython/installs/python-$(PYVERSION)/include/python$(PYMAJOR).$(PYMINOR)$(CPYTHON_ABI_FLAGS)
# Use env variable if defined, otherwise fallback to './'
export PYODIDE_BASE_URL?=./
# The compression level used for zip files and wheels. When distributing via a
# CDN it's more efficient to keep this value to 0, and let the CDN perform the
# Brotli compression.
export PYODIDE_ZIP_COMPRESSION_LEVEL?=6
export PIP_CONSTRAINT=$(PYODIDE_ROOT)/tools/constraints.txt
# For packages that depend on numpy.
# TODO: maybe move this somewhere else?
export NUMPY_LIB=$(HOSTSITEPACKAGES)/numpy/
# This environment variable is used for packages to detect if they are built
# for pyodide during build time
export PYODIDE=1
# This is the legacy environment variable used for the aforementioned purpose
export PYODIDE_PACKAGE_ABI=1
export DBGFLAGS_NODEBUG=-g0
export DBGFLAGS_WASMDEBUG=-g2
export DBGFLAGS_SOURCEMAPDEBUG=-g3
export DBG_LDFLAGS_SOURCEMAPDEBUG=-gseparate-dwarf
export DBGFLAGS=$(DBGFLAGS_NODEBUG)
ifdef PYODIDE_DEBUG
export PYODIDE_SYMBOLS=1
export PYODIDE_DEBUG_JS=1
export PYODIDE_ASSERTIONS=1
endif
ifdef PYODIDE_SOURCEMAP
# Debug with source maps (less useful than WASMDEBUG but easier if it helps)
export DBGFLAGS=$(DBGFLAGS_SOURCEMAPDEBUG)
export DBG_LDFLAGS=$(DBG_LDFLAGS_SOURCEMAPDEBUG)
else
ifdef PYODIDE_SYMBOLS
# Include debug symbols but no source maps (most useful)
export DBGFLAGS=$(DBGFLAGS_WASMDEBUG)
endif
endif
ifdef PYODIDE_ASSERTIONS
EXTRA_CFLAGS+= -DDEBUG_F
endif
export OPTFLAGS=-O2
export CFLAGS_BASE=\
$(OPTFLAGS) \
$(DBGFLAGS) \
-fPIC \
$(EXTRA_CFLAGS)
export LDFLAGS_BASE=\
$(OPTFLAGS) \
$(DBGFLAGS) \
$(DBG_LDFLAGS) \
-L$(CPYTHONROOT)/installs/python-$(PYVERSION)/lib/ \
-s WASM_BIGINT \
$(EXTRA_LDFLAGS)
export CXXFLAGS_BASE=\
-std=c++14
export SIDE_MODULE_LDFLAGS= $(LDFLAGS_BASE) -s SIDE_MODULE=1
export MAIN_MODULE_LDFLAGS= $(LDFLAGS_BASE) \
-s MAIN_MODULE=1 \
-s MODULARIZE=1 \
-s LZ4=1 \
-s EXPORT_NAME="'_createPyodideModule'" \
-s EXPORT_EXCEPTION_HANDLING_HELPERS \
-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \
-sEXPORTED_RUNTIME_METHODS='stackAlloc,stackRestore,stackSave' \
-s DEMANGLE_SUPPORT=1 \
-s USE_ZLIB \
-s USE_BZIP2 \
-s FORCE_FILESYSTEM=1 \
-s TOTAL_MEMORY=20971520 \
-s ALLOW_MEMORY_GROWTH=1 \
-s EXPORT_ALL=1 \
-s POLYFILL \
-s MIN_SAFARI_VERSION=140000 \
-s STACK_SIZE=5MB \
-s AUTO_JS_LIBRARIES=0 \
-s AUTO_NATIVE_LIBRARIES=0 \
-s NODEJS_CATCH_EXIT=0 \
-s NODEJS_CATCH_REJECTION=0 \
\
-lpython$(PYMAJOR).$(PYMINOR)$(CPYTHON_ABI_FLAGS) \
-lffi \
-lstdc++ \
-lidbfs.js \
-lnodefs.js \
-lproxyfs.js \
-lworkerfs.js \
-lwebsocket.js \
-leventloop.js \
\
-lGL \
-legl.js \
-lwebgl.js \
-lhtml5_webgl.js \
-sGL_WORKAROUND_SAFARI_GETCONTEXT_BUG=0
export SIDE_MODULE_CXXFLAGS = $(CXXFLAGS_BASE)
export SIDE_MODULE_CFLAGS= $(CFLAGS_BASE) -I$(PYTHONINCLUDE)
export MAIN_MODULE_CFLAGS= $(CFLAGS_BASE) \
-Wall \
-Wno-warn-absolute-paths \
-Werror=unused-variable \
-Werror=sometimes-uninitialized \
-Werror=int-conversion \
-Werror=incompatible-pointer-types \
-Werror=unused-result \
-I$(PYTHONINCLUDE) \
-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules']
export STDLIB_MODULE_CFLAGS= $(SIDE_MODULE_CFLAGS) -I Include/ -I . -I Include/internal/
# For RUST
export CARGO_BUILD_TARGET=wasm32-unknown-emscripten
export CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=emcc
export RUST_TOOLCHAIN=nightly-2023-04-29
export PYO3_CROSS_LIB_DIR=${CPYTHONINSTALL}/lib
export PYO3_CROSS_INCLUDE_DIR=${PYTHONINCLUDE}
# idealy we could automatically include all SIDE_MODULE_LDFLAGS here
export RUSTFLAGS= \
-C link-arg=-sSIDE_MODULE=2 \
-C link-arg=-sWASM_BIGINT \
-Z link-native-libraries=no
.output_vars:
set