ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Fri, 20 Jul 2012 20:15:40 +0200
changeset 2896 6ed90332dbda
parent 2895 2b939399b83b
child 2898 c7f6c498df6a
permissions -rw-r--r--
changed: #copyDLLsForLinkage
cg@2741
     1
"
cg@2741
     2
 COPYRIGHT (c) 2009 by eXept Software AG
cg@2741
     3
              All Rights Reserved
cg@2741
     4
cg@2741
     5
 This software is furnished under a license and may be used
cg@2741
     6
 only in accordance with the terms of that license and with the
cg@2741
     7
 inclusion of the above copyright notice.   This software may not
cg@2741
     8
 be provided or otherwise made available to, or used by, any
cg@2741
     9
 other person.  No title to or ownership of the software is
cg@2741
    10
 hereby transferred.
cg@2741
    11
"
cg@2596
    12
"{ Package: 'stx:libtool2' }"
cg@2596
    13
cg@2635
    14
"{ NameSpace: Tools }"
cg@2635
    15
cg@2596
    16
Object subclass:#ProjectBuilder
cg@2596
    17
	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
cg@2673
    18
		myWorkingDirectory mySTXTopDirectory myTopDirectory outputStream
cg@2680
    19
		makeExeOnly usedCompiler'
cg@2596
    20
	classVariableNames:'PreviousBuildDirectory'
cg@2596
    21
	poolDictionaries:''
cg@2596
    22
	category:'System-Support-Projects'
cg@2596
    23
!
cg@2596
    24
cg@2741
    25
!ProjectBuilder class methodsFor:'documentation'!
cg@2741
    26
cg@2741
    27
copyright
cg@2741
    28
"
cg@2741
    29
 COPYRIGHT (c) 2009 by eXept Software AG
cg@2741
    30
              All Rights Reserved
cg@2741
    31
cg@2741
    32
 This software is furnished under a license and may be used
cg@2741
    33
 only in accordance with the terms of that license and with the
cg@2741
    34
 inclusion of the above copyright notice.   This software may not
cg@2741
    35
 be provided or otherwise made available to, or used by, any
cg@2741
    36
 other person.  No title to or ownership of the software is
cg@2741
    37
 hereby transferred.
cg@2741
    38
"
cg@2741
    39
! !
cg@2596
    40
cg@2633
    41
!ProjectBuilder class methodsFor:'accessing'!
cg@2633
    42
cg@2633
    43
previousBuildDirectory
cg@2633
    44
    ^ PreviousBuildDirectory
cg@2633
    45
!
cg@2633
    46
cg@2633
    47
previousBuildDirectory:something
cg@2633
    48
    PreviousBuildDirectory := something.
cg@2633
    49
! !
cg@2633
    50
cg@2596
    51
!ProjectBuilder class methodsFor:'examples'!
cg@2596
    52
cg@2644
    53
example1
cg@2644
    54
    Smalltalk loadPackage:'stx:projects/helloWorldApp' asAutoloaded:true.
cg@2644
    55
cg@2644
    56
    self new
cg@2644
    57
        package:'stx:projects/helloWorldApp';
cg@2644
    58
        build
cg@2622
    59
!
cg@2622
    60
cg@2644
    61
example2
cg@2644
    62
    |builder|
cg@2644
    63
cg@2644
    64
    Smalltalk loadPackage:'stx:clients/Demos/foxCalcApplication' asAutoloaded:true.
cg@2644
    65
cg@2644
    66
    builder := self new.
cg@2644
    67
    builder package:'stx:clients/Demos/foxCalcApplication'.
cg@2644
    68
    builder build.
cg@2644
    69
cg@2644
    70
    UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
cg@2596
    71
! !
cg@2596
    72
cg@2873
    73
!ProjectBuilder class methodsFor:'queries'!
cg@2873
    74
cg@2873
    75
defaultUsedCompiler
cg@2873
    76
    |compiler|
cg@2873
    77
cg@2873
    78
    (compiler := UserPreferences current usedCompilerForBuild) notNil ifTrue:[
cg@2873
    79
        ^ compiler
cg@2873
    80
    ].
cg@2873
    81
cg@2873
    82
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2873
    83
        ^ 'bcc'
cg@2873
    84
    ].
cg@2873
    85
    ^ 'gcc'
cg@2873
    86
cg@2873
    87
    "Created: / 21-01-2012 / 14:06:51 / cg"
cg@2873
    88
!
cg@2873
    89
cg@2873
    90
listOfPossibleCompilers
cg@2873
    91
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2873
    92
        ^ #('bcc' 'vc' 'lcc' 'gcc' )
cg@2873
    93
    ].
cg@2873
    94
    ^ #('gcc')
cg@2873
    95
cg@2873
    96
    "Created: / 21-01-2012 / 14:04:15 / cg"
cg@2873
    97
! !
cg@2873
    98
cg@2596
    99
!ProjectBuilder methodsFor:'accessing'!
cg@2596
   100
cg@2644
   101
buildDirectory
cg@2644
   102
    ^ buildDirectory
cg@2622
   103
!
cg@2622
   104
cg@2634
   105
buildDirectory:something
cg@2634
   106
    buildDirectory := something.
cg@2634
   107
