mirror of https://github.com/aminya/setup-cpp
Merge branch 'master' into defaults [skip ci]
This commit is contained in:
parent
22d43201d9
commit
5cafac73d2
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -8,7 +8,7 @@ const DefaultVersions: Record<string, string> = {
|
|||
conan: "1.47.0", // https://github.com/conan-io/conan/releases
|
||||
meson: "0.61.4", // https://github.com/mesonbuild/meson/releases
|
||||
python: "3.8.10",
|
||||
kcov: "v40", // https://github.com/SimonKagstrom/kcov/releases
|
||||
kcov: "40", // https://github.com/SimonKagstrom/kcov/releases
|
||||
task: "3.12.0", // https://github.com/go-task/task/releases
|
||||
doxygen: "1.9.1", // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen
|
||||
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11", // https://community.chocolatey.org/packages/mingw#versionhistory and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
|
||||
|
|
|
@ -1,40 +1,51 @@
|
|||
import { setupKcov } from "../kcov"
|
||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||
import { getVersion } from "../../default_versions"
|
||||
import which from "which"
|
||||
|
||||
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", async () => {
|
||||
const version = getVersion("kcov", "true")
|
||||
|
||||
const directory = await setupTmpDir(`kcov-${version}`)
|
||||
await testKcov(version, directory)
|
||||
await cleanupTmpDir(`kcov-${version}`)
|
||||
it("should setup Kcov v40", async () => {
|
||||
const directory = await setupTmpDir("kcov-v40")
|
||||
const { binDir } = (await setupKcov("40", directory, "")) as InstallationInfo
|
||||
await testBin("kcov", ["--version"], binDir)
|
||||
await cleanupTmpDir("kcov-v40")
|
||||
})
|
||||
|
||||
// TODO
|
||||
// it("should setup Kcov v38", async () => {
|
||||
// const directory = await setupTmpDir("kcov-v38")
|
||||
// await testKcov("v38", directory)
|
||||
it("should setup Kcov v39", async () => {
|
||||
const directory = await setupTmpDir("kcov-v39")
|
||||
const { binDir } = (await setupKcov("39", directory, "")) as InstallationInfo
|
||||
await testBin("kcov", ["--version"], binDir)
|
||||
await cleanupTmpDir("kcov-v39")
|
||||
})
|
||||
|
||||
// it("should find Kcov in the cache", async () => {
|
||||
// const binDir = await testKcov("v39", directory)
|
||||
// if (isGitHubCI()) {
|
||||
// expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||
// }
|
||||
// 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("hostedtoolcache")).toBeTruthy()
|
||||
// await cleanupTmpDir("kcov-v39")
|
||||
// })
|
||||
it("should setup Kcov v38", async () => {
|
||||
try {
|
||||
const directory2 = await setupTmpDir("kcov-v38")
|
||||
|
||||
await setupKcov("38", directory2, "")
|
||||
|
||||
expect(which.sync("kcov", { nothrow: true })).toBeTruthy()
|
||||
|
||||
await testBin("kcov", ["--version"], "usr/local/bin") // because of cmake --install
|
||||
|
||||
await cleanupTmpDir("kcov-v38")
|
||||
} catch (err) {
|
||||
// TODO
|
||||
console.warn(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import execa from "execa"
|
||||
// import { join } from "path"
|
||||
// import { untildify_user as untildify } from "./utils/path/untildify"
|
||||
// import { setupCmake } from "../cmake/cmake"
|
||||
import { join } from "path"
|
||||
import untildify from "untildify"
|
||||
import which from "which"
|
||||
import { setupCmake } from "../cmake/cmake"
|
||||
import { getVersion } from "../default_versions"
|
||||
import { execSudo } from "../utils/exec/sudo"
|
||||
import { addBinExtension } from "../utils/extension/extension"
|
||||
import { extractTarByExe } from "../utils/setup/extract"
|
||||
|
@ -16,7 +18,7 @@ function getKcovPackageInfo(version: string): PackageInfo {
|
|||
}
|
||||
if (version_number >= 39) {
|
||||
return {
|
||||
url: `https://github.com/SimonKagstrom/kcov/releases/download/${version}/kcov-amd64.tar.gz`,
|
||||
url: `https://github.com/SimonKagstrom/kcov/releases/download/v${version_number}/kcov-amd64.tar.gz`,
|
||||
extractedFolderName: "",
|
||||
binRelativeDir: "usr/local/bin",
|
||||
binFileName: addBinExtension("kcov"),
|
||||
|
@ -28,21 +30,27 @@ function getKcovPackageInfo(version: string): PackageInfo {
|
|||
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, stdio: "inherit" })
|
||||
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out, stdio: "inherit" })
|
||||
await execSudo("cmake", ["--install", "./build"], out)
|
||||
return out
|
||||
},
|
||||
extractFunction: buildKcov,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function buildKcov(file: string, dest: string) {
|
||||
const out = await extractTarByExe(file, dest, ["--strip-components=1"])
|
||||
// build after extraction using CMake
|
||||
if (which.sync("cmake", { nothrow: true }) === null) {
|
||||
await setupCmake(getVersion("cmake", undefined), join(untildify(""), "cmake"), "")
|
||||
}
|
||||
if (process.platform === "linux") {
|
||||
await setupAptPack("libdw-dev")
|
||||
await setupAptPack("libcurl4-openssl-dev")
|
||||
}
|
||||
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out, stdio: "inherit" })
|
||||
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out, stdio: "inherit" })
|
||||
await execSudo("cmake", ["--install", "./build"], out)
|
||||
return out
|
||||
}
|
||||
|
||||
export async function setupKcov(version: string, setupDir: string, arch: string) {
|
||||
switch (process.platform) {
|
||||
case "linux": {
|
||||
|
|
|
@ -2,6 +2,7 @@ import execa from "execa"
|
|||
import { mkdirP } from "@actions/io"
|
||||
import which from "which"
|
||||
import { setupSevenZip } from "../../sevenzip/sevenzip"
|
||||
import { warning } from "../io/io"
|
||||
export { extractTar, extractXar, extract7z, extractZip } from "@actions/tool-cache"
|
||||
|
||||
let sevenZip: string | undefined
|
||||
|
@ -26,6 +27,17 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
|
|||
} catch {
|
||||
// ignore
|
||||
}
|
||||
await execa("tar", ["xf", file, "-C", dest, ...flags], { stdio: "inherit" })
|
||||
|
||||
// TODO windows fails to create symlinks
|
||||
// https://github.com/heroku/heroku-slugs/issues/3
|
||||
|
||||
try {
|
||||
await execa("tar", ["xf", file, "-C", dest, ...flags], { stdio: "inherit" })
|
||||
} catch (e) {
|
||||
if (process.platform === "win32" && (e as Error).message.includes("Can't create '\\\\?\\C:")) {
|
||||
warning(`Failed to extract symlink ${file} to ${dest}. Ignoring this symlink.`)
|
||||
}
|
||||
}
|
||||
|
||||
return dest
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue