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