ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Mon, 11 Mar 2013 19:39:57 +0100
changeset 2969 d03c40cd3fa5
parent 2964 44fd164ad253
child 2971 e10937c35748
permissions -rw-r--r--
fixes and more flyby helps
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@2914
   637
            self error:'Missing file: ',relativePath printString mayProceed:true.
sr@2684
   638
        ].
cg@2644
   639
    ].
cg@2873
   640
cg@2918
   641
    "Modified: / 05-09-2012 / 16:26:25 / cg"
cg@2600
   642
!
cg@2600
   643
cg@2644
   644
createHeaderFileFor:aClass in:packageTargetDir
cg@2644
   645
    |instVarList classInstVarList classVarList bindings superclassFilename
cg@2644
   646
     template file newContents oldContents|
cg@2644
   647
cg@2644
   648
    instVarList := StringCollection new.
cg@2644
   649
    aClass instVarNames do:[:v |
cg@2644
   650
        instVarList add:('OBJ %1;' bindWith:v)
cg@2644
   651
    ].
cg@2644
   652
    classInstVarList := StringCollection new.
cg@2644
   653
    aClass class instVarNames do:[:v |
cg@2961
   654
    "/ (v includes:$_) ifTrue:[self halt].
cg@2644
   655
        classInstVarList add:('OBJ %1;' bindWith:v)
cg@2644
   656
    ].
cg@2644
   657
    classVarList := StringCollection new.
cg@2644
   658
    aClass classVarNames do:[:v |
cg@2644
   659
        classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
cg@2644
   660
    ].
cg@2644
   661
cg@2644
   662
    bindings := Dictionary new.
cg@2644
   663
    bindings at:'ClassName' put:aClass name. 
cg@2644
   664
    aClass superclass isNil ifTrue:[
cg@2644
   665
        bindings at:'SuperclassName' put:'-'. 
cg@2852
   666
        bindings at:'SuperclassFileInclude' put:''.
cg@2644
   667
    ] ifFalse:[
cg@2644
   668
        bindings at:'SuperclassName' put:aClass superclass name. 
cg@2644
   669
        bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
cg@2644
   670
        bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
cg@2644
   671
    ].
cg@2644
   672
    bindings at:'InstVarList' put:instVarList asString. 
cg@2644
   673
    bindings at:'ClassVarList' put:classVarList asString. 
cg@2644
   674
    bindings at:'ClassInstVarList' put:classInstVarList asString. 
cg@2644
   675
cg@2644
   676
    template := 
cg@2644
   677
'/* This file was generated by ProjectBuilder. */
cg@2644
   678
/* !!!!!!!! Do not change by hand !!!!!!!! */
cg@2644
   679
cg@2644
   680
/* Class: %(ClassName) */
cg@2644
   681
/* Superclass: %(SuperclassName) */
cg@2644
   682
cg@2644
   683
%(SuperclassFileInclude)
cg@2644
   684
cg@2644
   685
/* INDIRECTGLOBALS */
cg@2644
   686
#ifdef _HEADER_INST_
cg@2644
   687
%(InstVarList)
cg@2644
   688
#endif /* _HEADER_INST_ */
cg@2644
   689
cg@2644
   690
#ifdef _HEADER_CLASS_
cg@2644
   691
%(ClassVarList)
cg@2644
   692
#endif /* _HEADER_CLASS_ */
cg@2644
   693
cg@2644
   694
#ifdef _HEADER_CLASSINST_
cg@2644
   695
%(ClassInstVarList)
cg@2644
   696
#endif /* _HEADER_CLASSINST_ */
cg@2644
   697
'.
cg@2644
   698
    newContents := template bindWithArguments:bindings.
sr@2683
   699
    file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
cg@2644
   700
    (file exists not
cg@2644
   701
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2644
   702
        file contents: newContents.
cg@2644
   703
    ].
cg@2852
   704
cg@2852
   705
    "Modified: / 15-08-2011 / 14:58:46 / cg"
cg@2596
   706
!
cg@2596
   707
cg@2644
   708
generateSourceFiles
cg@2964
   709
    (self isLocalBuild not and:[ sourceCodeManager notNil ])  ifTrue:[
cg@2644
   710
        "/ check out / generate files there
cg@2644
   711
        self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2644
   712
    ] ifFalse:[
cg@2644
   713
        "/ local build
cg@2644
   714
        "/ fileout the project
cg@2644
   715
        self generateSourceFilesByFilingOut
cg@2644
   716
    ]
