Merge pull request #174 from aminya/gcc-13 [skip ci]

This commit is contained in:
Amin Yahyaabadi 2023-05-24 18:48:23 -07:00 committed by GitHub
commit 3945890fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 996 additions and 773 deletions

View File

@ -1,4 +1,16 @@
{
"extends": "eslint-config-atomic",
"ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"]
"ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_"
}
]
}
}

View File

@ -12,6 +12,8 @@ ignorePaths:
words:
- aarch
- clangd
- Trofimovich
- cobertura
- aminya
- applellvm
- bazel

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

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -64,15 +64,15 @@
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"@babel/cli": "^7.21.0",
"@babel/cli": "^7.21.5",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^8.37.0",
"@types/eslint": "^8.40.0",
"@types/jest": "^29.5.1",
"@types/mri": "^1.1.1",
"@types/node": "^18.16.0",
"@types/node": "^20.2.3",
"@types/npmcli__ci-detect": "^2.0.0",
"@types/prettier": "2.7.2",
"@types/semver": "^7.3.13",
"@types/semver": "^7.5.0",
"@types/which": "^3.0.0",
"@upleveled/babel-plugin-remove-node-prefix": "github:aminya/babel-plugin-remove-node-prefix#95fcbd92405b99a6eece48c493548996f12e6519",
"admina": "^0.1.3",
@ -85,8 +85,8 @@
"escape-path-with-spaces": "^1.0.2",
"escape-quotes": "^1.0.2",
"escape-string-regexp": "^5.0.0",
"eslint": "^8.39.0",
"eslint-config-atomic": "^1.18.3",
"eslint": "^8.41.0",
"eslint-config-atomic": "^1.19.1",
"exec-powershell": "workspace:*",
"execa": "^7.1.1",
"fast-glob": "^3.2.12",
@ -95,7 +95,7 @@
"jest": "^29.5.0",
"mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"npm-check-updates": "^16.10.9",
"npm-check-updates": "^16.10.12",
"npm-run-all2": "^6.0.5",
"numerous": "1.0.3",
"parcel": "2.8.3",
@ -106,8 +106,8 @@
"quote-unquote": "^1.0.0",
"readme-md-generator": "^1.0.0",
"retry-as-promised": "^7.0.4",
"semver": "7.5.0",
"setup-python": "github:actions/setup-python#v4.6.0",
"semver": "7.5.1",
"setup-python": "github:actions/setup-python#v4.6.1",
"shx": "0.3.4",
"terser-config-atomic": "^0.1.1",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
@ -118,7 +118,7 @@
"ubuntu-version": "^2.0.0",
"untildify-user": "workspace:*",
"user-access": "workspace:*",
"which": "^3.0.0"
"which": "^3.0.1"
},
"engines": {
"node": ">=12.x"

View File

@ -12,7 +12,7 @@
},
"dependencies": {
"@actions/core": "^1.9.1",
"@npmcli/ci-detect": "github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d"
"ci-info": "^3.8.0"
},
"keywords": [
"log",

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ import { mkdirP } from "@actions/io"
import { readFileSync } from "fs"
import { addPath } from "../utils/env/addEnv"
/* eslint-disable require-atomic-updates */
let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars

View File

@ -70,7 +70,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
let installationInfo: InstallationInfo
if (version === "" || isArch() || hasDnf()) {
if (isArch()) {
installationInfo = setupPacmanPack("doxygen", version)
installationInfo = await setupPacmanPack("doxygen", version)
} else if (hasDnf()) {
return setupDnfPack("doxygen", version)
} else if (isUbuntu()) {

View File

@ -17,6 +17,7 @@ import { isUbuntu } from "../utils/env/isUbuntu"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { pathExists } from "path-exists"
import { ExecaReturnValue } from "execa"
interface MingwInfo {
releaseName: string
@ -95,7 +96,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
case "linux": {
if (arch === "x64") {
if (isArch()) {
installationInfo = setupPacmanPack("gcc", version)
installationInfo = await setupPacmanPack("gcc", version)
} else if (hasDnf()) {
installationInfo = setupDnfPack("gcc", version)
setupDnfPack("gcc-c++", version)
@ -109,7 +110,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
} else {
info(`Install g++-multilib because gcc for ${arch} was requested`)
if (isArch()) {
setupPacmanPack("gcc-multilib", version)
await setupPacmanPack("gcc-multilib", version)
} else if (isUbuntu()) {
await setupAptPack([{ name: "gcc-multilib", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }])
}
@ -157,7 +158,7 @@ async function setupChocoMingw(version: string, arch: string): Promise<Installat
}
async function activateGcc(version: string, binDir: string) {
const promises: Promise<any>[] = []
const promises: Promise<void | ExecaReturnValue<string>>[] = []
// Setup gcc as the compiler
// TODO

View File

@ -11,6 +11,18 @@ describe("setup-Kcov", () => {
return
}
it("should build and setup kcov-41", async () => {
const directory = await setupTmpDir("kcov-v41")
const { binDir } = (await setupKcov("41", directory, "")) as InstallationInfo
// the prebuild binary only works on ubuntu 20.04
try {
await testBin("kcov", ["--version"], binDir)
} catch (err) {
info((err as Error).message)
}
await cleanupTmpDir("kcov-v41")
})
it("should setup Kcov v40 via downloading the binaries", async () => {
const directory = await setupTmpDir("kcov-v40")
const { binDir } = (await setupKcov("40-binary", directory, "")) as InstallationInfo

54
src/kcov/gcc13.patch Normal file
View File

@ -0,0 +1,54 @@
From b63754b53b3a7cf43e13ec56bd0be76cb6175437 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Thu, 15 Sep 2022 19:55:21 +0100
Subject: [PATCH] Fix build on gcc-13: add missing <stdint.h> include
[ 15%] Building CXX object src/CMakeFiles/kcov.dir/writers/cobertura-writer.cc.o
In file included from kcov/src/writers/cobertura-writer.cc:6:
kcov/src/include/reporter.hh:24:90: error: 'uint64_t' has not been declared
24 | LineExecutionCount(unsigned int hits, unsigned int possibleHits, uint64_t order) :
| ^~~~~~~~
---
src/include/collector.hh | 2 ++
src/include/reporter.hh | 1 +
src/include/source-file-cache.hh | 2 ++
3 files changed, 5 insertions(+)
diff --git a/src/include/collector.hh b/src/include/collector.hh
index 79e5d5f2..1369a416 100644
--- a/src/include/collector.hh
+++ b/src/include/collector.hh
@@ -2,6 +2,8 @@
#include <string>
+#include <stdint.h>
+
namespace kcov
{
class IFileParser;
diff --git a/src/include/reporter.hh b/src/include/reporter.hh
index bc058e69..98d8e56b 100644
--- a/src/include/reporter.hh
+++ b/src/include/reporter.hh
@@ -3,6 +3,7 @@
#include <string>
#include <stddef.h>
+#include <stdint.h>
namespace kcov
{
diff --git a/src/include/source-file-cache.hh b/src/include/source-file-cache.hh
index c0cb00ee..cfc73b81 100644
--- a/src/include/source-file-cache.hh
+++ b/src/include/source-file-cache.hh
@@ -3,6 +3,8 @@
#include <vector>
#include <string>
+#include <stdint.h>
+
namespace kcov
{
/**

View File

@ -44,8 +44,7 @@ async function buildKcov(file: string, dest: string) {
if (process.platform === "linux") {
if (isArch()) {
setupPacmanPack("libdwarf")
setupPacmanPack("libcurl-openssl")
await Promise.all([setupPacmanPack("libdwarf"), setupPacmanPack("libcurl-openssl")])
} else if (hasDnf()) {
setupDnfPack("libdwarf-devel")
setupDnfPack("libcurl-devel")
@ -53,6 +52,19 @@ async function buildKcov(file: string, dest: string) {
await setupAptPack([{ name: "libdw-dev" }, { name: "libcurl4-openssl-dev" }])
}
}
// apply gcc13.patch
try {
if (which.sync("patch", { nothrow: true }) !== null) {
const patch = join(__dirname, "gcc13.patch")
await execa("patch", ["-N", "-p1", "-i", patch], { cwd: out, stdio: "inherit" })
} else {
info("`patch` not found, skipping gcc13.patch, kcov may not build on gcc 13")
}
} catch {
// ignore
}
const buildDir = join(out, "build")
await execa(cmake, ["-S", out, "-B", buildDir, "-DCMAKE_BUILD_TYPE=Release", "-G", "Ninja"], {
cwd: out,
@ -97,7 +109,7 @@ export async function setupKcov(versionGiven: string, setupDir: string, arch: st
if (installMethod === "binary" && version_number >= 39) {
installationInfo = await setupBin("kcov", version, getDownloadKcovPackageInfo, setupDir, arch)
if (isArch()) {
setupPacmanPack("binutils")
await setupPacmanPack("binutils")
} else if (hasDnf()) {
setupDnfPack("binutils")
} else if (isUbuntu()) {

View File

@ -1,6 +1,5 @@
import { join, addExeExt } from "patha"
import { delimiter } from "path"
import semverMajor from "semver/functions/major"
import { InstallationInfo, setupBin } from "../utils/setup/setupBin"
import { semverCoerceIfInvalid } from "../utils/setup/version"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
@ -59,12 +58,12 @@ async function setupLLVMDeps(arch: string, version: string) {
}
}
// TODO: install libtinfo on other distros
// setupPacmanPack("ncurses")
// await setupPacmanPack("ncurses")
}
}
export async function activateLLVM(directory: string, versionGiven: string) {
const version = semverCoerceIfInvalid(versionGiven)
const _version = semverCoerceIfInvalid(versionGiven)
const lib = join(directory, "lib")

View File

@ -131,7 +131,7 @@ export async function main(args: string[]): Promise<number> {
if (isArch() && typeof opts.cppcheck === "string" && typeof opts.gcovr === "string") {
info("installing python-pygments to avoid conflicts with cppcheck and gcovr on Arch linux")
setupPacmanPack("python-pygments")
await setupPacmanPack("python-pygments")
}
// loop over the tools and run their setup function

View File

@ -63,8 +63,8 @@ export async function setupPythonViaSystem(
case "linux": {
let installInfo: InstallationInfo
if (isArch()) {
installInfo = setupPacmanPack("python", version)
setupPacmanPack("python-pip")
installInfo = await setupPacmanPack("python", version)
await setupPacmanPack("python-pip")
} else if (hasDnf()) {
installInfo = setupDnfPack("python3", version)
setupDnfPack("python3-pip")
@ -113,7 +113,7 @@ export async function setupPythonAndPip(): Promise<string> {
} else if (process.platform === "linux") {
// ensure that pip is installed on Linux (happens when python is found but pip not installed)
if (isArch()) {
setupPacmanPack("python-pip")
await setupPacmanPack("python-pip")
} else if (hasDnf()) {
setupDnfPack("python3-pip")
} else if (isUbuntu()) {

View File

@ -111,6 +111,7 @@ async function addPathSystem(path: string) {
}
}
/* eslint-disable require-atomic-updates */
let setupCppInProfile_called = false
/// handles adding conditions to source .cpprc file from .bashrc and .profile

View File

@ -1,7 +1,5 @@
/* eslint-disable require-atomic-updates */
import { InstallationInfo } from "./setupBin"
import { execRoot, execRootSync } from "admina"
import { info } from "@actions/core"
import { GITHUB_ACTIONS } from "ci-info"
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
import which from "which"
@ -10,7 +8,9 @@ import { promises as fsPromises } from "fs"
const { appendFile } = fsPromises
import { execa } from "execa"
import escapeRegex from "escape-string-regexp"
import { warning, info } from "ci-log"
/* eslint-disable require-atomic-updates */
let didUpdate: boolean = false
let didInit: boolean = false
@ -62,16 +62,24 @@ async function getAptArg(name: string, version: string | undefined) {
const { stdout } = await execa("apt-cache", [
"search",
"--names-only",
`^${escapeRegex(name)}\-${escapeRegex(version)}$`,
`^${escapeRegex(name)}-${escapeRegex(version)}$`,
])
if (stdout.trim() !== "") {
return `${name}-${version}`
} else {
return `${name}=${version}`
try {
// check if apt-get show can find the version
const { stdout: showStdout } = await execa("apt-cache", ["show", `${name}=${version}`])
if (showStdout.trim() === "") {
return `${name}=${version}`
}
} catch {
// ignore
}
warning(`Failed to install ${name} ${version} via apt, trying without version`)
}
} else {
return name
}
return name
}
function getApt() {
@ -99,7 +107,7 @@ async function initApt(apt: string) {
"ca-certificates",
"gnupg",
])
const promises: Promise<any>[] = [
const promises: Promise<string | void>[] = [
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg"),
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg"),
]

View File

@ -104,9 +104,7 @@ export async function setupBin(
info(`Installing extraction dependencies`)
if (process.platform === "linux") {
if (isArch()) {
setupPacmanPack("unzip")
setupPacmanPack("tar")
setupPacmanPack("xz")
await Promise.all([setupPacmanPack("unzip"), setupPacmanPack("tar"), setupPacmanPack("xz")])
} else if (hasDnf()) {
setupDnfPack("unzip")
setupDnfPack("tar")

View File

@ -1,13 +1,14 @@
/* eslint-disable require-atomic-updates */
import { InstallationInfo } from "./setupBin"
import { execRootSync } from "admina"
import { info } from "ci-log"
import { info, warning } from "ci-log"
import { execa } from "execa"
/* eslint-disable require-atomic-updates */
let didUpdate: boolean = false
let didInit: boolean = false
/** A function that installs a package using pacman */
export function setupPacmanPack(name: string, version?: string, aur?: string): InstallationInfo {
export async function setupPacmanPack(name: string, version?: string, aur?: string): Promise<InstallationInfo> {
info(`Installing ${name} ${version ?? ""} via pacman`)
const pacman = "pacman"
@ -18,21 +19,52 @@ export function setupPacmanPack(name: string, version?: string, aur?: string): I
didUpdate = true
}
// install base-devel
if (!didInit) {
// install base-devel
execRootSync(pacman, ["-S", "--noconfirm", "base-devel"])
didInit = true
}
const runInstall = (arg: string) => {
return execRootSync(aur ?? pacman, ["-S", "--noconfirm", arg])
}
if (version !== undefined && version !== "") {
try {
execRootSync(aur ?? pacman, ["-S", "--noconfirm", `${name}=${version}`])
} catch {
execRootSync(aur ?? pacman, ["-S", "--noconfirm", `${name}${version}`])
// check if version is available
const availableVersions = await availablePacmanVersions(pacman, name)
if (availableVersions.includes(version)) {
// try different version formats
try {
runInstall(`${name}=${version}`)
} catch {
runInstall(`${name}${version}`)
}
} else {
// try without version
info(`Failed to install ${name} ${version} via pacman, trying without version`)
runInstall(name)
}
} else {
execRootSync(aur ?? pacman, ["-S", "--noconfirm", name])
// version not specified, install latest
runInstall(name)
}
return { binDir: "/usr/bin/" }
}
const pacmanSiVersionRegex = /Version\s*:\s*(.*)/g
/** Query pacman for available versions */
async function availablePacmanVersions(pacman: string, name: string) {
const availableVersions = []
try {
const { stdout } = await execa(pacman, ["-Si", name])
for (const match of stdout.matchAll(pacmanSiVersionRegex)) {
availableVersions.push(match[1])
}
} catch (err) {
warning(`Failed to get available versions for ${name}: ${err}`)
}
return availableVersions
}

View File

@ -1,4 +1,3 @@
/* eslint-disable require-atomic-updates */
import { info } from "@actions/core"
import { execaSync } from "execa"
import { pathExists } from "path-exists"
@ -8,6 +7,7 @@ import { addPythonBaseExecPrefix, setupPythonAndPip } from "../../python/python"
import { addPath } from "../env/addEnv"
import { InstallationInfo } from "./setupBin"
/* eslint-disable require-atomic-updates */
let python: string | undefined
let binDirs: string[] | undefined
@ -37,9 +37,8 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
async function findBinDir(dirs: string[], name: string) {
const exists = await Promise.all(dirs.map((dir) => pathExists(join(dir, addExeExt(name)))))
const dirIndex = exists.findIndex((exist) => exist)
const foundDir = dirs[dirIndex]
if (foundDir !== undefined) {
if (dirIndex !== -1) {
const foundDir = dirs[dirIndex]
return foundDir
}

View File

@ -12,7 +12,13 @@ import { info } from "ci-log"
export function getSpecificVersions(versions: Set<string>, semversion: string): string[] {
return Array.from(versions)
.filter((v) => /^\d+\.\d+\.\d+$/.test(v) && v.startsWith(semversion))
.sort()
.sort((a, b) => {
try {
return semverCompare(a, b)
} catch (err) {
return a.localeCompare(b)
}
})
.reverse()
}
@ -58,11 +64,12 @@ export async function getSpecificVersionAndUrl(
const offlineUrls: string[] = []
// TODO use Promise.any
for (const specificVersion of getSpecificVersions(versions, version)) {
// eslint-disable-next-line no-await-in-loop
const url = await getUrl(platform, specificVersion)
// eslint-disable-next-line no-await-in-loop
if (url !== null) {
// eslint-disable-next-line no-await-in-loop
if (await isUrlOnline(url)) {
return [specificVersion, url]
} else {

View File

@ -21,12 +21,14 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
if (process.platform === "linux") {
// vcpkg download and extraction dependencies
if (isArch()) {
setupPacmanPack("curl")
setupPacmanPack("zip")
setupPacmanPack("unzip")
setupPacmanPack("tar")
setupPacmanPack("git")
setupPacmanPack("pkg-config")
await Promise.all([
setupPacmanPack("curl"),
setupPacmanPack("zip"),
setupPacmanPack("unzip"),
setupPacmanPack("tar"),
setupPacmanPack("git"),
setupPacmanPack("pkg-config"),
])
} else if (hasDnf()) {
setupDnfPack("curl")
setupDnfPack("zip")

View File

@ -24,7 +24,7 @@ export const DefaultVersions: Record<string, string> = {
gcovr: "5.2", // https://pypi.org/project/gcovr/
conan: "1.60.0", // https://github.com/conan-io/conan/releases
meson: "1.0.2", // https://github.com/mesonbuild/meson/releases
kcov: "40", // https://github.com/SimonKagstrom/kcov/releases
kcov: "41", // https://github.com/SimonKagstrom/kcov/releases
task: "3.25.0", // https://github.com/go-task/task/releases
doxygen: isArch() ? "1.9.6-1" : "1.9.7", // https://www.doxygen.nl/download.html // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen // https://formulae.brew.sh/formula/doxygen // https://archlinux.org/packages/extra/x86_64/doxygen/
gcc: isArch() ? "13.1.1-1" : "13", // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
@ -35,7 +35,7 @@ export const DefaultVersions: Record<string, string> = {
// - the older ones use ""
export const DefaultLinuxVersion: Record<string, Record<number, string>> = {
gcc: {
22: "12",
22: "13",
20: "11",
18: "11",
16: "11",