ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Thu, 22 Oct 2009 23:27:57 +0200
changeset 2677 e2c24a1be97f
parent 2673 100b4dd5c3c2
child 2678 cca2788228ad
permissions -rw-r--r--
changed: #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@2644
   306
    #( 'keyboard.rc' 'keyboardMacros.rc' 'display.rc' 'd_win32.rc'
cg@2644
   307
       'host.rc' 'h_win32.rc'  
cg@2644
   308
    ) do:[:fn |
cg@2644
   309
        (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2644
   310
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2644
   311
    ]
cg@2600
   312
!
cg@2600
   313
cg@2644
   314
copySupportFilesForLinkage
cg@2644
   315
    |files|
cg@2644
   316
cg@2644
   317
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2644
   318
        files := #( 
cg@2644
   319
                    'support/win32/borland/cs3245.dll' 
cg@2644
   320
                    'support/win32/X11.dll'
cg@2644
   321
                    'support/win32/Xext.dll'
cg@2644
   322
                    'librun/librun.dll'
cg@2644
   323
                    'libbc/librun.lib'
cg@2644
   324
                    'libbc/cs32i.lib'
cg@2644
   325
                    'librun/genDate.exe'
cg@2644
   326
                    'librun/main.c'
cg@2673
   327
                    'projects/smalltalk/stx_16x16.ico'
cg@2673
   328
                    'projects/smalltalk/stx_32x32.ico'
cg@2673
   329
                    'projects/smalltalk/stx_splash.bmp'
cg@2644
   330
                 ).
cg@2644
   331
    ] ifFalse:[
cg@2644
   332
        files := #(
cg@2644
   333
                    'librun/genDate'
cg@2644
   334
                    'librun/main.c'
cg@2644
   335
                    'librun/librun.so'
cg@2644
   336
                )
cg@2644
   337
    ].
cg@2677
   338
    files := files asOrderedCollection.
cg@2677
   339
cg@2677
   340
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2677
   341
        projectDefinitionClass applicationIconFileName notNil ifTrue:[
cg@2677
   342
            files add:(projectDefinitionClass applicationIconFileName,'.ico')
cg@2677
   343
        ]
cg@2677
   344
    ].
cg@2644
   345
cg@2644
   346
    files do:[:dllRelativePath |
cg@2644
   347
        ((buildDirectory / 'stx' / dllRelativePath) exists
cg@2644
   348
        and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize
cg@2644
   349
        and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime
cg@2644
   350
        "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
cg@2644
   351
        ]]) ifFalse:[
cg@2644
   352
            (buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
cg@2644
   353
            (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
cg@2644
   354
        ]
cg@2644
   355
    ].
cg@2600
   356
!
cg@2600
   357
cg@2644
   358
createHeaderFileFor:aClass in:packageTargetDir
cg@2644
   359
    |instVarList classInstVarList classVarList bindings superclassFilename
cg@2644
   360
     template file newContents oldContents|
cg@2644
   361
cg@2644
   362
    instVarList := StringCollection new.
cg@2644
   363
    aClass instVarNames do:[:v |
cg@2644
   364
        instVarList add:('OBJ %1;' bindWith:v)
cg@2644
   365
    ].
cg@2644
   366
    classInstVarList := StringCollection new.
cg@2644
   367
    aClass class instVarNames do:[:v |
cg@2644
   368
(v includes:$_) ifTrue:[self halt].
cg@2644
   369
        classInstVarList add:('OBJ %1;' bindWith:v)
cg@2644
   370
    ].
cg@2644
   371
    classVarList := StringCollection new.
cg@2644
   372
    aClass classVarNames do:[:v |
cg@2644
   373
        classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
cg@2644
   374
    ].
cg@2644
   375
cg@2644
   376
    bindings := Dictionary new.
cg@2644
   377
    bindings at:'ClassName' put:aClass name. 
cg@2644
   378
    aClass superclass isNil ifTrue:[
cg@2644
   379
        bindings at:'SuperclassName' put:'-'. 
cg@2644
   380
        bindings at:'SuperclassFileInclude' put:nil.
cg@2644
   381
    ] ifFalse:[
cg@2644
   382
        bindings at:'SuperclassName' put:aClass superclass name. 
cg@2644
   383
        bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
cg@2644
   384
        bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
cg@2644
   385
    ].
cg@2644
   386
    bindings at:'InstVarList' put:instVarList asString. 
cg@2644
   387
    bindings at:'ClassVarList' put:classVarList asString. 
cg@2644
   388
    bindings at:'ClassInstVarList' put:classInstVarList asString. 
cg@2644
   389
cg@2644
   390
    template := 
cg@2644
   391
'/* This file was generated by ProjectBuilder. */
cg@2644
   392
/* !!!!!!!! Do not change by hand !!!!!!!! */
cg@2644
   393
cg@2644
   394
/* Class: %(ClassName) */
cg@2644
   395
/* Superclass: %(SuperclassName) */
cg@2644
   396
cg@2644
   397
%(SuperclassFileInclude)
cg@2644
   398
cg@2644
   399
/* INDIRECTGLOBALS */
cg@2644
   400
#ifdef _HEADER_INST_
cg@2644
   401
%(InstVarList)
cg@2644
   402
#endif /* _HEADER_INST_ */
cg@2644
   403
cg@2644
   404
#ifdef _HEADER_CLASS_
cg@2644
   405
%(ClassVarList)
cg@2644
   406
#endif /* _HEADER_CLASS_ */
cg@2644
   407
cg@2644
   408
#ifdef _HEADER_CLASSINST_
cg@2644
   409
%(ClassInstVarList)
cg@2644
   410
#endif /* _HEADER_CLASSINST_ */
cg@2644
   411
'.
cg@2644
   412
    newContents := template bindWithArguments:bindings.
cg@2644
   413
    file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),'.STH').
