STCCompilerInterface.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 04 Jan 2016 21:17:25 +0000
branchjv
changeset 3694 e89d2870030c
parent 3686 d8bf4414aa3d
child 3727 5ce5e4d7a752
permissions -rw-r--r--
STC interface clenaup: fixed compilation inder MINGW(32) MINGW(32) C compiler uses some dlls located in the same directtory as the compiler's executable - therefore that directory must be in PATH in order to find then. As it is not always guaranteed that the compiler is in the path, check the PATH and if it's not, add it there.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
 COPYRIGHT (c) 2006 by eXept Software AG
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
              All Rights Reserved
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 This software is furnished under a license and may be used
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 hereby transferred.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libcomp' }"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
    15
"{ NameSpace: Smalltalk }"
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
    16
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
Object subclass:#STCCompilerInterface
3240
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    18
	instanceVariableNames:'originator parserFlags initName theNonMetaclassToCompileFor
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    19
		classToCompileFor stFileName cFileName oFileName stcFlags cFlags
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    20
		stcPath ccPath requestor methodCategory executionStatus package'
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    21
	classVariableNames:'SequenceNumber Verbose KeepIntermediateFiles
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    22
		BuiltinCIncludeDirectories'
3240
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    23
	poolDictionaries:''
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    24
	category:'System-Compiler'
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!STCCompilerInterface class methodsFor:'documentation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
copyright
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 COPYRIGHT (c) 1989 by Claus Gittinger
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 COPYRIGHT (c) 2006 by eXept Software AG
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
              All Rights Reserved
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 This software is furnished under a license and may be used
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 only in accordance with the terms of that license and with the
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 inclusion of the above copyright notice.   This software may not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 be provided or otherwise made available to, or used by, any
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 other person.  No title to or ownership of the software is
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 hereby transferred.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
documentation
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    a refactored complex method - originally found in ByteCodeCompiler.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!STCCompilerInterface class methodsFor:'accessing'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    52
builtinCFlags
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    53
    "Return C compiler flags that are always passed to the C compiler
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    54
     when a (ST)C file is compiled."
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    55
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    56
    ^ OperatingSystem getCPUDefine , ' ', OperatingSystem getOSDefine
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    57
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    58
    "Created: / 04-12-2015 / 16:41:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    59
!
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    60
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    61
builtinCIncludeDirectories
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    62
    "Return C compiler include directories that are always passed to the C compiler
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    63
     when a (ST)C file is compiled."
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    64
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    65
    BuiltinCIncludeDirectories isNil ifTrue:[ 
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    66
        | executablePath |
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    67
        (executablePath := OperatingSystem pathOfSTXExecutable) notNil ifTrue:[
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    68
            executablePath := executablePath asFilename directory.
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    69
            ((executablePath / 'include' / 'stc.h') exists
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    70
              or:[((executablePath := executablePath directory) / 'include' / 'stc.h') exists
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    71
              or:[((executablePath := executablePath directory) / 'include' / 'stc.h') exists]])
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    72
                ifTrue:[
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    73
                    BuiltinCIncludeDirectories := '-I' , (executablePath / 'include') pathName.
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    74
                    ^ BuiltinCIncludeDirectories
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    75
                ]
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    76
        ].
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    77
        ^ ''
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    78
    ].
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    79
    ^ BuiltinCIncludeDirectories
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    80
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    81
    "
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    82
    STCCompilerInterface builtinCIncludeDirectories
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    83
    "
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    84
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    85
    "Created: / 09-12-2015 / 16:54:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    86
!
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    87
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    88
builtinCIncludeDirectories: aString
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    89
    "Set C compiler include directories that are always passed to the C compiler
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    90
     when a (ST)C file is compiled. 
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    91
     This is an entry for init scripts for custom Smalltalk/X distributions which use
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    92
     different directory layout than just a plain St/X worktree (such as Smalltalk/X jv-branch).
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    93
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    94
     Note, that this is a string, so it must include '-I'
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    95
     "
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    96
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    97
     BuiltinCIncludeDirectories := aString
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    98
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    99
    "Created: / 09-12-2015 / 16:59:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   100
!
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   101
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
stcPathOf:command 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    "return the path to an stc command, or nil if not found."
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    |f d reqdSuffix cmd|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    "/ care for executable suffix
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    cmd := command.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    OperatingSystem isMSDOSlike ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
        reqdSuffix := 'exe'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
        OperatingSystem isVMSlike ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
            reqdSuffix := 'EXE'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    reqdSuffix notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
        (f := cmd asFilename) suffix isEmpty ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
            cmd := (f withSuffix:reqdSuffix) name
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
        ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    "/ for our convenience, also check in current
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    "/ and parent directories; even if PATH does not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    "/ include them ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    "/ look in current ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    d := Filename currentDirectory.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    (f := d construct:cmd) isExecutable ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
        ^ f pathName
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    "/ look in ../stc ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    d := d construct:'..'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    (f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
        ^ f pathName
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    "/ look in ../../stc ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    d := d construct:'..'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    (f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
        ^ f pathName
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "/ ok, stc must be installed in some directory along the PATH
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    ^ OperatingSystem pathOfCommand:command
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
     STCCompilerInterface stcPathOf:'stc'     
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "Created: 13.9.1995 / 14:37:16 / claus"
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   154
!
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   155
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   156
verbose
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   157
    "if on, trace command execution on the Transcript"
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   158
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   159
    ^ Verbose
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   160
!
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   161
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   162
verbose:aBoolean 
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   163
    "if on, trace command execution on the Transcript"
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   164
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   165
    Verbose := aBoolean
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   166
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   167
    "
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   168
    STCCompilerInterface verbose: true.
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   169
    STCCompilerInterface verbose: false.
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   170
    "
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   171
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   172
    "Modified (comment): / 04-12-2015 / 16:44:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
!STCCompilerInterface class methodsFor:'class initialization'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
initialize
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    Verbose := false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
!STCCompilerInterface methodsFor:'accessing'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   183
cFileName:something
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   184
    cFileName := something.
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   185
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   186
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
incrementalStcPath 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    "return the path to the stc command for incremental method compilation, 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
     or nil if not found."
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    |f cmd|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    (cmd := parserFlags stcPath) isEmptyOrNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
        (f := self class stcPathOf:'stc') notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
            cmd := f
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
        ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
            cmd := self class stcPathOf:'demostc'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
        ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    (cmd notNil and:[cmd includes:Character space]) ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
        cmd := '"' , cmd , '"'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    ^ cmd
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    "Created: 13.9.1995 / 14:36:36 / claus"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    "Modified: 13.9.1995 / 15:15:04 / claus"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
originator:something
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    originator := something.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
parserFlags:something
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    parserFlags := something.
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   215
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   216
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   217
stFileName:something
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   218
    stFileName := something.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   221
!STCCompilerInterface methodsFor:'error raising'!
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   222
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   223
parseError:messageText position:position
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   224
    originator parseError:messageText position:position.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   225
    "not normally reached"
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   226
    ParseError raiseErrorString:messageText.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   227
! !
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   228
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
!STCCompilerInterface methodsFor:'machine code generation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   231
compileToMachineCode:aString forClass:aClass selector:selector inCategory:categoryArg 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   232
                             notifying:requestorArg install:install skipIfSame:skipIfSame silent:silent
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    "this is called to compile primitive code.
3357
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   234
     It saves the code to a tmporary, calls stc to create C-code, compiles it, links
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   235
     it to a tiny little dll and loads it.
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   236
     As you already see, this takes some time and is therefore ONLY done for code containing prims;
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   237
     all pure smalltalk code is compiled to bytecode and jitted by the VM."
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   239
    |handle oldMethod newMethod ok dllFileName|
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    install ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
        "/ cannot do it uninstalled. reason:
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
        "/ if it is loaded twice, the first version could be unloaded by
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
        "/ finalization, which would also unload the second version
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
        "/ (because the first unload would unload the second version too)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
        ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    ].
