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