compiler/cli/TCompilerCommand.st
changeset 18 e2168260b75a
parent 17 ee807ff2f897
equal deleted inserted replaced
17:ee807ff2f897 18:e2168260b75a
    55 initialize
    55 initialize
    56 
    56 
    57     super initialize.
    57     super initialize.
    58     debugging := Transcript notNil and:[Transcript isView].    
    58     debugging := Transcript notNil and:[Transcript isView].    
    59     self setupSignalHandlers.
    59     self setupSignalHandlers.
       
    60     self setupPackagePath.
    60 
    61 
    61     "Created: / 06-11-2011 / 22:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    62     "Created: / 06-11-2011 / 22:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    62     "Modified: / 01-09-2015 / 18:42:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    63     "Modified: / 26-09-2015 / 08:09:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    63 ! !
    64 ! !
    64 
    65 
    65 !TCompilerCommand class methodsFor:'compiling'!
    66 !TCompilerCommand class methodsFor:'compiling'!
    66 
    67 
    67 process: files
    68 process: files
    68     "Actually compile files using `options` and `includes`."
    69     "Actually compile files using `options` and `includes`."
    69 
    70 
    70     | env ctx compiler units |
    71     | env ctx compiler units |
       
    72 
       
    73     debugging ifTrue:[
       
    74         Stderr nextPutLine: 'Package path:'.
       
    75         Smalltalk packagePath do:[:each | 
       
    76             Stderr space; space; nextPutLine: each.
       
    77         ].
       
    78     ].
    71 
    79 
    72     env := TEnvironment new.
    80     env := TEnvironment new.
    73     env provider classpath addAll: includes.
    81     env provider classpath addAll: includes.
    74 
    82 
    75     ctx := TCompilerContext new.
    83     ctx := TCompilerContext new.
   110     options output notNil ifTrue:[ 
   118     options output notNil ifTrue:[ 
   111         self write: ctx llvmModule as: options output.
   119         self write: ctx llvmModule as: options output.
   112     ].
   120     ].
   113 
   121 
   114     "Created: / 24-09-2015 / 16:46:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   122     "Created: / 24-09-2015 / 16:46:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   115     "Modified: / 24-09-2015 / 18:45:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   123     "Modified: / 26-09-2015 / 07:52:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   116 !
   124 !
   117 
   125 
   118 write: anLLVMModule as: aString
   126 write: anLLVMModule as: aString
   119     options emitIR ifTrue:[ 
   127     options emitIR ifTrue:[ 
   120         aString asFilename writingFileDo:[:s|anLLVMModule dumpOn: s].  
   128         aString asFilename writingFileDo:[:s|anLLVMModule dumpOn: s].  
   261 
   269 
   262 handleSIGUSR2
   270 handleSIGUSR2
   263     self dumpProcesses
   271     self dumpProcesses
   264 
   272 
   265     "Created: / 27-06-2013 / 23:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   273     "Created: / 27-06-2013 / 23:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   274 !
       
   275 
       
   276 setupPackagePath
       
   277     | current |
       
   278     "/ Search for package path in case of in-build (non-deployed) execution
       
   279     current := OperatingSystem pathOfSTXExecutable asFilename directory.
       
   280     [ current isRootDirectory ] whileFalse:[
       
   281         (current / 'jv' / 'tea' / 'compiler' / 'cli') exists ifTrue:[ 
       
   282             Smalltalk packagePath:
       
   283                 (Smalltalk packagePath copyWith: current pathName).
       
   284             ^ self
       
   285         ].
       
   286         current := current directory.
       
   287     ]
       
   288 
       
   289     "Created: / 26-09-2015 / 08:09:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   266 !
   290 !
   267 
   291 
   268 setupSignalHandlers
   292 setupSignalHandlers
   269     "On UNIX, this sets up a custom signal handler on SIGUSR2 and SIGTERM that
   293     "On UNIX, this sets up a custom signal handler on SIGUSR2 and SIGTERM that
   270      dumps stacks on all threads"
   294      dumps stacks on all threads"