ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Mon, 06 Jun 2016 14:45:52 +0200
changeset 3307 58f20c91f623
parent 3182 c7579f84fa6b
child 3308 5cbec72e27fa
permissions -rw-r--r--
#BUGFIX by cg
class: Tools::ProjectBuilder
changed: #buildWithOutputTo:errorTo:
cg@3307
     1
"{ Encoding: utf8 }"
cg@3307
     2
cg@2741
     3
"
cg@2741
     4
 COPYRIGHT (c) 2009 by eXept Software AG
cg@2741
     5
              All Rights Reserved
cg@2741
     6
cg@2741
     7
 This software is furnished under a license and may be used
cg@2741
     8
 only in accordance with the terms of that license and with the
cg@2741
     9
 inclusion of the above copyright notice.   This software may not
cg@2741
    10
 be provided or otherwise made available to, or used by, any
cg@2741
    11
 other person.  No title to or ownership of the software is
cg@2741
    12
 hereby transferred.
cg@2741
    13
"
cg@2596
    14
"{ Package: 'stx:libtool2' }"
cg@2596
    15
cg@2635
    16
"{ NameSpace: Tools }"
cg@2635
    17
cg@2596
    18
Object subclass:#ProjectBuilder
cg@2596
    19
	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
cg@2673
    20
		myWorkingDirectory mySTXTopDirectory myTopDirectory outputStream
cg@3127
    21
		makeExeOnly makeAppOnly makeQuick usedCompiler stdOut stdErr
cg@3127
    22
		isQuickBuild isLocalBuild'
cg@2596
    23
	classVariableNames:'PreviousBuildDirectory'
cg@2596
    24
	poolDictionaries:''
cg@2596
    25
	category:'System-Support-Projects'
cg@2596
    26
!
cg@2596
    27
cg@2741
    28
!ProjectBuilder class methodsFor:'documentation'!
cg@2741
    29
cg@2741
    30
copyright
cg@2741
    31
"
cg@2741
    32
 COPYRIGHT (c) 2009 by eXept Software AG
cg@2741
    33
              All Rights Reserved
cg@2741
    34
cg@2741
    35
 This software is furnished under a license and may be used
cg@2741
    36
 only in accordance with the terms of that license and with the
cg@2741
    37
 inclusion of the above copyright notice.   This software may not
cg@2741
    38
 be provided or otherwise made available to, or used by, any
cg@2741
    39
 other person.  No title to or ownership of the software is
cg@2741
    40
 hereby transferred.
cg@2741
    41
"
cg@2741
    42
! !
cg@2596
    43
cg@2633
    44
!ProjectBuilder class methodsFor:'accessing'!
cg@2633
    45
cg@2633
    46
previousBuildDirectory
cg@2633
    47
    ^ PreviousBuildDirectory
cg@2633
    48
!
cg@2633
    49
cg@2633
    50
previousBuildDirectory:something
cg@2633
    51
    PreviousBuildDirectory := something.
cg@2633
    52
! !
cg@2633
    53
cg@2596
    54
!ProjectBuilder class methodsFor:'examples'!
cg@2596
    55
cg@2644
    56
example1
cg@2644
    57
    Smalltalk loadPackage:'stx:projects/helloWorldApp' asAutoloaded:true.
cg@2644
    58
cg@2644
    59
    self new
cg@2644
    60
        package:'stx:projects/helloWorldApp';
cg@2644
    61
        build
cg@2622
    62
!
cg@2622
    63
cg@2644
    64
example2
cg@2644
    65
    |builder|
cg@2644
    66
cg@2644
    67
    Smalltalk loadPackage:'stx:clients/Demos/foxCalcApplication' asAutoloaded:true.
cg@2644
    68
cg@2644
    69
    builder := self new.
cg@2909
    70
    builder 
cg@2909
    71
        package:'stx:clients/Demos/foxCalcApplication';
cg@2909
    72
        build.
cg@2644
    73
cg@2644
    74
    UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
cg@2909
    75
cg@2909
    76
    "Modified: / 03-09-2012 / 19:23:53 / cg"
cg@2596
    77
! !
cg@2596
    78
cg@2873
    79
!ProjectBuilder class methodsFor:'queries'!
cg@2873
    80
cg@2873
    81
defaultUsedCompiler
cg@2873
    82
    |compiler|
cg@2873
    83
cg@2873
    84
    (compiler := UserPreferences current usedCompilerForBuild) notNil ifTrue:[
cg@2873
    85
        ^ compiler
cg@2873
    86
    ].
cg@2873
    87
cg@3006
    88
    ^ ParserFlags usedCompiler
cg@2873
    89
!
cg@2873
    90
cg@2873
    91
listOfPossibleCompilers
cg@2873
    92
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2918
    93
        OperatingSystem getLoginName = 'cg' ifTrue:[
cg@2921
    94
            ^ #(
cg@2921
    95
                'bcc'   "/ OK
cg@2921
    96
                'vc'    "/ almost OK
cg@2921
    97
                'lcc'   "/ experimental, but only free for non-commercial work
cg@2921
    98
                'tcc'   "/ experimental; limited but free
cg@2921
    99
                'mingw' "/ experimental; free
cg@2921
   100
             )
cg@2918
   101
        ].
cg@2972
   102
        ^ #('bcc' 'vc' 'mingw' )
cg@2873
   103
    ].
cg@2873
   104
    ^ #('gcc')
cg@2873
   105
cg@2873
   106
    "Created: / 21-01-2012 / 14:04:15 / cg"
cg@2921
   107
!
cg@2921
   108
cg@2921
   109
suiteNameOfCompiler:usedCompiler
cg@2921
   110
    usedCompiler = 'bcc' ifTrue:[
cg@2921
   111
        ^ 'Borland C-Compiler'.
cg@2921
   112
    ].
cg@2921
   113
    usedCompiler = 'vc' ifTrue:[
cg@2974
   114
        ^ 'Microsoft Visual C Compiler'.
cg@2921
   115
    ].
cg@2921
   116
    usedCompiler = 'lcc' ifTrue:[
cg@2921
   117
        ^ 'LCC C-Compiler'.
cg@2921
   118
    ].
cg@2921
   119
    usedCompiler = 'tcc' ifTrue:[
cg@2921
   120
        ^ 'Tiny C-Compiler'.
cg@2921
   121
    ].
cg@2921
   122
    usedCompiler = 'gcc' ifTrue:[
cg@2921
   123
        ^ 'GNU C-Compiler'.
cg@2921
   124
    ].
cg@2921
   125
    usedCompiler = 'mingw' ifTrue:[
cg@2921
   126
        ^ 'MINGW GNU C-Compiler'.
cg@2921
   127
    ].
cg@2921
   128
    self halt:'unknown compiler'.
cg@2921
   129
cg@2921
   130
    ^ 'C-Compiler'.
cg@2921
   131
cg@2921
   132
    "Created: / 06-09-2012 / 15:58:33 / cg"
cg@2873
   133
! !
cg@2873
   134
cg@2596
   135
!ProjectBuilder methodsFor:'accessing'!
cg@2596
   136
cg@2644
   137
buildDirectory
cg@2644
   138
    ^ buildDirectory
cg@2622
   139
!
cg@2622
   140
cg@2634
   141
buildDirectory:something
cg@2634
   142
    buildDirectory := something.
cg@2634
   143
!
cg@2634
   144
cg@2964
   145
isLocalBuild
cg@2964
   146
    ^ isLocalBuild ? false
cg@2964
   147
!
cg@2964
   148
cg@2964
   149
