ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Wed, 14 Oct 2009 17:33:36 +0200
changeset 2622 e55f43981463
parent 2614 ff815b56c808
child 2628 57b363325368
permissions -rw-r--r--
*** empty log message ***
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@2599
   146
    self copySTCDirectoryForBuild.
cg@2596
   147
    self generateSourceFiles.
cg@2600
   148
    self copyDLLsForLinkage.
cg@2600
   149
    self copySupportFilesForLinkage.
cg@2600
   150
    self copyStartupFilesFromSmalltalk.
cg@2596
   151
cg@2611
   152
    self makeWithOutputTo:stdOut errorTo:stdErr.
cg@2596
   153
!
cg@2596
   154
cg@2614
   155
copyDLLsForLinkage
cg@2614
   156
    |targetBuildDir|
cg@2614
   157
cg@2614
   158
    targetBuildDir := buildDirectory / package module / package directory.
cg@2614
   159
cg@2614
   160
    (projectDefinitionClass allPreRequisites)
cg@2614
   161
    do:[:eachPackageToFileout |
cg@2614
   162
        |packageId packageDef packageModule packageDirectory packageTargetDir
cg@2614
   163
         dllSource dllSourceDir libraryName dllRelativePath|
cg@2614
   164
cg@2614
   165
        packageId := eachPackageToFileout asPackageId.
cg@2614
   166
        packageModule := packageId module.
cg@2614
   167
        packageDirectory := packageId directory.
cg@2614
   168
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2614
   169
cg@2614
   170
        packageDef := packageId projectDefinitionClass.
cg@2614
   171
        libraryName := packageDef libraryName.
cg@2614
   172
cg@2614
   173
        "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
cg@2614
   174
        dllSourceDir := myTopDirectory / packageModule / packageDirectory.
cg@2614
   175
        OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2614
   176
"/            dllRelativePath := 'objvc','/',(libraryName,'.dll').
cg@2614
   177
"/            (dllSourceDir / dllRelativePath) exists 
cg@2614
   178
            false ifFalse:[
cg@2614
   179
                dllRelativePath := 'objbc','/',(libraryName,'.dll').
cg@2614
   180
            ]
cg@2614
   181
        ] ifFalse:[
cg@2614
   182
            dllRelativePath := libraryName,'.so'.
cg@2614
   183
        ].
cg@2614
   184
        ((packageTargetDir / dllRelativePath) exists
cg@2614
   185
        and:[ (dllSourceDir / dllRelativePath) fileSize = (packageTargetDir / dllRelativePath) fileSize
cg@2614
   186
        and:[ (dllSourceDir / dllRelativePath) modificationTime < (packageTargetDir / dllRelativePath) modificationTime
cg@2614
   187
        "/ and:[ (dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath) ]
cg@2614
   188
        ]]) ifFalse:[
cg@2614
   189
            (packageTargetDir / dllRelativePath) directory recursiveMakeDirectory.
cg@2614
   190
            (dllSourceDir / dllRelativePath) copyTo:(packageTargetDir / dllRelativePath).    
cg@2614
   191
        ]
cg@2614
   192
    ].
cg@2600
   193
!
cg@2600
   194
cg@2614
   195
copyDirectory:relativepath
cg@2614
   196
    "/ need rules in stx
cg@2614
   197
    ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
cg@2614
   198
        recursiveCopyTo:(buildDirectory construct:'stx').
cg@2596
   199
!
cg@2596
   200
cg@2614
   201
copyDirectoryForBuild:subdir
cg@2614
   202
    |targetDir targetFile|
cg@2614
   203
cg@2614
   204
    targetDir := buildDirectory / 'stx' / subdir.
cg@2614
   205
    targetDir exists ifFalse:[
cg@2614
   206
        targetDir makeDirectory.
cg@2614
   207
    ].
cg@2614
   208
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
cg@2614
   209
        eachFile isDirectory ifFalse:[
cg@2614
   210
            targetFile := targetDir / eachFile baseName.
cg@2614
   211
            (targetFile exists not
cg@2614
   212
            or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
cg@2614
   213
                self activityNotification:'copying ',eachFile pathName,'...'.
cg@2614
   214
                eachFile copyTo:(targetDir construct:eachFile baseName)
cg@2614
   215
            ]
cg@2614
   216
        ].
cg@2614
   217
    ].
cg@2614
   218
    self activityNotification:nil
cg@2598
   219
!
cg@2598
   220
cg@2614
   221
copyResourcesForPackage:aPackage
cg@2614
   222
    |module directory|
cg@2614
   223
