ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Mon, 11 Mar 2013 21:31:15 +0100
changeset 2974 8cf2b51872fd
parent 2972 7db782e25d01
child 2979 06dcbe5668a4
permissions -rw-r--r--
class: Tools::ProjectBuilder
changed: #suiteNameOfCompiler:
cg@2741
     1
"
cg@2741
     2
 COPYRIGHT (c) 2009 by eXept Software AG
cg@2741
     3
              All Rights Reserved
cg@2741
     4
cg@2741
     5
 This software is furnished under a license and may be used
cg@2741
     6
 only in accordance with the terms of that license and with the
cg@2741
     7
 inclusion of the above copyright notice.   This software may not
cg@2741
     8
 be provided or otherwise made available to, or used by, any
cg@2741
     9
 other person.  No title to or ownership of the software is
cg@2741
    10
 hereby transferred.
cg@2741
    11
"
cg@2596
    12
"{ Package: 'stx:libtool2' }"
cg@2596
    13
cg@2635
    14
"{ NameSpace: Tools }"
cg@2635
    15
cg@2596
    16
Object subclass:#ProjectBuilder
cg@2596
    17
	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
cg@2673
    18
		myWorkingDirectory mySTXTopDirectory myTopDirectory outputStream
cg@2972
    19
		makeExeOnly makeQuick usedCompiler stdOut stdErr isQuickBuild
cg@2972
    20
		isLocalBuild'
cg@2596
    21
	classVariableNames:'PreviousBuildDirectory'
cg@2596
    22
	poolDictionaries:''
cg@2596
    23
	category:'System-Support-Projects'
cg@2596
    24
!
cg@2596
    25
cg@2741
    26
!ProjectBuilder class methodsFor:'documentation'!
cg@2741
    27
cg@2741
    28
copyright
cg@2741
    29
"
cg@2741
    30
 COPYRIGHT (c) 2009 by eXept Software AG
cg@2741
    31
              All Rights Reserved
cg@2741
    32
cg@2741
    33
 This software is furnished under a license and may be used
cg@2741
    34
 only in accordance with the terms of that license and with the
cg@2741
    35
 inclusion of the above copyright notice.   This software may not
cg@2741
    36
 be provided or otherwise made available to, or used by, any
cg@2741
    37
 other person.  No title to or ownership of the software is
cg@2741
    38
 hereby transferred.
cg@2741
    39
"
cg@2741
    40
! !
cg@2596
    41
cg@2633
    42
!ProjectBuilder class methodsFor:'accessing'!
cg@2633
    43
cg@2633
    44
previousBuildDirectory
cg@2633
    45
    ^ PreviousBuildDirectory
cg@2633
    46
!
cg@2633
    47
cg@2633
    48
previousBuildDirectory:something
cg@2633
    49
    PreviousBuildDirectory := something.
cg@2633
    50
! !
cg@2633
    51
cg@2596
    52
!ProjectBuilder class methodsFor:'examples'!
cg@2596
    53
cg@2644
    54
example1
cg@2644
    55
    Smalltalk loadPackage:'stx:projects/helloWorldApp' asAutoloaded:true.
cg@2644
    56
cg@2644
    57
    self new
cg@2644
    58
        package:'stx:projects/helloWorldApp';
cg@2644
    59
        build
cg@2622
    60
!
cg@2622
    61
cg@2644
    62
example2
cg@2644
    63
    |builder|
cg@2644
    64
cg@2644
    65
    Smalltalk loadPackage:'stx:clients/Demos/foxCalcApplication' asAutoloaded:true.
cg@2644
    66
cg@2644
    67
    builder := self new.
cg@2909
    68
    builder 
cg@2909
    69
        package:'stx:clients/Demos/foxCalcApplication';
cg@2909
    70
        build.
cg@2644
    71
cg@2644
    72
    UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
cg@2909
    73
cg@2909
    74
    "Modified: / 03-09-2012 / 19:23:53 / cg"
cg@2596
    75
! !
cg@2596
    76
cg@2873
    77
!ProjectBuilder class methodsFor:'queries'!
cg@2873
    78
cg@2873
    79
defaultUsedCompiler
cg@2873
    80
    |compiler|
cg@2873
    81
cg@2873
    82
    (compiler := UserPreferences current usedCompilerForBuild) notNil ifTrue:[
cg@2873
    83
        ^ compiler
cg@2873
    84
    ].
cg@2873
    85
cg@2921
    86
    ^ OperatingSystem isMSWINDOWSlike 
cg@2921
    87
        ifTrue:[ 'bcc' ]
cg@2921
    88
        ifFalse:[ 'gcc' ]
cg@2873
    89
cg@2873
    90
    "Created: / 21-01-2012 / 14:06:51 / cg"
cg@2873
    91
!
cg@2873
    92
cg@2873
    93
listOfPossibleCompilers
cg@2873
    94
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2918
    95
        OperatingSystem getLoginName = 'cg' ifTrue:[
cg@2921
    96
            ^ #(
cg@2921
    97
                'bcc'   "/ OK
cg@2921
    98
                'vc'    "/ almost OK
cg@2921
    99
                'lcc'   "/ experimental, but only free for non-commercial work
cg@2921
   100
                'tcc'   "/ experimental; limited but free
cg@2921
   101
                'mingw' "/ experimental; free
cg@2921
   102
             )
cg@2918
   103
        ].
cg@2972
   104
        ^ #('bcc' 'vc' 'mingw' )
cg@2873
   105
    ].
cg@2873
   106
    ^ #('gcc')
cg@2873
   107
cg@2873
   108
    "Created: / 21-01-2012 / 14:04:15 / cg"
cg@2921
   109
!
cg@2921
   110
cg@2921
   111
suiteNameOfCompiler:usedCompiler
cg@2921
   112
    usedCompiler = 'bcc' ifTrue:[
cg@2921
   113
        ^ 'Borland C-Compiler'.
cg@2921
   114
    ].
cg@2921
   115
    usedCompiler = 'vc' ifTrue:[
cg@2974
   116
        ^ 'Microsoft Visual C Compiler'.
cg@2921
   117
    ].
cg@2921
   118
    usedCompiler = 'lcc' ifTrue:[
cg@2921
   119
        ^ 'LCC C-Compiler'.
cg@2921
   120
    ].
cg@2921
   121
    usedCompiler = 'tcc' ifTrue:[
cg@2921
   122
        ^ 'Tiny C-Compiler'.
cg@2921
   123
    ].
cg@2921
   124
    usedCompiler = 'gcc' ifTrue:[
cg@2921
   125
        ^ 'GNU C-Compiler'.
cg@2921
   126
    ].
cg@2921
   127
    usedCompiler = 'mingw' ifTrue:[
cg@2921
   128
        ^ 'MINGW GNU C-Compiler'.
cg@2921
   129
    ].
cg@2921
   130
    self halt:'unknown compiler'.
cg@2921
   131
cg@2921
   132
    ^ 'C-Compiler'.
cg@2921
   133
cg@2921
   134
    "Created: / 06-09-2012 / 15:58:33 / cg"
cg@2873
   135
! !
cg@2873
   136
