CLI: Initialize package path for in-build-tree execution
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 26 Sep 2015 08:59:11 +0100
changeset 18e2168260b75a
parent 17 ee807ff2f897
child 19 7597503194b8
CLI: Initialize package path for in-build-tree execution

To allow for testing of CLI without need to deploy whole compiler toolchain.
compiler/cli/TCompilerCommand.st
     1.1 --- a/compiler/cli/TCompilerCommand.st	Fri Sep 25 21:58:10 2015 +0100
     1.2 +++ b/compiler/cli/TCompilerCommand.st	Sat Sep 26 08:59:11 2015 +0100
     1.3 @@ -57,9 +57,10 @@
     1.4      super initialize.
     1.5      debugging := Transcript notNil and:[Transcript isView].    
     1.6      self setupSignalHandlers.
     1.7 +    self setupPackagePath.
     1.8  
     1.9      "Created: / 06-11-2011 / 22:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.10 -    "Modified: / 01-09-2015 / 18:42:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.11 +    "Modified: / 26-09-2015 / 08:09:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.12  ! !
    1.13  
    1.14  !TCompilerCommand class methodsFor:'compiling'!
    1.15 @@ -69,6 +70,13 @@
    1.16  
    1.17      | env ctx compiler units |
    1.18  
    1.19 +    debugging ifTrue:[
    1.20 +        Stderr nextPutLine: 'Package path:'.
    1.21 +        Smalltalk packagePath do:[:each | 
    1.22 +            Stderr space; space; nextPutLine: each.
    1.23 +        ].
    1.24 +    ].
    1.25 +
    1.26      env := TEnvironment new.
    1.27      env provider classpath addAll: includes.
    1.28  
    1.29 @@ -112,7 +120,7 @@
    1.30      ].
    1.31  
    1.32      "Created: / 24-09-2015 / 16:46:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.33 -    "Modified: / 24-09-2015 / 18:45:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.34 +    "Modified: / 26-09-2015 / 07:52:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.35  !
    1.36  
    1.37  write: anLLVMModule as: aString
    1.38 @@ -265,6 +273,22 @@
    1.39      "Created: / 27-06-2013 / 23:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.40  !
    1.41  
    1.42 +setupPackagePath
    1.43 +    | current |
    1.44 +    "/ Search for package path in case of in-build (non-deployed) execution
    1.45 +    current := OperatingSystem pathOfSTXExecutable asFilename directory.
    1.46 +    [ current isRootDirectory ] whileFalse:[
    1.47 +        (current / 'jv' / 'tea' / 'compiler' / 'cli') exists ifTrue:[ 
    1.48 +            Smalltalk packagePath:
    1.49 +                (Smalltalk packagePath copyWith: current pathName).
    1.50 +            ^ self
    1.51 +        ].
    1.52 +        current := current directory.
    1.53 +    ]
    1.54 +
    1.55 +    "Created: / 26-09-2015 / 08:09:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.56 +!
    1.57 +
    1.58  setupSignalHandlers
    1.59      "On UNIX, this sets up a custom signal handler on SIGUSR2 and SIGTERM that
    1.60       dumps stacks on all threads"