ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Sun, 05 May 2013 17:10:26 +0200
changeset 3001 2d990fdb6496
parent 2989 fce70ea7d5d7
child 3006 741e3e2f0270
permissions -rw-r--r--
class: Tools::ProjectBuilder
comment/format in: #buildWithColorizedOutputTo:
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@2921
   240
                            makeOutput
cg@2921
   241
                                withEmphasis:{#backgroundColor->Color red. #color->Color white.}
cg@2921
   242
                                do:[makeOutput nextPutAll:string].
cg@2644
   243
                        ]
cg@2644
   244
                    ].
cg@2644
   245
    stdOut := ActorStream new
cg@2644
   246
                    nextPutBlock:[:char |
cg@2644
   247
                        lock critical:[
cg@2644
   248
                            makeOutput nextPut:char.
cg@2644
   249
                        ]
cg@2644
   250
                    ];
sr@2683
   251
                    nextPutAllBlock:[:string |
cg@2873
   252
                        lock critical:[         
sr@2683
   253
                            makeOutput nextPutAll:string.
cg@2644
   254
                        ]
cg@2644
   255
                    ].
cg@2635
   256
cg@2644
   257
    self buildWithOutputTo:stdOut errorTo:stdErr.
cg@2873
   258
cg@2921
   259
    "Modified: / 06-09-2012 / 16:15:50 / cg"
cg@2611
   260
!
cg@2611
   261
cg@2969
   262
buildWithOutputTo:stdOutArg errorTo:stdErrArg
cg@2611
   263
    "/ intermediate - this will move into a commonly used utility class
cg@2611
   264
    "/ (where all the project code support will be collected).
cg@2611
   265
cg@2596
   266
    |module directory|
cg@2596
   267
cg@2596
   268
    projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
cg@2596
   269
    projectDefinitionClass isNil ifTrue:[
cg@2596
   270
        self error:('Missing ProjectDefinition class for "',package asString,'"')
cg@2596
   271
    ].
cg@2596
   272
cg@2596
   273
    "/ ensure that everything is loaded...
cg@2596
   274
    projectDefinitionClass loadAsAutoloaded:false.
cg@2596
   275
    projectDefinitionClass loadExtensions.
cg@2596
   276
    projectDefinitionClass loadAllClassesAsAutoloaded:false.
cg@2596
   277
cg@2596
   278
    module := package module.
cg@2596
   279
    directory := package directory.
cg@2596
   280
cg@2596
   281
    buildDirectory isNil ifTrue:[
cg@2634
   282
        buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
cg@2634
   283
        buildDirectory isNil ifTrue:[
cg@2634
   284
            buildDirectory := Filename tempDirectory construct:'stx_build'.
cg@2634
   285
        ].
cg@2596
   286
    ].
cg@2596
   287
    buildDirectory := buildDirectory asFilename.
cg@2596
   288
cg@2596
   289
    "/ self validateBuildDirectoryIsPresent.
cg@2596
   290
cg@2596
   291
    PreviousBuildDirectory := buildDirectory.
cg@2596
   292
cg@2596
   293
    "/ UserPreferences current localBuild:true
cg@2964
   294
    (self isLocalBuild or:[UserPreferences current localBuild]) ifFalse:[
cg@2596
   295
        SourceCodeManager notNil ifTrue:[
sv@2861
   296
            sourceCodeManager := SourceCodeManagerUtilities default sourceCodeManagerFor:projectDefinitionClass.
cg@2596
   297
        ]
cg@2596
   298
    ].
cg@2596
   299
    sourceCodeManager := nil.
cg@2596
   300
cg@2598
   301
    myTopDirectory := 
cg@2596
   302
        Smalltalk packagePath 
cg@2596
   303
            detect:[:aPath |
cg@2596
   304
                (aPath asFilename / 'stx' / 'include') exists
cg@2596
   305
                and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
cg@2596
   306
            ifNone:nil.       
cg@2598
   307
    myTopDirectory isNil ifTrue:[
cg@2598
   308
        self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
cg@2596
   309
    ].
cg@2598
   310
    myTopDirectory := myTopDirectory asFilename.
cg@2598
   311
    mySTXTopDirectory := myTopDirectory / 'stx'.
cg@2613
   312
cg@2972
   313
    self makeQuick ifFalse:[
cg@2972
   314
        self setupBuildDirectory.
cg@2972
   315
        self activityNotification:'Generating stc directory...'.
cg@2972
   316
        self copySTCDirectoryForBuild.
cg@2972
   317
    ].
cg@2628
   318
    self activityNotification:'Generating source files...'.
cg@2596
   319
    self generateSourceFiles.
cg@2972
   320
    self makeQuick ifFalse:[
cg@2972
   321
        self activityNotification:'Copying dlls for linkage...'.
cg@2972
   322
        self copyDLLsForLinkage.
cg@2972
   323
        self activityNotification:'Copying support files for compilation and linkage...'.
cg@2972
   324
        self copySupportFilesForCompilation.
cg@2972
   325
        self copySupportFilesForLinkage.
cg@2972
   326
        self copyStartupFilesFromSmalltalk.
cg@2972
   327
    ].
cg@2628
   328
    self activityNotification:'Executing make...'.
cg@2611
   329
    self makeWithOutputTo:stdOut errorTo:stdErr.
cg@2912
   330
cg@2912
   331
    "Modified: / 04-09-2012 / 00:49:52 / cg"
cg@2898
   332
! !
cg@2898
   333
cg@2898
   334
!ProjectBuilder methodsFor:'building/private'!
cg@2596
   335
cg@2644
   336
copyDLLsForLinkage
cg@2911
   337
    |targetBuildDir preRequisites dllRelativeSourcePathes dllRelativeDestPathes|
sv@2723
   338
cg@2644
   339
    targetBuildDir := buildDirectory / package module / package directory.
cg@2644
   340
sv@2723
   341
    preRequisites := projectDefinitionClass allPreRequisites.
sv@2723
   342
    OperatingSystem isUNIXlike ifTrue:[
sv@2723
   343
        "For now: unix Makefiles require some libs implicitely..."
sv@2723
   344
        preRequisites := preRequisites union:#(
sv@2979
   345
                               #'stx:goodies/refactoryBrowser/parser'
sv@2979
   346
                               #'stx:libtool'
sv@2723
   347
                            ).
sv@2723
   348
    ].
