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