STCCompilerInterface.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 27 Oct 2022 14:53:59 +0100
branchjv
changeset 4735 3b11fb3ede98
parent 4723 524785227024
permissions -rw-r--r--
Allow single underscore as method / block argument and temporaries This commit is a follow up for 38b221e.
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
4275
e06f4b087e47 Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4259
diff changeset
     4
 COPYRIGHT (c) 2015-2016 Jan Vrany
e06f4b087e47 Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4259
diff changeset
     5
 COPYRIGHT (c) 2018 Jan Vrany
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
              All Rights Reserved
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 This software is furnished under a license and may be used
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 only in accordance with the terms of that license and with the
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 inclusion of the above copyright notice.   This software may not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 be provided or otherwise made available to, or used by, any
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 other person.  No title to or ownership of the software is
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
 hereby transferred.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
"{ Package: 'stx:libcomp' }"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
    17
"{ NameSpace: Smalltalk }"
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
    18
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
Object subclass:#STCCompilerInterface
3240
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    20
	instanceVariableNames:'originator parserFlags initName theNonMetaclassToCompileFor
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    21
		classToCompileFor stFileName cFileName oFileName stcFlags cFlags
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    22
		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
    23
	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
    24
		BuiltinCIncludeDirectories'
3240
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    25
	poolDictionaries:''
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
    26
	category:'System-Compiler'
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
!STCCompilerInterface class methodsFor:'documentation'!
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
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 COPYRIGHT (c) 1989 by Claus Gittinger
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 COPYRIGHT (c) 2006 by eXept Software AG
4275
e06f4b087e47 Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4259
diff changeset
    35
 COPYRIGHT (c) 2015-2016 Jan Vrany
e06f4b087e47 Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4259
diff changeset
    36
 COPYRIGHT (c) 2018 Jan Vrany
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
              All Rights Reserved
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 This software is furnished under a license and may be used
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 only in accordance with the terms of that license and with the
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 be provided or otherwise made available to, or used by, any
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 other person.  No title to or ownership of the software is
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 hereby transferred.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
documentation
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    a refactored complex method - originally found in ByteCodeCompiler.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!STCCompilerInterface class methodsFor:'accessing'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    56
builtinCFlags
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    57
    "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
    58
     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
    59
4212
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
    60
    ^ self getCPUDefine , ' ', self getOSDefine , ' ' , self getBuildTargetDefine
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    61
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    62
    "Created: / 04-12-2015 / 16:41:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4212
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
    63
    "Modified: / 17-01-2018 / 22:23:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    64
