Calculate environment variables for building with wasi-sdk.
(context)
| 279 | |
| 280 | |
| 281 | def 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 | |
| 320 | def host_triple(context): |
no test coverage detected
searching dependent graphs…