mirror of https://github.com/aminya/setup-cpp
fix: set the environment variables for gcc
This commit is contained in:
parent
cac52d79f7
commit
f5bfb821d1
|
@ -1,6 +1,5 @@
|
||||||
import { setupBrew } from "../brew"
|
import { setupBrew } from "../brew"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
|
||||||
|
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
describe("setup-brew", () => {
|
describe("setup-brew", () => {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const DefaultVersions: Record<string, string> = {
|
||||||
conan: "1.40.1",
|
conan: "1.40.1",
|
||||||
meson: "0.59.1",
|
meson: "0.59.1",
|
||||||
python: "3.x",
|
python: "3.x",
|
||||||
|
gcc: "11.2.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the default version if passed true or undefined, otherwise return the version itself */
|
/** Get the default version if passed true or undefined, otherwise return the version itself */
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
import { setupGcc } from "../gcc"
|
import { setupGcc } from "../gcc"
|
||||||
|
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
describe("setup-gcc", () => {
|
describe("setup-gcc", () => {
|
||||||
it("should setup gcc", async () => {
|
it("should setup gcc", async () => {
|
||||||
const installInfo = await setupGcc("", "", "")
|
const installInfo = await setupGcc("11.2.0", "", "")
|
||||||
|
|
||||||
await testBin("g++", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
await testBin("g++", ["--version"], installInfo?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,37 +1,38 @@
|
||||||
import { addPath } from "@actions/core"
|
import { addPath, exportVariable } from "@actions/core"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
|
import semverMajor from "semver/functions/major"
|
||||||
|
|
||||||
// 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) {
|
||||||
|
let binDir: string | undefined
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
if (arch === "arm" || arch === "arm64") {
|
if (arch === "arm" || arch === "arm64") {
|
||||||
await setupChocoPack("gcc-arm-embedded", version)
|
await setupChocoPack("gcc-arm-embedded", version)
|
||||||
}
|
}
|
||||||
await setupChocoPack("mingw", version)
|
await setupChocoPack("mingw", version)
|
||||||
let binDir: string | undefined
|
|
||||||
if (arch === "x64" && existsSync("C:\\tools\\mingw64\\bin")) {
|
if (arch === "x64" && existsSync("C:\\tools\\mingw64\\bin")) {
|
||||||
binDir = "C:\\tools\\mingw64\\bin"
|
binDir = "C:\\tools\\mingw64\\bin"
|
||||||
addPath(binDir)
|
addPath(binDir)
|
||||||
return { binDir }
|
|
||||||
} else if (arch === "ia32" && existsSync("C:\\tools\\mingw32\\bin")) {
|
} else if (arch === "ia32" && existsSync("C:\\tools\\mingw32\\bin")) {
|
||||||
binDir = "C:\\tools\\mingw32\\bin"
|
binDir = "C:\\tools\\mingw32\\bin"
|
||||||
addPath(binDir)
|
addPath(binDir)
|
||||||
return { binDir }
|
|
||||||
}
|
}
|
||||||
return undefined
|
break
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
return setupBrewPack("gcc", version)
|
binDir = setupBrewPack("gcc", version).binDir
|
||||||
|
break
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (arch === "x64") {
|
if (arch === "x64") {
|
||||||
return setupAptPack("g++", version, "ppa:ubuntu-toolchain-r/test")
|
binDir = (await setupAptPack("g++", version, "ppa:ubuntu-toolchain-r/test")).binDir
|
||||||
}
|
}
|
||||||
return setupAptPack("g++-multilib", version, "ppa:ubuntu-toolchain-r/test")
|
binDir = (await setupAptPack("g++-multilib", version, "ppa:ubuntu-toolchain-r/test")).binDir
|
||||||
|
break
|
||||||
}
|
}
|
||||||
// TODO support bare-metal
|
// TODO support bare-metal
|
||||||
// TODO support abi
|
// TODO support abi
|
||||||
|
@ -46,4 +47,30 @@ export async function setupGcc(version: string, _setupCppDir: string, arch: stri
|
||||||
throw new Error(`Unsupported platform for ${arch}`)
|
throw new Error(`Unsupported platform for ${arch}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (binDir !== undefined) {
|
||||||
|
const majorVersion = semverMajor(version)
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// const ld = process.env.LD_LIBRARY_PATH ?? ""
|
||||||
|
// const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
|
||||||
|
|
||||||
|
// // Setup gcc as the compiler
|
||||||
|
// exportVariable("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`)
|
||||||
|
// exportVariable("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`)
|
||||||
|
|
||||||
|
// exportVariable("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`)
|
||||||
|
|
||||||
|
// exportVariable("LDFLAGS", `-L${installDir}/lib`)
|
||||||
|
// exportVariable("CPPFLAGS", `-I${installDir}/include`)
|
||||||
|
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
exportVariable("CC", `${binDir}/gcc`)
|
||||||
|
exportVariable("CXX", `${binDir}/g++`)
|
||||||
|
} else {
|
||||||
|
exportVariable("CC", `${binDir}/gcc-${majorVersion}`)
|
||||||
|
exportVariable("CXX", `${binDir}/g++-${majorVersion}`)
|
||||||
|
}
|
||||||
|
return { binDir }
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue