2018-08-03 16:48:22 +00:00
|
|
|
from pathlib import Path
|
2020-05-12 10:33:20 +00:00
|
|
|
from typing import Optional, Set
|
2020-12-07 23:19:16 +00:00
|
|
|
import sys
|
2018-06-20 19:05:13 +00:00
|
|
|
|
2020-06-28 18:24:40 +00:00
|
|
|
ROOTDIR = Path(__file__).parents[1].resolve() / "tools"
|
2020-12-07 23:19:16 +00:00
|
|
|
HOSTPYTHON = sys.prefix
|
2020-07-07 14:21:33 +00:00
|
|
|
TARGETPYTHON = ROOTDIR / ".." / "cpython" / "installs" / "python-3.8.2"
|
2020-06-28 18:24:40 +00:00
|
|
|
DEFAULTCFLAGS = ""
|
2020-12-03 13:27:40 +00:00
|
|
|
# fmt: off
|
2020-06-28 18:24:40 +00:00
|
|
|
DEFAULTLDFLAGS = " ".join(
|
|
|
|
[
|
2020-11-30 17:54:35 +00:00
|
|
|
"-O2",
|
2020-12-03 13:27:40 +00:00
|
|
|
"-s", "BINARYEN_METHOD='native-wasm'",
|
2020-06-28 18:24:40 +00:00
|
|
|
"-Werror",
|
2020-12-03 13:27:40 +00:00
|
|
|
"-s", "EMULATED_FUNCTION_POINTERS=1",
|
|
|
|
"-s", "EMULATE_FUNCTION_POINTER_CASTS=1",
|
|
|
|
"-s", "SIDE_MODULE=1",
|
|
|
|
"-s", "WASM=1",
|
|
|
|
"-s", "BINARYEN_TRAP_MODE='clamp'",
|
|
|
|
"--memory-init-file", "0",
|
|
|
|
"-s", "LINKABLE=1",
|
|
|
|
"-s", "EXPORT_ALL=1",
|
|
|
|
"-s", "ERROR_ON_MISSING_LIBRARIES=0",
|
2020-06-28 18:24:40 +00:00
|
|
|
]
|
|
|
|
)
|
2020-12-03 13:27:40 +00:00
|
|
|
# fmt: on
|
2018-06-20 18:54:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2020-06-28 18:24:40 +00:00
|
|
|
|
2018-06-20 18:54:47 +00:00
|
|
|
# TODO: Validate against a schema
|
|
|
|
with open(package) as fd:
|
2020-07-10 20:55:43 +00:00
|
|
|
return yaml.safe_load(fd)
|
2020-05-08 23:28:44 +00:00
|
|
|
|
|
|
|
|
2020-05-12 10:33:20 +00:00
|
|
|
def _parse_package_subset(query: Optional[str]) -> Optional[Set[str]]:
|
2020-05-08 23:28:44 +00:00
|
|
|
"""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:
|
2020-05-12 10:33:20 +00:00
|
|
|
a set of package names to build or None.
|
2020-05-08 23:28:44 +00:00
|
|
|
"""
|
2020-05-09 10:32:10 +00:00
|
|
|
if query is None:
|
2020-05-08 23:28:44 +00:00
|
|
|
return None
|
2020-06-28 18:24:40 +00:00
|
|
|
packages = query.split(",")
|
2020-05-08 23:28:44 +00:00
|
|
|
packages = [el.strip() for el in packages]
|
2020-06-28 18:24:40 +00:00
|
|
|
packages = ["micropip", "distlib"] + packages
|
2020-05-12 10:33:20 +00:00
|
|
|
return set(packages)
|