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