refactor: don’t print compilation info on implicit compile (#1157)

This commit is contained in:
Veit Heller 2021-01-29 17:21:19 +01:00 committed by GitHub
parent 6057b03288
commit b0a207dd49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -282,8 +282,9 @@ runExeWithArgs ctx exe args = liftIO $ do
ExitFailure i -> throw (ShellOutException ("'" ++ exe ++ "' exited with return value " ++ show i ++ ".") i)
-- | Command for building the project, producing an executable binary or a shared library.
commandBuild :: Bool -> NullaryCommandCallback
commandBuild shutUp ctx = do
commandBuild :: VariadicCommandCallback
commandBuild ctx [] = commandBuild ctx [falseXObj]
commandBuild ctx [XObj (Bol shutUp) _ _] = do
let env = contextGlobalEnv ctx
typeEnv = contextTypeEnv ctx
proj = contextProj ctx
@ -348,6 +349,10 @@ commandBuild shutUp ctx = do
else case Map.lookup "main" (envBindings env) of
Just _ -> compile True
Nothing -> compile False
commandBuild ctx [arg] =
pure (evalError ctx ("`build` expected a boolean argument, but got `" ++ pretty arg ++ "`.") (xobjInfo arg))
commandBuild ctx args =
pure (evalError ctx ("`build` expected a single boolean argument, but got `" ++ unwords (map pretty args) ++ "`.") (xobjInfo (head args)))
setProjectCanExecute :: Bool -> Context -> Context
setProjectCanExecute value ctx =

View File

@ -645,13 +645,14 @@ executeCommand ctx@(Context env _ _ _ _ _ _ _) xobj =
[ XObj Do (Just dummyInfo) Nothing,
xobj',
XObj
(Lst [XObj (Sym (SymPath [] "build") Symbol) (Just dummyInfo) Nothing])
(Lst [XObj (Sym (SymPath [] "build") Symbol) (Just dummyInfo) Nothing, trueXObj])
(Just dummyInfo)
Nothing,
XObj
(Lst [XObj (Sym (SymPath [] "run") Symbol) (Just dummyInfo) Nothing])
(Just dummyInfo)
Nothing
Nothing,
(XObj (Lst []) (Just dummyInfo) (Just UnitTy))
]
)
(Just dummyInfo)

View File

@ -233,7 +233,6 @@ dynamicModule =
in [ f "quit" commandQuit "quits the program." "(quit)",
f "cat" commandCat "spits out the generated C code." "(cat)",
f "run" commandRunExe "runs the built executable." "(run)",
f "build" (commandBuild False) "builds the current code to an executable." "(build)",
f "reload" commandReload "reloads all currently loaded files that werent marked as only loading once (see `load` and `load-once`)." "(reload)",
f "env" commandListBindings "lists all current bindings." "(env)",
f "project" commandProject "prints the current project state." "(project)",
@ -285,7 +284,8 @@ dynamicModule =
f "str" commandStr "stringifies its arguments." "(str 1 \" \" 2 \" \" 3) ; => \"1 2 3\"",
f "s-expr" commandSexpression "returns the s-expression associated with a binding. When the binding is a type, the deftype form is returned instead of the type's module by default. Pass an optional bool argument to explicitly request the module for a type instead of its definition form. If the bool is true, the module for the type will be returned. Returns an error when no definition is found for the binding." "(s-expr foo), (s-expr foo true)",
f "load" commandLoad "loads a file into the current environment." "(load \"myfile.carp\")\n(load \"myrepo@version\" \"myfile\")",
f "load-once" commandLoadOnce "loads a file and prevents it from being reloaded (see `reload`)." "(load-once \"myfile.carp\")\n(load \"myrepo@version\" \"myfile\")"
f "load-once" commandLoadOnce "loads a file and prevents it from being reloaded (see `reload`)." "(load-once \"myfile.carp\")\n(load \"myrepo@version\" \"myfile\")",
f "build" commandBuild "builds the current code to an executable. Optionally takes a boolean that, when true, silences the output." "(build)"
]
unaries' =
let f = makeUnaryPrim . spath