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