2704
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   248
    parserFlags isNil ifTrue:[
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   249
        parserFlags := ParserFlags new
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   250
    ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    parserFlags stcCompilation == #never ifTrue:[^ #CannotLoad].
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   252
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   253
    classToCompileFor := aClass.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   254
    requestor := requestorArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   255
    methodCategory := categoryArg.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   257
    self ensureExternalToolsArePresent.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   258
    self ensureModuleDirectoryExists.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   260
    theNonMetaclassToCompileFor := classToCompileFor theNonMetaclass.
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   261
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   262
    self ensureSuperClassesAreLoadedOf:theNonMetaclassToCompileFor.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   263
    theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass |
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   264
        self ensureSuperClassesAreLoadedOf:aPrivateClass.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   265
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   266
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   267
    (classToCompileFor isNil 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   268
    or:[parserFlags allowExtensionsToPrivateClasses 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   269
    or:[classToCompileFor owningClass isNil]]) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   270
        (requestor respondsTo:#packageToInstall) ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   271
            package := Class packageQuerySignal query.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   272
        ] ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   273
            package := requestor packageToInstall
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   274
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   275
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   276
        package := classToCompileFor owningClass package
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    [
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   280
        self generateSTSource:aString.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   281
        self setupCompilationCommandArguments.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   282
        ok := self compileToC.
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   283
        ok ifFalse:[
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   284
            self reportCompilationErrorFor:stcPath.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   287
        parserFlags stcKeepSIntermediate ifTrue:[ self compileToS ].
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   288
        "/ now compile to machine code
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   289
        ok := self compileToObj.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
        ok ifFalse:[
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
   291
            self reportCompilationErrorFor:ccPath.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
        originator activityNotification:''.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
        OperatingSystem removeFile:'errorOutput'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
         if required, make a shared or otherwise loadable object file for it
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
        originator activityNotification:'linking'.
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   301
        dllFileName := ObjectFileLoader createLoadableObjectFor:(oFileName asFilename withoutSuffix name).
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   302
        dllFileName isNil ifTrue:[
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
            "/ something went wrong
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   304
            self parseError:('link error: ' , ObjectFileLoader lastError) position:1.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
        ].
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   306
        dllFileName asFilename exists ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   307
            self parseError:'link failed - cannot create machine code' position:1.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   310
        oldMethod := classToCompileFor compiledMethodAt:selector.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   311
        oldMethod notNil ifTrue:[package := oldMethod package].
3159
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   312
        install ifTrue:[
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   313
            (Smalltalk
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   314
                    changeRequest:#methodInClass
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   315
                    with:(Array with:classToCompileFor with:selector with:oldMethod)) ifFalse:[
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   316
                ^ #CannotLoad
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   317
            ].
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   318
        ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
         load the method objectfile
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
        originator activityNotification:'loading'.
3361
dfa4c3b41d1e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3359
diff changeset
   324
        handle := ObjectFileLoader loadMethodObjectFile:dllFileName.
dfa4c3b41d1e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3359
diff changeset
   325
        originator activityNotification:''.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
        handle isNil ifTrue:[
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   328
            KeepIntermediateFiles ~~ true ifTrue:[ OperatingSystem removeFile:dllFileName ].
2185
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   329
            "catch, so that #CannotLoad processing is done"
3069
230e5da2ff5d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3042
diff changeset
   330
            ParseError catch:[
2185
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   331
                originator parseError:'dynamic load of machine code failed' position:1.
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   332
            ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
            ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
         did it work ?
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
        "
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   339
        newMethod := classToCompileFor compiledMethodAt:selector.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
        "/ if install is false, we have to undo the install (which is always done, when loading machine code)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
        install ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
            oldMethod isNil ifTrue:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   344
                classToCompileFor removeSelector:selector
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
            ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
                newMethod setPackage:oldMethod package.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   347
                classToCompileFor addSelector:selector withMethod:oldMethod.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   348
                oldMethod setPackage:package.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
            ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
        newMethod notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
            handle method ~~ newMethod ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
                'Compiler [warning]: loaded method installed itself in another class' errorPrintCR.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
            newMethod source:aString string.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   358
            newMethod setPackage:package.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
"/            Project notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
"/                newMethod package:(Project currentPackageName)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
"/            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   363
    "/        classToCompileFor updateRevisionString.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
            install ifTrue:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   365
                classToCompileFor addChangeRecordForMethod:newMethod fromOld:oldMethod.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
                "/ kludge-sigh: must send change messages manually here (stc-loaded code does not do it)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
                "/ see addMethod:... in ClassDescription
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   369
                classToCompileFor changed:#methodDictionary with:(Array with:selector with:oldMethod).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   370
                Smalltalk changed:#methodInClass with:(Array with:classToCompileFor with:selector with:oldMethod).
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   371
            ] ifFalse:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   372
                oldMethod := nil.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
1986
57913c678602 comment
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   375
            silent ifFalse:[
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   376
                Transcript showCR:('    compiled: ', aClass name,' ',selector,' - machine code')
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
            ObjectMemory flushCaches.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
            handle method:newMethod.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   382
            "/ check for obsolete compiled method code and unload the
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   383
            "/ corresponding ObjectFileHandle.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   384
            "/ The old method with its source code is usually kept in the method history.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   385
            "/ and will be recompiled on an undo
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
            ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
                anotherHandle isMethodHandle ifTrue:[
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   389
                    anotherHandle method == oldMethod ifTrue:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   390
                        "break association betwen old method, code and handle"
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   391
                        anotherHandle removeConnectedObjects.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   392
                    ].
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   393
                    anotherHandle isObsolete ifTrue:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   394
                        anotherHandle unload.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   395
                        anotherHandle removeUnusedObjectFile.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   396
                    ].
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   397
                ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
            ^ newMethod.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
3013
8f6ee079e44d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3012
diff changeset
   402
        "/ OperatingSystem removeFile:moduleFileName.
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   403
        self parseError:'dynamic load failed' position:1.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    ] ensure:[
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   405
        KeepIntermediateFiles == true ifTrue:[ 
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   406
            Transcript showCR:'keeping files'
2703
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   407
        ] ifFalse:[
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   408
            parserFlags stcKeepSTIntermediate ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   409
                Transcript showCR:'keeping st file: ', stFileName asFilename pathName
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   410
            ] ifFalse:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   411
                OperatingSystem removeFile:stFileName.
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   412
                OperatingSystem removeFile:'errorOutput'.
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   413
            ].
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   414
            cFileName notNil ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   415
                parserFlags stcKeepCIntermediate == true ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   416
                    Transcript showCR:'keeping c file: ', cFileName asFilename pathName
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   417
                ] ifFalse:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   418
                    OperatingSystem removeFile:cFileName.
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   419
                ]
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   420
            ].
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   421
            oFileName notNil ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   422
                parserFlags stcKeepOIntermediate == true ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   423
                    Transcript showCR:'keeping o file: ', oFileName asFilename pathName
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   424
                ] ifFalse:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   425
                    OperatingSystem removeFile:oFileName.
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   426
                ].
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   427
            ].
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   428
"/            OperatingSystem isMSDOSlike ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   429
"/                mapFileName notNil ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   430
"/                   OperatingSystem removeFile:mapFileName.
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   431
"/                ].
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   432
"/                libFileName notNil ifTrue:[
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   433
"/                   OperatingSystem removeFile:libFileName.
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   434
"/                ].
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   435
"/            ].
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   436
        ]
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
     |m|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
     Object subclass:#Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
            instanceVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
            classVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
            poolDictionaries:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
            category:'tests'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
     m := ByteCodeCompiler
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
            compile:'foo ^ ''hello'''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
            forClass:Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
            inCategory:'tests'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
            notifying:nil
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
            install:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
            skipIfSame:false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
     m inspect
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
     |m|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
     Object subclass:#Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
            instanceVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
            classVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
            poolDictionaries:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
            category:'tests'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
     m := ByteCodeCompiler
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
            forClass:Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
            inCategory:'tests'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
            notifying:nil
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
            install:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
            skipIfSame:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
            silent:false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
     m inspect
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   475
    "Modified: / 14-09-1995 / 22:33:04 / claus"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   476
    "Modified: / 19-03-1999 / 08:31:42 / stefan"