cg@2614
   224
    module := aPackage asPackageId module.
cg@2614
   225
    directory := aPackage asPackageId directory.
cg@2614
   226
cg@2614
   227
    (myTopDirectory / module / directory / 'resources' ) exists ifTrue:[
cg@2614
   228
        (myTopDirectory / module / directory / 'resources' )
cg@2614
   229
            recursiveCopyTo:(buildDirectory / module / directory)
cg@2614
   230
    ].
cg@2614
   231
    (myTopDirectory / module / directory / 'styles' ) exists ifTrue:[
cg@2614
   232
        (myTopDirectory / module / directory / 'styles' )
cg@2614
   233
            recursiveCopyTo:(buildDirectory / module / directory)
cg@2614
   234
    ].
cg@2600
   235
!
cg@2600
   236
cg@2614
   237
copySTCDirectoryForBuild
cg@2614
   238
    |targetDir stc files|
cg@2614
   239
cg@2614
   240
    targetDir := buildDirectory / 'stx' / 'stc'.
cg@2614
   241
    targetDir exists ifFalse:[ targetDir makeDirectory ].
cg@2614
   242
cg@2614
   243
    stc := OperatingSystem isMSWINDOWSlike 
cg@2614
   244
                ifTrue:[ 'stc.exe' ]
cg@2614
   245
                ifFalse:[ 'stc' ].
cg@2614
   246
cg@2614
   247
    files := #( ) copyWith:stc.
cg@2614
   248
cg@2614
   249
    files do:[:eachFile |
cg@2614
   250
        |sourceFile targetFile|
cg@2614
   251
cg@2614
   252
        sourceFile := mySTXTopDirectory / 'stc' / eachFile.
cg@2614
   253
        targetFile := targetDir / eachFile.
cg@2614
   254
        (targetFile exists not
cg@2614
   255
        or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
cg@2614
   256
            self activityNotification:'copying ',sourceFile pathName,'...'.
cg@2614
   257
            sourceFile copyTo:targetFile
cg@2614
   258
        ].
cg@2614
   259
    ].
cg@2614
   260
    self activityNotification:nil
cg@2599
   261
!
cg@2599
   262
cg@2614
   263
copyStartupFilesFromSmalltalk
cg@2614
   264
    (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
cg@2614
   265
        (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
cg@2614
   266
    ].
cg@2614
   267
cg@2614
   268
    #( 'keyboard.rc' 'keyboardMacros.rc' 'display.rc' 'd_win32.rc'
cg@2614
   269
       'host.rc' 'h_win32.rc'  
cg@2614
   270
    ) do:[:fn |
cg@2614
   271
        (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2614
   272
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2614
   273
    ]
cg@2600
   274
!
cg@2600
   275
cg@2614
   276
copySupportFilesForLinkage
cg@2614
   277
    |files|
cg@2614
   278
cg@2614
   279
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2614
   280
        files := #( 
cg@2614
   281
                    'support/win32/borland/cs3245.dll' 
cg@2614
   282
                    'support/win32/X11.dll'
cg@2614
   283
                    'support/win32/Xext.dll'
cg@2614
   284
                    'librun/librun.dll'
cg@2614
   285
                    'libbc/librun.lib'
cg@2614
   286
                    'libbc/cs32i.lib'
cg@2614
   287
                    'librun/genDate.exe'
cg@2614
   288
                    'librun/main.c'
cg@2614
   289
                 ).
cg@2614
   290
    ] ifFalse:[
cg@2614
   291
        files := #(
cg@2614
   292
                    'librun/genDate'
cg@2614
   293
                    'librun/main.c'
cg@2614
   294
                    'librun/librun.so'
cg@2614
   295
                )
cg@2614
   296
    ].
cg@2614
   297
