feat: install 7z if needed for extraction of llvm on Windows

This commit is contained in:
Amin Yahyaabadi 2022-02-05 20:20:36 -08:00
parent 6aef987ea2
commit c65b6f6d58
8 changed files with 59 additions and 2 deletions

View File

@ -33,9 +33,13 @@ The package can be used locally or from CI services like GitHub Actions.
- gcovr - gcovr
- opencppcoverage - opencppcoverage
- kcov - kcov
`setup-cpp` can also install the following. These are automatically installed if needed for the above Cpp tools (e.g., python is required for conan).
- python - python
- choco - choco
- brew - brew
- sevenzip
# Usage # Usage

View File

@ -69,6 +69,9 @@ inputs:
kcov: kcov:
description: "The kcov version to install." description: "The kcov version to install."
required: false required: false
sevenzip:
description: "The 7z version to install."
required: false
runs: runs:
using: "node12" using: "node12"

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -29,6 +29,7 @@ import { join } from "path"
import { setupVCVarsall } from "./vcvarsall/vcvarsall" 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"
/** The setup functions */ /** The setup functions */
const setups = { const setups = {
@ -54,6 +55,7 @@ const setups = {
kcov: setupKcov, kcov: setupKcov,
make: setupMake, make: setupMake,
task: setupTask, task: setupTask,
sevenzip: setupSevenZip,
} }
/** The tools that can be installed */ /** The tools that can be installed */
@ -80,6 +82,7 @@ const tools: Array<keyof typeof setups> = [
"kcov", "kcov",
"make", "make",
"task", "task",
"sevenzip",
] ]
/** The possible inputs to the program */ /** The possible inputs to the program */
@ -290,9 +293,11 @@ All the available tools:
--gcovr --gcovr
--opencppcoverage --opencppcoverage
--kcov --kcov
--python --python
--choco --choco
--brew --brew
--sevenzip
`) `)
} }

View File

@ -0,0 +1,12 @@
import { setupSevenZip } from "../sevenzip"
import { testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin"
jest.setTimeout(300000)
describe("setup-7z", () => {
it("should setup 7z", async () => {
const installInfo = await setupSevenZip("", "", process.arch)
await testBin("7z", ["--help"], (installInfo as InstallationInfo | undefined)?.binDir)
})
})

21
src/sevenzip/sevenzip.ts Normal file
View File

@ -0,0 +1,21 @@
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 setupSevenZip(version: string, _setupDir: string, _arch: string) {
switch (process.platform) {
case "win32": {
return setupChocoPack("7zip", version)
}
case "darwin": {
return setupBrewPack("p7zip", version)
}
case "linux": {
return setupAptPack("p7zip-full", version)
}
default: {
throw new Error(`Unsupported platform`)
}
}
}

View File

@ -1,8 +1,20 @@
import execa from "execa" import execa from "execa"
import { mkdirP } from "@actions/io" import { mkdirP } from "@actions/io"
import which from "which"
import { setupSevenZip } from "../../sevenzip/sevenzip"
export { extractTar, extractXar, extract7z, extractZip } from "@actions/tool-cache" export { extractTar, extractXar, extract7z, extractZip } from "@actions/tool-cache"
let sevenZip: string | undefined
export async function extractExe(file: string, dest: string) { export async function extractExe(file: string, dest: string) {
// install 7z if needed
if (sevenZip === undefined) {
if (which.sync("7z", { nothrow: true }) !== null) {
sevenZip = "7z"
}
await setupSevenZip("", "", process.arch)
}
await execa("7z", ["x", file, `-o${dest}`]) await execa("7z", ["x", file, `-o${dest}`])
return dest return dest
} }