Skip to content

Commit

Permalink
feat: add a separate vcvarsall
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 5, 2021
1 parent 902069d commit cb6c11a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 13 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -45,6 +46,7 @@ const setups = {
doxygen: setupDoxygen,
cppcheck: setupCppcheck,
msvc: setupMSVC,
vcvarsall: setupVCVarsall,
}

/** The tools that can be installed */
Expand All @@ -65,6 +67,7 @@ const tools: Array<keyof typeof setups> = [
"llvm",
"gcc",
"msvc",
"vcvarsall",
]

/** The possible inputs to the program */
Expand Down Expand Up @@ -116,9 +119,15 @@ export async function main(args: string[]): Promise<number> {

// 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))
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/msvc/msvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion src/vcvarsall/vcvarsall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function getArch(arch: string): string {
}
}

export function activateMSVC(
export function setupVCVarsall(
VCTargetsPath: string | undefined,
arch: string,
toolset: string | undefined,
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@
"outDir": "./dist"
},
"compileOnSave": false,
"include": ["./src"],
"exclude": ["./src/python/setup-python", "src/msvc-dev-cmd/msvc-dev-cmd"]
"include": ["./src"]
}

0 comments on commit cb6c11a

Please sign in to comment.