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