Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/reusable-emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ jobs:
run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug
- name: "Make build Python"
run: python3 Platforms/emscripten make-build-python
- name: "Display build info of the build Python"
run: python3 Platforms/emscripten pythoninfo-build
- name: "Make dependencies"
run: >-
python3 Platforms/emscripten make-dependencies
${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }}
- name: "Configure host Python"
- name: "Configure host/Emscripten Python"
run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
- name: "Make host Python"
- name: "Make host/Emscripten Python"
run: python3 Platforms/emscripten make-host
- name: "Display build info"
run: python3 Platforms/emscripten run --pythoninfo
- name: "Display build info of the host/Emscripten Python"
run: python3 Platforms/emscripten pythoninfo-host
- name: "Test"
run: python3 Platforms/emscripten run --test
44 changes: 35 additions & 9 deletions Platforms/emscripten/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ def make_build_python(context, working_dir):
print(f"🎉 {binary} {version}")


@subdir("native_build_dir")
def pythoninfo_build_python(context, working_dir):
"""Display build info of the build Python."""
call(["make", "pythoninfo"], quiet=context.quiet)


def check_shasum(file: str, expected_shasum: str):
with open(file, "rb") as f:
digest = hashlib.file_digest(f, "sha256")
Expand Down Expand Up @@ -580,41 +586,49 @@ def make_emscripten_python(context, working_dir):
subprocess.check_call([exec_script, "--version"])


def run_emscripten_python(context):
def run_emscripten_python(context, args=None):
"""Run the built emscripten Python."""
host_dir = context.build_paths["host_dir"]
exec_script = host_dir / "python.sh"
if not exec_script.is_file():
print("Emscripten not built", file=sys.stderr)
sys.exit(1)

args = context.args
# Strip the "--" separator if present
if args and args[0] == "--":
args = args[1:]
if args is None:
args = context.args
# Strip the "--" separator if present
if args and args[0] == "--":
args = args[1:]

if context.test:
args = load_config_toml()["test-args"] + args
elif context.pythoninfo:
args = load_config_toml()["pythoninfo-args"] + args
if context.test:
args = load_config_toml()["test-args"] + args
elif context.pythoninfo:
args = load_config_toml()["pythoninfo-args"] + args

os.execv(str(exec_script), [str(exec_script), *args])


def pythoninfo_emscripten_python(context):
"""Display build info of the host/Emscripten Python."""
run_emscripten_python(context, ["-m", "test.pythoninfo"])


def build_target(context):
"""Build one or more targets."""
steps = []
if context.target in {"build", "all"}:
steps.extend([
configure_build_python,
make_build_python,
pythoninfo_build_python,
])
if context.target in {"host", "all"}:
steps.extend([
make_emscripten_libffi,
make_mpdec,
configure_emscripten_python,
make_emscripten_python,
pythoninfo_emscripten_python,
])

for step in steps:
Expand Down Expand Up @@ -707,6 +721,10 @@ def main():
"make-build-python", help="Run `make` for the build Python"
)

pythoninfo_build = subcommands.add_parser(
"pythoninfo-build", help="Display build info of the build Python"
)

configure_host = subcommands.add_parser(
"configure-host",
help=(
Expand All @@ -719,6 +737,10 @@ def main():
"make-host", help="Run `make` for the host/emscripten"
)

pythoninfo_host = subcommands.add_parser(
"pythoninfo-host", help="Display build info of the host/Emscripten Python"
)

run = subcommands.add_parser(
"run",
help="Run the built emscripten Python",
Expand Down Expand Up @@ -770,8 +792,10 @@ def main():
make_mpdec_cmd,
make_dependencies_cmd,
make_build,
pythoninfo_build,
configure_host,
make_host,
pythoninfo_host,
clean,
):
subcommand.add_argument(
Expand Down Expand Up @@ -840,8 +864,10 @@ def main():
"make-dependencies": make_dependencies,
"configure-build-python": configure_build_python,
"make-build-python": make_build_python,
"pythoninfo-build": pythoninfo_build_python,
"configure-host": configure_emscripten_python,
"make-host": make_emscripten_python,
"pythoninfo-host": pythoninfo_emscripten_python,
"build": build_target,
"run": run_emscripten_python,
"clean": clean_contents,
Expand Down
Loading