cg@2614
   298
    files do:[:dllRelativePath |
cg@2614
   299
        ((buildDirectory / 'stx' / dllRelativePath) exists
cg@2614
   300
        and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize
cg@2614
   301
        and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime
cg@2614
   302
        "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
cg@2614
   303
        ]]) ifFalse:[
cg@2614
   304
            (buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
cg@2614
   305
            (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
cg@2614
   306
        ]
cg@2614
   307
    ].
cg@2600
   308
!
cg@2600
   309
cg@2614
   310
createHeaderFileFor:aClass in:packageTargetDir
cg@2614
   311
    |instVarList classInstVarList classVarList bindings superclassFilename
cg@2614
   312
     template file newContents oldContents|
cg@2614
   313
cg@2614
   314
    instVarList := StringCollection new.
cg@2614
   315
    aClass instVarNames do:[:v |
cg@2614
   316
        instVarList add:('OBJ %1;' bindWith:v)
cg@2614
   317
    ].
cg@2614
   318
    classInstVarList := StringCollection new.
cg@2614
   319
    aClass class instVarNames do:[:v |
cg@2614
   320
(v includes:$_) ifTrue:[self halt].
cg@2614
   321
        classInstVarList add:('OBJ %1;' bindWith:v)
cg@2614
   322
    ].
cg@2614
   323
    classVarList := StringCollection new.
cg@2614
   324
    aClass classVarNames do:[:v |
cg@2614
   325
        classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
cg@2614
   326
    ].
cg@2614
   327
cg@2614
   328
    bindings := Dictionary new.
cg@2614
   329
    bindings at:'ClassName' put:aClass name. 
cg@2614
   330
    aClass superclass isNil ifTrue:[
cg@2614
   331
        bindings at:'SuperclassName' put:'-'. 
cg@2614
   332
        bindings at:'SuperclassFileInclude' put:nil.
cg@2614
   333
    ] ifFalse:[
cg@2614
   334
        bindings at:'SuperclassName' put:aClass superclass name. 
cg@2614
   335
        bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
cg@2614
   336
        bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
cg@2614
   337
    ].
cg@2614
   338
    bindings at:'InstVarList' put:instVarList asString. 
cg@2614
   339
    bindings at:'ClassVarList' put:classVarList asString. 
cg@2614
   340
    bindings at:'ClassInstVarList' put:classInstVarList asString. 
cg@2614
   341
cg@2614
   342
    template := 
cg@2614
   343
'/* This file was generated by ProjectBuilder. */
cg@2614
   344
/* !!!!!!!! Do not change by hand !!!!!!!! */
cg@2614
   345
cg@2614
   346
/* Class: %(ClassName) */
cg@2614
   347
/* Superclass: %(SuperclassName) */
cg@2614
   348
cg@2614
   349
%(SuperclassFileInclude)
cg@2614
   350
cg@2614
   351
/* INDIRECTGLOBALS */
cg@2614
   352
#ifdef _HEADER_INST_
cg@2614
   353
%(InstVarList)
cg@2614
   354
#endif /* _HEADER_INST_ */
cg@2614
   355
cg@2614
   356
#ifdef _HEADER_CLASS_
cg@2614
   357
%(ClassVarList)
cg@2614
   358
#endif /* _HEADER_CLASS_ */
cg@2614
   359
cg@2614
   360
#ifdef _HEADER_CLASSINST_
cg@2614
   361
%(ClassInstVarList)
cg@2614
   362
#endif /* _HEADER_CLASSINST_ */
cg@2614
   363
'.
cg@2614
   364
    newContents := template bindWithArguments:bindings.
cg@2614
   365
    file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),'.STH').
cg@2614
   366
    (file exists not
cg@2614
   367
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2614
   368
        file contents: newContents.
cg@2614
   369
    ].
cg@2596
   370
!
cg@2596
   371
cg@2614
   372
generateSourceFiles
cg@2614
   373
    sourceCodeManager notNil ifTrue:[
cg@2614
   374
        "/ check out / generate files there
cg@2614
   375
        self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2614
   376
    ] ifFalse:[
cg@2614
   377
        "/ local build
cg@2614
   378
        "/ fileout the project
cg@2614
   379
        self generateSourceFilesByFilingOut
cg@2614
   380
    ]
cg@2596
   381
!
cg@2596
   382
cg@2614
   383
generateSourceFilesByCheckingOutUsing:aSourceCodeManager
cg@2614
   384
    "/ will no longer be needed/supported
cg@2614
   385
cg@2614
   386
    |repository stxRepository module directory|
cg@2614
   387
cg@2614
   388
self halt.
cg@2614
   389
    "/ check out / generate files there
cg@2614
   390
    repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
cg@2614
   391
    stxRepository := aSourceCodeManager repositoryName.
cg@2614
   392
cg@2614
   393
    (buildDirectory construct:'stx') exists ifFalse:[
cg@2614
   394
        (module ~= 'stx') ifTrue:[
cg@2614
   395
            OperatingSystem
cg@2614
   396
                executeCommand:('cvs -d ',stxRepository,' co stx')
cg@2614
   397
                inputFrom:nil
cg@2614
   398
                outputTo:Transcript
cg@2614
   399
                errorTo:Transcript
cg@2614
   400
                inDirectory:buildDirectory
cg@2614
   401
                onError:[:status| self error:'cvs update stx failed'].
cg@2614
   402
        ].
cg@2614
   403
    ].
