mirror of https://github.com/aminya/setup-cpp
feat: change the installation directory to ~/tool
BREAKING CHANGE
This commit is contained in:
parent
722630db75
commit
c6eb5ca89b
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@ import which from "which"
|
|||
let binDir: string | undefined
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupBrew(_version: string, _setupCppDir: string, _arch: string) {
|
||||
export function setupBrew(_version: string, _setupDir: string, _arch: string) {
|
||||
if (!["darwin", "linux"].includes(process.platform)) {
|
||||
return undefined
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
|||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupCcache(version: string, _setupCppDir: string, _arch: string) {
|
||||
export function setupCcache(version: string, _setupDir: string, _arch: string) {
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
return setupChocoPack("ccache", version)
|
||||
|
|
|
@ -11,7 +11,7 @@ export function setupChocolatey(
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_version: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_setupCppDir: string,
|
||||
_setupDir: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_arch: string
|
||||
): InstallationInfo | undefined {
|
||||
|
|
|
@ -60,6 +60,6 @@ function getCmakePackageInfo(version: string, platform?: NodeJS.Platform): Packa
|
|||
|
||||
/** Setup cmake */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupCmake(version: string, setupCppDir: string, _arch: string): Promise<InstallationInfo> {
|
||||
return setupBin("cmake", version, getCmakePackageInfo, setupCppDir)
|
||||
export function setupCmake(version: string, setupDir: string, _arch: string): Promise<InstallationInfo> {
|
||||
return setupBin("cmake", version, getCmakePackageInfo, setupDir)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { setupPipPack } from "../utils/setup/setupPipPack"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupConan(version: string | undefined, _setupCppDir: string, _arch: string) {
|
||||
export function setupConan(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
return setupPipPack("conan", version)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
|||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function setupCppcheck(version: string | undefined, _setupCppDir: string, _arch: string) {
|
||||
export async function setupCppcheck(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
await setupChocoPack("cppcheck", version)
|
||||
|
|
|
@ -4,7 +4,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
|||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function setupDoxygen(version: string | undefined, _setupCppDir: string, _arch: string) {
|
||||
export async function setupDoxygen(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
await setupChocoPack("doxygen.install", version)
|
||||
|
|
|
@ -9,7 +9,7 @@ import semverCoerce from "semver/functions/coerce"
|
|||
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function setupGcc(version: string, _setupCppDir: string, arch: string) {
|
||||
export async function setupGcc(version: string, _setupDir: string, arch: string) {
|
||||
let binDir: string | undefined
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { setupPipPack } from "../utils/setup/setupPipPack"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupGcovr(version: string | undefined, _setupCppDir: string, _arch: string) {
|
||||
export function setupGcovr(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
return setupPipPack("gcovr", version)
|
||||
}
|
||||
|
|
|
@ -231,17 +231,14 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform): P
|
|||
}
|
||||
}
|
||||
|
||||
// const DEFAULT_UNIX_DIRECTORY = "./llvm"
|
||||
// const DEFAULT_WIN32_DIRECTORY = "C:/Program Files/LLVM"
|
||||
|
||||
export async function setupLLVM(
|
||||
version: string,
|
||||
setupCppDir: string,
|
||||
setupDir: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_arch: string
|
||||
): Promise<InstallationInfo> {
|
||||
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupCppDir)
|
||||
await activateLLVM(setupCppDir, version)
|
||||
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir)
|
||||
await activateLLVM(setupDir, version)
|
||||
return installationInfo
|
||||
}
|
||||
|
||||
|
|
15
src/main.ts
15
src/main.ts
|
@ -23,6 +23,7 @@ import { setupGcc } from "./gcc/gcc"
|
|||
import { InstallationInfo } from "./utils/setup/setupBin"
|
||||
import { error, success } from "./utils/io/io"
|
||||
import { setupVcpkg } from "./vcpkg/vcpkg"
|
||||
import { join } from "path"
|
||||
|
||||
/** The setup functions */
|
||||
const setups = {
|
||||
|
@ -93,7 +94,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
const arch = opts.architecture ?? process.arch
|
||||
|
||||
// the installation dir for the tools that are downloaded directly
|
||||
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildify("~/setup_cpp")
|
||||
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildify("~/")
|
||||
|
||||
// report messages
|
||||
const successMessages: string[] = []
|
||||
|
@ -114,7 +115,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
// runnig the setup function for this tool
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const installationInfo = await setupFunction(getVersion(tool, value), setupCppDir, arch)
|
||||
const installationInfo = await setupFunction(getVersion(tool, value), join(setupCppDir, tool), arch)
|
||||
|
||||
// preparing a report string
|
||||
if (installationInfo !== undefined) {
|
||||
|
@ -152,14 +153,14 @@ export async function main(args: string[]): Promise<number> {
|
|||
case "llvm":
|
||||
case "clang":
|
||||
case "clang++": {
|
||||
await setupLLVM(getVersion("llvm", version) as string, setupCppDir, arch)
|
||||
await setupLLVM(getVersion("llvm", version) as string, join(setupCppDir, "llvm"), arch)
|
||||
break
|
||||
}
|
||||
case "gcc":
|
||||
case "mingw":
|
||||
case "cygwin":
|
||||
case "msys": {
|
||||
await setupGcc(getVersion("gcc", version) as string, setupCppDir, arch)
|
||||
await setupGcc(getVersion("gcc", version) as string, join(setupCppDir, "gcc"), arch)
|
||||
break
|
||||
}
|
||||
case "cl":
|
||||
|
@ -169,7 +170,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
case "visualstudio":
|
||||
case "visualcpp":
|
||||
case "visualc++": {
|
||||
await setupMSVC(getVersion("msvc", version) as string, setupCppDir, arch)
|
||||
await setupMSVC(getVersion("msvc", version) as string, join(setupCppDir, "msvc"), arch)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
|
@ -221,7 +222,7 @@ main(process.argv)
|
|||
function printHelp() {
|
||||
core.info(`
|
||||
setup_cpp [options]
|
||||
setup_cpp --compiler llvm --cmake true --ninja true --ccache true --conan "1.40.1"
|
||||
setup_cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
|
||||
|
||||
Install all the tools required for building and testing C++/C projects.
|
||||
|
||||
|
@ -229,7 +230,7 @@ Install all the tools required for building and testing C++/C projects.
|
|||
--compiler\t the <compiler> to install.
|
||||
\t You can specify the version instead of specifying just the name e.g: --compiler 'llvm-11'
|
||||
|
||||
--tool_name\t pass "true" or pass the <version> you would like to install for this tool.
|
||||
--tool_name\t pass "true" or pass the <version> you would like to install for this tool. e.g. --conan true or --conan "1.42.1"
|
||||
|
||||
All the available tools:
|
||||
--llvm
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { setupPipPack } from "../utils/setup/setupPipPack"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupMeson(version: string | undefined, _setupCppDir: string, _arch: string) {
|
||||
export function setupMeson(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
return setupPipPack("meson", version)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ function getArch(arch: string): string {
|
|||
|
||||
export async function setupMSVC(
|
||||
version: MSVCVersion,
|
||||
_setupCppDir: string,
|
||||
_setupDir: string,
|
||||
arch: string,
|
||||
sdk?: string,
|
||||
uwp?: boolean,
|
||||
|
|
|
@ -27,6 +27,6 @@ function getNinjaPackageInfo(version: string, platform: NodeJS.Platform): Packag
|
|||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupNinja(version: string, setupCppDir: string, _arch: string): Promise<InstallationInfo> {
|
||||
return setupBin("ninja", version, getNinjaPackageInfo, setupCppDir)
|
||||
export function setupNinja(version: string, setupDir: string, _arch: string): Promise<InstallationInfo> {
|
||||
return setupBin("ninja", version, getNinjaPackageInfo, setupDir)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { addPath } from "../utils/path/addPath"
|
|||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function setupOpencppcoverage(version: string | undefined, _setupCppDir: string, _arch: string) {
|
||||
export async function setupOpencppcoverage(version: string | undefined, _setupDir: string, _arch: string) {
|
||||
if (process.platform !== "win32") {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ function isPyPyVersion(versionSpec: string) {
|
|||
return versionSpec.startsWith("pypy-")
|
||||
}
|
||||
|
||||
export async function setupActionsPython(version: string, _setupCppDir: string, arch: string) {
|
||||
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
|
||||
if (isPyPyVersion(version)) {
|
||||
const installed = await finderPyPy.findPyPyVersion(version, arch)
|
||||
core.info(
|
||||
|
|
|
@ -8,24 +8,24 @@ import { join } from "path"
|
|||
import { isCI } from "../utils/env/isci"
|
||||
import { setupActionsPython } from "./actions_python"
|
||||
|
||||
export function setupPython(version: string, setupCppDir: string, arch: string) {
|
||||
export function setupPython(version: string, setupDir: string, arch: string) {
|
||||
if (!isCI()) {
|
||||
// TODO parse versoin
|
||||
return setupPythonViaSystem("", setupCppDir, arch)
|
||||
return setupPythonViaSystem("", setupDir, arch)
|
||||
}
|
||||
try {
|
||||
return setupActionsPython(version, setupCppDir, arch)
|
||||
return setupActionsPython(version, setupDir, arch)
|
||||
} catch (err) {
|
||||
return setupPythonViaSystem(version, setupCppDir, arch)
|
||||
return setupPythonViaSystem(version, setupDir, arch)
|
||||
}
|
||||
}
|
||||
|
||||
export async function setupPythonViaSystem(version: string, setupCppDir: string, arch: string) {
|
||||
export async function setupPythonViaSystem(version: string, setupDir: string, arch: string) {
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
// Get an unique output directory name from the URL.
|
||||
const key: string = await hasha.async(version + arch, { algorithm: "md5" })
|
||||
const installDir = join(setupCppDir, key, "python")
|
||||
const installDir = join(setupDir, key, "python")
|
||||
const binDir = installDir
|
||||
await setupChocoPack("python3", version, [`/InstallDir:${installDir}`])
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { info } from "@actions/core"
|
|||
import { addPath } from "../path/addPath"
|
||||
import { join } from "path"
|
||||
import { existsSync } from "fs"
|
||||
import * as hasha from "hasha"
|
||||
import { tmpdir } from "os"
|
||||
import { isCI } from "../env/isci"
|
||||
|
||||
|
@ -40,7 +39,7 @@ export async function setupBin(
|
|||
name: string,
|
||||
version: string,
|
||||
getPackageInfo: (version: string, platform: NodeJS.Platform) => PackageInfo | Promise<PackageInfo>,
|
||||
setupCppDir: string
|
||||
setupDir: string
|
||||
): Promise<InstallationInfo> {
|
||||
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
|
||||
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACH ?? join(tmpdir(), "setup_cpp", "ToolCache")
|
||||
|
@ -63,18 +62,14 @@ export async function setupBin(
|
|||
}
|
||||
}
|
||||
|
||||
// Get an unique output directory name from the URL.
|
||||
const key: string = await hasha.async(url, { algorithm: "md5" })
|
||||
const rootDir = join(setupCppDir, key)
|
||||
|
||||
// download ane extract the package into the installation directory.
|
||||
if (!existsSync(rootDir)) {
|
||||
if (!existsSync(setupDir)) {
|
||||
info(`Download and extract ${name} ${version}`)
|
||||
const downloaded = await downloadTool(url)
|
||||
await extractFunction?.(downloaded, rootDir)
|
||||
await extractFunction?.(downloaded, setupDir)
|
||||
}
|
||||
|
||||
const installDir = join(rootDir, extractedFolderName)
|
||||
const installDir = join(setupDir, extractedFolderName)
|
||||
const binDir = join(installDir, binRelativeDir)
|
||||
|
||||
// Adding the bin dir to the path
|
||||
|
@ -84,7 +79,7 @@ export async function setupBin(
|
|||
|
||||
// check if inside Github Actions. If so, cache the installation
|
||||
if (isCI() && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||
await cacheDir(rootDir, name, version)
|
||||
await cacheDir(setupDir, name, version)
|
||||
}
|
||||
|
||||
return { installDir, binDir }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { addPath } from "@actions/core"
|
||||
import execa from "execa"
|
||||
import path from "path"
|
||||
import untildify from "untildify"
|
||||
import path, { dirname } from "path"
|
||||
import which from "which"
|
||||
import { addShellExtension, addShellHere } from "../utils/extension/extension"
|
||||
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||
|
@ -9,14 +8,13 @@ import { InstallationInfo } from "../utils/setup/setupBin"
|
|||
let hasVCPKG = false
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupVcpkg(_version: string, _setupCppDir: string, _arch: string): InstallationInfo {
|
||||
export function setupVcpkg(_version: string, setupDir: string, _arch: string): InstallationInfo {
|
||||
if (!hasVCPKG || which.sync("vcpkg", { nothrow: true }) === null) {
|
||||
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: untildify("~/") })
|
||||
const vcpkgDir = untildify("~/vcpkg")
|
||||
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: vcpkgDir, shell: true })
|
||||
addPath(vcpkgDir)
|
||||
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir) })
|
||||
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: setupDir, shell: true })
|
||||
addPath(setupDir)
|
||||
hasVCPKG = true
|
||||
return { binDir: vcpkgDir }
|
||||
return { binDir: setupDir }
|
||||
}
|
||||
|
||||
return { binDir: path.dirname(which.sync("vcpkg")) }
|
||||
|
|
Loading…
Reference in New Issue