isLocalBuild:aBoolean
cg@2964
   150
    "create a files without going through the source code manager"
cg@2964
   151
cg@2964
   152
    isLocalBuild := aBoolean.
cg@2964
   153
!
cg@2964
   154
cg@2964
   155
isQuickBuild
cg@2964
   156
    ^ isQuickBuild ? false
cg@2964
   157
!
cg@2964
   158
cg@2964
   159
isQuickBuild:aBoolean
cg@2964
   160
    "skips creation of header files, and copying of support files, if possible
cg@2964
   161
     to speedup a build. Use with care."
cg@2964
   162
cg@2964
   163
    isQuickBuild := aBoolean.
cg@2964
   164
!
cg@2964
   165
cg@3127
   166
makeAppOnly
cg@3127
   167
    ^ (makeAppOnly ? false)
cg@3127
   168
!
cg@3127
   169
cg@3127
   170
makeAppOnly:aBoolean
cg@3127
   171
    makeAppOnly := aBoolean.
cg@3127
   172
!
cg@3127
   173
cg@2972
   174
makeExeOnly
cg@2972
   175
    ^ (makeExeOnly ? false)
cg@2972
   176
!
cg@2972
   177
cg@2673
   178
makeExeOnly:aBoolean
cg@2673
   179
    makeExeOnly := aBoolean.
cg@2673
   180
!
cg@2673
   181
cg@2972
   182
makeQuick
cg@2972
   183
    ^ (makeQuick ? false)
cg@2972
   184
!
cg@2972
   185
cg@2972
   186
makeQuick:aBoolean
cg@2972
   187
    makeQuick := aBoolean.
cg@2972
   188
!
cg@2972
   189
cg@2644
   190
package:aPackageIDOrSymbol
cg@2644
   191
    package := aPackageIDOrSymbol asPackageId.
cg@2596
   192
!
cg@2596
   193
cg@2644
   194
packageBuildDirectory
cg@2644
   195
    "the directoray, where the deployable binary is created (xxxSetup.exe)"
cg@2622
   196
cg@2622
   197
    ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
cg@2635
   198
!
cg@2635
   199
cg@2644
   200
projectDefinitionClass:something
cg@2644
   201
    projectDefinitionClass := something.
cg@2680
   202
!
cg@2680
   203
sr@2683
   204
suffixForHeaderFiles
sr@2683
   205
    ^ OperatingSystem isUNIXlike ifTrue:['.H'] ifFalse:['.STH']
sr@2683
   206
!
sr@2683
   207
cg@2873
   208
usedCompilerForBuild:something
cg@2680
   209
    usedCompiler := something.
cg@2873
   210
cg@2873
   211
    "Created: / 22-01-2012 / 10:50:48 / cg"
cg@2596
   212
! !
cg@2596
   213
cg@2596
   214
!ProjectBuilder methodsFor:'building'!
cg@2596
   215
cg@2644
   216
build
cg@2644
   217
    "/ intermediate - this will move into a commonly used utility class
cg@2635
   218
    "/ (where all the project code support will be collected).
cg@2635
   219
cg@2647
   220
    |makeOutput|
cg@2647
   221
cg@2647
   222
    makeOutput := TextStream on:(Text new:10000).
cg@2647
   223
    self buildWithColorizedOutputTo:makeOutput.
cg@2647
   224
cg@2647
   225
    TextView openWith:makeOutput contents.
cg@2647
   226
!
cg@2647
   227
cg@2647
   228
buildWithColorizedOutputTo:makeOutput
cg@2647
   229
    "/ intermediate - this will move into a commonly used utility class
cg@2647
   230
    "/ (where all the project code support will be collected).
cg@2647
   231
cg@2921
   232
    |lock|
cg@2635
   233
cg@2644
   234
    lock := Semaphore forMutualExclusion.
cg@2647
   235
cg@2644
   236
    stdErr := ActorStream new
