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