Skip to content

Commit a8d76c6

Browse files
committed
fix: unset LLVM CPPFLAGS when llvm is not used as the compiler
1 parent 6ed018c commit a8d76c6

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ export async function main(args: string[]): Promise<number> {
160160
return 1
161161
}
162162

163+
let hasLLVM = false // used to unset CPPFLAGS of LLVM when other compilers are used as the main compiler
164+
163165
// loop over the tools and run their setup function
164166
for (const tool of tools) {
165167
// get the version or "true" or undefined for this tool from the options
@@ -187,8 +189,10 @@ export async function main(args: string[]): Promise<number> {
187189
// get the setup function
188190
const setupFunction = setups[tool]
189191

192+
hasLLVM = ["llvm", "clangformat", "clangtidy"].includes(tool)
193+
190194
// the tool installation directory (for the functions that ue it)
191-
const setupDir = join(setupCppDir, ["llvm", "clangformat", "clangtidy"].includes(tool) ? "llvm" : tool)
195+
const setupDir = join(setupCppDir, hasLLVM ? "llvm" : tool)
192196

193197
// eslint-disable-next-line no-await-in-loop
194198
installationInfo = await setupFunction(getVersion(tool, version, osVersion), setupDir, arch)
@@ -232,6 +236,12 @@ export async function main(args: string[]): Promise<number> {
232236
case "cygwin":
233237
case "msys": {
234238
const installationInfo = await setupGcc(getVersion("gcc", version, osVersion), join(setupCppDir, "gcc"), arch)
239+
240+
if (hasLLVM) {
241+
// remove the CPPFLAGS of LLVM that include the LLVM headers
242+
await addEnv("CPPFLAGS", "")
243+
}
244+
235245
successMessages.push(getSuccessMessage("gcc", installationInfo))
236246
break
237247
}
@@ -247,6 +257,12 @@ export async function main(args: string[]): Promise<number> {
247257
join(setupCppDir, "msvc"),
248258
arch
249259
)
260+
261+
if (hasLLVM) {
262+
// remove the CPPFLAGS of LLVM that include the LLVM headers
263+
await addEnv("CPPFLAGS", "")
264+
}
265+
250266
successMessages.push(getSuccessMessage("msvc", installationInfo))
251267
break
252268
}

0 commit comments

Comments
 (0)