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