!
cg@2634
   108
cg@2673
   109
makeExeOnly:aBoolean
cg@2673
   110
    makeExeOnly := aBoolean.
cg@2673
   111
!
cg@2673
   112
cg@2644
   113
package:aPackageIDOrSymbol
cg@2644
   114
    package := aPackageIDOrSymbol asPackageId.
cg@2596
   115
!
cg@2596
   116
cg@2644
   117
packageBuildDirectory
cg@2644
   118
    "the directoray, where the deployable binary is created (xxxSetup.exe)"
cg@2622
   119
cg@2622
   120
    ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
cg@2635
   121
!
cg@2635
   122
cg@2644
   123
projectDefinitionClass:something
cg@2644
   124
    projectDefinitionClass := something.
cg@2680
   125
!
cg@2680
   126
sr@2683
   127
suffixForHeaderFiles
sr@2683
   128
    ^ OperatingSystem isUNIXlike ifTrue:['.H'] ifFalse:['.STH']
sr@2683
   129
!
sr@2683
   130
cg@2873
   131
usedCompilerForBuild:something
cg@2680
   132
    usedCompiler := something.
cg@2873
   133
cg@2873
   134
    "Created: / 22-01-2012 / 10:50:48 / cg"
cg@2596
   135
! !
cg@2596
   136
cg@2596
   137
!ProjectBuilder methodsFor:'building'!
cg@2596
   138
cg@2644
   139
build
cg@2644
   140
    "/ intermediate - this will move into a commonly used utility class
cg@2635
   141
    "/ (where all the project code support will be collected).
cg@2635
   142
cg@2647
   143
    |makeOutput|
cg@2647
   144
cg@2647
   145
    makeOutput := TextStream on:(Text new:10000).
cg@2647
   146
    self buildWithColorizedOutputTo:makeOutput.
cg@2647
   147
cg@2647
   148
    TextView openWith:makeOutput contents.
cg@2647
   149
!
cg@2647
   150
cg@2647
   151
buildWithColorizedOutputTo:makeOutput
cg@2647
   152
    "/ intermediate - this will move into a commonly used utility class
cg@2647
   153
    "/ (where all the project code support will be collected).
cg@2647
   154
cg@2647
   155
    |stdOut stdErr lock|
cg@2635
   156
cg@2644
   157
    lock := Semaphore forMutualExclusion.
cg@2647
   158
cg@2644
   159
    stdErr := ActorStream new
cg@2644
   160
                    nextPutBlock:[:char |
cg@2644
   161
                        lock critical:[
cg@2644
   162
                            makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}.
cg@2644
   163
                            makeOutput nextPut:char.
cg@2644
   164
                            makeOutput emphasis:nil.
cg@2644
   165
                        ]
cg@2644
   166
                    ];
sr@2683
   167
                    nextPutAllBlock:[:string |
cg@2873
   168
                        lock critical:[          
cg@2873
   169
                            "/ (string includesString:'das Ziel' )ifTrue:[self halt].
cg@2644
   170
                            makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}.
sr@2683
   171
                            makeOutput nextPutAll:string.
cg@2644
   172
                            makeOutput emphasis:nil.
cg@2644
   173
                        ]
cg@2644
   174
                    ].
cg@2644
   175
    stdOut := ActorStream new
cg@2644
   176
                    nextPutBlock:[:char |
cg@2644
   177
                        lock critical:[
cg@2644
   178
                            makeOutput nextPut:char.
cg@2644
   179
                        ]
cg@2644
   180
                    ];
sr@2683
   181
                    nextPutAllBlock:[:string |
cg@2873
   182
                        lock critical:[         
cg@2873
   183
                            "/ (string includesString:'das Ziel' )ifTrue:[self halt].
sr@2683
   184
                            makeOutput nextPutAll:string.
cg@2644
   185
                        ]
cg@2644
   186
                    ].
cg@2635
   187
cg@2644
   188
    self buildWithOutputTo:stdOut errorTo:stdErr.
cg@2873
   189
cg@2873
   190
    "Modified: / 21-01-2012 / 13:49:13 / cg"
cg@2611
   191
!
cg@2611
   192
cg@2611
   193
buildWithOutputTo:stdOut errorTo:stdErr
cg@2611
   194
    "/ intermediate - this will move into a commonly used utility class
cg@2611
   195
    "/ (where all the project code support will be collected).
cg@2611
   196
cg@2596
   197
    |module directory|
cg@2596
   198
cg@2596
   199
    projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
cg@2596
   200
    projectDefinitionClass isNil ifTrue:[
cg@2596
   201
        self error:('Missing ProjectDefinition class for "',package asString,'"')
cg@2596
   202
    ].
cg@2596
   203
cg@2596
   204
    "/ ensure that everything is loaded...
cg@2596
   205
    projectDefinitionClass loadAsAutoloaded:false.
cg@2596
   206
    projectDefinitionClass loadExtensions.
cg@2596
   207
    projectDefinitionClass loadAllClassesAsAutoloaded:false.
cg@2596
   208
cg@2596
   209
    module := package module.
cg@2596
   210
    directory := package directory.
cg@2596
   211
