Skip to content

Add compiler to build path #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ license = "MIT"
author = "Jane Programmer"
maintainer = "[email protected]"
copyright = "2020 Jane Programmer"
compiler = "gfortran"
```

The preamble includes some metadata, such as `license`, `author`, and similar,
Expand Down Expand Up @@ -462,7 +461,6 @@ license = "MIT"
author = "Jane Programmer"
maintainer = "[email protected]"
copyright = "2020 Jane Programmer"
compiler = "gfortran"

[library]
source-dir="src"
Expand Down Expand Up @@ -493,7 +491,6 @@ license = "MIT"
author = "Jane Programmer"
maintainer = "[email protected]"
copyright = "2020 Jane Programmer"
compiler = "gfortran"

[library]
source-dir="src"
Expand Down
1 change: 0 additions & 1 deletion hello_complex/fpm.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name = "hello_complex"
compiler = "gfortran"

[library]
source-dir="source"
Expand Down
1 change: 0 additions & 1 deletion hello_world/fpm.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
name = "hello_world"
compiler = "gfortran"
20 changes: 12 additions & 8 deletions src/Fpm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ import qualified Toml
data Arguments = Arguments { command' :: Command, release :: Bool }

data TomlSettings = TomlSettings {
tomlSettingsCompiler :: String
, tomlSettingsProjectName :: String
tomlSettingsProjectName :: String
, tomlSettingsLibrary :: (Maybe Library)
, tomlSettingsExecutables :: [Executable]
, tomlSettingsTests :: [Executable]
Expand Down Expand Up @@ -200,9 +199,7 @@ getDirectoriesFiles dirs exts = getDirectoryFilesIO "" newPatterns
settingsCodec :: TomlCodec TomlSettings
settingsCodec =
TomlSettings
<$> Toml.string "compiler"
.= tomlSettingsCompiler
<*> Toml.string "name"
<$> Toml.string "name"
.= tomlSettingsProjectName
<*> Toml.dioptional (Toml.table libraryCodec "library")
.= tomlSettingsLibrary
Expand All @@ -227,16 +224,17 @@ executableCodec =
toml2AppSettings :: TomlSettings -> Bool -> IO AppSettings
toml2AppSettings tomlSettings release = do
let projectName = tomlSettingsProjectName tomlSettings
let compiler = "gfortran"
librarySettings <- getLibrarySettings $ tomlSettingsLibrary tomlSettings
executableSettings <- getExecutableSettings
(tomlSettingsExecutables tomlSettings)
projectName
testSettings <- getTestSettings $ tomlSettingsTests tomlSettings
buildPrefix <- makeBuildPrefix compiler release
return AppSettings
{ appSettingsCompiler = tomlSettingsCompiler tomlSettings
{ appSettingsCompiler = compiler
, appSettingsProjectName = projectName
, appSettingsBuildPrefix = "build"
</> if release then "release" else "debug"
, appSettingsBuildPrefix = buildPrefix
, appSettingsFlags = if release
then
[ "-Wall"
Expand Down Expand Up @@ -307,3 +305,9 @@ getTestSettings [] = do
else return []
else return []
getTestSettings tests = return tests

makeBuildPrefix :: String -> Bool -> IO String
makeBuildPrefix compiler release =
-- TODO Figure out what other info should be part of this
-- Probably version, and make sure to not include path to the compiler
Copy link
Member

@LKedward LKedward May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I think we will need compiler version eventually since they're not compatible between versions.

return $ "build" </> compiler ++ "_" ++ if release then "release" else "debug"