2704
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   477
    "Modified: / 17-09-2011 / 10:39:25 / cg"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   478
! !
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   479
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   480
!STCCompilerInterface methodsFor:'machine code generation-helpers'!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   481
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   482
compileToC
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   483
    "compile st to C using stc"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   484
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   485
    |command errorStream ok|
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   486
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   487
    command := (self possiblyQuotedPath:stcPath) , ' ' , stcFlags 
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   488
                , ' -defdir=', (self possiblyQuotedPath:cFileName asFilename directory pathName).
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
   489
    cFileName asFilename suffix ~= 'c' ifTrue:[
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   490
        command := command , ' -cSuffix=',cFileName asFilename suffix.
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   491
    ].
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   492
    command := command ,
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   493
                ' -C ' , (self possiblyQuotedPath:stFileName asFilename pathName).
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   494
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   495
    errorStream := 'errorOutput' asFilename writeStream.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   496
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   497
    Verbose == true ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   498
        'executing: ' infoPrint. command infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   499
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   500
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   501
    originator activityNotification:'compiling (stc)'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   502
    ok := OperatingSystem 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   503
                executeCommand:command 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   504
                inputFrom:nil
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   505
                outputTo:errorStream
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   506
                errorTo:errorStream
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   507
                onError:[:stat| 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   508
                            executionStatus := stat.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   509
                            false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   510
                        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   511
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   512
    errorStream close.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   513
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   514
    cFileName asFilename exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   515
        ok ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   516
            'Compiler [info]: oops - system says stc failed - but c-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   517
            ok := true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   518
        ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   519
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   520
        ok ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   521
            'Compiler [info]: oops - system says stc ok - but no c-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   522
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   523
        ok := false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   524
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   525
    ^ ok
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   526
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   527
    "Created: / 07-11-2006 / 12:11:24 / cg"
2643
60d2bae2be58 comment/format in: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
   528
    "Modified: / 08-08-2011 / 22:12:01 / cg"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   529
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   530
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   531
compileToExe
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   532
    "compile C to exe, using cc"
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   533
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   534
    |command errorStream ok|
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   535
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   536
    errorStream := 'errorOutput' asFilename newReadWriteStream.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   537
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   538
    command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ ' , (self possiblyQuotedPath:cFileName).
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   539
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   540
    Verbose == true ifTrue:[
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   541
        'executing: ' infoPrint. command infoPrintCR.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   542
    ].
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   543
    originator activityNotification:'compiling (' , ccPath , ')'.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   544
    ok := OperatingSystem 
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   545
                executeCommand:command 
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   546
                inputFrom:nil
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   547
                outputTo:errorStream
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   548
                errorTo:errorStream
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   549
                onError:[:stat| 
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   550
                            executionStatus := stat.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   551
                            false
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   552
                ].
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   553
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   554
    ok ifFalse:[
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   555
        errorStream reset.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   556
        errorStream copyToEndInto:Transcript.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   557
    ].
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   558
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   559
    errorStream close.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   560
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   561
    ^ ok
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   562
!
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   563
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   564
compileToObj
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   565
    "compile C to obj, using cc"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   566
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   567
    |errorStream ok commandTemplate command ccDefine env|
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   568
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   569
    errorStream := 'errorOutput' asFilename newReadWriteStream.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   570
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   571
    "/ bcc does not like -D__BORLANDC__ (needs to be set to a version, such as 0x0505
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   572
    "/ others do not need it (is already predefined in the compiler)
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   573
    "/ ccDefine := ' -D',ParserFlags usedCompilerDefine.
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   574
    "/ so, never redefine ccDefine
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   575
    ccDefine := ''.
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   576
3010
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   577
    ParserFlags useBorlandC ifTrue:[
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   578
        "Note: Windows/bcc32 does not understand a space between -o and filename"
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   579
        "/ cg: I guess, this does not work for visual-c
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   580
        commandTemplate := '%1 %2%3 -D__INCREMENTAL_COMPILE__ -o%4 -c %5'.
3010
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   581
    ] ifFalse:[
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   582
        commandTemplate := '%1 %2%3 -D__INCREMENTAL_COMPILE__ -o %4 -c %5'.
3010
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   583
    ].
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   584
    command := commandTemplate
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   585
                    bindWith:(self possiblyQuotedPath:ccPath) 
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   586
                    with:cFlags
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   587
                    with:ccDefine
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   588
                    with:(self possiblyQuotedPath:oFileName)
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   589
                    with:(self possiblyQuotedPath:cFileName).
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   590
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   591
    Verbose == true ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   592
        'executing: ' infoPrint. command infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   593
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   594
    originator activityNotification:'compiling (' , ccPath , ')'.
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   595
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   596
    env := OperatingSystem isUNIXlike
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   597
                    ifTrue:[OperatingSystem getEnvironment copy]
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   598
                    ifFalse:[env := Dictionary new].
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   599
    env at:'LANG' put:'C'.
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   600
    env at:'LC_MESSAGES' put:'C'.
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   601
3694
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   602
    "/ When compiling using MINGW32/64, the bin directory
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   603
    "/ must be in path since compiler uses some .dlls found there
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   604
    "/ (an otherwise, they won't be found)
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   605
    (ParserFlags useMingw32 or:[ ParserFlags useMingw64 ]) ifTrue:[
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   606
        "/ JV @ 2016-01-04: I dunno why, but adding new, fixed path to env variable passed
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   607
        "/ to executeCommand:...environment:... below does not work.
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   608
        "/ Modifying this very process own environment works, though,
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   609
        | path |
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   610
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   611
        path := OperatingSystem getEnvironment: 'PATH'.
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   612
        (path includesSubstring: ccPath) ifFalse:[
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   613
            OperatingSystem setEnvironment: 'PATH' to: path  , ';', ccPath asFilename directory pathName
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   614
        ].
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   615
    ].
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   616
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   617
    ok := OperatingSystem 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   618
                executeCommand:command 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   619
                inputFrom:nil
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   620
                outputTo:errorStream
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   621
                errorTo:errorStream
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   622
                environment:env
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   623
                onError:[:stat| 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   624
                            executionStatus := stat.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   625
                            false
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   626
                ].
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   627
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   628
    ok ifFalse:[
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   629
        errorStream reset.
3437
98ddce5703d1 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3423
diff changeset
   630
        errorStream contents do:[:l | Transcript showCR:(OperatingSystem decodePathOrCommandOutput: l)].
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   631
    ].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   632
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   633
    errorStream close.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   634
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   635
    oFileName asFilename exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   636
        ok ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   637
            'Compiler [info]: system says compile failed - but o-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   638
            ok := true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   639
        ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   640
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   641
        ok ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   642
            'Compiler [info]: system says compile ok - but no o-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   643
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   644
        ok := false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   645
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   646
    ^ ok
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   647
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   648
    "Created: / 07-11-2006 / 12:14:51 / cg"
3694
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   649
    "Modified: / 04-01-2016 / 21:12:56 / jv"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   650
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   651
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   652
compileToS
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   653
    "compile C to assembler, using cc"
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   654
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   655
    |command errorStream ok|
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   656
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   657
    errorStream := 'errorOutput' asFilename newReadWriteStream.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   658
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   659
    command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ -S ' , (self possiblyQuotedPath:cFileName).
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   660
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   661
    Verbose == true ifTrue:[
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   662
        'executing: ' infoPrint. command infoPrintCR.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   663
    ].
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   664
    originator activityNotification:'compiling (' , ccPath , ')'.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   665
    ok := OperatingSystem 
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   666
                executeCommand:command 
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   667
                inputFrom:nil
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   668
                outputTo:errorStream
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   669
                errorTo:errorStream
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   670
                onError:[:stat| 
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   671
                            executionStatus := stat.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   672
                            false
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   673
                ].
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   674
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   675
    ok ifFalse:[
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   676
        errorStream reset.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   677
        errorStream copyToEndInto:Transcript.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   678
    ].
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   679
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   680
    errorStream close.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   681
    ^ ok
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   682
!
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   683
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   684
ensureExternalToolsArePresent
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   685
    (stcPath := self incrementalStcPath) isNil ifTrue:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   686
        self parseError:'no stc compiler available - cannot create machine code' position:1.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   687
    ].
