mirror of https://github.com/aminya/setup-cpp
feat: add the cached isArch function
This commit is contained in:
parent
df27d7c079
commit
7caf0ddff8
|
@ -2,7 +2,7 @@ import { setupAptPack } 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"
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function setupCcache(version: string, _setupDir: string, _arch: string) {
|
export function setupCcache(version: string, _setupDir: string, _arch: string) {
|
||||||
|
@ -14,7 +14,7 @@ export function setupCcache(version: string, _setupDir: string, _arch: string) {
|
||||||
return setupBrewPack("ccache", version)
|
return setupBrewPack("ccache", version)
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
return setupPacmanPack("ccache", version)
|
return setupPacmanPack("ccache", version)
|
||||||
}
|
}
|
||||||
return setupAptPack("ccache", version)
|
return setupAptPack("ccache", version)
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupAptPack } 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"
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export async function setupCppcheck(version: string | undefined, _setupDir: string, _arch: string) {
|
export async function setupCppcheck(version: string | undefined, _setupDir: string, _arch: string) {
|
||||||
|
@ -17,7 +17,7 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
|
||||||
return setupBrewPack("cppcheck", version)
|
return setupBrewPack("cppcheck", version)
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
return setupPacmanPack("cppcheck", version)
|
return setupPacmanPack("cppcheck", version)
|
||||||
}
|
}
|
||||||
return setupAptPack("cppcheck", version)
|
return setupAptPack("cppcheck", version)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { setupGraphviz } from "../graphviz/graphviz"
|
||||||
import { getVersion } from "../default_versions"
|
import { getVersion } from "../default_versions"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
/** 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
|
||||||
|
@ -59,13 +59,13 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
||||||
case "linux": {
|
case "linux": {
|
||||||
let installationInfo: InstallationInfo
|
let installationInfo: InstallationInfo
|
||||||
if (version === "") {
|
if (version === "") {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
installationInfo = setupPacmanPack("doxygen", undefined)
|
installationInfo = setupPacmanPack("doxygen", undefined)
|
||||||
} else {
|
} else {
|
||||||
installationInfo = setupAptPack("doxygen", undefined)
|
installationInfo = setupAptPack("doxygen", undefined)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
installationInfo = setupPacmanPack("doxygen", version)
|
installationInfo = setupPacmanPack("doxygen", version)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { isGitHubCI } from "../utils/env/isci"
|
||||||
import { addBinExtension } from "../utils/extension/extension"
|
import { addBinExtension } from "../utils/extension/extension"
|
||||||
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
|
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||||
import { extract7Zip } from "../utils/setup/extract"
|
import { extract7Zip } from "../utils/setup/extract"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
interface MingwInfo {
|
interface MingwInfo {
|
||||||
releaseName: string
|
releaseName: string
|
||||||
|
@ -81,7 +81,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (arch === "x64") {
|
if (arch === "x64") {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
installationInfo = setupPacmanPack("gcc", version)
|
installationInfo = setupPacmanPack("gcc", version)
|
||||||
} else {
|
} else {
|
||||||
setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
|
setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
|
||||||
|
@ -89,7 +89,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
setupPacmanPack("gcc-multilib", version)
|
setupPacmanPack("gcc-multilib", version)
|
||||||
} else {
|
} else {
|
||||||
setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
|
setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
||||||
import { InstallationInfo } from "../utils/setup/setupBin"
|
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||||
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 which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export async function setupGraphviz(version: string, _setupDir: string, _arch: string) {
|
export async function setupGraphviz(version: string, _setupDir: string, _arch: string) {
|
||||||
|
@ -17,7 +17,7 @@ export async function setupGraphviz(version: string, _setupDir: string, _arch: s
|
||||||
return setupBrewPack("graphviz", version)
|
return setupBrewPack("graphviz", version)
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
return setupPacmanPack("graphviz", version)
|
return setupPacmanPack("graphviz", version)
|
||||||
}
|
}
|
||||||
return setupAptPack("graphviz", version)
|
return setupAptPack("graphviz", version)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { extractTarByExe } from "../utils/setup/extract"
|
||||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
||||||
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
|
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||||
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
function getKcovPackageInfo(version: string): PackageInfo {
|
function getKcovPackageInfo(version: string): PackageInfo {
|
||||||
const version_number = parseInt(version.replace(/^v/, ""), 10)
|
const version_number = parseInt(version.replace(/^v/, ""), 10)
|
||||||
|
@ -43,7 +44,7 @@ async function buildKcov(file: string, dest: string) {
|
||||||
await setupCmake(getVersion("cmake", undefined), join(untildify(""), "cmake"), "")
|
await setupCmake(getVersion("cmake", undefined), join(untildify(""), "cmake"), "")
|
||||||
}
|
}
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
setupPacmanPack("libdwarf")
|
setupPacmanPack("libdwarf")
|
||||||
setupPacmanPack("libcurl-openssl")
|
setupPacmanPack("libcurl-openssl")
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,7 +61,7 @@ async function buildKcov(file: string, dest: string) {
|
||||||
export async function setupKcov(version: string, setupDir: string, arch: string) {
|
export async function setupKcov(version: string, setupDir: string, arch: string) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
// TODO install kcov ? setupPacmanPack("kcov")
|
// TODO install kcov ? setupPacmanPack("kcov")
|
||||||
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir, arch)
|
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir, arch)
|
||||||
setupPacmanPack("binutils")
|
setupPacmanPack("binutils")
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { existsSync } from "fs"
|
||||||
import { isGitHubCI } from "../utils/env/isci"
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
import { setupGcc } from "../gcc/gcc"
|
import { setupGcc } from "../gcc/gcc"
|
||||||
import { getVersion } from "../default_versions"
|
import { getVersion } from "../default_versions"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
//================================================
|
//================================================
|
||||||
// Version
|
// Version
|
||||||
|
@ -286,7 +286,7 @@ async function _setupLLVM(version: string, setupDir: string, arch: string) {
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
// install llvm build dependencies
|
// install llvm build dependencies
|
||||||
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
|
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
// setupPacmanPack("ncurses")
|
// setupPacmanPack("ncurses")
|
||||||
// TODO: install libtinfo ?
|
// TODO: install libtinfo ?
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupAptPack } 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"
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export async function setupMake(version: string, _setupDir: string, _arch: string) {
|
export async function setupMake(version: string, _setupDir: string, _arch: string) {
|
||||||
|
@ -17,7 +17,7 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
|
||||||
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
|
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
return setupPacmanPack("make", version)
|
return setupPacmanPack("make", version)
|
||||||
}
|
}
|
||||||
return setupAptPack("make", version)
|
return setupAptPack("make", version)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { isGitHubCI } from "../utils/env/isci"
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
import { warning, info } from "../utils/io/io"
|
import { warning, info } from "../utils/io/io"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
export async function setupPython(version: string, setupDir: string, arch: string) {
|
export async function setupPython(version: string, setupDir: string, arch: string) {
|
||||||
if (!isGitHubCI()) {
|
if (!isGitHubCI()) {
|
||||||
|
@ -40,7 +40,7 @@ export async function setupPythonViaSystem(version: string, setupDir: string, _a
|
||||||
return setupBrewPack("python3", version)
|
return setupBrewPack("python3", version)
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
const installInfo = setupPacmanPack("python", version)
|
const installInfo = setupPacmanPack("python", version)
|
||||||
setupPacmanPack("python-pip")
|
setupPacmanPack("python-pip")
|
||||||
return installInfo
|
return installInfo
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { setupAptPack } 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"
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import which from "which"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function setupSevenZip(version: string, _setupDir: string, _arch: string) {
|
export function setupSevenZip(version: string, _setupDir: string, _arch: string) {
|
||||||
|
@ -14,7 +14,7 @@ export function setupSevenZip(version: string, _setupDir: string, _arch: string)
|
||||||
return setupBrewPack("p7zip", version)
|
return setupBrewPack("p7zip", version)
|
||||||
}
|
}
|
||||||
case "linux": {
|
case "linux": {
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
return setupPacmanPack("p7zip", version)
|
return setupPacmanPack("p7zip", version)
|
||||||
}
|
}
|
||||||
return setupAptPack("p7zip-full", version)
|
return setupAptPack("p7zip-full", version)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import which from "which"
|
||||||
|
|
||||||
|
let isArchCache: undefined | boolean = undefined
|
||||||
|
|
||||||
|
export function isArch(): boolean {
|
||||||
|
if (isArchCache === undefined) {
|
||||||
|
// detect arch by checking if pacman exists
|
||||||
|
isArchCache = which.sync("pacman", { nothrow: true }) !== null
|
||||||
|
}
|
||||||
|
|
||||||
|
return isArchCache
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import { tmpdir } from "os"
|
||||||
import { isGitHubCI } from "../env/isci"
|
import { isGitHubCI } from "../env/isci"
|
||||||
import { setupAptPack } from "./setupAptPack"
|
import { setupAptPack } from "./setupAptPack"
|
||||||
import { setupPacmanPack } from "./setupPacmanPack"
|
import { setupPacmanPack } from "./setupPacmanPack"
|
||||||
import which from "which"
|
import { isArch } from "../env/isArch"
|
||||||
|
|
||||||
/** A type that describes a package */
|
/** A type that describes a package */
|
||||||
export type PackageInfo = {
|
export type PackageInfo = {
|
||||||
|
@ -90,7 +90,7 @@ export async function setupBin(
|
||||||
if (!didInit) {
|
if (!didInit) {
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
// extraction dependencies
|
// extraction dependencies
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
setupPacmanPack("unzip")
|
setupPacmanPack("unzip")
|
||||||
setupPacmanPack("tar")
|
setupPacmanPack("tar")
|
||||||
setupPacmanPack("xz")
|
setupPacmanPack("xz")
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { getVersion } from "../../default_versions"
|
||||||
import { InstallationInfo } from "./setupBin"
|
import { InstallationInfo } from "./setupBin"
|
||||||
import { setupAptPack } from "./setupAptPack"
|
import { setupAptPack } from "./setupAptPack"
|
||||||
import { setupPacmanPack } from "./setupPacmanPack"
|
import { setupPacmanPack } from "./setupPacmanPack"
|
||||||
|
import { isArch } from "../env/isArch"
|
||||||
|
|
||||||
let python: string | undefined
|
let python: string | undefined
|
||||||
let binDir: string | undefined
|
let binDir: string | undefined
|
||||||
|
@ -43,7 +44,7 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
|
||||||
execa.sync(python, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
|
execa.sync(python, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
|
||||||
} else if (process.platform === "linux") {
|
} else if (process.platform === "linux") {
|
||||||
// ensure that pip is installed on Linux (happens when python is found but pip not installed)
|
// ensure that pip is installed on Linux (happens when python is found but pip not installed)
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
setupPacmanPack("python-pip")
|
setupPacmanPack("python-pip")
|
||||||
} else {
|
} else {
|
||||||
setupAptPack("python3-pip")
|
setupAptPack("python3-pip")
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { notice } from "../utils/io/io"
|
||||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
||||||
import { InstallationInfo } from "../utils/setup/setupBin"
|
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||||
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
|
||||||
let hasVCPKG = false
|
let hasVCPKG = false
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
|
||||||
if (!hasVCPKG || which.sync("vcpkg", { nothrow: true }) === null) {
|
if (!hasVCPKG || which.sync("vcpkg", { nothrow: true }) === null) {
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
// vcpkg download and extraction dependencies
|
// vcpkg download and extraction dependencies
|
||||||
if (which.sync("pacman", { nothrow: true })) {
|
if (isArch()) {
|
||||||
setupPacmanPack("curl")
|
setupPacmanPack("curl")
|
||||||
setupPacmanPack("zip")
|
setupPacmanPack("zip")
|
||||||
setupPacmanPack("unzip")
|
setupPacmanPack("unzip")
|
||||||
|
|
Loading…
Reference in New Issue