Skip to content

Commit ffd95a4

Browse files
Merge branch 'master' into test_runner_option
2 parents 3276af2 + 26f2fd3 commit ffd95a4

28 files changed

+1258
-518
lines changed

PACKAGING.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ copyright = "2020 Jane Programmer"
456456
[library]
457457
source-dir="src"
458458

459-
[[executable]]
459+
[[ executable ]]
460460
name="math_constants"
461461
source-dir="app"
462462
main="main.f90"
@@ -487,12 +487,12 @@ copyright = "2020 Jane Programmer"
487487
[library]
488488
source-dir="src"
489489

490-
[[executable]]
490+
[[ executable ]]
491491
name="math_constants"
492492
source-dir="app"
493493
main="main.f90"
494494

495-
[[test]]
495+
[[ test ]]
496496
name="runTests"
497497
source-dir="test"
498498
main="main.f90"
@@ -546,12 +546,12 @@ source-dir="src"
546546
[dependencies]
547547
helloff = { git = "https://gitlab.com/everythingfunctional/helloff.git" }
548548

549-
[[executable]]
549+
[[ executable ]]
550550
name="math_constants"
551551
source-dir="app"
552552
main="main.f90"
553553

554-
[[test]]
554+
[[ test ]]
555555
name="runTests"
556556
source-dir="test"
557557
main="main.f90"
@@ -601,14 +601,14 @@ copyright = "2020 Jane Programmer"
601601
[library]
602602
source-dir="src"
603603

604-
[[executable]]
604+
[[ executable ]]
605605
name="math_constants"
606606
source-dir="app"
607607
main="main.f90"
608608
[executable.dependencies]
609609
helloff = { git = "https://gitlab.com/everythingfunctional/helloff.git" }
610610

611-
[[test]]
611+
[[ test ]]
612612
name="runTests"
613613
source-dir="test"
614614
main="main.f90"
@@ -633,12 +633,12 @@ source-dir="src"
633633
[dev-dependencies]
634634
helloff = { git = "https://gitlab.com/everythingfunctional/helloff.git" }
635635

636-
[[executable]]
636+
[[ executable ]]
637637
name="math_constants"
638638
source-dir="app"
639639
main="main.f90"
640640

641-
[[test]]
641+
[[ test ]]
642642
name="runTests"
643643
source-dir="test"
644644
main="main.f90"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ to run, as can `fpm test`; like `fpm run specific_executable`. Command line
8181
arguments can also be passed to the executable(s) or test(s) with the option
8282
`--args "some arguments"`.
8383

84-
See additional instructions in the [Packaging guide](PACKAGING.md).
84+
See additional instructions in the [Packaging guide](PACKAGING.md) or
85+
the [manifest reference](manifest-reference.md).

