mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-26 06:11:50 +03:00
Merge pull request #203 from m-bd/path-lookup
Add PATH lookup to find Chez Scheme
This commit is contained in:
commit
f38dd50b3f
@ -19,14 +19,20 @@ import System.Info
|
||||
|
||||
%default covering
|
||||
|
||||
|
||||
pathLookup : IO String
|
||||
pathLookup
|
||||
= do path <- getEnv "PATH"
|
||||
let pathList = split (== ':') $ fromMaybe "/usr/bin:/usr/local/bin" path
|
||||
let candidates = [p ++ "/" ++ x | p <- pathList,
|
||||
x <- ["chez", "chezscheme9.5", "scheme"]]
|
||||
e <- firstExists candidates
|
||||
pure $ fromMaybe "/usr/bin/env scheme" e
|
||||
|
||||
findChez : IO String
|
||||
findChez
|
||||
= do env <- getEnv "CHEZ"
|
||||
case env of
|
||||
Just n => pure n
|
||||
Nothing => do e <- firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
||||
x <- ["chez", "chezscheme9.5", "scheme"]]
|
||||
pure $ fromMaybe "/usr/bin/env scheme" e
|
||||
= do Just chez <- getEnv "CHEZ" | Nothing => pathLookup
|
||||
pure chez
|
||||
|
||||
-- Given the chez compiler directives, return a list of pairs of:
|
||||
-- - the library file name
|
||||
|
@ -145,13 +145,18 @@ firstExists : List String -> IO (Maybe String)
|
||||
firstExists [] = pure Nothing
|
||||
firstExists (x :: xs) = if !(exists x) then pure (Just x) else firstExists xs
|
||||
|
||||
pathLookup : IO (Maybe String)
|
||||
pathLookup = do
|
||||
path <- getEnv "PATH"
|
||||
let pathList = split (== ':') $ fromMaybe "/usr/bin:/usr/local/bin" path
|
||||
let candidates = [p ++ "/" ++ x | p <- pathList,
|
||||
x <- ["chez", "chezscheme9.5", "scheme"]]
|
||||
firstExists candidates
|
||||
|
||||
findChez : IO (Maybe String)
|
||||
findChez
|
||||
= do env <- getEnv "CHEZ"
|
||||
case env of
|
||||
Just n => pure $ Just n
|
||||
Nothing => firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
||||
x <- ["chez", "chezscheme9.5", "scheme"]]
|
||||
= do Just chez <- getEnv "CHEZ" | Nothing => pathLookup
|
||||
pure $ Just chez
|
||||
|
||||
runChezTests : String -> List String -> IO (List Bool)
|
||||
runChezTests prog tests
|
||||
|
Loading…
Reference in New Issue
Block a user