2018-02-23 19:34:33 +00:00
|
|
|
PYVERSION=3.5.2
|
|
|
|
PYMINOR=$(basename $(PYVERSION))
|
|
|
|
CPYTHON_EMSCRIPTEN_ROOT=../cpython-emscripten
|
|
|
|
|
|
|
|
CC=emcc
|
|
|
|
CXX=em++
|
|
|
|
OPTFLAGS=-O2
|
|
|
|
CXXFLAGS=-std=c++14 $(OPTFLAGS) -g -I $(CPYTHON_EMSCRIPTEN_ROOT)/installs/python-$(PYVERSION)/include/python$(PYMINOR)/ -Wno-warn-absolute-paths
|
|
|
|
LDFLAGS=$(OPTFLAGS) $(CPYTHON_EMSCRIPTEN_ROOT)/installs/python-$(PYVERSION)/lib/libpython$(PYMINOR).a \
|
2018-02-24 17:47:13 +00:00
|
|
|
-s "BINARYEN_METHOD='native-wasm,interpret-binary,interpret-asm2wasm'" \
|
2018-02-23 19:34:33 +00:00
|
|
|
-s TOTAL_MEMORY=268435456 \
|
|
|
|
-s ASSERTIONS=2 \
|
|
|
|
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
|
|
|
|
-s EXPORTED_FUNCTIONS='["_main"]' \
|
|
|
|
--memory-init-file 0
|
|
|
|
|
|
|
|
|
2018-02-26 15:02:52 +00:00
|
|
|
all: build/pyodide.asm.html build/pyodide.js
|
2018-02-23 19:34:33 +00:00
|
|
|
|
|
|
|
|
2018-02-26 15:02:52 +00:00
|
|
|
build/pyodide.asm.html: src/main.bc src/jsproxy.bc src/js2python.bc src/pylocals.bc \
|
|
|
|
src/python2js.bc src/runpython.bc root
|
2018-02-26 13:31:46 +00:00
|
|
|
$(CC) -s WASM=1 -s EXPORT_NAME="'pyodide'" --bind -o $@ $(filter %.bc,$^) $(LDFLAGS) \
|
2018-02-23 19:34:33 +00:00
|
|
|
$(foreach d,$(wildcard root/*),--preload-file $d@/$(notdir $d))
|
|
|
|
|
|
|
|
|
2018-02-26 15:02:52 +00:00
|
|
|
build/pyodide.js: src/pyodide.js
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
|
2018-02-23 19:34:33 +00:00
|
|
|
clean:
|
|
|
|
-rm -fr root
|
2018-02-26 15:02:52 +00:00
|
|
|
-rm build/*
|
|
|
|
-rm src/*.bc
|
2018-02-23 19:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
%.bc: %.cpp $(CPYTHON_EMSCRIPTEN_ROOT)/installs/python-$(PYVERSION)/lib/python$(PYMINOR)
|
2018-02-24 17:47:13 +00:00
|
|
|
$(CXX) --bind -o $@ $< $(CXXFLAGS)
|
2018-02-23 19:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
root: $(CPYTHON_EMSCRIPTEN_ROOT)/installs/python-$(PYVERSION)/lib/python$(PYMINOR)
|
|
|
|
mkdir -p root/lib
|
|
|
|
cp -a $(CPYTHON_EMSCRIPTEN_ROOT)/installs/python-$(PYVERSION)/lib/python$(PYMINOR)/ root/lib
|
|
|
|
( \
|
|
|
|
cd root/lib/python$(PYMINOR); \
|
|
|
|
rm -fr test distutils ensurepip idlelib __pycache__ tkinter; \
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
$(CPYTHON_EMSCRIPTEN_ROOT)/installs/python-$(PYVERSION)/lib/python$(PYMINOR):
|
|
|
|
make -C $(CPYTHON_EMSCRIPTEN_ROOT)/$(PYVERSION)
|