sv@2723
   349
sv@2723
   350
    preRequisites do:[:eachPackageToFileout |
cg@2644
   351
        |packageId packageDef packageModule packageDirectory packageTargetDir
cg@2911
   352
         dllSource dllSourceDir libraryName dllRelativePathSource 
cg@2916
   353
         dllRelativePathDest objDirSource objDirDest alternativeObjDirSource|
cg@2644
   354
cg@2644
   355
        packageId := eachPackageToFileout asPackageId.
cg@2644
   356
        packageModule := packageId module.
cg@2644
   357
        packageDirectory := packageId directory.
cg@2644
   358
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   359
cg@2644
   360
        packageDef := packageId projectDefinitionClass.
cg@2644
   361
        libraryName := packageDef libraryName.
cg@2644
   362
cg@2644
   363
        "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
cg@2644
   364
        dllSourceDir := myTopDirectory / packageModule / packageDirectory.
cg@2909
   365
cg@2644
   366
        OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2911
   367
            objDirDest := self objDirForUsedCompiler:usedCompiler.
cg@2916
   368
            objDirSource := objDirDest.
cg@2916
   369
"/            "/ use visual-c files for tcc linkage
cg@2916
   370
"/            usedCompiler = 'tcc' ifTrue:[
cg@2916
   371
"/                objDirSource := self objDirForUsedCompiler:'vc'.
cg@2916
   372
"/            ] ifFalse:[
cg@2916
   373
"/                objDirSource := objDirDest
cg@2916
   374
"/            ].
cg@2916
   375
            (dllSourceDir / objDirSource / (libraryName, '.dll')) exists ifFalse:[
cg@2916
   376
                alternativeObjDirSource := self objDirForUsedCompiler:'vc'.
cg@2916
   377
                (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
cg@2921
   378
                    objDirSource := alternativeObjDirSource.
cg@2921
   379
                    stdErr nextPutLine:(('Warning: using alternative %1 from %2 (%3 version)...' 
cg@2921
   380
                                                bindWith:libraryName 
cg@2921
   381
                                                with:alternativeObjDirSource 
cg@2921
   382
                                                with:(self class suiteNameOfCompiler:'vc'))
cg@2921
   383
                                            emphasizeAllWith:(#color -> Color red darkened)).
cg@2921
   384
                ] ifFalse:[
cg@2921
   385
                    alternativeObjDirSource := self objDirForUsedCompiler:'bcc'.
cg@2921
   386
                    (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
cg@2921
   387
                        objDirSource := alternativeObjDirSource.
cg@2921
   388
                        stdErr nextPutLine:('Warning: using alternative %1 from %2 (%3 version)...' 
cg@2921
   389
                                    bindWith:libraryName 
cg@2921
   390
                                    with:alternativeObjDirSource 
cg@2921
   391
                                    with:(self class suiteNameOfCompiler:'bcc')).
cg@2921
   392
                    ]
cg@2921
   393
                ].
cg@2911
   394
            ].
cg@2916
   395
cg@2905
   396
"/            dllRelativePath := objDir,'/',(libraryName,'.dll').
cg@2644
   397
"/            (dllSourceDir / dllRelativePath) exists 
cg@2911
   398
            dllRelativeSourcePathes := Array with:(objDirSource,'\', libraryName, '.dll').
cg@2911
   399
            dllRelativeDestPathes := Array with:(objDirDest,'\', libraryName, '.dll').
cg@2644
   400
        ] ifFalse:[
cg@2911
   401
            dllRelativeSourcePathes := Array with:(libraryName,'.so').
cg@2958
   402
            dllRelativeDestPathes := Array with:(libraryName, '.so').
sv@2723
   403
            (packageModule = 'stx' and:[packageDirectory = 'libview']) ifTrue:[
cg@2958
   404
                dllRelativeSourcePathes := dllRelativeSourcePathes copyWith:('XWorkstation.so').
cg@2958
   405
                dllRelativeDestPathes := dllRelativeDestPathes copyWith:'XWorkstation.so'.
cg@2958
   406
                dllRelativeSourcePathes := dllRelativeSourcePathes copyWith:('GLXWorkstation.so').
cg@2958
   407
                dllRelativeDestPathes := dllRelativeDestPathes copyWith:'GLXWorkstation.so'.
sv@2723
   408
            ].
cg@2644
   409
        ].
cg@2911
   410
        dllRelativeSourcePathes with:dllRelativeDestPathes do:[:dllRelativeSourcePath :dllRelativeDestPath|
cg@2896
   411
            |source dest|
cg@2896
   412
cg@2911
   413
            source := dllSourceDir / dllRelativeSourcePath.
cg@2958
   414
            source exists ifFalse:[
cg@2958
   415
                self activityNotification:'   skip missing file: ',source pathName.
cg@2958
   416
            ] ifTrue:[
cg@2958
   417
                dest := packageTargetDir / dllRelativeDestPath.
cg@2958
   418
                (dest exists not
cg@2958
   419
                 or:[source fileSize ~= dest fileSize
cg@2958
   420
                 or:[source modificationTime >= dest modificationTime
cg@2958
   421
                 "/ or:[ ((dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath)) not ]
cg@2958
   422
                ]]) ifTrue:[
cg@2958
   423
                    Transcript showCR:'updating ',dllRelativeDestPath.
cg@2958
   424
                    dest directory recursiveMakeDirectory.
cg@2958
   425
                    source copyTo:dest.    
cg@2986
   426
                    self activityNotification:'    ',dest pathName
cg@2958
   427
                ].
cg@2958
   428
            ]
sv@2723
   429
        ].
cg@2614
   430
    ].
cg@2896
   431
cg@2921
   432
    "Modified: / 06-09-2012 / 16:19:29 / cg"
cg@2600
   433
!
cg@2600
   434
cg@2644
   435
copyDirectory:relativepath
cg@2644
   436
    "/ need rules in stx
cg@2644
   437
    ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
cg@2644
   438
        recursiveCopyTo:(buildDirectory construct:'stx').
cg@2596
   439
!
cg@2596
   440
cg@2644
   441
copyDirectoryForBuild:subdir
cg@2644
   442
    |targetDir targetFile|
cg@2644
   443
cg@2644
   444
    targetDir := buildDirectory / 'stx' / subdir.
cg@2644
   445
    targetDir exists ifFalse:[
cg@2644
   446
        targetDir makeDirectory.
cg@2964
   447
    ] ifTrue:[
cg@2964
   448
        self isQuickBuild ifTrue:[^ self]
cg@2644
   449
    ].
cg@2644
   450
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
cg@2644
   451
        eachFile isDirectory ifFalse:[
cg@2644
   452
            targetFile := targetDir / eachFile baseName.
cg@2644
   453
            (targetFile exists not
cg@2644
   454
            or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
cg@2644
   455
                self activityNotification:'copying ',eachFile pathName,'...'.
cg@2644
   456
                eachFile copyTo:(targetDir construct:eachFile baseName)
cg@2644
   457
            ]
cg@2644
   458
        ].
cg@2644
   459
    ].
cg@2644
   460
    self activityNotification:nil
cg@2598
   461
!
cg@2598
   462
cg@2644
   463
copyResourcesForPackage:aPackage
cg@2981
   464
    |module directory myPackageDirectory rsrcDir stylesDir|
cg@2644
   465
cg@2644
   466
    module := aPackage asPackageId module.
cg@2644
   467
    directory := aPackage asPackageId directory.
cg@2644
   468
cg@2981
   469
    myPackageDirectory := myTopDirectory / module / directory.
cg@2981
   470
cg@2981
   471
    (rsrcDir := myPackageDirectory / 'resources' ) exists ifTrue:[
cg@2981
   472
        rsrcDir recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   473
    ].
cg@2981
   474
    (stylesDir := myPackageDirectory / 'styles' ) exists ifTrue:[
cg@2981
   475
        stylesDir recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   476
    ].
cg@2600
   477
!
cg@2600
   478
cg@2644
   479
copySTCDirectoryForBuild
cg@2912
   480
    "copy stc files to the build directory"
cg@2912
   481
cg@2644
   482
    |targetDir stc files|
cg@2644
   483
cg@2644
   484
    targetDir := buildDirectory / 'stx' / 'stc'.
cg@2644
   485
    targetDir exists ifFalse:[ targetDir makeDirectory ].
cg@2644
   486
cg@2644
   487
    stc := OperatingSystem isMSWINDOWSlike 
cg@2644
   488
                ifTrue:[ 'stc.exe' ]
cg@2644
   489
                ifFalse:[ 'stc' ].
cg@2644
   490
cg@2644
   491
    files := #( ) copyWith:stc.
cg@2644
   492
cg@2644
   493
    files do:[:eachFile |
cg@2644
   494
        |sourceFile targetFile|
cg@2644
   495
cg@2644
   496
        sourceFile := mySTXTopDirectory / 'stc' / eachFile.
cg@2644
   497
        targetFile := targetDir / eachFile.
cg@2644
   498
        (targetFile exists not
cg@2644
   499
        or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
cg@2644
   500
            self activityNotification:'copying ',sourceFile pathName,'...'.
cg@2644
   501
            sourceFile copyTo:targetFile
cg@2644
   502
        ].
cg@2644
   503
    ].
sr@2683
   504
sr@2683
   505
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
   506
        (targetDir / 'stc') makeExecutableForAll    
sr@2683
   507
    ].
sr@2683
   508
cg@2644
   509
    self activityNotification:nil
cg@2912
   510
cg@2912
   511
    "Modified (comment): / 04-09-2012 / 00:49:19 / cg"
cg@2599
   512
!
cg@2599
   513
cg@2644
   514
copyStartupFilesFromSmalltalk
cg@2912
   515
    "copy additional smalltalk startup files to the build directory"
cg@2912
   516
cg@2644
   517
    (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
cg@2644
   518
        (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
cg@2644
   519
    ].
cg@2644
   520
cg@2678
   521
    #( 
cg@2678
   522
        'keyboard.rc' 
cg@2678
   523
        'keyboardMacros.rc' 
cg@2678
   524
        'display.rc' 
cg@2678
   525
        'd_win32.rc'
cg@2678
   526
        'host.rc' 
cg@2678
   527
        'h_win32.rc'  
cg@2678
   528
        'smalltalk.rc'  
cg@2678
   529
        'private.rc'  
cg@2644
   530
    ) do:[:fn |
cg@2644
   531
        (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2644
   532
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2678
   533
    ].
cg@2678
   534
cg@2678
   535
    (myTopDirectory / 'stx' / 'doc/online/english/LICENCE_STX.html')
cg@2678
   536
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / 'LICENCE_STX.html').
cg@2912
   537
cg@2912
   538
    "Modified (comment): / 04-09-2012 / 00:48:47 / cg"
cg@2912
   539
!
cg@2912
   540
cg@2912
   541
copySupportFilesForCompilation
cg@2912
   542
    "copy the tcc compiler to the build directory"
cg@2912
   543
cg@2912
   544
    |files|
cg@2912
   545
cg@2912
   546
    files := #().
cg@2912
   547
cg@2912
   548
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2984
   549
        files := files , #( 
cg@2984
   550
                        'librun/genDate.com' 
cg@2984
   551
                    ).
