From 95d7144c7b545637834b059597d04b2d42431a12 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 26 Mar 2009 22:36:13 +0000 Subject: [PATCH] Added the ability to specify linker flags separately from C compilation flags --- Main.hs | 11 ++++++++--- data/CompState.hs | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Main.hs b/Main.hs index 350dab4..abb9f65 100644 --- a/Main.hs +++ b/Main.hs @@ -65,6 +65,7 @@ optionsNoWarnings = "print help about warning options" , Option ['k'] ["keep-temporaries"] (NoArg $ optKeepTemporaries) "keep temporary files" , Option ['f'] ["compiler-flags"] (ReqArg optCompilerFlags "FLAGS") "flags for C/C++ compiler" + , Option [] ["external-link"] (ReqArg optCompilerLinkFlags "FLAGS") "link flags for C/C++ compiler" , Option [] ["run-indent"] (NoArg $ optRunIndent) "run indent on source before compilation (will full mode)" , Option [] ["frontend"] (ReqArg optFrontend "FRONTEND") "language frontend (options: occam, rain)" , Option [] ["mode"] (ReqArg optMode "MODE") "select mode (options: flowgraph, lex, html, parse, compile, post-c, full)" @@ -115,7 +116,10 @@ optFrontend s ps return $ ps { csFrontend = frontend } optCompilerFlags :: String -> OptFunc -optCompilerFlags flags ps = return $ ps { csCompilerFlags = flags } +optCompilerFlags flags ps = return $ ps { csCompilerFlags = flags ++ " " ++ csCompilerFlags ps} + +optCompilerLinkFlags :: String -> OptFunc +optCompilerLinkFlags flags ps = return $ ps { csCompilerLinkFlags = flags ++ " " ++ csCompilerLinkFlags ps} optVerbose :: OptFunc optVerbose ps = return $ ps { csVerboseLevel = csVerboseLevel ps + 1 } @@ -266,11 +270,12 @@ compileFull inputFile moutputFile -- Compile this new "post" C file into an object file exec $ cCommand postCFile postOFile (csCompilerFlags optsPS) -- Link the object files into a binary - exec $ cLinkCommand [oFile, postOFile] outputFile (csCompilerFlags optsPS) + exec $ cLinkCommand [oFile, postOFile] outputFile (csCompilerLinkFlags optsPS) -- For C++, just compile the source file directly into a binary BackendCPPCSP -> - exec $ cxxCommand cFile outputFile (csCompilerFlags optsPS) + exec $ cxxCommand cFile outputFile + (csCompilerFlags optsPS ++ " " ++ csCompilerLinkFlags optsPS) _ -> dieReport (Nothing, "Cannot use specified backend: " ++ show (csBackend optsPS) diff --git a/data/CompState.hs b/data/CompState.hs index f46cee7..eaf9314 100644 --- a/data/CompState.hs +++ b/data/CompState.hs @@ -99,6 +99,7 @@ data CompState = CompState { csBackend :: CompBackend, csFrontend :: CompFrontend, csCompilerFlags :: String, + csCompilerLinkFlags :: String, csSanityCheck :: Bool, csUsageChecking :: Bool, csVerboseLevel :: Int, @@ -139,6 +140,7 @@ emptyState = CompState { csBackend = BackendC, csFrontend = FrontendOccam, csCompilerFlags = "", + csCompilerLinkFlags = "", csSanityCheck = False, csUsageChecking = True, csVerboseLevel = 0,