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