cg@2912
   552
        usedCompiler = 'tcc' ifTrue:[
cg@2912
   553
            files := files , #( 
cg@2912
   554
                        'support/tcc'
cg@2912
   555
                    ).
cg@2912
   556
        ].
cg@2912
   557
    ] ifFalse:[
cg@2984
   558
        files := files , #( 
cg@2984
   559
                        "/ 'librun/genDate'   -- not needed on unix (done via script)
cg@2984
   560
                        'configurations/myConf' 
cg@2984
   561
                        'configurations/vendorConf' 
cg@2984
   562
                        'configurations/conf.inc' 
cg@2984
   563
                        'configurations/COMMON' 
cg@2984
   564
                    ).
cg@2912
   565
    ].
cg@2912
   566
cg@2912
   567
    files do:[:relativePath |
cg@2912
   568
        (mySTXTopDirectory / relativePath) exists ifTrue:[
cg@2912
   569
            ((buildDirectory / 'stx' / relativePath) exists
cg@2912
   570
            and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
cg@2912
   571
            and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
cg@2912
   572
            "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
cg@2912
   573
            ]]) ifFalse:[
cg@2984
   574
                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.    
cg@2984
   575
                (mySTXTopDirectory / relativePath) isDirectory ifTrue:[
cg@2984
   576
                    (mySTXTopDirectory / relativePath) recursiveCopyTo:(buildDirectory / 'stx' / relativePath) directory.    
cg@2984
   577
                ] ifFalse:[
cg@2984
   578
                    (mySTXTopDirectory / relativePath) copyTo:(buildDirectory / 'stx' / relativePath) directory.    
cg@2984
   579
                ]
cg@2912
   580
            ]
