From 5fae72c579869e6e2636ef38e47d91e3877dc47f Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Sun, 14 Jun 2020 20:42:45 -0700 Subject: Try using Linux like paths for build scripts --- src/Build.hs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Build.hs b/src/Build.hs index 7646ed6..c7519e5 100644 --- a/src/Build.hs +++ b/src/Build.hs @@ -15,6 +15,7 @@ import Data.Char ( isAsciiLower import Data.List ( intercalate , isSuffixOf ) +import Data.List.Utils ( replace ) import qualified Data.Map as Map import Data.Maybe ( fromMaybe , mapMaybe @@ -383,11 +384,17 @@ buildWithScript script projectDirectory buildDirectory compiler flags libraryNam absoluteBuildDirectory <- makeAbsolute buildDirectory createDirectoryIfMissing True absoluteBuildDirectory absoluteLibraryDirectories <- mapM makeAbsolute otherLibraryDirectories - setEnv "FC" compiler - setEnv "FFLAGS" (intercalate " " flags) - setEnv "BUILD_DIR" $ removeDriveLetter absoluteBuildDirectory - setEnv "INCLUDE_DIRS" (intercalate " " (map removeDriveLetter absoluteLibraryDirectories)) - let archiveFile = (removeDriveLetter absoluteBuildDirectory) "lib" ++ libraryName <.> "a" + setEnv "FC" compiler + setEnv "FFLAGS" (intercalate " " flags) + setEnv "BUILD_DIR" $ unWindowsPath absoluteBuildDirectory + setEnv + "INCLUDE_DIRS" + (intercalate " " (map unWindowsPath absoluteLibraryDirectories)) + let archiveFile = + (removeDriveLetter absoluteBuildDirectory) + "lib" + ++ libraryName + <.> "a" withCurrentDirectory projectDirectory if @@ -402,7 +409,12 @@ isMakefile script | script == "Makefile" = True | ".mk" `isSuffixOf` script = True | otherwise = False +unWindowsPath :: String -> String +unWindowsPath = changeSeparators . removeDriveLetter + removeDriveLetter :: String -> String -removeDriveLetter path - | ':' `elem` path = (tail . dropWhile (/= ':')) path - | otherwise = path +removeDriveLetter path | ':' `elem` path = (tail . dropWhile (/= ':')) path + | otherwise = path + +changeSeparators :: String -> String +changeSeparators = replace "\\" "/" -- cgit v1.2.3