aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/src/Build.hs
diff options
context:
space:
mode:
authorBrad Richardson <everythingfunctional@protonmail.com>2020-11-12 12:09:13 -0600
committerGitHub <noreply@github.com>2020-11-12 12:09:13 -0600
commit26f2fd3d3ee0cce09a880ec273a5e5f4914d8b35 (patch)
treeee62b672036ad9fe1a566b5552831dd6f44772e6 /bootstrap/src/Build.hs
parente1af93fad218e0d81ecf0f3303e6bba0816d1bbf (diff)
parent5ae9d75cbe87590baddf6b233286b6221b74657e (diff)
downloadfpm-26f2fd3d3ee0cce09a880ec273a5e5f4914d8b35.tar.gz
fpm-26f2fd3d3ee0cce09a880ec273a5e5f4914d8b35.zip
Merge pull request #220 from everythingfunctional/compiler_and_flags
Compiler and flags
Diffstat (limited to 'bootstrap/src/Build.hs')
-rw-r--r--bootstrap/src/Build.hs41
1 files changed, 24 insertions, 17 deletions
diff --git a/bootstrap/src/Build.hs b/bootstrap/src/Build.hs
index 3f647cd..e4f9992 100644
--- a/bootstrap/src/Build.hs
+++ b/bootstrap/src/Build.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE MultiWayIf #-}
module Build
- ( buildLibrary
+ ( CompilerSettings(..)
+ , buildLibrary
, buildProgram
, buildWithScript
)
@@ -50,22 +51,28 @@ import System.Directory ( createDirectoryIfMissing
, withCurrentDirectory
)
+data CompilerSettings = CompilerSettings {
+ compilerSettingsCompiler :: FilePath
+ , compilerSettingsFlags :: [String]
+ , compilerSettingsModuleFlag :: String
+ , compilerSettingsIncludeFlag :: String
+}
+
buildProgram
:: FilePath
-> [FilePath]
-> [FilePattern]
-> FilePath
- -> FilePath
- -> [String]
+ -> CompilerSettings
-> String
-> FilePath
-> [FilePath]
-> IO ()
-buildProgram programDirectory' libraryDirectories sourceExtensions buildDirectory' compiler flags programName programSource archives
+buildProgram programDirectory' libraryDirectories sourceExtensions buildDirectory' (CompilerSettings { compilerSettingsCompiler = compiler, compilerSettingsFlags = flags, compilerSettingsModuleFlag = moduleFlag, compilerSettingsIncludeFlag = includeFlag }) programName programSource archives
= do
let programDirectory = foldl1 (</>) (splitDirectories programDirectory')
- let buildDirectory = foldl1 (</>) (splitDirectories buildDirectory')
- let includeFlags = map ("-I" ++) libraryDirectories
+ let buildDirectory = foldl1 (</>) (splitDirectories buildDirectory')
+ let includeFlags = map (includeFlag ++) libraryDirectories
sourceFiles <- getDirectoriesFiles [programDirectory] sourceExtensions
rawSources <- mapM sourceFileToRawSource sourceFiles
let sources' = map processRawSource rawSources
@@ -98,7 +105,7 @@ buildProgram programDirectory' libraryDirectories sourceExtensions buildDirector
in fileMatcher &?> \(objectFile : _) -> do
need (sourceFile : directDependencies)
cmd compiler
- ["-c", "-J" ++ buildDirectory]
+ ["-c", moduleFlag ++ buildDirectory]
includeFlags
flags
["-o", objectFile, sourceFile]
@@ -113,14 +120,13 @@ buildLibrary
:: FilePath
-> [FilePattern]
-> FilePath
- -> FilePath
- -> [String]
+ -> CompilerSettings
-> String
-> [FilePath]
-> IO (FilePath)
-buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags libraryName otherLibraryDirectories
+buildLibrary libraryDirectory sourceExtensions buildDirectory (CompilerSettings { compilerSettingsCompiler = compiler, compilerSettingsFlags = flags, compilerSettingsModuleFlag = moduleFlag, compilerSettingsIncludeFlag = includeFlag }) libraryName otherLibraryDirectories
= do
- let includeFlags = map ("-I" ++) otherLibraryDirectories
+ let includeFlags = map (includeFlag ++) otherLibraryDirectories
sourceFiles <- getDirectoriesFiles [libraryDirectory] sourceExtensions
rawSources <- mapM sourceFileToRawSource sourceFiles
let sources = map processRawSource rawSources
@@ -150,7 +156,7 @@ buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags lib
in fileMatcher &?> \(objectFile : _) -> do
need (sourceFile : directDependencies)
cmd compiler
- ["-c", "-J" ++ buildDirectory]
+ ["-c", moduleFlag ++ buildDirectory]
includeFlags
flags
["-o", objectFile, sourceFile]
@@ -165,18 +171,19 @@ buildWithScript
:: String
-> FilePath
-> FilePath
- -> FilePath
- -> [String]
+ -> CompilerSettings
-> String
-> [FilePath]
-> IO (FilePath)
-buildWithScript script projectDirectory buildDirectory compiler flags libraryName otherLibraryDirectories
+buildWithScript script projectDirectory buildDirectory (CompilerSettings { compilerSettingsCompiler = compiler, compilerSettingsFlags = flags, compilerSettingsModuleFlag = moduleFlag, compilerSettingsIncludeFlag = includeFlag }) libraryName otherLibraryDirectories
= do
absoluteBuildDirectory <- makeAbsolute buildDirectory
createDirectoryIfMissing True absoluteBuildDirectory
absoluteLibraryDirectories <- mapM makeAbsolute otherLibraryDirectories
- setEnv "FC" compiler
- setEnv "FFLAGS" (intercalate " " flags)
+ setEnv "FC" compiler
+ setEnv "FFLAGS" (intercalate " " flags)
+ setEnv "FINCLUDEFLAG" includeFlag
+ setEnv "FMODUELFLAG" moduleFlag
setEnv "BUILD_DIR" $ unWindowsPath absoluteBuildDirectory
setEnv "INCLUDE_DIRS"
(intercalate " " (map unWindowsPath absoluteLibraryDirectories))