mirror of https://github.com/aminya/setup-cpp
fix: build or download kcov binary based on the ubuntu version
This commit is contained in:
parent
8fb789d7c1
commit
15070ee637
|
@ -63,6 +63,13 @@ const DefaultUbuntuVersion: Record<string, Record<number, string>> = {
|
||||||
16: "legacy",
|
16: "legacy",
|
||||||
14: "legacy",
|
14: "legacy",
|
||||||
},
|
},
|
||||||
|
kcov: {
|
||||||
|
22: "40",
|
||||||
|
20: "40-binary", // https://github.com/SimonKagstrom/kcov/releases
|
||||||
|
18: "40",
|
||||||
|
16: "40",
|
||||||
|
14: "40",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the default version if passed true or undefined, otherwise return the version itself */
|
/** Get the default version if passed true or undefined, otherwise return the version itself */
|
||||||
|
|
|
@ -9,19 +9,14 @@ import { addBinExtension } from "../utils/extension/extension"
|
||||||
import { extractTarByExe } from "../utils/setup/extract"
|
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 { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||||
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 { removeVPrefix } from "../utils/setup/version"
|
||||||
|
|
||||||
function getKcovPackageInfo(version: string): PackageInfo {
|
function getDownloadKcovPackageInfo(version_number: string): PackageInfo {
|
||||||
const version_number = parseInt(version.replace(/^v/, ""), 10)
|
|
||||||
if (version_number === 38) {
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
version = "v38"
|
|
||||||
}
|
|
||||||
if (version_number >= 39) {
|
|
||||||
return {
|
return {
|
||||||
url: `https://github.com/SimonKagstrom/kcov/releases/download/v${version_number}/kcov-amd64.tar.gz`,
|
url: `https://github.com/SimonKagstrom/kcov/releases/download/v${version_number}/kcov-amd64.tar.gz`,
|
||||||
extractedFolderName: "",
|
extractedFolderName: "",
|
||||||
|
@ -29,7 +24,10 @@ function getKcovPackageInfo(version: string): PackageInfo {
|
||||||
binFileName: addBinExtension("kcov"),
|
binFileName: addBinExtension("kcov"),
|
||||||
extractFunction: extractTarByExe,
|
extractFunction: extractTarByExe,
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
function getBuildKcovPackageInfo(version: string): PackageInfo {
|
||||||
|
const version_number = removeVPrefix(version)
|
||||||
return {
|
return {
|
||||||
url: `https://github.com/SimonKagstrom/kcov/archive/refs/tags/${version}.tar.gz`,
|
url: `https://github.com/SimonKagstrom/kcov/archive/refs/tags/${version}.tar.gz`,
|
||||||
extractedFolderName: `kcov-${version_number}`,
|
extractedFolderName: `kcov-${version_number}`,
|
||||||
|
@ -37,7 +35,6 @@ function getKcovPackageInfo(version: string): PackageInfo {
|
||||||
binFileName: addBinExtension("kcov"),
|
binFileName: addBinExtension("kcov"),
|
||||||
extractFunction: buildKcov,
|
extractFunction: buildKcov,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildKcov(file: string, dest: string) {
|
async function buildKcov(file: string, dest: string) {
|
||||||
|
@ -64,10 +61,22 @@ async function buildKcov(file: string, dest: string) {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setupKcov(version: string, setupDir: string, arch: string) {
|
export async function setupKcov(versionGiven: string, setupDir: string, arch: string) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "linux": {
|
case "linux": {
|
||||||
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir, arch)
|
// parse version
|
||||||
|
const versionSplit = versionGiven.split("-")
|
||||||
|
let version = versionSplit[0]
|
||||||
|
const installMethod = versionSplit[1] as "binary" | undefined
|
||||||
|
const version_number = removeVPrefix(version)
|
||||||
|
// fix inconsistency in tagging
|
||||||
|
if (version_number === 38) {
|
||||||
|
version = "v38"
|
||||||
|
}
|
||||||
|
|
||||||
|
let installationInfo: InstallationInfo
|
||||||
|
if (installMethod === "binary" && version_number >= 39) {
|
||||||
|
installationInfo = await setupBin("kcov", version, getDownloadKcovPackageInfo, setupDir, arch)
|
||||||
if (isArch()) {
|
if (isArch()) {
|
||||||
setupPacmanPack("binutils")
|
setupPacmanPack("binutils")
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
|
@ -76,6 +85,10 @@ export async function setupKcov(version: string, setupDir: string, arch: string)
|
||||||
setupAptPack("libbinutils")
|
setupAptPack("libbinutils")
|
||||||
}
|
}
|
||||||
return installationInfo
|
return installationInfo
|
||||||
|
} else {
|
||||||
|
installationInfo = await setupBin("kcov", version, getBuildKcovPackageInfo, setupDir, arch)
|
||||||
|
}
|
||||||
|
return installationInfo
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error(`Unsupported platform for ${arch}`)
|
throw new Error(`Unsupported platform for ${arch}`)
|
||||||
|
|
|
@ -115,3 +115,7 @@ export function semverCoerceIfInvalid(version: string) {
|
||||||
}
|
}
|
||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function removeVPrefix(version: string) {
|
||||||
|
return parseInt(version.replace(/^v/, ""), 10)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue