2022-03-17 22:48:56 +00:00
|
|
|
export PYVERSION ?= 3.10.2
|
2022-03-24 06:31:13 +00:00
|
|
|
export PYODIDE_EMSCRIPTEN_VERSION ?= 2.0.27
|
2019-01-10 12:40:01 +00:00
|
|
|
|
2022-03-29 03:07:36 +00:00
|
|
|
export PLATFORM_TRIPLET=wasm32-emscripten
|
|
|
|
|
2022-03-08 05:51:20 +00:00
|
|
|
# BASH_ENV tells bash to run pyodide_env.sh on startup, which sets various
|
2021-01-03 11:25:14 +00:00
|
|
|
# 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
|
2018-05-16 17:06:44 +00:00
|
|
|
|
2021-03-26 14:37:59 +00:00
|
|
|
export TOOLSDIR=$(PYODIDE_ROOT)/tools
|
2021-07-06 11:28:39 +00:00
|
|
|
|
|
|
|
version_tuple := $(subst ., ,$(PYVERSION:v%=%))
|
|
|
|
export PYMAJOR=$(word 1,$(version_tuple))
|
|
|
|
export PYMINOR=$(word 2,$(version_tuple))
|
|
|
|
export PYMICRO=$(word 3,$(version_tuple))
|
|
|
|
|
|
|
|
export HOSTPYTHONROOT=$(shell python${PYMAJOR}.${PYMINOR} -c "import sys; print(sys.prefix)")
|
|
|
|
export HOSTPYTHON=$(HOSTPYTHONROOT)/bin/python$(PYMAJOR).$(PYMINOR)
|
2021-12-20 19:26:27 +00:00
|
|
|
|
|
|
|
export CPYTHONROOT=$(PYODIDE_ROOT)/cpython
|
|
|
|
export CPYTHONLIB=$(CPYTHONROOT)/installs/python-$(PYVERSION)/lib/python$(PYMAJOR).$(PYMINOR)
|
2022-03-17 22:48:56 +00:00
|
|
|
export CPYTHONBUILD=$(CPYTHONROOT)/build/Python-$(PYVERSION)/
|
2021-12-20 19:26:27 +00:00
|
|
|
|
|
|
|
export TARGETINSTALLDIR=$(PYODIDE_ROOT)/cpython/installs/python-$(PYVERSION)
|
|
|
|
export HOSTINSTALLDIR=$(PYODIDE_ROOT)/packages/.artifacts
|
2022-03-22 05:05:30 +00:00
|
|
|
export HOSTSITEPACKAGES=$(PYODIDE_ROOT)/packages/.artifacts/lib/python$(PYMAJOR).$(PYMINOR)/site-packages
|
2021-12-20 19:26:27 +00:00
|
|
|
|
2021-07-06 11:28:39 +00:00
|
|
|
export PYTHONINCLUDE=$(PYODIDE_ROOT)/cpython/installs/python-$(PYVERSION)/include/python$(PYMAJOR).$(PYMINOR)
|
2018-05-16 17:06:44 +00:00
|
|
|
|
2020-12-18 12:23:45 +00:00
|
|
|
# Use env variable if defined, otherwise fallback to './'
|
|
|
|
export PYODIDE_BASE_URL?=./
|
2021-01-01 07:48:28 +00:00
|
|
|
|
2021-12-25 20:08:43 +00:00
|
|
|
# For packages that depend on numpy.
|
|
|
|
# TODO: maybe move this somewhere else?
|
2022-03-10 04:34:25 +00:00
|
|
|
export NUMPY_LIB=$(HOSTINSTALLDIR)/numpy-wasm-libs
|
2022-04-01 03:40:12 +00:00
|
|
|
export OPEN_SSL_ROOT=$(PYODIDE_ROOT)/packages/openssl/build/openssl-1.1.1n/
|
|
|
|
|
2021-12-25 20:08:43 +00:00
|
|
|
|
2021-01-01 07:48:28 +00:00
|
|
|
# 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
|
2018-12-25 09:44:09 +00:00
|
|
|
export PYODIDE_PACKAGE_ABI=1
|
2021-03-26 14:37:59 +00:00
|
|
|
|
2021-12-17 21:08:25 +00:00
|
|
|
export DBGFLAGS=-g0
|
Fix scipy linking errors (#2289)
With newer versions of emscripten, linker errors surface eariler.
This makes it easier to find function pointer cast errors without
having to execute the bad code path -- the errors happen when the
wasm modules are linked (at load time in the browser)
Anyways, this fixes more linker errors. Mostly the problems have
to do with LAPACK functions that take string arguments. Most
LAPACK functions that take string arguments use them as enums and
only care about the first character of the string. Because of the
way that f2c works, we need to replace these strings with the ascii
code of the first character so we should replace:
sTRSV( 'UPPER', 'NOTRANS', 'NONUNIT', J, H, LDH, Y, 1 )
==>
CALL sTRSV( 85, 78, 78, J, H, LDH, Y, 1 )
where 85 and 78 are the ascii codes of U and N. Various character
variables are subbed into being integer variables. The two
functions `ilaenv` and `xerbla` expect actual C strings as an
argument, but it is very annoying to produce C strings so instead
I added wrapper functions ilaenvf2c and xerblaf2c to clapack and
instead of calling ilaenv and xerbla we call the f2c versions.
2022-03-24 06:17:29 +00:00
|
|
|
# export DBGFLAGS=-g3 -gseparate-dwarf -sSEPARATE_DWARF_URL=http://localhost:8001/
|
2021-12-09 18:31:21 +00:00
|
|
|
|
2021-03-26 14:37:59 +00:00
|
|
|
export OPTFLAGS=-O2
|
|
|
|
export CFLAGS_BASE=\
|
|
|
|
$(OPTFLAGS) \
|
2021-12-09 18:31:21 +00:00
|
|
|
$(DBGFLAGS) \
|
2021-03-26 14:37:59 +00:00
|
|
|
-fPIC \
|
|
|
|
$(EXTRA_CFLAGS)
|
|
|
|
|
|
|
|
export LDFLAGS_BASE=\
|
|
|
|
$(OPTFLAGS) \
|
2021-12-09 18:31:21 +00:00
|
|
|
$(DBGFLAGS) \
|
2021-03-26 14:37:59 +00:00
|
|
|
-s MODULARIZE=1 \
|
|
|
|
-s LINKABLE=1 \
|
|
|
|
-s EXPORT_ALL=1 \
|
|
|
|
-s WASM=1 \
|
|
|
|
-std=c++14 \
|
|
|
|
-s LZ4=1 \
|
2021-06-26 08:34:31 +00:00
|
|
|
-L $(CPYTHONROOT)/installs/python-$(PYVERSION)/lib/ \
|
2021-03-26 14:37:59 +00:00
|
|
|
$(EXTRA_LDFLAGS)
|
|
|
|
|
|
|
|
export CXXFLAGS_BASE=
|
|
|
|
|
|
|
|
export SIDE_MODULE_LDFLAGS= $(LDFLAGS_BASE) -s SIDE_MODULE=1
|
2021-11-18 22:37:47 +00:00
|
|
|
export MAIN_MODULE_LDFLAGS= $(LDFLAGS_BASE) \
|
|
|
|
-s MAIN_MODULE=1 \
|
|
|
|
-s EXPORT_NAME="'_createPyodideModule'" \
|
2021-03-26 14:37:59 +00:00
|
|
|
-s EXPORTED_FUNCTIONS='["___cxa_guard_acquire", "__ZNSt3__28ios_base4initEPv", "_main"]' \
|
2022-02-19 07:31:19 +00:00
|
|
|
-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \
|
|
|
|
-s DEMANGLE_SUPPORT=1 \
|
|
|
|
-s USE_FREETYPE=1 \
|
|
|
|
-s USE_LIBPNG=1 \
|
|
|
|
-s FORCE_FILESYSTEM=1 \
|
|
|
|
-s TOTAL_MEMORY=20971520 \
|
|
|
|
-s ALLOW_MEMORY_GROWTH=1 \
|
|
|
|
\
|
2021-07-06 11:28:39 +00:00
|
|
|
-lpython$(PYMAJOR).$(PYMINOR) \
|
2021-06-26 08:34:31 +00:00
|
|
|
-lffi \
|
|
|
|
-lsqlite3 \
|
|
|
|
-lbz2 \
|
|
|
|
-lstdc++ \
|
2021-11-18 22:37:47 +00:00
|
|
|
-lidbfs.js \
|
|
|
|
-lnodefs.js \
|
|
|
|
-lproxyfs.js \
|
|
|
|
-lworkerfs.js \
|
2022-02-19 07:31:19 +00:00
|
|
|
\
|
2021-12-05 20:34:09 +00:00
|
|
|
--use-preload-plugins \
|
2021-11-18 22:37:47 +00:00
|
|
|
--preload-file $(CPYTHONLIB)@/lib/python$(PYMAJOR).$(PYMINOR) \
|
|
|
|
--preload-file src/py/lib@/lib/python$(PYMAJOR).$(PYMINOR)/\
|
|
|
|
--exclude-file "*__pycache__*" \
|
|
|
|
--exclude-file "*/test/*" \
|
|
|
|
--exclude-file "*/tests/*" \
|
2022-01-30 19:08:44 +00:00
|
|
|
--exclude-file "*/distutils/*" \
|
|
|
|
--pre-js src/core/pre.js
|
2021-03-26 14:37:59 +00:00
|
|
|
|
2022-02-19 07:31:19 +00:00
|
|
|
|
2021-03-26 14:37:59 +00:00
|
|
|
export SIDE_MODULE_CXXFLAGS = $(CXXFLAGS_BASE)
|
|
|
|
|
|
|
|
export SIDE_MODULE_CFLAGS= $(CFLAGS_BASE)
|
|
|
|
export MAIN_MODULE_CFLAGS= $(CFLAGS_BASE) \
|
2021-12-05 20:34:09 +00:00
|
|
|
-Wall \
|
|
|
|
-Wno-warn-absolute-paths \
|
|
|
|
-Werror=unused-variable \
|
|
|
|
-Werror=sometimes-uninitialized \
|
|
|
|
-Werror=int-conversion \
|
|
|
|
-Werror=incompatible-pointer-types \
|
|
|
|
-Werror=unused-result \
|
2022-02-19 07:31:19 +00:00
|
|
|
-I$(PYTHONINCLUDE) \
|
2022-03-05 20:32:04 +00:00
|
|
|
-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules']
|
2021-03-26 14:37:59 +00:00
|
|
|
|
2022-03-12 06:05:36 +00:00
|
|
|
export STDLIB_MODULE_CFLAGS= $(SIDE_MODULE_CFLAGS) -I Include/ -I .
|
2021-03-26 14:37:59 +00:00
|
|
|
|
|
|
|
.output_vars:
|
|
|
|
set
|