cg@2596
   212
    buildDirectory isNil ifTrue:[
cg@2634
   213
        buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
cg@2634
   214
        buildDirectory isNil ifTrue:[
cg@2634
   215
            buildDirectory := Filename tempDirectory construct:'stx_build'.
cg@2634
   216
        ].
cg@2596
   217
    ].
cg@2596
   218
    buildDirectory := buildDirectory asFilename.
cg@2596
   219
cg@2596
   220
    "/ self validateBuildDirectoryIsPresent.
cg@2596
   221
cg@2596
   222
    PreviousBuildDirectory := buildDirectory.
cg@2596
   223
cg@2596
   224
    "/ UserPreferences current localBuild:true
cg@2596
   225
    UserPreferences current localBuild ifFalse:[
cg@2596
   226
        SourceCodeManager notNil ifTrue:[
sv@2861
   227
            sourceCodeManager := SourceCodeManagerUtilities default sourceCodeManagerFor:projectDefinitionClass.
cg@2596
   228
        ]
cg@2596
   229
    ].
cg@2596
   230
    sourceCodeManager := nil.
cg@2596
   231
cg@2598
   232
    myTopDirectory := 
cg@2596
   233
        Smalltalk packagePath 
cg@2596
   234
            detect:[:aPath |
cg@2596
   235
                (aPath asFilename / 'stx' / 'include') exists
cg@2596
   236
                and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
cg@2596
   237
            ifNone:nil.       
cg@2598
   238
    myTopDirectory isNil ifTrue:[
cg@2598
   239
        self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
cg@2596
   240
    ].
cg@2598
   241
    myTopDirectory := myTopDirectory asFilename.
cg@2598
   242
    mySTXTopDirectory := myTopDirectory / 'stx'.
cg@2613
   243
cg@2596
   244
    self setupBuildDirectory.
cg@2628
   245
    self activityNotification:'Generating stc directory...'.
cg@2599
   246
    self copySTCDirectoryForBuild.
cg@2628
   247
    self activityNotification:'Generating source files...'.
cg@2596
   248
    self generateSourceFiles.
cg@2672
   249
    self activityNotification:'Copying dlls for linkage...'.
cg@2600
   250
    self copyDLLsForLinkage.
cg@2672
   251
    self activityNotification:'Copying support files for linkage...'.
cg@2600
   252
    self copySupportFilesForLinkage.
cg@2600
   253
    self copyStartupFilesFromSmalltalk.
cg@2596
   254
cg@2628
   255
    self activityNotification:'Executing make...'.
cg@2611
   256
    self makeWithOutputTo:stdOut errorTo:stdErr.
cg@2596
   257
!
cg@2596
   258
cg@2644
   259
copyDLLsForLinkage
sv@2723
   260
    |targetBuildDir preRequisites dllRelativePaths|
sv@2723
   261
cg@2644
   262
cg@2644
   263
    targetBuildDir := buildDirectory / package module / package directory.
cg@2644
   264
sv@2723
   265
    preRequisites := projectDefinitionClass allPreRequisites.
sv@2723
   266
    OperatingSystem isUNIXlike ifTrue:[
sv@2723
   267
        "For now: unix Makefiles require some libs implicitely..."
sv@2723
   268
        preRequisites := preRequisites union:#(
sv@2723
   269
                               'stx:goodies/refactoryBrowser/parser'
sv@2723
   270
                               'stx:libtool'
sv@2723
   271
                            ).
sv@2723
   272
    ].
sv@2723
   273
sv@2723
   274
    preRequisites do:[:eachPackageToFileout |
cg@2644
   275
        |packageId packageDef packageModule packageDirectory packageTargetDir
cg@2644
   276
         dllSource dllSourceDir libraryName dllRelativePath|
cg@2644
   277
cg@2644
   278
        packageId := eachPackageToFileout asPackageId.
cg@2644
   279
        packageModule := packageId module.
cg@2644
   280
        packageDirectory := packageId directory.
cg@2644
   281
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   282
cg@2644
   283
        packageDef := packageId projectDefinitionClass.
cg@2644
   284
        libraryName := packageDef libraryName.
cg@2644
   285
cg@2644
   286
        "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
cg@2644
   287
        dllSourceDir := myTopDirectory / packageModule / packageDirectory.
cg@2644
   288
        OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2644
   289
"/            dllRelativePath := 'objvc','/',(libraryName,'.dll').
cg@2644
   290
"/            (dllSourceDir / dllRelativePath) exists 
sv@2723
   291
            dllRelativePaths := Array with:('objbc\', libraryName, '.dll').
cg@2644
   292
        ] ifFalse:[
sv@2723
   293
            dllRelativePaths := Array with:(libraryName,'.so').
sv@2723
   294
            (packageModule = 'stx' and:[packageDirectory = 'libview']) ifTrue:[
sv@2723
   295
                dllRelativePaths := dllRelativePaths, #('XWorkstation.so' 'GLXWorkstation.so').
sv@2723
   296
            ].
cg@2644
   297
        ].
sv@2723
   298
        dllRelativePaths do:[:dllRelativePath|
cg@2896
   299
            |source dest|
cg@2896
   300
cg@2896
   301
            source := dllSourceDir / dllRelativePath.
cg@2896
   302
            dest := packageTargetDir / dllRelativePath.
cg@2896
   303
            (dest exists not
cg@2896
   304
             or:[source fileSize ~= dest fileSize
cg@2896
   305
             or:[source modificationTime >= dest modificationTime
sv@2723
   306
             "/ or:[ ((dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath)) not ]
sv@2723
   307
            ]]) ifTrue:[
cg@2896
   308
                Transcript showCR:'updating ',dllRelativePath.
cg@2896
   309
                dest directory recursiveMakeDirectory.
cg@2896
   310
                source copyTo:dest.    
sv@2723
   311
            ].
sv@2723
   312
        ].
cg@2614
   313
    ].
