mirror of https://github.com/aminya/setup-cpp
fix: make install directory configurable
This commit is contained in:
parent
40336c3c67
commit
a5ae2b4863
|
@ -9,7 +9,7 @@ Settting up a **cross-platform** enviroment for building and testing C++/C proje
|
|||
|
||||
This package is designed to be fully **modular** and as **minimal** as possible. This will allow you to only install the tools you want.
|
||||
|
||||
The package will be usable locally or inside GitHub Actions. Stay tuned for the stable release.
|
||||
The package will be usable from any environment (locally, GitHub Actions, etc). Stay tuned for the stable release.
|
||||
|
||||
# Features (WIP)
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers"
|
|||
jest.setTimeout(100000)
|
||||
|
||||
describe("setup-cmake", () => {
|
||||
let directory: string
|
||||
beforeEach(async () => {
|
||||
await setupTmpDir("setup-cmake")
|
||||
directory = await setupTmpDir("setup-cmake")
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -14,7 +15,7 @@ describe("setup-cmake", () => {
|
|||
}, 100000)
|
||||
|
||||
it("should setup CMake", async () => {
|
||||
const cmakePath = await setupCmake("3.20.2")
|
||||
const cmakePath = await setupCmake("3.20.2", directory)
|
||||
expect(cmakePath).toBeDefined()
|
||||
expect(cmakePath).not.toHaveLength(0)
|
||||
|
||||
|
|
|
@ -59,6 +59,6 @@ function getCmakePackageInfo(version: string, platform?: NodeJS.Platform): Packa
|
|||
}
|
||||
|
||||
/** Setup cmake */
|
||||
export function setupCmake(version: string): Promise<string> {
|
||||
return setupBin("cmake", version, getCmakePackageInfo)
|
||||
export function setupCmake(version: string, setupCppDir: string): Promise<string> {
|
||||
return setupBin("cmake", version, getCmakePackageInfo, setupCppDir)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as core from "@actions/core"
|
||||
import { setupCmake } from "./cmake/cmake"
|
||||
import { setupLLVM } from "./llvm/llvm"
|
||||
import { setupNinja } from "./ninja/ninja"
|
||||
|
||||
function maybeGetInput(key: string) {
|
||||
|
@ -11,17 +12,18 @@ function maybeGetInput(key: string) {
|
|||
}
|
||||
|
||||
export async function main(): Promise<number> {
|
||||
const setupCppDir = process.env.SETUP_CPP_DIR ?? "~/setup_cpp"
|
||||
try {
|
||||
// setup cmake
|
||||
const cmakeVersion = maybeGetInput("cmake")
|
||||
if (cmakeVersion !== undefined) {
|
||||
await setupCmake(cmakeVersion)
|
||||
await setupCmake(cmakeVersion, setupCppDir)
|
||||
}
|
||||
|
||||
// setup ninja
|
||||
const ninjaVersion = maybeGetInput("ninja")
|
||||
if (ninjaVersion !== undefined) {
|
||||
await setupNinja(ninjaVersion)
|
||||
await setupNinja(ninjaVersion, setupCppDir)
|
||||
}
|
||||
} catch (err) {
|
||||
core.error(err as string | Error)
|
||||
|
|
|
@ -5,8 +5,9 @@ import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers"
|
|||
jest.setTimeout(100000)
|
||||
|
||||
describe("setup-ninja", () => {
|
||||
let directory: string
|
||||
beforeEach(async () => {
|
||||
await setupTmpDir("setup-ninja")
|
||||
directory = await setupTmpDir("setup-ninja")
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -14,7 +15,7 @@ describe("setup-ninja", () => {
|
|||
}, 100000)
|
||||
|
||||
it("should setup Ninja", async () => {
|
||||
const ninjaPath = await setupNinja("1.10.2")
|
||||
const ninjaPath = await setupNinja("1.10.2", directory)
|
||||
expect(ninjaPath).toBeDefined()
|
||||
expect(ninjaPath).not.toHaveLength(0)
|
||||
|
||||
|
|
|
@ -26,6 +26,6 @@ function getNinjaPackageInfo(version: string, platform: NodeJS.Platform): Packag
|
|||
}
|
||||
}
|
||||
|
||||
export function setupNinja(version: string): Promise<string> {
|
||||
return setupBin("ninja", version, getNinjaPackageInfo)
|
||||
export function setupNinja(version: string, setupCppDir: string): Promise<string> {
|
||||
return setupBin("ninja", version, getNinjaPackageInfo, setupCppDir)
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ export type PackageInfo = {
|
|||
export async function setupBin(
|
||||
name: string,
|
||||
version: string,
|
||||
getPackageInfo: (version: string, platform: NodeJS.Platform) => PackageInfo
|
||||
getPackageInfo: (version: string, platform: NodeJS.Platform) => PackageInfo,
|
||||
setupCppDir: string
|
||||
): Promise<string> {
|
||||
const setupCppDir = process.env.SETUP_CPP_DIR ?? "~/setup_cpp"
|
||||
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
|
||||
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACH ?? join(setupCppDir, "ToolCache")
|
||||
|
||||
|
|
Loading…
Reference in New Issue