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

View File

@ -1,15 +1,13 @@
#!/bin/sh #!/bin/sh
# Compile all add-on scrips in this directory. # Compile all add-on scripts in this directory.
cd "$(dirname "$0")" || exit cd "$(dirname "$0")" || exit
echo "building hledger libraries" echo "building hledger libraries for scripts"
stack build hledger stack build hledger
echo "installing extra libraries needed by scripts" echo "installing extra libraries for scripts"
stack install string-qq stack install string-qq
echo "compiling hledger-* scripts" echo "compiling the hledger-* scripts"
for f in hledger-*.hs; do stack ghc -- "$f"; done for f in `git ls-files '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

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 -- See hledger-check-fancyassertions.hs
-- {-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-} -- {-# 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 #!/usr/bin/env stack
-- Run this script once from inside the hledger source tree; it will -- stack runghc --verbosity info --package hledger-lib
-- compile itself using the corresponding source version of hledger,
-- which is the version it is tested with. You can run the compiled -- Run this script from inside the hledger source tree, so that it
-- version from anywhere. It is compiled unoptimised, which takes less -- will use the corresponding source version of hledger, which is the
-- time and probably won't be noticeable otherwise; if you care, you -- version it is tested with.
-- can remove the "-O0" above.
-- --
-- To run it interpreted, eg while tweaking it: replace "ghc" above -- You can compile these scripts by running compile.sh in this directory.
-- with "runghc", and run from inside the hledger source tree. -- 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 -- You could make this a standalone script that runs from anywhere and
-- recompiles itself when changed: replace "ghc" above with -- recompiles itself when changed, by replacing "runghc" above with
-- "script --compile --resolver lts-16" (eg). -- "script --compile --resolver lts-16" (eg). However this uses the
-- However this uses the hledger version from that stackage resolver, -- hledger version from that stackage resolver, so in this case you
-- so in this case you should check out the corresponding release-tagged -- should check out the corresponding release-tagged version of this
-- version of this script for compatibility (eg: git checkout 1.18.1). -- 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.
{- {-
``` ```

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 -- 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 -- See hledger-check-fancyassertions.hs
{-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-} {-# 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 -- See hledger-check-fancyassertions.hs
--package string-qq --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 -- See hledger-check-fancyassertions.hs
--package string-qq --package string-qq
-- This is an unfinished prototype, see https://github.com/simonmichael/hledger/issues/1171 -- This is an unfinished prototype, see https://github.com/simonmichael/hledger/issues/1171
-- Requires a contemporaneous version of the hledger package. -- Requires a contemporaneous version of the hledger package.
-- Requires journal entries to be sorted by date. -- 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 -- See hledger-check-fancyassertions.hs
{-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-} {-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-}