Commit b53d2de0 authored by Valentin Reis's avatar Valentin Reis

Refactor.

parent 0ce27a0f
name: argotest
version: 0.1.0.0
license: MIT
license-file: LICENSE
author: Valentin Reis
maintainer: fre@freux.fr
build-type: Simple
extra-source-files: ChangeLog.md
cabal-version: >=1.10
executable argotest
main-is: argotest.hs
build-depends:
base,
turtle,
data-default,
optparse-applicative,
unix,
text,
system-filepath
default-language: Haskell2010
ghc-options:
-threaded
-Wall
-Wincomplete-uni-patterns
-Wincomplete-record-updates
-Wmissing-home-modules
-Widentities
-Wredundant-constraints
-Wcpp-undef
-fwarn-tabs
-fwarn-unused-imports
-fwarn-missing-signatures
-fwarn-name-shadowing
-fprint-potential-instances
-Wmissing-export-list
-fwarn-incomplete-patterns
#! /usr/bin/env nix-shell
#! nix-shell default.nix -i runhaskell -A argotest
{-# language RecordWildCards #-}
{-# language ApplicativeDo #-}
{-# language OverloadedStrings #-}
module Argotest where
module Main where
import Data.Default
import Turtle hiding ( header )
import Turtle hiding ( header
, arguments
)
import Options.Applicative
import Data.Maybe
import Prelude hiding ( FilePath )
import System.IO ( withFile )
import Debug.Trace
import Data.Text ( unpack
, pack
)
import Filesystem.Path ( (</>) )
import Control.Concurrent.Async
import System.Console.ANSI
import System.Console.ANSI.Types ( Color )
import System.Posix.Signals
import Data.Text ( pack )
import System.Posix.Process
data StackArgs = StackArgs
......@@ -72,14 +62,16 @@ executorParser = do
, "stream"
]
optSrc :: String -> Parser (Maybe (String, FilePath))
optSrc l = do
optSrc longform = do
parsed <- optional $ strOption
(long l <> metavar "PATH" <> help (l <> " source folder override."))
pure $ mapT l parsed
(long longform <> metavar "PATH" <> help
(longform <> " source folder override.")
)
pure $ mapT longform parsed
mapT :: String -> Maybe FilePath -> Maybe (String, FilePath)
mapT l thePath = case thePath of
mapT longform thePath = case thePath of
Nothing -> Nothing
Just p -> Just (l, p)
Just p -> Just (longform, p)
main :: IO ()
main = sh $ do
......@@ -111,12 +103,15 @@ main = sh $ do
Nothing
where
argumentsBuilder :: StackArgs -> [String]
argumentsBuilder a@StackArgs {..} =
argumentsBuilder StackArgs {..} =
["-A", "test"]
++ concat [ ["--arg", l <> "-src", encodeString p] | (l, p) <- overrides ]
++ concat
[ ["--arg", longform <> "-src", encodeString p]
| (longform, p) <- overrides
]
++ (case run of
Just command -> ["--run", command]
Nothing -> []
Just cmd -> ["--run", cmd]
Nothing -> []
)
opts = info
(executorParser <**> helper)
......
(import ../default.nix {}).argotest.hack
......@@ -14,17 +14,25 @@ in
dgemm_randomwalk-src ? argopkgs.applications.nrm.dgemm_randomwalk.src,
}:
let
filterHdevTools = builtins.filterSource (path: type:
(baseNameOf path != ".hdevtools.sock") &&
(baseNameOf path != ".ghc.environment.x86_64-linux-8.4.4") &&
(baseNameOf path != "dist"));
addHackEnv = package : package.overrideAttrs (old: {
hack = argopkgs.haskellPackages.shellFor {
packages = p: [package];
withHoogle = true;
buildInputs = devInputs ++ devHPackages;
};
});
cabalDevLoader = self: path: set: addHackEnv
(self.callCabal2nix (baseNameOf path) (filterHdevTools path) set);
devInputs = with argopkgs.haskellPackages; with argopkgs; [
sysstat jq
sysstat jq cabal-install
];
devHPackages = with argopkgs.haskellPackages; [
hdevtools hlint brittany ghcid
hdevtools hlint brittany ghcid Cabal
];
addHackEnv = package : package.overrideAttrs (old: {
buildInputs = old.buildInputs ++ devInputs ++ devHPackages;
});
in rec {
argotk = argopkgs.argotk.overrideAttrs (old: {src = argotk-src;} );
nrm = argopkgs.nodelevel.nrm.overrideAttrs (old: {src = nrm-src;} );
......@@ -76,15 +84,13 @@ in
];
});
argotest = argopkgs.mkShell {
name = "shake";
buildInputs = [
(argopkgs.haskellPackages.ghcWithPackages (p: with p; [
argotk
turtle data-default optparse-generic unix
]))
];
hpkgs = argopkgs.haskellPackages.override {
overrides = self: super:
let
loader = cabalDevLoader self;
in rec {
argotest = loader ./argotest {};
};
};
argotest-hack = addHackEnv argotest;
argotest = hpkgs.argotest;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment