mirror of https://github.com/aminya/setup-cpp
Merge pull request #10 from aminya/kcov
This commit is contained in:
commit
ce44289478
|
@ -28,6 +28,7 @@ The package can be used locally or from CI services like GitHub Actions.
|
|||
- doxygen
|
||||
- gcovr
|
||||
- opencppcoverage
|
||||
- kcov
|
||||
- python
|
||||
- choco
|
||||
- brew
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -8,6 +8,7 @@ const DefaultVersions: Record<string, string> = {
|
|||
conan: "1.42.1",
|
||||
meson: "0.60.1",
|
||||
python: "3.10.0",
|
||||
kcov: "v39",
|
||||
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11",
|
||||
}
|
||||
|
||||
|
|
|
@ -34,20 +34,30 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
|
|||
}
|
||||
case "linux": {
|
||||
if (arch === "x64") {
|
||||
await setupAptPack("gcc", version, [
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
|
||||
"ppa:ubuntu-toolchain-r/test",
|
||||
])
|
||||
binDir = (
|
||||
await setupAptPack("g++", version, [
|
||||
"ppa:ubuntu-toolchain-r/test",
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
|
||||
"ppa:ubuntu-toolchain-r/test",
|
||||
])
|
||||
).binDir
|
||||
} else {
|
||||
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
||||
await setupAptPack("gcc-multilib", version, [
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
|
||||
"ppa:ubuntu-toolchain-r/test",
|
||||
])
|
||||
binDir = (
|
||||
await setupAptPack("g++-multilib", version, [
|
||||
"ppa:ubuntu-toolchain-r/test",
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
|
||||
"'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
|
||||
"ppa:ubuntu-toolchain-r/test",
|
||||
])
|
||||
).binDir
|
||||
}
|
||||
|
@ -58,9 +68,9 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
|
|||
// case "none": {
|
||||
// if (arch === "arm" || arch === "arm64") {
|
||||
// return setupAptPack("gcc-arm-none-eabi", version, [
|
||||
// "ppa:ubuntu-toolchain-r/test",
|
||||
// "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial mai'",
|
||||
// "'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'",
|
||||
// "ppa:ubuntu-toolchain-r/test",
|
||||
// ])
|
||||
// } else {
|
||||
// throw new Error(`Unsupported platform for ${arch}`)
|
||||
|
@ -78,8 +88,6 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
|
|||
}
|
||||
|
||||
async function activateGcc(version: string, binDir: string) {
|
||||
const majorVersion = semverMajor(semverCoerce(version) ?? version)
|
||||
|
||||
// TODO
|
||||
// const ld = process.env.LD_LIBRARY_PATH ?? ""
|
||||
// const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
|
||||
|
@ -93,8 +101,14 @@ async function activateGcc(version: string, binDir: string) {
|
|||
exportVariable("CC", `${binDir}/gcc`)
|
||||
exportVariable("CXX", `${binDir}/g++`)
|
||||
} else {
|
||||
exportVariable("CC", `${binDir}/gcc-${majorVersion}`)
|
||||
exportVariable("CXX", `${binDir}/g++-${majorVersion}`)
|
||||
const majorVersion = semverMajor(semverCoerce(version) ?? version)
|
||||
if (majorVersion >= 5) {
|
||||
exportVariable("CC", `${binDir}/gcc-${majorVersion}`)
|
||||
exportVariable("CXX", `${binDir}/g++-${majorVersion}`)
|
||||
} else {
|
||||
exportVariable("CC", `${binDir}/gcc-${version}`)
|
||||
exportVariable("CXX", `${binDir}/g++-${version}`)
|
||||
}
|
||||
}
|
||||
|
||||
await setupMacOSSDK()
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
import { setupKcov } from "../kcov"
|
||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||
|
||||
jest.setTimeout(300000)
|
||||
async function testKcov(version: string, directory: string) {
|
||||
const { binDir } = (await setupKcov(version, directory, "")) as InstallationInfo
|
||||
await testBin("kcov", ["--version"], binDir)
|
||||
return binDir
|
||||
}
|
||||
|
||||
describe("setup-Kcov", () => {
|
||||
if (process.platform !== "linux") {
|
||||
it.todo("should setup kcov on non-linux")
|
||||
return
|
||||
}
|
||||
|
||||
it("should setup Kcov v39", async () => {
|
||||
const directory = await setupTmpDir("kcov-v39")
|
||||
await testKcov("v39", directory)
|
||||
await cleanupTmpDir("kcov-v39")
|
||||
})
|
||||
|
||||
// TODO
|
||||
// it("should setup Kcov v38", async () => {
|
||||
// const directory = await setupTmpDir("kcov-v38")
|
||||
// await testKcov("v38", directory)
|
||||
// await cleanupTmpDir("kcov-v39")
|
||||
// })
|
||||
|
||||
// it("should find Kcov in the cache", async () => {
|
||||
// const directory = await setupTmpDir("kcov-v39")
|
||||
// const binDir = await testKcov("v39", directory)
|
||||
// expect(binDir.includes("ToolCache")).toBeTruthy()
|
||||
// await cleanupTmpDir("kcov-v39")
|
||||
// })
|
||||
})
|
|
@ -0,0 +1,58 @@
|
|||
import execa from "execa"
|
||||
// import { join } from "path"
|
||||
// import untildify from "untildify"
|
||||
// import { setupCmake } from "../cmake/cmake"
|
||||
import { execaSudo } from "../utils/env/sudo"
|
||||
import { addBinExtension } from "../utils/extension/extension"
|
||||
import { extractTarByExe } from "../utils/setup/extract"
|
||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||
|
||||
function getKcovPackageInfo(version: 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 {
|
||||
url: `https://github.com/SimonKagstrom/kcov/releases/download/${version}/kcov-amd64.tar.gz`,
|
||||
extractedFolderName: "",
|
||||
binRelativeDir: "usr/local/bin",
|
||||
binFileName: addBinExtension("kcov"),
|
||||
extractFunction: (file: string, dest: string) => {
|
||||
return extractTarByExe(file, dest, ["--strip-components=0"])
|
||||
},
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
url: `https://github.com/SimonKagstrom/kcov/archive/refs/tags/${version}.tar.gz`,
|
||||
extractedFolderName: `kcov-${version_number}`,
|
||||
binRelativeDir: "build/",
|
||||
binFileName: addBinExtension("kcov"),
|
||||
extractFunction: async (file: string, dest: string): Promise<string> => {
|
||||
const out = await extractTarByExe(file, dest)
|
||||
// build after extraction using CMake
|
||||
// await setupCmake("3.22.0", join(untildify("~/"), "cmake"), "")
|
||||
await setupAptPack("libdw-dev")
|
||||
await setupAptPack("libcurl4-openssl-dev")
|
||||
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out })
|
||||
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out })
|
||||
await execaSudo("cmake", ["--install", "./build"], out)
|
||||
return out
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function setupKcov(version: string, setupDir: string, arch: string) {
|
||||
switch (process.platform) {
|
||||
case "linux": {
|
||||
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir)
|
||||
return installationInfo
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported platform for ${arch}`)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import { setupVcpkg } from "./vcpkg/vcpkg"
|
|||
import { join } from "path"
|
||||
import { warning } from "@actions/core"
|
||||
import { setupVCVarsall } from "./vcvarsall/vcvarsall"
|
||||
import { setupKcov } from "./kcov/kcov"
|
||||
|
||||
/** The setup functions */
|
||||
const setups = {
|
||||
|
@ -46,6 +47,7 @@ const setups = {
|
|||
cppcheck: setupCppcheck,
|
||||
msvc: setupMSVC,
|
||||
vcvarsall: setupVCVarsall,
|
||||
kcov: setupKcov,
|
||||
}
|
||||
|
||||
/** The tools that can be installed */
|
||||
|
@ -67,6 +69,7 @@ const tools: Array<keyof typeof setups> = [
|
|||
"gcc",
|
||||
"msvc",
|
||||
"vcvarsall",
|
||||
"kcov",
|
||||
]
|
||||
|
||||
/** The possible inputs to the program */
|
||||
|
@ -267,6 +270,7 @@ All the available tools:
|
|||
--doxygen
|
||||
--gcovr
|
||||
--opencppcoverage
|
||||
--kcov
|
||||
--python
|
||||
--choco
|
||||
--brew
|
||||
|
|
|
@ -19,9 +19,9 @@ export function mightSudo(command: string) {
|
|||
return command
|
||||
}
|
||||
|
||||
export function execaSudo(file: string, args: string[]) {
|
||||
export function execaSudo(file: string, args: string[], cwd?: string) {
|
||||
if (isRoot()) {
|
||||
return execa.command(`sudo ${[file, ...args].join(" ")}`, { shell: true })
|
||||
return execa.command(`sudo ${[file, ...args].join(" ")}`, { shell: true, cwd })
|
||||
} else {
|
||||
return execa(file, args)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue