Commit 83cd6c55 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Handle dyamic libraries in detectWay.

parent 3f3134cc
...@@ -126,15 +126,21 @@ libsuf way @ (Way set) = ...@@ -126,15 +126,21 @@ libsuf way @ (Way set) =
return $ prefix ++ "ghc" ++ version ++ extension return $ prefix ++ "ghc" ++ version ++ extension
-- Detect way from a given filename. Returns Nothing if there is no match: -- Detect way from a given filename. Returns Nothing if there is no match:
-- * detectWay "foo/bar.hi" == Just vanilla -- * detectWay "foo/bar.hi" == Just vanilla
-- * detectWay "baz.thr_p_o" == Just threadedProfiling -- * detectWay "baz.thr_p_o" == Just threadedProfiling
-- * detectWay "qwe.phi" == Nothing (expected "qwe.p_hi") -- * detectWay "qwe.phi" == Nothing (expected "qwe.p_hi")
-- * detectWay "xru.p_ghc7.11.20141222.dll" == Just profiling
detectWay :: FilePath -> Maybe Way detectWay :: FilePath -> Maybe Way
detectWay file = case reads prefix of detectWay file = case reads prefix of
[(way, "")] -> Just way [(way, "")] -> Just way
_ -> Nothing _ -> Nothing
where where
prefix = dropWhileEnd (== '_') . dropWhileEnd (/= '_') $ takeExtension file extension = takeExtension file
prefixed = if extension `notElem` ["so", "dll", "dynlib"]
then extension
else takeExtension . dropExtension .
dropExtension . dropExtension $ file
prefix = dropWhileEnd (== '_') . dropWhileEnd (/= '_') $ prefixed
-- Given a path, an extension suffix, and a file name check if the latter: -- Given a path, an extension suffix, and a file name check if the latter:
-- 1) conforms to pattern 'path//*suffix' -- 1) conforms to pattern 'path//*suffix'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment