aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Richardson <brichardson@structint.com>2020-06-14 20:42:45 -0700
committerBrad Richardson <brichardson@structint.com>2020-06-14 20:42:45 -0700
commit5fae72c579869e6e2636ef38e47d91e3877dc47f (patch)
tree0e3430fae1683aebd49b06530e26c14943aa29a1
parent100d30c57ffafb06b13d655bce5a09b518f732f1 (diff)
downloadfpm-5fae72c579869e6e2636ef38e47d91e3877dc47f.tar.gz
fpm-5fae72c579869e6e2636ef38e47d91e3877dc47f.zip
Try using Linux like paths for build scripts
-rw-r--r--package.yaml1
-rw-r--r--src/Build.hs28
2 files changed, 21 insertions, 8 deletions
diff --git a/package.yaml b/package.yaml
index ece47c9..7cf11c6 100644
--- a/package.yaml
+++ b/package.yaml
@@ -25,6 +25,7 @@ dependencies:
- directory
- extra
- filepath
+- MissingH
- optparse-applicative
- process
- shake
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 "\\" "/"