cg@2896
   314
cg@2896
   315
    "Modified: / 20-07-2012 / 18:30:06 / cg"
cg@2600
   316
!
cg@2600
   317
cg@2644
   318
copyDirectory:relativepath
cg@2644
   319
    "/ need rules in stx
cg@2644
   320
    ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
cg@2644
   321
        recursiveCopyTo:(buildDirectory construct:'stx').
cg@2596
   322
!
cg@2596
   323
cg@2644
   324
copyDirectoryForBuild:subdir
cg@2644
   325
    |targetDir targetFile|
cg@2644
   326
cg@2644
   327
    targetDir := buildDirectory / 'stx' / subdir.
cg@2644
   328
    targetDir exists ifFalse:[
cg@2644
   329
        targetDir makeDirectory.
cg@2644
   330
    ].
cg@2644
   331
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
cg@2644
   332
        eachFile isDirectory ifFalse:[
cg@2644
   333
            targetFile := targetDir / eachFile baseName.
cg@2644
   334
            (targetFile exists not
cg@2644
   335
            or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
cg@2644
   336
                self activityNotification:'copying ',eachFile pathName,'...'.
cg@2644
   337
                eachFile copyTo:(targetDir construct:eachFile baseName)
cg@2644
   338
            ]
cg@2644
   339
        ].
cg@2644
   340
    ].
cg@2644
   341
    self activityNotification:nil
cg@2598
   342
!
cg@2598
   343
cg@2644
   344
copyResourcesForPackage:aPackage
cg@2644
   345
    |module directory|
cg@2644
   346
cg@2644
   347
    module := aPackage asPackageId module.
cg@2644
   348
    directory := aPackage asPackageId directory.
cg@2644
   349
cg@2644
   350
    (myTopDirectory / module / directory / 'resources' ) exists ifTrue:[
cg@2644
   351
        (myTopDirectory / module / directory / 'resources' )
cg@2644
   352
            recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   353
    ].
cg@2644
   354
    (myTopDirectory / module / directory / 'styles' ) exists ifTrue:[
cg@2644
   355
        (myTopDirectory / module / directory / 'styles' )
cg@2644
   356
            recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   357
    ].
cg@2600
   358
!
cg@2600
   359
cg@2644
   360
copySTCDirectoryForBuild
cg@2644
   361
    |targetDir stc files|
cg@2644
   362
cg@2644
   363
    targetDir := buildDirectory / 'stx' / 'stc'.
cg@2644
   364
    targetDir exists ifFalse:[ targetDir makeDirectory ].
cg@2644
   365
cg@2644
   366
    stc := OperatingSystem isMSWINDOWSlike 
cg@2644
   367
                ifTrue:[ 'stc.exe' ]
cg@2644
   368
                ifFalse:[ 'stc' ].
cg@2644
   369
cg@2644
   370
    files := #( ) copyWith:stc.
cg@2644
   371
cg@2644
   372
    files do:[:eachFile |
cg@2644
   373
        |sourceFile targetFile|
cg@2644
   374
cg@2644
   375
        sourceFile := mySTXTopDirectory / 'stc' / eachFile.
cg@2644
   376
        targetFile := targetDir / eachFile.
cg@2644
   377
        (targetFile exists not
cg@2644
   378
        or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
cg@2644
   379
            self activityNotification:'copying ',sourceFile pathName,'...'.
cg@2644
   380
            sourceFile copyTo:targetFile
cg@2644
   381
        ].
cg@2644
   382
    ].
sr@2683
   383
sr@2683
   384
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
   385
        (targetDir / 'stc') makeExecutableForAll    
sr@2683
   386
    ].
sr@2683
   387
cg@2644
   388
    self activityNotification:nil
cg@2599
   389
!
cg@2599
   390
cg@2644
   391
copyStartupFilesFromSmalltalk
cg@2644
   392
    (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
cg@2644
   393
        (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
cg@2644
   394
    ].
cg@2644
   395
cg@2678
   396
    #( 
cg@2678
   397
        'keyboard.rc' 
cg@2678
   398
        'keyboardMacros.rc' 
cg@2678
   399
        'display.rc' 
cg@2678
   400
        'd_win32.rc'
cg@2678
   401
        'host.rc' 
cg@2678
   402
        'h_win32.rc'  
cg@2678
   403
        'smalltalk.rc'  
cg@2678
   404
        'private.rc'  
cg@2644
   405
    ) do:[:fn |
cg@2644
   406
        (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2644
   407
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2678
   408
    ].
cg@2678
   409
cg@2678
   410
    (myTopDirectory / 'stx' / 'doc/online/english/LICENCE_STX.html')
cg@2678
   411
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / 'LICENCE_STX.html').
cg@2600
   412