cg@2596
   137
!ProjectBuilder methodsFor:'accessing'!
cg@2596
   138
cg@2644
   139
buildDirectory
cg@2644
   140
    ^ buildDirectory
cg@2622
   141
!
cg@2622
   142
cg@2634
   143
buildDirectory:something
cg@2634
   144
    buildDirectory := something.
cg@2634
   145
!
cg@2634
   146
cg@2964
   147
isLocalBuild
cg@2964
   148
    ^ isLocalBuild ? false
cg@2964
   149
!
cg@2964
   150
cg@2964
   151
isLocalBuild:aBoolean
cg@2964
   152
    "create a files without going through the source code manager"
cg@2964
   153
cg@2964
   154
    isLocalBuild := aBoolean.
cg@2964
   155
!
cg@2964
   156
cg@2964
   157
isQuickBuild
cg@2964
   158
    ^ isQuickBuild ? false
cg@2964
   159
!
cg@2964
   160
cg@2964
   161
isQuickBuild:aBoolean
cg@2964
   162
    "skips creation of header files, and copying of support files, if possible
cg@2964
   163
     to speedup a build. Use with care."
cg@2964
   164
cg@2964
   165
    isQuickBuild := aBoolean.
cg@2964
   166
!
cg@2964
   167
cg@2972
   168
makeExeOnly
cg@2972
   169
    ^ (makeExeOnly ? false)
cg@2972
   170
!
cg@2972
   171
cg@2673
   172
makeExeOnly:aBoolean
cg@2673
   173
    makeExeOnly := aBoolean.
cg@2673
   174
!
cg@2673
   175
cg@2972
   176
makeQuick
cg@2972
   177
    ^ (makeQuick ? false)
cg@2972
   178
!
cg@2972
   179
cg@2972
   180
makeQuick:aBoolean
cg@2972
   181
    makeQuick := aBoolean.
cg@2972
   182
!
cg@2972
   183
cg@2644
   184
package:aPackageIDOrSymbol
cg@2644
   185
    package := aPackageIDOrSymbol asPackageId.
cg@2596
   186
!
cg@2596
   187
cg@2644
   188
packageBuildDirectory
cg@2644
   189
    "the directoray, where the deployable binary is created (xxxSetup.exe)"
cg@2622
   190
cg@2622
   191
    ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
cg@2635
   192
!
cg@2635
   193
cg@2644
   194
projectDefinitionClass:something
cg@2644
   195
    projectDefinitionClass := something.
cg@2680
   196
!
cg@2680
   197
sr@2683
   198
suffixForHeaderFiles
sr@2683
   199
    ^ OperatingSystem isUNIXlike ifTrue:['.H'] ifFalse:['.STH']
sr@2683
   200
!
sr@2683
   201
cg@2873
   202
usedCompilerForBuild:something
cg@2680
   203
    usedCompiler := something.
cg@2873
   204
cg@2873
   205
    "Created: / 22-01-2012 / 10:50:48 / cg"
cg@2596
   206
! !
cg@2596
   207
cg@2596
   208
!ProjectBuilder methodsFor:'building'!
cg@2596
   209
cg@2644
   210
build
cg@2644
   211
    "/ intermediate - this will move into a commonly used utility class
cg@2635
   212
    "/ (where all the project code support will be collected).
cg@2635
   213
cg@2647
   214
    |makeOutput|
cg@2647
   215
cg@2647
   216
    makeOutput := TextStream on:(Text new:10000).
cg@2647
   217
    self buildWithColorizedOutputTo:makeOutput.
cg@2647
   218
cg@2647
   219
    TextView openWith:makeOutput contents.
cg@2647
   220
!
cg@2647
   221
cg@2647
   222
buildWithColorizedOutputTo:makeOutput
cg@2647
   223
    "/ intermediate - this will move into a commonly used utility class
cg@2647
   224
    "/ (where all the project code support will be collected).
cg@2647
   225
cg@2921
   226
    |lock|
cg@2635
   227
cg@2644
   228
    lock := Semaphore forMutualExclusion.
cg@2647
   229
cg@2644
   230
    stdErr := ActorStream new
