Skip to content

Commit

Permalink
Fix ghc-paths for Bazel 0.27
Browse files Browse the repository at this point in the history
The amount of shell indirection seems to have changed in Bazel 0.27.
Meaning that we would need twice as many `\` for the `sed` call on
Windows. The `tr` command is insensitive to single backslashes, so it's
an easier alternative.
  • Loading branch information
aherrmann committed Jun 27, 2019
1 parent 342be04 commit 968ccaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions hazel/ghc_paths.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ def _ghc_paths_module_impl(ctx):
inputs = [ghc],
outputs = [ctx.outputs.out],
command = """
{ghc} --print-libdir
{ghc} --print-libdir | sed 's:\\\\:/:g'
cat > {out} << EOM
module GHC.Paths (
ghc, ghc_pkg, libdir, docdir
) where
libdir, docdir, ghc, ghc_pkg :: FilePath
poulet = "$({ghc} --print-libdir)"
libdir = "$({ghc} --print-libdir | sed 's:\\\\:/:g')"
docdir = "DOCDIR_IS_NOT_SET"
ghc, ghc_pkg, docdir, libdir :: FilePath
ghc = "{ghc}"
ghc_pkg = "{ghc_pkg}"
EOM""".format(
docdir = "DOCDIR_IS_NOT_SET"
EOM
echo -n 'libdir = "' >> {out}
{ghc} --print-libdir | tr '\\' '/' | tr -d '[:space:]' >> {out}
echo '"' >> {out}
""".format(
ghc = ghc.path,
ghc_pkg = tools.ghc_pkg.path,
out = ctx.outputs.out.path,
Expand Down
4 changes: 2 additions & 2 deletions hazel/test/ghc-paths-test.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module Main where

import Control.Monad (when)
import GHC.Paths (ghc, ghc_pkg, libdir, docdir, poulet)
import GHC.Paths (ghc, ghc_pkg, libdir, docdir)
import System.Exit (exitFailure)
import System.IO (hPutStrLn, stderr)

main :: IO ()
main = do
let require name value =
when (null value) $ do
hPutStrLn stderr (name ++ " should not be empty" ++ poulet)
hPutStrLn stderr (name ++ " should not be empty")
exitFailure
require "ghc" ghc
require "ghc_pkg" ghc_pkg
Expand Down

0 comments on commit 968ccaa

Please sign in to comment.