cg@2644
   414
    (file exists not
cg@2644
   415
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2644
   416
        file contents: newContents.
cg@2644
   417
    ].
cg@2596
   418
!
cg@2596
   419
cg@2644
   420
generateSourceFiles
cg@2644
   421
    sourceCodeManager notNil ifTrue:[
cg@2644
   422
        "/ check out / generate files there
cg@2644
   423
        self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2644
   424
    ] ifFalse:[
cg@2644
   425
        "/ local build
cg@2644
   426
        "/ fileout the project
cg@2644
   427
        self generateSourceFilesByFilingOut
cg@2644
   428
    ]
cg@2596
   429
!
cg@2596
   430
cg@2644
   431
generateSourceFilesByCheckingOutUsing:aSourceCodeManager
cg@2644
   432
    "/ will no longer be needed/supported
cg@2644
   433
cg@2644
   434
    |repository stxRepository module directory|
cg@2644
   435
cg@2644
   436
self halt.
cg@2644
   437
    "/ check out / generate files there
cg@2644
   438
    repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
cg@2644
   439
    stxRepository := aSourceCodeManager repositoryName.
cg@2644
   440
cg@2644
   441
    (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   442
        (module ~= 'stx') ifTrue:[
cg@2644
   443
            OperatingSystem
cg@2644
   444
                executeCommand:('cvs -d ',stxRepository,' co stx')
cg@2644
   445
                inputFrom:nil
cg@2644
   446
                outputTo:Transcript
cg@2644
   447
                errorTo:Transcript
cg@2644
   448
                inDirectory:buildDirectory
cg@2644
   449
                onError:[:status| self error:'cvs update stx failed'].
cg@2644
   450
        ].
cg@2644
   451
    ].
cg@2644
   452
cg@2644
   453
    ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
cg@2644
   454
        OperatingSystem
cg@2644
   455
            executeCommand:('cvs -d ',repository,' co -l ',directory)
cg@2644
   456
            inputFrom:nil
cg@2644
   457
            outputTo:Transcript
cg@2644
   458
            errorTo:Transcript
cg@2644
   459
            inDirectory:buildDirectory
cg@2644
   460
            onError:[:status| self error:'cvs update failed'].
cg@2644
   461
    ].
cg@2644
   462
    OperatingSystem
cg@2644
   463
        executeCommand:'cvs upd -d'
cg@2644
   464
        inputFrom:nil
cg@2644
   465
        outputTo:Transcript
cg@2644
   466
        errorTo:Transcript
cg@2644
   467
        inDirectory:(buildDirectory construct:module)
cg@2644
   468
        onError:[:status| self error:'cvs update failed'].
cg@2644
   469
self halt.
cg@2596
   470
