#QUALITY by stefan
authorStefan Vogel <sv@exept.de>
Fri, 11 May 2018 09:40:31 +0200
changeset 4250 2903262d8033
parent 4249 a308dc806db6
child 4251 299bb2bfcc35
#QUALITY by stefan class: STCCompilerInterface changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent: #reportCompilationErrorFor: class: STCCompilerInterface class changed: #initialize Better errrot message when compilation fails
STCCompilerInterface.st
--- a/STCCompilerInterface.st	Thu May 10 11:17:30 2018 +0200
+++ b/STCCompilerInterface.st	Fri May 11 09:40:31 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
  COPYRIGHT (c) 2006 by eXept Software AG
@@ -204,6 +206,9 @@
 
 initialize
     Verbose := false.
+    KeepIntermediateFiles := false.
+
+    "Modified: / 11-05-2018 / 09:34:34 / stefan"
 ! !
 
 !STCCompilerInterface methodsFor:'accessing'!
@@ -309,7 +314,7 @@
         self setupCompilationCommandArguments.
         ok := self 
                 compileToC_onError:[:errorFile |
-                    self reportCompilationErrorFor:stcPath fromFile:errorFile
+                    self reportCompilationErrorFor:stcPath, stcFlags fromFile:errorFile
                 ].
 
         parserFlags stcKeepSIntermediate ifTrue:[ 
@@ -318,7 +323,7 @@
         "/ now compile to machine code
         ok := self 
                 compileToObj_onError:[:errorFile |
-                    self reportCompilationErrorFor:ccPath fromFile:errorFile.
+                    self reportCompilationErrorFor:ccPath, cFlags fromFile:errorFile.
                 ].
 
         originator activityNotification:''.
@@ -354,7 +359,7 @@
         originator activityNotification:''.
 
         handle isNil ifTrue:[
-            KeepIntermediateFiles ~~ true ifTrue:[ OperatingSystem removeFile:dllFileName ].
+            KeepIntermediateFiles ifFalse:[ dllFileName asFilename remove ].
             "catch, so that #CannotLoad processing is done"
             ParseError catch:[
                 originator parseError:'dynamic load of machine code failed' position:1.
@@ -428,37 +433,37 @@
             ^ newMethod.
         ].
 
-        "/ OperatingSystem removeFile:moduleFileName.
+        "/ moduleFileName asFilename remove.
         self parseError:'dynamic load failed' position:1.
     ] ensure:[
-        KeepIntermediateFiles == true ifTrue:[ 
+        KeepIntermediateFiles ifTrue:[ 
             Transcript showCR:'keeping files'
         ] ifFalse:[
             parserFlags stcKeepSTIntermediate ifTrue:[
                 Transcript showCR:'keeping st file: ', stFileName asFilename pathName
             ] ifFalse:[
-                OperatingSystem removeFile:stFileName.
+                stFileName asFilename remove.
             ].
             cFileName notNil ifTrue:[
                 parserFlags stcKeepCIntermediate == true ifTrue:[
                     Transcript showCR:'keeping c file: ', cFileName asFilename pathName
                 ] ifFalse:[
-                    OperatingSystem removeFile:cFileName.
+                    cFileName asFilename remove.
                 ]
             ].
             oFileName notNil ifTrue:[
                 parserFlags stcKeepOIntermediate == true ifTrue:[
                     Transcript showCR:'keeping o file: ', oFileName asFilename pathName
                 ] ifFalse:[
-                    OperatingSystem removeFile:oFileName.
+                    oFileName asFilename remove.
                 ].
             ].
 "/            OperatingSystem isMSDOSlike ifTrue:[
 "/                mapFileName notNil ifTrue:[
-"/                   OperatingSystem removeFile:mapFileName.
+"/                   mapFileName asFilename remove.
 "/                ].
 "/                libFileName notNil ifTrue:[
-"/                   OperatingSystem removeFile:libFileName.
+"/                   libFileName asFilename remove.
 "/                ].
 "/            ].
         ]
@@ -501,8 +506,8 @@
     "
 
     "Modified: / 14-09-1995 / 22:33:04 / claus"
-    "Modified: / 19-03-1999 / 08:31:42 / stefan"
     "Modified: / 17-09-2011 / 10:39:25 / cg"
+    "Modified: / 11-05-2018 / 09:39:33 / stefan"
 ! !
 
 !STCCompilerInterface methodsFor:'machine code generation-helpers'!
@@ -919,70 +924,13 @@
 !
 
 reportCompilationErrorFor:aCommand
-    |eMsg errorMessages lNr|
-
-    (executionStatus notNil and:[executionStatus couldNotExecute]) ifTrue:[
-        eMsg := 'oops, no %1 - cannot create machine code' bindWith:aCommand.
-    ] ifFalse:[
-        errorMessages := 'errorOutput' asFilename contents collect:[:l | OperatingSystem decodePathOrCommandOutput: l ].
-        OperatingSystem removeFile:'errorOutput'.
-
-        errorMessages notNil ifTrue:[
-            errorMessages := errorMessages reject:[:line | line includesString:'Warning:'].
-
-            errorMessages size > 20 ifTrue:[
-                errorMessages := errorMessages select:[:line | line asLowercase startsWith:'error'].
-                errorMessages size > 20 ifTrue:[
-                    errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped'
-                ].
-            ].
-"/                    errorMessages := errorMessages collect:[:line |
-"/                        (line startsWith:(stFileName , ':')) ifTrue:[
-"/                            'Line: ' , (line copyFrom:(stFileName size + 2))
-"/                        ] ifFalse:[
-"/                            line
-"/                        ]
-"/                      ].
-        ].
-        errorMessages isNil ifTrue:[
-            errorMessages := #('')
-        ].
-        errorMessages := (Array with:'Failed to execute: "', aCommand,'"') , errorMessages.
-
-        "/ try to extract a line number"
-        (errorMessages contains:[:line | line includesString:'Borland']) ifTrue:[
-            |i i2 s|
-            i := errorMessages findFirst:[:l | l startsWith:(cFileName,':')].
-            i ~~ 0 ifTrue:[
-                ((errorMessages at:i+1) startsWith:'Error') ifTrue:[
-                    i2 := (errorMessages at:i+1) indexOfSubCollection:(stFileName).
-                    i2 ~~ 0 ifTrue:[
-                        s := (errorMessages at:i+1) copyFrom:(i2+stFileName size+1).
-                        s := s readStream.
-                        lNr := Integer readFrom:s.
-                        s skipSeparators.
-                    ].    
-                ]
-            ].
-        ].
-
-        errorMessages isEmpty ifTrue:[
-            eMsg := 'Error during compilation:\\Unspecified error (no output)' withCRs
-        ] ifFalse:[
-            eMsg := 'Error during compilation:\\' withCRs ,
-                    (errorMessages asStringCollection asString).
-        ].
-    ].
-
-    originator activityNotification:''.
-
-    ParseError new
-        lineNumber:lNr;
-        errorMessage:eMsg;
-        raise.
+    <resource: #obsolete>
+    self obsoleteMethodWarning.
+    ^ self reportCompilationErrorFor:aCommand fromFile:'errorOutput' asFilename.
 
     "Created: / 07-11-2006 / 12:29:04 / cg"
     "Modified: / 21-12-2013 / 00:08:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-05-2018 / 09:29:20 / stefan"
 !
 
 reportCompilationErrorFor:aCommand fromFile:anErrorFilename