mirror of https://github.com/aminya/setup-cpp
feat: support passing arch from CLI to setupBin
This commit is contained in:
parent
0fe9b461ac
commit
a062ce6962
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,16 +1,13 @@
|
||||||
import { extractZip, extractTar } from "@actions/tool-cache"
|
import { extractZip, extractTar } from "@actions/tool-cache"
|
||||||
import { getInput } from "@actions/core"
|
|
||||||
import semverLte from "semver/functions/lte"
|
import semverLte from "semver/functions/lte"
|
||||||
import semverCoerce from "semver/functions/coerce"
|
import semverCoerce from "semver/functions/coerce"
|
||||||
import { setupBin, PackageInfo, InstallationInfo } from "../utils/setup/setupBin"
|
import { setupBin, PackageInfo, InstallationInfo } from "../utils/setup/setupBin"
|
||||||
import { addBinExtension } from "../utils/extension/extension"
|
import { addBinExtension } from "../utils/extension/extension"
|
||||||
|
|
||||||
/** Get the platform data for cmake */
|
/** Get the platform data for cmake */
|
||||||
function getCmakePackageInfo(version: string, platform?: NodeJS.Platform): PackageInfo {
|
function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: string): PackageInfo {
|
||||||
const semVersion = semverCoerce(version) ?? version
|
const semVersion = semverCoerce(version) ?? version
|
||||||
const platformStr = platform ?? process.platform
|
switch (platform) {
|
||||||
const arch = getInput("architecture") || process.arch
|
|
||||||
switch (platformStr) {
|
|
||||||
case "win32": {
|
case "win32": {
|
||||||
const isOld = semverLte(semVersion, "v3.19.6")
|
const isOld = semverLte(semVersion, "v3.19.6")
|
||||||
let osArchStr: string
|
let osArchStr: string
|
||||||
|
@ -58,12 +55,11 @@ function getCmakePackageInfo(version: string, platform?: NodeJS.Platform): Packa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unsupported platform '${platformStr}'`)
|
throw new Error(`Unsupported platform '${platform}'`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setup cmake */
|
/** Setup cmake */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
export function setupCmake(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
export function setupCmake(version: string, setupDir: string, _arch: string): Promise<InstallationInfo> {
|
return setupBin("cmake", version, getCmakePackageInfo, setupDir, arch)
|
||||||
return setupBin("cmake", version, getCmakePackageInfo, setupDir)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ function getKcovPackageInfo(version: string): PackageInfo {
|
||||||
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": {
|
||||||
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir)
|
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir, arch)
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -222,8 +222,8 @@ export function getUrl(platform: string, version: string): string | null | Promi
|
||||||
//================================================
|
//================================================
|
||||||
// Exports
|
// Exports
|
||||||
//================================================
|
//================================================
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform): Promise<PackageInfo> {
|
async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform, _arch: string): Promise<PackageInfo> {
|
||||||
const [specificVersion, url] = await getSpecificVersionAndUrl(VERSIONS, platform, version, getUrl)
|
const [specificVersion, url] = await getSpecificVersionAndUrl(VERSIONS, platform, version, getUrl)
|
||||||
setOutput("version", specificVersion)
|
setOutput("version", specificVersion)
|
||||||
return {
|
return {
|
||||||
|
@ -235,13 +235,8 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform): P
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setupLLVM(
|
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
version: string,
|
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
|
||||||
setupDir: string,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
_arch: string
|
|
||||||
): Promise<InstallationInfo> {
|
|
||||||
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir)
|
|
||||||
await activateLLVM(installationInfo.installDir ?? setupDir, version)
|
await activateLLVM(installationInfo.installDir ?? setupDir, version)
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
|
@ -284,11 +279,6 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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(
|
export function setupClangTools(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
version: string,
|
return setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
|
||||||
setupDir: string,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
_arch: string
|
|
||||||
): Promise<InstallationInfo> {
|
|
||||||
return setupBin("llvm", version, getLLVMPackageInfo, setupDir)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ function getNinjaPlatform(platform: NodeJS.Platform) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the platform data for ninja */
|
/** Get the platform data for ninja */
|
||||||
function getNinjaPackageInfo(version: string, platform: NodeJS.Platform): PackageInfo {
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
function getNinjaPackageInfo(version: string, platform: NodeJS.Platform, _arch: string): PackageInfo {
|
||||||
const ninjaPlatform = getNinjaPlatform(platform)
|
const ninjaPlatform = getNinjaPlatform(platform)
|
||||||
return {
|
return {
|
||||||
binRelativeDir: "",
|
binRelativeDir: "",
|
||||||
|
@ -28,7 +29,6 @@ function getNinjaPackageInfo(version: string, platform: NodeJS.Platform): Packag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
export function setupNinja(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
export function setupNinja(version: string, setupDir: string, _arch: string): Promise<InstallationInfo> {
|
return setupBin("ninja", version, getNinjaPackageInfo, setupDir, arch)
|
||||||
return setupBin("ninja", version, getNinjaPackageInfo, setupDir)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,17 @@ export type InstallationInfo = {
|
||||||
export async function setupBin(
|
export async function setupBin(
|
||||||
name: string,
|
name: string,
|
||||||
version: string,
|
version: string,
|
||||||
getPackageInfo: (version: string, platform: NodeJS.Platform) => PackageInfo | Promise<PackageInfo>,
|
getPackageInfo: (version: string, platform: NodeJS.Platform, arch: string) => PackageInfo | Promise<PackageInfo>,
|
||||||
setupDir: string
|
setupDir: string,
|
||||||
|
arch: string
|
||||||
): Promise<InstallationInfo> {
|
): Promise<InstallationInfo> {
|
||||||
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
|
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
|
||||||
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACH ?? join(tmpdir(), "setup-cpp", "ToolCache")
|
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACHE ?? join(tmpdir(), "setup-cpp", "ToolCache")
|
||||||
|
|
||||||
const { url, binRelativeDir, binFileName, extractedFolderName, extractFunction } = await getPackageInfo(
|
const { url, binRelativeDir, binFileName, extractedFolderName, extractFunction } = await getPackageInfo(
|
||||||
version,
|
version,
|
||||||
process.platform
|
process.platform,
|
||||||
|
arch
|
||||||
)
|
)
|
||||||
|
|
||||||
// Restore from cache (if found).
|
// Restore from cache (if found).
|
||||||
|
|
Loading…
Reference in New Issue