cg@2614
   404
cg@2614
   405
    ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
cg@2614
   406
        OperatingSystem
cg@2614
   407
            executeCommand:('cvs -d ',repository,' co -l ',directory)
cg@2614
   408
            inputFrom:nil
cg@2614
   409
            outputTo:Transcript
cg@2614
   410
            errorTo:Transcript
cg@2614
   411
            inDirectory:buildDirectory
cg@2614
   412
            onError:[:status| self error:'cvs update failed'].
cg@2614
   413
    ].
cg@2614
   414
    OperatingSystem
cg@2614
   415
        executeCommand:'cvs upd -d'
cg@2614
   416
        inputFrom:nil
cg@2614
   417
        outputTo:Transcript
cg@2614
   418
        errorTo:Transcript
cg@2614
   419
        inDirectory:(buildDirectory construct:module)
cg@2614
   420
        onError:[:status| self error:'cvs update failed'].
cg@2614
   421
self halt.
cg@2596
   422
!
cg@2596
   423
cg@2614
   424
generateSourceFilesByFilingOut
cg@2614
   425
    "/ local build
cg@2614
   426
    "/ fileout the project
cg@2614
   427
cg@2614
   428
    (package module ~= 'stx') ifTrue:[
cg@2614
   429
        (buildDirectory / package module) makeDirectory.
cg@2614
   430
    ].
cg@2614
   431
cg@2614
   432
    "/ file out the package(s) which are to be built
cg@2614
   433
    ((Array with:package))
cg@2614
   434
    do:[:eachPackageToFileout |
cg@2614
   435
        |packageId packageModule packageDirectory packageTargetDir packageDef|
cg@2614
   436
cg@2614
   437
        packageId := eachPackageToFileout asPackageId.
cg@2614
   438
        packageModule := packageId module.
cg@2614
   439
        packageDirectory := packageId directory.
cg@2614
   440
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2614
   441
cg@2614
   442
        packageDef := packageId projectDefinitionClass.
cg@2614
   443
        (packageDef compiled_classNames_common ,
cg@2614
   444
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2614
   445
            |cls|
cg@2614
   446
cg@2614
   447
            cls := Smalltalk classNamed:eachClassName.
cg@2614
   448
            self assert:cls isLoaded.
cg@2614
   449
            cls fileOutIn:packageTargetDir
cg@2614
   450
        ].
cg@2614
   451
cg@2614
   452
"/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
cg@2614
   453
"/            cls isPrivate ifFalse:[
cg@2614
   454
"/                cls isLoaded ifFalse:[
cg@2614
   455
"/                    self halt.
cg@2614
   456
"/                    cls autoload.
cg@2614
   457
"/                ].
cg@2614
   458
"/                cls fileOutIn:packageTargetDir
cg@2614
   459
"/            ]
cg@2614
   460
"/        ].
cg@2614
   461
cg@2614
   462
        projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
cg@2614
   463
            ((packageTargetDir / fileName) exists
cg@2614
   464
            and:[ (packageTargetDir / fileName) contents = fileContents ]) ifFalse:[
cg@2614
   465
                (packageTargetDir / fileName) contents:fileContents.
cg@2614
   466
            ].
cg@2614
   467
        ].    
cg@2614
   468
    ].
cg@2614
   469
cg@2614
   470
    "/ generate header files in prerequisite packages...
cg@2614
   471
    (projectDefinitionClass allPreRequisites)
cg@2614
   472
    do:[:eachPackageToFileout |
cg@2614
   473
        |packageId packageDef packageModule packageDirectory packageTargetDir|
cg@2614
   474
cg@2614
   475
        packageId := eachPackageToFileout asPackageId.
cg@2614
   476
        packageModule := packageId module.
cg@2614
   477
        packageDirectory := packageId directory.
cg@2614
   478
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2614
   479
cg@2614
   480
        packageDef := packageId projectDefinitionClass.
cg@2614
   481
        (packageDef compiled_classNames_common ,
cg@2614
   482
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2614
   483
            |cls|
cg@2614
   484
cg@2614
   485
            cls := Smalltalk classNamed:eachClassName.
cg@2614
   486
            "/ self assert:cls isLoaded.
cg@2614
   487
            cls isLoaded ifTrue:[    
cg@2614
   488
                self createHeaderFileFor:cls in:packageTargetDir
cg@2614
   489
            ].
cg@2614
   490
        ].
cg@2614
   491
        self copyResourcesForPackage:eachPackageToFileout.
cg@2614
   492
    ].
cg@2614
   493