bootstrap/src/Build.hs

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE MultiWayIf #-}
22
module Build
3-
( buildLibrary
3+
( CompilerSettings(..)
4+
, buildLibrary
45
, buildProgram
56
, buildWithScript
67
)
@@ -50,22 +51,28 @@ import System.Directory ( createDirectoryIfMissing
5051
, withCurrentDirectory
5152
)
5253

54+
data CompilerSettings = CompilerSettings {
55+
compilerSettingsCompiler :: FilePath
56+
, compilerSettingsFlags :: [String]
57+
, compilerSettingsModuleFlag :: String
58+
, compilerSettingsIncludeFlag :: String
59+
}
60+
5361
buildProgram
5462
:: FilePath
5563
-> [FilePath]
5664
-> [FilePattern]
5765
-> FilePath
58-
-> FilePath
59-
-> [String]
66+
-> CompilerSettings
6067
-> String
6168
-> FilePath
6269
-> [FilePath]
6370
-> IO ()
64-
buildProgram programDirectory' libraryDirectories sourceExtensions buildDirectory' compiler flags programName programSource archives
71+
buildProgram programDirectory' libraryDirectories sourceExtensions buildDirectory' (CompilerSettings { compilerSettingsCompiler = compiler, compilerSettingsFlags = flags, compilerSettingsModuleFlag = moduleFlag, compilerSettingsIncludeFlag = includeFlag }) programName programSource archives
6572
= do
6673
let programDirectory = foldl1 (</>) (splitDirectories programDirectory')
67-
let buildDirectory = foldl1 (</>) (splitDirectories buildDirectory')
68-
let includeFlags = map ("-I" ++) libraryDirectories
74+
let buildDirectory = foldl1 (</>) (splitDirectories buildDirectory')
75+
let includeFlags = map (includeFlag ++) libraryDirectories
6976
sourceFiles <- getDirectoriesFiles [programDirectory] sourceExtensions
7077
rawSources <- mapM sourceFileToRawSource sourceFiles
7178
let sources' = map processRawSource rawSources
@@ -98,28 +105,28 @@ buildProgram programDirectory' libraryDirectories sourceExtensions buildDirector
98105
in fileMatcher &?> \(objectFile : _) -> do
99106
need (sourceFile : directDependencies)
100107
cmd compiler
101-
["-c", "-J" ++ buildDirectory]
108+
["-c", moduleFlag ++ buildDirectory]
102109
includeFlags
103110
flags
104111
["-o", objectFile, sourceFile]
105112
want [buildDirectory </> programName <.> exe]
106113
buildDirectory </> programName <.> exe %> \executable -> do
107114
need objectFiles
115+
need archives
108116
cmd compiler objectFiles archives ["-o", executable] flags
109117
mapM_ infoToRule compileTimeInfo
110118

111119
buildLibrary
112120
:: FilePath
113121
-> [FilePattern]
114122
-> FilePath
115-
-> FilePath
116-
-> [String]
123+
-> CompilerSettings
117124
-> String
118125
-> [FilePath]
119126
-> IO (FilePath)
120-
buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags libraryName otherLibraryDirectories
127+
buildLibrary libraryDirectory sourceExtensions buildDirectory (CompilerSettings { compilerSettingsCompiler = compiler, compilerSettingsFlags = flags, compilerSettingsModuleFlag = moduleFlag, compilerSettingsIncludeFlag = includeFlag }) libraryName otherLibraryDirectories
121128
= do
122-
let includeFlags = map ("-I" ++) otherLibraryDirectories
129+
let includeFlags = map (includeFlag ++) otherLibraryDirectories
123130
sourceFiles <- getDirectoriesFiles [libraryDirectory] sourceExtensions
124131
rawSources <- mapM sourceFileToRawSource sourceFiles
125132
let sources = map processRawSource rawSources
@@ -149,7 +156,7 @@ buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags lib
149156
in fileMatcher &?> \(objectFile : _) -> do
150157
need (sourceFile : directDependencies)
151158
cmd compiler
152-
["-c", "-J" ++ buildDirectory]
159+
["-c", moduleFlag ++ buildDirectory]
153160
includeFlags
154161
flags
155162
["-o", objectFile, sourceFile]
@@ -164,18 +171,19 @@ buildWithScript
164171
:: String
165172
-> FilePath
166173
-> FilePath
167-
-> FilePath
168-
-> [String]
174+
-> CompilerSettings
169175
-> String
170176
-> [FilePath]
171177
-> IO (FilePath)
172-
buildWithScript script projectDirectory buildDirectory compiler flags libraryName otherLibraryDirectories
178+
buildWithScript script projectDirectory buildDirectory (CompilerSettings { compilerSettingsCompiler = compiler, compilerSettingsFlags = flags, compilerSettingsModuleFlag = moduleFlag, compilerSettingsIncludeFlag = includeFlag }) libraryName otherLibraryDirectories
173179
= do
174180
absoluteBuildDirectory <- makeAbsolute buildDirectory
175181
createDirectoryIfMissing True absoluteBuildDirectory
176182
absoluteLibraryDirectories <- mapM makeAbsolute otherLibraryDirectories
177-
setEnv "FC" compiler
178-
setEnv "FFLAGS" (intercalate " " flags)
183+
setEnv "FC" compiler
184+
setEnv "FFLAGS" (intercalate " " flags)
185+
setEnv "FINCLUDEFLAG" includeFlag
186+
setEnv "FMODUELFLAG" moduleFlag
179187
setEnv "BUILD_DIR" $ unWindowsPath absoluteBuildDirectory
180188
setEnv "INCLUDE_DIRS"
181189
(intercalate " " (map unWindowsPath absoluteLibraryDirectories))

0 commit comments

Comments
 (0)