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