mirror of https://github.com/aminya/setup-cpp
feat: support gcc/mingw
This commit is contained in:
parent
cf3dbb2b16
commit
39993729df
10
README.md
10
README.md
|
@ -13,15 +13,16 @@ The package will be usable from any environment (locally, GitHub Actions, etc).
|
||||||
|
|
||||||
# Features (WIP)
|
# Features (WIP)
|
||||||
|
|
||||||
|
- setup llvm
|
||||||
|
- setup gcc/mingw
|
||||||
- setup cmake
|
- setup cmake
|
||||||
- setup ninja
|
- setup ninja
|
||||||
- setup llvm
|
|
||||||
- setup conan
|
|
||||||
- setup meson
|
- setup meson
|
||||||
- setup gcovr
|
- setup conan
|
||||||
|
- setup ccache
|
||||||
- setup cppcheck
|
- setup cppcheck
|
||||||
- setup doxygen
|
- setup doxygen
|
||||||
- setup ccache
|
- setup gcovr
|
||||||
- setup OpenCppCoverage
|
- setup OpenCppCoverage
|
||||||
- setup python
|
- setup python
|
||||||
- setup choco
|
- setup choco
|
||||||
|
@ -33,5 +34,4 @@ The package will be usable from any environment (locally, GitHub Actions, etc).
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
|
|
||||||
- [ ] setup gcc/mingw
|
|
||||||
- [ ] setup vcpkg
|
- [ ] setup vcpkg
|
||||||
|
|
|
@ -12,6 +12,9 @@ inputs:
|
||||||
llvm:
|
llvm:
|
||||||
description: "The llvm version to install"
|
description: "The llvm version to install"
|
||||||
required: false
|
required: false
|
||||||
|
gcc:
|
||||||
|
description: "The gcc version to install"
|
||||||
|
required: false
|
||||||
msvc:
|
msvc:
|
||||||
description: "The msvc version to install"
|
description: "The msvc version to install"
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { spawnSync as spawn } from "child_process"
|
||||||
|
import { setupGcc } from "../gcc"
|
||||||
|
|
||||||
|
jest.setTimeout(200000)
|
||||||
|
describe("setup-gcc", () => {
|
||||||
|
it("should setup gcc", async () => {
|
||||||
|
await setupGcc("", "", "")
|
||||||
|
|
||||||
|
const { status } = spawn("gcc", {
|
||||||
|
encoding: "utf8",
|
||||||
|
})
|
||||||
|
expect(status).toBe(0)
|
||||||
|
})
|
||||||
|
})
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
|
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||||
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export function setupGcc(version: string, _setupCppDir: string, arch: string) {
|
||||||
|
switch (process.platform) {
|
||||||
|
case "win32": {
|
||||||
|
if (arch === "arm" || arch === "arm64") {
|
||||||
|
return setupChocoPack("gcc-arm-embedded", version)
|
||||||
|
}
|
||||||
|
return setupChocoPack("mingw", version)
|
||||||
|
}
|
||||||
|
case "darwin": {
|
||||||
|
return setupBrewPack("gcc", version)
|
||||||
|
}
|
||||||
|
case "linux": {
|
||||||
|
if (arch === "x64") {
|
||||||
|
return setupAptPack("g++", version, "ppa:ubuntu-toolchain-r/test")
|
||||||
|
}
|
||||||
|
return setupAptPack("g++-multilib", version, "ppa:ubuntu-toolchain-r/test")
|
||||||
|
}
|
||||||
|
// TODO support bare-metal
|
||||||
|
// TODO support abi
|
||||||
|
// case "none": {
|
||||||
|
// if (arch === "arm" || arch === "arm64") {
|
||||||
|
// return setupAptPack("gcc-arm-none-eabi", version, "ppa:ubuntu-toolchain-r/test")
|
||||||
|
// } else {
|
||||||
|
// throw new Error(`Unsupported platform for ${arch}`)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
default: {
|
||||||
|
throw new Error(`Unsupported platform for ${arch}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -233,10 +233,11 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform): P
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
export async function setupLLVM(
|
export async function setupLLVM(
|
||||||
version: string,
|
version: string,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
_setupCppDir: string | undefined,
|
_setupCppDir: string | undefined,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
_arch: string
|
_arch: string
|
||||||
): Promise<InstallationInfo> {
|
): Promise<InstallationInfo> {
|
||||||
let directory = _setupCppDir
|
let directory = _setupCppDir
|
||||||
|
|
46
src/main.ts
46
src/main.ts
|
@ -17,6 +17,26 @@ import { setupPython } from "./python/python"
|
||||||
import semverValid from "semver/functions/valid"
|
import semverValid from "semver/functions/valid"
|
||||||
import { getVersion } from "./default_versions"
|
import { getVersion } from "./default_versions"
|
||||||
import { InstallationInfo } from "./utils/setup/setupBin"
|
import { InstallationInfo } from "./utils/setup/setupBin"
|
||||||
|
import { setupGcc } from "./gcc/gcc"
|
||||||
|
import { assert } from "console"
|
||||||
|
|
||||||
|
const tools = [
|
||||||
|
"cmake",
|
||||||
|
"ninja",
|
||||||
|
"python",
|
||||||
|
"conan",
|
||||||
|
"meson",
|
||||||
|
"gcovr",
|
||||||
|
"opencppcoverage",
|
||||||
|
"llvm",
|
||||||
|
"gcc",
|
||||||
|
"choco",
|
||||||
|
"brew",
|
||||||
|
"ccache",
|
||||||
|
"doxygen",
|
||||||
|
"cppcheck",
|
||||||
|
"msvc",
|
||||||
|
]
|
||||||
|
|
||||||
const setups = {
|
const setups = {
|
||||||
cmake: setupCmake,
|
cmake: setupCmake,
|
||||||
|
@ -27,6 +47,7 @@ const setups = {
|
||||||
gcovr: setupGcovr,
|
gcovr: setupGcovr,
|
||||||
opencppcoverage: setupOpencppcoverage,
|
opencppcoverage: setupOpencppcoverage,
|
||||||
llvm: setupLLVM,
|
llvm: setupLLVM,
|
||||||
|
gcc: setupGcc,
|
||||||
choco: setupChocolatey,
|
choco: setupChocolatey,
|
||||||
brew: setupBrew,
|
brew: setupBrew,
|
||||||
ccache: setupCcache,
|
ccache: setupCcache,
|
||||||
|
@ -75,6 +96,13 @@ export async function main(): Promise<number> {
|
||||||
await setupLLVM(getVersion("llvm", version) as string, setupCppDir, arch)
|
await setupLLVM(getVersion("llvm", version) as string, setupCppDir, arch)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
case "gcc":
|
||||||
|
case "mingw":
|
||||||
|
case "cygwin":
|
||||||
|
case "msys": {
|
||||||
|
await setupGcc(getVersion("gcc", version) as string, setupCppDir, arch)
|
||||||
|
break
|
||||||
|
}
|
||||||
case "cl":
|
case "cl":
|
||||||
case "msvc":
|
case "msvc":
|
||||||
case "msbuild":
|
case "msbuild":
|
||||||
|
@ -91,22 +119,8 @@ export async function main(): Promise<number> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const tool of [
|
for (const tool of tools) {
|
||||||
"cmake",
|
assert(tool in setups)
|
||||||
"ninja",
|
|
||||||
"python",
|
|
||||||
"conan",
|
|
||||||
"meson",
|
|
||||||
"gcovr",
|
|
||||||
"opencppcoverage",
|
|
||||||
"llvm",
|
|
||||||
"choco",
|
|
||||||
"brew",
|
|
||||||
"ccache",
|
|
||||||
"doxygen",
|
|
||||||
"cppcheck",
|
|
||||||
"msvc",
|
|
||||||
]) {
|
|
||||||
const version = maybeGetInput(tool)
|
const version = maybeGetInput(tool)
|
||||||
if (version !== undefined) {
|
if (version !== undefined) {
|
||||||
const setupFunction = setups[tool]
|
const setupFunction = setups[tool]
|
||||||
|
|
Loading…
Reference in New Issue