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