Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape backslashes used in -D flags on Windows. #50

Merged
merged 1 commit into from
Oct 24, 2017
Merged
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
12 changes: 10 additions & 2 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ main = defaultMainWithHooks customHooks
let pkg_descr' = updatePackageDescription actualBuildInfoToUse pkg_descr
postConf simpleUserHooks args flags pkg_descr' lbi

escBackslash :: FilePath -> FilePath
escBackslash [] = []
escBackslash ('\\':fs) = '\\' : '\\' : escBackslash fs
escBackslash (f:fs) = f : escBackslash fs

-- Generates build info with flags needed for CUDA Toolkit to be properly
-- visible to underlying build tools.
Expand All @@ -119,10 +123,14 @@ libraryBuildInfo profile installPath platform@(Platform arch os) ghcVersion = do
libraryPath = cudaLibraryPath platform installPath
includePath = cudaIncludePath platform installPath

-- OS-specific escaping for -D path defines
escDefPath | os == Windows = escBackslash
| otherwise = id

-- options for GHC
extraLibDirs' = [ libraryPath ]
ccOptions' = [ "-DCUDA_INSTALL_PATH=\"" ++ installPath ++ "\""
, "-DCUDA_LIBRARY_PATH=\"" ++ libraryPath ++ "\""
ccOptions' = [ "-DCUDA_INSTALL_PATH=\"" ++ escDefPath installPath ++ "\""
, "-DCUDA_LIBRARY_PATH=\"" ++ escDefPath libraryPath ++ "\""
, "-I" ++ includePath ]
ldOptions' = [ "-L" ++ libraryPath ]
ghcOptions = map ("-optc"++) ccOptions'
Expand Down