Merge pull request #78 from aminya/spaces [skip ci]

fix: escape the spaces in LDFLAGS and CPPFLAGS
This commit is contained in:
Amin Yahyaabadi 2022-05-11 21:38:12 -07:00 committed by GitHub
commit 0286b4c7c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 6 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -37,6 +37,7 @@
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2",
"@actions/tool-cache": "^1.7.2",
"escape-path-with-spaces": "^1.0.0",
"execa": "^5.1.1",
"mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",

View File

@ -23,6 +23,7 @@ specifiers:
cross-env: 7.0.3
cross-spawn: ^7.0.3
cspell: ^5.20.0
escape-path-with-spaces: ^1.0.0
eslint: ^8.14.0
eslint-config-atomic: ^1.17.1
execa: ^5.1.1
@ -52,6 +53,7 @@ dependencies:
'@actions/exec': 1.1.1
'@actions/io': 1.1.2
'@actions/tool-cache': 1.7.2
escape-path-with-spaces: 1.0.0
execa: 5.1.1
mri: 1.2.0
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
@ -3588,6 +3590,10 @@ packages:
engines: {node: '>=8'}
dev: true
/escape-path-with-spaces/1.0.0:
resolution: {integrity: sha512-+98Hh0yzVa0hldJXlzr0M/8B8LVXW9vNT5boC9k6o896Z52DGRplm3NwMGX0590ryGSegzTf/uaUiusFj2SQbQ==}
dev: false
/escape-string-regexp/1.0.5:
resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=}
engines: {node: '>=0.8.0'}

View File

@ -317,8 +317,8 @@ export async function activateLLVM(directory: string, versionGiven: string) {
}
}
addEnv("LDFLAGS", `-L${directory}/lib`)
addEnv("CPPFLAGS", `-I${directory}/include`)
addEnv("LDFLAGS", `-L"${directory}/lib"`)
addEnv("CPPFLAGS", `-I"${directory}/include"`)
addEnv("CC", `${directory}/bin/clang`)
addEnv("CXX", `${directory}/bin/clang++`)

View File

@ -5,9 +5,11 @@ import { appendFileSync, existsSync, readFileSync } from "fs"
import { error, warning } from "../io/io"
import { execPowershell } from "../exec/powershell"
import { delimiter } from "path"
import { escapeSpace } from "../path/escape_space"
/** An add path function that works locally or inside GitHub Actions */
export function addEnv(name: string, val: string | undefined) {
export function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
const val = shouldEscapeSpace ? escapeSpace(valGiven) : valGiven
try {
if (isGitHubCI()) {
exportVariable(name, val)

View File

@ -0,0 +1,11 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import escape from "escape-path-with-spaces"
/// Escape the spaces in the given path
export function escapeSpace(path: string | undefined): string {
if (path === undefined) {
return ""
}
return escape(path)
}

View File

@ -7,7 +7,7 @@ import spawn from "cross-spawn"
import { existsSync } from "fs"
export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
const tempDirectory = path.join(tmpdir(), "setup cpp temp", testName)
try {
await io.rmRF(tempDirectory)
await io.mkdirP(tempDirectory)