cg@2912
   581
        ] ifFalse:[
cg@2984
   582
            self error:'Missing file or directory: ',relativePath printString mayProceed:true.
cg@2912
   583
        ].
cg@2912
   584
    ].
cg@2912
   585
cg@2912
   586
    "Created: / 04-09-2012 / 00:47:49 / cg"
cg@2600
   587
!
cg@2600
   588
cg@2644
   589
copySupportFilesForLinkage
cg@2912
   590
    "copy additional files which are req'd for linkage to the build directory"
cg@2912
   591
cg@2644
   592
    |files|
cg@2644
   593
cg@2644
   594
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2644
   595
        files := #( 
cg@2969
   596
                    'librun/genDate.com'
cg@2644
   597
                    'librun/main.c'
cg@2673
   598
                    'projects/smalltalk/stx_16x16.ico'
cg@2673
   599
                    'projects/smalltalk/stx_32x32.ico'
cg@2673
   600
                    'projects/smalltalk/stx_splash.bmp'
cg@2644
   601
                 ).
cg@2905
   602
cg@2905
   603
        usedCompiler = 'bcc' ifTrue:[
cg@2905
   604
            files := files , #( 
cg@2905
   605
                        'librun/objbc/librun.dll'
cg@2905
   606
                        'support/win32/borland/cs3245.dll' 
cg@2905
   607
                        'support/win32/X11.dll'
cg@2905
   608
                        'support/win32/Xext.dll'
cg@2916
   609
                        'lib/bc/librun.lib'
cg@2916
   610
                        'lib/bc/cs32i.lib'
cg@2905
   611
                    ).
cg@2905
   612
        ].
cg@2905
   613
        usedCompiler = 'vc' ifTrue:[
cg@2905
   614
            files := files , #( 
cg@2905
   615
                        'librun/objvc/librun.dll'
cg@2916
   616
                        'lib/vc/librun.lib'
cg@2905
   617
                    ).
cg@2905
   618
        ].
cg@2911
   619
        usedCompiler = 'tcc' ifTrue:[
cg@2911
   620
            files := files , #( 
cg@2916
   621
                        'librun/objvc/librun.dll'   "/ linkage is against vc version!!
cg@2916
   622
                        'lib/vc/librun.lib'
cg@2916
   623
                    ).
cg@2916
   624
        ].
cg@2916
   625
        usedCompiler = 'lcc' ifTrue:[
cg@2916
   626
            files := files , #( 
cg@2916
   627
                        'librun/objvc/librun.dll'   "/ linkage is against vc version!!
cg@2916
   628
                        'lib/vc/librun.lib'
cg@2911
   629
                    ).
cg@2911
   630
        ].
cg@2918
   631
        usedCompiler = 'mingw' ifTrue:[
cg@2918
   632
            files := files , #( 
cg@2972
   633
                        'librun/objmingw/librun.dll'   "/ linkage is against vc version!!
cg@2972
   634
                        'lib/mingw/librun.lib'
cg@2918
   635
                    ).
cg@2918
   636
        ].
cg@2644
   637
    ] ifFalse:[
cg@2644
   638
        files := #(
cg@2644
   639
                    'librun/main.c'
cg@2644
   640
                    'librun/librun.so'
cg@2644
   641
                )
cg@2644
   642
    ].
cg@2677
   643
    files := files asOrderedCollection.
cg@2677
   644
cg@2677
   645
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2677
   646
        projectDefinitionClass applicationIconFileName notNil ifTrue:[
cg@2678
   647
            files add:('projects/smalltalk/',projectDefinitionClass applicationIconFileName,'.ico')
cg@2678
   648
        ].
cg@2678
   649
        projectDefinitionClass splashFileName notNil ifTrue:[
cg@2678
   650
            files add:('projects/smalltalk/',projectDefinitionClass splashFileName,'.bmp')
cg@2678
   651
        ].
cg@2677
   652
    ].
cg@2644
   653
cg@2914
   654
    files do:[:relativePath |
cg@2914
   655
        (mySTXTopDirectory / relativePath) exists ifTrue:[
cg@2914
   656
            ((buildDirectory / 'stx' / relativePath) exists
cg@2914
   657
            and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
cg@2914
   658
            and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
sr@2684
   659
            "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
sr@2684
   660
            ]]) ifFalse:[
cg@2914
   661
                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2914
   662
                (mySTXTopDirectory / relativePath) copyTo:(buildDirectory / 'stx' / relativePath).    
sr@2684
   663
            ]