!
cg@2596
   471
cg@2644
   472
generateSourceFilesByFilingOut
cg@2644
   473
    "/ local build
cg@2644
   474
    "/ fileout the project
cg@2644
   475
cg@2644
   476
    (package module ~= 'stx') ifTrue:[
cg@2644
   477
        (buildDirectory / package module) makeDirectory.
cg@2644
   478
    ].
cg@2644
   479
cg@2644
   480
    "/ file out the package(s) which are to be built
cg@2644
   481
    ((Array with:package))
cg@2644
   482
    do:[:eachPackageToFileout |
cg@2644
   483
        |packageId packageModule packageDirectory packageTargetDir packageDef|
cg@2644
   484
cg@2644
   485
        packageId := eachPackageToFileout asPackageId.
cg@2644
   486
        packageModule := packageId module.
cg@2644
   487
        packageDirectory := packageId directory.
cg@2644
   488
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   489
cg@2644
   490
        packageDef := packageId projectDefinitionClass.
cg@2644
   491
        (packageDef compiled_classNames_common ,
cg@2644
   492
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   493
            |cls fileName newSource|
cg@2644
   494
cg@2644
   495
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   496
            self assert:cls isLoaded.
cg@2644
   497
            fileName := (Smalltalk fileNameForClass:cls),'.st'.
cg@2644
   498
            fileName := packageTargetDir asFilename construct:fileName.
cg@2644
   499
            fileName exists ifTrue:[
cg@2644
   500
                newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
cg@2644
   501
                newSource = fileName contentsAsString ifFalse:[
cg@2644
   502
                    fileName contents:newSource
cg@2644
   503
                ].
cg@2644
   504
            ] ifFalse:[
cg@2644
   505
                cls fileOutIn:packageTargetDir withTimeStamp:false
cg@2644
   506
            ].
cg@2644
   507
        ].
cg@2644
   508
cg@2644
   509
"/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
cg@2644
   510
"/            cls isPrivate ifFalse:[
cg@2644
   511
"/                cls isLoaded ifFalse:[
cg@2644
   512
"/                    self halt.
cg@2644
   513
"/                    cls autoload.
cg@2644
   514
"/                ].
cg@2644
   515
"/                cls fileOutIn:packageTargetDir
cg@2644
   516
"/            ]
cg@2644
   517
"/        ].
cg@2644
   518
cg@2644
   519
        projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
cg@2644
   520
            ((packageTargetDir / fileName) exists
cg@2644
   521
            and:[ (packageTargetDir / fileName) contents = fileContents ]) ifFalse:[
cg@2644
   522
                (packageTargetDir / fileName) contents:fileContents.
cg@2644
   523
            ].
cg@2644
   524
        ].    
cg@2644
   525
    ].
cg@2644
   526
cg@2644
   527
    "/ generate header files in prerequisite packages...
cg@2644
   528
    (projectDefinitionClass allPreRequisites)
cg@2644
   529
    do:[:eachPackageToFileout |
cg@2644
   530
        |packageId packageDef packageModule packageDirectory packageTargetDir|
cg@2644
   531
cg@2644
   532
        packageId := eachPackageToFileout asPackageId.
cg@2644
   533
        packageModule := packageId module.
cg@2644
   534
        packageDirectory := packageId directory.
cg@2644
   535
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   536
cg@2644
   537
        packageDef := packageId projectDefinitionClass.
cg@2644
   538
        (packageDef compiled_classNames_common ,
cg@2644
   539
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   540
            |cls|
cg@2644
   541
cg@2644
   542
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   543
            "/ self assert:cls isLoaded.
cg@2644
   544
            cls isLoaded ifTrue:[    
cg@2644
   545
                self createHeaderFileFor:cls in:packageTargetDir
cg@2644
   546
            ].
cg@2644
   547
        ].
cg@2644
   548
        self copyResourcesForPackage:eachPackageToFileout.
cg@2644
   549
    ].
cg@2644
   550
cg@2644
   551
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   552
!
cg@2596
   553
cg@2644
   554
makeWithOutputTo:stdOut errorTo:stdErr
cg@2644
   555
    |module directory|
cg@2644
   556
cg@2644
   557
    module := package module.
cg@2644
   558
    directory := package directory.
cg@2644
   559
