mirror of https://github.com/aminya/setup-cpp
Merge pull request #293 from aminya/aliases [skip ci]
This commit is contained in:
commit
d7f5466d92
|
@ -3,6 +3,7 @@
|
||||||
"orta.vscode-jest",
|
"orta.vscode-jest",
|
||||||
"esbenp.prettier-vscode",
|
"esbenp.prettier-vscode",
|
||||||
"dbaeumer.vscode-eslint",
|
"dbaeumer.vscode-eslint",
|
||||||
"biomejs.biome"
|
"biomejs.biome",
|
||||||
|
"p42ai.refactor"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
20
README.md
20
README.md
|
@ -14,15 +14,15 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
|
||||||
|
|
||||||
`setup-cpp` is **modular** and you can choose to install any of these tools:
|
`setup-cpp` is **modular** and you can choose to install any of these tools:
|
||||||
|
|
||||||
| category | tools |
|
| category | tools |
|
||||||
| --------------------- | ------------------------------------------------------------ |
|
| --------------------- | --------------------------------------------------------------------------- |
|
||||||
| compiler and analyzer | llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat |
|
| compiler and analyzer | llvm, gcc, msvc, apple-clang, vcvarsall, cppcheck, clang-tidy, clang-format |
|
||||||
| build system | cmake, ninja, meson, make, task, bazel |
|
| build system | cmake, ninja, meson, make, task, bazel |
|
||||||
| package manager | vcpkg, conan, choco, brew, nala |
|
| package manager | vcpkg, conan, choco, brew, nala |
|
||||||
| cache | ccache, sccache |
|
| cache | ccache, sccache |
|
||||||
| documentation | doxygen, graphviz |
|
| documentation | doxygen, graphviz |
|
||||||
| coverage | gcovr, opencppcoverage, kcov |
|
| coverage | gcovr, opencppcoverage, kcov |
|
||||||
| other | python, powershell, sevenzip |
|
| other | python, powershell, sevenzip |
|
||||||
|
|
||||||
`setup-cpp` automatically handles the dependencies of the selected tool (e.g., `python` is required for `conan`).
|
`setup-cpp` automatically handles the dependencies of the selected tool (e.g., `python` is required for `conan`).
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ jobs:
|
||||||
ninja: true
|
ninja: true
|
||||||
vcpkg: true
|
vcpkg: true
|
||||||
cppcheck: true
|
cppcheck: true
|
||||||
clangtidy: true # instead of `true`, which chooses the default version, you can pass a specific version.
|
clang-tidy: true # instead of `true`, which chooses the default version, you can pass a specific version.
|
||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
33
action.yml
33
action.yml
|
@ -19,21 +19,51 @@ inputs:
|
||||||
llvm:
|
llvm:
|
||||||
description: "Wether to install llvm (true/false) or the specific version to install"
|
description: "Wether to install llvm (true/false) or the specific version to install"
|
||||||
required: false
|
required: false
|
||||||
|
clang:
|
||||||
|
description: "Wether to install clang (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
gcc:
|
gcc:
|
||||||
description: "Wether to install gcc (true/false) or the specific version to install"
|
description: "Wether to install gcc (true/false) or the specific version to install"
|
||||||
required: false
|
required: false
|
||||||
msvc:
|
msvc:
|
||||||
description: "Wether to install msvc (true/false) or the specific version to install"
|
description: "Wether to install msvc (true/false) or the specific version to install"
|
||||||
required: false
|
required: false
|
||||||
|
cl:
|
||||||
|
description: "Wether to install cl (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
|
msbuild:
|
||||||
|
description: "Wether to install msbuild (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
|
visualstudio:
|
||||||
|
description: "Wether to install visualstudio (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
|
apple-clang:
|
||||||
|
description: "Wether to install apple-clang (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
|
apple-llvm:
|
||||||
|
description: "Wether to install apple-llvm (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
|
appleclang:
|
||||||
|
description: "Wether to install apple-clang (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
|
applellvm:
|
||||||
|
description: "Wether to install apple-llvm (true/false) or the specific version to install"
|
||||||
|
required: false
|
||||||
vcvarsall:
|
vcvarsall:
|
||||||
description: "If should run vcvarsall?"
|
description: "If should run vcvarsall?"
|
||||||
required: false
|
required: false
|
||||||
cppcheck:
|
cppcheck:
|
||||||
description: "Wether to install cppcheck (true/false) or the specific version to install."
|
description: "Wether to install cppcheck (true/false) or the specific version to install."
|
||||||
required: false
|
required: false
|
||||||
|
clang-tidy:
|
||||||
|
description: "Wether to install clang-tidy (true/false) or the specific version to install."
|
||||||
|
required: false
|
||||||
clangtidy:
|
clangtidy:
|
||||||
description: "The clangWether to install tidy (true/false) or the specific version to install."
|
description: "The clangWether to install tidy (true/false) or the specific version to install."
|
||||||
required: false
|
required: false
|
||||||
|
clang-format:
|
||||||
|
description: "The clangWether to install format (true/false) or the specific version to install."
|
||||||
|
required: false
|
||||||
clangformat:
|
clangformat:
|
||||||
description: "The clangWether to install format (true/false) or the specific version to install."
|
description: "The clangWether to install format (true/false) or the specific version to install."
|
||||||
required: false
|
required: false
|
||||||
|
@ -94,6 +124,9 @@ inputs:
|
||||||
powershell:
|
powershell:
|
||||||
description: "Wether to install powershell (true/false) or the specific version to install."
|
description: "Wether to install powershell (true/false) or the specific version to install."
|
||||||
required: false
|
required: false
|
||||||
|
pwsh:
|
||||||
|
description: "Wether to install pwsh (true/false) or the specific version to install."
|
||||||
|
required: false
|
||||||
python:
|
python:
|
||||||
description: "Wether to install python (true/false) or the specific version to install."
|
description: "Wether to install python (true/false) or the specific version to install."
|
||||||
required: false
|
required: false
|
||||||
|
|
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,6 @@
|
||||||
import { parseArgs } from "../cli-options.js"
|
import { parseArgs } from "../cli-options.js"
|
||||||
import { getCompilerInfo } from "../compilers.js"
|
import { getCompilerInfo } from "../compilers.js"
|
||||||
import type { Inputs } from "../tool.js"
|
import { type Inputs, llvmTools } from "../tool.js"
|
||||||
import { DefaultUbuntuVersion, DefaultVersions } from "../versions/default_versions.js"
|
import { DefaultUbuntuVersion, DefaultVersions } from "../versions/default_versions.js"
|
||||||
import { getVersion, syncVersions } from "../versions/versions.js"
|
import { getVersion, syncVersions } from "../versions/versions.js"
|
||||||
|
|
||||||
|
@ -27,24 +27,23 @@ describe("getCompilerInfo", () => {
|
||||||
|
|
||||||
describe("syncVersion", () => {
|
describe("syncVersion", () => {
|
||||||
it("Syncs llvm tools versions", () => {
|
it("Syncs llvm tools versions", () => {
|
||||||
const llvmTools = ["llvm", "clangtidy", "clangformat"] as Inputs[]
|
expect(syncVersions(parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"]), llvmTools as Inputs[])).toBe(true)
|
||||||
expect(syncVersions(parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"]), llvmTools)).toBe(true)
|
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "true"]), llvmTools as Inputs[])).toBe(true)
|
||||||
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "true"]), llvmTools)).toBe(true)
|
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "12.0.0"]), llvmTools as Inputs[])).toBe(false)
|
||||||
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "12.0.0"]), llvmTools)).toBe(false)
|
|
||||||
|
|
||||||
const opts1 = parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"])
|
const opts1 = parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"])
|
||||||
expect(syncVersions(opts1, llvmTools)).toBe(true)
|
expect(syncVersions(opts1, llvmTools as Inputs[])).toBe(true)
|
||||||
expect(opts1.llvm).toBe(opts1.clangtidy)
|
expect(opts1.llvm).toBe(opts1.clangtidy)
|
||||||
expect(opts1.clangformat).toBe(undefined)
|
expect(opts1.clangformat).toBe(undefined)
|
||||||
|
|
||||||
const opts2 = parseArgs(["--clangtidy", "15.0.0", "--clangformat", "true"])
|
const opts2 = parseArgs(["--clangtidy", "15.0.0", "--clangformat", "true"])
|
||||||
expect(syncVersions(opts2, llvmTools)).toBe(true)
|
expect(syncVersions(opts2, llvmTools as Inputs[])).toBe(true)
|
||||||
expect(opts2.llvm).toBe(undefined)
|
expect(opts2.llvm).toBe(undefined)
|
||||||
expect(opts2.clangtidy).toBe("15.0.0")
|
expect(opts2.clangtidy).toBe("15.0.0")
|
||||||
expect(opts2.clangformat).toBe("15.0.0")
|
expect(opts2.clangformat).toBe("15.0.0")
|
||||||
|
|
||||||
const opts3 = parseArgs(["--llvm", "true", "--clangformat", "true"])
|
const opts3 = parseArgs(["--llvm", "true", "--clangformat", "true"])
|
||||||
expect(syncVersions(opts3, llvmTools)).toBe(true)
|
expect(syncVersions(opts3, llvmTools as Inputs[])).toBe(true)
|
||||||
expect(opts3.llvm).toBe("true")
|
expect(opts3.llvm).toBe("true")
|
||||||
expect(opts3.clangtidy).toBe(undefined)
|
expect(opts3.clangtidy).toBe(undefined)
|
||||||
expect(opts3.clangformat).toBe("true")
|
expect(opts3.clangformat).toBe("true")
|
||||||
|
|
|
@ -32,7 +32,9 @@ All the available tools:
|
||||||
|
|
||||||
console.table(
|
console.table(
|
||||||
{
|
{
|
||||||
"compiler and analyzer": { tools: "--llvm, --gcc, --msvc, --vcvarsall, --cppcheck, --clangtidy, --clangformat" },
|
"compiler and analyzer": {
|
||||||
|
tools: "--llvm, --gcc, --msvc, --apple-clang, --vcvarsall, --cppcheck, --clang-tidy, --clang-format",
|
||||||
|
},
|
||||||
"build system": { tools: "--cmake, --ninja, --meson, --make, --task, --bazel" },
|
"build system": { tools: "--cmake, --ninja, --meson, --make, --task, --bazel" },
|
||||||
"package manager": { tools: "--vcpkg, --conan, --choco, --brew, --nala" },
|
"package manager": { tools: "--vcpkg, --conan, --choco, --brew, --nala" },
|
||||||
cache: { tools: "--ccache, --sccache" },
|
cache: { tools: "--ccache, --sccache" },
|
||||||
|
|
130
src/compilers.ts
130
src/compilers.ts
|
@ -1,29 +1,41 @@
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { endGroup, notice, startGroup } from "@actions/core"
|
import { endGroup, startGroup } from "@actions/core"
|
||||||
import { error, info } from "ci-log"
|
import { error, info } from "ci-log"
|
||||||
import { addEnv } from "envosman"
|
|
||||||
import semverValid from "semver/functions/valid"
|
import semverValid from "semver/functions/valid"
|
||||||
import { getSuccessMessage, rcOptions } from "./cli-options.js"
|
import { getSuccessMessage } from "./cli-options.js"
|
||||||
import { setupGcc, setupMingw } from "./gcc/gcc.js"
|
import { setupGcc, setupMingw } from "./gcc/gcc.js"
|
||||||
import { activateGcovGCC, activateGcovLLVM } from "./gcovr/gcovr.js"
|
import { activateGcovGCC, activateGcovLLVM } from "./gcovr/gcovr.js"
|
||||||
|
import { setupAppleClang } from "./llvm/apple-clang.js"
|
||||||
import { setupLLVM } from "./llvm/llvm.js"
|
import { setupLLVM } from "./llvm/llvm.js"
|
||||||
import { setupMSVC } from "./msvc/msvc.js"
|
import { setupMSVC } from "./msvc/msvc.js"
|
||||||
|
import { appleClangSetups, gccSetups, llvmSetups, mingwSetups, msvcSetups } from "./tool.js"
|
||||||
|
import type { InstallationInfo } from "./utils/setup/setupBin.js"
|
||||||
import { getVersion } from "./versions/versions.js"
|
import { getVersion } from "./versions/versions.js"
|
||||||
|
|
||||||
/** Detecting the compiler version. Divide the given string by `-` and use the second element as the version */
|
/**
|
||||||
|
* Detecting the compiler version. Divide the given string by `-` and use the second element as the version
|
||||||
|
*
|
||||||
|
* @param compilerAndVersion - The compiler and version string
|
||||||
|
* @returns The compiler and version
|
||||||
|
*
|
||||||
|
* @nothrow It doesn't throw any error, but it logs the error if it fails to parse the compiler info
|
||||||
|
*/
|
||||||
export function getCompilerInfo(compilerAndVersion: string) {
|
export function getCompilerInfo(compilerAndVersion: string) {
|
||||||
const compilerAndMaybeVersion = compilerAndVersion.split("-")
|
try {
|
||||||
const compiler = compilerAndMaybeVersion[0]
|
const compilerAndMaybeVersion = compilerAndVersion.split("-")
|
||||||
if (1 in compilerAndMaybeVersion) {
|
const compiler = compilerAndMaybeVersion[0]
|
||||||
const maybeVersion = compilerAndMaybeVersion[1]
|
if (1 in compilerAndMaybeVersion) {
|
||||||
if (semverValid(maybeVersion) !== null) {
|
const maybeVersion = compilerAndMaybeVersion[1]
|
||||||
return { compiler, version: maybeVersion }
|
if (semverValid(maybeVersion) === null) {
|
||||||
} else {
|
info(`Invalid semver version ${maybeVersion} used for the compiler.`)
|
||||||
info(`Invalid semver version ${maybeVersion} used for the compiler.`)
|
}
|
||||||
return { compiler, version: maybeVersion }
|
return { compiler, version: maybeVersion }
|
||||||
}
|
}
|
||||||
|
return { compiler, version: undefined }
|
||||||
|
} catch (err) {
|
||||||
|
error(`Failed to parse the compiler info ${compilerAndVersion}: ${err}`)
|
||||||
|
return { compiler: compilerAndVersion, version: undefined }
|
||||||
}
|
}
|
||||||
return { compiler, version: undefined }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Installing the specified compiler */
|
/** Installing the specified compiler */
|
||||||
|
@ -35,73 +47,47 @@ export async function installCompiler(
|
||||||
successMessages: string[],
|
successMessages: string[],
|
||||||
errorMessages: string[],
|
errorMessages: string[],
|
||||||
) {
|
) {
|
||||||
try {
|
const { compiler, version } = getCompilerInfo(compilerAndVersion)
|
||||||
const { compiler, version } = getCompilerInfo(compilerAndVersion)
|
|
||||||
|
|
||||||
|
let installationInfo: InstallationInfo | undefined | void | null // null means the compiler is not supported
|
||||||
|
try {
|
||||||
// install the compiler. We allow some aliases for the compiler name
|
// install the compiler. We allow some aliases for the compiler name
|
||||||
startGroup(`Installing ${compiler} ${version ?? ""}`)
|
startGroup(`Installing ${compiler} ${version ?? ""}`)
|
||||||
switch (compiler) {
|
if (compiler in llvmSetups) {
|
||||||
case "llvm":
|
installationInfo = await setupLLVM(
|
||||||
case "clang":
|
getVersion("llvm", version, osVersion),
|
||||||
case "clang++": {
|
join(setupCppDir, "llvm"),
|
||||||
const installationInfo = await setupLLVM(
|
arch,
|
||||||
getVersion("llvm", version, osVersion),
|
)
|
||||||
join(setupCppDir, "llvm"),
|
await activateGcovLLVM()
|
||||||
arch,
|
} else if (compiler in gccSetups) {
|
||||||
)
|
const gccVersion = getVersion("gcc", version, osVersion)
|
||||||
|
installationInfo = await setupGcc(gccVersion, join(setupCppDir, "gcc"), arch)
|
||||||
await activateGcovLLVM()
|
await activateGcovGCC(gccVersion)
|
||||||
|
} else if (compiler in mingwSetups) {
|
||||||
successMessages.push(getSuccessMessage("llvm", installationInfo))
|
const gccVersion = getVersion("mingw", version, osVersion)
|
||||||
break
|
installationInfo = await setupMingw(gccVersion, join(setupCppDir, "gcc"), arch)
|
||||||
}
|
await activateGcovGCC(gccVersion)
|
||||||
case "gcc":
|
} else if (compiler in msvcSetups) {
|
||||||
case "mingw":
|
installationInfo = await setupMSVC(
|
||||||
case "cygwin":
|
getVersion("msvc", version, osVersion),
|
||||||
case "msys": {
|
join(setupCppDir, "msvc"),
|
||||||
const gccVersion = compiler === "mingw"
|
arch,
|
||||||
? getVersion("mingw", version, osVersion)
|
)
|
||||||
: getVersion("gcc", version, osVersion)
|
} else if (compiler in appleClangSetups) {
|
||||||
const installationInfo = compiler === "mingw"
|
await setupAppleClang()
|
||||||
? await setupMingw(gccVersion, join(setupCppDir, "gcc"), arch)
|
} else {
|
||||||
: await setupGcc(gccVersion, join(setupCppDir, "gcc"), arch)
|
installationInfo = null
|
||||||
|
errorMessages.push(`Unsupported compiler ${compiler}`)
|
||||||
await activateGcovGCC(gccVersion)
|
|
||||||
|
|
||||||
successMessages.push(getSuccessMessage("gcc", installationInfo))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case "cl":
|
|
||||||
case "msvc":
|
|
||||||
case "msbuild":
|
|
||||||
case "vs":
|
|
||||||
case "visualstudio":
|
|
||||||
case "visualcpp":
|
|
||||||
case "visualc++": {
|
|
||||||
const installationInfo = await setupMSVC(
|
|
||||||
getVersion("msvc", version, osVersion),
|
|
||||||
join(setupCppDir, "msvc"),
|
|
||||||
arch,
|
|
||||||
)
|
|
||||||
|
|
||||||
successMessages.push(getSuccessMessage("msvc", installationInfo))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case "appleclang":
|
|
||||||
case "applellvm": {
|
|
||||||
notice("Assuming apple-clang is already installed")
|
|
||||||
await Promise.all([addEnv("CC", "clang", rcOptions), addEnv("CXX", "clang++", rcOptions)])
|
|
||||||
successMessages.push(getSuccessMessage("apple-clang", undefined))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
errorMessages.push(`Unsupported compiler ${compiler}`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error(err as string | Error)
|
error(err as string | Error)
|
||||||
errorMessages.push(`Failed to install the ${compilerAndVersion}`)
|
errorMessages.push(`Failed to install the ${compilerAndVersion}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (installationInfo !== null) {
|
||||||
|
successMessages.push(getSuccessMessage(compiler, installationInfo))
|
||||||
|
}
|
||||||
|
|
||||||
endGroup()
|
endGroup()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { error } from "ci-log"
|
||||||
import pTimeout from "p-timeout"
|
import pTimeout from "p-timeout"
|
||||||
import { setupBrew } from "setup-brew"
|
import { setupBrew } from "setup-brew"
|
||||||
import { getSuccessMessage, rcOptions } from "./cli-options.js"
|
import { getSuccessMessage, rcOptions } from "./cli-options.js"
|
||||||
import { type ToolName, setups } from "./tool.js"
|
import { type ToolName, llvmTools, setups } from "./tool.js"
|
||||||
import type { InstallationInfo } from "./utils/setup/setupBin.js"
|
import type { InstallationInfo } from "./utils/setup/setupBin.js"
|
||||||
import { setupVCVarsall } from "./vcvarsall/vcvarsall.js"
|
import { setupVCVarsall } from "./vcvarsall/vcvarsall.js"
|
||||||
import { getVersion } from "./versions/versions.js"
|
import { getVersion } from "./versions/versions.js"
|
||||||
|
@ -46,7 +46,7 @@ async function installToolImpl(
|
||||||
setupCppDir: string,
|
setupCppDir: string,
|
||||||
successMessages: string[],
|
successMessages: string[],
|
||||||
) {
|
) {
|
||||||
const hasLLVM = ["llvm", "clangformat", "clangtidy"].includes(tool)
|
const hasLLVM = llvmTools.includes(tool)
|
||||||
|
|
||||||
let installationInfo: InstallationInfo | undefined | void
|
let installationInfo: InstallationInfo | undefined | void
|
||||||
if (tool === "vcvarsall") {
|
if (tool === "vcvarsall") {
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { error } from "console"
|
||||||
|
import { notice } from "ci-log"
|
||||||
|
import { addEnv } from "envosman"
|
||||||
|
import which from "which"
|
||||||
|
import { rcOptions } from "../cli-options.js"
|
||||||
|
|
||||||
|
export async function setupAppleClang() {
|
||||||
|
if (process.platform !== "darwin") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await which("clang", { nothrow: true }) !== null && await which("clang++", { nothrow: true }) !== null) {
|
||||||
|
notice("Assuming clang is an Apple Clang compiler")
|
||||||
|
await Promise.all([addEnv("CC", "clang", rcOptions), addEnv("CXX", "clang++", rcOptions)])
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO install Apple Clang automatically
|
||||||
|
error("Apple Clang automatic installation is not supported yet")
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ import { checkUpdates } from "./check-updates.js"
|
||||||
import { parseArgs, printHelp, rcOptions } from "./cli-options.js"
|
import { parseArgs, printHelp, rcOptions } from "./cli-options.js"
|
||||||
import { installCompiler } from "./compilers.js"
|
import { installCompiler } from "./compilers.js"
|
||||||
import { installTool } from "./installTool.js"
|
import { installTool } from "./installTool.js"
|
||||||
import { tools } from "./tool.js"
|
import { type Inputs, llvmTools, tools } from "./tool.js"
|
||||||
import { isArch } from "./utils/env/isArch.js"
|
import { isArch } from "./utils/env/isArch.js"
|
||||||
import { ubuntuVersion } from "./utils/env/ubuntu_version.js"
|
import { ubuntuVersion } from "./utils/env/ubuntu_version.js"
|
||||||
import { setupPacmanPack } from "./utils/setup/setupPacmanPack.js"
|
import { setupPacmanPack } from "./utils/setup/setupPacmanPack.js"
|
||||||
|
@ -56,8 +56,8 @@ async function main(args: string[]): Promise<number> {
|
||||||
const osVersion = await ubuntuVersion()
|
const osVersion = await ubuntuVersion()
|
||||||
|
|
||||||
// sync the version for the llvm tools
|
// sync the version for the llvm tools
|
||||||
if (!syncVersions(opts, ["llvm", "clangtidy", "clangformat"])) {
|
if (!syncVersions(opts, llvmTools as Inputs[])) {
|
||||||
error("The same version must be used for llvm, clangformat and clangtidy")
|
error("The same version must be used for llvm, clang-format and clang-tidy")
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
src/tool.ts
37
src/tool.ts
|
@ -6,10 +6,11 @@ import { setupCmake } from "./cmake/cmake.js"
|
||||||
import { setupConan } from "./conan/conan.js"
|
import { setupConan } from "./conan/conan.js"
|
||||||
import { setupCppcheck } from "./cppcheck/cppcheck.js"
|
import { setupCppcheck } from "./cppcheck/cppcheck.js"
|
||||||
import { setupDoxygen } from "./doxygen/doxygen.js"
|
import { setupDoxygen } from "./doxygen/doxygen.js"
|
||||||
import { setupGcc } from "./gcc/gcc.js"
|
import { setupGcc, setupMingw } from "./gcc/gcc.js"
|
||||||
import { setupGcovr } from "./gcovr/gcovr.js"
|
import { setupGcovr } from "./gcovr/gcovr.js"
|
||||||
import { setupGraphviz } from "./graphviz/graphviz.js"
|
import { setupGraphviz } from "./graphviz/graphviz.js"
|
||||||
import { setupKcov } from "./kcov/kcov.js"
|
import { setupKcov } from "./kcov/kcov.js"
|
||||||
|
import { setupAppleClang } from "./llvm/apple-clang.js"
|
||||||
import { setupClangFormat, setupClangTools, setupLLVM } from "./llvm/llvm.js"
|
import { setupClangFormat, setupClangTools, setupLLVM } from "./llvm/llvm.js"
|
||||||
import { setupMake } from "./make/make.js"
|
import { setupMake } from "./make/make.js"
|
||||||
import { setupMeson } from "./meson/meson.js"
|
import { setupMeson } from "./meson/meson.js"
|
||||||
|
@ -25,8 +26,31 @@ import { setupTask } from "./task/task.js"
|
||||||
import { setupVcpkg } from "./vcpkg/vcpkg.js"
|
import { setupVcpkg } from "./vcpkg/vcpkg.js"
|
||||||
import { setupVCVarsall } from "./vcvarsall/vcvarsall.js"
|
import { setupVCVarsall } from "./vcvarsall/vcvarsall.js"
|
||||||
|
|
||||||
|
export const llvmSetups = { llvm: setupLLVM, clang: setupLLVM, "clang++": setupLLVM } as const
|
||||||
|
export const gccSetups = { gcc: setupGcc, "g++": setupGcc } as const
|
||||||
|
export const mingwSetups = { mingw: setupMingw } as const
|
||||||
|
export const msvcSetups = {
|
||||||
|
msvc: setupMSVC,
|
||||||
|
cl: setupMSVC,
|
||||||
|
msbuild: setupMSVC,
|
||||||
|
visualstudio: setupMSVC,
|
||||||
|
} as const
|
||||||
|
export const appleClangSetups = {
|
||||||
|
appleclang: setupAppleClang,
|
||||||
|
applellvm: setupAppleClang,
|
||||||
|
"apple-clang": setupAppleClang,
|
||||||
|
"apple-llvm": setupAppleClang,
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export const llvmTools = ["llvm", "clang", "clang++", "clang-tidy", "clang-format", "clangtidy", "clangformat"]
|
||||||
|
|
||||||
/** The setup functions */
|
/** The setup functions */
|
||||||
export const setups = {
|
export const setups = {
|
||||||
|
...llvmSetups,
|
||||||
|
...gccSetups,
|
||||||
|
...mingwSetups,
|
||||||
|
...msvcSetups,
|
||||||
|
...appleClangSetups,
|
||||||
nala: setupNala,
|
nala: setupNala,
|
||||||
cmake: setupCmake,
|
cmake: setupCmake,
|
||||||
ninja: setupNinja,
|
ninja: setupNinja,
|
||||||
|
@ -37,25 +61,28 @@ export const setups = {
|
||||||
meson: setupMeson,
|
meson: setupMeson,
|
||||||
gcovr: setupGcovr,
|
gcovr: setupGcovr,
|
||||||
opencppcoverage: setupOpencppcoverage,
|
opencppcoverage: setupOpencppcoverage,
|
||||||
llvm: setupLLVM,
|
OpenCppCoverage: setupOpencppcoverage,
|
||||||
gcc: setupGcc,
|
|
||||||
choco: setupChocolatey,
|
choco: setupChocolatey,
|
||||||
brew: setupBrew,
|
brew: setupBrew,
|
||||||
powershell: setupPowershell,
|
powershell: setupPowershell,
|
||||||
|
pwsh: setupPowershell,
|
||||||
ccache: setupCcache,
|
ccache: setupCcache,
|
||||||
sccache: setupSccache,
|
sccache: setupSccache,
|
||||||
doxygen: setupDoxygen,
|
doxygen: setupDoxygen,
|
||||||
graphviz: setupGraphviz,
|
graphviz: setupGraphviz,
|
||||||
cppcheck: setupCppcheck,
|
cppcheck: setupCppcheck,
|
||||||
|
"clang-tidy": setupClangTools,
|
||||||
clangtidy: setupClangTools,
|
clangtidy: setupClangTools,
|
||||||
|
"clang-format": setupClangFormat,
|
||||||
clangformat: setupClangFormat,
|
clangformat: setupClangFormat,
|
||||||
msvc: setupMSVC,
|
|
||||||
vcvarsall: setupVCVarsall,
|
vcvarsall: setupVCVarsall,
|
||||||
kcov: setupKcov,
|
kcov: setupKcov,
|
||||||
make: setupMake,
|
make: setupMake,
|
||||||
task: setupTask,
|
task: setupTask,
|
||||||
sevenzip: setupSevenZip,
|
sevenzip: setupSevenZip,
|
||||||
}
|
"7zip": setupSevenZip,
|
||||||
|
"7z": setupSevenZip,
|
||||||
|
} as const
|
||||||
|
|
||||||
export type ToolName = keyof typeof setups
|
export type ToolName = keyof typeof setups
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,11 @@ const defaultLLVM = process.platform === "darwin" && process.arch === "x64"
|
||||||
export const DefaultVersions: Record<string, string | undefined> = {
|
export const DefaultVersions: Record<string, string | undefined> = {
|
||||||
// https://github.com/llvm/llvm-project/releases
|
// https://github.com/llvm/llvm-project/releases
|
||||||
llvm: defaultLLVM,
|
llvm: defaultLLVM,
|
||||||
|
clang: defaultLLVM,
|
||||||
|
"clang++": defaultLLVM,
|
||||||
|
"clang-tidy": defaultLLVM,
|
||||||
clangtidy: defaultLLVM,
|
clangtidy: defaultLLVM,
|
||||||
|
"clang-format": defaultLLVM,
|
||||||
clangformat: defaultLLVM,
|
clangformat: defaultLLVM,
|
||||||
ninja: "1.12.1", // https://github.com/ninja-build/ninja/releases
|
ninja: "1.12.1", // https://github.com/ninja-build/ninja/releases
|
||||||
cmake: "3.30.2", // https://github.com/Kitware/CMake/releases
|
cmake: "3.30.2", // https://github.com/Kitware/CMake/releases
|
||||||
|
|
Loading…
Reference in New Issue