cg@2644
   231
                    nextPutBlock:[:char |
cg@2644
   232
                        lock critical:[
cg@2921
   233
                            makeOutput 
cg@2921
   234
                                withEmphasis:{#backgroundColor->Color red. #color->Color white.}
cg@2921
   235
                                do:[makeOutput nextPut:char].
cg@2644
   236
                        ]
cg@2644
   237
                    ];
sr@2683
   238
                    nextPutAllBlock:[:string |
cg@2873
   239
                        lock critical:[          
cg@2873
   240
                            "/ (string includesString:'das Ziel' )ifTrue:[self halt].
cg@2921
   241
                            makeOutput
cg@2921
   242
                                withEmphasis:{#backgroundColor->Color red. #color->Color white.}
cg@2921
   243
                                do:[makeOutput nextPutAll:string].
cg@2644
   244
                        ]
cg@2644
   245
                    ].
cg@2644
   246
    stdOut := ActorStream new
cg@2644
   247
                    nextPutBlock:[:char |
cg@2644
   248
                        lock critical:[
cg@2644
   249
                            makeOutput nextPut:char.
cg@2644
   250
                        ]
cg@2644
   251
                    ];
sr@2683
   252
                    nextPutAllBlock:[:string |
cg@2873
   253
                        lock critical:[         
cg@2873
   254
                            "/ (string includesString:'das Ziel' )ifTrue:[self halt].
sr@2683
   255
                            makeOutput nextPutAll:string.
cg@2644
   256
                        ]
cg@2644
   257
                    ].
cg@2635
   258
cg@2644
   259
    self buildWithOutputTo:stdOut errorTo:stdErr.
cg@2873
   260
cg@2921
   261
    "Modified: / 06-09-2012 / 16:15:50 / cg"
cg@2611
   262
!
cg@2611
   263
cg@2969
   264
buildWithOutputTo:stdOutArg errorTo:stdErrArg
cg@2611
   265
    "/ intermediate - this will move into a commonly used utility class
cg@2611
   266
    "/ (where all the project code support will be collected).
cg@2611
   267
cg@2596
   268
    |module directory|
cg@2596
   269
cg@2596
   270
    projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
cg@2596
   271
    projectDefinitionClass isNil ifTrue:[
cg@2596
   272
        self error:('Missing ProjectDefinition class for "',package asString,'"')
cg@2596
   273
    ].
cg@2596
   274
cg@2596
   275
    "/ ensure that everything is loaded...
cg@2596
   276
    projectDefinitionClass loadAsAutoloaded:false.
cg@2596
   277
    projectDefinitionClass loadExtensions.
cg@2596
   278
    projectDefinitionClass loadAllClassesAsAutoloaded:false.
cg@2596
   279
cg@2596
   280
    module := package module.
cg@2596
   281
    directory := package directory.
cg@2596
   282
cg@2596
   283
    buildDirectory isNil ifTrue:[
cg@2634
   284
        buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
cg@2634
   285
        buildDirectory isNil ifTrue:[
cg@2634
   286
            buildDirectory := Filename tempDirectory construct:'stx_build'.
cg@2634
   287
        ].
cg@2596
   288
    ].
cg@2596
   289
    buildDirectory := buildDirectory asFilename.
cg@2596
   290
cg@2596
   291
    "/ self validateBuildDirectoryIsPresent.
cg@2596
   292
cg@2596
   293
    PreviousBuildDirectory := buildDirectory.
cg@2596
   294
cg@2596
   295
    "/ UserPreferences current localBuild:true
cg@2964
   296
    (self isLocalBuild or:[UserPreferences current localBuild]) ifFalse:[
cg@2596
   297
        SourceCodeManager notNil ifTrue:[
sv@2861
   298
            sourceCodeManager := SourceCodeManagerUtilities default sourceCodeManagerFor:projectDefinitionClass.
cg@2596
   299
        ]
cg@2596
   300
    ].
cg@2596
   301
    sourceCodeManager := nil.
cg@2596
   302
cg@2598
   303
    myTopDirectory := 
cg@2596
   304
        Smalltalk packagePath 
cg@2596
   305
            detect:[:aPath |
cg@2596
   306
                (aPath asFilename / 'stx' / 'include') exists
cg@2596
   307
                and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
cg@2596
   308
            ifNone:nil.       
cg@2598
   309
    myTopDirectory isNil ifTrue:[
cg@2598
   310
        self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
cg@2596
   311
    ].
cg@2598
   312
    myTopDirectory := myTopDirectory asFilename.
cg@2598
   313
    mySTXTopDirectory := myTopDirectory / 'stx'.
cg@2613
   314
cg@2972
   315
    self makeQuick ifFalse:[
cg@2972
   316
        self setupBuildDirectory.
cg@2972
   317
        self activityNotification:'Generating stc directory...'.
cg@2972
   318
        self copySTCDirectoryForBuild.
cg@2972
   319
    ].
cg@2628
   320
    self activityNotification:'Generating source files...'.
cg@2596
   321
    self generateSourceFiles.
cg@2972
   322
    self makeQuick ifFalse:[
cg@2972
   323
        self activityNotification:'Copying dlls for linkage...'.
cg@2972
   324
        self copyDLLsForLinkage.
cg@2972
   325
        self activityNotification:'Copying support files for compilation and linkage...'.
cg@2972
   326
        self copySupportFilesForCompilation.
cg@2972
   327
        self copySupportFilesForLinkage.
cg@2972
   328
        self copyStartupFilesFromSmalltalk.
cg@2972
   329
    ].
cg@2628
   330
    self activityNotification:'Executing make...'.
cg@2611
   331
    self makeWithOutputTo:stdOut errorTo:stdErr.
cg@2912
   332
cg@2912
   333
    "Modified: / 04-09-2012 / 00:49:52 / cg"
cg@2898
   334
! !
cg@2898
   335
cg@2898
   336
!ProjectBuilder methodsFor:'building/private'!
cg@2596
   337
cg@2644
   338
copyDLLsForLinkage
cg@2911
   339
    |targetBuildDir preRequisites dllRelativeSourcePathes dllRelativeDestPathes|
sv@2723
   340
cg@2644
   341
    targetBuildDir := buildDirectory / package module / package directory.
cg@2644
   342
sv@2723
   343
    preRequisites := projectDefinitionClass allPreRequisites.
sv@2723
   344
    OperatingSystem isUNIXlike ifTrue:[
sv@2723
   345
        "For now: unix Makefiles require some libs implicitely..."
sv@2723
   346
        preRequisites := preRequisites union:#(
sv@2723
   347
                               'stx:goodies/refactoryBrowser/parser'
sv@2723
   348
                               'stx:libtool'
sv@2723
   349
                            ).
sv@2723
   350
    ].
sv@2723
   351
sv@2723
   352
    preRequisites do:[:eachPackageToFileout |
cg@2644
   353
        |packageId packageDef packageModule packageDirectory packageTargetDir
cg@2911
   354
         dllSource dllSourceDir libraryName dllRelativePathSource 
cg@2916
   355
         dllRelativePathDest objDirSource objDirDest alternativeObjDirSource|
cg@2644
   356
cg@2644
   357
        packageId := eachPackageToFileout asPackageId.
cg@2644
   358
        packageModule := packageId module.
cg@2644
   359
        packageDirectory := packageId directory.
cg@2644
   360
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   361
cg@2644
   362
        packageDef := packageId projectDefinitionClass.
cg@2644
   363
        libraryName := packageDef libraryName.
cg@2644
   364
cg@2644
   365
        "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
cg@2644
   366
        dllSourceDir := myTopDirectory / packageModule / packageDirectory.
cg@2909
   367
cg@2644
   368
        OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2911
   369
            objDirDest := self objDirForUsedCompiler:usedCompiler.
cg@2916
   370
            objDirSource := objDirDest.
cg@2916
   371
"/            "/ use visual-c files for tcc linkage
cg@2916
   372
"/            usedCompiler = 'tcc' ifTrue:[
cg@2916
   373
"/                objDirSource := self objDirForUsedCompiler:'vc'.
cg@2916
   374
"/            ] ifFalse:[
cg@2916
   375
"/                objDirSource := objDirDest
cg@2916
   376
"/            ].
cg@2916
   377
            (dllSourceDir / objDirSource / (libraryName, '.dll')) exists ifFalse:[
cg@2916
   378
                alternativeObjDirSource := self objDirForUsedCompiler:'vc'.
cg@2916
   379
                (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
cg@2921
   380
                    objDirSource := alternativeObjDirSource.
cg@2921
   381
                    stdErr nextPutLine:(('Warning: using alternative %1 from %2 (%3 version)...' 
cg@2921
   382
                                                bindWith:libraryName 
cg@2921
   383
                                                with:alternativeObjDirSource 
cg@2921
   384
                                                with:(self class suiteNameOfCompiler:'vc'))
cg@2921
   385
                                            emphasizeAllWith:(#color -> Color red darkened)).
cg@2921
   386
                ] ifFalse:[
cg@2921
   387
                    alternativeObjDirSource := self objDirForUsedCompiler:'bcc'.
cg@2921
   388
                    (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
cg@2921
   389
                        objDirSource := alternativeObjDirSource.
cg@2921
   390
                        stdErr nextPutLine:('Warning: using alternative %1 from %2 (%3 version)...' 
cg@2921
   391
                                    bindWith:libraryName 
cg@2921
   392
                                    with:alternativeObjDirSource 
cg@2921
   393
                                    with:(self class suiteNameOfCompiler:'bcc')).
cg@2921
   394
                    ]
cg@2921
   395
                ].
cg@2911
   396
            ].
cg@2916
   397
cg@2905
   398
"/            dllRelativePath := objDir,'/',(libraryName,'.dll').
cg@2644
   399
"/            (dllSourceDir / dllRelativePath) exists 
cg@2911
   400
            dllRelativeSourcePathes := Array with:(objDirSource,'\', libraryName, '.dll').
cg@2911
   401
            dllRelativeDestPathes := Array with:(objDirDest,'\', libraryName, '.dll').
cg@2644
   402
        ] ifFalse:[
cg@2911
   403
            dllRelativeSourcePathes := Array with:(libraryName,'.so').
cg@2958
   404
            dllRelativeDestPathes := Array with:(libraryName, '.so').
sv@2723
   405
            (packageModule = 'stx' and:[packageDirectory = 'libview']) ifTrue:[
cg@2958
   406
                dllRelativeSourcePathes := dllRelativeSourcePathes copyWith:('XWorkstation.so').
cg@2958
   407
                dllRelativeDestPathes := dllRelativeDestPathes copyWith:'XWorkstation.so'.
cg@2958
   408
                dllRelativeSourcePathes := dllRelativeSourcePathes copyWith:('GLXWorkstation.so').
cg@2958
   409
                dllRelativeDestPathes := dllRelativeDestPathes copyWith:'GLXWorkstation.so'.
sv@2723
   410
            ].
cg@2644
   411
        ].
cg@2911
   412
        dllRelativeSourcePathes with:dllRelativeDestPathes do:[:dllRelativeSourcePath :dllRelativeDestPath|
cg@2896
   413
            |source dest|
cg@2896
   414
cg@2911
   415
            source := dllSourceDir / dllRelativeSourcePath.
cg@2958
   416
            source exists ifFalse:[
cg@2958
   417
                self activityNotification:'   skip missing file: ',source pathName.
cg@2958
   418
            ] ifTrue:[
cg@2958
   419
                dest := packageTargetDir / dllRelativeDestPath.
cg@2958
   420
                (dest exists not
cg@2958
   421
                 or:[source fileSize ~= dest fileSize
cg@2958
   422
                 or:[source modificationTime >= dest modificationTime
cg@2958
   423
                 "/ or:[ ((dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath)) not ]
cg@2958
   424
                ]]) ifTrue:[
cg@2958
   425
                    Transcript showCR:'updating ',dllRelativeDestPath.
cg@2958
   426
                    dest directory recursiveMakeDirectory.
cg@2958
   427
                    source copyTo:dest.    
cg@2958
   428
                ].
cg@2958
   429
            ]
sv@2723
   430
        ].
cg@2614
   431
    ].
cg@2896
   432
cg@2921
   433
    "Modified: / 06-09-2012 / 16:19:29 / cg"
cg@2600
   434
!
cg@2600
   435
cg@2644
   436
copyDirectory:relativepath
cg@2644
   437
    "/ need rules in stx
cg@2644
   438
    ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
cg@2644
   439
        recursiveCopyTo:(buildDirectory construct:'stx').
cg@2596
   440
!
cg@2596
   441
cg@2644
   442
copyDirectoryForBuild:subdir
cg@2644
   443
    |targetDir targetFile|
cg@2644
   444
cg@2644
   445
    targetDir := buildDirectory / 'stx' / subdir.
cg@2644
   446
    targetDir exists ifFalse:[
cg@2644
   447
        targetDir makeDirectory.
cg@2964
   448
    ] ifTrue:[
cg@2964
   449
        self isQuickBuild ifTrue:[^ self]
cg@2644
   450
    ].
cg@2644
   451
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
cg@2644
   452
        eachFile isDirectory ifFalse:[
cg@2644
   453
            targetFile := targetDir / eachFile baseName.
cg@2644
   454
            (targetFile exists not
cg@2644
   455
            or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
cg@2644
   456
                self activityNotification:'copying ',eachFile pathName,'...'.
cg@2644
   457
                eachFile copyTo:(targetDir construct:eachFile baseName)
cg@2644
   458
            ]
cg@2644
   459
        ].
cg@2644
   460
    ].
cg@2644
   461
    self activityNotification:nil
cg@2598
   462
!
cg@2598
   463
cg@2644
   464
copyResourcesForPackage:aPackage
cg@2644
   465
    |module directory|
cg@2644
   466
cg@2644
   467
    module := aPackage asPackageId module.
cg@2644
   468
    directory := aPackage asPackageId directory.
cg@2644
   469
cg@2644
   470
    (myTopDirectory / module / directory / 'resources' ) exists ifTrue:[
cg@2644
   471
        (myTopDirectory / module / directory / 'resources' )
cg@2644
   472
            recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   473
    ].
cg@2644
   474
    (myTopDirectory / module / directory / 'styles' ) exists ifTrue:[
cg@2644
   475
        (myTopDirectory / module / directory / 'styles' )
cg@2644
   476
            recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   477
    ].
cg@2600
   478
!
cg@2600
   479
cg@2644
   480
copySTCDirectoryForBuild
cg@2912
   481
    "copy stc files to the build directory"
cg@2912
   482
cg@2644
   483
    |targetDir stc files|
cg@2644
   484
cg@2644
   485
    targetDir := buildDirectory / 'stx' / 'stc'.
cg@2644
   486
    targetDir exists ifFalse:[ targetDir makeDirectory ].
cg@2644
   487
cg@2644
   488
    stc := OperatingSystem isMSWINDOWSlike 
cg@2644
   489
                ifTrue:[ 'stc.exe' ]
cg@2644
   490
                ifFalse:[ 'stc' ].
cg@2644
   491
cg@2644
   492
    files := #( ) copyWith:stc.
cg@2644
   493
cg@2644
   494
    files do:[:eachFile |
cg@2644
   495
        |sourceFile targetFile|
cg@2644
   496
cg@2644
   497
        sourceFile := mySTXTopDirectory / 'stc' / eachFile.
cg@2644
   498
        targetFile := targetDir / eachFile.
cg@2644
   499
        (targetFile exists not
cg@2644
   500
        or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
cg@2644
   501
            self activityNotification:'copying ',sourceFile pathName,'...'.
cg@2644
   502
            sourceFile copyTo:targetFile
cg@2644
   503
        ].
cg@2644
   504
    ].
sr@2683
   505
sr@2683
   506
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
   507
        (targetDir / 'stc') makeExecutableForAll    
sr@2683
   508
    ].
sr@2683
   509
cg@2644
   510
    self activityNotification:nil
cg@2912
   511
cg@2912
   512
    "Modified (comment): / 04-09-2012 / 00:49:19 / cg"
cg@2599
   513
!
cg@2599
   514
cg@2644
   515
copyStartupFilesFromSmalltalk
cg@2912
   516
    "copy additional smalltalk startup files to the build directory"
cg@2912
   517
cg@2644
   518
    (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
cg@2644
   519
        (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
cg@2644
   520
    ].
cg@2644
   521
cg@2678
   522
    #( 
cg@2678
   523
        'keyboard.rc' 
cg@2678
   524
        'keyboardMacros.rc' 
cg@2678
   525
        'display.rc' 
cg@2678
   526
        'd_win32.rc'
cg@2678
   527
        'host.rc' 
cg@2678
   528
        'h_win32.rc'  
cg@2678
   529
        'smalltalk.rc'  
cg@2678
   530
        'private.rc'  
cg@2644
   531
    ) do:[:fn |
cg@2644
   532
        (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2644
   533
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2678
   534
    ].
cg@2678
   535
cg@2678
   536
    (myTopDirectory / 'stx' / 'doc/online/english/LICENCE_STX.html')
cg@2678
   537
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / 'LICENCE_STX.html').
cg@2912
   538
cg@2912
   539
    "Modified (comment): / 04-09-2012 / 00:48:47 / cg"
cg@2912
   540
!
cg@2912
   541
cg@2912
   542
copySupportFilesForCompilation
cg@2912
   543
    "copy the tcc compiler to the build directory"
cg@2912
   544
cg@2912
   545
    |files|
cg@2912
   546
cg@2912
   547
    files := #().
cg@2912
   548
cg@2912
   549
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2964
   550
        files := files , #( 'librun/genDate.com' ).
cg@2912
   551
        usedCompiler = 'tcc' ifTrue:[
cg@2912
   552
            files := files , #( 
cg@2912
   553
                        'support/tcc'
cg@2912
   554
                    ).
cg@2912
   555
        ].
cg@2912
   556
    ] ifFalse:[
cg@2964
   557
        files := files , #( 'librun/genDate' ).
cg@2912
   558
    ].
cg@2912
   559
cg@2912
   560
    files do:[:relativePath |
cg@2912
   561
        (mySTXTopDirectory / relativePath) exists ifTrue:[
cg@2912
   562
            ((buildDirectory / 'stx' / relativePath) exists
cg@2912
   563
            and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
cg@2912
   564
            and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
cg@2912
   565
            "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
cg@2912
   566
            ]]) ifFalse:[
cg@2912
   567
                (mySTXTopDirectory / relativePath) recursiveCopyTo:(buildDirectory / 'stx' / relativePath).    
cg@2912
   568
            ]
cg@2912
   569
        ] ifFalse:[
cg@2912
   570
            self error:'Missing directory: ',relativePath printString mayProceed:true.
cg@2912
   571
        ].
