Lines Matching +full:platform +full:- +full:sdk +full:- +full:version
4 $ ./Tools/wasm/wasm_builder.py emscripten-browser build repl
5 $ ./Tools/wasm/wasm_builder.py emscripten-node-dl build test
8 Primary build targets are "emscripten-node-dl" (NodeJS, dynamic linking),
9 "emscripten-browser", and "wasi".
11 Emscripten builds require a recent Emscripten SDK. The tools looks for an
15 WASI builds require WASI SDK and wasmtime. The tool looks for 'WASI_SDK_PATH'
16 and falls back to /opt/wasi-sdk.
21 ./Tools/wasm/wasm_builder.py --clean build build
55 # path to WASI-SDK root
56 WASI_SDK_PATH = pathlib.Path(os.environ.get("WASI_SDK_PATH", "/opt/wasi-sdk"))
58 # path to Emscripten SDK config file.
59 # auto-detect's EMSDK in /opt/emsdk without ". emsdk_env.sh".
63 (3, 1, 14): "https://github.com/emscripten-core/emscripten/issues/17338",
64 (3, 1, 16): "https://github.com/emscripten-core/emscripten/issues/17393",
65 (3, 1, 20): "https://github.com/emscripten-core/emscripten/issues/17720",
73 run "make clean -C '{SRCDIR}'".
77 Builds require a C compiler (gcc, clang), make, pkg-config, and development
80 Debian/Ubuntu: sudo apt install build-essential git curl pkg-config zlib1g-dev
81 Fedora/CentOS: sudo dnf install gcc make git-core curl pkgconfig zlib-devel
85 wasm32-emscripten builds need Emscripten SDK. Please follow instructions at
87 Emscripten and how to activate the SDK with "emsdk_env.sh".
89 git clone https://github.com/emscripten-core/emsdk.git /path/to/emsdk
97 wasm32-wasi builds need WASI SDK. Please fetch the latest SDK from
98 https://github.com/WebAssembly/wasi-sdk/releases and install it to
99 "/opt/wasi-sdk". Alternatively you can install the SDK in a different location
101 of the SDK. The SDK is available for Linux x86_64, macOS x86_64, and MinGW.
105 wasm32-wasi tests require wasmtime on PATH. Please follow instructions at
112 ) -> Tuple[pathlib.PurePath, pathlib.PurePath]:
121 with open(emconfig, encoding="utf-8") as f:
134 def read_python_version(configure: pathlib.Path = CONFIGURE) -> str:
138 minor version number.
141 with configure.open(encoding="utf-8") as f:
170 class Platform: class
171 """Platform-specific settings
173 - CONFIG_SITE override
174 - configure wrapper (e.g. emconfigure)
175 - make wrapper (e.g. emmake)
176 - additional environment variables
177 - check function to verify SDK
191 def getenv(self, profile: "BuildProfile") -> dict:
210 if sys.platform == "linux":
211 # skip pkg-config check on macOS
212 if not shutil.which("pkg-config"):
213 raise MissingDependency("pkg-config", INSTALL_NATIVE)
217 subprocess.check_call(["pkg-config", "--exists", devel])
223 NATIVE = Platform(
239 raise MissingDependency("Emscripten SDK EM_CONFIG", INSTALL_EMSDK)
244 # version check
245 version_txt = EMSCRIPTEN_ROOT / "emscripten-version.txt"
249 version = f.read().strip().strip('"')
250 if version.endswith("-git"):
251 # git / upstream / tot-upstream installation
252 version = version[:-4]
253 version_tuple = tuple(int(v) for v in version.split("."))
257 f"Emscripten SDK {version} in '{EMSCRIPTEN_ROOT}' is older than "
258 "minimum required version "
266 f"Emscripten SDK {version} in '{EMSCRIPTEN_ROOT}' has known "
278 EMSCRIPTEN = Platform(
281 config_site=WASMTOOLS / "config.site-wasm32-emscripten",
287 # workaround for https://github.com/emscripten-core/emscripten/issues/17635
297 wasm_ld = WASI_SDK_PATH / "bin" / "wasm-ld"
306 WASI = Platform(
309 config_site=WASMTOOLS / "config.site-wasm32-wasi",
310 configure_wrapper=WASMTOOLS / "wasi-env",
319 "--env PYTHONPATH=/{relbuilddir}/build/lib.wasi-wasm32-{version}:/Lib "
320 "--mapdir /::{srcdir} --"
331 wasm32_emscripten = "wasm32-unknown-emscripten"
332 wasm64_emscripten = "wasm64-unknown-emscripten"
333 wasm32_wasi = "wasm32-unknown-wasi"
334 wasm64_wasi = "wasm64-unknown-wasi"
335 # current platform
339 def platform(self) -> Platform: member in Host
348 def is_emscripten(self) -> bool:
353 def is_wasi(self) -> bool:
357 def get_extra_paths(self) -> Iterable[pathlib.PurePath]:
358 """Host-specific os.environ["PATH"] entries.
360 Emscripten's Node version 14.x works well for wasm32-emscripten.
361 wasm64-emscripten requires more recent v8 version, e.g. node 16.x.
374 def emport_args(self) -> List[str]:
375 """Host-specific port args (Emscripten)."""
378 return ["-sMEMORY64=1"]
380 return ["-sMEMORY64=0"]
385 def embuilder_args(self) -> List[str]:
386 """Host-specific embuilder args (Emscripten)."""
389 return ["--wasm64"]
395 """Emscripten-specific targets (--with-emscripten-target)"""
398 browser_debug = "browser-debug"
400 node_debug = "node-debug"
408 def emport_args(self) -> List[str]:
409 """Target-specific port args."""
412 # some libs come in debug and non-debug builds
413 return ["-O0"]
415 return ["-O2"]
437 default_testopts: str = "-j2"
440 def is_browser(self) -> bool:
445 def builddir(self) -> pathlib.Path:
450 def python_cmd(self) -> pathlib.Path:
452 return self.builddir / self.host.platform.pythonexe
455 def makefile(self) -> pathlib.Path:
460 def configure_cmd(self) -> List[str]:
465 cmd = [configure, "-C"]
466 platform = self.host.platform
467 if platform.configure_wrapper:
468 cmd.insert(0, os.fspath(platform.configure_wrapper))
470 cmd.append(f"--host={self.host.value}")
471 cmd.append(f"--build={Host.build.value}")
475 cmd.append(f"--with-emscripten-target={self.target.value}")
480 cmd.append(f"--{opt}-wasm-dynamic-linking")
485 cmd.append(f"--{opt}-wasm-pthreads")
488 cmd.append(f"--with-build-python={BUILD.python_cmd}")
490 if platform.config_site is not None:
491 cmd.append(f"CONFIG_SITE={platform.config_site}")
496 def make_cmd(self) -> List[str]:
499 platform = self.host.platform
500 if platform.make_wrapper:
501 cmd.insert(0, os.fspath(platform.make_wrapper))
504 def getenv(self) -> dict:
505 """Generate environ dict for platform"""
507 env.setdefault("MAKEFLAGS", f"-j{os.cpu_count()}")
508 platenv = self.host.platform.getenv(self)
522 version=PYTHON_VERSION,
581 "--eval", f"run: all; $(HOSTRUNNER) ./$(PYTHON) {shlex.join(args)}", "run"
591 "--bind",
593 "--port",
624 """Pre-build emscripten ports."""
625 platform = self.host.platform
626 if platform.ports is None or platform.cc is None:
629 embuilder_cmd = [os.fspath(platform.ports)]
632 embuilder_cmd.append("--force")
634 ports_cmd = [os.fspath(platform.cc)]
641 ports_cmd.append("-sMAIN_MODULE")
642 embuilder_cmd.append("--pic")
645 # Trigger multi-threaded build.
646 ports_cmd.append("-sUSE_PTHREADS")
648 # Pre-build libbz2, libsqlite3, libz, and some system libs.
649 ports_cmd.extend(["-sUSE_ZLIB", "-sUSE_BZIP2", "-sUSE_SQLITE3"])
650 # Multi-threaded sqlite3 has different suffix
652 ["build", "bzip2", "sqlite3-mt" if self.pthreads else "sqlite3", "zlib"]
657 with tempfile.TemporaryDirectory(suffix="-py-emport") as tmpdir:
665 "-o",
680 # wasm32-emscripten
682 "emscripten-browser",
689 "emscripten-browser-debug",
696 "emscripten-node-dl",
703 "emscripten-node-dl-debug",
710 "emscripten-node-pthreads",
717 "emscripten-node-pthreads-debug",
725 "emscripten-node-dl-pthreads-debug",
732 # wasm64-emscripten (requires Emscripten >= 3.1.21)
734 "wasm64-emscripten-node-debug",
742 # wasm32-wasi
748 # no SDK available yet
750 # "wasm64-wasi",
765 "--clean",
766 "-c",
772 "--verbose",
773 "-v",
779 "--silent",
785 "--testopts",
788 "--testopts='-v test_os'."
797 "platform",
798 metavar="PLATFORM",
799 help=f"Build platform: {', '.join(platforms_help)}",
833 if args.platform == "cleanall":
839 cm_args = ("--silent",) if args.silent else ()
845 builder = PROFILES[args.platform]
847 builder.host.platform.check()
858 # auto-build
862 logger.info("Auto-building 'build' Python.")
864 BUILD.host.platform.check()
875 logger.info("\n*** %s %s", args.platform, op)