mirror of
https://github.com/tweag/asterius.git
synced 2024-09-19 21:07:55 +03:00
Un-escape .rsp contents to reverse the effects of Cabal's escapeResponseFileArg (#671)
This commit is contained in:
parent
de0bef7883
commit
d8bfc9d4e3
@ -34,10 +34,24 @@ main = do
|
||||
getAhcArArgs :: IO [String]
|
||||
getAhcArArgs = getArgs >>= fmap concat . mapM expand
|
||||
where
|
||||
expand :: String -> IO [String]
|
||||
expand opt = case opt of
|
||||
('@' : path) -> catchIOError (lines <$> readFile path) (const $ pure [opt])
|
||||
('@' : path) ->
|
||||
catchIOError
|
||||
(map undoEscapeResponseFileArg . lines <$> readFile path)
|
||||
(const $ pure [opt])
|
||||
_ -> return [opt]
|
||||
|
||||
-- | Un-escape a single the contents of @.rsp@ file, essentially reversing the
|
||||
-- effects of Cabal's @escapeResponseFileArg@
|
||||
-- (https://github.com/haskell/cabal/blob/dde6255a4e6b531c0567bc499840d11ead9d885b/Cabal/Distribution/Simple/Program/ResponseFile.hs#L48).
|
||||
undoEscapeResponseFileArg :: String -> String
|
||||
undoEscapeResponseFileArg arg = case arg of
|
||||
"" -> ""
|
||||
'\\' : c : cs -> c : undoEscapeResponseFileArg cs
|
||||
'\\' : [] -> error "undoEscapeResponseFileArg: dangling backslash"
|
||||
c : cs -> c : undoEscapeResponseFileArg cs
|
||||
|
||||
-- | Create a library archive from a bunch of object files, using @Ar@ from the
|
||||
-- GHC API. Though the name of each object file is preserved, we set the
|
||||
-- timestamp, owner ID, group ID, and file mode to default values (0, 0, 0, and
|
||||
|
Loading…
Reference in New Issue
Block a user