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