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