sr@2684
   664
        ] ifFalse:[
cg@2971
   665
"/ does not really help: objbc/librun.lib does not work with MSVC and vice versa...
cg@2971
   666
"/            ((relativePath = 'librun/objvc/librun.dll')
cg@2971
   667
"/            and:[ (mySTXTopDirectory / 'librun/objbc/librun.dll') exists ])ifTrue:[
cg@2971
   668
"/                stdErr nextPutLine:('Warning: using alternative librun from objbc (Borland version)...'). 
cg@2971
   669
"/                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2971
   670
"/                (mySTXTopDirectory / 'librun/objbc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).    
cg@2971
   671
"/            ] ifFalse:[
cg@2971
   672
"/                ((relativePath = 'librun/objbc/librun.dll')
cg@2971
   673
"/                and:[ (mySTXTopDirectory / 'librun/objvc/librun.dll') exists ])ifTrue:[
cg@2971
   674
"/                    stdErr nextPutLine:('Warning: using alternative librun from objvc (MSVC version)...'). 
cg@2971
   675
"/                    (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2971
   676
"/                    (mySTXTopDirectory / 'librun/objvc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).    
cg@2971
   677
"/                ] ifFalse:[
cg@2971
   678
                    self error:'Missing file: ',relativePath printString mayProceed:true.
cg@2971
   679
"/                ]
cg@2971
   680
"/            ]
sr@2684
   681
        ].
cg@2644
   682
    ].
cg@2873
   683
cg@2918
   684
    "Modified: / 05-09-2012 / 16:26:25 / cg"
cg@2600
   685
!
cg@2600
   686
cg@2644
   687
createHeaderFileFor:aClass in:packageTargetDir
cg@2644
   688
    |instVarList classInstVarList classVarList bindings superclassFilename
cg@2644
   689
     template file newContents oldContents|
cg@2644
   690
cg@2644
   691
    instVarList := StringCollection new.
cg@2644
   692
    aClass instVarNames do:[:v |
cg@2644
   693
        instVarList add:('OBJ %1;' bindWith:v)
cg@2644
   694
    ].
cg@2644
   695
    classInstVarList := StringCollection new.
cg@2644
   696
    aClass class instVarNames do:[:v |
cg@2961
   697
    "/ (v includes:$_) ifTrue:[self halt].
cg@2644
   698
        classInstVarList add:('OBJ %1;' bindWith:v)
cg@2644
   699
    ].
cg@2644
   700
    classVarList := StringCollection new.
cg@2644
   701
    aClass classVarNames do:[:v |
cg@2644
   702
        classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
cg@2644
   703
    ].
cg@2644
   704
cg@2644
   705
    bindings := Dictionary new.
cg@2644
   706
    bindings at:'ClassName' put:aClass name. 
cg@2644
   707
    aClass superclass isNil ifTrue:[
cg@2644
   708
        bindings at:'SuperclassName' put:'-'. 
cg@2852
   709
        bindings at:'SuperclassFileInclude' put:''.
cg@2644
   710
    ] ifFalse:[
cg@2644
   711
        bindings at:'SuperclassName' put:aClass superclass name. 
cg@2644
   712
        bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
cg@2644
   713
        bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
cg@2644
   714
    ].
cg@2644
   715
    bindings at:'InstVarList' put:instVarList asString. 
cg@2644
   716
    bindings at:'ClassVarList' put:classVarList asString. 
cg@2644
   717
    bindings at:'ClassInstVarList' put:classInstVarList asString. 
cg@2644
   718
cg@2644
   719
    template := 
cg@2644
   720
'/* This file was generated by ProjectBuilder. */
cg@2644
   721
/* !!!!!!!! Do not change by hand !!!!!!!! */
cg@2644
   722
cg@2644
   723
/* Class: %(ClassName) */
cg@2644
   724
/* Superclass: %(SuperclassName) */
cg@2644
   725
cg@2644
   726
%(SuperclassFileInclude)
cg@2644
   727
cg@2644
   728
/* INDIRECTGLOBALS */
cg@2644
   729
#ifdef _HEADER_INST_
cg@2644
   730
%(InstVarList)
cg@2644
   731
#endif /* _HEADER_INST_ */
cg@2644
   732
cg@2644
   733
#ifdef _HEADER_CLASS_
cg@2644
   734
%(ClassVarList)
cg@2644
   735
#endif /* _HEADER_CLASS_ */
cg@2644
   736
cg@2644
   737
#ifdef _HEADER_CLASSINST_
cg@2644
   738
%(ClassInstVarList)
cg@2644
   739
#endif /* _HEADER_CLASSINST_ */
cg@2644
   740
'.
cg@2644
   741
    newContents := template bindWithArguments:bindings.
sr@2683
   742
    file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
cg@2644
   743
    (file exists not
cg@2644
   744
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2644
   745
        file contents: newContents.
cg@2644
   746
    ].
cg@2852
   747
cg@2852
   748
    "Modified: / 15-08-2011 / 14:58:46 / cg"
cg@2596
   749
!
cg@2596
   750
cg@2644
   751
generateSourceFiles
cg@2964
   752
    (self isLocalBuild not and:[ sourceCodeManager notNil ])  ifTrue:[
cg@2644
   753
        "/ check out / generate files there
cg@2644
   754
        self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2644
   755
    ] ifFalse:[
cg@2644
   756
        "/ local build
cg@2644
   757
        "/ fileout the project
cg@2644
   758
        self generateSourceFilesByFilingOut
cg@2644
   759
    ]
cg@2596
   760
!
cg@2596
   761
cg@2644
   762
generateSourceFilesByCheckingOutUsing:aSourceCodeManager
cg@2644
   763
    "/ will no longer be needed/supported
cg@2644
   764
cg@2644
   765
    |repository stxRepository module directory|
cg@2644
   766
cg@2868
   767
    self breakPoint:#cg.
cg@2868
   768
cg@2644
   769
    "/ check out / generate files there
cg@2644
   770
    repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
cg@2644
   771
    stxRepository := aSourceCodeManager repositoryName.
