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