Commit 8b6eec46 authored by Michael Hanus's avatar Michael Hanus
Browse files

Compiler parameterization improved

parent ad121693
......@@ -175,12 +175,9 @@ checkFormIDsInProg opts mname formnames = do
else do
putStrLnInfo opts $
"Some forms have non-matching IDs: setting correct form IDs..."
case optSysName opts of
"pakcs" -> setFormIDsInFlatCurry opts mname
"kics2" -> setFormIDsInTypedFlatCurry opts mname
o -> do putStrLn $ "Unknown Curry system '" ++ o ++ "'. " ++
"Cannot set correct form IDs!"
exitWith 1
if optTypedFlat opts
then setFormIDsInTypedFlatCurry opts mname
else setFormIDsInFlatCurry opts mname
return (Just mname)
-- Test whether all `HtmlFormDef` identifiers in a module are correct,
......
......@@ -25,7 +25,7 @@ banner :: String
banner = unlines [bannerLine,bannerText,bannerLine]
where
bannerText = "Compile Curry programs with HTML forms to CGI executables " ++
"(Version of 17/12/20)"
"(Version of 26/04/21)"
bannerLine = take (length bannerText) (repeat '=')
------------------------------------------------------------------------------
......@@ -39,7 +39,7 @@ data Options = Options
, optForms :: [QName] -- qualified names of form operations
, optFormMods :: [String] -- names of modules containing form operations
, optSystem :: String -- path to root of Curry system
, optSysName :: String -- name of the Curry system ("pakcs", "kics2")
, optTypedFlat :: Bool -- does the Curry compiler require TypedFlatCurry?
, optCPM :: String -- command to invoke Curry Package Manager
, optCurryRC :: [String] -- curryrc options
, optCurryOpts :: [String] -- options passed to the Curry compiler
......@@ -48,7 +48,7 @@ data Options = Options
defaultOptions :: Options
defaultOptions =
Options 1 False "" "" [] [] installDir "" "cypm exec"
Options 1 False "" "" [] [] installDir False "cypm exec"
[] [":set -time", ":set -interactive"]
"-t 120"
......@@ -110,7 +110,8 @@ options =
, Option "s" ["system"]
(ReqArg (\s opts -> opts { optSystem = s }) "<s>")
("set path to the root of Curry system so that\n" ++
"'<s>/bin/curry' is invoked to compile script\n" ++
"'<s>/bin/curry' is invoked to compile script and\n" ++
"'<s>/bin/cleancurry' is invoked to clean itermediate files\n" ++
"(default: '" ++ installDir ++ "')")
, Option "" ["cpmexec"]
(ReqArg (\s opts -> opts { optCPM = s }) "<c>")
......
......@@ -50,12 +50,14 @@ checkCurrySystem opts = do
error $ "Curry system executable '" ++ currybin ++ "' does not exist!"
(rc,out,_) <- evalCmd currybin ["--compiler-name"] ""
unless (rc == 0) $
error "Cannot determine kind of Curry system (pakcs,kics2)!"
error "Cannot determine kind of Curry system (pakcs,kics2,curry2go)!"
let sysname = filter (not . isSpace) out
if sysname `elem` ["pakcs","kics2"]
then return opts { optSysName = sysname }
else do putStrLn $ "Unknown Curry system '" ++ sysname ++ "'."
exitWith 1
case sysname of
"pakcs" -> return opts { optTypedFlat = False }
"kics2" -> return opts { optTypedFlat = True }
"curry2go" -> return opts { optTypedFlat = False }
_ -> do putStrLn $ "Unknown Curry system '" ++ sysname ++ "'."
exitWith 1
-- Generate the main program containing the wrapper for all forms
-- and compile it into a CGI binary.
......@@ -77,12 +79,14 @@ compileCGI opts transmods mname = do
unless (null transmods) $ precompile mainmod
-- compile main module:
let curryverb = if optVerb opts == 2 then 1 else optVerb opts
cf <- system $ unwords $
[ optCPM opts, optSystem opts </> "bin" </> "curry" , "--nocypm" ] ++
map (\rcopts -> "-D" ++ rcopts) (optCurryRC opts) ++
[ ":set", 'v' : show curryverb ] ++
optCurryOpts opts ++
[ ":load", mainmod, ":save", maincall, ":quit" ]
compilecmd = unwords $
[ optCPM opts, optSystem opts </> "bin" </> "curry" , "--nocypm" ] ++
map (\rcopts -> "-D" ++ rcopts) (optCurryRC opts) ++
[ ":set", 'v' : show curryverb ] ++
optCurryOpts opts ++
[ ":load", mainmod, ":save", maincall, ":quit" ]
putStrLnInter opts $ "Executing: " ++ compilecmd
cf <- system compilecmd
when (cf > 0) $ do
putStrLn "Error occurred, generation aborted."
cleanMain mainmod
......@@ -102,11 +106,11 @@ compileCGI opts transmods mname = do
putStrLnInter opts $ "Modules transformed by setting form IDs:\n" ++
unwords transmods
putStrLnInfo opts $ "Pre-compiling " ++ mainmod ++ "..."
case optSysName opts of
"pakcs" -> do readFlatCurry mainmod
mapM_ (copyTransFlatCurry opts) transmods
"kics2" -> do readTypeAnnotatedFlatCurry mainmod
mapM_ (copyTransTypedFlatCurry opts) transmods
if optTypedFlat opts
then do readTypeAnnotatedFlatCurry mainmod
mapM_ (copyTransTypedFlatCurry opts) transmods
else do readFlatCurry mainmod
mapM_ (copyTransFlatCurry opts) transmods
cleanMain mainmod = do
system $ unwords [optSystem opts </> "bin" </> "cleancurry", mainmod]
......
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