mirror of https://github.com/aminya/setup-cpp
Merge pull request #37 from aminya/more-logging [skip ci]
This commit is contained in:
commit
5397b1ac4a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -39,15 +39,19 @@ export function setupChocolatey(
|
|||
}
|
||||
|
||||
// https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe
|
||||
execa.sync(powershell, [
|
||||
"-NoProfile",
|
||||
"-InputFormat",
|
||||
"None",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-Command",
|
||||
"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))",
|
||||
])
|
||||
execa.sync(
|
||||
powershell,
|
||||
[
|
||||
"-NoProfile",
|
||||
"-InputFormat",
|
||||
"None",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-Command",
|
||||
"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))",
|
||||
],
|
||||
{ stdio: "inherit" }
|
||||
)
|
||||
|
||||
const chocoPath = `${process.env.ALLUSERSPROFILE}\\chocolatey\\bin`
|
||||
addPath(chocoPath)
|
||||
|
|
|
@ -34,8 +34,8 @@ function getKcovPackageInfo(version: string): PackageInfo {
|
|||
// await setupCmake("3.22.0", join(untildify(""), "cmake"), "")
|
||||
await setupAptPack("libdw-dev")
|
||||
await setupAptPack("libcurl4-openssl-dev")
|
||||
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out })
|
||||
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out })
|
||||
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out, stdio: "inherit" })
|
||||
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out, stdio: "inherit" })
|
||||
await execSudo("cmake", ["--install", "./build"], out)
|
||||
return out
|
||||
},
|
||||
|
|
14
src/main.ts
14
src/main.ts
|
@ -30,6 +30,7 @@ import { setupVCVarsall } from "./vcvarsall/vcvarsall"
|
|||
import { setupKcov } from "./kcov/kcov"
|
||||
import { addEnv } from "./utils/env/addEnv"
|
||||
import { setupSevenZip } from "./sevenzip/sevenzip"
|
||||
import { endGroup, startGroup } from "@actions/core"
|
||||
|
||||
/** The setup functions */
|
||||
const setups = {
|
||||
|
@ -125,22 +126,23 @@ export async function main(args: string[]): Promise<number> {
|
|||
// loop over the tools and run their setup function
|
||||
for (const tool of tools) {
|
||||
// get the version or "true" or undefined for this tool from the options
|
||||
const value = opts[tool]
|
||||
const version = opts[tool]
|
||||
|
||||
// skip if undefined
|
||||
if (value !== undefined) {
|
||||
if (version !== undefined) {
|
||||
// running the setup function for this tool
|
||||
startGroup(`Installing ${tool} ${version}`)
|
||||
try {
|
||||
let installationInfo: InstallationInfo | undefined | void
|
||||
if (tool === "vcvarsall") {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
setupVCVarsall(getVersion(tool, value), undefined, arch, undefined, undefined, false, false)
|
||||
setupVCVarsall(getVersion(tool, version), undefined, arch, undefined, undefined, false, false)
|
||||
} else {
|
||||
// get the setup function
|
||||
const setupFunction = setups[tool]
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
installationInfo = await setupFunction(getVersion(tool, value), join(setupCppDir, tool), arch)
|
||||
installationInfo = await setupFunction(getVersion(tool, version), join(setupCppDir, tool), arch)
|
||||
}
|
||||
// preparing a report string
|
||||
successMessages.push(getSuccessMessage(tool, installationInfo))
|
||||
|
@ -149,6 +151,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
error(e as string | Error)
|
||||
errorMessages.push(`${tool} failed to install`)
|
||||
}
|
||||
endGroup()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,6 +162,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
const { compiler, version } = getCompilerInfo(maybeCompiler)
|
||||
|
||||
// install the compiler. We allow some aliases for the compiler name
|
||||
startGroup(`Installing ${compiler} ${version ?? ""}`)
|
||||
switch (compiler) {
|
||||
case "llvm":
|
||||
case "clang":
|
||||
|
@ -198,10 +202,12 @@ export async function main(args: string[]): Promise<number> {
|
|||
errorMessages.push(`Unsupported compiler ${compiler}`)
|
||||
}
|
||||
}
|
||||
endGroup()
|
||||
}
|
||||
} catch (e) {
|
||||
error(e as string | Error)
|
||||
errorMessages.push(`Failed to install the ${maybeCompiler}`)
|
||||
endGroup()
|
||||
}
|
||||
|
||||
if (successMessages.length === 0 && errorMessages.length === 0) {
|
||||
|
|
|
@ -18,5 +18,5 @@ export function execPowershell(command: string) {
|
|||
throw new Error("Could not find powershell")
|
||||
}
|
||||
|
||||
execa.sync(powershell, ["-c", command])
|
||||
execa.sync(powershell, ["-c", command], { stdio: "inherit" })
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@ export function execSudo(file: string, args: string[], cwd?: string) {
|
|||
stdio: "inherit",
|
||||
})
|
||||
} else {
|
||||
return execa(file, args)
|
||||
return execa(file, args, { stdio: "inherit" })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export async function extractExe(file: string, dest: string) {
|
|||
sevenZip = "7z"
|
||||
}
|
||||
|
||||
await execa(sevenZip, ["x", file, `-o${dest}`])
|
||||
await execa(sevenZip, ["x", file, `-o${dest}`], { stdio: "inherit" })
|
||||
return dest
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,6 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
|
|||
} catch {
|
||||
// ignore
|
||||
}
|
||||
await execa("tar", ["xf", file, "-C", dest, ...flags])
|
||||
await execa("tar", ["xf", file, "-C", dest, ...flags], { stdio: "inherit" })
|
||||
return dest
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
import { execSudo } from "../exec/sudo"
|
||||
import { info } from "@actions/core"
|
||||
|
||||
let didUpdate: boolean = false
|
||||
let didInit: boolean = false
|
||||
|
@ -11,6 +12,8 @@ export async function setupAptPack(
|
|||
version?: string,
|
||||
repositories: boolean | string[] = true
|
||||
): Promise<InstallationInfo> {
|
||||
info(`Installing ${name} ${version ?? ""} via apt`)
|
||||
|
||||
const apt = "apt-get"
|
||||
|
||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
||||
|
|
|
@ -45,6 +45,8 @@ export async function setupBin(
|
|||
setupDir: string,
|
||||
arch: string
|
||||
): Promise<InstallationInfo> {
|
||||
info(`Installing ${name} ${version} ${arch} via direct downloading`)
|
||||
|
||||
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
|
||||
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACHE ?? join(tmpdir(), "setup-cpp", "hostedtoolcache")
|
||||
|
||||
|
@ -64,6 +66,7 @@ export async function setupBin(
|
|||
if (existsSync(binDir) && existsSync(join(binDir, binFileName))) {
|
||||
info(`${name} ${version} was found in the cache at ${binDir}.`)
|
||||
addPath(binDir)
|
||||
|
||||
return { installDir, binDir }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { info } from "@actions/core"
|
||||
import execa from "execa"
|
||||
import which from "which"
|
||||
import { setupBrew } from "../../brew/brew"
|
||||
|
@ -8,6 +9,8 @@ let hasBrew = false
|
|||
|
||||
/** A function that installs a package using brew */
|
||||
export function setupBrewPack(name: string, version?: string): InstallationInfo {
|
||||
info(`Installing ${name} ${version ?? ""} via brew`)
|
||||
|
||||
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
||||
setupBrew("", "", process.arch)
|
||||
hasBrew = true
|
||||
|
|
|
@ -4,11 +4,14 @@ import which from "which"
|
|||
import { setupChocolatey } from "../../chocolatey/chocolatey"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
import execa from "execa"
|
||||
import { info } from "@actions/core"
|
||||
|
||||
let hasChoco = false
|
||||
|
||||
/** A function that installs a package using choco */
|
||||
export function setupChocoPack(name: string, version?: string, args: string[] = []): InstallationInfo {
|
||||
info(`Installing ${name} ${version ?? ""} via chocolatey`)
|
||||
|
||||
if (!hasChoco || which.sync("choco", { nothrow: true }) === null) {
|
||||
setupChocolatey("", "", process.arch)
|
||||
hasChoco = true
|
||||
|
@ -34,5 +37,6 @@ export function setupChocoPack(name: string, version?: string, args: string[] =
|
|||
|
||||
const binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
|
||||
addPath(binDir)
|
||||
|
||||
return { binDir }
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ let tried = false
|
|||
|
||||
/** A function that installs a package using pip */
|
||||
export async function setupPipPack(name: string, version?: string): Promise<InstallationInfo> {
|
||||
info(`Installing ${name} ${version ?? ""} via pip`)
|
||||
|
||||
// setup python and pip if needed
|
||||
if (python === undefined) {
|
||||
if (which.sync("python3", { nothrow: true }) !== null) {
|
||||
|
@ -36,7 +38,7 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
|
|||
}
|
||||
if (process.platform === "win32") {
|
||||
// https://github.com/pypa/pip/issues/10875#issuecomment-1030293005
|
||||
execa.sync(python, ["-m", "pip", "install", "-U", "pip==21.3.1"])
|
||||
execa.sync(python, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
|
||||
}
|
||||
|
||||
execa.sync(python, ["-m", "pip", "install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
|
||||
|
|
|
@ -23,12 +23,12 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
|
|||
}
|
||||
|
||||
if (!existsSync(join(setupDir, addShellExtension("bootstrap-vcpkg")))) {
|
||||
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir) })
|
||||
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
|
||||
} else {
|
||||
warning(`Vcpkg folder already exists at ${setupDir}`)
|
||||
}
|
||||
|
||||
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: setupDir, shell: true })
|
||||
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: setupDir, shell: true, stdio: "inherit" })
|
||||
addPath(setupDir)
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
hasVCPKG = true
|
||||
|
|
Loading…
Reference in New Issue