mirror of https://github.com/aminya/setup-cpp
Merge pull request #152 from aminya/perf [skip ci]
This commit is contained in:
commit
24f1544102
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -59,12 +59,14 @@
|
||||||
"ci-log": "workspace:1.0.0",
|
"ci-log": "workspace:1.0.0",
|
||||||
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
|
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
|
||||||
"escape-quotes": "^1.0.2",
|
"escape-quotes": "^1.0.2",
|
||||||
|
"escape-string-regexp": "^5.0.0",
|
||||||
"exec-powershell": "workspace:1.0.0",
|
"exec-powershell": "workspace:1.0.0",
|
||||||
"execa": "^5.1.1",
|
"execa": "^5.1.1",
|
||||||
"is-url-online": "^1.5.0",
|
"is-url-online": "^1.5.0",
|
||||||
"mri": "^1.2.0",
|
"mri": "^1.2.0",
|
||||||
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
||||||
"numerous": "1.0.3",
|
"numerous": "1.0.3",
|
||||||
|
"path-exists": "^4.0.0",
|
||||||
"patha": "^0.4.1",
|
"patha": "^0.4.1",
|
||||||
"quote-unquote": "^1.0.0",
|
"quote-unquote": "^1.0.0",
|
||||||
"semver": "7.3.8",
|
"semver": "7.3.8",
|
||||||
|
|
|
@ -31,6 +31,7 @@ importers:
|
||||||
cspell: ^6.14.3
|
cspell: ^6.14.3
|
||||||
escape-path-with-spaces: github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3
|
escape-path-with-spaces: github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3
|
||||||
escape-quotes: ^1.0.2
|
escape-quotes: ^1.0.2
|
||||||
|
escape-string-regexp: ^5.0.0
|
||||||
eslint: ^8.28.0
|
eslint: ^8.28.0
|
||||||
eslint-config-atomic: ^1.18.1
|
eslint-config-atomic: ^1.18.1
|
||||||
exec-powershell: workspace:1.0.0
|
exec-powershell: workspace:1.0.0
|
||||||
|
@ -44,6 +45,7 @@ importers:
|
||||||
npm-run-all2: ^6.0.4
|
npm-run-all2: ^6.0.4
|
||||||
numerous: 1.0.3
|
numerous: 1.0.3
|
||||||
parcel: 2.8.0
|
parcel: 2.8.0
|
||||||
|
path-exists: ^4.0.0
|
||||||
patha: ^0.4.1
|
patha: ^0.4.1
|
||||||
prettier: 2.7.1
|
prettier: 2.7.1
|
||||||
prettier-config-atomic: ^3.1.0
|
prettier-config-atomic: ^3.1.0
|
||||||
|
@ -72,12 +74,14 @@ importers:
|
||||||
ci-log: link:packages/ci-log
|
ci-log: link:packages/ci-log
|
||||||
escape-path-with-spaces: github.com/aminya/escape-path-with-spaces/d9f81ee649203ddc55783a2f96ada59df06118e3
|
escape-path-with-spaces: github.com/aminya/escape-path-with-spaces/d9f81ee649203ddc55783a2f96ada59df06118e3
|
||||||
escape-quotes: 1.0.2
|
escape-quotes: 1.0.2
|
||||||
|
escape-string-regexp: 5.0.0
|
||||||
exec-powershell: link:packages/exec-powershell
|
exec-powershell: link:packages/exec-powershell
|
||||||
execa: 5.1.1
|
execa: 5.1.1
|
||||||
is-url-online: 1.5.0
|
is-url-online: 1.5.0
|
||||||
mri: 1.2.0
|
mri: 1.2.0
|
||||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||||
numerous: 1.0.3
|
numerous: 1.0.3
|
||||||
|
path-exists: 4.0.0
|
||||||
patha: 0.4.1
|
patha: 0.4.1
|
||||||
quote-unquote: 1.0.0
|
quote-unquote: 1.0.0
|
||||||
semver: 7.3.8
|
semver: 7.3.8
|
||||||
|
@ -7822,7 +7826,6 @@ packages:
|
||||||
/path-exists/4.0.0:
|
/path-exists/4.0.0:
|
||||||
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/path-is-absolute/1.0.1:
|
/path-is-absolute/1.0.1:
|
||||||
resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==}
|
resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==}
|
||||||
|
|
|
@ -36,7 +36,7 @@ export async function setupBazel(version: string, _setupDir: string, _arch: stri
|
||||||
"-c",
|
"-c",
|
||||||
`echo "deb [arch=amd64 signed-by=${keyFileName}] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list`,
|
`echo "deb [arch=amd64 signed-by=${keyFileName}] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list`,
|
||||||
])
|
])
|
||||||
return setupAptPack("bazel", version, [], true)
|
return setupAptPack([{ name: "bazel", version }], true)
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported linux distribution`)
|
throw new Error(`Unsupported linux distribution`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function setupCcache(version: string, _setupDir: string, _arch: string) {
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
return setupDnfPack("ccache", version)
|
return setupDnfPack("ccache", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
return setupAptPack("ccache", version)
|
return setupAptPack([{ name: "ccache", version }])
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported linux distribution`)
|
throw new Error(`Unsupported linux distribution`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* eslint-disable require-atomic-updates */
|
/* eslint-disable require-atomic-updates */
|
||||||
import execa from "execa"
|
import execa from "execa"
|
||||||
import { existsSync } from "fs"
|
|
||||||
|
import pathExists from "path-exists"
|
||||||
import { dirname } from "patha"
|
import { dirname } from "patha"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { addPath } from "../utils/env/addEnv"
|
import { addPath } from "../utils/env/addEnv"
|
||||||
|
@ -63,7 +64,7 @@ export async function setupChocolatey(
|
||||||
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
|
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existsSync(binDir)) {
|
if (await pathExists(binDir)) {
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
|
|
|
@ -25,7 +25,7 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
return setupDnfPack("ccache", version)
|
return setupDnfPack("ccache", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
return setupAptPack("cppcheck", version)
|
return setupAptPack([{ name: "cppcheck", version }])
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported linux distribution`)
|
throw new Error(`Unsupported linux distribution`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,12 @@ import { extractTar, extractZip } from "../utils/setup/extract"
|
||||||
import { notice } from "ci-log"
|
import { notice } from "ci-log"
|
||||||
import { setupGraphviz } from "../graphviz/graphviz"
|
import { setupGraphviz } from "../graphviz/graphviz"
|
||||||
import { getVersion } from "../versions/versions"
|
import { getVersion } from "../versions/versions"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { isArch } from "../utils/env/isArch"
|
import { isArch } from "../utils/env/isArch"
|
||||||
import { hasDnf } from "../utils/env/hasDnf"
|
import { hasDnf } from "../utils/env/hasDnf"
|
||||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
/** Get the platform data for cmake */
|
/** Get the platform data for cmake */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -66,7 +67,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
return setupDnfPack("doxygen", version)
|
return setupDnfPack("doxygen", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
installationInfo = await setupAptPack("doxygen", version)
|
installationInfo = await setupAptPack([{ name: "doxygen", version }])
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported linux distributions`)
|
throw new Error(`Unsupported linux distributions`)
|
||||||
}
|
}
|
||||||
|
@ -74,10 +75,10 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
||||||
try {
|
try {
|
||||||
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
|
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
|
||||||
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
|
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
|
||||||
await setupAptPack("libclang-cpp9")
|
await setupAptPack([{ name: "libclang-cpp9" }])
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
|
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
|
||||||
installationInfo = await setupAptPack("doxygen", undefined)
|
installationInfo = await setupAptPack([{ name: "doxygen" }])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported linux distributions`)
|
throw new Error(`Unsupported linux distributions`)
|
||||||
|
@ -99,7 +100,7 @@ async function activateWinDoxygen() {
|
||||||
"C:/Program Files/doxygen/bin",
|
"C:/Program Files/doxygen/bin",
|
||||||
"C:/Program Files (x86)/doxygen",
|
"C:/Program Files (x86)/doxygen",
|
||||||
]) {
|
]) {
|
||||||
if (existsSync(join(binDir, "doxygen.exe"))) {
|
if (await pathExists(join(binDir, "doxygen.exe"))) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await addPath(binDir)
|
await addPath(binDir)
|
||||||
return binDir
|
return binDir
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { addPath, addEnv } from "../utils/env/addEnv"
|
import { addPath, addEnv } from "../utils/env/addEnv"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
||||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
||||||
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||||
|
@ -16,6 +16,7 @@ import { isArch } from "../utils/env/isArch"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
import { hasDnf } from "../utils/env/hasDnf"
|
import { hasDnf } from "../utils/env/hasDnf"
|
||||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
interface MingwInfo {
|
interface MingwInfo {
|
||||||
releaseName: string
|
releaseName: string
|
||||||
|
@ -95,15 +96,17 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
|
||||||
setupDnfPack("gcc-c++", version)
|
setupDnfPack("gcc-c++", version)
|
||||||
setupDnfPack("libstdc++-devel", undefined)
|
setupDnfPack("libstdc++-devel", undefined)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
|
installationInfo = await setupAptPack([
|
||||||
installationInfo = await setupAptPack("g++", version, [])
|
{ name: "gcc", version, repositories: ["ppa:ubuntu-toolchain-r/test"] },
|
||||||
|
{ name: "g++", version, repositories: ["ppa:ubuntu-toolchain-r/test"] },
|
||||||
|
])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
||||||
if (isArch()) {
|
if (isArch()) {
|
||||||
setupPacmanPack("gcc-multilib", version)
|
setupPacmanPack("gcc-multilib", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
|
await setupAptPack([{ name: "gcc-multilib", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -133,13 +136,13 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
|
||||||
async function setupChocoMingw(version: string, arch: string): Promise<InstallationInfo | undefined> {
|
async function setupChocoMingw(version: string, arch: string): Promise<InstallationInfo | undefined> {
|
||||||
await setupChocoPack("mingw", version)
|
await setupChocoPack("mingw", version)
|
||||||
let binDir: string | undefined
|
let binDir: string | undefined
|
||||||
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
|
if (arch === "x64" && (await pathExists("C:/tools/mingw64/bin"))) {
|
||||||
binDir = "C:/tools/mingw64/bin"
|
binDir = "C:/tools/mingw64/bin"
|
||||||
await addPath(binDir)
|
await addPath(binDir)
|
||||||
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
|
} else if (arch === "ia32" && (await pathExists("C:/tools/mingw32/bin"))) {
|
||||||
binDir = "C:/tools/mingw32/bin"
|
binDir = "C:/tools/mingw32/bin"
|
||||||
await addPath(binDir)
|
await addPath(binDir)
|
||||||
} else if (existsSync(`${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin/g++.exe`)) {
|
} else if (await pathExists(`${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin/g++.exe`)) {
|
||||||
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
|
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
|
||||||
}
|
}
|
||||||
if (binDir !== undefined) {
|
if (binDir !== undefined) {
|
||||||
|
@ -149,7 +152,7 @@ async function setupChocoMingw(version: string, arch: string): Promise<Installat
|
||||||
}
|
}
|
||||||
|
|
||||||
async function activateGcc(version: string, binDir: string) {
|
async function activateGcc(version: string, binDir: string) {
|
||||||
const promises: Promise<void>[] = []
|
const promises: Promise<any>[] = []
|
||||||
// Setup gcc as the compiler
|
// Setup gcc as the compiler
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -171,19 +174,23 @@ async function activateGcc(version: string, binDir: string) {
|
||||||
promises.push(addEnv("CC", `${binDir}/gcc-${majorVersion}`), addEnv("CXX", `${binDir}/g++-${majorVersion}`))
|
promises.push(addEnv("CC", `${binDir}/gcc-${majorVersion}`), addEnv("CXX", `${binDir}/g++-${majorVersion}`))
|
||||||
|
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
|
promises.push(
|
||||||
updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
|
updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`),
|
||||||
updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
|
updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`),
|
||||||
|
updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`),
|
||||||
updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
|
updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
promises.push(addEnv("CC", `${binDir}/gcc-${version}`), addEnv("CXX", `${binDir}/g++-${version}`))
|
promises.push(addEnv("CC", `${binDir}/gcc-${version}`), addEnv("CXX", `${binDir}/g++-${version}`))
|
||||||
|
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
|
promises.push(
|
||||||
updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
|
updateAptAlternatives("cc", `${binDir}/gcc-${version}`),
|
||||||
updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
|
updateAptAlternatives("cxx", `${binDir}/g++-${version}`),
|
||||||
|
updateAptAlternatives("gcc", `${binDir}/gcc-${version}`),
|
||||||
updateAptAlternatives("g++", `${binDir}/g++-${version}`)
|
updateAptAlternatives("g++", `${binDir}/g++-${version}`)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,15 +198,15 @@ async function activateGcc(version: string, binDir: string) {
|
||||||
promises.push(setupMacOSSDK())
|
promises.push(setupMacOSSDK())
|
||||||
|
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
addGccLoggingMatcher()
|
await addGccLoggingMatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addGccLoggingMatcher() {
|
async function addGccLoggingMatcher() {
|
||||||
const matcherPath = join(__dirname, "gcc_matcher.json")
|
const matcherPath = join(__dirname, "gcc_matcher.json")
|
||||||
if (!existsSync(matcherPath)) {
|
if (!(await pathExists(matcherPath))) {
|
||||||
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.js")
|
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.js")
|
||||||
}
|
}
|
||||||
info(`::add-matcher::${matcherPath}`)
|
info(`::add-matcher::${matcherPath}`)
|
||||||
|
|
|
@ -25,7 +25,7 @@ export async function setupGraphviz(version: string, _setupDir: string, _arch: s
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
return setupDnfPack("graphviz", version)
|
return setupDnfPack("graphviz", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
return setupAptPack("graphviz", version)
|
return setupAptPack([{ name: "graphviz", version }])
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported linux distribution`)
|
throw new Error(`Unsupported linux distribution`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,7 @@ async function buildKcov(file: string, dest: string) {
|
||||||
setupDnfPack("libdwarf-devel")
|
setupDnfPack("libdwarf-devel")
|
||||||
setupDnfPack("libcurl-devel")
|
setupDnfPack("libcurl-devel")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("libdw-dev")
|
await setupAptPack([{ name: "libdw-dev" }, { name: "libcurl4-openssl-dev" }])
|
||||||
await setupAptPack("libcurl4-openssl-dev")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const buildDir = join(out, "build")
|
const buildDir = join(out, "build")
|
||||||
|
@ -102,7 +101,7 @@ export async function setupKcov(versionGiven: string, setupDir: string, arch: st
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
setupDnfPack("binutils")
|
setupDnfPack("binutils")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("libbinutils")
|
await setupAptPack([{ name: "libbinutils" }])
|
||||||
}
|
}
|
||||||
return installationInfo
|
return installationInfo
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,13 +7,14 @@ import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
||||||
import { addEnv } from "../utils/env/addEnv"
|
import { addEnv } from "../utils/env/addEnv"
|
||||||
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
||||||
import { info, warning } from "ci-log"
|
import { info, warning } from "ci-log"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { setupGcc } from "../gcc/gcc"
|
import { setupGcc } from "../gcc/gcc"
|
||||||
import { getVersion } from "../versions/versions"
|
import { getVersion } from "../versions/versions"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
import { getLLVMPackageInfo } from "./llvm_url"
|
import { getLLVMPackageInfo } from "./llvm_url"
|
||||||
import { ubuntuVersion } from "../utils/env/ubuntu_version"
|
import { ubuntuVersion } from "../utils/env/ubuntu_version"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
const installationInfo = await setupLLVMWithoutActivation(version, setupDir, arch)
|
const installationInfo = await setupLLVMWithoutActivation(version, setupDir, arch)
|
||||||
|
@ -51,9 +52,9 @@ async function setupLLVMDeps(arch: string, version: string) {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
const majorVersion = parseInt(version.split(".")[0], 10)
|
const majorVersion = parseInt(version.split(".")[0], 10)
|
||||||
if (majorVersion <= 10) {
|
if (majorVersion <= 10) {
|
||||||
await setupAptPack("libtinfo5")
|
await setupAptPack([{ name: "libtinfo5" }])
|
||||||
} else {
|
} else {
|
||||||
await setupAptPack("libtinfo-dev")
|
await setupAptPack([{ name: "libtinfo-dev" }])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: install libtinfo on other distros
|
// TODO: install libtinfo on other distros
|
||||||
|
@ -69,7 +70,7 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
||||||
const ld = process.env.LD_LIBRARY_PATH ?? ""
|
const ld = process.env.LD_LIBRARY_PATH ?? ""
|
||||||
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
|
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
|
||||||
|
|
||||||
const promises = [
|
const promises: Promise<any>[] = [
|
||||||
// the output of this action
|
// the output of this action
|
||||||
addEnv("LLVM_PATH", directory),
|
addEnv("LLVM_PATH", directory),
|
||||||
|
|
||||||
|
@ -94,41 +95,43 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
||||||
// windows builds fail with llvm's CPATH
|
// windows builds fail with llvm's CPATH
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
const llvmMajor = semverMajor(version)
|
const llvmMajor = semverMajor(version)
|
||||||
if (existsSync(`${directory}/lib/clang/${version}/include`)) {
|
if (await pathExists(`${directory}/lib/clang/${version}/include`)) {
|
||||||
promises.push(addEnv("CPATH", `${directory}/lib/clang/${version}/include`))
|
promises.push(addEnv("CPATH", `${directory}/lib/clang/${version}/include`))
|
||||||
} else if (existsSync(`${directory}/lib/clang/${llvmMajor}/include`)) {
|
} else if (await pathExists(`${directory}/lib/clang/${llvmMajor}/include`)) {
|
||||||
promises.push(addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`))
|
promises.push(addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
updateAptAlternatives("cc", `${directory}/bin/clang`)
|
promises.push(
|
||||||
updateAptAlternatives("cxx", `${directory}/bin/clang++`)
|
updateAptAlternatives("cc", `${directory}/bin/clang`),
|
||||||
updateAptAlternatives("clang", `${directory}/bin/clang`)
|
updateAptAlternatives("cxx", `${directory}/bin/clang++`),
|
||||||
updateAptAlternatives("clang++", `${directory}/bin/clang++`)
|
updateAptAlternatives("clang", `${directory}/bin/clang`),
|
||||||
updateAptAlternatives("lld", `${directory}/bin/lld`)
|
updateAptAlternatives("clang++", `${directory}/bin/clang++`),
|
||||||
updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
|
updateAptAlternatives("lld", `${directory}/bin/lld`),
|
||||||
|
updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`),
|
||||||
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
addLLVMLoggingMatcher()
|
await addLLVMLoggingMatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setup llvm tools (clang tidy, clang format, etc) without activating llvm and using it as the compiler */
|
/** Setup llvm tools (clang tidy, clang format, etc) without activating llvm and using it as the compiler */
|
||||||
export function setupClangTools(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
export async function setupClangTools(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
addLLVMLoggingMatcher()
|
await addLLVMLoggingMatcher()
|
||||||
}
|
}
|
||||||
return setupLLVMWithoutActivation(version, setupDir, arch)
|
return setupLLVMWithoutActivation(version, setupDir, arch)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLLVMLoggingMatcher() {
|
async function addLLVMLoggingMatcher() {
|
||||||
const matcherPath = join(__dirname, "llvm_matcher.json")
|
const matcherPath = join(__dirname, "llvm_matcher.json")
|
||||||
if (!existsSync(matcherPath)) {
|
if (!(await pathExists(matcherPath))) {
|
||||||
return warning("the llvm_matcher.json file does not exist in the same folder as setup_cpp.js")
|
return warning("the llvm_matcher.json file does not exist in the same folder as setup_cpp.js")
|
||||||
}
|
}
|
||||||
info(`::add-matcher::${matcherPath}`)
|
info(`::add-matcher::${matcherPath}`)
|
||||||
|
|
|
@ -270,7 +270,7 @@ export async function main(args: string[]): Promise<number> {
|
||||||
info(`took ${timeFormatter.format(time1, time2) || "0 seconds"}`)
|
info(`took ${timeFormatter.format(time1, time2) || "0 seconds"}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
finalizeCpprc()
|
await finalizeCpprc()
|
||||||
|
|
||||||
if (successMessages.length === 0 && errorMessages.length === 0) {
|
if (successMessages.length === 0 && errorMessages.length === 0) {
|
||||||
warning("setup_cpp was called without any arguments. Nothing to do.")
|
warning("setup_cpp was called without any arguments. Nothing to do.")
|
||||||
|
|
|
@ -25,7 +25,7 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
return setupDnfPack("make", version)
|
return setupDnfPack("make", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
return setupAptPack("make", version)
|
return setupAptPack([{ name: "make", version }])
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported linux distribution`)
|
throw new Error(`Unsupported linux distribution`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,9 @@ import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
||||||
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
|
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { join } from "patha"
|
import { join } from "patha"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { error, info, warning } from "ci-log"
|
import { error, info, warning } from "ci-log"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
|
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
|
||||||
|
|
||||||
|
@ -66,13 +67,13 @@ export async function setupMSVC(
|
||||||
await setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
await setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
||||||
|
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
addMSVCLoggingMatcher()
|
await addMSVCLoggingMatcher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMSVCLoggingMatcher() {
|
async function addMSVCLoggingMatcher() {
|
||||||
const matcherPath = join(__dirname, "msvc_matcher.json")
|
const matcherPath = join(__dirname, "msvc_matcher.json")
|
||||||
if (!existsSync(matcherPath)) {
|
if (!(await pathExists(matcherPath))) {
|
||||||
return warning("the msvc_matcher.json file does not exist in the same folder as setup_cpp.js")
|
return warning("the msvc_matcher.json file does not exist in the same folder as setup_cpp.js")
|
||||||
}
|
}
|
||||||
info(`::add-matcher::${matcherPath}`)
|
info(`::add-matcher::${matcherPath}`)
|
||||||
|
|
|
@ -33,12 +33,12 @@ export async function setupNala(version: string, _setupDir: string, _arch: strin
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (version !== "legacy") {
|
if (version !== "legacy") {
|
||||||
await setupAptPack("nala", undefined, [], true)
|
await setupAptPack([{ name: "nala" }], true)
|
||||||
} else {
|
} else {
|
||||||
await setupAptPack("nala-legacy", undefined, [], true)
|
await setupAptPack([{ name: "nala-legacy" }], true)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await setupAptPack("nala-legacy", undefined, [], true)
|
await setupAptPack([{ name: "nala-legacy" }], true)
|
||||||
}
|
}
|
||||||
|
|
||||||
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates
|
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates
|
||||||
|
|
|
@ -33,7 +33,7 @@ export async function setupPowershell(version: string | undefined, _setupDir: st
|
||||||
])
|
])
|
||||||
return setupDnfPack("powershell", version)
|
return setupDnfPack("powershell", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("curl")
|
await setupAptPack([{ name: "curl" }])
|
||||||
const ubuntuVerSplitted = (await ubuntuVersion())!
|
const ubuntuVerSplitted = (await ubuntuVersion())!
|
||||||
const ubuntuVersionString = `${ubuntuVerSplitted[0]}.0${ubuntuVerSplitted[1]}`
|
const ubuntuVersionString = `${ubuntuVerSplitted[0]}.0${ubuntuVerSplitted[1]}`
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export async function setupPowershell(version: string | undefined, _setupDir: st
|
||||||
// `echo "deb [arch=amd64 signed-by=${keyFileName}] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list`,
|
// `echo "deb [arch=amd64 signed-by=${keyFileName}] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list`,
|
||||||
// ])
|
// ])
|
||||||
|
|
||||||
return setupAptPack("powershell", version, [], true)
|
return setupAptPack([{ name: "powershell", version }], true)
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported linux distribution`)
|
throw new Error(`Unsupported linux distribution`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { useCpythonVersion } from "setup-python/src/find-python"
|
import { useCpythonVersion } from "setup-python/src/find-python"
|
||||||
import { findPyPyVersion } from "setup-python/src/find-pypy"
|
import { findPyPyVersion } from "setup-python/src/find-pypy"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { info, warning } from "ci-log"
|
import { info, warning } from "ci-log"
|
||||||
import { debug } from "@actions/core"
|
import { debug } from "@actions/core"
|
||||||
import { join } from "patha"
|
import { join } from "patha"
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { isCacheFeatureAvailable, IS_MAC } from "setup-python/src/utils"
|
import { isCacheFeatureAvailable, IS_MAC } from "setup-python/src/utils"
|
||||||
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
|
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
function isPyPyVersion(versionSpec: string) {
|
function isPyPyVersion(versionSpec: string) {
|
||||||
return versionSpec.startsWith("pypy")
|
return versionSpec.startsWith("pypy")
|
||||||
|
@ -51,15 +52,15 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
addPythonLoggingMatcher()
|
await addPythonLoggingMatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPythonLoggingMatcher() {
|
async function addPythonLoggingMatcher() {
|
||||||
const matcherPath = join(__dirname, "python_matcher.json")
|
const matcherPath = join(__dirname, "python_matcher.json")
|
||||||
if (!existsSync(matcherPath)) {
|
if (!(await pathExists(matcherPath))) {
|
||||||
return warning("the python_matcher.json file does not exist in the same folder as setup_cpp.js")
|
return warning("the python_matcher.json file does not exist in the same folder as setup_cpp.js")
|
||||||
}
|
}
|
||||||
info(`::add-matcher::${matcherPath}`)
|
info(`::add-matcher::${matcherPath}`)
|
||||||
|
|
|
@ -69,8 +69,7 @@ export async function setupPythonViaSystem(
|
||||||
installInfo = setupDnfPack("python3", version)
|
installInfo = setupDnfPack("python3", version)
|
||||||
setupDnfPack("python3-pip")
|
setupDnfPack("python3-pip")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
installInfo = await setupAptPack("python3", version)
|
installInfo = await setupAptPack([{ name: "python3", version }, { name: "python3-pip" }])
|
||||||
await setupAptPack("python3-pip")
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported linux distributions`)
|
throw new Error(`Unsupported linux distributions`)
|
||||||
}
|
}
|
||||||
|
@ -118,7 +117,7 @@ export async function setupPythonAndPip(): Promise<string> {
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
setupDnfPack("python3-pip")
|
setupDnfPack("python3-pip")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("python3-pip")
|
await setupAptPack([{ name: "python3-pip" }])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ export function setupSevenZip(version: string, _setupDir: string, _arch: string)
|
||||||
setupDnfPack("p7zip", version)
|
setupDnfPack("p7zip", version)
|
||||||
return setupDnfPack("p7zip-plugins", version)
|
return setupDnfPack("p7zip-plugins", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
return setupAptPack("p7zip-full", version)
|
return setupAptPack([{ name: "p7zip-full", version }])
|
||||||
}
|
}
|
||||||
throw new Error(`Unsupported linux distribution`)
|
throw new Error(`Unsupported linux distribution`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
|
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { untildifyUser } from "untildify-user"
|
import { untildifyUser } from "untildify-user"
|
||||||
import { appendFileSync, existsSync, readFileSync, writeFileSync } from "fs"
|
import { appendFileSync, readFileSync, writeFileSync } from "fs"
|
||||||
import { error, warning } from "ci-log"
|
import { error, warning } from "ci-log"
|
||||||
import { execPowershell } from "exec-powershell"
|
import { execPowershell } from "exec-powershell"
|
||||||
import { delimiter } from "path"
|
import { delimiter } from "path"
|
||||||
import escapeSpace from "escape-path-with-spaces"
|
import escapeSpace from "escape-path-with-spaces"
|
||||||
import { giveUserAccess } from "user-access"
|
import { giveUserAccess } from "user-access"
|
||||||
import escapeQuote from "escape-quotes"
|
import escapeQuote from "escape-quotes"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an environment variable.
|
* Add an environment variable.
|
||||||
|
@ -75,7 +76,7 @@ async function addEnvSystem(name: string, valGiven: string | undefined) {
|
||||||
}
|
}
|
||||||
case "linux":
|
case "linux":
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
setupCppInProfile()
|
await setupCppInProfile()
|
||||||
appendFileSync(cpprc_path, `\nexport ${name}="${val}"\n`)
|
appendFileSync(cpprc_path, `\nexport ${name}="${val}"\n`)
|
||||||
info(`${name}="${val}" was added to "${cpprc_path}`)
|
info(`${name}="${val}" was added to "${cpprc_path}`)
|
||||||
return
|
return
|
||||||
|
@ -99,7 +100,7 @@ async function addPathSystem(path: string) {
|
||||||
}
|
}
|
||||||
case "linux":
|
case "linux":
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
setupCppInProfile()
|
await setupCppInProfile()
|
||||||
appendFileSync(cpprc_path, `\nexport PATH="${path}:$PATH"\n`)
|
appendFileSync(cpprc_path, `\nexport PATH="${path}:$PATH"\n`)
|
||||||
info(`"${path}" was added to "${cpprc_path}"`)
|
info(`"${path}" was added to "${cpprc_path}"`)
|
||||||
return
|
return
|
||||||
|
@ -113,7 +114,7 @@ async function addPathSystem(path: string) {
|
||||||
let setupCppInProfile_called = false
|
let setupCppInProfile_called = false
|
||||||
|
|
||||||
/// handles adding conditions to source .cpprc file from .bashrc and .profile
|
/// handles adding conditions to source .cpprc file from .bashrc and .profile
|
||||||
export function setupCppInProfile() {
|
export async function setupCppInProfile() {
|
||||||
if (setupCppInProfile_called) {
|
if (setupCppInProfile_called) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ export function setupCppInProfile() {
|
||||||
// a variable that prevents source_cpprc from being called from .bashrc and .profile
|
// a variable that prevents source_cpprc from being called from .bashrc and .profile
|
||||||
const source_cpprc_str = "# Automatically Generated by setup-cpp\nexport SOURCE_CPPRC=0"
|
const source_cpprc_str = "# Automatically Generated by setup-cpp\nexport SOURCE_CPPRC=0"
|
||||||
|
|
||||||
if (existsSync(cpprc_path)) {
|
if (await pathExists(cpprc_path)) {
|
||||||
const cpprc_content = readFileSync(cpprc_path, "utf8")
|
const cpprc_content = readFileSync(cpprc_path, "utf8")
|
||||||
if (cpprc_content.includes(source_cpprc_str)) {
|
if (cpprc_content.includes(source_cpprc_str)) {
|
||||||
// already executed setupCppInProfile
|
// already executed setupCppInProfile
|
||||||
|
@ -153,8 +154,8 @@ export function setupCppInProfile() {
|
||||||
setupCppInProfile_called = true
|
setupCppInProfile_called = true
|
||||||
}
|
}
|
||||||
|
|
||||||
export function finalizeCpprc() {
|
export async function finalizeCpprc() {
|
||||||
if (existsSync(cpprc_path)) {
|
if (await pathExists(cpprc_path)) {
|
||||||
const entries = readFileSync(cpprc_path, "utf-8").split("\n")
|
const entries = readFileSync(cpprc_path, "utf-8").split("\n")
|
||||||
|
|
||||||
const unique_entries = [...new Set(entries.reverse())].reverse() // remove duplicates, keeping the latest entry
|
const unique_entries = [...new Set(entries.reverse())].reverse() // remove duplicates, keeping the latest entry
|
||||||
|
|
|
@ -8,7 +8,7 @@ export async function ubuntuVersion(): Promise<number[] | null> {
|
||||||
try {
|
try {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
||||||
await setupAptPack("lsb-release")
|
await setupAptPack([{ name: "lsb-release" }])
|
||||||
}
|
}
|
||||||
const versionSplitted = await getUbuntuVersion()
|
const versionSplitted = await getUbuntuVersion()
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,32 @@
|
||||||
/* eslint-disable require-atomic-updates */
|
/* eslint-disable require-atomic-updates */
|
||||||
import { InstallationInfo } from "./setupBin"
|
import { InstallationInfo } from "./setupBin"
|
||||||
import { execRootSync } from "admina"
|
import { execRoot, execRootSync } from "admina"
|
||||||
import { info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
||||||
import { appendFileSync, existsSync } from "fs"
|
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
import { promises as fsPromises } from "fs"
|
||||||
|
const { appendFile } = fsPromises
|
||||||
|
import execa from "execa"
|
||||||
|
import escapeRegex from "escape-string-regexp"
|
||||||
|
|
||||||
let didUpdate: boolean = false
|
let didUpdate: boolean = false
|
||||||
let didInit: boolean = false
|
let didInit: boolean = false
|
||||||
|
|
||||||
|
export type AptPackage = {
|
||||||
|
name: string
|
||||||
|
version?: string
|
||||||
|
repositories?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
/** A function that installs a package using apt */
|
/** A function that installs a package using apt */
|
||||||
export async function setupAptPack(
|
export async function setupAptPack(packages: AptPackage[], update = false): Promise<InstallationInfo> {
|
||||||
name: string,
|
|
||||||
version?: string,
|
|
||||||
repositories: string[] = [],
|
|
||||||
update = false
|
|
||||||
): Promise<InstallationInfo> {
|
|
||||||
const apt: string = getApt()
|
const apt: string = getApt()
|
||||||
|
|
||||||
|
for (const { name, version } of packages) {
|
||||||
info(`Installing ${name} ${version ?? ""} via ${apt}`)
|
info(`Installing ${name} ${version ?? ""} via ${apt}`)
|
||||||
|
}
|
||||||
|
|
||||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
process.env.DEBIAN_FRONTEND = "noninteractive"
|
||||||
|
|
||||||
|
@ -33,27 +40,40 @@ export async function setupAptPack(
|
||||||
didInit = true
|
didInit = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(repositories) && repositories.length !== 0) {
|
const allRepositories = [...new Set(packages.flatMap((pack) => pack.repositories ?? []))]
|
||||||
for (const repo of repositories) {
|
|
||||||
|
if (allRepositories.length !== 0) {
|
||||||
|
for (const repo of allRepositories) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
execRootSync("add-apt-repository", ["--update", "-y", repo])
|
execRootSync("add-apt-repository", ["-y", repo])
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRepos(apt)
|
updateRepos(apt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version !== undefined && version !== "") {
|
const aptArgs = await Promise.all(packages.map((pack) => getAptArg(pack.name, pack.version)))
|
||||||
try {
|
execRootSync(apt, ["install", "--fix-broken", "-y", ...aptArgs])
|
||||||
execRootSync(apt, ["install", "--fix-broken", "-y", `${name}=${version}`])
|
|
||||||
} catch {
|
|
||||||
execRootSync(apt, ["install", "--fix-broken", "-y", `${name}-${version}`])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
execRootSync(apt, ["install", "--fix-broken", "-y", name])
|
|
||||||
}
|
|
||||||
|
|
||||||
return { binDir: "/usr/bin/" }
|
return { binDir: "/usr/bin/" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getAptArg(name: string, version: string | undefined) {
|
||||||
|
if (version !== undefined && version !== "") {
|
||||||
|
const { stdout } = await execa("apt-cache", [
|
||||||
|
"search",
|
||||||
|
"--names-only",
|
||||||
|
`^${escapeRegex(name)}\-${escapeRegex(version)}$`,
|
||||||
|
])
|
||||||
|
if (stdout.trim() !== "") {
|
||||||
|
return `${name}-${version}`
|
||||||
|
} else {
|
||||||
|
return `${name}=${version}`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getApt() {
|
function getApt() {
|
||||||
let apt: string
|
let apt: string
|
||||||
if (which.sync("nala", { nothrow: true }) !== null) {
|
if (which.sync("nala", { nothrow: true }) !== null) {
|
||||||
|
@ -79,25 +99,29 @@ async function initApt(apt: string) {
|
||||||
"ca-certificates",
|
"ca-certificates",
|
||||||
"gnupg",
|
"gnupg",
|
||||||
])
|
])
|
||||||
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
|
const promises: Promise<any>[] = [
|
||||||
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg")
|
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg"),
|
||||||
|
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg"),
|
||||||
|
]
|
||||||
if (apt === "nala") {
|
if (apt === "nala") {
|
||||||
// enable utf8 otherwise it fails because of the usage of ASCII encoding
|
// enable utf8 otherwise it fails because of the usage of ASCII encoding
|
||||||
await addEnv("LANG", "C.UTF-8")
|
promises.push(addEnv("LANG", "C.UTF-8"), addEnv("LC_ALL", "C.UTF-8"))
|
||||||
await addEnv("LC_ALL", "C.UTF-8")
|
|
||||||
}
|
}
|
||||||
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
function initGpg() {
|
function initGpg() {
|
||||||
execRootSync("gpg", ["-k"])
|
execRootSync("gpg", ["-k"])
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addAptKeyViaServer(keys: string[], name: string, server = "keyserver.ubuntu.com") {
|
export async function addAptKeyViaServer(keys: string[], name: string, server = "keyserver.ubuntu.com") {
|
||||||
const fileName = `/etc/apt/trusted.gpg.d/${name}`
|
const fileName = `/etc/apt/trusted.gpg.d/${name}`
|
||||||
if (!existsSync(fileName)) {
|
if (!(await pathExists(fileName))) {
|
||||||
initGpg()
|
initGpg()
|
||||||
for (const key of keys) {
|
|
||||||
execRootSync("gpg", [
|
await Promise.all(
|
||||||
|
keys.map(async (key) => {
|
||||||
|
await execRoot("gpg", [
|
||||||
"--no-default-keyring",
|
"--no-default-keyring",
|
||||||
"--keyring",
|
"--keyring",
|
||||||
`gnupg-ring:${fileName}`,
|
`gnupg-ring:${fileName}`,
|
||||||
|
@ -106,29 +130,30 @@ export function addAptKeyViaServer(keys: string[], name: string, server = "keyse
|
||||||
"--recv-keys",
|
"--recv-keys",
|
||||||
key,
|
key,
|
||||||
])
|
])
|
||||||
execRootSync("chmod", ["644", fileName])
|
await execRoot("chmod", ["644", fileName])
|
||||||
}
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return fileName
|
return fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addAptKeyViaDownload(name: string, url: string) {
|
export async function addAptKeyViaDownload(name: string, url: string) {
|
||||||
const fileName = `/etc/apt/trusted.gpg.d/${name}`
|
const fileName = `/etc/apt/trusted.gpg.d/${name}`
|
||||||
if (!existsSync(fileName)) {
|
if (!(await pathExists(fileName))) {
|
||||||
initGpg()
|
initGpg()
|
||||||
await setupAptPack("curl", undefined)
|
await setupAptPack([{ name: "curl" }], undefined)
|
||||||
execRootSync("bash", ["-c", `curl -s ${url} | gpg --no-default-keyring --keyring gnupg-ring:${fileName} --import`])
|
execRootSync("bash", ["-c", `curl -s ${url} | gpg --no-default-keyring --keyring gnupg-ring:${fileName} --import`])
|
||||||
execRootSync("chmod", ["644", fileName])
|
execRootSync("chmod", ["644", fileName])
|
||||||
}
|
}
|
||||||
return fileName
|
return fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateAptAlternatives(name: string, path: string) {
|
export async function updateAptAlternatives(name: string, path: string) {
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
return execRootSync("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
|
return execRoot("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
|
||||||
} else {
|
} else {
|
||||||
setupCppInProfile()
|
await setupCppInProfile()
|
||||||
return appendFileSync(
|
return appendFile(
|
||||||
cpprc_path,
|
cpprc_path,
|
||||||
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} 40; fi\n`
|
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} 40; fi\n`
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { find, downloadTool, cacheDir } from "@actions/tool-cache"
|
||||||
import { info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import { addPath } from "../env/addEnv"
|
import { addPath } from "../env/addEnv"
|
||||||
import { join } from "patha"
|
import { join } from "patha"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { tmpdir } from "os"
|
import { tmpdir } from "os"
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { setupAptPack } from "./setupAptPack"
|
import { setupAptPack } from "./setupAptPack"
|
||||||
|
@ -11,6 +11,7 @@ import { isArch } from "../env/isArch"
|
||||||
import { hasDnf } from "../env/hasDnf"
|
import { hasDnf } from "../env/hasDnf"
|
||||||
import { setupDnfPack } from "./setupDnfPack"
|
import { setupDnfPack } from "./setupDnfPack"
|
||||||
import { isUbuntu } from "../env/isUbuntu"
|
import { isUbuntu } from "../env/isUbuntu"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
/** A type that describes a package */
|
/** A type that describes a package */
|
||||||
export type PackageInfo = {
|
export type PackageInfo = {
|
||||||
|
@ -70,7 +71,7 @@ export async function setupBin(
|
||||||
if (dir) {
|
if (dir) {
|
||||||
const installDir = join(dir, extractedFolderName)
|
const installDir = join(dir, extractedFolderName)
|
||||||
const binDir = join(installDir, binRelativeDir)
|
const binDir = join(installDir, binRelativeDir)
|
||||||
if (existsSync(binDir) && existsSync(join(binDir, binFileName))) {
|
if (await pathExists(join(binDir, binFileName))) {
|
||||||
info(`${name} ${version} was found in the cache at ${binDir}.`)
|
info(`${name} ${version} was found in the cache at ${binDir}.`)
|
||||||
await addPath(binDir)
|
await addPath(binDir)
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ export async function setupBin(
|
||||||
const binFile = join(binDir, binFileName)
|
const binFile = join(binDir, binFileName)
|
||||||
|
|
||||||
// download ane extract the package into the installation directory.
|
// download ane extract the package into the installation directory.
|
||||||
if (!existsSync(binDir) || !existsSync(binFile)) {
|
if ((await Promise.all([pathExists(binDir), pathExists(binFile)])).includes(false)) {
|
||||||
info(`Download and extract ${name} ${version}`)
|
info(`Download and extract ${name} ${version}`)
|
||||||
|
|
||||||
if (!didInit) {
|
if (!didInit) {
|
||||||
|
@ -102,9 +103,7 @@ export async function setupBin(
|
||||||
setupDnfPack("tar")
|
setupDnfPack("tar")
|
||||||
setupDnfPack("xz")
|
setupDnfPack("xz")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("unzip")
|
await setupAptPack([{ name: "unzip" }, { name: "tar" }, { name: "xz-utils" }])
|
||||||
await setupAptPack("tar")
|
|
||||||
await setupAptPack("xz-utils")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line require-atomic-updates
|
// eslint-disable-next-line require-atomic-updates
|
||||||
|
|
|
@ -3,10 +3,11 @@ import execa from "execa"
|
||||||
import { info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import { addPythonBaseExecPrefix, setupPythonAndPip } from "../../python/python"
|
import { addPythonBaseExecPrefix, setupPythonAndPip } from "../../python/python"
|
||||||
import { InstallationInfo } from "./setupBin"
|
import { InstallationInfo } from "./setupBin"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { addExeExt, dirname, join } from "patha"
|
import { addExeExt, dirname, join } from "patha"
|
||||||
import { addPath } from "../env/addEnv"
|
import { addPath } from "../env/addEnv"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
let python: string | undefined
|
let python: string | undefined
|
||||||
let binDirs: string[] | undefined
|
let binDirs: string[] | undefined
|
||||||
|
@ -27,15 +28,18 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
|
||||||
binDirs = await addPythonBaseExecPrefix(python)
|
binDirs = await addPythonBaseExecPrefix(python)
|
||||||
}
|
}
|
||||||
|
|
||||||
const binDir = findBinDir(binDirs, name)
|
const binDir = await findBinDir(binDirs, name)
|
||||||
|
|
||||||
await addPath(binDir)
|
await addPath(binDir)
|
||||||
|
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
||||||
function findBinDir(dirs: string[], name: string) {
|
async function findBinDir(dirs: string[], name: string) {
|
||||||
const foundDir = dirs.find((dir) => existsSync(join(dir, addExeExt(name))))
|
const exists = await Promise.all(dirs.map((dir) => pathExists(join(dir, addExeExt(name)))))
|
||||||
|
const dirIndex = exists.findIndex((exist) => exist)
|
||||||
|
const foundDir = dirs[dirIndex]
|
||||||
|
|
||||||
if (foundDir !== undefined) {
|
if (foundDir !== undefined) {
|
||||||
return foundDir
|
return foundDir
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ import { tmpdir } from "os"
|
||||||
import * as path from "patha"
|
import * as path from "patha"
|
||||||
import { addExeExt, join } from "patha"
|
import { addExeExt, join } from "patha"
|
||||||
import spawn from "cross-spawn"
|
import spawn from "cross-spawn"
|
||||||
import { existsSync } from "fs"
|
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
export async function setupTmpDir(testName: string) {
|
export async function setupTmpDir(testName: string) {
|
||||||
const tempDirectory = path.join(tmpdir(), "setup cpp temp", testName)
|
const tempDirectory = path.join(tmpdir(), "setup cpp temp", testName)
|
||||||
|
@ -39,7 +40,7 @@ export async function testBin(
|
||||||
console.log(`Testing the existence of ${binDir}`)
|
console.log(`Testing the existence of ${binDir}`)
|
||||||
expect(binDir).toBeDefined()
|
expect(binDir).toBeDefined()
|
||||||
expect(binDir).not.toHaveLength(0)
|
expect(binDir).not.toHaveLength(0)
|
||||||
expect(existsSync(binDir)).toBeTruthy()
|
expect(await pathExists(binDir)).toBeTruthy()
|
||||||
bin = join(binDir, addExeExt(name))
|
bin = join(binDir, addExeExt(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import execa from "execa"
|
import execa from "execa"
|
||||||
import { existsSync } from "fs"
|
|
||||||
import { dirname, join, addShExt, addShRelativePrefix } from "patha"
|
import { dirname, join, addShExt, addShRelativePrefix } from "patha"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { addPath } from "../utils/env/addEnv"
|
import { addPath } from "../utils/env/addEnv"
|
||||||
|
@ -12,6 +12,7 @@ import { hasDnf } from "../utils/env/hasDnf"
|
||||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
import { giveUserAccess } from "user-access"
|
import { giveUserAccess } from "user-access"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
let hasVCPKG = false
|
let hasVCPKG = false
|
||||||
|
|
||||||
|
@ -35,16 +36,18 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
|
||||||
setupDnfPack("git")
|
setupDnfPack("git")
|
||||||
setupDnfPack("pkg-config")
|
setupDnfPack("pkg-config")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
await setupAptPack("curl")
|
await setupAptPack([
|
||||||
await setupAptPack("zip")
|
{ name: "curl" },
|
||||||
await setupAptPack("unzip")
|
{ name: "zip" },
|
||||||
await setupAptPack("tar")
|
{ name: "unzip" },
|
||||||
await setupAptPack("git")
|
{ name: "tar" },
|
||||||
await setupAptPack("pkg-config")
|
{ name: "git" },
|
||||||
|
{ name: "pkg-config" },
|
||||||
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!existsSync(join(setupDir, addShExt("bootstrap-vcpkg", ".bat")))) {
|
if (!(await pathExists(join(setupDir, addShExt("bootstrap-vcpkg", ".bat"))))) {
|
||||||
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
|
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
|
||||||
} else {
|
} else {
|
||||||
notice(`Vcpkg folder already exists at ${setupDir}. This might mean that ~/vcpkg is restored from the cache.`)
|
notice(`Vcpkg folder already exists at ${setupDir}. This might mean that ~/vcpkg is restored from the cache.`)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { existsSync } from "fs"
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { setupMSVCDevCmd } from "msvc-dev-cmd/lib.js"
|
import { setupMSVCDevCmd } from "msvc-dev-cmd/lib.js"
|
||||||
import { addEnv } from "../utils/env/addEnv"
|
import { addEnv } from "../utils/env/addEnv"
|
||||||
import { info } from "ci-log"
|
import { info } from "ci-log"
|
||||||
|
import pathExists from "path-exists"
|
||||||
|
|
||||||
function getArch(arch: string): string {
|
function getArch(arch: string): string {
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
|
@ -30,7 +30,7 @@ export async function setupVCVarsall(
|
||||||
uwp?: boolean,
|
uwp?: boolean,
|
||||||
spectre?: boolean
|
spectre?: boolean
|
||||||
) {
|
) {
|
||||||
if (VCTargetsPath !== undefined && existsSync(VCTargetsPath)) {
|
if (VCTargetsPath !== undefined && (await pathExists(VCTargetsPath))) {
|
||||||
info(`Adding ${VCTargetsPath} to PATH`)
|
info(`Adding ${VCTargetsPath} to PATH`)
|
||||||
await addEnv("VCTargetsPath", VCTargetsPath)
|
await addEnv("VCTargetsPath", VCTargetsPath)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue