2018-08-03 16:48:22 +00:00
|
|
|
from pathlib import Path
|
2020-05-08 23:28:44 +00:00
|
|
|
from typing import Optional, List
|
2018-06-20 18:54:47 +00:00
|
|
|
|
2018-06-20 19:05:13 +00:00
|
|
|
|
2018-09-21 11:30:28 +00:00
|
|
|
ROOTDIR = Path(__file__).parents[1].resolve() / 'tools'
|
2020-03-25 11:31:12 +00:00
|
|
|
HOSTPYTHON = ROOTDIR / '..' / 'cpython' / 'build' / '3.7.4' / 'host'
|
|
|
|
TARGETPYTHON = ROOTDIR / '..' / 'cpython' / 'installs' / 'python-3.7.4'
|
2018-06-22 14:22:00 +00:00
|
|
|
DEFAULTCFLAGS = ''
|
|
|
|
DEFAULTLDFLAGS = ' '.join([
|
2018-06-20 18:54:47 +00:00
|
|
|
'-O3',
|
|
|
|
'-s', "BINARYEN_METHOD='native-wasm'",
|
2018-06-20 19:05:13 +00:00
|
|
|
'-Werror',
|
2018-06-20 18:54:47 +00:00
|
|
|
'-s', 'EMULATED_FUNCTION_POINTERS=1',
|
|
|
|
'-s', 'EMULATE_FUNCTION_POINTER_CASTS=1',
|
|
|
|
'-s', 'SIDE_MODULE=1',
|
|
|
|
'-s', 'WASM=1',
|
|
|
|
'--memory-init-file', '0'
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
def parse_package(package):
|
2018-06-22 18:49:52 +00:00
|
|
|
# Import yaml here because pywasmcross needs to run in the built native
|
|
|
|
# Python, which won't have PyYAML
|
|
|
|
import yaml
|
2018-06-20 18:54:47 +00:00
|
|
|
# TODO: Validate against a schema
|
|
|
|
with open(package) as fd:
|
|
|
|
return yaml.load(fd)
|
2020-05-08 23:28:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def _parse_package_subset(query: str) -> Optional[List[str]]:
|
|
|
|
"""Parse the list of packages specified with PYODIDE_PACKAGES env var.
|
|
|
|
|
2020-05-08 23:46:59 +00:00
|
|
|
Also add the list of mandatory packages: ['micropip', 'distlib']
|
2020-05-08 23:28:44 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
a list of package names to build, or None if all packages should be
|
|
|
|
built.
|
|
|
|
"""
|
|
|
|
if not query:
|
|
|
|
# build all packages
|
|
|
|
return None
|
|
|
|
packages = query.split(',')
|
|
|
|
packages = [el.strip() for el in packages]
|
2020-05-08 23:46:59 +00:00
|
|
|
return ['micropip', 'distlib'] + packages
|