!
cg@2600
   413
cg@2644
   414
copySupportFilesForLinkage
cg@2644
   415
    |files|
cg@2644
   416
cg@2644
   417
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2644
   418
        files := #( 
cg@2644
   419
                    'support/win32/borland/cs3245.dll' 
cg@2644
   420
                    'support/win32/X11.dll'
cg@2644
   421
                    'support/win32/Xext.dll'
cg@2873
   422
                    'librun/objbc/librun.dll'
cg@2644
   423
                    'libbc/librun.lib'
cg@2644
   424
                    'libbc/cs32i.lib'
cg@2644
   425
                    'librun/genDate.exe'
cg@2644
   426
                    'librun/main.c'
cg@2673
   427
                    'projects/smalltalk/stx_16x16.ico'
cg@2673
   428
                    'projects/smalltalk/stx_32x32.ico'
cg@2673
   429
                    'projects/smalltalk/stx_splash.bmp'
cg@2644
   430
                 ).
cg@2644
   431
    ] ifFalse:[
cg@2644
   432
        files := #(
cg@2644
   433
                    'librun/main.c'
cg@2644
   434
                    'librun/librun.so'
cg@2644
   435
                )
cg@2644
   436
    ].
cg@2677
   437
    files := files asOrderedCollection.
cg@2677
   438
cg@2677
   439
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2677
   440
        projectDefinitionClass applicationIconFileName notNil ifTrue:[
cg@2678
   441
            files add:('projects/smalltalk/',projectDefinitionClass applicationIconFileName,'.ico')
cg@2678
   442
        ].
cg@2678
   443
        projectDefinitionClass splashFileName notNil ifTrue:[
cg@2678
   444
            files add:('projects/smalltalk/',projectDefinitionClass splashFileName,'.bmp')
cg@2678
   445
        ].
cg@2677
   446
    ].
cg@2644
   447
cg@2644
   448
    files do:[:dllRelativePath |
sr@2684
   449
        (mySTXTopDirectory / dllRelativePath) exists ifTrue:[
sr@2684
   450
            ((buildDirectory / 'stx' / dllRelativePath) exists
sr@2684
   451
            and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize
sr@2684
   452
            and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime
sr@2684
   453
            "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
sr@2684
   454
            ]]) ifFalse:[
sr@2684
   455
                (buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
sr@2684
   456
                (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
sr@2684
   457
            ]
sr@2684
   458
        ] ifFalse:[
sr@2684
   459
            self error:'Missing file: ',dllRelativePath printString mayProceed:true.
sr@2684
   460
        ].
cg@2644
   461
    ].
cg@2873
   462
cg@2873
   463
    "Modified: / 21-01-2012 / 13:40:56 / cg"
cg@2600
   464
!
cg@2600
   465
cg@2644
   466
createHeaderFileFor:aClass in:packageTargetDir
cg@2644
   467
    |instVarList classInstVarList classVarList bindings superclassFilename
cg@2644
   468
     template file newContents oldContents|
cg@2644
   469
cg@2644
   470
    instVarList := StringCollection new.
cg@2644
   471
    aClass instVarNames do:[:v |
cg@2644
   472
        instVarList add:('OBJ %1;' bindWith:v)
cg@2644
   473
    ].
cg@2644
   474
    classInstVarList := StringCollection new.
cg@2644
   475
    aClass class instVarNames do:[:v |
cg@2644
   476
(v includes:$_) ifTrue:[self halt].
cg@2644
   477
        classInstVarList add:('OBJ %1;' bindWith:v)
cg@2644
   478
    ].
cg@2644
   479
    classVarList := StringCollection new.
cg@2644
   480
    aClass classVarNames do:[:v |
cg@2644
   481
        classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
cg@2644
   482
    ].
cg@2644
   483
cg@2644
   484
    bindings := Dictionary new.
cg@2644
   485
    bindings at:'ClassName' put:aClass name. 
cg@2644
   486
    aClass superclass isNil ifTrue:[
cg@2644
   487
        bindings at:'SuperclassName' put:'-'. 
cg@2852
   488
        bindings at:'SuperclassFileInclude' put:''.
cg@2644
   489
    ] ifFalse:[
cg@2644
   490
        bindings at:'SuperclassName' put:aClass superclass name. 
cg@2644
   491
        bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
cg@2644
   492
        bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
cg@2644
   493
    ].
cg@2644
   494
    bindings at:'InstVarList' put:instVarList asString. 
cg@2644
   495
    bindings at:'ClassVarList' put:classVarList asString. 
cg@2644
   496
    bindings at:'ClassInstVarList' put:classInstVarList asString. 
cg@2644
   497
cg@2644
   498
    template := 
cg@2644
   499
'/* This file was generated by ProjectBuilder. */
cg@2644
   500
/* !!!!!!!! Do not change by hand !!!!!!!! */
cg@2644
   501
cg@2644
   502
/* Class: %(ClassName) */
cg@2644
   503
/* Superclass: %(SuperclassName) */
cg@2644
   504
