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