fix: fix the kcov build + use ninja for faster build

This commit is contained in:
Amin Yahyaabadi 2022-07-27 18:45:26 -07:00
parent f61dd0e6b8
commit de92c65463
7 changed files with 34 additions and 15 deletions

View File

@ -22,6 +22,7 @@ words:
- CPPFLAGS - CPPFLAGS
- cpprc - cpprc
- Cpython - Cpython
- DCMAKE
- deps - deps
- devel - devel
- dyld - dyld

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.mjs vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,5 @@
import execa from "execa" import execa from "execa"
import { join } from "path" import { join } from "path"
import untildify from "untildify"
import which from "which" import which from "which"
import { setupCmake } from "../cmake/cmake" import { setupCmake } from "../cmake/cmake"
import { getVersion } from "../default_versions" import { getVersion } from "../default_versions"
@ -15,6 +14,8 @@ import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu" import { isUbuntu } from "../utils/env/isUbuntu"
import { addVPrefix, removeVPrefix } from "../utils/setup/version" import { addVPrefix, removeVPrefix } from "../utils/setup/version"
import { info } from "../utils/io/io" import { info } from "../utils/io/io"
import { untildify_user } from "../utils/path/untildify"
import { setupNinja } from "../ninja/ninja"
function getDownloadKcovPackageInfo(version: string): PackageInfo { function getDownloadKcovPackageInfo(version: string): PackageInfo {
return { return {
@ -27,11 +28,10 @@ function getDownloadKcovPackageInfo(version: string): PackageInfo {
} }
function getBuildKcovPackageInfo(version: string): PackageInfo { 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: "",
binRelativeDir: "build/", binRelativeDir: "build/src",
binFileName: addBinExtension("kcov"), binFileName: addBinExtension("kcov"),
extractFunction: buildKcov, extractFunction: buildKcov,
} }
@ -39,10 +39,10 @@ function getBuildKcovPackageInfo(version: string): PackageInfo {
async function buildKcov(file: string, dest: string) { async function buildKcov(file: string, dest: string) {
const out = await extractTarByExe(file, dest, ["--strip-components=1"]) const out = await extractTarByExe(file, dest, ["--strip-components=1"])
// build after extraction using CMake // build after extraction using CMake
if (which.sync("cmake", { nothrow: true }) === null) { let cmake = await getCmake()
await setupCmake(getVersion("cmake", undefined), join(untildify(""), "cmake"), "")
}
if (process.platform === "linux") { if (process.platform === "linux") {
if (isArch()) { if (isArch()) {
setupPacmanPack("libdwarf") setupPacmanPack("libdwarf")
@ -55,11 +55,28 @@ async function buildKcov(file: string, dest: string) {
setupAptPack("libcurl4-openssl-dev") setupAptPack("libcurl4-openssl-dev")
} }
} }
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out, stdio: "inherit" }) const buildDir = join(out, "build")
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out, stdio: "inherit" }) await execa(cmake, ["-S", out, "-B", buildDir, "-DCMAKE_BUILD_TYPE=Release", "-G", "Ninja"], {
// execSudo("cmake", ["--install", "./build"], out) 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 "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) { export async function setupKcov(versionGiven: string, setupDir: string, arch: string) {

View File

@ -37,6 +37,7 @@ export async function testBin(
) { ) {
let bin = name let bin = name
if (typeof binDir === "string") { if (typeof binDir === "string") {
console.log(`Testing the existence of ${binDir}`)
expect(binDir).toBeDefined() expect(binDir).toBeDefined()
expect(binDir).not.toHaveLength(0) expect(binDir).not.toHaveLength(0)
expect(existsSync(binDir)).toBeTruthy() expect(existsSync(binDir)).toBeTruthy()