summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
Diffstat (limited to 'Biz')
-rw-r--r--Biz/Bild.hs61
-rw-r--r--Biz/Bild.nix7
-rw-r--r--Biz/Bild/ShellHook.sh3
3 files changed, 43 insertions, 28 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs
index 007bda8..17fb883 100644
--- a/Biz/Bild.hs
+++ b/Biz/Bild.hs
@@ -181,20 +181,21 @@ move args =
+> exitSummary
where
printOrBuild :: Map FilePath Target -> IO [ExitCode]
- printOrBuild analyses =
- if args `Cli.has` Cli.longOption "analyze"
- then
- analyses
- |> Map.elems
- |> putJSON
- >> pure [Exit.ExitSuccess]
- else do
- root <- Env.getEnv "BIZ_ROOT"
- createHier root
- analyses
- |> Map.toList
- |> map snd
- |> traverse (build isTest isLoud)
+ printOrBuild analyses
+ | args `Cli.has` Cli.longOption "json" =
+ analyses
+ |> Map.elems
+ |> putJSON
+ >> pure [Exit.ExitSuccess]
+ | args `Cli.has` Cli.longOption "repl" =
+ traverse (repl isLoud) (Map.elems analyses)
+ | otherwise = do
+ root <- Env.getEnv "BIZ_ROOT"
+ createHier root
+ analyses
+ |> Map.toList
+ |> map snd
+ |> traverse (build isTest isLoud)
isTest = args `Cli.has` Cli.longOption "test"
isLoud = args `Cli.has` Cli.longOption "loud"
putJSON = Aeson.encode .> ByteString.toStrict .> Char8.putStrLn
@@ -212,9 +213,10 @@ Usage:
bild [options] <target>...
Options:
+ --repl Start a repl for the target
--test Run tests on a target after building
--loud Show all output from compiler
- --analyze Only analyze and print as JSON, don't build
+ --json Only analyze and print as JSON, don't build
-h, --help Print this info
|]
@@ -238,7 +240,7 @@ data Compiler
| Guile
| NixBuild
| Copy
- deriving (Show, Generic, Aeson.ToJSON)
+ deriving (Eq, Show, Generic, Aeson.ToJSON)
data Target = Target
{ -- | Output name
@@ -463,9 +465,30 @@ test loud Target {..} = case compiler of
onFailure = Log.fail ["test", nschunk namespace] >> Log.br,
onSuccess = Log.pass ["test", nschunk namespace] >> Log.br
}
- _ -> do
- Log.warn ["test", nschunk namespace, "unavailable"] >> Log.br
- pure Exit.ExitSuccess
+ _ ->
+ Log.warn ["test", nschunk namespace, "unavailable"]
+ >> Log.br
+ >> pure Exit.ExitSuccess
+
+repl :: Bool -> Target -> IO Exit.ExitCode
+repl _ Target {..} =
+ case compiler of
+ c
+ | c `elem` [GhcExe, GhcLib] ->
+ [ ["--packages"],
+ ["haskellPackages." <> d | d <- Set.toList langdeps],
+ Set.toList sysdeps,
+ [ "--command",
+ "ghci -i$BIZ_ROOT -ghci-script $BIZ_ROOT/.ghci " <> path
+ ]
+ ]
+ |> mconcat
+ |> Process.callProcess "nix-shell"
+ >> Exit.exitSuccess
+ _ ->
+ Log.fail ["repl", nschunk namespace, "not implemented"]
+ >> Log.br
+ >> Exit.exitFailure
build :: Bool -> Bool -> Target -> IO Exit.ExitCode
build andTest loud target@Target {..} = do
diff --git a/Biz/Bild.nix b/Biz/Bild.nix
index cab8193..a4e655b 100644
--- a/Biz/Bild.nix
+++ b/Biz/Bild.nix
@@ -58,7 +58,7 @@ in rec {
set -eux
mkdir $out
: analyzing with bild
- ${bild}/bin/bild --analyze ${main} 1> $out/analysis.json 2> $out/stderr
+ ${bild}/bin/bild --json ${main} 1> $out/analysis.json 2> $out/stderr
set +eux
'';
installPhase = "exit 0";
@@ -124,11 +124,9 @@ in rec {
env = pkgs.mkShell {
name = "bizdev";
buildInputs = with nixpkgs.pkgs; [
- ghcPackageSetFull # need this until 'bild -s' works
# this should just be dev tools
haskell.packages.${ghcCompiler}.apply-refact
bild
- cmark
figlet
haskell.packages.${ghcCompiler}.fast-tags
hlint
@@ -140,14 +138,11 @@ in rec {
python38Packages.pylint
shellcheck
wemux
- gmnisrv
- gmni
] ++ lib.optional nixpkgs.stdenv.isLinux [
# scheme deps (i think these are broken on macOS)
guile
#inspekt3d
#libfive
- ccze
];
shellHook = ". ${./Bild/ShellHook.sh}";
};
diff --git a/Biz/Bild/ShellHook.sh b/Biz/Bild/ShellHook.sh
index 625ac60..cff40c6 100644
--- a/Biz/Bild/ShellHook.sh
+++ b/Biz/Bild/ShellHook.sh
@@ -5,7 +5,6 @@ function help() {
echo " bild compile code"
echo " ci run all builds and tests"
echo " deps manage dependencies with niv"
- echo " ghci start ghci with correct options"
echo " help show this message"
echo " lint auto-lint all changed files"
echo " pie product improvement engine"
@@ -36,8 +35,6 @@ function deps() {
niv --sources-file $BIZ_ROOT/Biz/Bild/Sources.json $@
}
-alias ghci="ghci -i$BIZ_ROOT -ghci-script $BIZ_ROOT/.ghci"
-
function pie() {
runghc Biz.Pie $@
}