cg@2644
   237
                    nextPutBlock:[:char |
cg@2644
   238
                        lock critical:[
cg@2921
   239
                            makeOutput 
cg@2921
   240
                                withEmphasis:{#backgroundColor->Color red. #color->Color white.}
cg@2921
   241
                                do:[makeOutput nextPut:char].
cg@2644
   242
                        ]
cg@2644
   243
                    ];
sr@2683
   244
                    nextPutAllBlock:[:string |
cg@2873
   245
                        lock critical:[          
cg@2921
   246
                            makeOutput
cg@2921
   247
                                withEmphasis:{#backgroundColor->Color red. #color->Color white.}
cg@2921
   248
                                do:[makeOutput nextPutAll:string].
cg@2644
   249
                        ]
cg@2644
   250
                    ].
cg@2644
   251
    stdOut := ActorStream new
cg@2644
   252
                    nextPutBlock:[:char |
cg@2644
   253
                        lock critical:[
cg@2644
   254
                            makeOutput nextPut:char.
cg@2644
   255
                        ]
cg@2644
   256
                    ];
sr@2683
   257
                    nextPutAllBlock:[:string |
cg@2873
   258
                        lock critical:[         
sr@2683
   259
                            makeOutput nextPutAll:string.
cg@2644
   260
                        ]
cg@2644
   261
                    ].
cg@2635
   262
cg@2644
   263
    self buildWithOutputTo:stdOut errorTo:stdErr.
cg@2873
   264
cg@2921
   265
    "Modified: / 06-09-2012 / 16:15:50 / cg"
cg@2611
   266
!
cg@2611
   267
cg@2969
   268
buildWithOutputTo:stdOutArg errorTo:stdErrArg
cg@2611
   269
    "/ intermediate - this will move into a commonly used utility class
cg@2611
   270
    "/ (where all the project code support will be collected).
cg@2611
   271
cg@2596
   272
    |module directory|
cg@2596
   273
cg@3307
   274
    usedCompiler isNil ifTrue:[
cg@3307
   275
        usedCompiler := ParserFlags usedCompiler.
cg@3307
   276
    ].
cg@3307
   277
cg@2596
   278
    projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
cg@2596
   279
    projectDefinitionClass isNil ifTrue:[
cg@2596
   280
        self error:('Missing ProjectDefinition class for "',package asString,'"')
cg@2596
   281
    ].
cg@2596
   282
cg@2596
   283
    "/ ensure that everything is loaded...
cg@2596
   284
    projectDefinitionClass loadAsAutoloaded:false.
cg@2596
   285
    projectDefinitionClass loadExtensions.
cg@2596
   286
    projectDefinitionClass loadAllClassesAsAutoloaded:false.
cg@2596
   287
cg@2596
   288
    module := package module.
cg@2596
   289
    directory := package directory.
cg@2596
   290
cg@2596
   291
    buildDirectory isNil ifTrue:[
cg@2634
   292
        buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
cg@2634
   293
        buildDirectory isNil ifTrue:[
cg@2634
   294
            buildDirectory := Filename tempDirectory construct:'stx_build'.
cg@2634
   295
        ].
cg@2596
   296
    ].
cg@2596
   297
    buildDirectory := buildDirectory asFilename.
cg@2596
   298
cg@2596
   299
    "/ self validateBuildDirectoryIsPresent.
cg@2596
   300
cg@2596
   301
    PreviousBuildDirectory := buildDirectory.
cg@2596
   302
cg@2596
   303
    "/ UserPreferences current localBuild:true
cg@2964
   304
    (self isLocalBuild or:[UserPreferences current localBuild]) ifFalse:[
cg@2596
   305
        SourceCodeManager notNil ifTrue:[
sv@3043
   306
            sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass.
cg@2596
   307
        ]
cg@2596
   308
    ].
cg@2596
   309
    sourceCodeManager := nil.
cg@2596
   310
cg@2598
   311
    myTopDirectory := 
cg@2596
   312
        Smalltalk packagePath 
cg@2596
   313
            detect:[:aPath |
cg@2596
   314
                (aPath asFilename / 'stx' / 'include') exists
cg@2596
   315
                and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
cg@2596
   316
            ifNone:nil.       
cg@2598
   317
    myTopDirectory isNil ifTrue:[
cg@2598
   318
        self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
cg@2596
   319
    ].
cg@2598
   320
    myTopDirectory := myTopDirectory asFilename.
cg@2598
   321
    mySTXTopDirectory := myTopDirectory / 'stx'.
cg@2613
   322
cg@2972
   323
    self makeQuick ifFalse:[
cg@2972
   324
        self setupBuildDirectory.
cg@2972
   325
        self activityNotification:'Generating stc directory...'.
cg@2972
   326
        self copySTCDirectoryForBuild.
cg@2972
   327
    ].
cg@2628
   328
    self activityNotification:'Generating source files...'.
cg@2596
   329
    self generateSourceFiles.
cg@2972
   330
    self makeQuick ifFalse:[
cg@2972
   331
        self activityNotification:'Copying dlls for linkage...'.
cg@2972
   332
        self copyDLLsForLinkage.
cg@2972
   333
        self activityNotification:'Copying support files for compilation and linkage...'.
cg@2972
   334
        self copySupportFilesForCompilation.
cg@2972
   335
        self copySupportFilesForLinkage.
cg@2972
   336
        self copyStartupFilesFromSmalltalk.
cg@2972
   337
    ].
cg@2628
   338
    self activityNotification:'Executing make...'.
cg@2611
   339
    self makeWithOutputTo:stdOut errorTo:stdErr.
cg@2912
   340
cg@3307
   341
    "Modified: / 06-06-2016 / 12:13:01 / cg"
cg@2898
   342
! !
cg@2898
   343
cg@2898
   344
!ProjectBuilder methodsFor:'building/private'!
cg@2596
   345
cg@2644
   346
copyDLLsForLinkage
cg@2911
   347
    |targetBuildDir preRequisites dllRelativeSourcePathes dllRelativeDestPathes|
sv@2723
   348
cg@2644
   349
    targetBuildDir := buildDirectory / package module / package directory.
cg@2644
   350
sv@2723
   351
    preRequisites := projectDefinitionClass allPreRequisites.
sv@2723
   352
    OperatingSystem isUNIXlike ifTrue:[
sv@2723
   353
        "For now: unix Makefiles require some libs implicitely..."
sv@2723
   354
        preRequisites := preRequisites union:#(
sv@2979
   355
                               #'stx:goodies/refactoryBrowser/parser'
sv@2979
   356
                               #'stx:libtool'
sv@2723
   357
                            ).
sv@2723
   358
    ].
sv@2723
   359
sv@2723
   360
    preRequisites do:[:eachPackageToFileout |
cg@2644
   361
        |packageId packageDef packageModule packageDirectory packageTargetDir
cg@2911
   362
         dllSource dllSourceDir libraryName dllRelativePathSource 
cg@2916
   363
         dllRelativePathDest objDirSource objDirDest alternativeObjDirSource|
cg@2644
   364
cg@2644
   365
        packageId := eachPackageToFileout asPackageId.
cg@2644
   366
        packageModule := packageId module.
cg@2644
   367
        packageDirectory := packageId directory.
cg@2644
   368
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   369
cg@2644
   370
        packageDef := packageId projectDefinitionClass.
cg@2644
   371
        libraryName := packageDef libraryName.
cg@2644
   372
cg@2644
   373
        "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
cg@2644
   374
        dllSourceDir := myTopDirectory / packageModule / packageDirectory.
cg@2909
   375
cg@2644
   376
        OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2911
   377
            objDirDest := self objDirForUsedCompiler:usedCompiler.
cg@2916
   378
            objDirSource := objDirDest.
cg@2916
   379
"/            "/ use visual-c files for tcc linkage
cg@2916
   380
"/            usedCompiler = 'tcc' ifTrue:[
cg@2916
   381
"/                objDirSource := self objDirForUsedCompiler:'vc'.
cg@2916
   382
"/            ] ifFalse:[
cg@2916
   383
"/                objDirSource := objDirDest
cg@2916
   384
"/            ].
cg@2916
   385
            (dllSourceDir / objDirSource / (libraryName, '.dll')) exists ifFalse:[
cg@2916
   386
                alternativeObjDirSource := self objDirForUsedCompiler:'vc'.
cg@2916
   387
                (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
cg@2921
   388
                    objDirSource := alternativeObjDirSource.
cg@2921
   389
                    stdErr nextPutLine:(('Warning: using alternative %1 from %2 (%3 version)...' 
cg@2921
   390
                                                bindWith:libraryName 
cg@2921
   391
                                                with:alternativeObjDirSource 
cg@2921
   392
                                                with:(self class suiteNameOfCompiler:'vc'))
cg@2921
   393
                                            emphasizeAllWith:(#color -> Color red darkened)).
cg@2921
   394
                ] ifFalse:[
cg@2921
   395
                    alternativeObjDirSource := self objDirForUsedCompiler:'bcc'.
cg@2921
   396
                    (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
cg@2921
   397
                        objDirSource := alternativeObjDirSource.
cg@2921
   398
                        stdErr nextPutLine:('Warning: using alternative %1 from %2 (%3 version)...' 
cg@2921
   399
                                    bindWith:libraryName 
cg@2921
   400
                                    with:alternativeObjDirSource 
cg@2921
   401
                                    with:(self class suiteNameOfCompiler:'bcc')).
cg@2921
   402
                    ]
cg@2921
   403
                ].
cg@2911
   404
            ].
cg@2916
   405
cg@2905
   406
"/            dllRelativePath := objDir,'/',(libraryName,'.dll').
cg@2644
   407
"/            (dllSourceDir / dllRelativePath) exists 
cg@2911
   408
            dllRelativeSourcePathes := Array with:(objDirSource,'\', libraryName, '.dll').
cg@2911
   409
            dllRelativeDestPathes := Array with:(objDirDest,'\', libraryName, '.dll').
cg@2644
   410
        ] ifFalse:[
cg@2911
   411
            dllRelativeSourcePathes := Array with:(libraryName,'.so').
cg@2958
   412
            dllRelativeDestPathes := Array with:(libraryName, '.so').
sv@2723
   413
            (packageModule = 'stx' and:[packageDirectory = 'libview']) ifTrue:[
cg@2958
   414
                dllRelativeSourcePathes := dllRelativeSourcePathes copyWith:('XWorkstation.so').
cg@2958
   415
                dllRelativeDestPathes := dllRelativeDestPathes copyWith:'XWorkstation.so'.
cg@2958
   416
                dllRelativeSourcePathes := dllRelativeSourcePathes copyWith:('GLXWorkstation.so').
cg@2958
   417
                dllRelativeDestPathes := dllRelativeDestPathes copyWith:'GLXWorkstation.so'.
sv@2723
   418
            ].
cg@2644
   419
        ].
cg@2911
   420
        dllRelativeSourcePathes with:dllRelativeDestPathes do:[:dllRelativeSourcePath :dllRelativeDestPath|
cg@2896
   421
            |source dest|
cg@2896
   422
cg@2911
   423
            source := dllSourceDir / dllRelativeSourcePath.
cg@2958
   424
            source exists ifFalse:[
cg@2958
   425
                self activityNotification:'   skip missing file: ',source pathName.
cg@2958
   426
            ] ifTrue:[
cg@2958
   427
                dest := packageTargetDir / dllRelativeDestPath.
cg@2958
   428
                (dest exists not
cg@2958
   429
                 or:[source fileSize ~= dest fileSize
cg@2958
   430
                 or:[source modificationTime >= dest modificationTime
cg@2958
   431
                 "/ or:[ ((dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath)) not ]
cg@2958
   432
                ]]) ifTrue:[
cg@2958
   433
                    Transcript showCR:'updating ',dllRelativeDestPath.
cg@2958
   434
                    dest directory recursiveMakeDirectory.
cg@2958
   435
                    source copyTo:dest.    
cg@2986
   436
                    self activityNotification:'    ',dest pathName
cg@3041
   437
                ] ifFalse:[
cg@3041
   438
                    Transcript showCR:'already up-to-date: ',dllRelativeDestPath.
cg@3041
   439
                ]
cg@2958
   440
            ]
sv@2723
   441
        ].
cg@2614
   442
    ].
cg@2896
   443
cg@2921
   444
    "Modified: / 06-09-2012 / 16:19:29 / cg"
cg@2600
   445
!
cg@2600
   446
cg@2644
   447
copyDirectory:relativepath
cg@2644
   448
    "/ need rules in stx
cg@2644
   449
    ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
cg@2644
   450
        recursiveCopyTo:(buildDirectory construct:'stx').
cg@2596
   451
!
cg@2596
   452
cg@2644
   453
copyDirectoryForBuild:subdir
cg@2644
   454
    |targetDir targetFile|
cg@2644
   455
cg@2644
   456
    targetDir := buildDirectory / 'stx' / subdir.
cg@2644
   457
    targetDir exists ifFalse:[
cg@2644
   458
        targetDir makeDirectory.
cg@2964
   459
    ] ifTrue:[
cg@2964
   460
        self isQuickBuild ifTrue:[^ self]
cg@2644
   461
    ].
cg@2644
   462
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
cg@2644
   463
        eachFile isDirectory ifFalse:[
cg@2644
   464
            targetFile := targetDir / eachFile baseName.
cg@2644
   465
            (targetFile exists not
cg@2644
   466
            or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
cg@2644
   467
                self activityNotification:'copying ',eachFile pathName,'...'.
cg@2644
   468
                eachFile copyTo:(targetDir construct:eachFile baseName)
cg@2644
   469
            ]
cg@2644
   470
        ].
cg@2644
   471
    ].
cg@2644
   472
    self activityNotification:nil
cg@2598
   473
!
cg@2598
   474
cg@2644
   475
copyResourcesForPackage:aPackage
cg@2981
   476
    |module directory myPackageDirectory rsrcDir stylesDir|
cg@2644
   477
cg@2644
   478
    module := aPackage asPackageId module.
cg@2644
   479
    directory := aPackage asPackageId directory.
cg@2644
   480
cg@2981
   481
    myPackageDirectory := myTopDirectory / module / directory.
cg@2981
   482
cg@2981
   483
    (rsrcDir := myPackageDirectory / 'resources' ) exists ifTrue:[
cg@2981
   484
        rsrcDir recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   485
    ].
cg@2981
   486
    (stylesDir := myPackageDirectory / 'styles' ) exists ifTrue:[
cg@2981
   487
        stylesDir recursiveCopyTo:(buildDirectory / module / directory)
cg@2644
   488
    ].
cg@2600
   489
!
cg@2600
   490
cg@2644
   491
copySTCDirectoryForBuild
cg@2912
   492
    "copy stc files to the build directory"
cg@2912
   493
cg@2644
   494
    |targetDir stc files|
cg@2644
   495
cg@2644
   496
    targetDir := buildDirectory / 'stx' / 'stc'.
cg@2644
   497
    targetDir exists ifFalse:[ targetDir makeDirectory ].
cg@2644
   498
cg@2644
   499
    stc := OperatingSystem isMSWINDOWSlike 
cg@2644
   500
                ifTrue:[ 'stc.exe' ]
cg@2644
   501
                ifFalse:[ 'stc' ].
cg@2644
   502
cg@2644
   503
    files := #( ) copyWith:stc.
cg@2644
   504
cg@2644
   505
    files do:[:eachFile |
cg@2644
   506
        |sourceFile targetFile|
cg@2644
   507
cg@2644
   508
        sourceFile := mySTXTopDirectory / 'stc' / eachFile.
cg@2644
   509
        targetFile := targetDir / eachFile.
cg@2644
   510
        (targetFile exists not
cg@2644
   511
        or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
cg@2644
   512
            self activityNotification:'copying ',sourceFile pathName,'...'.
cg@2644
   513
            sourceFile copyTo:targetFile
cg@2644
   514
        ].
cg@2644
   515
    ].
sr@2683
   516
sr@2683
   517
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
   518
        (targetDir / 'stc') makeExecutableForAll    
sr@2683
   519
    ].
sr@2683
   520
cg@2644
   521
    self activityNotification:nil
cg@2912
   522
cg@2912
   523
    "Modified (comment): / 04-09-2012 / 00:49:19 / cg"
cg@2599
   524
!
cg@2599
   525
cg@2644
   526
copyStartupFilesFromSmalltalk
cg@2912
   527
    "copy additional smalltalk startup files to the build directory"
cg@2912
   528
cg@2644
   529
    (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
cg@2644
   530
        (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
cg@2644
   531
    ].
cg@2644
   532
cg@2678
   533
    #( 
cg@2678
   534
        'keyboard.rc' 
cg@2678
   535
        'keyboardMacros.rc' 
cg@2678
   536
        'display.rc' 
cg@2678
   537
        'd_win32.rc'
cg@2678
   538
        'host.rc' 
cg@2678
   539
        'h_win32.rc'  
cg@2678
   540
        'smalltalk.rc'  
cg@2678
   541
        'private.rc'  
cg@2644
   542
    ) do:[:fn |
cg@2644
   543
        (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2644
   544
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2678
   545
    ].
cg@2678
   546
cg@2678
   547
    (myTopDirectory / 'stx' / 'doc/online/english/LICENCE_STX.html')
cg@2678
   548
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / 'LICENCE_STX.html').
cg@2912
   549
cg@2912
   550
    "Modified (comment): / 04-09-2012 / 00:48:47 / cg"
cg@2912
   551
!
cg@2912
   552
cg@2912
   553
copySupportFilesForCompilation
cg@2912
   554
    "copy the tcc compiler to the build directory"
cg@2912
   555
cg@2912
   556
    |files|
cg@2912
   557
cg@2912
   558
    files := #().
cg@2912
   559
cg@2912
   560
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2984
   561
        files := files , #( 
cg@2984
   562
                        'librun/genDate.com' 
cg@2984
   563
                    ).
cg@2912
   564
        usedCompiler = 'tcc' ifTrue:[
cg@2912
   565
            files := files , #( 
cg@2912
   566
                        'support/tcc'
cg@2912
   567
                    ).
cg@2912
   568
        ].
cg@2912
   569
    ] ifFalse:[
cg@2984
   570
        files := files , #( 
cg@2984
   571
                        "/ 'librun/genDate'   -- not needed on unix (done via script)
cg@2984
   572
                        'configurations/myConf' 
cg@2984
   573
                        'configurations/vendorConf' 
cg@2984
   574
                        'configurations/conf.inc' 
cg@2984
   575
                        'configurations/COMMON' 
cg@2984
   576
                    ).
