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
|
2021-01-08 16:29:01 +00:00
|
|
|
import shutil
|
2018-06-20 19:05:13 +00:00
|
|
|
|
2021-01-01 07:48:28 +00:00
|
|
|
ROOTDIR = Path(__file__).parents[1].resolve()
|
|
|
|
TOOLSDIR = ROOTDIR / "tools"
|
|
|
|
TARGETPYTHON = ROOTDIR / "cpython" / "installs" / "python-3.8.2"
|
2021-01-08 16:29:01 +00:00
|
|
|
|
2021-01-02 08:17:14 +00:00
|
|
|
# Leading space so that argparse doesn't think this is a flag
|
|
|
|
DEFAULTCFLAGS = " -fPIC"
|
2021-01-03 00:17:08 +00:00
|
|
|
DEFAULTCXXFLAGS = ""
|
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-06-28 18:24:40 +00:00
|
|
|
"-Werror",
|
2020-12-03 13:27:40 +00:00
|
|
|
"-s", "EMULATE_FUNCTION_POINTER_CASTS=1",
|
2021-02-06 07:58:12 +00:00
|
|
|
"-s",'BINARYEN_EXTRA_PASSES="--pass-arg=max-func-params@61"',
|
2020-12-03 13:27:40 +00:00
|
|
|
"-s", "SIDE_MODULE=1",
|
|
|
|
"-s", "WASM=1",
|
|
|
|
"--memory-init-file", "0",
|
|
|
|
"-s", "LINKABLE=1",
|
|
|
|
"-s", "EXPORT_ALL=1",
|
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
|
|
|
|
|
|
|
|
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
|
2021-03-20 18:00:35 +00:00
|
|
|
packages = {el.strip() for el in query.split(",")}
|
|
|
|
packages.update(["micropip", "distlib"])
|
|
|
|
packages.discard("")
|
|
|
|
return packages
|
2021-01-08 16:29:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def file_packager_path() -> Path:
|
|
|
|
# Use emcc.py because emcc may be a ccache symlink
|
|
|
|
emcc_path = shutil.which("emcc.py")
|
|
|
|
if emcc_path is None:
|
|
|
|
raise RuntimeError(
|
|
|
|
"emcc.py not found. Setting file_packager.py path to /dev/null"
|
|
|
|
)
|
|
|
|
|
|
|
|
return Path(emcc_path).parent / "tools" / "file_packager.py"
|