2649
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   688
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   689
    "make it absolute, so that we are immune to directory changes"
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   690
    stcPath := stcPath asFilename pathName.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   691
    (ccPath := parserFlags ccPath) isNil ifTrue:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   692
        self parseError:'no cc compiler available - cannot create machine code' position:1.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   693
    ].
2649
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   694
    "make it absolute, so that we are immune to directory changes"
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   695
    ccPath := ccPath asFilename pathName.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   696
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   697
    (ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   698
        self parseError:'no dynamic loader configured - cannot create machine code' position:1.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   699
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   700
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   701
    "Created: / 07-11-2006 / 12:31:48 / cg"
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   702
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   703
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   704
ensureModuleDirectoryExists
3664
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   705
    |mP t msg|
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   706
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   707
    mP := parserFlags stcModulePath.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   708
    mP isEmptyOrNil ifTrue:[
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   709
        self parseError:'No temporary module directory, check your settings!!' position:1.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   710
    ].
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   711
    mP := mP asFilename.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   712
    mP exists ifFalse:[
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   713
        mP makeDirectory
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   714
    ].
3240
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
   715
    (mP isWritableDirectory and:[mP isReadable]) ifFalse:[
3664
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   716
        (mP exists and:[mP isDirectory]) ifTrue:[
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   717
            msg := 'No write permission in temporary module directory: '.
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   718
        ] ifFalse:[    
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   719
            msg := 'No access to temporary module directory: '.
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   720
        ].
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   721
        self parseError:(msg , mP pathName) position:1.
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   722
    ].
3664
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   723
    
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   724
    "/ create a small README there ...
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   725
    
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   726
    (t := mP construct:'README') exists ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   727
        t contents:'This temporary ST/X directory contains machine code for
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   728
accepted methods with embedded C-code 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   729
(i.e. dynamic compiled code for inline-C methods).
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   730
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   731
Files here are not automatically removed, since ST/X 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   732
cannot determine if any (other) snapshot image still 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   733
requires a file here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   734
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   735
Please be careful when removing files here - a snapshot
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   736
image which was saved with accepted embedded C-code
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   737
may not be able to restart correctly if you remove a
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   738
required file.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   739
Also, when you export a snapshot image for execution
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   740
on another machine, make certain that the required
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   741
module-files are also present there.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   742
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   743
You should periodically clean dead entries here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   744
i.e. remove files, when you are certain that none
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   745
of your snapshot images refers to any module here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   746
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   747
See the launchers File-Modules dialog for a list of
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   748
modules which are still required by your running image.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   749
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   750
With kind regards - your ST/X.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   751
'.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   752
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   753
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   754
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   755
ensureSuperClassesAreLoadedOf:aClass
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   756
    |supers|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   757
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   758
    supers := aClass allSuperclasses.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   759
    supers reverseDo:[:cls|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   760
        cls isLoaded ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   761
            self parseError:('Cannot stc-compile (superclass %1 is unloaded)' bindWith:cls) position:1.
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   762
        ]
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   763
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   764
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   765
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   766
fileOutAllDefinitionsOf:aClass to:aStream rememberIn:definedClasses
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   767
    |defineAction|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   768
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   769
    defineAction := 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   770
        [:cls|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   771
            (definedClasses includes:cls) ifFalse:[
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   772
                cls 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   773
                    basicFileOutDefinitionOn:aStream 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   774
                    withNameSpace:false withPackage:false
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   775
                    syntaxHilighting:false.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   776
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   777
                aStream nextPut:(aStream class chunkSeparator); cr.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   778
                definedClasses add:cls.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   779
            ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   780
        ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   781
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   782
    aClass allSuperclasses reverseDo:defineAction.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   783
    defineAction value:aClass.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   784
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   785
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   786
generateSTSource:aString 
3359
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
   787
    |stream definedClasses sep className modulesDir ns nsName|
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   788
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   789
    "/ generate a unique name, consisting of my processID and a sequence number
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   790
    "/ the processId is added to allow filein of modules from different
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   791
    "/ lifes
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   792
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   793
    SequenceNumber := (SequenceNumber ? 0) + 1.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   794
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   795
    initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   796
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   797
"/    Smalltalk isSmalltalkDevelopmentSystem ifTrue:[
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   798
"/        modulesParentDir := Filename currentDirectory. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   799
"/    ] ifFalse:[
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   800
"/        modulesParentDir := Filename tempDirectory. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   801
"/    ].
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   802
"/    modulesDir := modulesParentDir construct:'modules'. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   803
    modulesDir := ParserFlags stcModulePath.
2647
a47876ae33fd changed: #generateSTSource:
Stefan Vogel <sv@exept.de>
parents: 2646
diff changeset
   804
    stFileName := (modulesDir asFilename construct:(initName , '.st')) name. 
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   805
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   806
    [
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   807
        stream := stFileName asFilename writeStream.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   808
    ] on:FileStream openErrorSignal do:[:ex|
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   809
        self parseError:'cannot create temporary sourcefile for compilation' position:1.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   810
        ^ #CannotLoad
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   811
    ].
3419
24e01ffb296f class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3411
diff changeset
   812
    stream := EncodedStream stream:stream encoder:(CharacterEncoder encoderForUTF8).
24e01ffb296f class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3411
diff changeset
   813
    stream nextPutLine:'"{ Encoding: utf8 }" !!'.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   814
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   815
    definedClasses := IdentitySet new.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   816
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   817
    sep := stream class chunkSeparator.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   818
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   819
    Class fileOutNameSpaceQuerySignal answer:true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   820
    do:[
2467
a7ed431694a2 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
   821
        theNonMetaclassToCompileFor realSharedPoolNames do:[:eachPoolname |
2067
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   822
            |pool|
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   823
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   824
            pool := Smalltalk at:eachPoolname.
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   825
            self 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   826
                fileOutAllDefinitionsOf:pool 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   827
                to:stream 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   828
                rememberIn:definedClasses.
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   829
        ].
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   830
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   831
        self 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   832
            fileOutAllDefinitionsOf:theNonMetaclassToCompileFor 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   833
            to:stream 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   834
            rememberIn:definedClasses.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   835
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   836
        theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass |
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   837
            self 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   838
                fileOutAllDefinitionsOf:aPrivateClass 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   839
                to:stream 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   840
                rememberIn:definedClasses.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   841
        ].
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   842
"/        theNonMetaclassToCompileFor fileOutPrimitiveDefinitionsOn:stream.
2026
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   843
"/ If a method uses a static primitive function... - but this doesn't work
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   844
"/ Yes it does work, but primitive functions have to be strictly static!!
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   845
        theNonMetaclassToCompileFor fileOutPrimitiveSpecsOn:stream.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   846
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   847
2026
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   848
"/    stream cr.
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   849
"/    stream nextPutLine:'"{ Package: ''' , package , ''' }"'.
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   850
"/    stream cr.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   851
3357
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   852
    className := theNonMetaclassToCompileFor name.
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   853
    ns := theNonMetaclassToCompileFor topNameSpace.
3359
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
   854
    (ns notNil and:[ns ~= Smalltalk and:[nsName := ns name. className startsWith:(nsName,'::')]]) ifTrue:[
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
   855
        className := className copyFrom:nsName size+2+1.
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
   856
        "/ split to avoid being regognized as a directive
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
   857
        stream nextPutLine:('"','{ NameSpace: ',nsName,' }"').
3357
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   858
    ].
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   859
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   860
    stream nextPut:sep.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   861
    stream nextPutAll:className.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   862
    classToCompileFor isMeta ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   863
        stream nextPutAll:' class'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   864
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   865
    stream nextPutAll:' methodsFor:'''; nextPutAll:methodCategory; nextPutAll:''''.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   866
    stream nextPut:sep; cr.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   867
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   868
    stream nextPutLine:'"{ Line: 0 }"'; 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   869
           nextChunkPut:aString;
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   870
           space; nextPut:sep.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   871
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   872
    stream close.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   873
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   874
    "Modified: / 08-08-2011 / 23:23:10 / cg"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   875
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   876
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   877
possiblyQuotedPath:aPath
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   878
    (aPath includes:Character space) ifTrue:[
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   879
        (aPath startsWith:'"') ifFalse:[
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   880
            ^ '"',aPath,'"'
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   881
        ]
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   882
    ].
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   883
    ^ aPath
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   884
!
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   885
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
   886
reportCompilationErrorFor:aCommand
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   887
    |eMsg errorMessages lNr|
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   888
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   889
    (executionStatus notNil and:[executionStatus couldNotExecute]) ifTrue:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   890
        eMsg := 'oops, no %1 - cannot create machine code' bindWith:aCommand.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   891
    ] ifFalse:[
3437
98ddce5703d1 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3423
diff changeset
   892
        errorMessages := 'errorOutput' asFilename contents collect:[:l | OperatingSystem decodePathOrCommandOutput: l ].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   893
        OperatingSystem removeFile:'errorOutput'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   894
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   895
        errorMessages notNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   896
            errorMessages := errorMessages reject:[:line | line includesString:'Warning:'].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   897
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   898
            errorMessages size > 20 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   899
                errorMessages := errorMessages select:[:line | line asLowercase startsWith:'error'].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   900
                errorMessages size > 20 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   901
                    errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped'
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   902
                ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   903
            ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   904
"/                    errorMessages := errorMessages collect:[:line |
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   905
"/                        (line startsWith:(stFileName , ':')) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   906
"/                            'Line: ' , (line copyFrom:(stFileName size + 2))
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   907
"/                        ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   908
"/                            line
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   909
"/                        ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   910
"/                      ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   911
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   912
        errorMessages isNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   913
            errorMessages := #('')
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   914
        ].
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
   915
        errorMessages := (Array with:'Failed to execute: "', aCommand,'"') , errorMessages.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   916
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   917
        "/ try to extract a line number"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   918
        (errorMessages contains:[:line | line includesString:'Borland']) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   919
            |i i2 s|
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   920
            i := errorMessages findFirst:[:l | l startsWith:(cFileName,':')].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   921
            i ~~ 0 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   922
                ((errorMessages at:i+1) startsWith:'Error') ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   923
                    i2 := (errorMessages at:i+1) indexOfSubCollection:(stFileName).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   924
                    i2 ~~ 0 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   925
                        s := (errorMessages at:i+1) copyFrom:(i2+stFileName size+1).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   926
                        s := s readStream.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   927
                        lNr := Integer readFrom:s.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   928
                        s skipSeparators.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   929
                    ].    
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   930
                ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   931
            ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   932
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   933
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   934
        errorMessages isEmpty ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   935
            eMsg := 'Error during compilation:\\Unspecified error (no output)' withCRs
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   936
        ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   937
            eMsg := 'Error during compilation:\\' withCRs ,
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   938
                    (errorMessages asStringCollection asString).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   939
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   940
    ].
2461
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   941
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   942
    originator activityNotification:''.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   943
3069
230e5da2ff5d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3042
diff changeset
   944
    ParseError new
2461
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   945
        lineNumber:lNr;
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   946
        errorMessage:eMsg;
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   947
        raise.
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   948
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   949
    "Created: / 07-11-2006 / 12:29:04 / cg"
3348
b59a15a24ab3 class: STCCompilerInterface
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3240
diff changeset
   950
    "Modified: / 21-12-2013 / 00:08:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   951
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   952
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   953
setupCompilationCommandArguments
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   954
    |stFn libDir incDir incDirArg defs incl opts|
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   955
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   956
    parserFlags isNil ifTrue:[ parserFlags := ParserFlags new].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   957
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   958
    stFn := stFileName asFilename.
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   959
    oFileName := stFn nameWithoutSuffix , (ObjectFileLoader objectFileExtension).
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   960
    cFileName := (stFn withSuffix:'c') name. 
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   961
"/    ParserFlags useBorlandC ifTrue:[
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   962
"/        cFileName := (stFn withSuffix:'sc') name. 
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   963
"/    ].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   964
    oFileName asFilename delete.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   965
    cFileName asFilename delete.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   966
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   967
    "/ stcFlags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName .
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   968
    stcFlags := '+newIncremental -E:errorOutput'.
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
   969
    initName notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   970
        stcFlags := stcFlags,' -N' , initName .
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   971
    ].
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   972
    cFlags := self class builtinCFlags.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   973
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
   974
    (defs := parserFlags stcCompilationDefines) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   975
        cFlags := cFlags , ' ' , defs
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   976
    ].
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   977
    stcFlags := stcFlags , ' ', self class builtinCIncludeDirectories.
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   978
    cFlags := cFlags , ' ', self class builtinCIncludeDirectories.
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   979
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
   980
    (incl := parserFlags stcCompilationIncludes) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   981
        stcFlags := incl , ' ' , stcFlags.
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   982
        cFlags := cFlags , ' ' , incl.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   983
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   984
        "/ if STX_LIBDIR is defined, and not in passed argument,
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   985
        "/ add it here.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   986
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   987
        libDir := OperatingSystem getEnvironment:'STX_LIBDIR'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   988
        (libDir notNil and:[libDir asFilename exists]) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   989
            incDir := libDir asFilename construct:'include'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   990
            incDir exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   991
                incDirArg := '-I' , incDir pathName.
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   992
                (incl asCollectionOfWords includes:incDirArg) ifFalse:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   993
                    stcFlags := stcFlags , ' ' , incDirArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   994
                    cFlags := cFlags , ' ' , incDirArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   995
                ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   996
            ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   997
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   998
    ].
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
   999
    (opts := parserFlags stcCompilationOptions) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1000
        stcFlags := opts , ' ' , stcFlags
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1001
    ].
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1002
    (opts := parserFlags ccCompilationOptions) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1003
        cFlags := cFlags , ' ' , opts
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1004
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1005
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1006
    "Created: / 07-11-2006 / 12:24:47 / cg"
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  1007
    "Modified: / 07-11-2006 / 13:58:54 / cg"
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1008
    "Modified: / 09-12-2015 / 17:00:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
!STCCompilerInterface class methodsFor:'documentation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
version
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1014
    ^ '$Header$'
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1015
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1016
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1017
version_CVS
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1018
    ^ '$Header$'
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1019
!
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1020
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1021
version_HG
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1022
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1023
    ^ '$Changeset: <not expanded> $'
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
  1026
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
STCCompilerInterface initialize!