@@ -5,34 +5,64 @@ Tooling for building CPython+Pygame on WebAssembly
55example building from within own pygame git clone tree on ubuntu 20.04 or linux mint :
66``` bash
77#! /bin/bash
8+ # update system
9+ sudo apt-get update
10+ sudo apt-get install -y git bash python3-pip curl lz4 pv
11+ sudo mkdir -p /opt/python-wasm-sdk && sudo chown $( whoami) /opt/python-wasm-sdk
12+
813
914# in github CI, current working dir would be /home/runner/pygame/pygame.
15+ [ -d ../pygame ] || git clone https://github.com/pygame/pygame
16+ if [ -f setup.py ]
17+ then
1018
11- # update system
12- sudo apt-get update
13- sudo apt-get install -y bash python3-pip curl pv
19+ # update cython
20+ if [ -f ../dev ]
21+ then
22+ echo " * not upgrading cython"
23+ else
24+ pip3 install git+https://github.com/cython/cython.git --user --upgrade
25+ fi
1426
15- # update cython
16- pip3 install git+https://github.com/cython/cython.git --upgrade
27+ # update source tree
28+ git clean -f
29+ git pull
1730
18- # update source tree
19- git clean -f
20- git pull
31+ mkdir -p /opt/python-wasm-sdk
2132
22- # sdk
23- sudo mkdir -p /opt/python-wasm-sdk && sudo chown $( whoami) /opt/python-wasm-sdk
24- curl -sL --retry 5 https://github.com/pygame-web/python-wasm-sdk/releases/download/0.1.0/python-wasm-sdk-stable.tar.bz2 \
25- | tar xvPj \
26- | pv -f -c -p -l -s 20626 > /dev/null
33+ # sdk
34+ if [ -f /opt/python-wasm-sdk/python3-wasm ]
35+ then
36+ echo " * not upgrading python-wasm-sdk"
37+ else
38+ echo " * using cached python-wasm-sdk archive"
39+
40+ if [ -f ../python-wasm-sdk-stable.tar.lz4 ]
41+ then
42+ # time tar xfvjP ../python-wasm-sdk-stable.tar.bz2 \
43+ # | pv -f -c -p -l -s 20626 >/dev/null
44+ time tar xfvP ../python-wasm-sdk-stable.tar.lz4 --use-compress-program=lz4 \
45+ | pv -f -c -p -l -s 20626 > /dev/null
46+ else
47+ curl -sL --retry 5 https://github.com/pygame-web/python-wasm-sdk/releases/download/0.2.0/python-wasm-sdk-stable.tar.bz2 \
48+ | tar xvPj \
49+ | pv -f -c -p -l -s 20626 > /dev/null
50+ fi
51+ fi
52+
53+ # build pygame
54+ touch $( find | grep pxd$)
55+ python3 setup.py config cython > /dev/null
56+
57+ /opt/python-wasm-sdk/python3-wasm setup.py -config -auto -sdl2 > /dev/null
2758
28- # build pygame
29- touch $( find | grep pxd$)
30- python3 setup.py config cython
59+ # /opt/python-wasm-sdk/python3-wasm setup.py build
60+ EMCC_CFLAGS=" -fPIC -I/opt/python-wasm-sdk/devices/emsdk/usr/include/SDL2 -s USE_SDL=2" /opt/python-wasm-sdk/python3-wasm setup.py build -j1
3161
32- /opt/python-wasm-sdk/python3-wasm setup.py -config -auto -sdl2
3362
34- /opt/python-wasm-sdk/python3-wasm setup.py build
63+ mkdir -p dist
64+ # get static lib
65+ SYS_PYTHON=python3 /opt/python-wasm-sdk/emsdk/upstream/emscripten/emar rcs dist/libpygame.a $( find build/temp.wasm32-* /| grep o$)
3566
36- # get static lib
37- SYS_PYTHON=python3 /opt/python-wasm-sdk/emsdk/upstream/emscripten/emar rcs libpygame.a $( find build/temp.wasm32-* /| grep o$)
67+ fi
3868```
0 commit comments