cg@2912
   572
    ].
cg@2912
   573
cg@2912
   574
    "Created: / 04-09-2012 / 00:47:49 / cg"
cg@2600
   575
!
cg@2600
   576
cg@2644
   577
copySupportFilesForLinkage
cg@2912
   578
    "copy additional files which are req'd for linkage to the build directory"
cg@2912
   579
cg@2644
   580
    |files|
cg@2644
   581
cg@2644
   582
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2644
   583
        files := #( 
cg@2969
   584
                    'librun/genDate.com'
cg@2644
   585
                    'librun/main.c'
cg@2673
   586
                    'projects/smalltalk/stx_16x16.ico'
cg@2673
   587
                    'projects/smalltalk/stx_32x32.ico'
cg@2673
   588
                    'projects/smalltalk/stx_splash.bmp'
cg@2644
   589
                 ).
cg@2905
   590
cg@2905
   591
        usedCompiler = 'bcc' ifTrue:[
cg@2905
   592
            files := files , #( 
cg@2905
   593
                        'librun/objbc/librun.dll'
cg@2905
   594
                        'support/win32/borland/cs3245.dll' 
cg@2905
   595
                        'support/win32/X11.dll'
cg@2905
   596
                        'support/win32/Xext.dll'
cg@2916
   597
                        'lib/bc/librun.lib'
cg@2916
   598
                        'lib/bc/cs32i.lib'
cg@2905
   599
                    ).
