mirror of https://github.com/aminya/setup-cpp
fix: fix the kcov build + use ninja for faster build
This commit is contained in:
parent
f61dd0e6b8
commit
de92c65463
|
@ -22,6 +22,7 @@ words:
|
|||
- CPPFLAGS
|
||||
- cpprc
|
||||
- Cpython
|
||||
- DCMAKE
|
||||
- deps
|
||||
- devel
|
||||
- dyld
|
||||
|
|
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
|
@ -1,6 +1,5 @@
|
|||
import execa from "execa"
|
||||
import { join } from "path"
|
||||
import untildify from "untildify"
|
||||
import which from "which"
|
||||
import { setupCmake } from "../cmake/cmake"
|
||||
import { getVersion } from "../default_versions"
|
||||
|
@ -15,6 +14,8 @@ import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
|||
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||
import { addVPrefix, removeVPrefix } from "../utils/setup/version"
|
||||
import { info } from "../utils/io/io"
|
||||
import { untildify_user } from "../utils/path/untildify"
|
||||
import { setupNinja } from "../ninja/ninja"
|
||||
|
||||
function getDownloadKcovPackageInfo(version: string): PackageInfo {
|
||||
return {
|
||||
|
@ -27,11 +28,10 @@ function getDownloadKcovPackageInfo(version: string): PackageInfo {
|
|||
}
|
||||
|
||||
function getBuildKcovPackageInfo(version: string): PackageInfo {
|
||||
const version_number = removeVPrefix(version)
|
||||
return {
|
||||
url: `https://github.com/SimonKagstrom/kcov/archive/refs/tags/${version}.tar.gz`,
|
||||
extractedFolderName: `kcov-${version_number}`,
|
||||
binRelativeDir: "build/",
|
||||
extractedFolderName: "",
|
||||
binRelativeDir: "build/src",
|
||||
binFileName: addBinExtension("kcov"),
|
||||
extractFunction: buildKcov,
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ function getBuildKcovPackageInfo(version: string): PackageInfo {
|
|||
|
||||
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"), "")
|
||||
}
|
||||
let cmake = await getCmake()
|
||||
|
||||
if (process.platform === "linux") {
|
||||
if (isArch()) {
|
||||
setupPacmanPack("libdwarf")
|
||||
|
@ -55,11 +55,28 @@ async function buildKcov(file: string, dest: string) {
|
|||
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" })
|
||||
// execSudo("cmake", ["--install", "./build"], out)
|
||||
const buildDir = join(out, "build")
|
||||
await execa(cmake, ["-S", out, "-B", buildDir, "-DCMAKE_BUILD_TYPE=Release", "-G", "Ninja"], {
|
||||
cwd: out,
|
||||
stdio: "inherit",
|
||||
})
|
||||
await execa(cmake, ["--build", buildDir, "--config", "Release"], { cwd: out, stdio: "inherit" })
|
||||
// execSudo(cmake, ["--install", buildDir], out)
|
||||
// return "user/local/bin" // the cmake install prefix
|
||||
return join(out, "build")
|
||||
return out
|
||||
}
|
||||
|
||||
async function getCmake() {
|
||||
let cmake = which.sync("cmake", { nothrow: true })
|
||||
if (cmake === null) {
|
||||
const { binDir } = await setupCmake(getVersion("cmake", undefined), join(untildify_user(""), "cmake"), "")
|
||||
cmake = join(binDir, "cmake")
|
||||
}
|
||||
let ninja = which.sync("ninja", { nothrow: true })
|
||||
if (ninja === null) {
|
||||
await setupNinja(getVersion("ninja", undefined), join(untildify_user(""), "ninja"), "")
|
||||
}
|
||||
return cmake
|
||||
}
|
||||
|
||||
export async function setupKcov(versionGiven: string, setupDir: string, arch: string) {
|
||||
|
|
|
@ -37,6 +37,7 @@ export async function testBin(
|
|||
) {
|
||||
let bin = name
|
||||
if (typeof binDir === "string") {
|
||||
console.log(`Testing the existence of ${binDir}`)
|
||||
expect(binDir).toBeDefined()
|
||||
expect(binDir).not.toHaveLength(0)
|
||||
expect(existsSync(binDir)).toBeTruthy()
|
||||
|
|
Loading…
Reference in New Issue