mirror of https://github.com/aminya/setup-cpp
Merge pull request #52 from aminya/linux-compiler [skip ci]
This commit is contained in:
commit
877b23130e
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
import { addPath, addEnv } from "../utils/env/addEnv"
|
||||
import { existsSync } from "fs"
|
||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
||||
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||
import semverMajor from "semver/functions/major"
|
||||
|
@ -96,9 +96,19 @@ async function activateGcc(version: string, binDir: string) {
|
|||
if (majorVersion >= 5) {
|
||||
addEnv("CC", `${binDir}/gcc-${majorVersion}`)
|
||||
addEnv("CXX", `${binDir}/g++-${majorVersion}`)
|
||||
|
||||
if (process.platform === "linux") {
|
||||
await updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
|
||||
await updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
|
||||
}
|
||||
} else {
|
||||
addEnv("CC", `${binDir}/gcc-${version}`)
|
||||
addEnv("CXX", `${binDir}/g++-${version}`)
|
||||
|
||||
if (process.platform === "linux") {
|
||||
await updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
|
||||
await updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
|||
import { addBinExtension } from "../utils/extension/extension"
|
||||
import { addEnv } from "../utils/env/addEnv"
|
||||
import { info, setOutput } from "@actions/core"
|
||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
||||
import { warning } from "../utils/io/io"
|
||||
import { existsSync } from "fs"
|
||||
import { isGitHubCI } from "../utils/env/isci"
|
||||
|
@ -307,6 +307,16 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
|||
|
||||
await setupMacOSSDK()
|
||||
|
||||
if (process.platform === "linux") {
|
||||
await updateAptAlternatives("cc", `${directory}/bin/clang`)
|
||||
await updateAptAlternatives("cxx", `${directory}/bin/clang++`)
|
||||
await updateAptAlternatives("clang", `${directory}/bin/clang`)
|
||||
await updateAptAlternatives("clang++", `${directory}/bin/clang++`)
|
||||
await updateAptAlternatives("lld", `${directory}/bin/lld`)
|
||||
await updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
|
||||
await updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
||||
}
|
||||
|
||||
if (isGitHubCI()) {
|
||||
addLLVMLoggingMatcher()
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ export function addPath(path: string) {
|
|||
}
|
||||
}
|
||||
|
||||
const cpprc_path = untildify(".cpprc")
|
||||
export const cpprc_path = untildify(".cpprc")
|
||||
|
||||
function addEnvSystem(name: string, valGiven: string | undefined) {
|
||||
const val = valGiven ?? ""
|
||||
|
@ -96,7 +96,7 @@ function addPathSystem(path: string) {
|
|||
let setupCppInProfile_called = false
|
||||
|
||||
/// handles adding conditions to source .cpprc file from .bashrc and .profile
|
||||
function setupCppInProfile() {
|
||||
export function setupCppInProfile() {
|
||||
if (setupCppInProfile_called) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ import { InstallationInfo } from "./setupBin"
|
|||
import { execSudo } from "../exec/sudo"
|
||||
import { info } from "@actions/core"
|
||||
import { warning } from "../io/io"
|
||||
import { isGitHubCI } from "../env/isci"
|
||||
import { cpprc_path, setupCppInProfile } from "../env/addEnv"
|
||||
import { appendFileSync } from "fs"
|
||||
|
||||
let didUpdate: boolean = false
|
||||
let didInit: boolean = false
|
||||
|
@ -68,3 +71,15 @@ export async function setupAptPack(
|
|||
|
||||
return { binDir: "/usr/bin/" }
|
||||
}
|
||||
|
||||
export function updateAptAlternatives(name: string, path: string) {
|
||||
if (isGitHubCI()) {
|
||||
return execSudo("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "10"])
|
||||
} else {
|
||||
setupCppInProfile()
|
||||
return appendFileSync(
|
||||
cpprc_path,
|
||||
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} 10; fi\n`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue