Added full-compile support for the CHP backend
This commit is contained in:
parent
78716a2727
commit
e3c426e870
20
Main.hs
20
Main.hs
|
@ -276,11 +276,10 @@ compileFull inputFile moutputFile
|
||||||
("-", Nothing) -> dieReport (Nothing, "Must specify an output file when using full-compile mode")
|
("-", Nothing) -> dieReport (Nothing, "Must specify an output file when using full-compile mode")
|
||||||
(file, _) -> return file
|
(file, _) -> return file
|
||||||
|
|
||||||
let (cExtension, hExtension)
|
let extension = case csBackend optsPS of
|
||||||
= case csBackend optsPS of
|
BackendC -> ".c"
|
||||||
BackendC -> (".tock.c", ".tock.h")
|
BackendCPPCSP -> ".cpp"
|
||||||
BackendCPPCSP -> (".tock.cpp", ".tock.hpp")
|
_ -> ""
|
||||||
_ -> ("", "")
|
|
||||||
|
|
||||||
-- Translate input file to C/C++
|
-- Translate input file to C/C++
|
||||||
let cFile = outputFile ++ cExtension
|
let cFile = outputFile ++ cExtension
|
||||||
|
@ -331,14 +330,9 @@ compileFull inputFile moutputFile
|
||||||
|
|
||||||
-- For C++, just compile the source file directly into a binary
|
-- For C++, just compile the source file directly into a binary
|
||||||
BackendCPPCSP ->
|
BackendCPPCSP ->
|
||||||
do cs <- lift getCompState
|
exec $ cxxCommand cFile outputFile
|
||||||
if csHasMain optsPS
|
(csCompilerFlags optsPS ++ " " ++ csCompilerLinkFlags 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)
|
|
||||||
_ -> dieReport (Nothing, "Cannot use specified backend: "
|
_ -> dieReport (Nothing, "Cannot use specified backend: "
|
||||||
++ show (csBackend optsPS)
|
++ show (csBackend optsPS)
|
||||||
++ " with full-compile mode")
|
++ " with full-compile mode")
|
||||||
|
|
|
@ -19,12 +19,16 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-- | Generate CHP code from the AST
|
-- | Generate CHP code from the AST
|
||||||
module GenerateCHP where
|
module GenerateCHP where
|
||||||
|
|
||||||
|
import Control.Monad.Trans
|
||||||
import System.IO
|
import System.IO
|
||||||
|
|
||||||
import qualified AST as A
|
import qualified AST as A
|
||||||
import Pass
|
import Pass
|
||||||
|
|
||||||
generateCHP :: Handle -> A.AST -> PassM ()
|
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 ()
|
genAST _ = return ()
|
||||||
|
|
|
@ -23,3 +23,6 @@ cLinkCommand files out extra = "@CC@ @TOCK_CFLAGS@ -o " ++ out ++ " " ++ (concat
|
||||||
cxxCommand :: String -> String -> String -> String
|
cxxCommand :: String -> String -> String -> String
|
||||||
cxxCommand inp out extra = "@CXX@ @TOCK_CXXFLAGS@ " ++ tockIncludeFlags ++ " -o " ++ out ++ " " ++ inp ++ " @TOCK_CXXLDFLAGS@"
|
cxxCommand inp out extra = "@CXX@ @TOCK_CXXFLAGS@ " ++ tockIncludeFlags ++ " -o " ++ out ++ " " ++ inp ++ " @TOCK_CXXLDFLAGS@"
|
||||||
++ " " ++ extra
|
++ " " ++ extra
|
||||||
|
|
||||||
|
hCommand :: String -> String -> String
|
||||||
|
hCommand inp out = "@GHC@ --make " ++ inp ++ " -o " ++ out
|
||||||
|
|
|
@ -36,6 +36,7 @@ AC_DEFUN([AC_NEED_PROG],
|
||||||
#Check that they have alex, GHC, svn and the CCSP headers:
|
#Check that they have alex, GHC, svn and the CCSP headers:
|
||||||
|
|
||||||
AC_NEED_PROG(ghc,HAVE_ghc)
|
AC_NEED_PROG(ghc,HAVE_ghc)
|
||||||
|
AC_PATH_PROG(GHC,ghc)
|
||||||
AC_NEED_PROG(ghc-pkg,HAVE_ghcpkg)
|
AC_NEED_PROG(ghc-pkg,HAVE_ghcpkg)
|
||||||
AC_NEED_PROG(alex,HAVE_alex)
|
AC_NEED_PROG(alex,HAVE_alex)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user