cg@2912
   577
    ].
cg@2912
   578
cg@2912
   579
    files do:[:relativePath |
cg@2912
   580
        (mySTXTopDirectory / relativePath) exists ifTrue:[
cg@2912
   581
            ((buildDirectory / 'stx' / relativePath) exists
cg@2912
   582
            and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
cg@2912
   583
            and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
cg@2912
   584
            "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
cg@2912
   585
            ]]) ifFalse:[
cg@2984
   586
                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.    
cg@2984
   587
                (mySTXTopDirectory / relativePath) isDirectory ifTrue:[
cg@2984
   588
                    (mySTXTopDirectory / relativePath) recursiveCopyTo:(buildDirectory / 'stx' / relativePath) directory.    
cg@2984
   589
                ] ifFalse:[
cg@2984
   590
                    (mySTXTopDirectory / relativePath) copyTo:(buildDirectory / 'stx' / relativePath) directory.    
cg@2984
   591
                ]
cg@2912
   592
            ]
cg@2912
   593
        ] ifFalse:[
cg@2984
   594
            self error:'Missing file or directory: ',relativePath printString mayProceed:true.
cg@2912
   595
        ].
cg@2912
   596
    ].
cg@2912
   597
cg@2912
   598
    "Created: / 04-09-2012 / 00:47:49 / cg"
