--- a/STCCompilerInterface.st Thu Oct 13 00:50:39 2016 +0200
+++ b/STCCompilerInterface.st Thu Oct 13 00:52:26 2016 +0200
@@ -412,6 +412,67 @@
!STCCompilerInterface methodsFor:'machine code generation-helpers'!
+compileToC_onError:aBlock
+ "compile st to C using stc.
+ If any error happens, call aBlock passing it the fileName containing diagnostics"
+
+ |command ok errorOutputFile|
+
+ command := (self possiblyQuotedPath:stcPath) , ' ' , stcFlags
+ , '-E:',(self possiblyQuotedPath:Filename tempDirectory / 'lastIncrStcErrorOutput')
+ , ' -defdir=', (self possiblyQuotedPath:cFileName asFilename directory pathName).
+ cFileName asFilename suffix ~= 'c' ifTrue:[
+ command := command , ' -cSuffix=',cFileName asFilename suffix.
+ ].
+ command := command , ' -C ' , (self possiblyQuotedPath:stFileName asFilename pathName).
+
+ Verbose == true ifTrue:[
+ Transcript show:'executing: '; showCR:command.
+ ].
+
+ originator activityNotification:'compiling (stc)'.
+
+ errorOutputFile := Filename tempDirectory / 'stcErrorOutput'.
+ errorOutputFile writingFileDo:[:errorStream |
+ ok := OperatingSystem
+ executeCommand:command
+ inputFrom:nil
+ outputTo:errorStream
+ errorTo:errorStream
+ inDirectory:(OperatingSystem pathOfSTXExecutable)
+ showWindow:false
+ onError:[:stat|
+self halt.
+ executionStatus := stat.
+ false
+ ].
+ ].
+
+ cFileName asFilename exists ifTrue:[
+ ok ifFalse:[
+ 'Compiler [info]: oops - system says stc failed - but c-file is there ...' infoPrintCR.
+ ok := true
+ ]
+ ] ifFalse:[
+ ok ifTrue:[
+ 'Compiler [info]: oops - system says stc ok - but no c-file is there ...' infoPrintCR
+ ].
+ ok := false
+ ].
+
+ [
+ ok ifFalse:[
+ aBlock value:errorOutputFile
+ ].
+ ] ensure:[
+ errorOutputFile remove.
+ ].
+ ^ ok
+
+ "Created: / 07-11-2006 / 12:11:24 / cg"
+ "Modified: / 08-08-2011 / 22:12:01 / cg"
+!
+
compileToExe_onError:aBlock
"compile C to exe, using cc.
If any error happens, call aBlock passing it the fileName containing diagnostics"