Skip to content

Commit dabdff5

Browse files
committed
fix: refactor setupMacOSSDK
1 parent 770429f commit dabdff5

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/gcc/gcc.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
66
import { setupChocoPack } from "../utils/setup/setupChocoPack"
77
import semverMajor from "semver/functions/major"
88
import semverCoerce from "semver/functions/coerce"
9+
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
910

1011
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1112
export async function setupGcc(version: string, _setupCppDir: string, arch: string) {
@@ -54,13 +55,13 @@ export async function setupGcc(version: string, _setupCppDir: string, arch: stri
5455
}
5556
}
5657
if (binDir !== undefined) {
57-
activateGcc(version, binDir)
58+
await activateGcc(version, binDir)
5859
return { binDir }
5960
}
6061
return undefined
6162
}
6263

63-
function activateGcc(version: string, binDir: string) {
64+
async function activateGcc(version: string, binDir: string) {
6465
const majorVersion = semverMajor(semverCoerce(version) ?? version)
6566

6667
// TODO
@@ -79,4 +80,6 @@ function activateGcc(version: string, binDir: string) {
7980
exportVariable("CC", `${binDir}/gcc-${majorVersion}`)
8081
exportVariable("CXX", `${binDir}/g++-${majorVersion}`)
8182
}
83+
84+
await setupMacOSSDK()
8285
}

src/llvm/llvm.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { isValidUrl } from "../utils/http/validate_url"
66
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
77
import { extractExe, extractTarByExe } from "../utils/setup/extract"
88
import { getSpecificVersionAndUrl, getVersions } from "../utils/setup/version"
9-
import { getExecOutput } from "@actions/exec"
10-
import { existsSync } from "fs"
9+
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
1110

1211
//================================================
1312
// Version
@@ -271,15 +270,5 @@ export async function activateLLVM(directory: string, version: string) {
271270

272271
core.exportVariable("LIBRARY_PATH", `${directory}/lib`)
273272

274-
if (process.platform === "darwin") {
275-
try {
276-
const xcrun = await getExecOutput("xcrun --sdk macosx --show-sdk-path")
277-
const sdkroot = xcrun.stdout || xcrun.stderr
278-
if (existsSync(sdkroot)) {
279-
core.exportVariable("SDKROOT", sdkroot)
280-
}
281-
} catch (e) {
282-
core.error(e as Error | string)
283-
}
284-
}
273+
await setupMacOSSDK()
285274
}

src/macos-sdk/macos-sdk.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { getExecOutput } from "@actions/exec"
2+
import { existsSync } from "fs"
3+
import * as core from "@actions/core"
4+
5+
export async function setupMacOSSDK() {
6+
if (process.platform === "darwin") {
7+
try {
8+
const xcrun = await getExecOutput("xcrun --sdk macosx --show-sdk-path")
9+
const sdkroot = xcrun.stdout || xcrun.stderr
10+
if (existsSync(sdkroot)) {
11+
core.exportVariable("SDKROOT", sdkroot)
12+
}
13+
} catch (e) {
14+
core.error(e as Error | string)
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)