fix: fix macos-sdk

This commit is contained in:
Amin Yahyaabadi 2021-12-11 05:46:00 -06:00
parent 75bad90eef
commit ab471df24f
4 changed files with 18 additions and 4 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
import { setupMacOSSDK } from "../macos-sdk"
jest.setTimeout(300000)
describe("setup-macos-sdk", () => {
it("should setup macos-sdk", async () => {
if (process.platform === "darwin") {
process.env.SDKROOT = undefined
await setupMacOSSDK()
expect(process.env.SDKROOT).toBeTruthy()
expect(typeof process.env.SDKROOT).toBe("string")
}
})
})

View File

@ -1,5 +1,4 @@
import { getExecOutput } from "@actions/exec" import { getExecOutput } from "@actions/exec"
import { existsSync } from "fs"
import * as core from "@actions/core" import * as core from "@actions/core"
export async function setupMacOSSDK() { export async function setupMacOSSDK() {
@ -7,8 +6,10 @@ export async function setupMacOSSDK() {
try { try {
const xcrun = await getExecOutput("xcrun --sdk macosx --show-sdk-path") const xcrun = await getExecOutput("xcrun --sdk macosx --show-sdk-path")
const sdkroot = xcrun.stdout || xcrun.stderr const sdkroot = xcrun.stdout || xcrun.stderr
if (existsSync(sdkroot)) { if (sdkroot) {
core.exportVariable("SDKROOT", sdkroot) core.exportVariable("SDKROOT", sdkroot)
} else {
core.error(`SDKROOT not set`)
} }
} catch (e) { } catch (e) {
core.error(e as Error | string) core.error(e as Error | string)