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