cg@2600
   599
!
cg@2600
   600
cg@2644
   601
copySupportFilesForLinkage
cg@2912
   602
    "copy additional files which are req'd for linkage to the build directory"
cg@2912
   603
cg@2644
   604
    |files|
cg@2644
   605
cg@2644
   606
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2644
   607
        files := #( 
cg@2969
   608
                    'librun/genDate.com'
cg@2644
   609
                    'librun/main.c'
cg@2673
   610
                    'projects/smalltalk/stx_16x16.ico'
cg@2673
   611
                    'projects/smalltalk/stx_32x32.ico'
cg@2673
   612
                    'projects/smalltalk/stx_splash.bmp'
cg@2644
   613
                 ).
cg@2905
   614
cg@2905
   615
        usedCompiler = 'bcc' ifTrue:[
cg@2905
   616
            files := files , #( 
cg@2905
   617
                        'librun/objbc/librun.dll'
cg@2905
   618
                        'support/win32/borland/cs3245.dll' 
cg@2905
   619
                        'support/win32/X11.dll'
cg@2905
   620
                        'support/win32/Xext.dll'
cg@2916
   621
                        'lib/bc/librun.lib'
cg@2916
   622
                        'lib/bc/cs32i.lib'
cg@2905
   623
                    ).
cg@2905
   624
        ].
cg@2905
   625
        usedCompiler = 'vc' ifTrue:[
cg@2905
   626
            files := files , #( 
cg@2905
   627
                        'librun/objvc/librun.dll'
cg@2916
   628
                        'lib/vc/librun.lib'
cg@2905
   629
                    ).
cg@2905
   630
        ].
cg@2911
   631
        usedCompiler = 'tcc' ifTrue:[
cg@2911
   632
            files := files , #( 
cg@2916
   633
                        'librun/objvc/librun.dll'   "/ linkage is against vc version!!
cg@2916
   634
                        'lib/vc/librun.lib'
cg@2916
   635
                    ).
cg@2916
   636
        ].
cg@2916
   637
        usedCompiler = 'lcc' ifTrue:[
cg@2916
   638
            files := files , #( 
cg@2916
   639
                        'librun/objvc/librun.dll'   "/ linkage is against vc version!!
cg@2916
   640
                        'lib/vc/librun.lib'
cg@2911
   641
                    ).
cg@2911
   642
        ].
cg@2918
   643
        usedCompiler = 'mingw' ifTrue:[
cg@2918
   644
            files := files , #( 
cg@2972
   645
                        'librun/objmingw/librun.dll'   "/ linkage is against vc version!!
cg@2972
   646
                        'lib/mingw/librun.lib'
cg@2918
   647
                    ).
cg@2918
   648
        ].
cg@2644
   649
    ] ifFalse:[
cg@2644
   650
        files := #(
cg@2644
   651
                    'librun/main.c'
cg@2644
   652
                    'librun/librun.so'
cg@2644
   653
                )
cg@2644
   654
    ].
cg@2677
   655
    files := files asOrderedCollection.
cg@2677
   656
cg@2677
   657
    OperatingSystem isMSWINDOWSlike ifTrue:[
cg@2677
   658
        projectDefinitionClass applicationIconFileName notNil ifTrue:[
cg@2678
   659
            files add:('projects/smalltalk/',projectDefinitionClass applicationIconFileName,'.ico')
cg@2678
   660
        ].
cg@2678
   661
        projectDefinitionClass splashFileName notNil ifTrue:[
cg@2678
   662
            files add:('projects/smalltalk/',projectDefinitionClass splashFileName,'.bmp')
cg@2678
   663
        ].
cg@2677
   664
    ].
cg@2644
   665
cg@2914
   666
    files do:[:relativePath |
cg@2914
   667
        (mySTXTopDirectory / relativePath) exists ifTrue:[
cg@2914
   668
            ((buildDirectory / 'stx' / relativePath) exists
cg@2914
   669
            and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
cg@2914
   670
            and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
sr@2684
   671
            "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
sr@2684
   672
            ]]) ifFalse:[
cg@2914
   673
                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2914
   674
                (mySTXTopDirectory / relativePath) copyTo:(buildDirectory / 'stx' / relativePath).    
sr@2684
   675
            ]
sr@2684
   676
        ] ifFalse:[
cg@2971
   677
"/ does not really help: objbc/librun.lib does not work with MSVC and vice versa...
cg@2971
   678
"/            ((relativePath = 'librun/objvc/librun.dll')
cg@2971
   679
"/            and:[ (mySTXTopDirectory / 'librun/objbc/librun.dll') exists ])ifTrue:[
cg@2971
   680
"/                stdErr nextPutLine:('Warning: using alternative librun from objbc (Borland version)...'). 
cg@2971
   681
"/                (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2971
   682
"/                (mySTXTopDirectory / 'librun/objbc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).    
cg@2971
   683
"/            ] ifFalse:[
cg@2971
   684
"/                ((relativePath = 'librun/objbc/librun.dll')
cg@2971
   685
"/                and:[ (mySTXTopDirectory / 'librun/objvc/librun.dll') exists ])ifTrue:[
cg@2971
   686
"/                    stdErr nextPutLine:('Warning: using alternative librun from objvc (MSVC version)...'). 
cg@2971
   687
"/                    (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
cg@2971
   688
"/                    (mySTXTopDirectory / 'librun/objvc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).    
cg@2971
   689
"/                ] ifFalse:[
cg@2971
   690
                    self error:'Missing file: ',relativePath printString mayProceed:true.
cg@2971
   691
"/                ]
cg@2971
   692
"/            ]
sr@2684
   693
        ].
cg@2644
   694
    ].
cg@2873
   695
cg@2918
   696
    "Modified: / 05-09-2012 / 16:26:25 / cg"
cg@2600
   697
!
cg@2600
   698
cg@2644
   699
createHeaderFileFor:aClass in:packageTargetDir
cg@2644
   700
    |instVarList classInstVarList classVarList bindings superclassFilename
cg@2644
   701
     template file newContents oldContents|
cg@2644
   702
cg@2644
   703
    instVarList := StringCollection new.
cg@2644
   704
    aClass instVarNames do:[:v |
cg@2644
   705
        instVarList add:('OBJ %1;' bindWith:v)
cg@2644
   706
    ].