cg@2596
   717
!
cg@2596
   718
cg@2644
   719
generateSourceFilesByCheckingOutUsing:aSourceCodeManager
cg@2644
   720
    "/ will no longer be needed/supported
cg@2644
   721
cg@2644
   722
    |repository stxRepository module directory|
cg@2644
   723
cg@2868
   724
    self breakPoint:#cg.
cg@2868
   725
cg@2644
   726
    "/ check out / generate files there
cg@2644
   727
    repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
cg@2644
   728
    stxRepository := aSourceCodeManager repositoryName.
cg@2644
   729
cg@2644
   730
    (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
   731
        (module ~= 'stx') ifTrue:[
cg@2644
   732
            OperatingSystem
cg@2644
   733
                executeCommand:('cvs -d ',stxRepository,' co stx')
cg@2644
   734
                inputFrom:nil
cg@2644
   735
                outputTo:Transcript
cg@2644
   736
                errorTo:Transcript
cg@2644
   737
                inDirectory:buildDirectory
cg@2644
   738
                onError:[:status| self error:'cvs update stx failed'].
cg@2644
   739
        ].
cg@2644
   740
    ].
cg@2644
   741
cg@2644
   742
    ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
cg@2644
   743
        OperatingSystem
cg@2644
   744
            executeCommand:('cvs -d ',repository,' co -l ',directory)
cg@2644
   745
            inputFrom:nil
cg@2644
   746
            outputTo:Transcript
cg@2644
   747
            errorTo:Transcript
cg@2644
   748
            inDirectory:buildDirectory
cg@2644
   749
            onError:[:status| self error:'cvs update failed'].
cg@2644
   750
    ].
cg@2644
   751
    OperatingSystem
cg@2644
   752
        executeCommand:'cvs upd -d'
cg@2644
   753
        inputFrom:nil
cg@2644
   754
        outputTo:Transcript
cg@2644
   755
        errorTo:Transcript
cg@2644
   756
        inDirectory:(buildDirectory construct:module)
cg@2644
   757
        onError:[:status| self error:'cvs update failed'].
cg@2644
   758
self halt.
cg@2868
   759
cg@2868
   760
    "Modified: / 29-12-2011 / 14:02:56 / cg"
cg@2596
   761
!
cg@2596
   762
cg@2644
   763
generateSourceFilesByFilingOut
cg@2644
   764
    "/ local build
cg@2644
   765
    "/ fileout the project
cg@2644
   766
sv@2844
   767
    |fullPathName|
sv@2844
   768
cg@2644
   769
    (package module ~= 'stx') ifTrue:[
cg@2644
   770
        (buildDirectory / package module) makeDirectory.
cg@2644
   771
    ].
cg@2644
   772
cg@2644
   773
    "/ file out the package(s) which are to be built
cg@2644
   774
    ((Array with:package))
cg@2644
   775
    do:[:eachPackageToFileout |
cg@2644
   776
        |packageId packageModule packageDirectory packageTargetDir packageDef|
cg@2644
   777
cg@2644
   778
        packageId := eachPackageToFileout asPackageId.
cg@2644
   779
        packageModule := packageId module.
cg@2644
   780
        packageDirectory := packageId directory.
cg@2644
   781
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   782
cg@2644
   783
        packageDef := packageId projectDefinitionClass.
cg@2644
   784
        (packageDef compiled_classNames_common ,
cg@2644
   785
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   786
            |cls fileName newSource|
cg@2644
   787
cg@2644
   788
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   789
            self assert:cls isLoaded.
cg@2644
   790
            fileName := (Smalltalk fileNameForClass:cls),'.st'.
cg@2644
   791
            fileName := packageTargetDir asFilename construct:fileName.
cg@2644
   792
            fileName exists ifTrue:[
cg@2644
   793
                newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
cg@2644
   794
                newSource = fileName contentsAsString ifFalse:[
cg@2644
   795
                    fileName contents:newSource
cg@2644
   796
                ].
cg@2644
   797
            ] ifFalse:[
cg@2644
   798
                cls fileOutIn:packageTargetDir withTimeStamp:false
cg@2644
   799
            ].
cg@2644
   800
        ].
cg@2644
   801
cg@2644
   802
"/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
cg@2644
   803
"/            cls isPrivate ifFalse:[
cg@2644
   804
"/                cls isLoaded ifFalse:[
cg@2644
   805
"/                    self halt.
cg@2644
   806
"/                    cls autoload.
cg@2644
   807
"/                ].
cg@2644
   808
"/                cls fileOutIn:packageTargetDir
cg@2644
   809
"/            ]
cg@2644
   810
"/        ].
cg@2644
   811
cg@2644
   812
        projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
sv@2844
   813
            fullPathName := packageTargetDir construct:fileName.
sv@2844
   814
            fullPathName directory exists ifFalse:[
sv@2844
   815
                "take care for files like 'autopackage/default.apspec'"
sv@2844
   816
                fullPathName directory makeDirectory.
sv@2844
   817
            ].
sv@2844
   818
            (fullPathName exists
sv@2844
   819
             and:[ fullPathName contents = fileContents ]) ifFalse:[
sv@2844
   820
                fullPathName contents:fileContents.
cg@2644
   821
            ].
cg@2644
   822
        ].    
cg@2644
   823
    ].
cg@2644
   824
cg@2644
   825
    "/ generate header files in prerequisite packages...
cg@2644
   826
    (projectDefinitionClass allPreRequisites)
cg@2644
   827
    do:[:eachPackageToFileout |
cg@2644
   828
        |packageId packageDef packageModule packageDirectory packageTargetDir|
cg@2644
   829
cg@2644
   830
        packageId := eachPackageToFileout asPackageId.
cg@2644
   831
        packageModule := packageId module.
cg@2644
   832
        packageDirectory := packageId directory.
cg@2644
   833
        packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
cg@2644
   834
cg@2644
   835
        packageDef := packageId projectDefinitionClass.
cg@2644
   836
        (packageDef compiled_classNames_common ,
cg@2644
   837
        packageDef compiled_classNamesForPlatform) do:[:eachClassName |
cg@2644
   838
            |cls|
cg@2644
   839
cg@2644
   840
            cls := Smalltalk classNamed:eachClassName.
cg@2644
   841
            "/ self assert:cls isLoaded.
cg@2969
   842
            cls isNil ifTrue:[
cg@2969
   843
                stdErr nextPutLine:('Missing class: ',eachClassName, ' (not present in system. Warning only:subclasses of it will not be compiled)').
cg@2969
   844
            ] ifFalse:[
cg@2969
   845
                cls isLoaded ifTrue:[    
cg@2969
   846
                    self createHeaderFileFor:cls in:packageTargetDir
cg@2969
   847
                ]
cg@2644
   848
            ].
cg@2644
   849
        ].
cg@2644
   850
        self copyResourcesForPackage:eachPackageToFileout.
cg@2644
   851
    ].
cg@2644
   852
cg@2644
   853
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   854
!
cg@2596
   855
cg@2909
   856
makeCommandOfCompiler:usedCompiler
cg@2909
   857
    usedCompiler = 'bcc' ifTrue:[ 
cg@2909
   858
        ^ 'bmake'.
cg@2909
   859
    ].
cg@2909
   860
    usedCompiler = 'vc' ifTrue:[ 
cg@2909
   861
        ^ 'vcmake'. "/ compilerFlag := '-DUSEVC' 
cg@2909
   862
    ].
cg@2909
   863
    usedCompiler = 'lcc' ifTrue:[ 
cg@2909
   864
        ^ 'lccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   865
    ].
cg@2909
   866
    usedCompiler = 'tcc' ifTrue:[ 
cg@2909
   867
        ^ 'tccmake'. "/ compilerFlag := '-DUSELCC' 
cg@2909
   868
    ].
cg@2909
   869
    usedCompiler = 'gcc' ifTrue:[ 
cg@2921
   870
        ^ 'make'.       "/ compilerFlag := '-DUSEGCC' 
cg@2909
   871
    ].
cg@2918
   872
    usedCompiler = 'mingw' ifTrue:[ 
cg@2921
   873
        ^ 'mingwmake'.  "/ compilerFlag := '-DUSEMINGW' 
cg@2909
   874
    ].
cg@2909
   875
    self error:'unknown compiler specified'.
cg@2909
   876
cg@2909
   877
    "Created: / 03-09-2012 / 19:46:07 / cg"
cg@2909
   878
!
cg@2909
   879
cg@2644
   880
makeWithOutputTo:stdOut errorTo:stdErr
cg@2909
   881
    |module directory makeCommand|
cg@2644
   882
cg@2644
   883
    module := package module.
cg@2644
   884
    directory := package directory.
cg@2644
   885
cg@2680
   886
    makeCommand := ParserFlags makeCommand.
cg@2895
   887
    usedCompiler isNil ifTrue:[
cg@2895
   888
        usedCompiler := ParserFlags usedCompiler.
cg@2895
   889
    ].
cg@2909
   890
    makeCommand := self makeCommandOfCompiler:usedCompiler.
cg@2873
   891
cg@2852
   892
    "/ makeCommand := makeCommand, ' TOP=', mySTXTopDirectory pathName.
cg@2680
   893
sr@2683
   894
    OperatingSystem isUNIXlike ifTrue:[
cg@2921
   895
        "/ generate the makefile first
cg@2969
   896
        self activityNotification:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName).
sr@2683
   897
        OperatingSystem
sv@2845
   898
            executeCommand:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName)
sr@2683
   899
            inputFrom:nil
sr@2683
   900
            outputTo:stdOut
sr@2683
   901
            errorTo:stdErr
sr@2683
   902
            inDirectory:(buildDirectory / module / directory)
cg@2921
   903
            onError:[:status | self error:'make failed'].
sr@2683
   904
    ].
sr@2683
   905
cg@2644
   906
    projectDefinitionClass isLibraryDefinition ifTrue:[
cg@2921
   907
        "/ generate the library
cg@2969
   908
        self activityNotification:(makeCommand,' classLibRule').
cg@2644
   909
        OperatingSystem
cg@2680
   910
            executeCommand:(makeCommand,' classLibRule')
cg@2644
   911
            inputFrom:nil
cg@2644
   912
            outputTo:stdOut
cg@2644
   913
            errorTo:stdErr
cg@2644
   914
            inDirectory:(buildDirectory / module / directory)
cg@2921
   915
            onError:[:status | self error:'make failed'].
cg@2644
   916
    ] ifFalse:[
cg@2969
   917
        (makeExeOnly ? false) ifTrue:[
cg@2969
   918
            self activityNotification:(makeCommand,' exe').
cg@2969
   919
            OperatingSystem
cg@2969
   920
                "/ generate the executable
cg@2969
   921
                executeCommand:(makeCommand,' exe')
cg@2969
   922
                inputFrom:nil
cg@2969
   923
                outputTo:stdOut
cg@2969
   924
                errorTo:stdErr
cg@2969
   925
                inDirectory:(buildDirectory / module / directory)
cg@2969
   926
                onError:[:status | self error:'make failed'].
cg@2644
   927
cg@2969
   928
        ] ifFalse:[
cg@2921
   929
            "/ generate the self-installable package
cg@2969
   930
            self activityNotification:(makeCommand,' ALL_NP').
cg@2673
   931
            OperatingSystem
cg@2969
   932
                executeCommand:(makeCommand,' ALL_NP')
cg@2673
   933
                inputFrom:nil
cg@2673
   934
                outputTo:stdOut
cg@2673
   935
                errorTo:stdErr
cg@2673
   936
                inDirectory:(buildDirectory / module / directory)
cg@2921
   937
                onError:[:status | self error:'make failed'].
cg@2673
   938
        ]
cg@2644
   939
    ]
cg@2793
   940
cg@2909
   941
    "Modified: / 03-09-2012 / 19:47:15 / cg"
cg@2921
   942
    "Modified (comment): / 06-09-2012 / 16:22:38 / cg"
cg@2611
   943
!
cg@2611
   944
cg@2905
   945
objDirForUsedCompiler
cg@2909
   946
    ^ self objDirForUsedCompiler:usedCompiler
cg@2909
   947
cg@2909
   948
    "Created: / 20-08-2012 / 17:01:13 / cg"
cg@2909
   949
!
cg@2909
   950
cg@2909
   951
objDirForUsedCompiler:usedCompiler
cg@2918
   952
    usedCompiler = 'gcc' ifTrue:[^ 'obj'].      "/ unix case
cg@2918
   953
cg@2905
   954
    usedCompiler = 'bcc' ifTrue:[^ 'objbc'].
cg@2905
   955
    usedCompiler = 'vc' ifTrue:[^ 'objvc'].
cg@2909
   956
    usedCompiler = 'tcc' ifTrue:[^ 'objtcc'].
cg@2909
   957
    usedCompiler = 'lcc' ifTrue:[^ 'objlcc'].
cg@2918
   958
    usedCompiler = 'mingw' ifTrue:[^ 'objmingw'].
cg@2961
   959
    self halt:'please add compiler here'.
cg@2905
   960
    ^ 'objbc'
cg@2905
   961
cg@2909
   962
    "Created: / 03-09-2012 / 19:55:34 / cg"
cg@2905
   963
!
cg@2905
   964
sr@2683
   965
recursiveCopyDirectoryForBuild:subdir
sr@2683
   966
    |targetDir|
sr@2683
   967
sr@2683
   968
    targetDir := buildDirectory / 'stx' / subdir.
sr@2683
   969
    targetDir exists ifFalse:[
sr@2683
   970
        targetDir makeDirectory.
sr@2683
   971
    ].
sr@2683
   972
    (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
sr@2683
   973
        eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
sr@2683
   974
    ].
sr@2683
   975
    self activityNotification:nil
sr@2683
   976
!
sr@2683
   977
cg@2644
   978
setupBuildDirectory
cg@2644
   979
    buildDirectory exists ifFalse:[
cg@2644
   980
        buildDirectory recursiveMakeDirectory.
cg@2644
   981
    ].
cg@2644
   982
    (buildDirectory / 'stx') exists ifFalse:[
cg@2644
   983
        (buildDirectory / 'stx') makeDirectory.
cg@2644
   984
    ].
cg@2644
   985
cg@2644
   986
    self copyDirectoryForBuild:'include'.
cg@2644
   987
    self copyDirectoryForBuild:'rules'.
sr@2683
   988
    OperatingSystem isUNIXlike ifTrue:[
sr@2683
   989
        self recursiveCopyDirectoryForBuild:'configurations'.
sr@2683
   990
    ]
cg@2635
   991
!
cg@2596
   992
cg@2644
   993
validateBuildDirectoryIsPresent
cg@2644
   994
cg@2644
   995
    ^ self.
cg@2644
   996
cg@2644
   997
"/    [
cg@2644
   998
"/        |default directoryIsOKForMe stc |
cg@2644
   999
"/
cg@2644
  1000
"/        default := (buildDirectory ?
cg@2644
  1001
"/                          PreviousBuildDirectory)
cg@2644
  1002
"/                          ifNil:[ UserPreferences current buildDirectory].
cg@2644
  1003
"/
cg@2644
  1004
"/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
cg@2644
  1005
"/                                 default:default.
cg@2644
  1006
"/
cg@2644
  1007
"/        buildDirectory isEmptyOrNil ifTrue:[^ self].
cg@2644
  1008
"/        buildDirectory := buildDirectory asFilename.
cg@2644
  1009
"/        directoryIsOKForMe := true.
cg@2644
  1010
"/
cg@2644
  1011
"/        buildDirectory exists ifFalse:[
cg@2644
  1012
"/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
cg@2644
  1013
"/            directoryIsOKForMe := false.
cg@2644
  1014
"/        ] ifTrue:[
cg@2644
  1015
"/            (buildDirectory construct:'stx') exists ifFalse:[
cg@2644
  1016
"/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
cg@2644
  1017
"/                directoryIsOKForMe := false.
cg@2644
  1018
"/            ] ifTrue:[
cg@2644
  1019
"/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
cg@2644
  1020
"/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
cg@2644
  1021
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
cg@2644
  1022
"/                    directoryIsOKForMe := false.
cg@2644
  1023
"/                ].
cg@2644
  1024
"/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
cg@2644
  1025
"/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
cg@2644
  1026
"/                    directoryIsOKForMe := false.
cg@2644
  1027
"/                ].
cg@2644
  1028
"/            ]
cg@2644
  1029
"/        ].
cg@2644
  1030
"/        directoryIsOKForMe
cg@2644
  1031
"/    ] whileFalse
cg@2596
  1032
! !
cg@2596
  1033
cg@2596
  1034
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
  1035
cg@2896
  1036
version
cg@2896
  1037
    ^ '$Header$'
cg@2896
  1038
!
cg@2896
  1039
cg@2596
  1040
version_CVS
cg@2596
  1041
    ^ '$Header$'
cg@2596
  1042
! !
cg@2958
  1043