Commit fd72bc3a authored by Jonas Oberschweiber's avatar Jonas Oberschweiber

Pass options to cpm curry to compiler

parent 99cc1cdf
......@@ -62,19 +62,19 @@ runWithArgs opts = do
else return ()
setLogLevel $ optLogLevel opts
result <- case optCommand opts of
NoCommand -> failIO "NoCommand"
Deps -> deps config repo globalCache
PkgInfo o -> info o config repo globalCache
Install o -> install o config repo globalCache
Compiler -> compiler config repo globalCache
Exec o -> exec o config repo globalCache
Diff o -> diff o config repo globalCache
NoCommand -> failIO "NoCommand"
Deps -> deps config repo globalCache
PkgInfo o -> info o config repo globalCache
Install o -> install o config repo globalCache
Compiler o -> compiler o config repo globalCache
Exec o -> exec o config repo globalCache
Diff o -> diff o config repo globalCache
Uninstall o -> uninstall o config repo globalCache
Update -> update config repo globalCache
Search o -> search o config repo
Upgrade o -> upgrade o config repo globalCache
Link o -> link o config repo globalCache
New -> newPackage
Update -> update config repo globalCache
Search o -> search o config repo
Upgrade o -> upgrade o config repo globalCache
Link o -> link o config repo globalCache
New -> newPackage
case result of
(msgs, _) -> mapIO showLogEntry msgs >> return ()
......@@ -88,7 +88,7 @@ data Command
| Install InstallOptions
| Uninstall UninstallOptions
| PkgInfo InfoOptions
| Compiler
| Compiler CompilerOptions
| Update
| Search SearchOptions
| Upgrade UpgradeOptions
......@@ -122,6 +122,9 @@ data LinkOptions = LinkOptions
data ExecOptions = ExecOptions
{ exeCommand :: String }
data CompilerOptions = CompilerOptions
{ comCommand :: String }
data DiffOptions = DiffOptions
{ diffVersion :: Version
, diffModules :: Maybe [String]
......@@ -163,6 +166,11 @@ execOpts s = case optCommand s of
Exec opts -> opts
_ -> ExecOptions ""
compOpts :: Options -> CompilerOptions
compOpts s = case optCommand s of
Compiler opts -> opts
_ -> CompilerOptions ""
diffOpts :: Options -> DiffOptions
diffOpts s = case optCommand s of
Diff opts -> opts
......@@ -224,8 +232,12 @@ optionParser = optParser
<> help "The version to be uninstalled") )
<|> command "deps" (help "Calculate dependencies") (\a -> Right $ a { optCommand = Deps }) []
<|> command "new" (help "Create a new package") (\a -> Right $ a { optCommand = New }) []
<|> command "curry" (help "Load package spec from current directory and start Curry with correct dependencies.") (\a -> Right $ a { optCommand = Compiler }) []
<|> command "update" (help "Update the package index") (\a -> Right $ a { optCommand = Update }) []
<|> command "curry" (help "Load package spec from current directory and start Curry with correct dependencies.") (\a -> Right $ a { optCommand = Compiler (compOpts a) })
( rest (\s a -> Right $ a { optCommand = Compiler (compOpts a) { comCommand = s } })
( metavar "ARGS"
<> help "The options to pass to the compiler"
<> optional) )
<|> command "exec" (help "Execute a command with the CURRYPATH set") (\a -> Right $ a { optCommand = Exec (execOpts a) })
( rest (\s a -> Right $ a { optCommand = Exec (execOpts a) { exeCommand = s } })
( metavar "COMMAND"
......@@ -306,15 +318,15 @@ info (InfoOptions Nothing (Just _)) _ _ _ = failIO "Must specify package name"
printInfo :: Repository -> GlobalCache -> Package -> IO (ErrorLogger ())
printInfo repo gc pkg = putStrLn (renderPackageInfo repo gc pkg) >> succeedIO ()
compiler :: Config -> Repository -> GlobalCache -> IO (ErrorLogger ())
compiler cfg repo gc = tryFindLocalPackageSpec "." |>=
compiler :: CompilerOptions -> Config -> Repository -> GlobalCache -> IO (ErrorLogger ())
compiler o cfg repo gc = tryFindLocalPackageSpec "." |>=
\specDir -> resolveAndCopyDependencies cfg repo gc specDir |>=
\pkgs -> getAbsolutePath specDir >>= \abs -> succeedIO () |>
succeedIO (abs </> "src") |>=
\srcDir -> log Info ("Starting Curry with CURRYPATH " ++ (dependencyPaths pkgs abs) ++ ":" ++ srcDir) |>
do
setEnviron "CURRYPATH" $ (dependencyPaths pkgs abs) ++ ":" ++ srcDir
system "curry"
system $ "curry " ++ comCommand o
unsetEnviron "CURRYPATH"
succeedIO ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment