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