cg@2905
   600
        ].
cg@2905
   601
        usedCompiler = 'vc' ifTrue:[
cg@2905
   602
            files := files , #( 
cg@2905
   603
                        'librun/objvc/librun.dll'
cg@2916
   604
                        'lib/vc/librun.lib'
cg@2905
   605
                    ).
cg@2905
   606
        ].
cg@2911
   607
        usedCompiler = 'tcc' ifTrue:[
cg@2911
   608
            files := files , #( 
cg@2916
   609
                        'librun/objvc/librun.dll'   "/ linkage is against vc version!!
cg@2916
   610
                        'lib/vc/librun.lib'
cg@2916
   611
                    ).
cg@2916
   612
        ].
cg@2916
   613
        usedCompiler = 'lcc' ifTrue:[
cg@2916
   614
            files := files , #( 
cg@2916
   615
                        'librun/objvc/librun.dll'   "/ linkage is against vc version!!
cg@2916
   616
                        'lib/vc/librun.lib'
cg@2911
   617
                    ).
cg@2911
   618
        ].
cg@2918
   619
        usedCompiler = 'mingw' ifTrue:[
cg@2918
   620
            files := files , #( 
cg@2972
   621
                        'librun/objmingw/librun.dll'   "/ linkage is against vc version!!
cg@2972
   622
                        'lib/mingw/librun.lib'
cg@2918
   623
                    ).
cg@2918
   624
        ].
cg@2644
   625
    ] ifFalse:[
cg@2644
   626
        files := #(
cg@2644
   627
                    'librun/main.c'
cg@2644
   628
                    'librun/librun.so'
cg@2644
   629
                )
cg@2644
   630
    ].
cg@2677
   631
    files := files asOrderedCollection.
cg@2677
   632
cg@2677
   633
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2677
   634
        projectDefinitionClass applicationIconFileName notNil ifTrue:[
cg@2678
   635
            files add:('projects/smalltalk/',projectDefinitionClass applicationIconFileName,'.ico')
cg@2678
   636
        ].
cg@2678
   637
        projectDefinitionClass splashFileName notNil ifTrue:[
cg@2678
   638
            files add:('projects/smalltalk/',projectDefinitionClass splashFileName,'.bmp')
cg@2678
   639
        ].
cg@2677
   640
    ].
cg@2644
   641
cg@2914
   642
    files do:[:relativePath |
cg@2914
   643
        (mySTXTopDirectory / relativePath) exists ifTrue:[
cg@2914
   644
            ((buildDirectory / 'stx' / relativePath) exists
cg@2914
   645
            and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
cg@2914
   646
            and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
sr@2684
   647
            "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
sr@2684
   648
            ]]) ifFalse:[
cg@2914
   649
                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2914
   650
                (mySTXTopDirectory / relativePath) copyTo:(buildDirectory / 'stx' / relativePath).    
sr@2684
   651
            ]
sr@2684
   652
        ] ifFalse:[
cg@2971
   653
"/ does not really help: objbc/librun.lib does not work with MSVC and vice versa...
cg@2971
   654
"/            ((relativePath = 'librun/objvc/librun.dll')
cg@2971
   655
"/            and:[ (mySTXTopDirectory / 'librun/objbc/librun.dll') exists ])ifTrue:[
cg@2971
   656
"/                stdErr nextPutLine:('Warning: using alternative librun from objbc (Borland version)...'). 
cg@2971
   657
"/                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2971
   658
"/                (mySTXTopDirectory / 'librun/objbc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).    
cg@2971
   659
"/            ] ifFalse:[
cg@2971
   660
"/                ((relativePath = 'librun/objbc/librun.dll')
cg@2971
   661
"/                and:[ (mySTXTopDirectory / 'librun/objvc/librun.dll') exists ])ifTrue:[
cg@2971
   662
"/                    stdErr nextPutLine:('Warning: using alternative librun from objvc (MSVC version)...'). 
cg@2971
   663
"/                    (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2971
   664
"/                    (mySTXTopDirectory / 'librun/objvc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).    
cg@2971
   665
"/                ] ifFalse:[
cg@2971
   666
                    self error:'Missing file: ',relativePath printString mayProceed:true.
cg@2971
   667
"/                ]
cg@2971
   668
"/            ]
sr@2684
   669
        ].
