mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-19 10:51:35 +03:00
commit
c208bf0592
4
Makefile
4
Makefile
@ -1,7 +1,9 @@
|
|||||||
PREFIX = ${HOME}/.idris2
|
PREFIX ?= ${HOME}/.idris2
|
||||||
export IDRIS2_PATH = ${CURDIR}/libs/prelude/build:${CURDIR}/libs/base/build
|
export IDRIS2_PATH = ${CURDIR}/libs/prelude/build:${CURDIR}/libs/base/build
|
||||||
export IDRIS2_DATA = ${CURDIR}/support
|
export IDRIS2_DATA = ${CURDIR}/support
|
||||||
|
|
||||||
|
-include custom.mk
|
||||||
|
|
||||||
.PHONY: ttimp idris2 prelude test base clean lib_clean
|
.PHONY: ttimp idris2 prelude test base clean lib_clean
|
||||||
|
|
||||||
all: idris2 libs test
|
all: idris2 libs test
|
||||||
|
@ -121,6 +121,7 @@ executable = idris2
|
|||||||
-- opts = "--cg-opt -O2 --partial-eval"
|
-- opts = "--cg-opt -O2 --partial-eval"
|
||||||
-- opts = "--cg-opt -pg --partial-eval"
|
-- opts = "--cg-opt -pg --partial-eval"
|
||||||
opts = "--partial-eval"
|
opts = "--partial-eval"
|
||||||
|
-- opts = "--partial-eval --cg-opt -lws2_32" -- windows
|
||||||
|
|
||||||
main = Idris.Main
|
main = Idris.Main
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@ firstExists (x :: xs) = if !(exists x) then pure (Just x) else firstExists xs
|
|||||||
|
|
||||||
findChez : IO String
|
findChez : IO String
|
||||||
findChez
|
findChez
|
||||||
= do e <- firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
= do env <- getEnv "CHEZ"
|
||||||
|
case env of
|
||||||
|
Just n => pure n
|
||||||
|
Nothing => do e <- firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
||||||
x <- ["scheme", "chez", "chezscheme9.5"]]
|
x <- ["scheme", "chez", "chezscheme9.5"]]
|
||||||
maybe (pure "/usr/bin/env scheme") pure e
|
maybe (pure "/usr/bin/env scheme") pure e
|
||||||
|
|
||||||
@ -46,11 +49,12 @@ escapeQuotes s = pack $ foldr escape [] $ unpack s
|
|||||||
|
|
||||||
schHeader : String -> List String -> String
|
schHeader : String -> List String -> String
|
||||||
schHeader chez libs
|
schHeader chez libs
|
||||||
= "#!" ++ chez ++ " --script\n\n" ++
|
= if os /= "windows" then "#!" ++ chez ++ " --script\n\n" else "" ++
|
||||||
"(import (chezscheme))\n" ++
|
"(import (chezscheme))\n" ++
|
||||||
"(case (machine-type)\n" ++
|
"(case (machine-type)\n" ++
|
||||||
" [(i3le ti3le a6le ta6le) (load-shared-object \"libc.so.6\")]\n" ++
|
" [(i3le ti3le a6le ta6le) (load-shared-object \"libc.so.6\")]\n" ++
|
||||||
" [(i3osx ti3osx a6osx ta6osx) (load-shared-object \"libc.dylib\")]\n" ++
|
" [(i3osx ti3osx a6osx ta6osx) (load-shared-object \"libc.dylib\")]\n" ++
|
||||||
|
" [(i3nt ti3nt a6nt ta6nt) (load-shared-object \"msvcrt.dll\")]\n" ++
|
||||||
" [else (load-shared-object \"libc.so\")])\n\n" ++
|
" [else (load-shared-object \"libc.so\")])\n\n" ++
|
||||||
showSep "\n" (map (\x => "(load-shared-object \"" ++ escapeQuotes x ++ "\")") libs) ++ "\n\n" ++
|
showSep "\n" (map (\x => "(load-shared-object \"" ++ escapeQuotes x ++ "\")") libs) ++ "\n\n" ++
|
||||||
"(let ()\n"
|
"(let ()\n"
|
||||||
|
@ -11,15 +11,19 @@ import System.Info
|
|||||||
%default total
|
%default total
|
||||||
|
|
||||||
isWindows : Bool
|
isWindows : Bool
|
||||||
isWindows = os `elem` ["win32", "mingw32", "cygwin32"]
|
isWindows = os `elem` ["windows", "mingw32", "cygwin32"]
|
||||||
|
|
||||||
sep : Char
|
sep : Char
|
||||||
sep = if isWindows then '\\' else '/'
|
sep = '/'
|
||||||
|
|
||||||
export
|
export
|
||||||
dirSep : String
|
dirSep : String
|
||||||
dirSep = cast sep
|
dirSep = cast sep
|
||||||
|
|
||||||
|
export
|
||||||
|
pathSep : Char
|
||||||
|
pathSep = if isWindows then ';' else ':'
|
||||||
|
|
||||||
fullPath : String -> List String
|
fullPath : String -> List String
|
||||||
fullPath fp = filter (/="") $ split (==sep) fp
|
fullPath fp = filter (/="") $ split (==sep) fp
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ updatePaths
|
|||||||
defs <- get Ctxt
|
defs <- get Ctxt
|
||||||
bpath <- coreLift $ getEnv "IDRIS2_PATH"
|
bpath <- coreLift $ getEnv "IDRIS2_PATH"
|
||||||
case bpath of
|
case bpath of
|
||||||
Just path => do traverse addExtraDir (map trim (split (==':') path))
|
Just path => do traverse addExtraDir (map trim (split (==pathSep) path))
|
||||||
pure ()
|
pure ()
|
||||||
Nothing => pure ()
|
Nothing => pure ()
|
||||||
bdata <- coreLift $ getEnv "IDRIS2_DATA"
|
bdata <- coreLift $ getEnv "IDRIS2_DATA"
|
||||||
case bdata of
|
case bdata of
|
||||||
Just path => do traverse addDataDir (map trim (split (==':') path))
|
Just path => do traverse addDataDir (map trim (split (==pathSep) path))
|
||||||
pure ()
|
pure ()
|
||||||
Nothing => pure ()
|
Nothing => pure ()
|
||||||
-- BLODWEN_PATH goes first so that it overrides this if there's
|
-- BLODWEN_PATH goes first so that it overrides this if there's
|
||||||
|
@ -70,7 +70,7 @@ runTest : String -> String -> String -> IO Bool
|
|||||||
runTest dir prog test
|
runTest dir prog test
|
||||||
= do chdir (dir ++ "/" ++ test)
|
= do chdir (dir ++ "/" ++ test)
|
||||||
putStr $ dir ++ "/" ++ test ++ ": "
|
putStr $ dir ++ "/" ++ test ++ ": "
|
||||||
system $ "sh ./run " ++ prog ++ " > output"
|
system $ "sh ./run " ++ prog ++ " | tr -d \\r > output"
|
||||||
Right out <- readFile "output"
|
Right out <- readFile "output"
|
||||||
| Left err => do print err
|
| Left err => do print err
|
||||||
pure False
|
pure False
|
||||||
@ -96,7 +96,10 @@ firstExists (x :: xs) = if !(exists x) then pure (Just x) else firstExists xs
|
|||||||
|
|
||||||
findChez : IO (Maybe String)
|
findChez : IO (Maybe String)
|
||||||
findChez
|
findChez
|
||||||
= firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
= do env <- getEnv "CHEZ"
|
||||||
|
case env of
|
||||||
|
Just n => pure $ Just n
|
||||||
|
Nothing => firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
||||||
x <- ["scheme", "chez", "chezscheme9.5"]]
|
x <- ["scheme", "chez", "chezscheme9.5"]]
|
||||||
|
|
||||||
main : IO ()
|
main : IO ()
|
||||||
|
Loading…
Reference in New Issue
Block a user