Removed kroc-wrapper.occ, in favour of generating it as a temporary file for each all-in-one compilation

This commit is contained in:
Neil Brown 2007-10-08 22:24:02 +00:00
parent 32fa80be0f
commit b0f5f6be77
3 changed files with 22 additions and 31 deletions

20
Main.hs
View File

@ -102,6 +102,21 @@ getOpts argv =
(_,_,errs) -> error (concat errs ++ usageInfo header options) (_,_,errs) -> error (concat errs ++ usageInfo header options)
where header = "Usage: tock [OPTION...] SOURCEFILE" where header = "Usage: tock [OPTION...] SOURCEFILE"
writeOccamWrapper :: Handle -> IO ()
writeOccamWrapper h = do
write "#INCLUDE \"cifccsp.inc\"\n"
write "#PRAGMA EXTERNAL \"PROC C.tock.main.init (INT raddr, CHAN BYTE in?, out!, err!) = 0\"\n"
write "#PRAGMA EXTERNAL \"PROC C.tock.main.free (VAL INT raddr) = 0\"\n"
write "PROC kroc.main (CHAN BYTE in?, out!, err!)\n"
write " INT addr:\n"
write " SEQ\n"
write " C.tock.main.init (addr, in?, out!, err!)\n"
write " cifccsp.startprocess (addr)\n"
write " C.tock.main.free (addr)\n"
write ":\n"
where
write = hPutStr h
main :: IO () main :: IO ()
main = do main = do
argv <- getArgs argv <- getArgs
@ -138,7 +153,10 @@ main = do
postCAnalyse (tempPath ++ ".s") tempHandlePost postCAnalyse (tempPath ++ ".s") tempHandlePost
liftIO $ hClose tempHandlePost liftIO $ hClose tempHandlePost
exec $ cCommand tempPathPost (tempPathPost ++ ".o") exec $ cCommand tempPathPost (tempPathPost ++ ".o")
exec $ krocLinkCommand (tempPath ++ ".o") (tempPathPost ++ ".o") destBin (tempPathOcc, tempHandleOcc) <- liftIO $ openTempFile "." "tock-temp.occ"
liftIO $ writeOccamWrapper tempHandleOcc
liftIO $ hClose tempHandleOcc
exec $ krocLinkCommand tempPathOcc [(tempPath ++ ".o"),(tempPathPost ++ ".o")] destBin
BackendCPPCSP -> exec $ cxxCommand tempPath destBin BackendCPPCSP -> exec $ cxxCommand tempPath destBin

View File

@ -24,12 +24,13 @@ TOCK_CXXFLAGS = -O2 -g -Wall -ggdb3 -I.
CompilerCommands.hs: Makefile CompilerCommands.hs: Makefile
echo -e 'module CompilerCommands where\n' > CompilerCommands.hs echo -e 'module CompilerCommands where\n' > CompilerCommands.hs
echo -e '--This file is auto-generated by Makefile.am\n' >> CompilerCommands.hs echo -e '--This file is auto-generated by Makefile.am\n' >> CompilerCommands.hs
echo -e 'import Data.List\n' >> CompilerCommands.hs
echo -e 'cCommand :: String -> String -> String\n' >> CompilerCommands.hs echo -e 'cCommand :: String -> String -> String\n' >> CompilerCommands.hs
echo -e 'cCommand inp out = "$(CC) $(TOCK_CFLAGS) -x c -c -o " ++ out ++ " " ++ inp\n' >> CompilerCommands.hs echo -e 'cCommand inp out = "$(CC) $(TOCK_CFLAGS) -x c -c -o " ++ out ++ " " ++ inp\n' >> CompilerCommands.hs
echo -e 'cAsmCommand :: String -> String -> String\n' >> CompilerCommands.hs echo -e 'cAsmCommand :: String -> String -> String\n' >> CompilerCommands.hs
echo -e 'cAsmCommand inp out = "$(CC) $(TOCK_CFLAGS) -x c -S -o " ++ out ++ " " ++ inp\n' >> CompilerCommands.hs echo -e 'cAsmCommand inp out = "$(CC) $(TOCK_CFLAGS) -x c -S -o " ++ out ++ " " ++ inp\n' >> CompilerCommands.hs
echo -e 'krocLinkCommand :: String -> String -> String -> String\n' echo -e 'krocLinkCommand :: String -> [String] -> String -> String\n'
echo -e 'krocLinkCommand fileA fileB out = "kroc -o " ++ out ++ " kroc-wrapper.occ " ++ fileA ++ " " ++ fileB ++ " -lcif"\n' >> CompilerCommands.hs echo -e 'krocLinkCommand wrapper files out = "kroc -o " ++ out ++ " " ++ wrapper ++ " " ++ (concat (intersperse " " files)) ++ " -lcif"\n' >> CompilerCommands.hs
echo -e 'cxxCommand :: String -> String -> String\n' >> CompilerCommands.hs echo -e 'cxxCommand :: String -> String -> String\n' >> CompilerCommands.hs
echo -e 'cxxCommand inp out = "$(CXX) $(TOCK_CXXFLAGS) -x c++ -o " ++ out ++ " " ++ inp\n' >> CompilerCommands.hs echo -e 'cxxCommand inp out = "$(CXX) $(TOCK_CXXFLAGS) -x c++ -o " ++ out ++ " " ++ inp\n' >> CompilerCommands.hs

View File

@ -1,28 +0,0 @@
-- KRoC wrapper to run Tock-generated CIF program
-- Copyright (C) 2007 University of Kent
--
-- This library is free software; you can redistribute it and/or modify it
-- under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation, either version 2 of the License, or (at
-- your option) any later version.
--
-- This library is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
-- General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public License
-- along with this library. If not, see <http://www.gnu.org/licenses/>.
#INCLUDE "cifccsp.inc"
#PRAGMA EXTERNAL "PROC C.tock.main.init (INT raddr, CHAN BYTE in?, out!, err!) = 0"
#PRAGMA EXTERNAL "PROC C.tock.main.free (VAL INT raddr) = 0"
PROC kroc.main (CHAN BYTE in?, out!, err!)
INT addr:
SEQ
C.tock.main.init (addr, in?, out!, err!)
cifccsp.startprocess (addr)
C.tock.main.free (addr)
: