Added an option to automatically run indent on C/C++ source before running GCC
This option is very handy when debugging the C/C++ output of Tock when GCC gives a compiler error.
This commit is contained in:
parent
936dc29fde
commit
1343954c2f
6
Main.hs
6
Main.hs
|
@ -63,6 +63,7 @@ optionsNoWarnings =
|
|||
, Option [] ["help-warnings"] (NoArg optPrintWarningHelp)
|
||||
"print help about warning options"
|
||||
, Option ['k'] ["keep-temporaries"] (NoArg $ optKeepTemporaries) "keep temporary files"
|
||||
, 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, parse, compile, post-c, full)"
|
||||
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
|
||||
|
@ -115,6 +116,9 @@ optVerbose ps = return $ ps { csVerboseLevel = csVerboseLevel ps + 1 }
|
|||
optKeepTemporaries :: OptFunc
|
||||
optKeepTemporaries ps = return $ ps { csKeepTemporaries = True }
|
||||
|
||||
optRunIndent :: OptFunc
|
||||
optRunIndent ps = return $ ps { csRunIndent = True }
|
||||
|
||||
optOutput :: String -> OptFunc
|
||||
optOutput s ps = return $ ps { csOutputFile = s }
|
||||
|
||||
|
@ -235,6 +239,8 @@ compileFull inputFile moutputFile
|
|||
let cFile = outputFile ++ extension
|
||||
withOutputFile cFile $ compile ModeCompile inputFile
|
||||
noteFile cFile
|
||||
when (csRunIndent optsPS) $
|
||||
exec $ "indent " ++ cFile
|
||||
|
||||
case csBackend optsPS of
|
||||
BackendC ->
|
||||
|
|
|
@ -12,7 +12,7 @@ checkout:
|
|||
svn co http://projects.cs.kent.ac.uk/projects/kroc/svn/kroc/trunk/tests/cgtests
|
||||
|
||||
%: %.occ
|
||||
./tock -vk --backend=$(BACKEND) -o $@ $<
|
||||
./tock -vk --backend=$(BACKEND) --run-indent -o $@ $<
|
||||
|
||||
run: $(tests)
|
||||
cd cgtests && ./run-tests
|
||||
|
|
|
@ -104,6 +104,7 @@ data CompState = CompState {
|
|||
csOutputFile :: String,
|
||||
csKeepTemporaries :: Bool,
|
||||
csEnabledWarnings :: Set WarningType,
|
||||
csRunIndent :: Bool,
|
||||
csClassicOccamMobility :: Bool,
|
||||
|
||||
-- Set by preprocessor
|
||||
|
@ -147,6 +148,7 @@ emptyState = CompState {
|
|||
, WarnUnknownPreprocessorDirective
|
||||
, WarnUnusedVariable],
|
||||
-- TODO enable WarnUninitialisedVariable by default
|
||||
csRunIndent = False,
|
||||
csClassicOccamMobility = False,
|
||||
|
||||
csCurrentFile = "none",
|
||||
|
|
Loading…
Reference in New Issue
Block a user