cg@2644
   670
    ].
cg@2873
   671
cg@2918
   672
    "Modified: / 05-09-2012 / 16:26:25 / cg"
cg@2600
   673
!
cg@2600
   674
cg@2644
   675
createHeaderFileFor:aClass in:packageTargetDir
cg@2644
   676
    |instVarList classInstVarList classVarList bindings superclassFilename
cg@2644
   677
     template file newContents oldContents|
cg@2644
   678
cg@2644
   679
    instVarList := StringCollection new.
cg@2644
   680
    aClass instVarNames do:[:v |
cg@2644
   681
        instVarList add:('OBJ %1;' bindWith:v)
cg@2644
   682
    ].
cg@2644
   683
    classInstVarList := StringCollection new.
cg@2644
   684
    aClass class instVarNames do:[:v |
cg@2961
   685
    "/ (v includes:$_) ifTrue:[self halt].
cg@2644
   686
        classInstVarList add:('OBJ %1;' bindWith:v)
cg@2644
   687
    ].
cg@2644
   688
    classVarList := StringCollection new.
cg@2644
   689
    aClass classVarNames do:[:v |
cg@2644
   690
        classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
cg@2644
   691
    ].
cg@2644
   692
cg@2644
   693
    bindings := Dictionary new.
cg@2644
   694
    bindings at:'ClassName' put:aClass name. 
cg@2644
   695
    aClass superclass isNil ifTrue:[
cg@2644
   696
        bindings at:'SuperclassName' put:'-'. 
cg@2852
   697
        bindings at:'SuperclassFileInclude' put:''.
cg@2644
   698
    ] ifFalse:[
cg@2644
   699
        bindings at:'SuperclassName' put:aClass superclass name. 
cg@2644
   700
        bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
cg@2644
   701
        bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
cg@2644
   702
    ].
cg@2644
   703
    bindings at:'InstVarList' put:instVarList asString. 
cg@2644
   704
    bindings at:'ClassVarList' put:classVarList asString. 
cg@2644
   705
    bindings at:'ClassInstVarList' put:classInstVarList asString. 
cg@2644
   706
cg@2644
   707
    template := 
cg@2644
   708
'/* This file was generated by ProjectBuilder. */
cg@2644
   709
/* !!!!!!!! Do not change by hand !!!!!!!! */
cg@2644
   710
cg@2644
   711
/* Class: %(ClassName) */
cg@2644
   712
/* Superclass: %(SuperclassName) */
cg@2644
   713
cg@2644
   714
%(SuperclassFileInclude)
cg@2644
   715
cg@2644
   716
/* INDIRECTGLOBALS */
cg@2644
   717
#ifdef _HEADER_INST_
cg@2644
   718
%(InstVarList)
cg@2644
   719
#endif /* _HEADER_INST_ */
cg@2644
   720
cg@2644
   721
#ifdef _HEADER_CLASS_
cg@2644
   722
%(ClassVarList)
cg@2644
   723
#endif /* _HEADER_CLASS_ */
cg@2644
   724
cg@2644
   725
#ifdef _HEADER_CLASSINST_
cg@2644
   726
%(ClassInstVarList)
cg@2644
   727
#endif /* _HEADER_CLASSINST_ */
cg@2644
   728
'.
cg@2644
   729
    newContents := template bindWithArguments:bindings.
sr@2683
   730
    file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
cg@2644
   731
    (file exists not
cg@2644
   732
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2644
   733
        file contents: newContents.
cg@2644
   734
    ].
cg@2852
   735
cg@2852
   736
    "Modified: / 15-08-2011 / 14:58:46 / cg"
cg@2596
   737
!
cg@2596
   738
cg@2644
   739
generateSourceFiles
cg@2964
   740
    (self isLocalBuild not and:[ sourceCodeManager notNil ])  ifTrue:[
cg@2644
   741
        "/ check out / generate files there
cg@2644
   742
        self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2644
   743
    ] ifFalse:[
cg@2644
   744
        "/ local build
cg@2644
   745
        "/ fileout the project
cg@2644
   746
        self generateSourceFilesByFilingOut
cg@2644
   747
    ]
cg@2596
   748
!
cg@2596
   749
cg@2644
   750
generateSourceFilesByCheckingOutUsing:aSourceCodeManager
cg@2644
   751
    "/ will no longer be needed/supported
cg@2644
   752
cg@2644
   753
    |repository stxRepository module directory|
cg@2644
   754
cg@2868
   755
    self breakPoint:#cg.
cg@2868
   756
cg@2644
   757
    "/ check out / generate files there
cg@2644
   758
    repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
cg@2644
   759
    stxRepository := aSourceCodeManager repositoryName.
cg@2644
   760
cg@2644
   761
    (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   762
        (module ~= 'stx') ifTrue:[
cg@2644
   763
            OperatingSystem
cg@2644
   764
                executeCommand:('cvs -d ',stxRepository,' co stx')
cg@2644
   765
                inputFrom:nil
cg@2644
   766
                outputTo:Transcript
cg@2644
   767
                errorTo:Transcript
cg@2644
   768
                inDirectory:buildDirectory
cg@2644
   769
                onError:[:status| self error:'cvs update stx failed'].
cg@2644
   770
        ].
cg@2644
   771
    ].
cg@2644
   772
cg@2644
   773
    ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
cg@2644
   774
        OperatingSystem
cg@2644
   775
            executeCommand:('cvs -d ',repository,' co -l ',directory)
cg@2644
   776
            inputFrom:nil
cg@2644
   777
            outputTo:Transcript
cg@2644
   778
            errorTo:Transcript
cg@2644
   779
            inDirectory:buildDirectory
cg@2644
   780
            onError:[:status| self error:'cvs update failed'].
cg@2644
   781
    ].
cg@2644
   782
    OperatingSystem
cg@2644
   783
        executeCommand:'cvs upd -d'
cg@2644
   784
        inputFrom:nil
cg@2644
   785
        outputTo:Transcript
cg@2644
   786
        errorTo:Transcript
cg@2644
   787
        inDirectory:(buildDirectory construct:module)
cg@2644
   788
        onError:[:status| self error:'cvs update failed'].
cg@2644
   789
self halt.
cg@2868
   790
cg@2868
   791
    "Modified: / 29-12-2011 / 14:02:56 / cg"
cg@2596
   792
!
cg@2596
   793
cg@2644
   794
generateSourceFilesByFilingOut
cg@2644
   795
    "/ local build
cg@2644
   796
    "/ fileout the project
cg@2644
   797
sv@2844
   798
    |fullPathName|
sv@2844
   799
cg@2644
   800
    (package module ~= 'stx') ifTrue:[
cg@2644
   801
        (buildDirectory / package module) makeDirectory.
cg@2644
   802
    ].
cg@2644
   803
cg@2644
   804
    "/ file out the package(s) which are to be built
