Skip to content

Commit 0286b4c

Browse files
authored
Merge pull request #78 from aminya/spaces [skip ci]
fix: escape the spaces in LDFLAGS and CPPFLAGS
2 parents a78b699 + 1476cdd commit 0286b4c

File tree

8 files changed

+26
-6
lines changed

8 files changed

+26
-6
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.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@actions/exec": "^1.1.1",
3838
"@actions/io": "^1.1.2",
3939
"@actions/tool-cache": "^1.7.2",
40+
"escape-path-with-spaces": "^1.0.0",
4041
"execa": "^5.1.1",
4142
"mri": "^1.2.0",
4243
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/llvm/llvm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ export async function activateLLVM(directory: string, versionGiven: string) {
317317
}
318318
}
319319

320-
addEnv("LDFLAGS", `-L${directory}/lib`)
321-
addEnv("CPPFLAGS", `-I${directory}/include`)
320+
addEnv("LDFLAGS", `-L"${directory}/lib"`)
321+
addEnv("CPPFLAGS", `-I"${directory}/include"`)
322322

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

src/utils/env/addEnv.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { appendFileSync, existsSync, readFileSync } from "fs"
55
import { error, warning } from "../io/io"
66
import { execPowershell } from "../exec/powershell"
77
import { delimiter } from "path"
8+
import { escapeSpace } from "../path/escape_space"
89

910
/** An add path function that works locally or inside GitHub Actions */
10-
export function addEnv(name: string, val: string | undefined) {
11+
export function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
12+
const val = shouldEscapeSpace ? escapeSpace(valGiven) : valGiven
1113
try {
1214
if (isGitHubCI()) {
1315
exportVariable(name, val)

src/utils/path/escape_space.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-ignore
3+
import escape from "escape-path-with-spaces"
4+
5+
/// Escape the spaces in the given path
6+
export function escapeSpace(path: string | undefined): string {
7+
if (path === undefined) {
8+
return ""
9+
}
10+
return escape(path)
11+
}

src/utils/tests/test-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import spawn from "cross-spawn"
77
import { existsSync } from "fs"
88

99
export async function setupTmpDir(testName: string) {
10-
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
10+
const tempDirectory = path.join(tmpdir(), "setup cpp temp", testName)
1111
try {
1212
await io.rmRF(tempDirectory)
1313
await io.mkdirP(tempDirectory)

0 commit comments

Comments
 (0)