ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Tue, 20 Oct 2009 21:51:54 +0200
changeset 2634 3f14301cec84
parent 2633 4a48f107431a
child 2635 8b62bd023558
permissions -rw-r--r--
added: #buildDirectory:
changed: #buildWithOutputTo:errorTo:
cg@2596
     1
"{ Package: 'stx:libtool2' }"
cg@2596
     2
cg@2596
     3
Object subclass:#ProjectBuilder
cg@2596
     4
	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
cg@2598
     5
		myWorkingDirectory mySTXTopDirectory myTopDirectory'
cg@2596
     6
	classVariableNames:'PreviousBuildDirectory'
cg@2596
     7
	poolDictionaries:''
cg@2596
     8
	category:'System-Support-Projects'
cg@2596
     9
!
cg@2596
    10
cg@2596
    11
cg@2633
    12
!ProjectBuilder class methodsFor:'accessing'!
cg@2633
    13
cg@2633
    14
previousBuildDirectory
cg@2633
    15
    ^ PreviousBuildDirectory
cg@2633
    16
!
cg@2633
    17
cg@2633
    18
previousBuildDirectory:something
cg@2633
    19
    PreviousBuildDirectory := something.
cg@2633
    20
! !
cg@2633
    21
cg@2596
    22
!ProjectBuilder class methodsFor:'examples'!
cg@2596
    23
cg@2622
    24
!
cg@2622
    25
cg@2634
    26
methodsFor:'examples'
cg@2596
    27
! !
cg@2596
    28
cg@2596
    29
!ProjectBuilder methodsFor:'accessing'!
cg@2596
    30
cg@2634
    31
x:clients/Demos/foxCalcApplication'.
cg@2634
    32
    builder build.
cg@2634
    33
cg@2634
    34
    UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
cg@2622
    35
!
cg@2622
    36
cg@2634
    37
buildDirectory:something
cg@2634
    38
    buildDirectory := something.
cg@2634
    39
!
cg@2634
    40
cg@2634
    41
uilder build.
cg@2634
    42
cg@2634
    43
    UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
cg@2634
    44
!
cg@2634
    45
cg@2634
    46
kageBuildDirectory.
cg@2596
    47
!
cg@2596
    48
cg@2622
    49
packageBuildDirectory
cg@2622
    50
    "the directoray, where the deployable binary is created (xxxSetup.exe)"
cg@2622
    51
cg@2622
    52
    ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
cg@2596
    53
! !
cg@2596
    54
cg@2596
    55
!ProjectBuilder methodsFor:'building'!
cg@2596
    56
cg@2634
    57
(package asPackageId module) / (package asPackageId directory)
cg@2611
    58
!
cg@2611
    59
cg@2611
    60
buildWithOutputTo:stdOut errorTo:stdErr
cg@2611
    61
    "/ intermediate - this will move into a commonly used utility class
cg@2611
    62
    "/ (where all the project code support will be collected).
cg@2611
    63
cg@2596
    64
    |module directory|
cg@2596
    65
cg@2596
    66
    projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
cg@2596
    67
    projectDefinitionClass isNil ifTrue:[
cg@2596
    68
        self error:('Missing ProjectDefinition class for "',package asString,'"')
cg@2596
    69
    ].
cg@2596
    70
cg@2596
    71
    "/ ensure that everything is loaded...
cg@2596
    72
    projectDefinitionClass loadAsAutoloaded:false.
cg@2596
    73
    projectDefinitionClass loadExtensions.
cg@2596
    74
    projectDefinitionClass loadAllClassesAsAutoloaded:false.
cg@2596
    75
cg@2596
    76
    module := package module.
cg@2596
    77
    directory := package directory.
cg@2596
    78
cg@2596
    79
    buildDirectory isNil ifTrue:[
cg@2634
    80
        buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
cg@2634
    81
        buildDirectory isNil ifTrue:[
cg@2634
    82
            buildDirectory := Filename tempDirectory construct:'stx_build'.
cg@2634
    83
        ].
cg@2596
    84
    ].
cg@2596
    85
    buildDirectory := buildDirectory asFilename.
cg@2596
    86
cg@2596
    87
    "/ self validateBuildDirectoryIsPresent.
cg@2596
    88
cg@2596
    89
    PreviousBuildDirectory := buildDirectory.
cg@2596
    90
cg@2596
    91
    "/ UserPreferences current localBuild:true
cg@2596
    92
    UserPreferences current localBuild ifFalse:[
cg@2596
    93
        SourceCodeManager notNil ifTrue:[
cg@2596
    94
            sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass.
cg@2596
    95
        ]
cg@2596
    96
    ].
cg@2596
    97
    sourceCodeManager := nil.
cg@2596
    98
cg@2598
    99
    myTopDirectory := 
cg@2596
   100
        Smalltalk packagePath 
