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