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)
|
, Option [] ["help-warnings"] (NoArg optPrintWarningHelp)
|
||||||
"print help about warning options"
|
"print help about warning options"
|
||||||
, Option ['k'] ["keep-temporaries"] (NoArg $ optKeepTemporaries) "keep temporary files"
|
, 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 [] ["frontend"] (ReqArg optFrontend "FRONTEND") "language frontend (options: occam, rain)"
|
||||||
, Option [] ["mode"] (ReqArg optMode "MODE") "select mode (options: flowgraph, parse, compile, post-c, full)"
|
, Option [] ["mode"] (ReqArg optMode "MODE") "select mode (options: flowgraph, parse, compile, post-c, full)"
|
||||||
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
|
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
|
||||||
|
@ -115,6 +116,9 @@ optVerbose ps = return $ ps { csVerboseLevel = csVerboseLevel ps + 1 }
|
||||||
optKeepTemporaries :: OptFunc
|
optKeepTemporaries :: OptFunc
|
||||||
optKeepTemporaries ps = return $ ps { csKeepTemporaries = True }
|
optKeepTemporaries ps = return $ ps { csKeepTemporaries = True }
|
||||||
|
|
||||||
|
optRunIndent :: OptFunc
|
||||||
|
optRunIndent ps = return $ ps { csRunIndent = True }
|
||||||
|
|
||||||
optOutput :: String -> OptFunc
|
optOutput :: String -> OptFunc
|
||||||
optOutput s ps = return $ ps { csOutputFile = s }
|
optOutput s ps = return $ ps { csOutputFile = s }
|
||||||
|
|
||||||
|
@ -235,6 +239,8 @@ compileFull inputFile moutputFile
|
||||||
let cFile = outputFile ++ extension
|
let cFile = outputFile ++ extension
|
||||||
withOutputFile cFile $ compile ModeCompile inputFile
|
withOutputFile cFile $ compile ModeCompile inputFile
|
||||||
noteFile cFile
|
noteFile cFile
|
||||||
|
when (csRunIndent optsPS) $
|
||||||
|
exec $ "indent " ++ cFile
|
||||||
|
|
||||||
case csBackend optsPS of
|
case csBackend optsPS of
|
||||||
BackendC ->
|
BackendC ->
|
||||||
|
|
|
@ -12,7 +12,7 @@ checkout:
|
||||||
svn co http://projects.cs.kent.ac.uk/projects/kroc/svn/kroc/trunk/tests/cgtests
|
svn co http://projects.cs.kent.ac.uk/projects/kroc/svn/kroc/trunk/tests/cgtests
|
||||||
|
|
||||||
%: %.occ
|
%: %.occ
|
||||||
./tock -vk --backend=$(BACKEND) -o $@ $<
|
./tock -vk --backend=$(BACKEND) --run-indent -o $@ $<
|
||||||
|
|
||||||
run: $(tests)
|
run: $(tests)
|
||||||
cd cgtests && ./run-tests
|
cd cgtests && ./run-tests
|
||||||
|
|
|
@ -104,6 +104,7 @@ data CompState = CompState {
|
||||||
csOutputFile :: String,
|
csOutputFile :: String,
|
||||||
csKeepTemporaries :: Bool,
|
csKeepTemporaries :: Bool,
|
||||||
csEnabledWarnings :: Set WarningType,
|
csEnabledWarnings :: Set WarningType,
|
||||||
|
csRunIndent :: Bool,
|
||||||
csClassicOccamMobility :: Bool,
|
csClassicOccamMobility :: Bool,
|
||||||
|
|
||||||
-- Set by preprocessor
|
-- Set by preprocessor
|
||||||
|
@ -147,6 +148,7 @@ emptyState = CompState {
|
||||||
, WarnUnknownPreprocessorDirective
|
, WarnUnknownPreprocessorDirective
|
||||||
, WarnUnusedVariable],
|
, WarnUnusedVariable],
|
||||||
-- TODO enable WarnUninitialisedVariable by default
|
-- TODO enable WarnUninitialisedVariable by default
|
||||||
|
csRunIndent = False,
|
||||||
csClassicOccamMobility = False,
|
csClassicOccamMobility = False,
|
||||||
|
|
||||||
csCurrentFile = "none",
|
csCurrentFile = "none",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user