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