cg@2644
   505
%(SuperclassFileInclude)
cg@2644
   506
cg@2644
   507
/* INDIRECTGLOBALS */
cg@2644
   508
#ifdef _HEADER_INST_
cg@2644
   509
%(InstVarList)
cg@2644
   510
#endif /* _HEADER_INST_ */
cg@2644
   511
cg@2644
   512
#ifdef _HEADER_CLASS_
cg@2644
   513
%(ClassVarList)
cg@2644
   514
#endif /* _HEADER_CLASS_ */
cg@2644
   515
cg@2644
   516
#ifdef _HEADER_CLASSINST_
cg@2644
   517
%(ClassInstVarList)
cg@2644
   518
#endif /* _HEADER_CLASSINST_ */
cg@2644
   519
'.
cg@2644
   520
    newContents := template bindWithArguments:bindings.
sr@2683
   521
    file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
cg@2644
   522
    (file exists not
cg@2644
   523
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2644
   524
        file contents: newContents.
cg@2644
   525
    ].
cg@2852
   526
cg@2852
   527
    "Modified: / 15-08-2011 / 14:58:46 / cg"
cg@2596
   528
!
cg@2596
   529
cg@2644
   530
generateSourceFiles
cg@2644
   531
    sourceCodeManager notNil ifTrue:[
cg@2644
   532
        "/ check out / generate files there
cg@2644
   533
        self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2644
   534
    ] ifFalse:[
cg@2644
   535
        "/ local build
cg@2644
   536
        "/ fileout the project
cg@2644
   537
        self generateSourceFilesByFilingOut
cg@2644
   538
    ]
cg@2596
   539
!
cg@2596
   540
cg@2644
   541
generateSourceFilesByCheckingOutUsing:aSourceCodeManager
cg@2644
   542
    "/ will no longer be needed/supported
cg@2644
   543
cg@2644
   544
    |repository stxRepository module directory|
cg@2644
   545
cg@2868
   546
    self breakPoint:#cg.
cg@2868
   547
cg@2644
   548
    "/ check out / generate files there
cg@2644
   549
    repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
cg@2644
   550
    stxRepository := aSourceCodeManager repositoryName.
cg@2644
   551
cg@2644
   552
    (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   553
        (module ~= 'stx') ifTrue:[
cg@2644
   554
            OperatingSystem
cg@2644
   555
                executeCommand:('cvs -d ',stxRepository,' co stx')
cg@2644
   556
                inputFrom:nil
cg@2644
   557
                outputTo:Transcript
cg@2644
   558
                errorTo:Transcript
cg@2644
   559
                inDirectory:buildDirectory
cg@2644
   560
                onError:[:status| self error:'cvs update stx failed'].
cg@2644
   561
        ].
cg@2644
   562
    ].
cg@2644
   563
cg@2644
   564
    ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
cg@2644
   565
        OperatingSystem
cg@2644
   566
            executeCommand:('cvs -d ',repository,' co -l ',directory)
cg@2644
   567
            inputFrom:nil
cg@2644
   568
            outputTo:Transcript
cg@2644
   569
            errorTo:Transcript
cg@2644
   570
            inDirectory:buildDirectory
cg@2644
   571
            onError:[:status| self error:'cvs update failed'].
cg@2644
   572
    ].
cg@2644
   573
    OperatingSystem
cg@2644
   574
        executeCommand:'cvs upd -d'
cg@2644
   575
        inputFrom:nil
cg@2644
   576
        outputTo:Transcript
cg@2644
   577
        errorTo:Transcript
cg@2644
   578
        inDirectory:(buildDirectory construct:module)
cg@2644
   579
        onError:[:status| self error:'cvs update failed'].
cg@2644
   580
self halt.
cg@2868
   581
cg@2868
   582
    "Modified: / 29-12-2011 / 14:02:56 / cg"
cg@2596
   583
!
cg@2596
   584
cg@2644
   585
generateSourceFilesByFilingOut
cg@2644
   586
    "/ local build
cg@2644
   587
    "/ fileout the project
cg@2644
   588
sv@2844
   589
    |fullPathName|
sv@2844
   590
cg@2644
   591
    (package module ~= 'stx') ifTrue:[
cg@2644
   592
        (buildDirectory / package module) makeDirectory.
cg@2644
   593
    ].
cg@2644
   594
cg@2644
   595
    "/ file out the package(s) which are to be built
cg@2644
   596
    ((Array with:package))
