Added full-compile support for the CHP backend

This commit is contained in:
Neil Brown 2008-11-26 12:48:48 +00:00
parent 78716a2727
commit e3c426e870
4 changed files with 16 additions and 14 deletions

20
Main.hs
View File

@ -276,11 +276,10 @@ compileFull inputFile moutputFile
("-", Nothing) -> dieReport (Nothing, "Must specify an output file when using full-compile mode")
(file, _) -> return file
let (cExtension, hExtension)
= case csBackend optsPS of
BackendC -> (".tock.c", ".tock.h")
BackendCPPCSP -> (".tock.cpp", ".tock.hpp")
_ -> ("", "")
let extension = case csBackend optsPS of
BackendC -> ".c"
BackendCPPCSP -> ".cpp"
_ -> ""
-- Translate input file to C/C++
let cFile = outputFile ++ cExtension
@ -331,14 +330,9 @@ compileFull inputFile moutputFile
-- For C++, just compile the source file directly into a binary
BackendCPPCSP ->
do cs <- lift getCompState
if csHasMain optsPS
then let otherOFiles = [usedFile ++ ".tock.o"
| usedFile <- Set.toList $ csUsedFiles cs]
in exec $ cxxCommand cFile outputFile
(concat (intersperse " " otherOFiles) ++ " " ++ csCompilerFlags optsPS ++ " " ++ csCompilerLinkFlags optsPS)
else exec $ cxxCommand cFile (outputFile ++ ".tock.o")
("-c " ++ csCompilerFlags optsPS)
exec $ cxxCommand cFile outputFile
(csCompilerFlags optsPS ++ " " ++ csCompilerLinkFlags optsPS)
_ -> dieReport (Nothing, "Cannot use specified backend: "
++ show (csBackend optsPS)
++ " with full-compile mode")

View File

@ -19,12 +19,16 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
-- | Generate CHP code from the AST
module GenerateCHP where
import Control.Monad.Trans
import System.IO
import qualified AST as A
import Pass
generateCHP :: Handle -> A.AST -> PassM ()
generateCHP h tr = genAST tr
generateCHP h tr = do
liftIO $ hPutStrLn h "main :: IO ()"
liftIO $ hPutStrLn h "main = return ()"
genAST tr
genAST _ = return ()

View File

@ -23,3 +23,6 @@ cLinkCommand files out extra = "@CC@ @TOCK_CFLAGS@ -o " ++ out ++ " " ++ (concat
cxxCommand :: String -> String -> String -> String
cxxCommand inp out extra = "@CXX@ @TOCK_CXXFLAGS@ " ++ tockIncludeFlags ++ " -o " ++ out ++ " " ++ inp ++ " @TOCK_CXXLDFLAGS@"
++ " " ++ extra
hCommand :: String -> String -> String
hCommand inp out = "@GHC@ --make " ++ inp ++ " -o " ++ out

View File

@ -36,6 +36,7 @@ AC_DEFUN([AC_NEED_PROG],
#Check that they have alex, GHC, svn and the CCSP headers:
AC_NEED_PROG(ghc,HAVE_ghc)
AC_PATH_PROG(GHC,ghc)
AC_NEED_PROG(ghc-pkg,HAVE_ghcpkg)
AC_NEED_PROG(alex,HAVE_alex)