!
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
    65
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    66
builtinCIncludeDirectories
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    67
    "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
    68
     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
    69
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    70
    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
    71
        | executablePath |
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    72
        (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
    73
            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
    74
            ((executablePath / 'include' / 'stc.h') exists
4652
c945656beeba Fix ParserFlags and STCCompilerInterface to work with out-of-tree builds
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4275
diff changeset
    75
              or:[((executablePath := executablePath directory directory) / 'include' / 'stc.h') exists
c945656beeba Fix ParserFlags and STCCompilerInterface to work with out-of-tree builds
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4275
diff changeset
    76
              or:[((executablePath := executablePath directory directory) / 'include' / 'stc.h') exists]])
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    77
                ifTrue:[
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    78
                    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
    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
        ^ ''
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
    ^ BuiltinCIncludeDirectories
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    85
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
    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
    88
    "
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    89
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    90
    "Created: / 09-12-2015 / 16:54:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4652
c945656beeba Fix ParserFlags and STCCompilerInterface to work with out-of-tree builds
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4275
diff changeset
    91
    "Modified: / 22-05-2020 / 22:58:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
    92
!
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
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
    95
    "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
    96
     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
    97
     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
    98
     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
    99
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   100
     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
   101
     "
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   102
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   103
     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
   104
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   105
    "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
   106
!
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
   107
4212
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
   108
getBuildTargetDefine
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
   109
    ^ '-DBUILD_TARGET=\"', Smalltalk configuration , '\"'
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
   110
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
   111
    "Created: / 17-01-2018 / 22:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
   112
!
414189868428 Fixed builtin C flags to include `-DBUILD_TARGET=...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4063
diff changeset
   113
4023
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   114
getCCDefine
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   115
    "return a string which was used to identify the C-Compiler used
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   116
     when STX was compiled, and which should be passed down when compiling methods.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   117
     For example, when compiled with GNUC, this is '__GNUC__';
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   118
     on windows, this is either '__VISUAL__', '__BORLANDC__' or '__MINGW64__'"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   119
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   120
%{  /* NOCONTEXT */
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   121
#ifndef CC_DEFINE
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   122
# ifdef __win32__
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   123
#  if defined( __BORLANDC__ )
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   124
#   define CC_DEFINE    "__BORLANDC__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   125
#  else
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   126
#   if defined( __VISUALC__ )
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   127
#    define CC_DEFINE     "__VISUALC__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   128
#   else
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   129
#    if defined( __MINGW64__ )
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   130
#     define CC_DEFINE     "__MINGW64__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   131
#    else
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   132
#     if defined( __MINGW32__ )
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   133
#      define CC_DEFINE     "__MINGW32__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   134
#     else
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   135
#      define CC_DEFINE     "__CC__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   136
#     endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   137
#    endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   138
#   endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   139
#  endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   140
# else /* not __win32__ */
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   141
#  if defined(__CLANG__) || defined( __clang__ )
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   142
#   define CC_DEFINE     "__CLANG__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   143
#  else
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   144
#   ifdef __GNUC__
4254
3fe3c5bbe84e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4250
diff changeset
   145
    // https://expeccoalm.exept.de/D252306
3fe3c5bbe84e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4250
diff changeset
   146
    // must not redefine __GNUC__, because gcc defines this anyway with the gcc version 
3fe3c5bbe84e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4250
diff changeset
   147
    // contained in this macro (which is used by glibc includes).
3fe3c5bbe84e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4250
diff changeset
   148
    // also defined in STCCompilerInterface class >> #getCCDefine
3fe3c5bbe84e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4250
diff changeset
   149
#    define CC_DEFINE     "STX__GNUC__"
4023
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   150
#   else
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   151
#    define CC_DEFINE     "__CC__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   152
#   endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   153
#  endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   154
# endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   155
#endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   156
    RETURN ( __MKSTRING(CC_DEFINE));
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   157
%}
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   158
    "
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   159
     STCCompilerInterface getCCDefine
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   160
    "
4254
3fe3c5bbe84e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4250
diff changeset
   161
3fe3c5bbe84e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4250
diff changeset
   162
    "Modified: / 11-05-2018 / 10:12:47 / stefan"
4023
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   163
!
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   164
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   165
getCPUDefine
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   166
    "return a string which was used to identify this CPU type when STX was
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   167
     compiled, and which should be passed down when compiling methods.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   168
     For example, on a 386 (and successors), this may be '-D__x86__'; 
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   169
     on a vax, this would be '-D__vax__'.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   170
     This is normally not of interest to 'normal' users; however, it is passed
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   171
     down to the c-compiler when methods are incrementally compiled to machine code.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   172
     Do not use this for CPU determination; only to pass on to stc for compilation.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   173
     (see OperatingSystem getCPUType for this)"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   174
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   175
%{  /* NOCONTEXT */
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   176
#   ifndef CPU_DEFINE
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   177
#       define CPU_DEFINE "-DunknownCPU"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   178
#   endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   179
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   180
    RETURN ( __MKSTRING(CPU_DEFINE));
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   181
%}
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   182
    "
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   183
     STCCompilerInterface getCPUDefine
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   184
    "
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   185
!
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   186
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   187
getOSDefine
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   188
    "return a string which was used to identify this machine when stx was
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   189
     compiled, and which should be passed down when compiling methods.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   190
     For example, on linux, this is '-D__linux__'; on osx, it is '-D__osx__'.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   191
     Do not use this for OS determination; only to pass on to stc for compilation.
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   192
     (see OperatingSystem getOSType for this)"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   193
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   194
%{  /* NOCONTEXT */
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   195
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   196
#ifndef OS_DEFINE
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   197
# ifdef __win32__
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   198
#  define OS_DEFINE "-D__win32__"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   199
# endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   200
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   201
# ifndef OS_DEFINE
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   202
#  define OS_DEFINE "-DunknownOS"
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   203
# endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   204
#endif
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   205
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   206
    RETURN ( __MKSTRING(OS_DEFINE));
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   207
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   208
#undef OS_DEFINE
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   209
%}
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   210
    "
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   211
     STCCompilerInterface getOSDefine
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   212
    "
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   213
!
03113f2bc542 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4021
diff changeset
   214
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
stcPathOf:command 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    "return the path to an stc command, or nil if not found."
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    |f d reqdSuffix cmd|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    "/ care for executable suffix
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    cmd := command.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    OperatingSystem isMSDOSlike ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
        reqdSuffix := 'exe'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        OperatingSystem isVMSlike ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
            reqdSuffix := 'EXE'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    reqdSuffix notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
        (f := cmd asFilename) suffix isEmpty ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
            cmd := (f withSuffix:reqdSuffix) name
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "/ for our convenience, also check in current
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    "/ and parent directories; even if PATH does not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    "/ include them ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    "/
3720
1d89765dce7f #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
   241
    #('.' '../stc' '../../stc') do:[:relPath |
1d89765dce7f #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
   242
        d := Filename currentDirectory construct:relPath.
1d89765dce7f #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
   243
        (f := d construct:cmd) isExecutable ifTrue:[
1d89765dce7f #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
   244
            ^ f pathName
1d89765dce7f #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
   245
        ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    "/ ok, stc must be installed in some directory along the PATH
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    ^ OperatingSystem pathOfCommand:command
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
     STCCompilerInterface stcPathOf:'stc'     
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    "Created: 13.9.1995 / 14:37:16 / claus"
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   258
!
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   259
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   260
verbose
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   261
    "if on, trace command execution on the Transcript"
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   262
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   263
    ^ Verbose
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   264
!
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   265
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   266
verbose:aBoolean 
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   267
    "if on, trace command execution on the Transcript"
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   268
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   269
    Verbose := aBoolean
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   270
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   271
    "
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   272
    STCCompilerInterface verbose: true.
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   273
    STCCompilerInterface verbose: false.
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   274
    "
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   275
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
   276
    "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
   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
!STCCompilerInterface class methodsFor:'class initialization'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
initialize
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    Verbose := false.
4250
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
   283
    KeepIntermediateFiles := false.
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
   284
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
   285
    "Modified: / 11-05-2018 / 09:34:34 / stefan"
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
!STCCompilerInterface methodsFor:'accessing'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   290
cFileName:something
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   291
    cFileName := something.
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   292
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   293
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
incrementalStcPath 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    "return the path to the stc command for incremental method compilation, 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
     or nil if not found."
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
    |f cmd|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    (cmd := parserFlags stcPath) isEmptyOrNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
        (f := self class stcPathOf:'stc') notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
            cmd := f
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
        ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
            cmd := self class stcPathOf:'demostc'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
        ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
    (cmd notNil and:[cmd includes:Character space]) ifTrue:[
4712
3c2662449b4c #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4679
diff changeset
   308
        cmd := cmd withDoubleQuotes.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    ^ cmd
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    "Created: 13.9.1995 / 14:36:36 / claus"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    "Modified: 13.9.1995 / 15:15:04 / claus"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
originator:something
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    originator := something.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
parserFlags:something
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    parserFlags := something.
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   322
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   323
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   324
stFileName:something
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   325
    stFileName := something.
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
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   328
!STCCompilerInterface methodsFor:'error raising'!
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   329
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   330
parseError:messageText position:position
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   331
    originator notNil ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   332
        originator parseError:messageText position:position.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   333
        "not normally reached"
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   334
    ].
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   335
    ParseError raiseErrorString:messageText.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   336
! !
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   337
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
!STCCompilerInterface methodsFor:'machine code generation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   340
compileToMachineCode:aString forClass:aClass selector:selector inCategory:categoryArg 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   341
                             notifying:requestorArg install:install skipIfSame:skipIfSame silent:silent
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
    "this is called to compile primitive code.
3357
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   343
     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
   344
     it to a tiny little dll and loads it.
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
   345
     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
   346
     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
   347
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   348
    ^ self 
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   349
        compileToMachineCode:aString forClass:aClass selector:selector inCategory:categoryArg 
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   350
        notifying:requestorArg install:install skipIfSame:skipIfSame silent:silent
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   351
        generateCOnly:false
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   352
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   353
    "
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   354
     |m|
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   355
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   356
     Object subclass:#Test
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   357
            instanceVariableNames:''
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   358
            classVariableNames:''
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   359
            poolDictionaries:''
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   360
            category:'tests'.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   361
     m := ByteCodeCompiler
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   362
            compile:'foo ^ ''hello'''
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   363
            forClass:Test
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   364
            inCategory:'tests'
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   365
            notifying:nil
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   366
            install:false
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   367
            skipIfSame:false.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   368
     m inspect
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   369
    "
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   370
    "
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   371
     |m|
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   372
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   373
     Object subclass:#Test
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   374
            instanceVariableNames:''
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   375
            classVariableNames:''
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   376
            poolDictionaries:''
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   377
            category:'tests'.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   378
     m := ByteCodeCompiler
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   379
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   380
            forClass:Test
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   381
            inCategory:'tests'
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   382
            notifying:nil
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   383
            install:false
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   384
            skipIfSame:false
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   385
            silent:false.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   386
     m inspect
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   387
    "
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   388
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   389
    "Modified: / 14-09-1995 / 22:33:04 / claus"
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   390
    "Modified: / 17-09-2011 / 10:39:25 / cg"
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   391
    "Modified: / 16-05-2018 / 13:48:25 / stefan"
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   392
!
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   393
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   394
compileToMachineCode:aString forClass:aClass selector:selector inCategory:categoryArg 
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   395
                             notifying:requestorArg install:install skipIfSame:skipIfSame silent:silent
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   396
                             generateCOnly:generateCOnly
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   397
    "this is called to compile primitive code.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   398
     It saves the code to a tmporary, calls stc to create C-code, compiles it, links
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   399
     it to a tiny little dll and loads it.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   400
     As you already see, this takes some time and is therefore ONLY done for code containing prims;
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   401
     all pure smalltalk code is compiled to bytecode and jitted by the VM."
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   402
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   403
    |handle oldMethod newMethod ok dllFileName|
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   405
    (install not and:[generateCOnly not]) ifTrue:[
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
        "/ cannot do it uninstalled. reason:
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
        "/ if it is loaded twice, the first version could be unloaded by
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
        "/ finalization, which would also unload the second version
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
        "/ (because the first unload would unload the second version too)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
        ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    ].
2704
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   412
    parserFlags isNil ifTrue:[
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   413
        parserFlags := ParserFlags new
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   414
    ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    parserFlags stcCompilation == #never ifTrue:[^ #CannotLoad].
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   416
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   417
    classToCompileFor := aClass.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   418
    requestor := requestorArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   419
    methodCategory := categoryArg.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   421
    self ensureExternalToolsArePresent.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   422
    self ensureModuleDirectoryExists.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   424
    theNonMetaclassToCompileFor := classToCompileFor theNonMetaclass.
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   425
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   426
    self ensureSuperClassesAreLoadedOf:theNonMetaclassToCompileFor.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   427
    theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass |
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   428
        self ensureSuperClassesAreLoadedOf:aPrivateClass.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   429
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   430
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   431
    (classToCompileFor isNil 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   432
    or:[parserFlags allowExtensionsToPrivateClasses 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   433
    or:[classToCompileFor owningClass isNil]]) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   434
        (requestor respondsTo:#packageToInstall) ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   435
            package := Class packageQuerySignal query.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   436
        ] ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   437
            package := requestor packageToInstall
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   438
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   439
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   440
        package := classToCompileFor owningClass package
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
    [
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   444
        self generateSTSource:aString.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   445
        self setupCompilationCommandArguments.
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   446
        ok := self 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   447
                compileToC_onError:[:errorFile |
4260
b87d65887496 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4254
diff changeset
   448
                    self reportCompilationErrorFor:stcPath fromFile:errorFile
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   449
                ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   451
        (generateCOnly or:[parserFlags stcKeepSIntermediate]) ifTrue:[ 
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   452
            self compileToS_onError:[:errorFile | ]
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   453
        ].
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   454
        generateCOnly ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   455
            ^ cFileName asFilename
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   456
        ].
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   457
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   458
        "/ now compile to machine code
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   459
        ok := self 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   460
                compileToObj_onError:[:errorFile |
4250
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
   461
                    self reportCompilationErrorFor:ccPath, cFlags fromFile:errorFile.
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   462
                ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
        originator activityNotification:''.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
         if required, make a shared or otherwise loadable object file for it
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
        originator activityNotification:'linking'.
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   470
        dllFileName := ObjectFileLoader createLoadableObjectFor:(oFileName asFilename withoutSuffix name).
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   471
        dllFileName isNil ifTrue:[
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
            "/ something went wrong
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   473
            self parseError:('link error: ' , ObjectFileLoader lastError) position:1.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
        ].
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   475
        dllFileName asFilename exists ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   476
            self parseError:'link failed - cannot create machine code' position:1.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   479
        oldMethod := classToCompileFor compiledMethodAt:selector.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   480
        oldMethod notNil ifTrue:[package := oldMethod package].
3159
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   481
        install ifTrue:[
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   482
            (Smalltalk
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   483
                    changeRequest:#methodInClass
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   484
                    with:(Array with:classToCompileFor with:selector with:oldMethod)) ifFalse:[
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   485
                ^ #CannotLoad
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   486
            ].
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   487
        ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
         load the method objectfile
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
        originator activityNotification:'loading'.
3361
dfa4c3b41d1e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3359
diff changeset
   493
        handle := ObjectFileLoader loadMethodObjectFile:dllFileName.
dfa4c3b41d1e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3359
diff changeset
   494
        originator activityNotification:''.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
        handle isNil ifTrue:[
4250
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
   497
            KeepIntermediateFiles ifFalse:[ dllFileName asFilename remove ].
2185
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   498
            "catch, so that #CannotLoad processing is done"
3069
230e5da2ff5d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3042
diff changeset
   499
            ParseError catch:[
2185
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   500
                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
   501
            ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
            ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
         did it work ?
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
        "
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   508
        newMethod := classToCompileFor compiledMethodAt:selector.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
        "/ 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
   511
        install ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
            oldMethod isNil ifTrue:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   513
                classToCompileFor removeSelector:selector
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
            ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
                newMethod setPackage:oldMethod package.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   516
                classToCompileFor addSelector:selector withMethod:oldMethod.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   517
                oldMethod setPackage:package.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
            ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
        newMethod notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
            handle method ~~ newMethod ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
                'Compiler [warning]: loaded method installed itself in another class' errorPrintCR.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
            newMethod source:aString string.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   527
            newMethod setPackage:package.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
"/            Project notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
"/                newMethod package:(Project currentPackageName)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
"/            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   532
    "/        classToCompileFor updateRevisionString.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
            install ifTrue:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   534
                classToCompileFor addChangeRecordForMethod:newMethod fromOld:oldMethod.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
                "/ 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
   537
                "/ see addMethod:... in ClassDescription
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   538
                classToCompileFor changed:#methodDictionary with:(Array with:selector with:oldMethod).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   539
                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
   540
            ] ifFalse:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   541
                oldMethod := nil.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
1986
57913c678602 comment
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   544
            silent ifFalse:[
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   545
                Transcript showCR:('    compiled: ', aClass name,' ',selector,' - machine code')
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
            ObjectMemory flushCaches.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
            handle method:newMethod.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   551
            "/ 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
   552
            "/ corresponding ObjectFileHandle.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   553
            "/ 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
   554
            "/ and will be recompiled on an undo
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
            ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
                anotherHandle isMethodHandle ifTrue:[
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   558
                    anotherHandle method == oldMethod ifTrue:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   559
                        "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
   560
                        anotherHandle removeConnectedObjects.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   561
                    ].
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   562
                    anotherHandle isObsolete ifTrue:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   563
                        anotherHandle unload.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   564
                        anotherHandle removeUnusedObjectFile.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   565
                    ].
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   566
                ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
            ^ newMethod.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
4250
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
   571
        "/ moduleFileName asFilename remove.
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   572
        self parseError:'dynamic load failed' position:1.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
    ] ensure:[
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   574
        generateCOnly ifFalse:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   575
            KeepIntermediateFiles ifTrue:[ 
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   576
                Transcript showCR:'keeping files'
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   577
            ] ifFalse:[
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   578
                parserFlags stcKeepSTIntermediate ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   579
                    Transcript showCR:'keeping st file: ', stFileName asFilename pathName
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   580
                ] ifFalse:[
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   581
                    stFileName asFilename remove.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   582
                ].
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   583
                cFileName notNil ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   584
                    parserFlags stcKeepCIntermediate == true ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   585
                        Transcript showCR:'keeping c file: ', cFileName asFilename pathName
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   586
                    ] ifFalse:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   587
                        cFileName asFilename remove.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   588
                    ]
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   589
                ].
4477
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   590
                oFileName notNil ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   591
                    parserFlags stcKeepOIntermediate == true ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   592
                        Transcript showCR:'keeping o file: ', oFileName asFilename pathName
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   593
                    ] ifFalse:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   594
                        oFileName asFilename remove.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   595
                    ].
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   596
                ].
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   597
    "/            OperatingSystem isMSDOSlike ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   598
    "/                mapFileName notNil ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   599
    "/                   mapFileName asFilename remove.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   600
    "/                ].
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   601
    "/                libFileName notNil ifTrue:[
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   602
    "/                   libFileName asFilename remove.
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   603
    "/                ].
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   604
    "/            ].
2eef68083666 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4468
diff changeset
   605
            ]
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   606
        ]
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
     |m|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
     Object subclass:#Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
            instanceVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
            classVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
            poolDictionaries:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
            category:'tests'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
     m := ByteCodeCompiler
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
            compile:'foo ^ ''hello'''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
            forClass:Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
            inCategory:'tests'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
            notifying:nil
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
            install:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
            skipIfSame:false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
     m inspect
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
     |m|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
     Object subclass:#Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
            instanceVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
            classVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
            poolDictionaries:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
            category:'tests'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
     m := ByteCodeCompiler
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
            forClass:Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
            inCategory:'tests'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
            notifying:nil
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
            install:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
            skipIfSame:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
            silent:false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
     m inspect
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   645
    "Modified: / 14-09-1995 / 22:33:04 / claus"
2704
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   646
    "Modified: / 17-09-2011 / 10:39:25 / cg"
4260
b87d65887496 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4254
diff changeset
   647
    "Modified: / 16-05-2018 / 13:48:25 / stefan"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   648
! !
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   649
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   650
!STCCompilerInterface methodsFor:'machine code generation-helpers'!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   651
4019
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   652
compileToC_onError:aBlock
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   653
    "compile st to C using stc.
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   654
     If any error happens, call aBlock passing it the fileName containing diagnostics"
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   655
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   656
    |command ok errorOutputFile|
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   657
4679
47b03fee99a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4615
diff changeset
   658
    command := (Filename possiblyQuotedPathname:stcPath) , ' ' 
47b03fee99a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4615
diff changeset
   659
                , stcFlags 
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   660
                , ' -defdir=', (Filename possiblyQuotedPathname:cFileName asFilename directory pathName).
4019
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   661
    cFileName asFilename suffix ~= 'c' ifTrue:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   662
        command := command , ' -cSuffix=',cFileName asFilename suffix.
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   663
    ].
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   664
    command := command , ' -C ' , (Filename possiblyQuotedPathname:stFileName asFilename pathName).
4019
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   665
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   666
    Verbose == true ifTrue:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   667
        Transcript show:'executing: '; showCR:command.
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   668
    ].
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   669
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   670
    originator activityNotification:'compiling (stc)'.
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   671
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   672
    errorOutputFile := Filename tempDirectory / 'stcErrorOutput'. 
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   673
    errorOutputFile writingFileDo:[:errorStream |
4260
b87d65887496 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4254
diff changeset
   674
        errorStream nextPutAll:'Command: '; nextPutLine:command; cr; flush.
4019
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   675
        ok := OperatingSystem 
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   676
                    executeCommand:command 
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   677
                    inputFrom:nil
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   678
                    outputTo:errorStream
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   679
                    errorTo:errorStream
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   680
                    showWindow:false
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   681
                    onError:[:stat| 
4021
28085e55bd26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   682
                                self breakPoint:#cg.
4019
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   683
                                executionStatus := stat.
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   684
                                false
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   685
                            ].
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   686
    ].
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   687
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   688
    cFileName asFilename exists ifTrue:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   689
        ok ifFalse:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   690
            'Compiler [info]: oops - system says stc failed - but c-file is there ...' infoPrintCR.
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   691
            ok := true
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   692
        ]
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   693
    ] ifFalse:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   694
        ok ifTrue:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   695
            'Compiler [info]: oops - system says stc ok - but no c-file is there ...' infoPrintCR
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   696
        ].
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   697
        ok := false
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   698
    ].
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   699
    
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   700
    [
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   701
        ok ifFalse:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   702
            aBlock value:errorOutputFile
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   703
        ].
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   704
    ] ensure:[
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   705
        errorOutputFile remove.
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   706
    ].
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   707
    ^ ok
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   708
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   709
    "Created: / 07-11-2006 / 12:11:24 / cg"
4260
b87d65887496 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4254
diff changeset
   710
    "Modified: / 16-05-2018 / 13:49:01 / stefan"
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   711
    "Modified: / 28-03-2019 / 16:17:03 / Claus Gittinger"
4679
47b03fee99a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4615
diff changeset
   712
    "Modified: / 16-06-2020 / 19:08:12 / cg"
4019
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   713
!
ca410e6cca3f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
   714
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   715
compileToExe_onError:aBlock 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   716
    "compile C to exe, using cc.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   717
     If any error happens, call aBlock passing it the fileName containing diagnostics"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   718
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   719
    |command errorOutputFile ok|
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   720
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   721
    command := (Filename possiblyQuotedPathname:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ ' , (Filename possiblyQuotedPathname:cFileName).
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   722
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   723
    Verbose == true ifTrue:[
3957
28c8f6bdb08d #BUGFIX by sr
sr
parents: 3793
diff changeset
   724
        Transcript show:'executing: ' showCR:command.
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   725
    ].
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   726
    originator activityNotification:'compiling (' , ccPath , ')'.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   727
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   728
    errorOutputFile := Filename tempDirectory / 'stcErrorOutput'. 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   729
    errorOutputFile writingFileDo:[:errorStream |
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   730
        ok := OperatingSystem 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   731
                    executeCommand:command 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   732
                    inputFrom:nil
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   733
                    outputTo:errorStream
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   734
                    errorTo:errorStream
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   735
                    showWindow:false
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   736
                    onError:[:stat| 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   737
                                executionStatus := stat.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   738
                                false
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   739
                    ].
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   740
    ].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   741
    
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   742
    [
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   743
        ok ifFalse:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   744
            aBlock value:errorOutputFile
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   745
        ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   746
    ] ensure:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   747
        errorOutputFile remove.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   748
    ].
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   749
    ^ ok
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   750
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   751
    "Modified: / 28-03-2019 / 16:17:06 / Claus Gittinger"
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   752
!
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   753
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   754
compileToObj_onError:aBlock
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   755
    "compile C to obj, using cc.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   756
     If any error happens, call aBlock passing it the fileName containing diagnostics"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   757
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   758
    |errorOutputFile ok commandTemplate command ccDefine env|
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   759
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   760
    "/ bcc does not like -D__BORLANDC__ (needs to be set to a version, such as 0x0505)
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   761
    "/ others do not need it (is already predefined in the compiler)
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   762
    "/ ccDefine := ' -D',ParserFlags usedCompilerDefine.
3173
5b547821eb61 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3170
diff changeset
   763
    "/ so, never redefine ccDefine
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   764
    ccDefine := ''.
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   765
3010
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   766
    ParserFlags useBorlandC ifTrue:[
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   767
        "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
   768
        "/ cg: I guess, this does not work for visual-c
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   769
        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
   770
    ] ifFalse:[
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   771
        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
   772
    ].
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   773
    command := commandTemplate
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   774
                    bindWith:(Filename possiblyQuotedPathname:ccPath) 
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   775
                    with:cFlags
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   776
                    with:ccDefine
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   777
                    with:(Filename possiblyQuotedPathname:oFileName)
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   778
                    with:(Filename possiblyQuotedPathname:cFileName).
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   779
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   780
    Verbose == true ifTrue:[
3957
28c8f6bdb08d #BUGFIX by sr
sr
parents: 3793
diff changeset
   781
        Transcript show:'executing: '; showCR:command.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   782
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   783
    originator activityNotification:'compiling (' , ccPath , ')'.
3423
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   784
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   785
    env := OperatingSystem isUNIXlike
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   786
                    ifTrue:[OperatingSystem getEnvironment copy]
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   787
                    ifFalse:[env := Dictionary new].
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   788
    env at:'LANG' put:'C'.
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   789
    env at:'LC_MESSAGES' put:'C'.
c6e2dbd8446a class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   790
3694
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   791
    "/ 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
   792
    "/ 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
   793
    "/ (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
   794
    (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
   795
        "/ 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
   796
        "/ 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
   797
        "/ 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
   798
        | path |
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   799
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   800
        path := OperatingSystem getEnvironment: 'PATH'.
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   801
        (path includesSubstring: ccPath) ifFalse:[
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   802
            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
   803
        ].
e89d2870030c STC interface clenaup: fixed compilation inder MINGW(32)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3686
diff changeset
   804
    ].
4028
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4007 4023
diff changeset
   805
    
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   806
    errorOutputFile := Filename tempDirectory / 'stcErrorOutput'. 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   807
    errorOutputFile writingFileDo:[:errorStream |
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   808
        ok := OperatingSystem 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   809
                    executeCommand:command 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   810
                    inputFrom:nil
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   811
                    outputTo:errorStream
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   812
                    errorTo:errorStream
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   813
                    environment:env
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   814
                    showWindow:false
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   815
                    onError:
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   816
                        [:stat| 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   817
                            executionStatus := stat.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   818
                            false
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   819
                        ].
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   820
    ].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   821
    
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   822
    oFileName asFilename exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   823
        ok ifFalse:[
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   824
            'Compiler [info]: system says compile failed - but o-file is there ...' infoPrintCR.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   825
            ok := true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   826
        ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   827
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   828
        ok ifTrue:[
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   829
            'Compiler [info]: system says compile ok - but no o-file is there ...' infoPrintCR.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   830
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   831
        ok := false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   832
    ].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   833
    [
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   834
        ok ifFalse:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   835
            aBlock value:errorOutputFile
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   836
        ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   837
    ] ensure:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   838
        errorOutputFile remove.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   839
    ].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   840
    ^ ok
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   841
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   842
    "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
   843
    "Modified: / 04-01-2016 / 21:12:56 / jv"
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   844
    "Modified: / 28-03-2019 / 16:17:10 / Claus Gittinger"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   845
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   846
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   847
compileToS_onError:aBlock
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   848
    "compile C to assembler, using cc.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   849
     If any error happens, call aBlock passing it the fileName containing diagnostics"
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   850
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   851
    |command errorOutputFile ok|
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   852
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   853
    command := (Filename possiblyQuotedPathname:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ -S ' , (Filename possiblyQuotedPathname:cFileName).
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   854
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   855
    Verbose == true ifTrue:[
3957
28c8f6bdb08d #BUGFIX by sr
sr
parents: 3793
diff changeset
   856
        Transcript show:'executing: '; showCR:command.
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   857
    ].
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   858
    originator activityNotification:'compiling (' , ccPath , ')'.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   859
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   860
    errorOutputFile := Filename tempDirectory / 'stcErrorOutput'. 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   861
    errorOutputFile writingFileDo:[:errorStream |
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   862
        ok := OperatingSystem 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   863
                    executeCommand:command 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   864
                    inputFrom:nil
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   865
                    outputTo:errorStream
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   866
                    errorTo:errorStream
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   867
                    showWindow:false
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   868
                    onError:[:stat| 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   869
                                executionStatus := stat.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   870
                                false
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   871
                    ].
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   872
    ].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   873
    [
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   874
        ok ifFalse:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   875
            aBlock value:errorOutputFile
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   876
        ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   877
    ] ensure:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   878
        errorOutputFile remove.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
   879
    ].
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   880
    ^ ok
4400
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   881
978971f3de9e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4309
diff changeset
   882
    "Modified: / 28-03-2019 / 16:17:13 / Claus Gittinger"
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   883
!
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   884
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   885
ensureExternalToolsArePresent
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   886
    (stcPath := self incrementalStcPath) isNil ifTrue:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   887
        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
   888
    ].
2649
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   889
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   890
    "make it absolute, so that we are immune to directory changes"
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   891
    stcPath := stcPath asFilename pathName.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   892
    (ccPath := parserFlags ccPath) isNil ifTrue:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   893
        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
   894
    ].
2649
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   895
    "make it absolute, so that we are immune to directory changes"
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   896
    ccPath := ccPath asFilename pathName.
1939
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
    (ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   899
        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
   900
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   901
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   902
    "Created: / 07-11-2006 / 12:31:48 / cg"
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   903
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   904
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   905
ensureModuleDirectoryExists
3664
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   906
    |mP t msg|
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   907
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   908
    mP := parserFlags stcModulePath.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   909
    mP isEmptyOrNil ifTrue:[
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   910
        self parseError:'No temporary module directory, check your settings!!' position:1.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   911
    ].
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   912
    mP := mP asFilename.
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   913
    mP exists ifFalse:[
4058
1e87dfa2ea9e #BUGFIX by sr
sr
parents: 4023
diff changeset
   914
        mP recursiveMakeDirectory
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   915
    ].
3240
60e8fa24bbc6 Use #isWritableDirectory
Stefan Vogel <sv@exept.de>
parents: 3173
diff changeset
   916
    (mP isWritableDirectory and:[mP isReadable]) ifFalse:[
3664
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   917
        (mP exists and:[mP isDirectory]) ifTrue:[
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   918
            msg := 'No write permission in temporary module directory: '.
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   919
        ] ifFalse:[    
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   920
            msg := 'No access to temporary module directory: '.
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   921
        ].
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   922
        self parseError:(msg , mP pathName) position:1.
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   923
    ].
3664
646ce5a13d24 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
   924
    
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   925
    "/ create a small README there ...
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   926
    
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   927
    (t := mP construct:'README') exists ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   928
        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
   929
accepted methods with embedded C-code 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   930
(i.e. dynamic compiled code for inline-C methods).
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   931
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   932
Files here are not automatically removed, since ST/X 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   933
cannot determine if any (other) snapshot image still 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   934
requires a file here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   935
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   936
Please be careful when removing files here - a snapshot
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   937
image which was saved with accepted embedded C-code
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   938
may not be able to restart correctly if you remove a
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   939
required file.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   940
Also, when you export a snapshot image for execution
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   941
on another machine, make certain that the required
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   942
module-files are also present there.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   943
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   944
You should periodically clean dead entries here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   945
i.e. remove files, when you are certain that none
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   946
of your snapshot images refers to any module here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   947
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   948
See the launchers File-Modules dialog for a list of
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   949
modules which are still required by your running image.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   950
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   951
With kind regards - your ST/X.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   952
'.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   953
    ].
4031
671f88158987 Fixed STCCompilerInterface>>ensureModuleDirectoryExists
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4028
diff changeset
   954
671f88158987 Fixed STCCompilerInterface>>ensureModuleDirectoryExists
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4028
diff changeset
   955
    "Modified: / 26-10-2016 / 22:35:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   956
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   957
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   958
ensureSuperClassesAreLoadedOf:aClass
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   959
    |supers|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   960
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   961
    supers := aClass allSuperclasses.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   962
    supers reverseDo:[:cls|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   963
        cls isLoaded ifFalse:[
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
   964
            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
   965
        ]
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   966
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   967
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   968
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   969
fileOutAllDefinitionsOf:aClass to:aStream rememberIn:definedClasses
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   970
    |defineAction|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   971
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   972
    defineAction := 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   973
        [:cls|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   974
            (definedClasses includes:cls) ifFalse:[
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   975
                cls 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   976
                    basicFileOutDefinitionOn:aStream 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   977
                    withNameSpace:false withPackage:false
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   978
                    syntaxHilighting:false.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   979
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   980
                aStream nextPut:(aStream class chunkSeparator); cr.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   981
                definedClasses add:cls.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   982
            ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   983
        ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   984
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   985
    aClass allSuperclasses reverseDo:defineAction.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   986
    defineAction value:aClass.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   987
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   988
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   989
generateSTSource:aString 
3359
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
   990
    |stream definedClasses sep className modulesDir ns nsName|
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   991
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   992
    "/ generate a unique name, consisting of my processID and a sequence number
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   993
    "/ the processId is added to allow filein of modules from different
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   994
    "/ lifes
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
    SequenceNumber := (SequenceNumber ? 0) + 1.
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
    initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   999
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1000
"/    Smalltalk isSmalltalkDevelopmentSystem ifTrue:[
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1001
"/        modulesParentDir := Filename currentDirectory. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1002
"/    ] ifFalse:[
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1003
"/        modulesParentDir := Filename tempDirectory. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1004
"/    ].
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1005
"/    modulesDir := modulesParentDir construct:'modules'. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1006
    modulesDir := ParserFlags stcModulePath.
2647
a47876ae33fd changed: #generateSTSource:
Stefan Vogel <sv@exept.de>
parents: 2646
diff changeset
  1007
    stFileName := (modulesDir asFilename construct:(initName , '.st')) name. 
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1008
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1009
    [
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1010
        stream := stFileName asFilename writeStream.
4615
0df1ab0308a1 #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1011
    ] on:OpenError do:[:ex|
3411
9e5e218273ee class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3361
diff changeset
  1012
        self parseError:'cannot create temporary sourcefile for compilation' position:1.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1013
        ^ #CannotLoad
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1014
    ].
3419
24e01ffb296f class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3411
diff changeset
  1015
    stream := EncodedStream stream:stream encoder:(CharacterEncoder encoderForUTF8).
24e01ffb296f class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3411
diff changeset
  1016
    stream nextPutLine:'"{ Encoding: utf8 }" !!'.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1017
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1018
    definedClasses := IdentitySet new.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1019
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1020
    sep := stream class chunkSeparator.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1021
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1022
    Class fileOutNameSpaceQuerySignal answer:true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1023
    do:[
2467
a7ed431694a2 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  1024
        theNonMetaclassToCompileFor realSharedPoolNames do:[:eachPoolname |
2067
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1025
            |pool|
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1026
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1027
            pool := Smalltalk at:eachPoolname.
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1028
            self 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1029
                fileOutAllDefinitionsOf:pool 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1030
                to:stream 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1031
                rememberIn:definedClasses.
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1032
        ].
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
  1033
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1034
        self 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1035
            fileOutAllDefinitionsOf:theNonMetaclassToCompileFor 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1036
            to:stream 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1037
            rememberIn:definedClasses.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1038
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1039
        theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass |
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1040
            self 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1041
                fileOutAllDefinitionsOf:aPrivateClass 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1042
                to:stream 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1043
                rememberIn:definedClasses.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1044
        ].
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
  1045
"/        theNonMetaclassToCompileFor fileOutPrimitiveDefinitionsOn:stream.
2026
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
  1046
"/ 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
  1047
"/ 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
  1048
        theNonMetaclassToCompileFor fileOutPrimitiveSpecsOn:stream.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1049
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1050
2026
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
  1051
"/    stream cr.
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
  1052
"/    stream nextPutLine:'"{ Package: ''' , package , ''' }"'.
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
  1053
"/    stream cr.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1054
3357
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
  1055
    className := theNonMetaclassToCompileFor name.
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
  1056
    ns := theNonMetaclassToCompileFor topNameSpace.
4292
c52d721695b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  1057
    
c52d721695b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  1058
    (ns notNil 
c52d721695b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  1059
      and:[ns ~= Smalltalk 
c52d721695b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  1060
      and:[nsName := ns name. 
c52d721695b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  1061
           className startsWith:(nsName,'::')
c52d721695b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  1062
    ]]) ifTrue:[
3359
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
  1063
        className := className copyFrom:nsName size+2+1.
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
  1064
        "/ split to avoid being regognized as a directive
f18089e05968 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3357
diff changeset
  1065
        stream nextPutLine:('"','{ NameSpace: ',nsName,' }"').
3357
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
  1066
    ].
7dabc8614714 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
  1067
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1068
    stream nextPut:sep.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1069
    stream nextPutAll:className.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1070
    classToCompileFor isMeta ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1071
        stream nextPutAll:' class'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1072
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1073
    stream nextPutAll:' methodsFor:'''; nextPutAll:methodCategory; nextPutAll:''''.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1074
    stream nextPut:sep; cr.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1075
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1076
    stream nextPutLine:'"{ Line: 0 }"'; 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1077
           nextChunkPut:aString;
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1078
           space; nextPut:sep.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1079
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1080
    stream close.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1081
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
  1082
    "Modified: / 08-08-2011 / 23:23:10 / cg"
4292
c52d721695b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  1083
    "Modified (format): / 08-08-2018 / 08:58:35 / Claus Gittinger"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1084
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1085
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
  1086
reportCompilationErrorFor:aCommand
4250
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
  1087
    <resource: #obsolete>
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
  1088
    self obsoleteMethodWarning.
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
  1089
    ^ self reportCompilationErrorFor:aCommand fromFile:'errorOutput' asFilename.
2461
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
  1090
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1091
    "Created: / 07-11-2006 / 12:29:04 / cg"
3348
b59a15a24ab3 class: STCCompilerInterface
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3240
diff changeset
  1092
    "Modified: / 21-12-2013 / 00:08:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4250
2903262d8033 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4225
diff changeset
  1093
    "Modified: / 11-05-2018 / 09:29:20 / stefan"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1094
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1095
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1096
reportCompilationErrorFor:aCommand fromFile:anErrorFilename
4468
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1097
    |eMsg errorMessages errorMessagesColorized lNr cFile stFile|
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1098
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1099
    (executionStatus notNil and:[executionStatus couldNotExecute]) ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1100
        eMsg := 'oops, no %1 - cannot create machine code' bindWith:aCommand.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1101
    ] ifFalse:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1102
        errorMessages := anErrorFilename contents 
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1103
                            collect:[:l | OperatingSystem decodePathOrCommandOutput: l ].
4468
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1104
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1105
        "/ replace the filename string
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1106
        cFile := cFileName asFilename name.
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1107
        stFile := stFileName asFilename name.
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1108
        errorMessages := errorMessages 
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1109
            collect:[:line |
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1110
                (line startsWith:cFile) ifTrue:[
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1111
                    cFileName asFilename baseName,(line copyFrom:cFile size+1)
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1112
                ] ifFalse:[
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1113
                    (line startsWith:stFile) ifTrue:[
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1114
                        stFileName asFilename baseName,(line copyFrom:stFile size+1)
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1115
                    ] ifFalse:[
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1116
                        line
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1117
                    ].
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1118
                ].
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1119
            ].
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1120
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1121
        errorMessagesColorized := 
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1122
            errorMessages collect:[:line |
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1123
                (line includesString:'warning:' caseSensitive:false) ifTrue:[
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1124
                    line withColor:Color orange
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1125
                ] ifFalse:[
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1126
                    (line includesString:'error:' caseSensitive:false) ifTrue:[
4540
f3cc57ef4e7e #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
  1127
                        line allRed
4468
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1128
                    ] ifFalse:[
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1129
                        line
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1130
                    ]
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1131
                ]
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1132
            ].
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1133
        Transcript showCR:errorMessagesColorized asString.
cf6348f8d103 #UI_ENHANCEMENT by exept
Claus Gittinger <cg@exept.de>
parents: 4400
diff changeset
  1134
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1135
        errorMessages notNil ifTrue:[
4309
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1136
            errorMessages := errorMessages reject:[:line | line includesString:'Note:' caseSensitive:false].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1137
            errorMessages size > 20 ifTrue:[
4600
f07c4dab5486 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1138
                errorMessages := errorMessages reject:[:line | line startsWith:'Note ' caseSensitive:false].
f07c4dab5486 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1139
            ].
f07c4dab5486 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1140
            errorMessages size > 20 ifTrue:[
4309
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1141
                errorMessages := errorMessages reject:[:line | line includesString:'Warning:' caseSensitive:false].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1142
                errorMessages size > 20 ifTrue:[
4600
f07c4dab5486 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1143
                    errorMessages := errorMessages reject:[:line | line startsWith:'Warning ' caseSensitive:false].
f07c4dab5486 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1144
                ].
f07c4dab5486 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1145
                errorMessages size > 20 ifTrue:[
4309
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1146
                    "/ errorMessages := errorMessages select:[:line | line asLowercase startsWith:'error'].
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1147
                    errorMessages size > 20 ifTrue:[
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1148
                        errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped'
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1149
                    ].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1150
                ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1151
"/                    errorMessages := errorMessages collect:[:line |
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1152
"/                        (line startsWith:(stFileName , ':')) ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1153
"/                            'Line: ' , (line copyFrom:(stFileName size + 2))
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1154
"/                        ] ifFalse:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1155
"/                            line
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1156
"/                        ]
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1157
"/                      ].
4309
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1158
            ].
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1159
        ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1160
        errorMessages isNil ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1161
            errorMessages := #('')
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1162
        ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1163
        errorMessages := (Array with:'Failed to execute: "', aCommand,'"') , errorMessages.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1164
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1165
        "/ try to extract a line number"
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1166
        (errorMessages contains:[:line | line includesString:'Borland']) ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1167
            |i i2 s|
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1168
            i := errorMessages findFirst:[:l | l startsWith:(cFileName,':')].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1169
            i ~~ 0 ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1170
                ((errorMessages at:i+1) startsWith:'Error') ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1171
                    i2 := (errorMessages at:i+1) indexOfSubCollection:(stFileName).
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1172
                    i2 ~~ 0 ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1173
                        s := (errorMessages at:i+1) copyFrom:(i2+stFileName size+1).
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1174
                        s := s readStream.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1175
                        lNr := Integer readFrom:s.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1176
                        s skipSeparators.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1177
                    ].    
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1178
                ]
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1179
            ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1180
        ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1181
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1182
        errorMessages isEmpty ifTrue:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1183
            eMsg := 'Error during compilation:\\Unspecified error (no output)' withCRs
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1184
        ] ifFalse:[
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1185
            eMsg := 'Error during compilation:\\' withCRs ,
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1186
                    (errorMessages asStringCollection asString).
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1187
        ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1188
    ].
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1189
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1190
    originator activityNotification:''.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1191
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1192
    ParseError new
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1193
        lineNumber:lNr;
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1194
        errorMessage:eMsg;
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1195
        raise.
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1196
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1197
    "Created: / 07-11-2006 / 12:29:04 / cg"
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1198
    "Modified: / 21-12-2013 / 00:08:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4135
ec9b0d7c8952 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
  1199
    "Modified: / 25-02-2017 / 09:58:18 / cg"
ec9b0d7c8952 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
  1200
    "Modified (format): / 25-02-2017 / 19:33:58 / cg"
4309
c8afd1b2aa81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4292
diff changeset
  1201
    "Modified: / 01-10-2018 / 09:18:53 / Claus Gittinger"
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1202
!
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1203
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1204
setupCompilationCommandArguments
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
  1205
    |stFn libDir incDir incDirArg defs incl opts|
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1206
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1207
    parserFlags isNil ifTrue:[ parserFlags := ParserFlags new].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1208
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  1209
    stFn := stFileName asFilename.
4266
7fe184eebe89 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4260
diff changeset
  1210
    oFileName := (stFn withSuffix:(ObjectFileLoader objectFileSuffix)) name.
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  1211
    cFileName := (stFn withSuffix:'c') name. 
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
  1212
"/    ParserFlags useBorlandC ifTrue:[
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
  1213
"/        cFileName := (stFn withSuffix:'sc') name. 
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
  1214
"/    ].
4225
53895f16c1e2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4135
diff changeset
  1215
    oFileName asFilename remove.
53895f16c1e2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4135
diff changeset
  1216
    cFileName asFilename remove.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1217
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1218
    "/ stcFlags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName .
4679
47b03fee99a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4615
diff changeset
  1219
    stcFlags := '+newIncremental +opt +optInline'.
4018
973908080769 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4004
diff changeset
  1220
    stcFlags := '+newIncremental'.
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1221
    initName notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1222
        stcFlags := stcFlags,' -N' , initName .
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1223
    ].
3685
4087099b6e26 STC interface clenaup: cleaned up C flags initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3664
diff changeset
  1224
    cFlags := self class builtinCFlags.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1225
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1226
    (defs := parserFlags stcCompilationDefines) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1227
        cFlags := cFlags , ' ' , defs
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1228
    ].
3686
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1229
    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
  1230
    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
  1231
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1232
    (incl := parserFlags stcCompilationIncludes) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1233
        stcFlags := incl , ' ' , stcFlags.
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1234
        cFlags := cFlags , ' ' , incl.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1235
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1236
        "/ if STX_LIBDIR is defined, and not in passed argument,
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1237
        "/ add it here.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1238
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1239
        libDir := OperatingSystem getEnvironment:'STX_LIBDIR'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1240
        (libDir notNil and:[libDir asFilename exists]) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1241
            incDir := libDir asFilename construct:'include'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1242
            incDir exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1243
                incDirArg := '-I' , incDir pathName.
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1244
                (incl asCollectionOfWords includes:incDirArg) ifFalse:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1245
                    stcFlags := stcFlags , ' ' , incDirArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1246
                    cFlags := cFlags , ' ' , incDirArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1247
                ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1248
            ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1249
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1250
    ].
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1251
    (opts := parserFlags stcCompilationOptions) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1252
        stcFlags := opts , ' ' , stcFlags
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1253
    ].
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1254
    (opts := parserFlags ccCompilationOptions) notEmptyOrNil ifTrue:[
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1255
        cFlags := cFlags , ' ' , opts
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1256
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1257
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1258
    "Created: / 07-11-2006 / 12:24:47 / cg"
4679
47b03fee99a1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4615
diff changeset
  1259
    "Modified: / 16-06-2020 / 19:07:43 / 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
  1260
    "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
  1261
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
!STCCompilerInterface class methodsFor:'documentation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1265
version
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1266
    ^ '$Header$'
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1267
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1268
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
  1269
version_CVS
3659
7570b2de4934 class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3437
diff changeset
  1270
    ^ '$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
  1271
!
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1272
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1273
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
  1274
d8bf4414aa3d STC interface clenaup: cleaned up C include directories initialization and settings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3685
diff changeset
  1275
    ^ '$Changeset: <not expanded> $'
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1276
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1277
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
  1278
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
STCCompilerInterface initialize!