cg@2644
   597
    do:[:eachPackageToFileout |
cg@2644
   598
        |packageId packageModule packageDirectory packageTargetDir packageDef|
cg@2644
   599
cg@2644
   600
        packageId := eachPackageToFileout asPackageId.
cg@2644
   601
        packageModule := packageId module.
cg@2644
   602
        packageDirectory := packageId directory.
cg@2644
   603
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   604
cg@2644
   605
        packageDef := packageId projectDefinitionClass.
cg@2644
   606
        (packageDef compiled_classNames_common ,
cg@2644
   607
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   608
            |cls fileName newSource|
cg@2644
   609
cg@2644
   610
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   611
            self assert:cls isLoaded.
cg@2644
   612
            fileName := (Smalltalk fileNameForClass:cls),'.st'.
cg@2644
   613
            fileName := packageTargetDir asFilename construct:fileName.
cg@2644
   614
            fileName exists ifTrue:[
cg@2644
   615
                newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
cg@2644
   616
                newSource = fileName contentsAsString ifFalse:[
cg@2644
   617
                    fileName contents:newSource
cg@2644
   618
                ].
cg@2644
   619
            ] ifFalse:[
cg@2644
   620
                cls fileOutIn:packageTargetDir withTimeStamp:false
cg@2644
   621
            ].
cg@2644
   622
        ].
cg@2644
   623
cg@2644
   624
"/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
cg@2644
   625
"/            cls isPrivate ifFalse:[
cg@2644
   626
"/                cls isLoaded ifFalse:[
cg@2644
   627
"/                    self halt.
cg@2644
   628
"/                    cls autoload.
cg@2644
   629
"/                ].
cg@2644
   630
"/                cls fileOutIn:packageTargetDir
cg@2644
   631
"/            ]
cg@2644
   632
"/        ].
cg@2644
   633
cg@2644
   634
        projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
sv@2844
   635
            fullPathName := packageTargetDir construct:fileName.
sv@2844
   636
            fullPathName directory exists ifFalse:[
sv@2844
   637
                "take care for files like 'autopackage/default.apspec'"
sv@2844
   638
                fullPathName directory makeDirectory.
sv@2844
   639
            ].
sv@2844
   640
            (fullPathName exists
sv@2844
   641
             and:[ fullPathName contents = fileContents ]) ifFalse:[
sv@2844
   642
                fullPathName contents:fileContents.
cg@2644
   643
            ].
cg@2644
   644
        ].    
cg@2644
   645
    ].
cg@2644
   646
cg@2644
   647
    "/ generate header files in prerequisite packages...
cg@2644
   648
    (projectDefinitionClass allPreRequisites)
cg@2644
   649
    do:[:eachPackageToFileout |
cg@2644
   650
        |packageId packageDef packageModule packageDirectory packageTargetDir|
cg@2644
   651
cg@2644
   652
        packageId := eachPackageToFileout asPackageId.
cg@2644
   653
        packageModule := packageId module.
cg@2644
   654
        packageDirectory := packageId directory.
cg@2644
   655
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   656
cg@2644
   657
        packageDef := packageId projectDefinitionClass.
cg@2644
   658
        (packageDef compiled_classNames_common ,
cg@2644
   659
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   660
            |cls|
cg@2644
   661
cg@2644
   662
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   663
            "/ self assert:cls isLoaded.
cg@2644
   664
            cls isLoaded ifTrue:[    
cg@2644
   665
                self createHeaderFileFor:cls in:packageTargetDir
cg@2644
   666
            ].
cg@2644
   667
        ].
cg@2644
   668
        self copyResourcesForPackage:eachPackageToFileout.
cg@2644
   669
    ].
cg@2644
   670
cg@2644
   671
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   672
!
cg@2596
   673
cg@2644
   674
makeWithOutputTo:stdOut errorTo:stdErr
cg@2680
   675
    |module directory compilerFlag makeCommand|
cg@2644
   676
cg@2644
   677
    module := package module.
cg@2644
   678
    directory := package directory.
cg@2644
   679
cg@2680
   680
    makeCommand := ParserFlags makeCommand.
cg@2895
   681
    usedCompiler isNil ifTrue:[
cg@2895
   682
        usedCompiler := ParserFlags usedCompiler.
cg@2895
   683
    ].
cg@2873
   684
    usedCompiler = 'vc' ifTrue:[ 
cg@2873
   685
        makeCommand := 'vcmake'. "/ compilerFlag := '-DUSEVC' 
cg@2873
   686
    ] ifFalse:[
cg@2873
   687
        usedCompiler = 'lcc' ifTrue:[ 
cg@2873
   688
            makeCommand := 'lcmake'. "/ compilerFlag := '-DUSELCC' 
cg@2873
   689
        ] ifFalse:[
cg@2873
   690
            usedCompiler = 'gcc' ifTrue:[ 
cg@2873
   691
                makeCommand := 'make'. 
cg@2873
   692
            ] ifFalse:[
cg@2873
   693
                usedCompiler = 'bcc' ifTrue:[ 
cg@2873
   694
                    makeCommand := 'bmake'.
cg@2873
   695
                ] ifFalse:[
cg@2895
   696
                    self error:'no compiler specified'.
cg@2873
   697
                ]
cg@2873
   698
            ]
cg@2873
   699
        ]
cg@2873
   700
    ].
cg@2873
   701
cg@2852
   702
    "/ makeCommand := makeCommand, ' TOP=', mySTXTopDirectory pathName.
cg@2680
   703
sr@2683
   704
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
   705
        OperatingSystem
sv@2845
   706
            executeCommand:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName)
sr@2683
   707
            inputFrom:nil
sr@2683
   708
            outputTo:stdOut
sr@2683
   709
            errorTo:stdErr
sr@2683
   710
            inDirectory:(buildDirectory / module / directory)
sr@2683
   711
            onError:[:status| self error:'make failed'].
sr@2683
   712
    ].
sr@2683
   713
