bin: switch to "runghc", drop "env -S" (#1453)

env -S isn't a thing on linux of course. Go back to using standard
env, which means using a stack options line, which means not using
"ghc". This new setup is probably simpler anyway. I've just had to
give up on the goal of having each script's required packages being
defined in one place; now (to they extent they are required) they
must be defined both in the script header and in compile.sh.
This commit is contained in:
Simon Michael 2021-01-12 10:55:00 -08:00
parent 2db87333d7
commit 32ccbba805
9 changed files with 37 additions and 38 deletions

View File

@ -6,10 +6,10 @@ Things in this directory can be unfinished or out of date.
The hledger-*.hs scripts here are example/experimental hledger [add-on commands].
See <https://hledger.org/scripting.html> for more about this.
They are mostly implemented as [stack] scripts; if you have stack in your $PATH,
they should just work, automatically installing their dependencies if needed.
(You can also run them with [cabal], or runghc, or compile them with
ghc, if you take care of the dependencies yourself.)
They are mostly implemented as [stack] runghc scripts. See the comments in
hledger-check-fancyassertions.hs for more about how to run or compile them.
Short version: run bin/compile.sh to compile all scripts, and add this directory
to your $PATH so they show up in hledger's command list.
Scripts overview, simplest first:

View File

@ -1,15 +1,13 @@
#!/bin/sh
# Compile all add-on scrips in this directory.
# Compile all add-on scripts in this directory.
cd "$(dirname "$0")" || exit
echo "building hledger libraries"
echo "building hledger libraries for scripts"
stack build hledger
echo "installing extra libraries needed by scripts"
echo "installing extra libraries for scripts"
stack install string-qq
echo "compiling hledger-* scripts"
for f in hledger-*.hs; do stack ghc -- "$f"; done
# stack script --compile would install extra libs more automatically
# but would also run scripts, which we don't want
echo "compiling the hledger-* scripts"
for f in `git ls-files 'hledger-*.hs'`; do stack ghc -- "$f"; done

View File

@ -1,4 +1,5 @@
#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0
#!/usr/bin/env stack
-- stack runghc --verbosity info --package hledger
-- See hledger-check-fancyassertions.hs
-- {-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-}

View File

@ -1,24 +1,20 @@
#!/usr/bin/env -S stack ghc --verbosity info --package hledger-lib -- -O0
-- Run this script once from inside the hledger source tree; it will
-- compile itself using the corresponding source version of hledger,
-- which is the version it is tested with. You can run the compiled
-- version from anywhere. It is compiled unoptimised, which takes less
-- time and probably won't be noticeable otherwise; if you care, you
-- can remove the "-O0" above.
#!/usr/bin/env stack
-- stack runghc --verbosity info --package hledger-lib
-- Run this script from inside the hledger source tree, so that it
-- will use the corresponding source version of hledger, which is the
-- version it is tested with.
--
-- To run it interpreted, eg while tweaking it: replace "ghc" above
-- with "runghc", and run from inside the hledger source tree.
-- You can compile these scripts by running compile.sh in this directory.
-- The compiled executables can be run from anywhere, so you could add
-- this directory to your $PATH and see them in hledger's command list.
--
-- To make it a standalone script that runs from anywhere and
-- recompiles itself when changed: replace "ghc" above with
-- "script --compile --resolver lts-16" (eg).
-- However this uses the hledger version from that stackage resolver,
-- so in this case you should check out the corresponding release-tagged
-- version of this script for compatibility (eg: git checkout 1.18.1).
--
-- env -S and a multi-argument shebang line is used, rather than a stack
-- options line, because current stack won't run the ghc command that way.
-- Hopefully your env supports -S.
-- You could make this a standalone script that runs from anywhere and
-- recompiles itself when changed, by replacing "runghc" above with
-- "script --compile --resolver lts-16" (eg). However this uses the
-- hledger version from that stackage resolver, so in this case you
-- should check out the corresponding release-tagged version of this
-- script for compatibility (eg: git checkout 1.18.1).
{-
```

View File

@ -1,4 +1,5 @@
#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0
#!/usr/bin/env stack
-- stack runghc --verbosity info --package hledger
-- See hledger-check-fancyassertions.hs
{-

View File

@ -1,4 +1,5 @@
#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0
#!/usr/bin/env stack
-- stack runghc --verbosity info --package hledger
-- See hledger-check-fancyassertions.hs
{-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-}

View File

@ -1,6 +1,6 @@
#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0
#!/usr/bin/env stack
-- stack runghc --verbosity info --package hledger
-- See hledger-check-fancyassertions.hs
--package string-qq
{-

View File

@ -1,8 +1,9 @@
#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0
#!/usr/bin/env stack
-- stack runghc --verbosity info --package hledger
-- See hledger-check-fancyassertions.hs
--package string-qq
-- This is an unfinished prototype, see https://github.com/simonmichael/hledger/issues/1171
-- Requires a contemporaneous version of the hledger package.
-- Requires journal entries to be sorted by date.

View File

@ -1,4 +1,5 @@
#!/usr/bin/env -S stack ghc --verbosity info --package hledger -- -O0
#!/usr/bin/env stack
-- stack runghc --verbosity info --package hledger
-- See hledger-check-fancyassertions.hs
{-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-}