cg@2644
   772
cg@2644
   773
    (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   774
        (module ~= 'stx') ifTrue:[
cg@2644
   775
            OperatingSystem
cg@2644
   776
                executeCommand:('cvs -d ',stxRepository,' co stx')
cg@2644
   777
                inputFrom:nil
cg@2644
   778
                outputTo:Transcript
cg@2644
   779
                errorTo:Transcript
cg@2644
   780
                inDirectory:buildDirectory
cg@2644
   781
                onError:[:status| self error:'cvs update stx failed'].
cg@2644
   782
        ].
cg@2644
   783
    ].
cg@2644
   784
cg@2644
   785
    ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
cg@2644
   786
        OperatingSystem
cg@2644
   787
            executeCommand:('cvs -d ',repository,' co -l ',directory)
cg@2644
   788
            inputFrom:nil
cg@2644
   789
            outputTo:Transcript
cg@2644
   790
            errorTo:Transcript
cg@2644
   791
            inDirectory:buildDirectory
cg@2644
   792
            onError:[:status| self error:'cvs update failed'].
cg@2644
   793
    ].
cg@2644
   794
    OperatingSystem
cg@2644
   795
        executeCommand:'cvs upd -d'
cg@2644
   796
        inputFrom:nil
cg@2644
   797
        outputTo:Transcript
cg@2644
   798
        errorTo:Transcript
cg@2644
   799
        inDirectory:(buildDirectory construct:module)
cg@2644
   800
        onError:[:status| self error:'cvs update failed'].
cg@2644
   801
self halt.
cg@2868
   802
cg@2868
   803
    "Modified: / 29-12-2011 / 14:02:56 / cg"
cg@2596
   804
!
cg@2596
   805
cg@2644
   806
generateSourceFilesByFilingOut
cg@2644
   807
    "/ local build
cg@2644
   808
    "/ fileout the project
cg@2644
   809
sv@2844
   810
    |fullPathName|
sv@2844
   811
cg@2644
   812
    (package module ~= 'stx') ifTrue:[
cg@2644
   813
        (buildDirectory / package module) makeDirectory.
cg@2644
   814
    ].
cg@2644
   815
cg@2644
   816
    "/ file out the package(s) which are to be built
cg@2644
   817
    ((Array with:package))
cg@2644
   818
    do:[:eachPackageToFileout |
cg@2981
   819
        |packageId packageModule packageDirectory packageTargetDir packageDef extSource|
cg@2644
   820
cg@2644
   821
        packageId := eachPackageToFileout asPackageId.
cg@2644
   822
        packageModule := packageId module.
cg@2644
   823
        packageDirectory := packageId directory.
cg@2644
   824
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   825
cg@2644
   826
        packageDef := packageId projectDefinitionClass.
cg@2644
   827
        (packageDef compiled_classNames_common ,
cg@2644
   828
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   829
            |cls fileName newSource|
cg@2644
   830
cg@2644
   831
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   832
            self assert:cls isLoaded.
cg@2644
   833
            fileName := (Smalltalk fileNameForClass:cls),'.st'.
cg@2644
   834
            fileName := packageTargetDir asFilename construct:fileName.
cg@2644
   835
            fileName exists ifTrue:[
cg@2644
   836
                newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
cg@2644
   837
                newSource = fileName contentsAsString ifFalse:[
cg@2644
   838
                    fileName contents:newSource
cg@2644
   839
                ].
cg@2644
   840
            ] ifFalse:[
cg@2644
   841
                cls fileOutIn:packageTargetDir withTimeStamp:false
cg@2644
   842
            ].
cg@2644
   843
        ].
cg@2644
   844
cg@2981
   845
        packageDef hasExtensionMethods ifTrue:[
cg@2981
   846
            extSource := 
cg@2981
   847
                String streamContents:[:s |
cg@2985
   848
                    s nextPutAll:('"{ Package: ''%1'' }" !!\\' bindWith:packageDef package) withCRs.
cg@2985
   849
cg@2981
   850
                    packageDef extensionMethods do:[:eachMethod |
cg@2981
   851
                        eachMethod mclass fileOutMethod:eachMethod on:s
cg@2981
   852
                    ].
cg@2981
   853
                ].
cg@2987
   854
            extSource isWideString ifTrue:[
cg@2987
   855
                extSource := ( '"{ Encoding: utf8 }"' , Character cr asString, Character cr asString, extSource).
cg@2987
   856
                extSource := extSource utf8Encoded.
cg@2987
   857
            ].
cg@2985
   858
            (packageTargetDir asFilename construct:'extensions.st') contents:extSource
cg@2981
   859
        ].
cg@2981
   860
cg@2644
   861
"/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
cg@2644
   862
"/            cls isPrivate ifFalse:[
cg@2644
   863
"/                cls isLoaded ifFalse:[
cg@2644
   864
"/                    self halt.
cg@2644
   865
"/                    cls autoload.
cg@2644
   866
"/                ].
cg@2644
   867
"/                cls fileOutIn:packageTargetDir
cg@2644
   868
"/            ]
cg@2644
   869
"/        ].
cg@2644
   870
cg@2644
   871
        projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
sv@2844
   872
            fullPathName := packageTargetDir construct:fileName.
sv@2844
   873
            fullPathName directory exists ifFalse:[
sv@2844
   874
                "take care for files like 'autopackage/default.apspec'"
sv@2844
   875
                fullPathName directory makeDirectory.
sv@2844
   876
            ].
sv@2844
   877
            (fullPathName exists
sv@2844
   878
             and:[ fullPathName contents = fileContents ]) ifFalse:[
sv@2844
   879
                fullPathName contents:fileContents.
cg@2644
   880
            ].
cg@2644
   881
        ].    
cg@2644
   882
    ].