cg@2644
   707
    classInstVarList := StringCollection new.
cg@2644
   708
    aClass class instVarNames do:[:v |
cg@2961
   709
    "/ (v includes:$_) ifTrue:[self halt].
cg@2644
   710
        classInstVarList add:('OBJ %1;' bindWith:v)
cg@2644
   711
    ].
cg@2644
   712
    classVarList := StringCollection new.
cg@2644
   713
    aClass classVarNames do:[:v |
cg@2644
   714
        classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
cg@2644
   715
    ].
cg@2644
   716
cg@2644
   717
    bindings := Dictionary new.
cg@2644
   718
    bindings at:'ClassName' put:aClass name. 
cg@2644
   719
    aClass superclass isNil ifTrue:[
cg@2644
   720
        bindings at:'SuperclassName' put:'-'. 
cg@2852
   721
        bindings at:'SuperclassFileInclude' put:''.
cg@2644
   722
    ] ifFalse:[
cg@2644
   723
        bindings at:'SuperclassName' put:aClass superclass name. 
cg@2644
   724
        bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
cg@2644
   725
        bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
cg@2644
   726
    ].
cg@2644
   727
    bindings at:'InstVarList' put:instVarList asString. 
cg@2644
   728
    bindings at:'ClassVarList' put:classVarList asString. 
cg@2644
   729
    bindings at:'ClassInstVarList' put:classInstVarList asString. 
cg@2644
   730
cg@2644
   731
    template := 
cg@2644
   732
'/* This file was generated by ProjectBuilder. */
cg@2644
   733
/* !!!!!!!! Do not change by hand !!!!!!!! */
cg@2644
   734
cg@2644
   735
/* Class: %(ClassName) */
cg@2644
   736
/* Superclass: %(SuperclassName) */
cg@2644
   737
cg@2644
   738
%(SuperclassFileInclude)
cg@2644
   739
cg@2644
   740
/* INDIRECTGLOBALS */
cg@2644
   741
#ifdef _HEADER_INST_
cg@2644
   742
%(InstVarList)
cg@2644
   743
#endif /* _HEADER_INST_ */
cg@2644
   744
cg@2644
   745
#ifdef _HEADER_CLASS_
cg@2644
   746
%(ClassVarList)
cg@2644
   747
#endif /* _HEADER_CLASS_ */
cg@2644
   748
cg@2644
   749
#ifdef _HEADER_CLASSINST_
cg@2644
   750
%(ClassInstVarList)
cg@2644
   751
#endif /* _HEADER_CLASSINST_ */
cg@2644
   752
'.
cg@2644
   753
    newContents := template bindWithArguments:bindings.
sr@2683
   754
    file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
cg@2644
   755
    (file exists not
cg@2644
   756
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2644
   757
        file contents: newContents.
cg@2644
   758
    ].
cg@2852
   759
cg@2852
   760
    "Modified: / 15-08-2011 / 14:58:46 / cg"
cg@2596
   761
!
cg@2596
   762
cg@3042
   763
generateBuildSupportFilesByFilingOutIn:packageTargetDir forDefinitionClass:projectDefinitionClass
cg@3042
   764
    |fullPathName|
cg@3042
   765
cg@3042
   766
    projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
cg@3042
   767
        fullPathName := packageTargetDir construct:fileName.
cg@3042
   768
        fullPathName directory exists ifFalse:[
cg@3042
   769
            "take care for files like 'autopackage/default.apspec'"
cg@3042
   770
            fullPathName directory makeDirectory.
cg@3042
   771
        ].
cg@3042
   772
        (fullPathName exists
cg@3042
   773
         and:[ fullPathName contents = fileContents ]) ifFalse:[
cg@3042
   774
            fullPathName contents:fileContents.
cg@3042
   775
        ].
cg@3042
   776
    ].    
cg@3042
   777
!
cg@3042
   778
cg@2644
   779
generateSourceFiles
cg@2964
   780
    (self isLocalBuild not and:[ sourceCodeManager notNil ])  ifTrue:[
cg@2644
   781
        "/ check out / generate files there
cg@2644
   782
        self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2644
   783
    ] ifFalse:[
cg@2644
   784
        "/ local build
cg@2644
   785
        "/ fileout the project
cg@2644
   786
        self generateSourceFilesByFilingOut
cg@2644
   787
    ]
cg@2596
   788
!
cg@2596
   789
cg@2644
   790
generateSourceFilesByCheckingOutUsing:aSourceCodeManager
cg@2644
   791
    "/ will no longer be needed/supported
cg@2644
   792
cg@2644
   793
    |repository stxRepository module directory|
cg@2644
   794
cg@2868
   795
    self breakPoint:#cg.
cg@2868
   796
cg@2644
   797
    "/ check out / generate files there
cg@2644
   798
    repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
cg@2644
   799
    stxRepository := aSourceCodeManager repositoryName.
cg@2644
   800
cg@2644
   801
    (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   802
        (module ~= 'stx') ifTrue:[
cg@2644
   803
            OperatingSystem
cg@2644
   804
                executeCommand:('cvs -d ',stxRepository,' co stx')
cg@2644
   805
                inputFrom:nil
cg@2644
   806
                outputTo:Transcript
cg@2644
   807
                errorTo:Transcript
cg@2644
   808
                inDirectory:buildDirectory
cg@2644
   809
                onError:[:status| self error:'cvs update stx failed'].
cg@2644
   810
        ].
cg@2644
   811
    ].
cg@2644
   812
cg@2644
   813
    ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
cg@2644
   814
        OperatingSystem
cg@2644
   815
            executeCommand:('cvs -d ',repository,' co -l ',directory)
cg@2644
   816
            inputFrom:nil
cg@2644
   817
            outputTo:Transcript
cg@2644
   818
            errorTo:Transcript
cg@2644
   819
            inDirectory:buildDirectory
cg@2644
   820
            onError:[:status| self error:'cvs update failed'].
cg@2644
   821
    ].
cg@2644
   822
    OperatingSystem
cg@2644
   823
        executeCommand:'cvs upd -d'
cg@2644
   824
        inputFrom:nil
cg@2644
   825
        outputTo:Transcript
cg@2644
   826
        errorTo:Transcript
cg@2644
   827
        inDirectory:(buildDirectory construct:module)
cg@2644
   828
        onError:[:status| self error:'cvs update failed'].
cg@2644
   829
self halt.
cg@2868
   830
cg@2868
   831
    "Modified: / 29-12-2011 / 14:02:56 / cg"
cg@2596
   832
!
cg@2596
   833
cg@2644
   834
generateSourceFilesByFilingOut
cg@2644
   835
    "/ local build
cg@2644
   836
    "/ fileout the project
cg@2644
   837
cg@2644
   838
    (package module ~= 'stx') ifTrue:[
cg@2644
   839
        (buildDirectory / package module) makeDirectory.
cg@2644
   840
    ].
cg@2644
   841
cg@2644
   842
    "/ file out the package(s) which are to be built
cg@2644
   843
    ((Array with:package))
