Skip to content

Commit

Permalink
Merge pull request #50 from TravisWhitaker/windows-escape
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcdonell committed Oct 24, 2017
2 parents 75e6732 + f486338 commit 707a321
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit 707a321

Please sign in to comment.