mirror of https://github.com/aminya/setup-cpp
Merge pull request #290 from aminya/llvm-flags [skip ci]
This commit is contained in:
commit
5d06e63ba4
16
biome.jsonc
16
biome.jsonc
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
|
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
|
||||||
"files": {
|
"files": {
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"**/node_modules/**",
|
"**/node_modules/**",
|
||||||
|
@ -33,8 +33,18 @@
|
||||||
"suspicious": {
|
"suspicious": {
|
||||||
"noConfusingVoidType": "off"
|
"noConfusingVoidType": "off"
|
||||||
},
|
},
|
||||||
"nursery": {
|
"correctness": {
|
||||||
"useImportExtensions": "warn"
|
"useImportExtensions": {
|
||||||
|
"level": "error",
|
||||||
|
"options": {
|
||||||
|
"suggestedExtensions": {
|
||||||
|
"ts": {
|
||||||
|
"component": "js",
|
||||||
|
"module": "js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
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
18
package.json
18
package.json
|
@ -61,7 +61,7 @@
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"@aminya/minijson": "1.0.3",
|
"@aminya/minijson": "1.0.3",
|
||||||
"@babel/core": "^7.25.2",
|
"@babel/core": "^7.25.2",
|
||||||
"@biomejs/biome": "^1.8.3",
|
"@biomejs/biome": "^1.9.1",
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
"@liuli-util/vite-plugin-node": "^0.9.0",
|
"@liuli-util/vite-plugin-node": "^0.9.0",
|
||||||
"@octokit/core": "^6.1.2",
|
"@octokit/core": "^6.1.2",
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
"@types/escape-quotes": "~1.0.0",
|
"@types/escape-quotes": "~1.0.0",
|
||||||
"@types/eslint": "^8.56.12",
|
"@types/eslint": "^8.56.12",
|
||||||
"@types/iarna__toml": "~2.0.5",
|
"@types/iarna__toml": "~2.0.5",
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.13",
|
||||||
"@types/memoizee": "^0.4.11",
|
"@types/memoizee": "^0.4.11",
|
||||||
"@types/node": "^12.20.55",
|
"@types/node": "^12.20.55",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
|
@ -89,14 +89,14 @@
|
||||||
"ci-log": "workspace:*",
|
"ci-log": "workspace:*",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"cspell": "^8.14.2",
|
"cspell": "^8.14.3",
|
||||||
"diagnostics_channel": "^1.1.0",
|
"diagnostics_channel": "^1.1.0",
|
||||||
"dprint": "^0.47.2",
|
"dprint": "^0.47.2",
|
||||||
"envosman": "workspace:*",
|
"envosman": "workspace:*",
|
||||||
"escape-path-with-spaces": "^1.0.2",
|
"escape-path-with-spaces": "^1.0.2",
|
||||||
"escape-quotes": "^1.0.2",
|
"escape-quotes": "^1.0.2",
|
||||||
"escape-string-regexp": "^5.0.0",
|
"escape-string-regexp": "^5.0.0",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.1",
|
||||||
"eslint-config-atomic": "^1.22.1",
|
"eslint-config-atomic": "^1.22.1",
|
||||||
"exec-powershell": "workspace:*",
|
"exec-powershell": "workspace:*",
|
||||||
"execa": "^7.2.0",
|
"execa": "^7.2.0",
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#c01f519bd995460228ed3dec4df51df92dc290fd",
|
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#c01f519bd995460228ed3dec4df51df92dc290fd",
|
||||||
"node-downloader-helper": "2.1.9",
|
"node-downloader-helper": "2.1.9",
|
||||||
"npm-check-updates": "^17.1.1",
|
"npm-check-updates": "^17.1.1",
|
||||||
"npm-run-all2": "^6.2.2",
|
"npm-run-all2": "^6.2.3",
|
||||||
"numerous": "1.0.3",
|
"numerous": "1.0.3",
|
||||||
"p-timeout": "^6.1.2",
|
"p-timeout": "^6.1.2",
|
||||||
"path-exists": "^5.0.0",
|
"path-exists": "^5.0.0",
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
"prettier-config-atomic": "^4.0.0",
|
"prettier-config-atomic": "^4.0.0",
|
||||||
"readme-md-generator": "^1.0.0",
|
"readme-md-generator": "^1.0.0",
|
||||||
"retry-as-promised": "^7.0.4",
|
"retry-as-promised": "^7.0.4",
|
||||||
"rollup": "^4.21.2",
|
"rollup": "^4.21.3",
|
||||||
"safe-stable-stringify": "^2.5.0",
|
"safe-stable-stringify": "^2.5.0",
|
||||||
"semver": "7.6.3",
|
"semver": "7.6.3",
|
||||||
"setup-apt": "workspace:*",
|
"setup-apt": "workspace:*",
|
||||||
|
@ -127,17 +127,17 @@
|
||||||
"setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751",
|
"setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751",
|
||||||
"shx": "0.3.4",
|
"shx": "0.3.4",
|
||||||
"simple-update-notifier": "^2.0.0",
|
"simple-update-notifier": "^2.0.0",
|
||||||
"terser": "^5.31.6",
|
"terser": "^5.33.0",
|
||||||
"terser-config-atomic": "^1.0.0",
|
"terser-config-atomic": "^1.0.0",
|
||||||
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
|
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"ts-readme": "^1.1.3",
|
"ts-readme": "^1.1.3",
|
||||||
"turbo": "2.1.1",
|
"turbo": "2.1.1",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.6.2",
|
||||||
"ubuntu-version": "^2.0.0",
|
"ubuntu-version": "^2.0.0",
|
||||||
"untildify-user": "workspace:*",
|
"untildify-user": "workspace:*",
|
||||||
"util.types": "^0.0.2",
|
"util.types": "^0.0.2",
|
||||||
"vite": "^5.4.3",
|
"vite": "^5.4.6",
|
||||||
"vite-plugin-babel": "^1.2.0",
|
"vite-plugin-babel": "^1.2.0",
|
||||||
"web-streams-polyfill": "^4.0.0",
|
"web-streams-polyfill": "^4.0.0",
|
||||||
"which": "^4.0.0"
|
"which": "^4.0.0"
|
||||||
|
|
1171
pnpm-lock.yaml
1171
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,6 @@ export async function installCompiler(
|
||||||
setupCppDir: string,
|
setupCppDir: string,
|
||||||
arch: string,
|
arch: string,
|
||||||
successMessages: string[],
|
successMessages: string[],
|
||||||
hasLLVM: boolean,
|
|
||||||
errorMessages: string[],
|
errorMessages: string[],
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
@ -67,11 +66,6 @@ export async function installCompiler(
|
||||||
? await setupMingw(gccVersion, join(setupCppDir, "gcc"), arch)
|
? await setupMingw(gccVersion, join(setupCppDir, "gcc"), arch)
|
||||||
: await setupGcc(gccVersion, join(setupCppDir, "gcc"), arch)
|
: await setupGcc(gccVersion, join(setupCppDir, "gcc"), arch)
|
||||||
|
|
||||||
if (hasLLVM) {
|
|
||||||
// remove back the added CPPFLAGS of LLVM that include the LLVM headers
|
|
||||||
await addEnv("CPPFLAGS", "", rcOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
await activateGcovGCC(gccVersion)
|
await activateGcovGCC(gccVersion)
|
||||||
|
|
||||||
successMessages.push(getSuccessMessage("gcc", installationInfo))
|
successMessages.push(getSuccessMessage("gcc", installationInfo))
|
||||||
|
@ -90,11 +84,6 @@ export async function installCompiler(
|
||||||
arch,
|
arch,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (hasLLVM) {
|
|
||||||
// remove the CPPFLAGS of LLVM that include the LLVM headers
|
|
||||||
await addEnv("CPPFLAGS", "", rcOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
successMessages.push(getSuccessMessage("msvc", installationInfo))
|
successMessages.push(getSuccessMessage("msvc", installationInfo))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,8 @@ export async function installTool(
|
||||||
timeout: number = DEFAULT_TIMEOUT,
|
timeout: number = DEFAULT_TIMEOUT,
|
||||||
) {
|
) {
|
||||||
startGroup(`Installing ${tool} ${version}`)
|
startGroup(`Installing ${tool} ${version}`)
|
||||||
let hasLLVM = false
|
|
||||||
try {
|
try {
|
||||||
hasLLVM = await pTimeout(installToolImpl(tool, version, osVersion, arch, setupCppDir, successMessages), {
|
await pTimeout(installToolImpl(tool, version, osVersion, arch, setupCppDir, successMessages), {
|
||||||
milliseconds: timeout,
|
milliseconds: timeout,
|
||||||
message: `Timeout while installing ${tool} ${version}. You can increase the timeout from options`,
|
message: `Timeout while installing ${tool} ${version}. You can increase the timeout from options`,
|
||||||
})
|
})
|
||||||
|
@ -37,7 +36,6 @@ export async function installTool(
|
||||||
errorMessages.push(`${tool} failed to install`)
|
errorMessages.push(`${tool} failed to install`)
|
||||||
}
|
}
|
||||||
endGroup()
|
endGroup()
|
||||||
return hasLLVM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installToolImpl(
|
async function installToolImpl(
|
||||||
|
@ -48,7 +46,6 @@ async function installToolImpl(
|
||||||
setupCppDir: string,
|
setupCppDir: string,
|
||||||
successMessages: string[],
|
successMessages: string[],
|
||||||
) {
|
) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
const hasLLVM = ["llvm", "clangformat", "clangtidy"].includes(tool)
|
const hasLLVM = ["llvm", "clangformat", "clangtidy"].includes(tool)
|
||||||
|
|
||||||
let installationInfo: InstallationInfo | undefined | void
|
let installationInfo: InstallationInfo | undefined | void
|
||||||
|
@ -72,5 +69,4 @@ async function installToolImpl(
|
||||||
}
|
}
|
||||||
// preparing a report string
|
// preparing a report string
|
||||||
successMessages.push(getSuccessMessage(tool, installationInfo))
|
successMessages.push(getSuccessMessage(tool, installationInfo))
|
||||||
return hasLLVM
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { type InstallationInfo, setupBin } from "../utils/setup/setupBin.js"
|
||||||
import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
|
import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
|
||||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
|
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
|
||||||
import { semverCoerceIfInvalid } from "../utils/setup/version.js"
|
import { semverCoerceIfInvalid } from "../utils/setup/version.js"
|
||||||
|
import { quoteIfHasSpace } from "../utils/std/index.js"
|
||||||
import { getVersion } from "../versions/versions.js"
|
import { getVersion } from "../versions/versions.js"
|
||||||
import { LLVMPackages, setupLLVMApt } from "./llvm_installer.js"
|
import { LLVMPackages, setupLLVMApt } from "./llvm_installer.js"
|
||||||
import { getLLVMPackageInfo } from "./llvm_url.js"
|
import { getLLVMPackageInfo } from "./llvm_url.js"
|
||||||
|
@ -26,11 +27,11 @@ const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURL
|
||||||
|
|
||||||
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)
|
||||||
await activateLLVM(installationInfo.installDir ?? setupDir)
|
await activateLLVM(installationInfo.installDir ?? setupDir, version)
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupLLVMWithoutActivation_raw(version: string, setupDir: string, arch: string) {
|
async function setupLLVMWithoutActivation_(version: string, setupDir: string, arch: string) {
|
||||||
// install LLVM
|
// install LLVM
|
||||||
const [installationInfo, _1] = await Promise.all([
|
const [installationInfo, _1] = await Promise.all([
|
||||||
setupLLVMOnly(version, setupDir, arch),
|
setupLLVMOnly(version, setupDir, arch),
|
||||||
|
@ -42,7 +43,7 @@ async function setupLLVMWithoutActivation_raw(version: string, setupDir: string,
|
||||||
|
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
const setupLLVMWithoutActivation = memoize(setupLLVMWithoutActivation_raw, { promise: true })
|
const setupLLVMWithoutActivation = memoize(setupLLVMWithoutActivation_, { promise: true })
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup clang-format
|
* Setup clang-format
|
||||||
|
@ -64,8 +65,7 @@ async function setupLLVMOnly(
|
||||||
arch: string,
|
arch: string,
|
||||||
packages: LLVMPackages = LLVMPackages.All,
|
packages: LLVMPackages = LLVMPackages.All,
|
||||||
) {
|
) {
|
||||||
const coeredVersion = semverCoerceIfInvalid(version)
|
const majorVersion = majorLLVMVersion(version)
|
||||||
const majorVersion = Number.parseInt(coeredVersion.split(".")[0], 10)
|
|
||||||
try {
|
try {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
return await setupLLVMApt(majorVersion, packages)
|
return await setupLLVMApt(majorVersion, packages)
|
||||||
|
@ -79,7 +79,12 @@ async function setupLLVMOnly(
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
async function llvmBinaryDeps_raw(majorVersion: number) {
|
function majorLLVMVersion(version: string) {
|
||||||
|
const coeredVersion = semverCoerceIfInvalid(version)
|
||||||
|
return Number.parseInt(coeredVersion.split(".")[0], 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function llvmBinaryDeps_(majorVersion: number) {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
if (majorVersion <= 10) {
|
if (majorVersion <= 10) {
|
||||||
await installAptPack([{ name: "libtinfo5" }])
|
await installAptPack([{ name: "libtinfo5" }])
|
||||||
|
@ -96,36 +101,45 @@ async function llvmBinaryDeps_raw(majorVersion: number) {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const llvmBinaryDeps = memoize(llvmBinaryDeps_raw, { promise: true })
|
const llvmBinaryDeps = memoize(llvmBinaryDeps_, { promise: true })
|
||||||
|
|
||||||
async function setupLLVMDeps_raw(arch: string) {
|
async function setupLLVMDeps_(arch: string) {
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
// using llvm requires ld, an up to date libstdc++, etc. So, install gcc first,
|
// using llvm requires ld, an up to date libstdc++, etc. So, install gcc first,
|
||||||
// but with a lower priority than the one used by activateLLVM()
|
// but with a lower priority than the one used by activateLLVM()
|
||||||
await setupGcc(getVersion("gcc", undefined, await ubuntuVersion()), "", arch, 40)
|
await setupGcc(getVersion("gcc", undefined, await ubuntuVersion()), "", arch, 40)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const setupLLVMDeps = memoize(setupLLVMDeps_raw, { promise: true })
|
const setupLLVMDeps = memoize(setupLLVMDeps_, { promise: true })
|
||||||
|
|
||||||
export async function activateLLVM(directory: string) {
|
export async function activateLLVM(directory: string, version: 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 llvmMajor = majorLLVMVersion(version)
|
||||||
|
|
||||||
const actPromises: Promise<void>[] = [
|
const actPromises: Promise<void>[] = [
|
||||||
|
// compiler paths
|
||||||
|
addEnv("CC", addExeExt(`${directory}/bin/clang`), rcOptions),
|
||||||
|
addEnv("CXX", addExeExt(`${directory}/bin/clang++`), rcOptions),
|
||||||
|
|
||||||
// the output of this action
|
// the output of this action
|
||||||
addEnv("LLVM_PATH", directory, rcOptions),
|
addEnv("LLVM_PATH", directory, rcOptions),
|
||||||
|
|
||||||
// Setup LLVM as the compiler
|
// Setup LLVM as the compiler
|
||||||
addEnv("LD_LIBRARY_PATH", `${directory}/lib${delimiter}${ld}`, rcOptions),
|
addEnv("LD_LIBRARY_PATH", `${ld}${delimiter}${directory}/lib`, rcOptions),
|
||||||
addEnv("DYLD_LIBRARY_PATH", `${directory}/lib${delimiter}${dyld}`, rcOptions),
|
addEnv("DYLD_LIBRARY_PATH", `${dyld}${delimiter}${directory}/lib`, rcOptions),
|
||||||
|
|
||||||
// compiler flags
|
// compiler flags
|
||||||
addEnv("LDFLAGS", `-L"${directory}/lib"`, rcOptions),
|
addEnv("LLVM_LDFLAGS", `-L${quoteIfHasSpace(`${directory}/lib`)}`, rcOptions),
|
||||||
addEnv("CPPFLAGS", `-I"${directory}/include"`, rcOptions),
|
addEnv("LLVM_CPPFLAGS", `-I${quoteIfHasSpace(`${directory}/include`)}`, rcOptions),
|
||||||
|
|
||||||
// compiler paths
|
// CPATH
|
||||||
addEnv("CC", addExeExt(`${directory}/bin/clang`), rcOptions),
|
await pathExists(`${directory}/lib/clang/${version}/include`)
|
||||||
addEnv("CXX", addExeExt(`${directory}/bin/clang++`), rcOptions),
|
? addEnv("LLVM_CPATH", `${directory}/lib/clang/${version}/include`, rcOptions)
|
||||||
|
: await pathExists(`${directory}/lib/clang/${llvmMajor}/include`)
|
||||||
|
? addEnv("LLVM_CPATH", `${directory}/lib/clang/${llvmMajor}/include`, rcOptions)
|
||||||
|
: Promise.resolve(),
|
||||||
|
|
||||||
addEnv("LIBRARY_PATH", `${directory}/lib`, rcOptions),
|
addEnv("LIBRARY_PATH", `${directory}/lib`, rcOptions),
|
||||||
|
|
||||||
|
@ -133,16 +147,6 @@ export async function activateLLVM(directory: string) {
|
||||||
setupMacOSSDK(),
|
setupMacOSSDK(),
|
||||||
]
|
]
|
||||||
|
|
||||||
// TODO Causes issues with clangd
|
|
||||||
// TODO Windows builds fail with llvm's CPATH
|
|
||||||
// if (process.platform !== "win32") {
|
|
||||||
// if (await pathExists(`${directory}/lib/clang/${version}/include`)) {
|
|
||||||
// promises.push(addEnv("CPATH", `${directory}/lib/clang/${version}/include`, rcOptions))
|
|
||||||
// } else if (await pathExists(`${directory}/lib/clang/${llvmMajor}/include`)) {
|
|
||||||
// promises.push(addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`, rcOptions))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
const priority = 60
|
const priority = 60
|
||||||
actPromises.push(
|
actPromises.push(
|
||||||
|
|
|
@ -293,7 +293,7 @@ async function ensurePipUpgrade(foundPython: string) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addPythonBaseExecPrefix_raw(python: string) {
|
async function addPythonBaseExecPrefix_(python: string) {
|
||||||
const dirs: string[] = []
|
const dirs: string[] = []
|
||||||
|
|
||||||
// detection based on the platform
|
// detection based on the platform
|
||||||
|
@ -317,4 +317,4 @@ async function addPythonBaseExecPrefix_raw(python: string) {
|
||||||
*
|
*
|
||||||
* The answer is cached for subsequent calls
|
* The answer is cached for subsequent calls
|
||||||
*/
|
*/
|
||||||
export const addPythonBaseExecPrefix = memoize(addPythonBaseExecPrefix_raw, { promise: true })
|
export const addPythonBaseExecPrefix = memoize(addPythonBaseExecPrefix_, { promise: true })
|
||||||
|
|
|
@ -66,9 +66,6 @@ async function main(args: string[]): Promise<number> {
|
||||||
await setupPacmanPack("python-pygments")
|
await setupPacmanPack("python-pygments")
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used to unset CPPFLAGS of LLVM when other compilers are used as the main compiler */
|
|
||||||
let hasLLVM = false
|
|
||||||
|
|
||||||
// loop over the tools and run their setup function
|
// loop over the tools and run their setup function
|
||||||
|
|
||||||
let failedFast = false
|
let failedFast = false
|
||||||
|
@ -89,7 +86,7 @@ async function main(args: string[]): Promise<number> {
|
||||||
// running the setup function for this tool
|
// running the setup function for this tool
|
||||||
time1 = Date.now()
|
time1 = Date.now()
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
hasLLVM = await installTool(
|
await installTool(
|
||||||
tool,
|
tool,
|
||||||
version,
|
version,
|
||||||
osVersion,
|
osVersion,
|
||||||
|
@ -109,7 +106,7 @@ async function main(args: string[]): Promise<number> {
|
||||||
const maybeCompiler = opts.compiler
|
const maybeCompiler = opts.compiler
|
||||||
if (maybeCompiler !== undefined) {
|
if (maybeCompiler !== undefined) {
|
||||||
const time1Compiler = Date.now()
|
const time1Compiler = Date.now()
|
||||||
await installCompiler(maybeCompiler, osVersion, setupCppDir, arch, successMessages, hasLLVM, errorMessages)
|
await installCompiler(maybeCompiler, osVersion, setupCppDir, arch, successMessages, errorMessages)
|
||||||
const time2Compiler = Date.now()
|
const time2Compiler = Date.now()
|
||||||
info(`took ${timeFormatter.format(time1Compiler, time2Compiler) || "0 seconds"}`)
|
info(`took ${timeFormatter.format(time1Compiler, time2Compiler) || "0 seconds"}`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import memoize from "memoizee"
|
||||||
*
|
*
|
||||||
* @returns {number[]} - The macOS version as an array of numbers
|
* @returns {number[]} - The macOS version as an array of numbers
|
||||||
*/
|
*/
|
||||||
function macosVersion_raw() {
|
function macosVersion_() {
|
||||||
if (process.platform !== "darwin") {
|
if (process.platform !== "darwin") {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,4 @@ function macosVersion_raw() {
|
||||||
const { version } = macosRelease()
|
const { version } = macosRelease()
|
||||||
return version.split(".").map((v) => Number.parseInt(v, 10))
|
return version.split(".").map((v) => Number.parseInt(v, 10))
|
||||||
}
|
}
|
||||||
export const macosVersion = memoize(macosVersion_raw)
|
export const macosVersion = memoize(macosVersion_)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { getUbuntuVersion } from "ubuntu-version"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { isUbuntu } from "./isUbuntu.js"
|
import { isUbuntu } from "./isUbuntu.js"
|
||||||
|
|
||||||
async function ubuntuVersion_raw(): Promise<number[] | null> {
|
async function ubuntuVersion_(): Promise<number[] | null> {
|
||||||
try {
|
try {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
try {
|
try {
|
||||||
|
@ -34,7 +34,7 @@ async function ubuntuVersion_raw(): Promise<number[] | null> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Detect Ubuntu version */
|
/** Detect Ubuntu version */
|
||||||
export const ubuntuVersion = memoize(ubuntuVersion_raw, { promise: true })
|
export const ubuntuVersion = memoize(ubuntuVersion_, { promise: true })
|
||||||
|
|
||||||
/** Detect Ubuntu version using os.version() for Ubuntu based distros */
|
/** Detect Ubuntu version using os.version() for Ubuntu based distros */
|
||||||
function detectUsingOsVersion() {
|
function detectUsingOsVersion() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ export async function hasPipx(givenPython: string) {
|
||||||
return (await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })).exitCode === 0
|
return (await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })).exitCode === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPipxHome_raw() {
|
async function getPipxHome_() {
|
||||||
let pipxHome = process.env.PIPX_HOME
|
let pipxHome = process.env.PIPX_HOME
|
||||||
if (pipxHome !== undefined) {
|
if (pipxHome !== undefined) {
|
||||||
return pipxHome
|
return pipxHome
|
||||||
|
@ -130,9 +130,9 @@ async function getPipxHome_raw() {
|
||||||
await mkdirp(join(pipxHome, "venv"))
|
await mkdirp(join(pipxHome, "venv"))
|
||||||
return pipxHome
|
return pipxHome
|
||||||
}
|
}
|
||||||
const getPipxHome = memoize(getPipxHome_raw, { promise: true })
|
const getPipxHome = memoize(getPipxHome_, { promise: true })
|
||||||
|
|
||||||
async function getPipxBinDir_raw() {
|
async function getPipxBinDir_() {
|
||||||
if (process.env.PIPX_BIN_DIR !== undefined) {
|
if (process.env.PIPX_BIN_DIR !== undefined) {
|
||||||
return process.env.PIPX_BIN_DIR
|
return process.env.PIPX_BIN_DIR
|
||||||
}
|
}
|
||||||
|
@ -142,16 +142,16 @@ async function getPipxBinDir_raw() {
|
||||||
await mkdirp(pipxBinDir)
|
await mkdirp(pipxBinDir)
|
||||||
return pipxBinDir
|
return pipxBinDir
|
||||||
}
|
}
|
||||||
const getPipxBinDir = memoize(getPipxBinDir_raw, { promise: true })
|
const getPipxBinDir = memoize(getPipxBinDir_, { promise: true })
|
||||||
|
|
||||||
async function getPython_raw(): Promise<string> {
|
async function getPython_(): Promise<string> {
|
||||||
const pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
|
const pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
|
||||||
if (pythonBin === undefined) {
|
if (pythonBin === undefined) {
|
||||||
throw new Error("Python binary was not found")
|
throw new Error("Python binary was not found")
|
||||||
}
|
}
|
||||||
return pythonBin
|
return pythonBin
|
||||||
}
|
}
|
||||||
const getPython = memoize(getPython_raw, { promise: true })
|
const getPython = memoize(getPython_, { promise: true })
|
||||||
|
|
||||||
async function pipHasPackage(python: string, name: string) {
|
async function pipHasPackage(python: string, name: string) {
|
||||||
const result = await execa(python, ["-m", "pip", "-qq", "index", "versions", name], {
|
const result = await execa(python, ["-m", "pip", "-qq", "index", "versions", name], {
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
export function unique(dirs: string[]) {
|
export function unique(dirs: string[]) {
|
||||||
return [...new Set(dirs)]
|
return [...new Set(dirs)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function quoteIfHasSpace(str: string, quoteChar = "\"") {
|
||||||
|
return str.includes(" ") ? `${quoteChar}${str}${quoteChar}` : str
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue