Skip to content

Commit de92c65

Browse files
committed
fix: fix the kcov build + use ninja for faster build
1 parent f61dd0e commit de92c65

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ words:
2222
- CPPFLAGS
2323
- cpprc
2424
- Cpython
25+
- DCMAKE
2526
- deps
2627
- devel
2728
- dyld

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/setup_cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/kcov/kcov.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import execa from "execa"
22
import { join } from "path"
3-
import untildify from "untildify"
43
import which from "which"
54
import { setupCmake } from "../cmake/cmake"
65
import { getVersion } from "../default_versions"
@@ -15,6 +14,8 @@ import { setupDnfPack } from "../utils/setup/setupDnfPack"
1514
import { isUbuntu } from "../utils/env/isUbuntu"
1615
import { addVPrefix, removeVPrefix } from "../utils/setup/version"
1716
import { info } from "../utils/io/io"
17+
import { untildify_user } from "../utils/path/untildify"
18+
import { setupNinja } from "../ninja/ninja"
1819

1920
function getDownloadKcovPackageInfo(version: string): PackageInfo {
2021
return {
@@ -27,22 +28,21 @@ function getDownloadKcovPackageInfo(version: string): PackageInfo {
2728
}
2829

2930
function getBuildKcovPackageInfo(version: string): PackageInfo {
30-
const version_number = removeVPrefix(version)
3131
return {
3232
url: `https://github.com/SimonKagstrom/kcov/archive/refs/tags/${version}.tar.gz`,
33-
extractedFolderName: `kcov-${version_number}`,
34-
binRelativeDir: "build/",
33+
extractedFolderName: "",
34+
binRelativeDir: "build/src",
3535
binFileName: addBinExtension("kcov"),
3636
extractFunction: buildKcov,
3737
}
3838
}
3939

4040
async function buildKcov(file: string, dest: string) {
4141
const out = await extractTarByExe(file, dest, ["--strip-components=1"])
42+
4243
// build after extraction using CMake
43-
if (which.sync("cmake", { nothrow: true }) === null) {
44-
await setupCmake(getVersion("cmake", undefined), join(untildify(""), "cmake"), "")
45-
}
44+
let cmake = await getCmake()
45+
4646
if (process.platform === "linux") {
4747
if (isArch()) {
4848
setupPacmanPack("libdwarf")
@@ -55,11 +55,28 @@ async function buildKcov(file: string, dest: string) {
5555
setupAptPack("libcurl4-openssl-dev")
5656
}
5757
}
58-
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out, stdio: "inherit" })
59-
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out, stdio: "inherit" })
60-
// execSudo("cmake", ["--install", "./build"], out)
58+
const buildDir = join(out, "build")
59+
await execa(cmake, ["-S", out, "-B", buildDir, "-DCMAKE_BUILD_TYPE=Release", "-G", "Ninja"], {
60+
cwd: out,
61+
stdio: "inherit",
62+
})
63+
await execa(cmake, ["--build", buildDir, "--config", "Release"], { cwd: out, stdio: "inherit" })
64+
// execSudo(cmake, ["--install", buildDir], out)
6165
// return "user/local/bin" // the cmake install prefix
62-
return join(out, "build")
66+
return out
67+
}
68+
69+
async function getCmake() {
70+
let cmake = which.sync("cmake", { nothrow: true })
71+
if (cmake === null) {
72+
const { binDir } = await setupCmake(getVersion("cmake", undefined), join(untildify_user(""), "cmake"), "")
73+
cmake = join(binDir, "cmake")
74+
}
75+
let ninja = which.sync("ninja", { nothrow: true })
76+
if (ninja === null) {
77+
await setupNinja(getVersion("ninja", undefined), join(untildify_user(""), "ninja"), "")
78+
}
79+
return cmake
6380
}
6481

6582
export async function setupKcov(versionGiven: string, setupDir: string, arch: string) {

src/utils/tests/test-helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export async function testBin(
3737
) {
3838
let bin = name
3939
if (typeof binDir === "string") {
40+
console.log(`Testing the existence of ${binDir}`)
4041
expect(binDir).toBeDefined()
4142
expect(binDir).not.toHaveLength(0)
4243
expect(existsSync(binDir)).toBeTruthy()

0 commit comments

Comments
 (0)