返回 CodeWhale
ohos-clang.ps1
根目录 / scripts / ohos / ohos-clang.ps1
1 $ErrorActionPreference = "Stop"
2
3 if ([string]::IsNullOrWhiteSpace($env:OHOS_NATIVE_SDK)) {
4 [Console]::Error.WriteLine("error: set OHOS_NATIVE_SDK to the OpenHarmony native SDK directory. It must contain llvm\bin and sysroot.")
5 exit 1
6 }
7
8 $sdk = $env:OHOS_NATIVE_SDK
9 $clang = [System.IO.Path]::Combine($sdk, "llvm", "bin", "clang.exe")
10 $sysroot = [System.IO.Path]::Combine($sdk, "sysroot")
11
12 if (-not (Test-Path -LiteralPath $clang -PathType Leaf -ErrorAction SilentlyContinue)) {
13 [Console]::Error.WriteLine("error: OHOS_NATIVE_SDK does not contain llvm\bin\clang.exe: $sdk")
14 exit 1
15 }
16
17 if (-not (Test-Path -LiteralPath $sysroot -PathType Container -ErrorAction SilentlyContinue)) {
18 [Console]::Error.WriteLine("error: OHOS_NATIVE_SDK does not contain sysroot: $sdk")
19 exit 1
20 }
21
22 & $clang -target aarch64-linux-ohos "--sysroot=$sysroot" -D__MUSL__ @args
23 exit $LASTEXITCODE
24
24 lines Plain Text