cg@2644
   844
    do:[:eachPackageToFileout |
cg@2981
   845
        |packageId packageModule packageDirectory packageTargetDir packageDef extSource|
cg@2644
   846
cg@2644
   847
        packageId := eachPackageToFileout asPackageId.
cg@2644
   848
        packageModule := packageId module.
cg@2644
   849
        packageDirectory := packageId directory.
cg@2644
   850
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   851
cg@2644
   852
        packageDef := packageId projectDefinitionClass.
cg@2644
   853
        (packageDef compiled_classNames_common ,
cg@2644
   854
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   855
            |cls fileName newSource|
cg@2644
   856
cg@2644
   857
            cls := Smalltalk classNamed:eachClassName.
cg@3182
   858
            (cls notNil and:[cls isLoaded]) ifFalse:[
cg@3182
   859
                self error:'missing class: ',eachClassName mayProceed:true
cg@3182
   860
            ].
cg@2644
   861
            fileName := (Smalltalk fileNameForClass:cls),'.st'.
cg@2644
   862
            fileName := packageTargetDir asFilename construct:fileName.
cg@2644
   863
            fileName exists ifTrue:[
cg@2644
   864
                newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
cg@2644
   865
                newSource = fileName contentsAsString ifFalse:[
cg@2644
   866
                    fileName contents:newSource
cg@2644
   867
                ].
cg@2644
   868
            ] ifFalse:[
cg@2644
   869
                cls fileOutIn:packageTargetDir withTimeStamp:false
cg@2644
   870
            ].
cg@2644
   871
        ].
cg@2644
   872
cg@2981
   873
        packageDef hasExtensionMethods ifTrue:[
cg@2981
   874
            extSource := 
cg@2981
   875
                String streamContents:[:s |
cg@2985
   876
                    s nextPutAll:('"{ Package: ''%1'' }" !!\\' bindWith:packageDef package) withCRs.
cg@2985
   877
cg@2981
   878
                    packageDef extensionMethods do:[:eachMethod |
cg@2981
   879
                        eachMethod mclass fileOutMethod:eachMethod on:s
cg@2981
   880
                    ].
cg@2981
   881
                ].
cg@2987
   882
            extSource isWideString ifTrue:[
cg@2987
   883
                extSource := ( '"{ Encoding: utf8 }"' , Character cr asString, Character cr asString, extSource).
cg@2987
   884
                extSource := extSource utf8Encoded.
cg@2987
   885
            ].
cg@2985
   886
            (packageTargetDir asFilename construct:'extensions.st') contents:extSource
cg@2981
   887
        ].
cg@2981
   888
cg@2644
   889
"/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
cg@2644
   890
"/            cls isPrivate ifFalse:[
cg@2644
   891
"/                cls isLoaded ifFalse:[
cg@2644
   892
"/                    self halt.
cg@2644
   893
"/                    cls autoload.
cg@2644
   894
"/                ].
cg@2644
   895
"/                cls fileOutIn:packageTargetDir
cg@2644
   896
"/            ]
cg@2644
   897
"/        ].
cg@3042
   898
        self generateBuildSupportFilesByFilingOutIn:packageTargetDir forDefinitionClass:projectDefinitionClass.
cg@2644
   899
    ].
cg@2972
   900
    self makeQuick ifFalse:[
cg@3042
   901
        "/ generate header files and build support files
cg@3042
   902
        "/ in prerequisite packages...
cg@2972
   903
        (projectDefinitionClass allPreRequisites)
cg@2972
   904
        do:[:eachPackageToFileout |
cg@2972
   905
            |packageId packageDef packageModule packageDirectory packageTargetDir|
cg@2644
   906
cg@2972
   907
            packageId := eachPackageToFileout asPackageId.
cg@2972
   908
            packageModule := packageId module.
cg@2972
   909
            packageDirectory := packageId directory.
cg@2972
   910
            packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   911
cg@2972
   912
            packageDef := packageId projectDefinitionClass.
cg@2972
   913
            (packageDef compiled_classNames_common ,
cg@2972
   914
            packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2972
   915
                |cls|
cg@2644
   916
cg@2972
   917
                cls := Smalltalk classNamed:eachClassName.
cg@2972
   918
                "/ self assert:cls isLoaded.
cg@2972
   919
                cls isNil ifTrue:[
cg@2972
   920
                    stdErr nextPutLine:('Missing class: ',eachClassName, ' (not present in system. Warning only:subclasses of it will not be compiled)').
cg@2972
   921
                ] ifFalse:[
cg@2972
   922
                    cls isLoaded ifTrue:[    
cg@2972
   923
                        self createHeaderFileFor:cls in:packageTargetDir
cg@2972
   924
                    ]
cg@2972
   925
                ].
cg@2644
   926
            ].
cg@2972
   927
            self copyResourcesForPackage:eachPackageToFileout.
cg@3042
   928
            self generateBuildSupportFilesByFilingOutIn:packageTargetDir forDefinitionClass:packageDef.
cg@3042
   929
            (packageTargetDir / '.NOSOURCE') contents:'existence of this file suppresses compilation of st files'.
cg@2644
   930
        ].
cg@2644
   931
    ].
cg@2644
   932
cg@2644
   933
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   934
!
cg@2596
   935
cg@2909
   936
makeCommandOfCompiler:usedCompiler
cg@2909
   937
    usedCompiler = 'bcc' ifTrue:[ 
cg@2909
   938
        ^ 'bmake'.
cg@2909
   939
    ].
cg@2909
   940
    usedCompiler = 'vc' ifTrue:[ 
cg@2909
   941
        ^ 'vcmake'. "/ compilerFlag := '-DUSEVC' 
cg@2909
   942
    ].
cg@2909
   943
    usedCompiler = 'lcc' ifTrue:[ 
cg@2909
   944
        ^ 'lccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   945
    ].
cg@2909
   946
    usedCompiler = 'tcc' ifTrue:[ 
cg@2909
   947
        ^ 'tccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   948
    ].
cg@2918
   949
    usedCompiler = 'mingw' ifTrue:[ 
cg@2921
   950
        ^ 'mingwmake'.  "/ compilerFlag := '-DUSEMINGW' 
cg@2909
   951
    ].
cg@2989
   952
    true "usedCompiler = 'gcc'" ifTrue:[ 
cg@2989
   953
        ^ 'make'.       "/ compilerFlag := '-DUSEGCC' 
cg@2989
   954
    ].
cg@2909
   955
    self error:'unknown compiler specified'.
cg@2909
   956
cg@2909
   957
    "Created: / 03-09-2012 / 19:46:07 / cg"
cg@2909
   958
!
cg@2909
   959
cg@2644
   960
makeWithOutputTo:stdOut errorTo:stdErr
cg@3127
   961
    |module directory makeCommand forceArg makeTarget|
cg@2644
   962
cg@2644
   963
    module := package module.
cg@2644
   964
    directory := package directory.
cg@2644
   965
cg@2680
   966
    makeCommand := ParserFlags makeCommand.
cg@2895
   967
    usedCompiler isNil ifTrue:[
cg@2895
   968
        usedCompiler := ParserFlags usedCompiler.
cg@2895
   969
    ].
cg@2909
   970
    makeCommand := self makeCommandOfCompiler:usedCompiler.
cg@3072
   971
    forceArg := ''.
cg@3072
   972
    
cg@2852
   973
    "/ makeCommand := makeCommand, ' TOP=', mySTXTopDirectory pathName.
cg@2680
   974
sr@2683
   975
    OperatingSystem isUNIXlike ifTrue:[
cg@3072
   976
        forceArg := ' FORCE='.
cg@3072
   977
cg@2921
   978
        "/ generate the makefile first
cg@2984
   979
        self activityNotification:('sh %1/rules/stmkmf (in %2)' 
cg@2984
   980
                    bindWith:mySTXTopDirectory pathName    
cg@2984
   981
                    with:(buildDirectory / module / directory)).
sr@2683
   982
        OperatingSystem
sv@2845
   983
            executeCommand:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName)
