feat(cli): respect WASI_SDK_PATH env (#1946)
This commit is contained in:
parent
f60c465950
commit
bec6bd67be
1 changed files with 31 additions and 0 deletions
|
@ -527,6 +527,31 @@ class Builder {
|
|||
'wasm32-wasi-threads',
|
||||
)
|
||||
this.envs.EMNAPI_LINK_DIR = emnapi
|
||||
const { WASI_SDK_PATH } = process.env
|
||||
|
||||
if (WASI_SDK_PATH && existsSync(WASI_SDK_PATH)) {
|
||||
this.envs.CARGO_TARGET_WASM32_WASI_PREVIEW1_THREADS_LINKER = join(
|
||||
WASI_SDK_PATH,
|
||||
'bin',
|
||||
'wasm-ld',
|
||||
)
|
||||
this.setEnvIfNotExists('CC', join(WASI_SDK_PATH, 'bin', 'clang'))
|
||||
this.setEnvIfNotExists('CXX', join(WASI_SDK_PATH, 'bin', 'clang++'))
|
||||
this.setEnvIfNotExists('AR', join(WASI_SDK_PATH, 'bin', 'ar'))
|
||||
this.setEnvIfNotExists('RANLIB', join(WASI_SDK_PATH, 'bin', 'ranlib'))
|
||||
this.setEnvIfNotExists(
|
||||
'CFLAGS',
|
||||
`--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread`,
|
||||
)
|
||||
this.setEnvIfNotExists(
|
||||
'CXXFLAGS',
|
||||
`--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread`,
|
||||
)
|
||||
this.setEnvIfNotExists(
|
||||
`LDFLAGS`,
|
||||
`-fuse-ld=${WASI_SDK_PATH}/bin/wasm-ld --target=wasm32-wasi-threads`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
debug('Set envs: ')
|
||||
|
@ -879,4 +904,10 @@ class Builder {
|
|||
}
|
||||
return []
|
||||
}
|
||||
|
||||
private setEnvIfNotExists(env: string, value: string) {
|
||||
if (!process.env[env]) {
|
||||
this.envs[env] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue