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