Commit 8ae55c54 authored by Michael Hanus 's avatar Michael Hanus

Parameter "--system=path" added to enable selection of Curry system for compilation of web script

parent 71a60e33
......@@ -8,21 +8,36 @@
--- which does all the work.
---
--- @author Michael Hanus
--- @version November 2018
--- @version September 2019
------------------------------------------------------------------------------
module MakeCGI
where
import Directory ( doesFileExist )
import Distribution ( installDir )
import FilePath ( (</>) )
import FilePath ( (</>) )
import List ( isPrefixOf )
import System
import HTML.CGI.PackageConfig ( packagePath )
main :: IO ()
main = do
args <- getArgs
args0 <- getArgs
-- check whether option `--system=xxx` is provided:
let (args1,args2) = break ("--system=" `isPrefixOf`) args0
(root,args) = if null args2
then (installDir, args1)
else (drop 9 (head args2), args1 ++ tail args2)
checkCurrySystem root
rc <- system (unwords ((packagePath </> "scripts" </> "makecgi.sh") :
map (\s -> '"' : s ++ "\"") (installDir : args)))
map (\s -> '"' : s ++ "\"") (root : args)))
exitWith rc
checkCurrySystem :: String -> IO ()
checkCurrySystem currydir = do
let currybin = currydir </> "bin" </> "curry"
isexec <- doesFileExist currybin
unless isexec $
error $ "Curry system executable '" ++ currybin ++ "' does not exist!"
......@@ -83,7 +83,9 @@ if [ $# != 1 -a $# != 3 ] ; then
echo "<curry> : name of the Curry program (without suffix) containing the script"
echo
echo "FURTHER OPTIONS:"
echo '-Dname=val : define (curry)rc property "name" as "val"'
echo "--system=path: set path to the root of Curry system"
echo " (then 'path/bin/curry' is invoked to compile script)"
echo '-Dname=val : define (curry)rc property "name" as "val"'
echo "--cpmexec <c>: set the command to execute programs with the Curry Package"
echo " Manager (default: 'cypm exec')"
echo "--compact : reduce size of generated cgi program by deleting unused functions"
......@@ -177,7 +179,7 @@ else
fi
# compile main module:
echo "Generating saved state for initial expression: $MAIN"
echo "Generating executable for initial expression: $MAIN"
$CPMEXEC $CURRYROOT/bin/curry --nocypm $CURRYDOPTIONS $CURRYOPTIONS :l $MAINMOD :save $MAINCALL :q
# now the file $MAINMOD should contain the executable computing the HTML form:
......
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