cg@2644
   805
    ((Array with:package))
cg@2644
   806
    do:[:eachPackageToFileout |
cg@2644
   807
        |packageId packageModule packageDirectory packageTargetDir packageDef|
cg@2644
   808
cg@2644
   809
        packageId := eachPackageToFileout asPackageId.
cg@2644
   810
        packageModule := packageId module.
cg@2644
   811
        packageDirectory := packageId directory.
cg@2644
   812
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   813
cg@2644
   814
        packageDef := packageId projectDefinitionClass.
cg@2644
   815
        (packageDef compiled_classNames_common ,
cg@2644
   816
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   817
            |cls fileName newSource|
cg@2644
   818
cg@2644
   819
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   820
            self assert:cls isLoaded.
cg@2644
   821
            fileName := (Smalltalk fileNameForClass:cls),'.st'.
cg@2644
   822
            fileName := packageTargetDir asFilename construct:fileName.
cg@2644
   823
            fileName exists ifTrue:[
cg@2644
   824
                newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
cg@2644
   825
                newSource = fileName contentsAsString ifFalse:[
cg@2644
   826
                    fileName contents:newSource
cg@2644
   827
                ].
cg@2644
   828
            ] ifFalse:[
cg@2644
   829
                cls fileOutIn:packageTargetDir withTimeStamp:false
cg@2644
   830
            ].
cg@2644
   831
        ].
cg@2644
   832
cg@2644
   833
"/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
cg@2644
   834
"/            cls isPrivate ifFalse:[
cg@2644
   835
"/                cls isLoaded ifFalse:[
cg@2644
   836
"/                    self halt.
cg@2644
   837
"/                    cls autoload.
cg@2644
   838
"/                ].
cg@2644
   839
"/                cls fileOutIn:packageTargetDir
cg@2644
   840
"/            ]
cg@2644
   841
"/        ].
cg@2644
   842
cg@2644
   843
        projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
sv@2844
   844
            fullPathName := packageTargetDir construct:fileName.
sv@2844
   845
            fullPathName directory exists ifFalse:[
sv@2844
   846
                "take care for files like 'autopackage/default.apspec'"
sv@2844
   847
                fullPathName directory makeDirectory.
sv@2844
   848
            ].
sv@2844
   849
            (fullPathName exists
sv@2844
   850
             and:[ fullPathName contents = fileContents ]) ifFalse:[
sv@2844
   851
                fullPathName contents:fileContents.
cg@2644
   852
            ].
cg@2644
   853
        ].    
cg@2644
   854
    ].
cg@2972
   855
    self makeQuick ifFalse:[
cg@2972
   856
        "/ generate header files in prerequisite packages...
cg@2972
   857
        (projectDefinitionClass allPreRequisites)
cg@2972
   858
        do:[:eachPackageToFileout |
cg@2972
   859
            |packageId packageDef packageModule packageDirectory packageTargetDir|
cg@2644
   860
cg@2972
   861
            packageId := eachPackageToFileout asPackageId.
cg@2972
   862
            packageModule := packageId module.
cg@2972
   863
            packageDirectory := packageId directory.
cg@2972
   864
            packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   865
cg@2972
   866
            packageDef := packageId projectDefinitionClass.
cg@2972
   867
            (packageDef compiled_classNames_common ,
cg@2972
   868
            packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2972
   869
                |cls|
cg@2644
   870
cg@2972
   871
                cls := Smalltalk classNamed:eachClassName.
cg@2972
   872
                "/ self assert:cls isLoaded.
cg@2972
   873
                cls isNil ifTrue:[
cg@2972
   874
                    stdErr nextPutLine:('Missing class: ',eachClassName, ' (not present in system. Warning only:subclasses of it will not be compiled)').
cg@2972
   875
                ] ifFalse:[
cg@2972
   876
                    cls isLoaded ifTrue:[    
cg@2972
   877
                        self createHeaderFileFor:cls in:packageTargetDir
cg@2972
   878
                    ]
cg@2972
   879
                ].
cg@2644
   880
            ].
cg@2972
   881
            self copyResourcesForPackage:eachPackageToFileout.
cg@2644
   882
        ].
cg@2644
   883
    ].
cg@2644
   884
cg@2644
   885
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   886
!
cg@2596
   887
cg@2909
   888
makeCommandOfCompiler:usedCompiler
cg@2909
   889
    usedCompiler = 'bcc' ifTrue:[ 
cg@2909
   890
        ^ 'bmake'.
cg@2909
   891
    ].
cg@2909
   892
    usedCompiler = 'vc' ifTrue:[ 
cg@2909
   893
        ^ 'vcmake'. "/ compilerFlag := '-DUSEVC' 
cg@2909
   894
    ].
cg@2909
   895
    usedCompiler = 'lcc' ifTrue:[ 
cg@2909
   896
        ^ 'lccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   897
    ].
cg@2909
   898
    usedCompiler = 'tcc' ifTrue:[ 
cg@2909
   899
        ^ 'tccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   900
    ].
cg@2909
   901
    usedCompiler = 'gcc' ifTrue:[ 
cg@2921
   902
        ^ 'make'.       "/ compilerFlag := '-DUSEGCC' 
cg@2909
   903
    ].
cg@2918
   904
    usedCompiler = 'mingw' ifTrue:[ 
cg@2921
   905
        ^ 'mingwmake'.  "/ compilerFlag := '-DUSEMINGW' 
cg@2909
   906
    ].
cg@2909
   907
    self error:'unknown compiler specified'.
cg@2909
   908
cg@2909
   909
    "Created: / 03-09-2012 / 19:46:07 / cg"
cg@2909
   910
!
cg@2909
   911
cg@2644
   912
makeWithOutputTo:stdOut errorTo:stdErr
cg@2909
   913
    |module directory makeCommand|
cg@2644
   914
cg@2644
   915
    module := package module.
cg@2644
   916
    directory := package directory.
cg@2644
   917
cg@2680
   918
    makeCommand := ParserFlags makeCommand.
cg@2895
   919
    usedCompiler isNil ifTrue:[
cg@2895
   920
        usedCompiler := ParserFlags usedCompiler.
cg@2895
   921
    ].
cg@2909
   922
    makeCommand := self makeCommandOfCompiler:usedCompiler.
cg@2873
   923
cg@2852
   924
    "/ makeCommand := makeCommand, ' TOP=', mySTXTopDirectory pathName.
cg@2680
   925
sr@2683
   926
    OperatingSystem isUNIXlike ifTrue:[
cg@2921
   927
        "/ generate the makefile first
cg@2969
   928
        self activityNotification:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName).
sr@2683
   929
        OperatingSystem
sv@2845
   930
            executeCommand:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName)
sr@2683
   931
            inputFrom:nil
sr@2683
   932
            outputTo:stdOut
sr@2683
   933
            errorTo:stdErr
sr@2683
   934
            inDirectory:(buildDirectory / module / directory)
cg@2921
   935
            onError:[:status | self error:'make failed'].
sr@2683
   936
    ].
sr@2683
   937