cg@2972
   883
    self makeQuick ifFalse:[
cg@2972
   884
        "/ generate header files in prerequisite packages...
cg@2972
   885
        (projectDefinitionClass allPreRequisites)
cg@2972
   886
        do:[:eachPackageToFileout |
cg@2972
   887
            |packageId packageDef packageModule packageDirectory packageTargetDir|
cg@2644
   888
cg@2972
   889
            packageId := eachPackageToFileout asPackageId.
cg@2972
   890
            packageModule := packageId module.
cg@2972
   891
            packageDirectory := packageId directory.
cg@2972
   892
            packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   893
cg@2972
   894
            packageDef := packageId projectDefinitionClass.
cg@2972
   895
            (packageDef compiled_classNames_common ,
cg@2972
   896
            packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2972
   897
                |cls|
cg@2644
   898
cg@2972
   899
                cls := Smalltalk classNamed:eachClassName.
cg@2972
   900
                "/ self assert:cls isLoaded.
cg@2972
   901
                cls isNil ifTrue:[
cg@2972
   902
                    stdErr nextPutLine:('Missing class: ',eachClassName, ' (not present in system. Warning only:subclasses of it will not be compiled)').
cg@2972
   903
                ] ifFalse:[
cg@2972
   904
                    cls isLoaded ifTrue:[    
cg@2972
   905
                        self createHeaderFileFor:cls in:packageTargetDir
cg@2972
   906
                    ]
cg@2972
   907
                ].
cg@2644
   908
            ].
cg@2972
   909
            self copyResourcesForPackage:eachPackageToFileout.
cg@2644
   910
        ].
cg@2644
   911
    ].
cg@2644
   912
cg@2644
   913
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   914
!
cg@2596
   915
cg@2909
   916
makeCommandOfCompiler:usedCompiler
cg@2909
   917
    usedCompiler = 'bcc' ifTrue:[ 
cg@2909
   918
        ^ 'bmake'.
cg@2909
   919
    ].
cg@2909
   920
    usedCompiler = 'vc' ifTrue:[ 
cg@2909
   921
        ^ 'vcmake'. "/ compilerFlag := '-DUSEVC' 
cg@2909
   922
    ].
cg@2909
   923
    usedCompiler = 'lcc' ifTrue:[ 
cg@2909
   924
        ^ 'lccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   925
    ].
cg@2909
   926
    usedCompiler = 'tcc' ifTrue:[ 
cg@2909
   927
        ^ 'tccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   928
    ].
cg@2918
   929
    usedCompiler = 'mingw' ifTrue:[ 
cg@2921
   930
        ^ 'mingwmake'.  "/ compilerFlag := '-DUSEMINGW' 
cg@2909
   931
    ].
cg@2989
   932
    true "usedCompiler = 'gcc'" ifTrue:[ 
cg@2989
   933
        ^ 'make'.       "/ compilerFlag := '-DUSEGCC' 
cg@2989
   934
    ].
cg@2909
   935
    self error:'unknown compiler specified'.
cg@2909
   936
cg@2909
   937
    "Created: / 03-09-2012 / 19:46:07 / cg"
cg@2909
   938
!
cg@2909
   939
cg@2644
   940
makeWithOutputTo:stdOut errorTo:stdErr
cg@2909
   941
    |module directory makeCommand|
cg@2644
   942
cg@2644
   943
    module := package module.
cg@2644
   944
    directory := package directory.
cg@2644
   945
cg@2680
   946
    makeCommand := ParserFlags makeCommand.
cg@2895
   947
    usedCompiler isNil ifTrue:[
cg@2895
   948
        usedCompiler := ParserFlags usedCompiler.
cg@2895
   949
    ].
cg@2909
   950
    makeCommand := self makeCommandOfCompiler:usedCompiler.
cg@2873
   951
cg@2852
   952
    "/ makeCommand := makeCommand, ' TOP=', mySTXTopDirectory pathName.
cg@2680
   953
sr@2683
   954
    OperatingSystem isUNIXlike ifTrue:[
cg@2921
   955
        "/ generate the makefile first
cg@2984
   956
        self activityNotification:('sh %1/rules/stmkmf (in %2)' 
cg@2984
   957
                    bindWith:mySTXTopDirectory pathName    
cg@2984
   958
                    with:(buildDirectory / module / directory)).
sr@2683
   959
        OperatingSystem
sv@2845
   960
            executeCommand:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName)
sr@2683
   961
            inputFrom:nil
sr@2683
   962
            outputTo:stdOut
sr@2683
   963
            errorTo:stdErr
sr@2683
   964
            inDirectory:(buildDirectory / module / directory)
cg@2921
   965
            onError:[:status | self error:'make failed'].
sr@2683
   966
    ].
sr@2683
   967
cg@2644
   968
    projectDefinitionClass isLibraryDefinition ifTrue:[
cg@2921
   969
        "/ generate the library
cg@2969
   970
        self activityNotification:(makeCommand,' classLibRule').
cg@2644
   971
        OperatingSystem
cg@2989
   972
            executeCommand:(makeCommand,' classLibRule FORCE=')
cg@2644
   973
            inputFrom:nil
cg@2644
   974
            outputTo:stdOut
cg@2644
   975
            errorTo:stdErr
cg@2644
   976
            inDirectory:(buildDirectory / module / directory)
cg@2921
   977
            onError:[:status | self error:'make failed'].
cg@2644
   978
    ] ifFalse:[
cg@2972
   979
        (self makeExeOnly) ifTrue:[
cg@2969
   980
            self activityNotification:(makeCommand,' exe').
cg@2969
   981
            OperatingSystem
cg@2969
   982
                "/ generate the executable
cg@2989
   983
                executeCommand:(makeCommand,' exe FORCE=')
cg@2969
   984
                inputFrom:nil
cg@2969
   985
                outputTo:stdOut
cg@2969
   986
                errorTo:stdErr
cg@2969
   987
                inDirectory:(buildDirectory / module / directory)
cg@2969
   988
                onError:[:status | self error:'make failed'].
cg@2644
   989
cg@2969
   990
        ] ifFalse:[
cg@2921
   991
            "/ generate the self-installable package
cg@2969
   992
            self activityNotification:(makeCommand,' ALL_NP').
cg@2673
   993
            OperatingSystem
cg@2969
   994
                executeCommand:(makeCommand,' ALL_NP')
cg@2673
   995
                inputFrom:nil
cg@2673
   996
                outputTo:stdOut
cg@2673
   997
                errorTo:stdErr
cg@2673
   998
                inDirectory:(buildDirectory / module / directory)
cg@2921
   999
                onError:[:status | self error:'make failed'].
cg@2673
  1000
        ]
cg@2644
  1001
    ]
