Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("getCompilerInfo", () => {
})

describe("syncVersion", () => {
it("Syncs llvm tools versions", async () => {
it("Syncs llvm tools versions", () => {
const llvmTools = ["llvm", "clangtidy", "clangformat"] as Inputs[]
expect(syncVersions(parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"]), llvmTools)).toBe(true)
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "true"]), llvmTools)).toBe(true)
Expand Down
6 changes: 3 additions & 3 deletions src/chocolatey/chocolatey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { InstallationInfo } from "../utils/setup/setupBin"

let binDir: string | undefined

export function setupChocolatey(
export async function setupChocolatey(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_version: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_setupDir: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_arch: string
): InstallationInfo | undefined {
): Promise<InstallationInfo | undefined> {
if (process.platform !== "win32") {
return undefined
}
Expand Down Expand Up @@ -54,7 +54,7 @@ export function setupChocolatey(
)

const chocoPath = `${process.env.ALLUSERSPROFILE}\\chocolatey\\bin`
addPath(chocoPath)
await addPath(chocoPath)

const maybeChoco = which.sync("choco", { nothrow: true })
if (maybeChoco !== null) {
Expand Down
6 changes: 3 additions & 3 deletions src/cppcheck/cppcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
switch (process.platform) {
case "win32": {
await setupChocoPack("cppcheck", version)
const binDir = activateWinCppcheck()
const binDir = await activateWinCppcheck()
return { binDir }
}
case "darwin": {
Expand All @@ -23,8 +23,8 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
}
}

function activateWinCppcheck() {
async function activateWinCppcheck() {
const binDir = "C:/Program Files/Cppcheck"
addPath(binDir)
await addPath(binDir)
return binDir
}
7 changes: 4 additions & 3 deletions src/doxygen/doxygen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
switch (process.platform) {
case "win32": {
await setupChocoPack("doxygen.install", version)
const binDir = activateWinDoxygen()
const binDir = await activateWinDoxygen()
const installationInfo = { binDir }
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
return installationInfo
Expand Down Expand Up @@ -72,7 +72,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
}
}

function activateWinDoxygen() {
async function activateWinDoxygen() {
switch (process.platform) {
case "win32": {
for (const binDir of [
Expand All @@ -81,7 +81,8 @@ function activateWinDoxygen() {
"C:/Program Files (x86)/doxygen",
]) {
if (existsSync(binDir)) {
addPath(binDir)
// eslint-disable-next-line no-await-in-loop
await addPath(binDir)
return binDir
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/gcc/gcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
await setupChocoPack("mingw", version)
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
binDir = "C:/tools/mingw64/bin"
addPath(binDir)
await addPath(binDir)
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
binDir = "C:/tools/mingw32/bin"
addPath(binDir)
await addPath(binDir)
} else if (existsSync(`${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin/g++.exe`)) {
binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
}
Expand Down Expand Up @@ -72,19 +72,19 @@ async function activateGcc(version: string, binDir: string) {
// const ld = process.env.LD_LIBRARY_PATH ?? ""
// const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
// // Setup gcc as the compiler
// addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`)
// addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`)
// addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`)
// addEnv("LDFLAGS", `-L${installDir}/lib`)
// addEnv("CPPFLAGS", `-I${installDir}/include`)
// await addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`)
// await addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`)
// await addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`)
// await addEnv("LDFLAGS", `-L${installDir}/lib`)
// await addEnv("CPPFLAGS", `-I${installDir}/include`)
if (process.platform === "win32") {
addEnv("CC", `${binDir}/gcc`)
addEnv("CXX", `${binDir}/g++`)
await addEnv("CC", `${binDir}/gcc`)
await addEnv("CXX", `${binDir}/g++`)
} else {
const majorVersion = semverMajor(semverCoerce(version) ?? version)
if (majorVersion >= 5) {
addEnv("CC", `${binDir}/gcc-${majorVersion}`)
addEnv("CXX", `${binDir}/g++-${majorVersion}`)
await addEnv("CC", `${binDir}/gcc-${majorVersion}`)
await addEnv("CXX", `${binDir}/g++-${majorVersion}`)

if (process.platform === "linux") {
await updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
Expand All @@ -93,8 +93,8 @@ async function activateGcc(version: string, binDir: string) {
await updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
}
} else {
addEnv("CC", `${binDir}/gcc-${version}`)
addEnv("CXX", `${binDir}/g++-${version}`)
await addEnv("CC", `${binDir}/gcc-${version}`)
await addEnv("CXX", `${binDir}/g++-${version}`)

if (process.platform === "linux") {
await updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
Expand Down
8 changes: 4 additions & 4 deletions src/graphviz/graphviz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupGraphviz(version: string, _setupDir: string, _arch: string) {
export async function setupGraphviz(version: string, _setupDir: string, _arch: string) {
switch (process.platform) {
case "win32": {
setupChocoPack("graphviz", version)
await setupChocoPack("graphviz", version)
return activateGraphviz()
}
case "darwin": {
Expand All @@ -23,11 +23,11 @@ export function setupGraphviz(version: string, _setupDir: string, _arch: string)
}
}

function activateGraphviz(): InstallationInfo {
async function activateGraphviz(): Promise<InstallationInfo> {
switch (process.platform) {
case "win32": {
const binDir = "C:/Program Files/Graphviz/bin"
addPath(binDir)
await addPath(binDir)
return { binDir }
}
default: {
Expand Down
20 changes: 10 additions & 10 deletions src/llvm/llvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,29 +301,29 @@ export async function activateLLVM(directory: string, versionGiven: string) {
const ld = process.env.LD_LIBRARY_PATH ?? ""
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""

addEnv("LLVM_PATH", directory) // the output of this action
await addEnv("LLVM_PATH", directory) // the output of this action

// Setup LLVM as the compiler
addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`)
addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`)
await addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`)
await addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`)

// windows builds fail with llvm's CPATH
if (process.platform !== "win32") {
const llvmMajor = semverMajor(version)
if (existsSync(`${directory}/lib/clang/${version}/include`)) {
addEnv("CPATH", `${directory}/lib/clang/${version}/include`)
await addEnv("CPATH", `${directory}/lib/clang/${version}/include`)
} else if (existsSync(`${directory}/lib/clang/${llvmMajor}/include`)) {
addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`)
await addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`)
}
}

addEnv("LDFLAGS", `-L"${directory}/lib"`)
addEnv("CPPFLAGS", `-I"${directory}/include"`)
await addEnv("LDFLAGS", `-L"${directory}/lib"`)
await addEnv("CPPFLAGS", `-I"${directory}/include"`)

addEnv("CC", `${directory}/bin/clang`)
addEnv("CXX", `${directory}/bin/clang++`)
await addEnv("CC", `${directory}/bin/clang`)
await addEnv("CXX", `${directory}/bin/clang++`)

addEnv("LIBRARY_PATH", `${directory}/lib`)
await addEnv("LIBRARY_PATH", `${directory}/lib`)

await setupMacOSSDK()

Expand Down
2 changes: 1 addition & 1 deletion src/macos-sdk/macos-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function setupMacOSSDK() {
const xcrun = await getExecOutput("xcrun --sdk macosx --show-sdk-path")
const sdkroot = xcrun.stdout || xcrun.stderr
if (sdkroot) {
addEnv("SDKROOT", sdkroot.trim())
await addEnv("SDKROOT", sdkroot.trim())
} else {
error(`SDKROOT not set`)
}
Expand Down
21 changes: 17 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,16 @@ export async function main(args: string[]): Promise<number> {
try {
let installationInfo: InstallationInfo | undefined | void
if (tool === "vcvarsall") {
setupVCVarsall(getVersion(tool, version, osVersion), undefined, arch, undefined, undefined, false, false)
// eslint-disable-next-line no-await-in-loop
await setupVCVarsall(
getVersion(tool, version, osVersion),
undefined,
arch,
undefined,
undefined,
false,
false
)
} else {
// get the setup function
const setupFunction = setups[tool]
Expand Down Expand Up @@ -224,15 +233,19 @@ export async function main(args: string[]): Promise<number> {
case "visualstudio":
case "visualcpp":
case "visualc++": {
const installationInfo = setupMSVC(getVersion("msvc", version, osVersion), join(setupCppDir, "msvc"), arch)
const installationInfo = await setupMSVC(
getVersion("msvc", version, osVersion),
join(setupCppDir, "msvc"),
arch
)
successMessages.push(getSuccessMessage("msvc", installationInfo))
break
}
case "appleclang":
case "applellvm": {
notice("Assuming apple-clang is already installed")
addEnv("CC", "clang")
addEnv("CXX", "clang++")
await addEnv("CC", "clang")
await addEnv("CXX", "clang++")
successMessages.push(getSuccessMessage("apple-clang", undefined))
break
}
Expand Down
4 changes: 2 additions & 2 deletions src/make/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupMake(version: string, _setupDir: string, _arch: string) {
export async function setupMake(version: string, _setupDir: string, _arch: string) {
switch (process.platform) {
case "win32": {
return setupChocoPack("make", version)
}
case "darwin": {
setupBrewPack("make", version)
addPath("/usr/local/opt/make/libexec/gnubin")
await addPath("/usr/local/opt/make/libexec/gnubin")
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
}
case "linux": {
Expand Down
20 changes: 10 additions & 10 deletions src/msvc/__tests__/msvc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,64 @@ import { setupMSVC } from "../msvc"

jest.setTimeout(300000)
describe("setup-msvc", () => {
it("should setup the pre-installed msvc", () => {
it("should setup the pre-installed msvc", async () => {
try {
if (process.platform !== "win32") {
return
}
setupMSVC("", "", process.arch)
await setupMSVC("", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2022", () => {
it("should setup msvc 2022", async () => {
try {
if (process.platform !== "win32") {
return
}
setupMSVC("2022", "", process.arch)
await setupMSVC("2022", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2019", () => {
it("should setup msvc 2019", async () => {
try {
if (process.platform !== "win32") {
return
}
setupMSVC("2019", "", process.arch)
await setupMSVC("2019", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2017", () => {
it("should setup msvc 2017", async () => {
try {
if (process.platform !== "win32") {
return
}
setupMSVC("2017", "", process.arch)
await setupMSVC("2017", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2015", () => {
it("should setup msvc 2015", async () => {
try {
if (process.platform !== "win32") {
return
}
setupMSVC("2015", "", process.arch)
await setupMSVC("2015", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
Expand Down
12 changes: 6 additions & 6 deletions src/msvc/msvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { error, info, warning } from "../utils/io/io"

type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string

export function setupMSVC(
export async function setupMSVC(
versionGiven: MSVCVersion,
_setupDir: string,
arch: string,
Expand Down Expand Up @@ -41,19 +41,19 @@ export function setupMSVC(
try {
if (version === "14.0") {
toolset = "14.0"
setupChocoPack("visualcpp-build-tools", "14.0.25420.1", ["--ignore-dependencies"])
await setupChocoPack("visualcpp-build-tools", "14.0.25420.1", ["--ignore-dependencies"])
VCTargetsPath = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140"
} else if (version === "15.0") {
toolset = "14.16"
setupChocoPack("visualstudio2017buildtools", "15.9.41.0", [])
await setupChocoPack("visualstudio2017buildtools", "15.9.41.0", [])
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16" // TODO verify path
} else if (version === "16.0") {
toolset = "14.29"
setupChocoPack("visualstudio2019buildtools", "16.11.7.0", [])
await setupChocoPack("visualstudio2019buildtools", "16.11.7.0", [])
VCTargetsPath = "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133"
} else if (version === "17.0") {
toolset = undefined
setupChocoPack("visualstudio2022buildtools", "117.0.5.0", [])
await setupChocoPack("visualstudio2022buildtools", "117.0.5.0", [])
VCTargetsPath = undefined
} else {
error(`The given MSVC versions ${versionGiven} is not supported yet.`)
Expand All @@ -63,7 +63,7 @@ export function setupMSVC(
}
}
// run vcvarsall.bat environment variables
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
await setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)

if (isGitHubCI()) {
addMSVCLoggingMatcher()
Expand Down
Loading