cg@2644
   560
    projectDefinitionClass isLibraryDefinition ifTrue:[
cg@2644
   561
        OperatingSystem
cg@2644
   562
            executeCommand:(ParserFlags makeCommand,' classLibRule')
cg@2644
   563
            inputFrom:nil
cg@2644
   564
            outputTo:stdOut
cg@2644
   565
            errorTo:stdErr
cg@2644
   566
            inDirectory:(buildDirectory / module / directory)
cg@2644
   567
            onError:[:status| self error:'make failed'].
cg@2644
   568
    ] ifFalse:[
cg@2644
   569
        OperatingSystem
cg@2644
   570
            executeCommand:(ParserFlags makeCommand,' exe')
cg@2644
   571
            inputFrom:nil
cg@2644
   572
            outputTo:stdOut
cg@2644
   573
            errorTo:stdErr
cg@2644
   574
            inDirectory:(buildDirectory / module / directory)
cg@2644
   575
            onError:[:status| self error:'make failed'].
cg@2644
   576
cg@2673
   577
        (makeExeOnly ? false) ifFalse:[
cg@2673
   578
            OperatingSystem
cg@2673
   579
                executeCommand:(ParserFlags makeCommand,' setup')
cg@2673
   580
                inputFrom:nil
cg@2673
   581
                outputTo:stdOut
cg@2673
   582
                errorTo:stdErr
cg@2673
   583
                inDirectory:(buildDirectory / module / directory)
cg@2673
   584
                onError:[:status| self error:'make failed'].
cg@2673
   585
        ]
cg@2644
   586
    ]
cg@2611
   587
!
cg@2611
   588
cg@2644
   589
setupBuildDirectory
cg@2644
   590
    buildDirectory exists ifFalse:[
cg@2644
   591
        buildDirectory recursiveMakeDirectory.
cg@2644
   592
    ].
cg@2644
   593
    (buildDirectory / 'stx') exists ifFalse:[
cg@2644
   594
        (buildDirectory / 'stx') makeDirectory.
cg@2644
   595
    ].
cg@2644
   596
cg@2644
   597
    self copyDirectoryForBuild:'include'.
cg@2644
   598
    self copyDirectoryForBuild:'rules'.
cg@2635
   599
!
cg@2596
   600
cg@2644
   601
validateBuildDirectoryIsPresent
cg@2644
   602
cg@2644
   603
    ^ self.
cg@2644
   604
cg@2644
   605
"/    [
cg@2644
   606
"/        |default directoryIsOKForMe stc |
cg@2644
   607
"/
cg@2644
   608
"/        default := (buildDirectory ?
cg@2644
   609
"/                          PreviousBuildDirectory)
cg@2644
   610
"/                          ifNil:[ UserPreferences current buildDirectory].
cg@2644
   611
"/
cg@2644
   612
"/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
cg@2644
   613
"/                                 default:default.
cg@2644
   614
"/
cg@2644
   615
"/        buildDirectory isEmptyOrNil ifTrue:[^ self].
cg@2644
   616
"/        buildDirectory := buildDirectory asFilename.
cg@2644
   617
"/        directoryIsOKForMe := true.
cg@2644
   618
"/
cg@2644
   619
"/        buildDirectory exists ifFalse:[
cg@2644
   620
"/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
cg@2644
   621
"/            directoryIsOKForMe := false.
cg@2644
   622
"/        ] ifTrue:[
cg@2644
   623
"/            (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   624
"/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
cg@2644
   625
"/                directoryIsOKForMe := false.
cg@2644
   626
"/            ] ifTrue:[
cg@2644
   627
"/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
cg@2644
   628
"/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
cg@2644
   629
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
cg@2644
   630
"/                    directoryIsOKForMe := false.
cg@2644
   631
"/                ].
cg@2644
   632
"/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
cg@2644
   633
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
cg@2644
   634
"/                    directoryIsOKForMe := false.
cg@2644
   635
"/                ].
cg@2644
   636
"/            ]
cg@2644
   637
"/        ].
cg@2644
   638
"/        directoryIsOKForMe
cg@2644
   639
"/    ] whileFalse
cg@2596
   640
! !
cg@2596
   641
cg@2596
   642
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
   643
cg@2596
   644
version_CVS
cg@2596
   645
    ^ '$Header$'
cg@2596
   646
! !