all: initial work on dependency management

This commit is contained in:
hellerve 2018-06-21 17:00:39 +02:00
parent e741d59ce3
commit 89c9492567
5 changed files with 17 additions and 1 deletions

View File

@ -81,6 +81,11 @@ main = do args <- SystemEnvironment.getArgs
runInputT settings (repl finalContext "")
Build -> do _ <- executeString True finalContext ":b" "Compiler (Build)"
return ()
Install thing ->
do _ <- executeString True finalContext
("(install \"" ++ thing ++ "\")")
"Installation"
return ()
BuildAndRun -> do _ <- executeString True finalContext ":bx" "Compiler (Build & Run)"
-- TODO: Handle the return value from executeString and return that one to the shell
return ()
@ -103,6 +108,7 @@ parseArgs args = parseArgsInternal [] Repl [] args
case arg of
"-b" -> parseArgsInternal filesToLoad Build otherOptions restArgs
"-x" -> parseArgsInternal filesToLoad BuildAndRun otherOptions restArgs
"-i" -> parseArgsInternal filesToLoad (Install (head restArgs)) otherOptions (tail restArgs)
"--check" -> parseArgsInternal filesToLoad Check otherOptions restArgs
"--no-core" -> parseArgsInternal filesToLoad execMode (NoCore : otherOptions) restArgs
"--log-memory" -> parseArgsInternal filesToLoad execMode (LogMemory : otherOptions) restArgs

View File

@ -20,3 +20,4 @@
(load "Map.carp")
(load "Heap.carp")
(load "Sort.carp")
(load "Install.carp")

8
core/Install.carp Normal file
View File

@ -0,0 +1,8 @@
(defn install [file]
(let [split (String.split-by file &[\@])]
(if (= (Array.length &split) 1)
(System.system &(fmt "git clone %s" file))
(do
(System.system &(fmt "git clone %s" file))
(comment TODO: check out tag)
))))

View File

@ -447,6 +447,7 @@ catcher ctx exception =
case contextExecMode ctx of
Repl -> return ctx
Build -> exitWith (ExitFailure returnCode)
Install _ -> exitWith (ExitFailure returnCode)
BuildAndRun -> exitWith (ExitFailure returnCode)
Check -> exitWith ExitSuccess

View File

@ -618,7 +618,7 @@ forceTy :: XObj -> Ty
forceTy xobj = fromMaybe (error ("No type in " ++ show xobj)) (ty xobj)
-- | How should the compiler be run? Interactively or just build / build & run and then quit?
data ExecutionMode = Repl | Build | BuildAndRun | Check deriving (Show, Eq)
data ExecutionMode = Repl | Build | BuildAndRun | Install String | Check deriving (Show, Eq)
-- | Information needed by the REPL
data Context = Context { contextGlobalEnv :: Env