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