cg@2614
   494
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   495
!
cg@2596
   496
cg@2611
   497
makeWithOutputTo:stdOut errorTo:stdErr
cg@2611
   498
    |module directory|
cg@2611
   499
cg@2611
   500
    module := package module.
cg@2611
   501
    directory := package directory.
cg@2611
   502
cg@2612
   503
    projectDefinitionClass isLibraryDefinition ifTrue:[
cg@2612
   504
        OperatingSystem
cg@2612
   505
            executeCommand:(ParserFlags makeCommand,' classLibRule')
cg@2612
   506
            inputFrom:nil
cg@2612
   507
            outputTo:stdOut
cg@2612
   508
            errorTo:stdErr
cg@2612
   509
            inDirectory:(buildDirectory / module / directory)
cg@2612
   510
            onError:[:status| self error:'make failed'].
cg@2612
   511
    ] ifFalse:[
cg@2612
   512
        OperatingSystem
cg@2612
   513
            executeCommand:(ParserFlags makeCommand,' exe')
cg@2612
   514
            inputFrom:nil
cg@2612
   515
            outputTo:stdOut
cg@2612
   516
            errorTo:stdErr
cg@2612
   517
            inDirectory:(buildDirectory / module / directory)
cg@2612
   518
            onError:[:status| self error:'make failed'].
cg@2611
   519
cg@2612
   520
        OperatingSystem
cg@2612
   521
            executeCommand:(ParserFlags makeCommand,' setup')
cg@2612
   522
            inputFrom:nil
cg@2612
   523
            outputTo:stdOut
cg@2612
   524
            errorTo:stdErr
cg@2612
   525
            inDirectory:(buildDirectory / module / directory)
cg@2612
   526
            onError:[:status| self error:'make failed'].
cg@2612
   527
    ]
cg@2611
   528
!
cg@2611
   529
cg@2614
   530
setupBuildDirectory
cg@2614
   531
    buildDirectory exists ifFalse:[
cg@2614
   532
        buildDirectory recursiveMakeDirectory.
cg@2614
   533
    ].
cg@2614
   534
    (buildDirectory / 'stx') exists ifFalse:[
cg@2614
   535
        (buildDirectory / 'stx') makeDirectory.
cg@2614
   536
    ].
cg@2596
   537
cg@2614
   538
    self copyDirectoryForBuild:'include'.
cg@2614
   539
    self copyDirectoryForBuild:'rules'.
cg@2596
   540
!
cg@2596
   541
cg@2614
   542
validateBuildDirectoryIsPresent
cg@2614
   543
cg@2614
   544
    ^ self.
cg@2614
   545
cg@2614
   546
"/    [
cg@2614
   547
"/        |default directoryIsOKForMe stc |
cg@2614
   548
"/
cg@2614
   549
"/        default := (buildDirectory ?
cg@2614
   550
"/                          PreviousBuildDirectory)
cg@2614
   551
"/                          ifNil:[ UserPreferences current buildDirectory].
cg@2614
   552
"/
cg@2614
   553
"/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
cg@2614
   554
"/                                 default:default.
cg@2614
   555
"/
cg@2614
   556
"/        buildDirectory isEmptyOrNil ifTrue:[^ self].
cg@2614
   557
"/        buildDirectory := buildDirectory asFilename.
cg@2614
   558
"/        directoryIsOKForMe := true.
cg@2614
   559
"/
cg@2614
   560
"/        buildDirectory exists ifFalse:[
cg@2614
   561
"/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
cg@2614
   562
"/            directoryIsOKForMe := false.
cg@2614
   563
"/        ] ifTrue:[
cg@2614
   564
"/            (buildDirectory construct:'stx') exists ifFalse:[
cg@2614
   565
"/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
cg@2614
   566
"/                directoryIsOKForMe := false.
cg@2614
   567
"/            ] ifTrue:[
cg@2614
   568
"/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
cg@2614
   569
"/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
cg@2614
   570
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
cg@2614
   571
"/                    directoryIsOKForMe := false.
cg@2614
   572
"/                ].
cg@2614
   573
"/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
cg@2614
   574
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
cg@2614
   575
"/                    directoryIsOKForMe := false.
cg@2614
   576
"/                ].
cg@2614
   577
"/            ]
cg@2614
   578
"/        ].
cg@2614
   579
"/        directoryIsOKForMe
cg@2614
   580
"/    ] whileFalse
cg@2596
   581
! !
cg@2596
   582
cg@2596
   583
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
   584
cg@2596
   585
version_CVS
cg@2596
   586
    ^ '$Header$'
cg@2596
   587
! !