From cb6c11a359cda10d5ac57a404cb21936a437d485 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 5 Dec 2021 08:20:14 -0600 Subject: [PATCH] feat: add a separate vcvarsall --- README.md | 1 + action.yml | 3 +++ package.json | 6 +++--- src/main.ts | 16 +++++++++++++--- src/msvc/msvc.ts | 4 ++-- src/vcvarsall/vcvarsall.ts | 2 +- tsconfig.json | 3 +-- 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1763901d..0dfb2c54 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ The package can be used locally or from CI services like GitHub Actions. Stay tu - gcc - cmake - ninja +- vcvarsall - vcpkg - meson - conan diff --git a/action.yml b/action.yml index 5be83fb5..15adab72 100644 --- a/action.yml +++ b/action.yml @@ -18,6 +18,9 @@ inputs: msvc: description: "The msvc version to install" required: false + vcvarsall: + description: "If should run vcvarsall?" + required: false cmake: description: "The cmake version to install." required: false diff --git a/package.json b/package.json index 4b0679a3..5a9590fb 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,11 @@ "execa": "^5.1.1", "hasha": "^5.2.2", "mri": "^1.2.0", + "msvc-dev-cmd": " https://github.com/ilammy/msvc-dev-cmd", "semver": "^7.3.5", - "untildify": "^4.0.0", - "which": "^2.0.2", "setup-python": "https://github.com/actions/setup-python", - "msvc-dev-cmd": " https://github.com/ilammy/msvc-dev-cmd" + "untildify": "^4.0.0", + "which": "^2.0.2" }, "devDependencies": { "@types/cross-spawn": "^6.0.2", diff --git a/src/main.ts b/src/main.ts index 199c4ae5..9475d047 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,6 +26,7 @@ import { error, success } from "./utils/io/io" import { setupVcpkg } from "./vcpkg/vcpkg" import { join } from "path" import { warning } from "@actions/core" +import { setupVCVarsall } from "./vcvarsall/vcvarsall" /** The setup functions */ const setups = { @@ -45,6 +46,7 @@ const setups = { doxygen: setupDoxygen, cppcheck: setupCppcheck, msvc: setupMSVC, + vcvarsall: setupVCVarsall, } /** The tools that can be installed */ @@ -65,6 +67,7 @@ const tools: Array = [ "llvm", "gcc", "msvc", + "vcvarsall", ] /** The possible inputs to the program */ @@ -116,9 +119,15 @@ export async function main(args: string[]): Promise { // running the setup function for this tool try { - // eslint-disable-next-line no-await-in-loop - const installationInfo = await setupFunction(getVersion(tool, value), join(setupCppDir, tool), arch) - + let installationInfo: InstallationInfo | undefined | void + if (tool === "vcvarsall") { + // TODO expose the options + // eslint-disable-next-line no-await-in-loop + ;(setupFunction as typeof setupVCVarsall)(undefined, arch, undefined, undefined, false, false) + } else { + // eslint-disable-next-line no-await-in-loop + installationInfo = await setupFunction(getVersion(tool, value), join(setupCppDir, tool), arch) + } // preparing a report string if (installationInfo !== undefined) { successMessages.push(getSuccessMessage(tool, installationInfo)) @@ -252,6 +261,7 @@ Install all the tools required for building and testing C++/C projects. All the available tools: --llvm --gcc +--vcvarsall --cmake --ninja --vcpkg diff --git a/src/msvc/msvc.ts b/src/msvc/msvc.ts index 969bf83f..580344a7 100644 --- a/src/msvc/msvc.ts +++ b/src/msvc/msvc.ts @@ -2,7 +2,7 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack" import { error, exportVariable, warning } from "@actions/core" import { existsSync } from "fs" import { isCI } from "../utils/env/isci" -import { activateMSVC } from "../vcvarsall/vcvarsall" +import { setupVCVarsall } from "../vcvarsall/vcvarsall" type MSVCVersion = "2015" | "2017" | "2019" | string @@ -56,5 +56,5 @@ export async function setupMSVC( } } // run vcvarsall.bat environment variables - activateMSVC(VCTargetsPath, arch, toolset, sdk, uwp, spectre) + setupVCVarsall(VCTargetsPath, arch, toolset, sdk, uwp, spectre) } diff --git a/src/vcvarsall/vcvarsall.ts b/src/vcvarsall/vcvarsall.ts index a750c27f..c99ce2e5 100644 --- a/src/vcvarsall/vcvarsall.ts +++ b/src/vcvarsall/vcvarsall.ts @@ -17,7 +17,7 @@ function getArch(arch: string): string { } } -export function activateMSVC( +export function setupVCVarsall( VCTargetsPath: string | undefined, arch: string, toolset: string | undefined, diff --git a/tsconfig.json b/tsconfig.json index d7276a31..c4c78492 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,6 +27,5 @@ "outDir": "./dist" }, "compileOnSave": false, - "include": ["./src"], - "exclude": ["./src/python/setup-python", "src/msvc-dev-cmd/msvc-dev-cmd"] + "include": ["./src"] }