MCPcopy Index your code
hub / github.com/python/cpython / wasi_sdk_env

Function wasi_sdk_env

Platforms/WASI/_build.py:281–317  ·  view source on GitHub ↗

Calculate environment variables for building with wasi-sdk.

(context)

Source from the content-addressed store, hash-verified

279
280
281def wasi_sdk_env(context):
282 """Calculate environment variables for building with wasi-sdk."""
283 wasi_sdk_path = wasi_sdk(context)
284 sysroot = wasi_sdk_path / "share" / "wasi-sysroot"
285 env = {
286 "CC": "clang",
287 "CPP": "clang-cpp",
288 "CXX": "clang++",
289 "AR": "llvm-ar",
290 "RANLIB": "ranlib",
291 }
292
293 for env_var, binary_name in list(env.items()):
294 env[env_var] = os.fsdecode(wasi_sdk_path / "bin" / binary_name)
295
296 if not wasi_sdk_path.name.startswith("wasi-sdk"):
297 for compiler in ["CC", "CPP", "CXX"]:
298 env[compiler] += f" --sysroot={sysroot}"
299
300 env["PKG_CONFIG_PATH"] = ""
301 env["PKG_CONFIG_LIBDIR"] = os.pathsep.join(
302 map(
303 os.fsdecode,
304 [sysroot / "lib" / "pkgconfig", sysroot / "share" / "pkgconfig"],
305 )
306 )
307 env["PKG_CONFIG_SYSROOT_DIR"] = os.fsdecode(sysroot)
308
309 env["WASI_SDK_PATH"] = os.fsdecode(wasi_sdk_path)
310 env["WASI_SYSROOT"] = os.fsdecode(sysroot)
311
312 env["PATH"] = os.pathsep.join([
313 os.fsdecode(wasi_sdk_path / "bin"),
314 os.environ["PATH"],
315 ])
316
317 return env
318
319
320def host_triple(context):

Callers 1

configure_wasi_pythonFunction · 0.85

Calls 5

wasi_sdkFunction · 0.85
listClass · 0.85
itemsMethod · 0.45
startswithMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…