cg@2596
   101
            detect:[:aPath |
cg@2596
   102
                (aPath asFilename / 'stx' / 'include') exists
cg@2596
   103
                and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
cg@2596
   104
            ifNone:nil.       
cg@2598
   105
    myTopDirectory isNil ifTrue:[
cg@2598
   106
        self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
cg@2596
   107
    ].
cg@2598
   108
    myTopDirectory := myTopDirectory asFilename.
cg@2598
   109
    mySTXTopDirectory := myTopDirectory / 'stx'.
cg@2613
   110
cg@2596
   111
    self setupBuildDirectory.
cg@2628
   112
    self activityNotification:'Generating stc directory...'.
cg@2599
   113
    self copySTCDirectoryForBuild.
cg@2628
   114
    self activityNotification:'Generating source files...'.
cg@2596
   115
    self generateSourceFiles.
cg@2628
   116
    self activityNotification:'Generating dlls for linkage...'.
cg@2600
   117
    self copyDLLsForLinkage.
cg@2628
   118
    self activityNotification:'Generating support files for linkage...'.
cg@2600
   119
    self copySupportFilesForLinkage.
cg@2600
   120
    self copyStartupFilesFromSmalltalk.
cg@2596
   121
cg@2628
   122
    self activityNotification:'Executing make...'.
cg@2611
   123
    self makeWithOutputTo:stdOut errorTo:stdErr.
cg@2596
   124
!
cg@2596
   125
cg@2634
   126
...'.
cg@2634
   127
    self copySupportFilesForLinkage.
cg@2634
   128
    self copyStartupFilesFromSmalltalk.
cg@2614
   129
cg@2634
   130
    self activityNotification:'Executing make...'.
cg@2634
   131
    self makeWithOutputTo:stdOut errorTo:stdErr.
cg@2634
   132
!
cg@2614
   133
cg@2634
   134
(packageTargetDir / dllRelativePath) directory recursiveMakeDirectory.
cg@2614
   135
            (dllSourceDir / dllRelativePath) copyTo:(packageTargetDir / dllRelativePath).    
cg@2614
   136
        ]
cg@2614
   137
    ].
cg@2600
   138
!
cg@2600
   139
cg@2634
   140
tory:relativepath
cg@2614
   141
    "/ need rules in stx
cg@2614
   142
    ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
cg@2614
   143
        recursiveCopyTo:(buildDirectory construct:'stx').
cg@2596
   144
!
cg@2596
   145
cg@2634
   146
ification:'copying ',eachFile pathName,'...'.
cg@2614
   147
                eachFile copyTo:(targetDir construct:eachFile baseName)
cg@2614
   148
            ]
cg@2614
   149
        ].
cg@2614
   150
    ].
cg@2614
   151
    self activityNotification:nil
cg@2598
   152
!
cg@2598
   153
cg@2634
   154
tory / module / directory / 'styles' ) exists ifTrue:[
cg@2614
   155
        (myTopDirectory / module / directory / 'styles' )
cg@2614
   156
            recursiveCopyTo:(buildDirectory / module / directory)
cg@2614
   157
    ].
cg@2600
   158
!
cg@2600
   159
cg@2634
   160
me ]) ifTrue:[
cg@2614
   161
            self activityNotification:'copying ',sourceFile pathName,'...'.
cg@2614
   162
            sourceFile copyTo:targetFile
cg@2614
   163
        ].
cg@2614
   164
    ].
cg@2614
   165
    self activityNotification:nil
cg@2599
   166
!
cg@2599
   167
cg@2634
   168
'host.rc' 'h_win32.rc'  
cg@2614
   169
    ) do:[:fn |
cg@2614
   170
        (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2614
   171
            copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
cg@2614
   172
    ]
cg@2600
   173
!
cg@2600
   174
cg@2634
   175
ry / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
cg@2614
   176
            (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
cg@2614
   177
        ]
cg@2614
   178
    ].
cg@2600
   179
!
cg@2600
   180
cg@2634
   181
ename / ((Smalltalk fileNameForClass:aClass),'.STH').
cg@2614
   182
    (file exists not
cg@2614
   183
    or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
cg@2614
   184
        file contents: newContents.
cg@2614
   185
    ].
cg@2596
   186
!
cg@2596
   187
cg@2634
   188
self generateSourceFilesByCheckingOutUsing:sourceCodeManager
cg@2614
   189
    ] ifFalse:[
cg@2614
   190
        "/ local build
cg@2614
   191
        "/ fileout the project
cg@2614
   192
        self generateSourceFilesByFilingOut
cg@2614
   193
    ]
cg@2596
   194
!
cg@2596
   195
cg@2634
   196
:nil
cg@2614
   197
        outputTo:Transcript
cg@2614
   198
        errorTo:Transcript
cg@2614
   199
        inDirectory:(buildDirectory construct:module)
cg@2614
   200
        onError:[:status| self error:'cvs update failed'].
cg@2614
   201
self halt.
cg@2596
   202
!
cg@2596
   203
cg@2634
   204
or:cls in:packageTargetDir
cg@2614
   205
            ].
cg@2614
   206
        ].
cg@2614
   207
        self copyResourcesForPackage:eachPackageToFileout.
cg@2614
   208
    ].
cg@2614
   209
cg@2614
   210
"/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
cg@2596
   211
!
cg@2596
   212
cg@2634
   213
nil
cg@2612
   214
            outputTo:stdOut
cg@2612
   215
            errorTo:stdErr
cg@2612
   216
            inDirectory:(buildDirectory / module / directory)
cg@2612
   217
            onError:[:status| self error:'make failed'].
cg@2612
   218
    ]
cg@2611
   219
!
cg@2611
   220
cg@2634
   221
(buildDirectory / 'stx') exists ifFalse:[
cg@2614
   222
        (buildDirectory / 'stx') makeDirectory.
cg@2614
   223
    ].
cg@2596
   224
cg@2614
   225
    self copyDirectoryForBuild:'include'.
cg@2614
   226
    self copyDirectoryForBuild:'rules'.
cg@2596
   227
! !
cg@2596
   228
cg@2596
   229
!ProjectBuilder class methodsFor:'documentation'!
cg@2596
   230
cg@2596
   231
version_CVS
cg@2596
   232
    ^ '$Header$'
cg@2596
   233
! !