aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Richardson <brichardson@structint.com>2020-05-23 20:43:04 -0700
committerBrad Richardson <brichardson@structint.com>2020-05-23 20:43:04 -0700
commitd89214ba52c968a950dc3118f54b8547350536d9 (patch)
tree6783b1360272411f8e51aebd6f17678fadc1c23a
parentb5a1ada4f24a4334dcaef6d2d8dcfb53e17ecc6c (diff)
downloadfpm-d89214ba52c968a950dc3118f54b8547350536d9.tar.gz
fpm-d89214ba52c968a950dc3118f54b8547350536d9.zip
Add path dependencies and a test to make sure it works
-rw-r--r--hello_fpm/.gitignore1
-rw-r--r--hello_fpm/app/main.f909
-rw-r--r--hello_fpm/fpm.toml4
-rw-r--r--src/Fpm.hs15
-rw-r--r--test/Spec.hs5
5 files changed, 33 insertions, 1 deletions
diff --git a/hello_fpm/.gitignore b/hello_fpm/.gitignore
new file mode 100644
index 0000000..a007fea
--- /dev/null
+++ b/hello_fpm/.gitignore
@@ -0,0 +1 @@
+build/*
diff --git a/hello_fpm/app/main.f90 b/hello_fpm/app/main.f90
new file mode 100644
index 0000000..5df6d64
--- /dev/null
+++ b/hello_fpm/app/main.f90
@@ -0,0 +1,9 @@
+program hello_fpm
+ use farewell_m, only: make_farewell
+ use greet_m, only: make_greeting
+
+ implicit none
+
+ print *, make_greeting("fpm")
+ print *, make_farewell("fpm")
+end program hello_fpm
diff --git a/hello_fpm/fpm.toml b/hello_fpm/fpm.toml
new file mode 100644
index 0000000..d94d904
--- /dev/null
+++ b/hello_fpm/fpm.toml
@@ -0,0 +1,4 @@
+name = "hello_fpm"
+
+[dependencies]
+hello_complex = { path = "../hello_complex" }
diff --git a/src/Fpm.hs b/src/Fpm.hs
index c3b682a..253bc85 100644
--- a/src/Fpm.hs
+++ b/src/Fpm.hs
@@ -81,12 +81,14 @@ data Executable = Executable {
, executableName :: String
}
-data Version = SimpleVersion String | GitVersion GitVersionSpec
+data Version = SimpleVersion String | GitVersion GitVersionSpec | PathVersion PathVersionSpec
data GitVersionSpec = GitVersionSpec { gitVersionSpecUrl :: String, gitVersionSpecRef :: Maybe GitRef }
data GitRef = Tag String | Branch String | Commit String
+data PathVersionSpec = PathVersionSpec { pathVersionSpecPath :: String }
+
data Command = Run | Test | Build
data DependencyTree = Dependency {
@@ -263,6 +265,11 @@ matchGitVersion = \case
GitVersion v -> Just v
_ -> Nothing
+matchPathVersion :: Version -> Maybe PathVersionSpec
+matchPathVersion = \case
+ PathVersion v -> Just v
+ _ -> Nothing
+
matchTag :: GitRef -> Maybe String
matchTag = \case
Tag v -> Just v
@@ -282,6 +289,7 @@ versionCodec :: Toml.Key -> Toml.TomlCodec Version
versionCodec key =
Toml.dimatch matchSimpleVersion SimpleVersion (Toml.string key)
<|> Toml.dimatch matchGitVersion GitVersion (Toml.table gitVersionCodec key)
+ <|> Toml.dimatch matchPathVersion PathVersion (Toml.table pathVersionCodec key)
gitVersionCodec :: Toml.TomlCodec GitVersionSpec
gitVersionCodec =
@@ -297,6 +305,10 @@ gitRefCodec =
<|> Toml.dimatch matchBranch Branch (Toml.string "branch")
<|> Toml.dimatch matchCommit Commit (Toml.string "rev")
+pathVersionCodec :: Toml.TomlCodec PathVersionSpec
+pathVersionCodec =
+ PathVersionSpec <$> Toml.string "path" .= pathVersionSpecPath
+
toml2AppSettings :: TomlSettings -> Bool -> IO AppSettings
toml2AppSettings tomlSettings release = do
let projectName = tomlSettingsProjectName tomlSettings
@@ -452,6 +464,7 @@ fetchDependency name version = do
)
return (name, clonePath)
Nothing -> return (name, clonePath)
+ PathVersion versionSpec -> return (name, pathVersionSpecPath versionSpec)
{-
Bulding the dependencies is done on a depth first basis to ensure all of
diff --git a/test/Spec.hs b/test/Spec.hs
index cd10913..dfa70d6 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -9,6 +9,7 @@ main :: IO ()
main = do
testHelloWorld
testHelloComplex
+ testHelloFpm
testHelloWorld :: IO ()
testHelloWorld =
@@ -17,3 +18,7 @@ testHelloWorld =
testHelloComplex :: IO ()
testHelloComplex =
withCurrentDirectory "hello_complex" $ start $ Arguments Test False
+
+testHelloFpm :: IO ()
+testHelloFpm =
+ withCurrentDirectory "hello_fpm" $ start $ Arguments Run False