cg@2644
   938
    projectDefinitionClass isLibraryDefinition ifTrue:[
cg@2921
   939
        "/ generate the library
cg@2969
   940
        self activityNotification:(makeCommand,' classLibRule').
cg@2644
   941
        OperatingSystem
cg@2680
   942
            executeCommand:(makeCommand,' classLibRule')
cg@2644
   943
            inputFrom:nil
cg@2644
   944
            outputTo:stdOut
cg@2644
   945
            errorTo:stdErr
cg@2644
   946
            inDirectory:(buildDirectory / module / directory)
cg@2921
   947
            onError:[:status | self error:'make failed'].
cg@2644
   948
    ] ifFalse:[
cg@2972
   949
        (self makeExeOnly) ifTrue:[
cg@2969
   950
            self activityNotification:(makeCommand,' exe').
cg@2969
   951
            OperatingSystem
cg@2969
   952
                "/ generate the executable
cg@2969
   953
                executeCommand:(makeCommand,' exe')
cg@2969
   954
                inputFrom:nil
cg@2969
   955
                outputTo:stdOut
cg@2969
   956
                errorTo:stdErr
cg@2969
   957
                inDirectory:(buildDirectory / module / directory)
cg@2969
   958
                onError:[:status | self error:'make failed'].
cg@2644
   959
cg@2969
   960
        ] ifFalse:[
cg@2921
   961
            "/ generate the self-installable package
cg@2969
   962
            self activityNotification:(makeCommand,' ALL_NP').
cg@2673
   963
            OperatingSystem
cg@2969
   964
                executeCommand:(makeCommand,' ALL_NP')
cg@2673
   965
                inputFrom:nil
cg@2673
   966
                outputTo:stdOut
cg@2673
   967
                errorTo:stdErr
cg@2673
   968
                inDirectory:(buildDirectory / module / directory)
cg@2921
   969
                onError:[:status | self error:'make failed'].
cg@2673
   970
        ]
cg@2644
   971
    ]
cg@2793
   972
cg@2909
   973
    "Modified: / 03-09-2012 / 19:47:15 / cg"
cg@2921
   974
    "Modified (comment): / 06-09-2012 / 16:22:38 / cg"
cg@2611
   975
!
cg@2611
   976
cg@2905
   977
objDirForUsedCompiler
cg@2909
   978
    ^ self objDirForUsedCompiler:usedCompiler
cg@2909
   979
cg@2909
   980
    "Created: / 20-08-2012 / 17:01:13 / cg"
cg@2909
   981
!
cg@2909
   982
cg@2909
   983
objDirForUsedCompiler:usedCompiler
cg@2918
   984
    usedCompiler = 'gcc' ifTrue:[^ 'obj'].      "/ unix case
cg@2918
   985
cg@2905
   986
    usedCompiler = 'bcc' ifTrue:[^ 'objbc'].
cg@2905
   987
    usedCompiler = 'vc' ifTrue:[^ 'objvc'].
cg@2909
   988
    usedCompiler = 'tcc' ifTrue:[^ 'objtcc'].
cg@2909
   989
    usedCompiler = 'lcc' ifTrue:[^ 'objlcc'].
cg@2918
   990
    usedCompiler = 'mingw' ifTrue:[^ 'objmingw'].
cg@2961
   991
    self halt:'please add compiler here'.
cg@2905
   992
    ^ 'objbc'
cg@2905
   993
cg@2909
   994
    "Created: / 03-09-2012 / 19:55:34 / cg"
cg@2905
   995
!
cg@2905
   996
sr@2683
   997
recursiveCopyDirectoryForBuild:subdir
sr@2683
   998
    |targetDir|
sr@2683
   999
sr@2683
  1000
    targetDir := buildDirectory / 'stx' / subdir.
sr@2683
  1001
    targetDir exists ifFalse:[
sr@2683
  1002
        targetDir makeDirectory.
sr@2683
  1003
    ].
sr@2683
  1004
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
sr@2683
  1005
        eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
sr@2683
  1006
    ].
sr@2683
  1007
    self activityNotification:nil
sr@2683
  1008
!
sr@2683
  1009
cg@2644
  1010
setupBuildDirectory
cg@2644
  1011
    buildDirectory exists ifFalse:[
cg@2644
  1012
        buildDirectory recursiveMakeDirectory.
cg@2644
  1013
    ].
cg@2644
  1014
    (buildDirectory / 'stx') exists ifFalse:[
cg@2644
  1015
        (buildDirectory / 'stx') makeDirectory.
cg@2644
  1016
    ].
cg@2644
  1017
cg@2644
  1018
    self copyDirectoryForBuild:'include'.
cg@2644
  1019
    self copyDirectoryForBuild:'rules'.
sr@2683
  1020
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
  1021
        self recursiveCopyDirectoryForBuild:'configurations'.
sr@2683
  1022
    ]
cg@2635
  1023
!
cg@2596
  1024
cg@2644
  1025
validateBuildDirectoryIsPresent
cg@2644
  1026
cg@2644
  1027
    ^ self.
cg@2644
  1028
cg@2644
  1029
"/    [
cg@2644
  1030
"/        |default directoryIsOKForMe stc |
cg@2644
  1031
"/
cg@2644
  1032
"/        default := (buildDirectory ?
cg@2644
  1033
"/                          PreviousBuildDirectory)
cg@2644
  1034
"/                          ifNil:[ UserPreferences current buildDirectory].
cg@2644
  1035
"/
cg@2644
  1036
"/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
cg@2644
  1037
"/                                 default:default.
cg@2644
  1038
"/
cg@2644
  1039
"/        buildDirectory isEmptyOrNil ifTrue:[^ self].
cg@2644
  1040
"/        buildDirectory := buildDirectory asFilename.
cg@2644
  1041
"/        directoryIsOKForMe := true.
cg@2644
  1042
"/
cg@2644
  1043
"/        buildDirectory exists ifFalse:[
cg@2644
  1044
"/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
cg@2644
  1045
"/            directoryIsOKForMe := false.
cg@2644
  1046
"/        ] ifTrue:[
cg@2644
  1047
"/            (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
  1048
"/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
cg@2644
  1049
"/                directoryIsOKForMe := false.
cg@2644
  1050
"/            ] ifTrue:[
cg@2644
  1051
"/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
cg@2644
  1052
"/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
cg@2644
  1053
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
cg@2644
  1054
"/                    directoryIsOKForMe := false.
cg@2644
  1055
"/                ].
cg@2644
  1056
"/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
cg@2644
  1057
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
cg@2644
  1058
"/                    directoryIsOKForMe := false.
cg@2644
  1059
"/                ].
cg@2644
  1060
"/            ]
cg@2644
  1061
"/        ].
cg@2644
  1062
"/        directoryIsOKForMe
cg@2644
  1063
"/    ] whileFalse
cg@2596
  1064
! !
cg@2596
  1065
cg@2596
  1066
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
  1067
cg@2896
  1068
version
cg@2896
  1069
    ^ '$Header$'
cg@2896
  1070
!
cg@2896
  1071
cg@2596
  1072
version_CVS
cg@2596
  1073
    ^ '$Header$'
cg@2596
  1074
! !
cg@2958
  1075