aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Richardson <everythingfunctional@protonmail.com>2020-02-25 14:00:21 -0800
committerGitHub <noreply@github.com>2020-02-25 14:00:21 -0800
commit5d38dffc1023cef688e055019fa2569618cf1a4d (patch)
tree7b13ccc55588d467708c20f14b114cc56bb93b0b
parent2292bbd1d57c97d800e87e1cb6ccd1981ad50333 (diff)
parentd9cd40f9d84e104207f8ef34c6d5a4f9d1b3af4b (diff)
downloadfpm-5d38dffc1023cef688e055019fa2569618cf1a4d.tar.gz
fpm-5d38dffc1023cef688e055019fa2569618cf1a4d.zip
Merge pull request #40 from everythingfunctional/master
Switch to using Haskell
-rw-r--r--.github/workflows/CI.yml30
-rw-r--r--.gitignore5
-rw-r--r--ChangeLog.md3
-rw-r--r--README.md37
-rw-r--r--Setup.hs2
-rw-r--r--app/Main.hs43
-rw-r--r--archive/.gitignore2
-rw-r--r--archive/Cargo.lock (renamed from Cargo.lock)0
-rw-r--r--archive/Cargo.toml (renamed from Cargo.toml)0
-rwxr-xr-xarchive/ci/install_cmake.sh (renamed from ci/install_cmake.sh)0
-rw-r--r--archive/src/main.rs (renamed from src/main.rs)0
-rw-r--r--archive/tests/1/a.f90 (renamed from tests/1/a.f90)0
-rw-r--r--archive/tests/1/b.f90 (renamed from tests/1/b.f90)0
-rw-r--r--archive/tests/1/fpm.toml (renamed from tests/1/fpm.toml)0
-rw-r--r--archive/tests/1/main.f90 (renamed from tests/1/main.f90)0
-rw-r--r--archive/tests/2/fpm.toml (renamed from tests/2/fpm.toml)0
-rw-r--r--archive/tests/2/main.f90 (renamed from tests/2/main.f90)0
-rw-r--r--archive/tests/cli.rs (renamed from tests/cli.rs)0
-rw-r--r--package.yaml49
-rw-r--r--src/Lib.hs6
-rw-r--r--stack.yaml66
-rw-r--r--stack.yaml.lock12
-rw-r--r--test/Spec.hs2
23 files changed, 220 insertions, 37 deletions
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index fcc50b6..946caba 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -4,9 +4,6 @@ on: [push, pull_request]
env:
CI: "ON" # We can detect this in the build system and other vendors implement it
- CMAKE_BUILD_PARALLEL_LEVEL: "2" # 2 cores on each GHA VM, enable parallel builds
- CTEST_OUTPUT_ON_FAILURE: "ON" # This way we don't need a flag to ctest
- CTEST_PARALLEL_LEVEL: "2"
HOMEBREW_NO_ANALYTICS: "ON" # Make Homebrew installation a little quicker
HOMEBREW_NO_AUTO_UPDATE: "ON"
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON"
@@ -22,7 +19,6 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
gcc_v: [9] # Version of GFortran we want to use.
- rust: [stable]
env:
FC: gfortran
GCC_V: ${{ matrix.gcc_v }}
@@ -31,9 +27,19 @@ jobs:
- name: Checkout code
uses: actions/checkout@v1
- - name: Install CMake Linux
- if: contains(matrix.os, 'ubuntu')
- run: ci/install_cmake.sh
+ - name: Install Haskell Linux / macOS
+ if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
+ uses: mstksg/setup-stack@v1
+
+ - name: Install Haskell Windows
+ if: contains(matrix.os, 'windows')
+ run: |
+ (New-Object System.Net.WebClient).DownloadFile("https://get.haskellstack.org/stable/windows-x86_64.zip", "windows-x86_64.zip")
+ mkdir stack-tmp
+ cd stack-tmp
+ unzip ..\windows-x86_64.zip
+ copy stack.exe "C:\Program Files\Git\usr\bin"
+ cd ..
- name: Install GFortran Linux
if: contains(matrix.os, 'ubuntu')
@@ -42,16 +48,10 @@ jobs:
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
--slave /usr/bingcov gcov /usr/bin/gcov-${GCC_V}
-
- - name: Install Rust
- uses: hecrj/setup-rust-action@v1
- with:
- rust-version: ${{ matrix.rust }}
-
- name: Build
run: |
- cargo test --verbose --no-run
+ stack build
- name: Run tests
run: |
- cargo test
+ stack test
diff --git a/.gitignore b/.gitignore
index 53eaa21..50e5ce9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
-/target
-**/*.rs.bk
+.stack-work/
+fpm.cabal
+*~ \ No newline at end of file
diff --git a/ChangeLog.md b/ChangeLog.md
new file mode 100644
index 0000000..b6fab63
--- /dev/null
+++ b/ChangeLog.md
@@ -0,0 +1,3 @@
+# Changelog for fpm
+
+## Unreleased changes
diff --git a/README.md b/README.md
index e6e23c1..b767268 100644
--- a/README.md
+++ b/README.md
@@ -4,29 +4,26 @@ A prototype version.
## How to try it out
-Install Rust, then:
-```
-cargo build
-```
-Go to a test directory and execute:
+### Install Haskell
+
+Install Haskell Stack from (https://haskellstack.org/). E.g., to install on
+Linux without root access, follow the [manual download](https://docs.haskellstack.org/en/stable/install_and_upgrade/#manual-download_2):
```
-cd tests/1
-../../target/debug/fpm build
-../../target/debug/fpm run
+wget https://get.haskellstack.org/stable/linux-x86_64-static.tar.gz
+tar xaf linux-x86_64-static.tar.gz
```
-And the same in the other test directory (one can also call `run` directly):
+and put the `stack` binary in your path, for example by:
```
-cd tests/2
-../../target/debug/fpm run
+export PATH="$PATH:`pwd`/stack-2.1.3-linux-x86_64-static/"
```
-## Development Details
-
-The command line interface (CLI) program `fpm` is build according to the
-following Rust CLI tutorial:
-
-https://rust-cli.github.io/book/index.html
+### Build and Test FPM
-and the user API is inspired by Cargo. Here is Cargo project layout:
-
-https://doc.rust-lang.org/cargo/guide/project-layout.html
+Build using:
+```
+stack build
+```
+To test:
+```
+stack test
+```
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
index 0000000..9a994af
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/app/Main.hs b/app/Main.hs
new file mode 100644
index 0000000..9d9c5dc
--- /dev/null
+++ b/app/Main.hs
@@ -0,0 +1,43 @@
+module Main where
+
+import Options.Applicative
+
+newtype Arguments = Arguments { command' :: Command }
+
+data Command = Run | Test | Build
+
+main :: IO ()
+main = do
+ args <- getArguments
+ run args
+
+run :: Arguments -> IO ()
+run args = case command' args of
+ Run -> putStrLn "Run"
+ Test -> putStrLn "Test"
+ Build -> putStrLn "Build"
+
+getArguments :: IO Arguments
+getArguments = execParser
+ (info
+ (arguments <**> helper)
+ (fullDesc <> progDesc "Work with Fortran projects" <> header
+ "fpm - A Fortran package manager and build system"
+ )
+ )
+
+arguments :: Parser Arguments
+arguments = subparser
+ ( command "run" (info runArguments (progDesc "Run the executable"))
+ <> command "test" (info testArguments (progDesc "Run the tests"))
+ <> command "build" (info buildArguments (progDesc "Build the executable"))
+ )
+
+runArguments :: Parser Arguments
+runArguments = pure $ Arguments Run
+
+testArguments :: Parser Arguments
+testArguments = pure $ Arguments Test
+
+buildArguments :: Parser Arguments
+buildArguments = pure $ Arguments Build
diff --git a/archive/.gitignore b/archive/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/archive/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/Cargo.lock b/archive/Cargo.lock
index 048207e..048207e 100644
--- a/Cargo.lock
+++ b/archive/Cargo.lock
diff --git a/Cargo.toml b/archive/Cargo.toml
index 8baaf30..8baaf30 100644
--- a/Cargo.toml
+++ b/archive/Cargo.toml
diff --git a/ci/install_cmake.sh b/archive/ci/install_cmake.sh
index 9afe1e2..9afe1e2 100755
--- a/ci/install_cmake.sh
+++ b/archive/ci/install_cmake.sh
diff --git a/src/main.rs b/archive/src/main.rs
index 340c1d3..340c1d3 100644
--- a/src/main.rs
+++ b/archive/src/main.rs
diff --git a/tests/1/a.f90 b/archive/tests/1/a.f90
index a4f64a2..a4f64a2 100644
--- a/tests/1/a.f90
+++ b/archive/tests/1/a.f90
diff --git a/tests/1/b.f90 b/archive/tests/1/b.f90
index 8b57633..8b57633 100644
--- a/tests/1/b.f90
+++ b/archive/tests/1/b.f90
diff --git a/tests/1/fpm.toml b/archive/tests/1/fpm.toml
index c7d48a4..c7d48a4 100644
--- a/tests/1/fpm.toml
+++ b/archive/tests/1/fpm.toml
diff --git a/tests/1/main.f90 b/archive/tests/1/main.f90
index d886be3..d886be3 100644
--- a/tests/1/main.f90
+++ b/archive/tests/1/main.f90
diff --git a/tests/2/fpm.toml b/archive/tests/2/fpm.toml
index c7d48a4..c7d48a4 100644
--- a/tests/2/fpm.toml
+++ b/archive/tests/2/fpm.toml
diff --git a/tests/2/main.f90 b/archive/tests/2/main.f90
index bd820eb..bd820eb 100644
--- a/tests/2/main.f90
+++ b/archive/tests/2/main.f90
diff --git a/tests/cli.rs b/archive/tests/cli.rs
index b099721..b099721 100644
--- a/tests/cli.rs
+++ b/archive/tests/cli.rs
diff --git a/package.yaml b/package.yaml
new file mode 100644
index 0000000..2cf73a8
--- /dev/null
+++ b/package.yaml
@@ -0,0 +1,49 @@
+name: fpm
+version: 0.1.0.0
+github: "githubuser/fpm"
+license: BSD3
+author: "Author name here"
+maintainer: "example@example.com"
+copyright: "2020 Author name here"
+
+extra-source-files:
+- README.md
+- ChangeLog.md
+
+# Metadata used when publishing your package
+# synopsis: Short description of your package
+# category: Web
+
+# To avoid duplicated efforts in documentation and dealing with the
+# complications of embedding Haddock markup inside cabal files, it is
+# common to point users to the README.md file.
+description: Please see the README on GitHub at <https://github.com/githubuser/fpm#readme>
+
+dependencies:
+- base >= 4.7 && < 5
+- optparse-applicative
+
+library:
+ source-dirs: src
+
+executables:
+ fpm-exe:
+ main: Main.hs
+ source-dirs: app
+ ghc-options:
+ - -threaded
+ - -rtsopts
+ - -with-rtsopts=-N
+ dependencies:
+ - fpm
+
+tests:
+ fpm-test:
+ main: Spec.hs
+ source-dirs: test
+ ghc-options:
+ - -threaded
+ - -rtsopts
+ - -with-rtsopts=-N
+ dependencies:
+ - fpm
diff --git a/src/Lib.hs b/src/Lib.hs
new file mode 100644
index 0000000..d36ff27
--- /dev/null
+++ b/src/Lib.hs
@@ -0,0 +1,6 @@
+module Lib
+ ( someFunc
+ ) where
+
+someFunc :: IO ()
+someFunc = putStrLn "someFunc"
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 0000000..0094ee9
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,66 @@
+# This file was automatically generated by 'stack init'
+#
+# Some commonly used options have been documented as comments in this file.
+# For advanced use and comprehensive documentation of the format, please see:
+# https://docs.haskellstack.org/en/stable/yaml_configuration/
+
+# Resolver to choose a 'specific' stackage snapshot or a compiler version.
+# A snapshot resolver dictates the compiler version and the set of packages
+# to be used for project dependencies. For example:
+#
+# resolver: lts-3.5
+# resolver: nightly-2015-09-21
+# resolver: ghc-7.10.2
+#
+# The location of a snapshot can be provided as a file or url. Stack assumes
+# a snapshot provided as a file might change, whereas a url resource does not.
+#
+# resolver: ./custom-snapshot.yaml
+# resolver: https://example.com/snapshots/2018-01-01.yaml
+resolver: lts-12.26
+
+# User packages to be built.
+# Various formats can be used as shown in the example below.
+#
+# packages:
+# - some-directory
+# - https://example.com/foo/bar/baz-0.0.2.tar.gz
+# subdirs:
+# - auto-update
+# - wai
+packages:
+- .
+# Dependency packages to be pulled from upstream that are not in the resolver.
+# These entries can reference officially published versions as well as
+# forks / in-progress versions pinned to a git hash. For example:
+#
+# extra-deps:
+# - acme-missiles-0.3
+# - git: https://github.com/commercialhaskell/stack.git
+# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
+#
+# extra-deps: []
+
+# Override default flag values for local packages and extra-deps
+# flags: {}
+
+# Extra package databases containing global packages
+# extra-package-dbs: []
+
+# Control whether we use the GHC we find on the path
+# system-ghc: true
+#
+# Require a specific version of stack, using version ranges
+# require-stack-version: -any # Default
+# require-stack-version: ">=2.1"
+#
+# Override the architecture used by stack, especially useful on Windows
+# arch: i386
+# arch: x86_64
+#
+# Extra directories used by stack for building
+# extra-include-dirs: [/path/to/dir]
+# extra-lib-dirs: [/path/to/dir]
+#
+# Allow a newer minor version of GHC than the snapshot specifies
+# compiler-check: newer-minor
diff --git a/stack.yaml.lock b/stack.yaml.lock
new file mode 100644
index 0000000..6bee1e8
--- /dev/null
+++ b/stack.yaml.lock
@@ -0,0 +1,12 @@
+# This file was autogenerated by Stack.
+# You should not edit this file by hand.
+# For more information, please see the documentation at:
+# https://docs.haskellstack.org/en/stable/lock_files
+
+packages: []
+snapshots:
+- completed:
+ size: 509471
+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/26.yaml
+ sha256: 95f014df58d0679b1c4a2b7bf2b652b61da8d30de5f571abb0d59015ef678646
+ original: lts-12.26
diff --git a/test/Spec.hs b/test/Spec.hs
new file mode 100644
index 0000000..cd4753f
--- /dev/null
+++ b/test/Spec.hs
@@ -0,0 +1,2 @@
+main :: IO ()
+main = putStrLn "Test suite not yet implemented"