cg@2644
   714
    projectDefinitionClass isLibraryDefinition ifTrue:[
cg@2644
   715
        OperatingSystem
cg@2680
   716
            executeCommand:(makeCommand,' classLibRule')
cg@2644
   717
            inputFrom:nil
cg@2644
   718
            outputTo:stdOut
cg@2644
   719
            errorTo:stdErr
cg@2644
   720
            inDirectory:(buildDirectory / module / directory)
cg@2644
   721
            onError:[:status| self error:'make failed'].
cg@2644
   722
    ] ifFalse:[
cg@2644
   723
        OperatingSystem
cg@2680
   724
            executeCommand:(makeCommand,' exe')
cg@2644
   725
            inputFrom:nil
cg@2644
   726
            outputTo:stdOut
cg@2644
   727
            errorTo:stdErr
cg@2644
   728
            inDirectory:(buildDirectory / module / directory)
cg@2644
   729
            onError:[:status| self error:'make failed'].
cg@2644
   730
cg@2673
   731
        (makeExeOnly ? false) ifFalse:[
cg@2673
   732
            OperatingSystem
cg@2680
   733
                executeCommand:(makeCommand,' setup')
cg@2673
   734
                inputFrom:nil
cg@2673
   735
                outputTo:stdOut
cg@2673
   736
                errorTo:stdErr
cg@2673
   737
                inDirectory:(buildDirectory / module / directory)
cg@2673
   738
                onError:[:status| self error:'make failed'].
cg@2673
   739
        ]
cg@2644
   740
    ]
cg@2793
   741
cg@2895
   742
    "Modified: / 20-07-2012 / 12:13:29 / cg"
cg@2611
   743
!
cg@2611
   744
sr@2683
   745
recursiveCopyDirectoryForBuild:subdir
sr@2683
   746
    |targetDir|
sr@2683
   747
sr@2683
   748
    targetDir := buildDirectory / 'stx' / subdir.
sr@2683
   749
    targetDir exists ifFalse:[
sr@2683
   750
        targetDir makeDirectory.
sr@2683
   751
    ].
sr@2683
   752
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
sr@2683
   753
        eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
sr@2683
   754
    ].
sr@2683
   755
    self activityNotification:nil
sr@2683
   756
!
sr@2683
   757
cg@2644
   758
setupBuildDirectory
cg@2644
   759
    buildDirectory exists ifFalse:[
cg@2644
   760
        buildDirectory recursiveMakeDirectory.
cg@2644
   761
    ].
cg@2644
   762
    (buildDirectory / 'stx') exists ifFalse:[
cg@2644
   763
        (buildDirectory / 'stx') makeDirectory.
cg@2644
   764
    ].
cg@2644
   765
cg@2644
   766
    self copyDirectoryForBuild:'include'.
cg@2644
   767
    self copyDirectoryForBuild:'rules'.
sr@2683
   768
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
   769
        self recursiveCopyDirectoryForBuild:'configurations'.
sr@2683
   770
    ]
cg@2635
   771
!
cg@2596
   772
cg@2644
   773
validateBuildDirectoryIsPresent
cg@2644
   774
cg@2644
   775
    ^ self.
cg@2644
   776
cg@2644
   777
"/    [
cg@2644
   778
"/        |default directoryIsOKForMe stc |
cg@2644
   779
"/
cg@2644
   780
"/        default := (buildDirectory ?
cg@2644
   781
"/                          PreviousBuildDirectory)
cg@2644
   782
"/                          ifNil:[ UserPreferences current buildDirectory].
cg@2644
   783
"/
cg@2644
   784
"/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
cg@2644
   785
"/                                 default:default.
cg@2644
   786
"/
cg@2644
   787
"/        buildDirectory isEmptyOrNil ifTrue:[^ self].
cg@2644
   788
"/        buildDirectory := buildDirectory asFilename.
cg@2644
   789
"/        directoryIsOKForMe := true.
cg@2644
   790
"/
cg@2644
   791
"/        buildDirectory exists ifFalse:[
cg@2644
   792
"/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
cg@2644
   793
"/            directoryIsOKForMe := false.
cg@2644
   794
"/        ] ifTrue:[
cg@2644
   795
"/            (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   796
"/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
cg@2644
   797
"/                directoryIsOKForMe := false.
cg@2644
   798
"/            ] ifTrue:[
cg@2644
   799
"/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
cg@2644
   800
"/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
cg@2644
   801
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
cg@2644
   802
"/                    directoryIsOKForMe := false.
cg@2644
   803
"/                ].
cg@2644
   804
"/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
cg@2644
   805
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
cg@2644
   806
"/                    directoryIsOKForMe := false.
cg@2644
   807
"/                ].
cg@2644
   808
"/            ]
cg@2644
   809
"/        ].
cg@2644
   810
"/        directoryIsOKForMe
cg@2644
   811
"/    ] whileFalse
cg@2596
   812
! !
cg@2596
   813
cg@2596
   814
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
   815
cg@2896
   816
version
cg@2896
   817
    ^ '$Header$'
cg@2896
   818
!
cg@2896
   819
cg@2596
   820
version_CVS
cg@2596
   821
    ^ '$Header$'
cg@2596
   822
! !