cg@2793
  1002
cg@2909
  1003
    "Modified: / 03-09-2012 / 19:47:15 / cg"
cg@2921
  1004
    "Modified (comment): / 06-09-2012 / 16:22:38 / cg"
cg@2611
  1005
!
cg@2611
  1006
cg@2905
  1007
objDirForUsedCompiler
cg@2909
  1008
    ^ self objDirForUsedCompiler:usedCompiler
cg@2909
  1009
cg@2909
  1010
    "Created: / 20-08-2012 / 17:01:13 / cg"
cg@2909
  1011
!
cg@2909
  1012
cg@2909
  1013
objDirForUsedCompiler:usedCompiler
cg@2918
  1014
    usedCompiler = 'gcc' ifTrue:[^ 'obj'].      "/ unix case
cg@2918
  1015
cg@2905
  1016
    usedCompiler = 'bcc' ifTrue:[^ 'objbc'].
cg@2905
  1017
    usedCompiler = 'vc' ifTrue:[^ 'objvc'].
cg@2909
  1018
    usedCompiler = 'tcc' ifTrue:[^ 'objtcc'].
cg@2909
  1019
    usedCompiler = 'lcc' ifTrue:[^ 'objlcc'].
cg@2918
  1020
    usedCompiler = 'mingw' ifTrue:[^ 'objmingw'].
cg@2961
  1021
    self halt:'please add compiler here'.
cg@2905
  1022
    ^ 'objbc'
cg@2905
  1023
cg@2909
  1024
    "Created: / 03-09-2012 / 19:55:34 / cg"
cg@2905
  1025
!
cg@2905
  1026
sr@2683
  1027
recursiveCopyDirectoryForBuild:subdir
sr@2683
  1028
    |targetDir|
sr@2683
  1029
sr@2683
  1030
    targetDir := buildDirectory / 'stx' / subdir.
sr@2683
  1031
    targetDir exists ifFalse:[
sr@2683
  1032
        targetDir makeDirectory.
sr@2683
  1033
    ].
sr@2683
  1034
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
sr@2683
  1035
        eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
sr@2683
  1036
    ].
sr@2683
  1037
    self activityNotification:nil
sr@2683
  1038
!
sr@2683
  1039
cg@2644
  1040
setupBuildDirectory
cg@2984
  1041
    self activityNotification:('Building in %1' bindWith:buildDirectory pathName).
cg@2984
  1042
cg@2644
  1043
    buildDirectory exists ifFalse:[
cg@2644
  1044
        buildDirectory recursiveMakeDirectory.
cg@2644
  1045
    ].
cg@2644
  1046
    (buildDirectory / 'stx') exists ifFalse:[
cg@2644
  1047
        (buildDirectory / 'stx') makeDirectory.
cg@2644
  1048
    ].
cg@2644
  1049
cg@2644
  1050
    self copyDirectoryForBuild:'include'.
cg@2644
  1051
    self copyDirectoryForBuild:'rules'.
cg@2984
  1052
sr@2683
  1053
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
  1054
        self recursiveCopyDirectoryForBuild:'configurations'.
sr@2683
  1055
    ]
cg@2635
  1056
!
cg@2596
  1057
cg@2644
  1058
validateBuildDirectoryIsPresent
cg@2644
  1059
cg@2644
  1060
    ^ self.
cg@2644
  1061
cg@2644
  1062
"/    [
cg@2644
  1063
"/        |default directoryIsOKForMe stc |
cg@2644
  1064
"/
cg@2644
  1065
"/        default := (buildDirectory ?
cg@2644
  1066
"/                          PreviousBuildDirectory)
cg@2644
  1067
"/                          ifNil:[ UserPreferences current buildDirectory].
cg@2644
  1068
"/
cg@2644
  1069
"/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
cg@2644
  1070
"/                                 default:default.
cg@2644
  1071
"/
cg@2644
  1072
"/        buildDirectory isEmptyOrNil ifTrue:[^ self].
cg@2644
  1073
"/        buildDirectory := buildDirectory asFilename.
cg@2644
  1074
"/        directoryIsOKForMe := true.
cg@2644
  1075
"/
cg@2644
  1076
"/        buildDirectory exists ifFalse:[
cg@2644
  1077
"/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
cg@2644
  1078
"/            directoryIsOKForMe := false.
cg@2644
  1079
"/        ] ifTrue:[
cg@2644
  1080
"/            (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
  1081
"/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
cg@2644
  1082
"/                directoryIsOKForMe := false.
cg@2644
  1083
"/            ] ifTrue:[
cg@2644
  1084
"/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
cg@2644
  1085
"/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
cg@2644
  1086
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
cg@2644
  1087
"/                    directoryIsOKForMe := false.
cg@2644
  1088
"/                ].
cg@2644
  1089
"/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
cg@2644
  1090
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
cg@2644
  1091
"/                    directoryIsOKForMe := false.
cg@2644
  1092
"/                ].
cg@2644
  1093
"/            ]
cg@2644
  1094
"/        ].
cg@2644
  1095
"/        directoryIsOKForMe
cg@2644
  1096
"/    ] whileFalse
cg@2596
  1097
! !
cg@2596
  1098
cg@2596
  1099
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
  1100
cg@2896
  1101
version
cg@2896
  1102
    ^ '$Header$'
cg@2896
  1103
!
cg@2896
  1104
cg@2596
  1105
version_CVS
cg@2596
  1106
    ^ '$Header$'
cg@2596
  1107
! !
cg@2958
  1108