fix: refactor setupMacOSSDK

This commit is contained in:
Amin Yahyaabadi 2021-11-21 11:06:16 -06:00
parent 770429f88c
commit dabdff585f
5 changed files with 26 additions and 17 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

@ -6,6 +6,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack" import { setupChocoPack } from "../utils/setup/setupChocoPack"
import semverMajor from "semver/functions/major" import semverMajor from "semver/functions/major"
import semverCoerce from "semver/functions/coerce" import semverCoerce from "semver/functions/coerce"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupGcc(version: string, _setupCppDir: string, arch: string) { export async function setupGcc(version: string, _setupCppDir: string, arch: string) {
@ -54,13 +55,13 @@ export async function setupGcc(version: string, _setupCppDir: string, arch: stri
} }
} }
if (binDir !== undefined) { if (binDir !== undefined) {
activateGcc(version, binDir) await activateGcc(version, binDir)
return { binDir } return { binDir }
} }
return undefined return undefined
} }
function activateGcc(version: string, binDir: string) { async function activateGcc(version: string, binDir: string) {
const majorVersion = semverMajor(semverCoerce(version) ?? version) const majorVersion = semverMajor(semverCoerce(version) ?? version)
// TODO // TODO
@ -79,4 +80,6 @@ function activateGcc(version: string, binDir: string) {
exportVariable("CC", `${binDir}/gcc-${majorVersion}`) exportVariable("CC", `${binDir}/gcc-${majorVersion}`)
exportVariable("CXX", `${binDir}/g++-${majorVersion}`) exportVariable("CXX", `${binDir}/g++-${majorVersion}`)
} }
await setupMacOSSDK()
} }

View File

@ -6,8 +6,7 @@ import { isValidUrl } from "../utils/http/validate_url"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin" import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { extractExe, extractTarByExe } from "../utils/setup/extract" import { extractExe, extractTarByExe } from "../utils/setup/extract"
import { getSpecificVersionAndUrl, getVersions } from "../utils/setup/version" import { getSpecificVersionAndUrl, getVersions } from "../utils/setup/version"
import { getExecOutput } from "@actions/exec" import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
import { existsSync } from "fs"
//================================================ //================================================
// Version // Version
@ -271,15 +270,5 @@ export async function activateLLVM(directory: string, version: string) {
core.exportVariable("LIBRARY_PATH", `${directory}/lib`) core.exportVariable("LIBRARY_PATH", `${directory}/lib`)
if (process.platform === "darwin") { await setupMacOSSDK()
try {
const xcrun = await getExecOutput("xcrun --sdk macosx --show-sdk-path")
const sdkroot = xcrun.stdout || xcrun.stderr
if (existsSync(sdkroot)) {
core.exportVariable("SDKROOT", sdkroot)
}
} catch (e) {
core.error(e as Error | string)
}
}
} }

View File

@ -0,0 +1,17 @@
import { getExecOutput } from "@actions/exec"
import { existsSync } from "fs"
import * as core from "@actions/core"
export async function setupMacOSSDK() {
if (process.platform === "darwin") {
try {
const xcrun = await getExecOutput("xcrun --sdk macosx --show-sdk-path")
const sdkroot = xcrun.stdout || xcrun.stderr
if (existsSync(sdkroot)) {
core.exportVariable("SDKROOT", sdkroot)
}
} catch (e) {
core.error(e as Error | string)
}
}
}