sr@2683
   984
            inputFrom:nil
sr@2683
   985
            outputTo:stdOut
sr@2683
   986
            errorTo:stdErr
sr@2683
   987
            inDirectory:(buildDirectory / module / directory)
cg@2921
   988
            onError:[:status | self error:'make failed'].
sr@2683
   989
    ].
sr@2683
   990
cg@2644
   991
    projectDefinitionClass isLibraryDefinition ifTrue:[
cg@2921
   992
        "/ generate the library
cg@2969
   993
        self activityNotification:(makeCommand,' classLibRule').
cg@2644
   994
        OperatingSystem
cg@3072
   995
            executeCommand:(makeCommand,' classLibRule',forceArg)
cg@2644
   996
            inputFrom:nil
cg@2644
   997
            outputTo:stdOut
cg@2644
   998
            errorTo:stdErr
cg@2644
   999
            inDirectory:(buildDirectory / module / directory)
cg@2921
  1000
            onError:[:status | self error:'make failed'].
cg@2644
  1001
    ] ifFalse:[
cg@2972
  1002
        (self makeExeOnly) ifTrue:[
cg@3127
  1003
            makeTarget := 'exe'
cg@3127
  1004
        ] ifFalse:[
cg@3127
  1005
            (self makeAppOnly) ifTrue:[
cg@3127
  1006
                makeTarget := 'app'
cg@3127
  1007
            ] ifFalse:[
cg@3127
  1008
                makeTarget := 'ALL_NP'
cg@3127
  1009
            ].
cg@3127
  1010
            self activityNotification:(makeCommand,' ',makeTarget).
cg@2969
  1011
            OperatingSystem
cg@2969
  1012
                "/ generate the executable
cg@3127
  1013
                executeCommand:(makeCommand,' ',makeTarget,forceArg)
cg@2673
  1014
                inputFrom:nil
cg@2673
  1015
                outputTo:stdOut
cg@2673
  1016
                errorTo:stdErr
cg@2673
  1017
                inDirectory:(buildDirectory / module / directory)
cg@2921
  1018
                onError:[:status | self error:'make failed'].
cg@2673
  1019
        ]
cg@2644
  1020
    ]
cg@2793
  1021
cg@3072
  1022
    "Modified: / 28-01-2014 / 21:48:07 / cg"
cg@2611
  1023
!
cg@2611
  1024
cg@2905
  1025
objDirForUsedCompiler
cg@2909
  1026
    ^ self objDirForUsedCompiler:usedCompiler
cg@2909
  1027
cg@2909
  1028
    "Created: / 20-08-2012 / 17:01:13 / cg"
cg@2909
  1029
!
cg@2909
  1030
cg@2909
  1031
objDirForUsedCompiler:usedCompiler
cg@2918
  1032
    usedCompiler = 'gcc' ifTrue:[^ 'obj'].      "/ unix case
cg@2918
  1033
cg@2905
  1034
    usedCompiler = 'bcc' ifTrue:[^ 'objbc'].
cg@2905
  1035
    usedCompiler = 'vc' ifTrue:[^ 'objvc'].
cg@2909
  1036
    usedCompiler = 'tcc' ifTrue:[^ 'objtcc'].
cg@2909
  1037
    usedCompiler = 'lcc' ifTrue:[^ 'objlcc'].
cg@2918
  1038
    usedCompiler = 'mingw' ifTrue:[^ 'objmingw'].
cg@2961
  1039
    self halt:'please add compiler here'.
cg@2905
  1040
    ^ 'objbc'
cg@2905
  1041
cg@2909
  1042
    "Created: / 03-09-2012 / 19:55:34 / cg"
cg@2905
  1043
!
cg@2905
  1044
sr@2683
  1045
recursiveCopyDirectoryForBuild:subdir
sr@2683
  1046
    |targetDir|
sr@2683
  1047
sr@2683
  1048
    targetDir := buildDirectory / 'stx' / subdir.
sr@2683
  1049
    targetDir exists ifFalse:[
sr@2683
  1050
        targetDir makeDirectory.
sr@2683
  1051
    ].
sr@2683
  1052
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
sr@2683
  1053
        eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
sr@2683
  1054
    ].
sr@2683
  1055
    self activityNotification:nil
sr@2683
  1056
!
sr@2683
  1057
cg@2644
  1058
setupBuildDirectory
cg@2984
  1059
    self activityNotification:('Building in %1' bindWith:buildDirectory pathName).
cg@2984
  1060
cg@2644
  1061
    buildDirectory exists ifFalse:[
cg@2644
  1062
        buildDirectory recursiveMakeDirectory.
cg@2644
  1063
    ].
cg@2644
  1064
    (buildDirectory / 'stx') exists ifFalse:[
cg@2644
  1065
        (buildDirectory / 'stx') makeDirectory.
cg@2644
  1066
    ].
cg@2644
  1067
cg@2644
  1068
    self copyDirectoryForBuild:'include'.
cg@2644
  1069
    self copyDirectoryForBuild:'rules'.
cg@2984
  1070
sr@2683
  1071
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
  1072
        self recursiveCopyDirectoryForBuild:'configurations'.
sr@2683
  1073
    ]
cg@2635
  1074
!
cg@2596
  1075
cg@2644
  1076
validateBuildDirectoryIsPresent
cg@2644
  1077
cg@2644
  1078
    ^ self.
cg@2644
  1079
cg@2644
  1080
"/    [
cg@2644
  1081
"/        |default directoryIsOKForMe stc |
cg@2644
  1082
"/
cg@2644
  1083
"/        default := (buildDirectory ?
cg@2644
  1084
"/                          PreviousBuildDirectory)
cg@2644
  1085
"/                          ifNil:[ UserPreferences current buildDirectory].
cg@2644
  1086
"/
cg@2644
  1087
"/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
cg@2644
  1088
"/                                 default:default.
cg@2644
  1089
"/
cg@2644
  1090
"/        buildDirectory isEmptyOrNil ifTrue:[^ self].
cg@2644
  1091
"/        buildDirectory := buildDirectory asFilename.
cg@2644
  1092
"/        directoryIsOKForMe := true.
cg@2644
  1093
"/
cg@2644
  1094
"/        buildDirectory exists ifFalse:[
cg@2644
  1095
"/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
cg@2644
  1096
"/            directoryIsOKForMe := false.
cg@2644
  1097
"/        ] ifTrue:[
cg@2644
  1098
"/            (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
  1099
"/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
cg@2644
  1100
"/                directoryIsOKForMe := false.
cg@2644
  1101
"/            ] ifTrue:[
cg@2644
  1102
"/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
cg@2644
  1103
"/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
cg@2644
  1104
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
cg@2644
  1105
"/                    directoryIsOKForMe := false.
cg@2644
  1106
"/                ].
cg@2644
  1107
"/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
cg@2644
  1108
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
cg@2644
  1109
"/                    directoryIsOKForMe := false.
cg@2644
  1110
"/                ].
cg@2644
  1111
"/            ]
cg@2644
  1112
"/        ].
cg@2644
  1113
"/        directoryIsOKForMe
cg@2644
  1114
"/    ] whileFalse
cg@2596
  1115
! !
cg@2596
  1116
cg@2596
  1117
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
  1118
cg@2896
  1119
version
cg@2896
  1120
    ^ '$Header$'
cg@2896
  1121
!
cg@2896
  1122
cg@2596
  1123
version_CVS
cg@2596
  1124
    ^ '$Header$'
cg@2596
  1125
! !
cg@2958
  1126