mirror of
https://github.com/apple/swift.git
synced 2026-10-26 20:15:53 +01:00
Wire the `wasm32-unknown-emscripten` target through the build infrastructure. No Swift stdlib code yet. - Product classes `EmscriptenSysroot` and `EmscriptenLLVMRuntimeLibs` (emsdk sysroot + compiler-rt builtins), `EmscriptenStdlib` (configures the stdlib + SDK overlay against the sysroot), `EmscriptenSwiftSDK` (bundles the artifacts into a redistributable SDK archive). - CLI flags `--build-emscripten-stdlib`, `--skip-test-emscripten-stdlib`, `--emscripten-path`. Default build flows are unaffected unless `--build-emscripten-stdlib` is passed. - `utils/wasm/emscripten-run.py` runner (Node.js), alongside `utils/wasm/wasi-run.py`. - `SwiftUtils.cmake` adds the `SWIFT_WASM_HOSTED_SDKS` registry and `sdk_has_wasm_sysroot()` so `test/CMakeLists.txt` derives the per-SDK embedded test target instead of hardcoding WASI. - `stdlib/public/CMakeLists.txt` and `test/CMakeLists.txt` handle the `EMSCRIPTEN` SDK but stay inert until `SWIFT_EMSCRIPTEN_SYSROOT_PATH` is set, which only happens via `--build-emscripten-stdlib`.
51 lines
1.5 KiB
Python
Executable File
51 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def collect_wasm_env(local_env=os.environ, prefix='WASM_RUN_CHILD_'):
|
|
return dict((key[len(prefix):], value)
|
|
for key, value in local_env.items() if key.startswith(prefix))
|
|
|
|
|
|
class EmscriptenRunner(object):
|
|
def __init__(self):
|
|
pass
|
|
|
|
def run(self, args):
|
|
command = self.invocation(args)
|
|
if args.verbose:
|
|
print(' '.join(command), file=sys.stderr)
|
|
if not args.dry_run:
|
|
subprocess.check_call(command)
|
|
|
|
def invocation(self, args):
|
|
command = ["node"]
|
|
env_vars = collect_wasm_env()
|
|
for key, value in env_vars.items():
|
|
# Node.js inherits env from the process, so set them in os.environ
|
|
os.environ[key] = value
|
|
command.extend(args.command)
|
|
return command
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('-v', '--verbose', action='store_true', dest='verbose',
|
|
help='print commands as they are run')
|
|
parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
|
|
help="print the commands that would have been run, but"
|
|
" don't actually run them")
|
|
parser.add_argument('command', nargs=argparse.REMAINDER,
|
|
help='the command to run', metavar='command...')
|
|
args = parser.parse_args()
|
|
runner = EmscriptenRunner()
|
|
runner.run(args)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|