author | Claus Gittinger <cg@exept.de> |
Sun, 11 Oct 2009 02:27:08 +0200 | |
changeset 2613 | b8d38caaa884 |
parent 2612 | 2e735008a4d8 |
child 2614 | ff815b56c808 |
permissions | -rw-r--r-- |
2596 | 1 |
"{ Package: 'stx:libtool2' }" |
2 |
||
3 |
Object subclass:#ProjectBuilder |
|
4 |
instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory |
|
2598 | 5 |
myWorkingDirectory mySTXTopDirectory myTopDirectory' |
2596 | 6 |
classVariableNames:'PreviousBuildDirectory' |
7 |
poolDictionaries:'' |
|
8 |
category:'System-Support-Projects' |
|
9 |
! |
|
10 |
||
11 |
||
12 |
!ProjectBuilder class methodsFor:'examples'! |
|
13 |
||
14 |
example1 |
|
15 |
Smalltalk loadPackage:'stx:projects/helloWorldApp' asAutoloaded:true. |
|
16 |
||
17 |
self new |
|
18 |
package:'stx:projects/helloWorldApp'; |
|
19 |
build |
|
20 |
! ! |
|
21 |
||
22 |
!ProjectBuilder methodsFor:'accessing'! |
|
23 |
||
24 |
package:aPackageIDOrSymbol |
|
25 |
package := aPackageIDOrSymbol asPackageId. |
|
26 |
! |
|
27 |
||
28 |
projectDefinitionClass:something |
|
29 |
projectDefinitionClass := something. |
|
30 |
! ! |
|
31 |
||
32 |
!ProjectBuilder methodsFor:'building'! |
|
33 |
||
34 |
build |
|
35 |
"/ intermediate - this will move into a commonly used utility class |
|
36 |
"/ (where all the project code support will be collected). |
|
37 |
||
2611 | 38 |
|makeOutput stdOut stdErr lock| |
39 |
||
40 |
lock := Semaphore forMutualExclusion. |
|
41 |
makeOutput := TextStream on:(Text new:10000). |
|
42 |
stdErr := ActorStream new |
|
43 |
nextPutBlock:[:char | |
|
44 |
lock critical:[ |
|
45 |
makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}. |
|
46 |
makeOutput nextPut:char. |
|
47 |
makeOutput emphasis:nil. |
|
48 |
] |
|
49 |
]; |
|
50 |
nextPutAllBlock:[:char | |
|
51 |
lock critical:[ |
|
52 |
makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}. |
|
53 |
makeOutput nextPutAll:char. |
|
54 |
makeOutput emphasis:nil. |
|
55 |
] |
|
56 |
]. |
|
57 |
stdOut := ActorStream new |
|
58 |
nextPutBlock:[:char | |
|
59 |
lock critical:[ |
|
60 |
makeOutput nextPut:char. |
|
61 |
] |
|
62 |
]; |
|
63 |
nextPutAllBlock:[:char | |
|
64 |
lock critical:[ |
|
65 |
makeOutput nextPutAll:char. |
|
66 |
] |
|
67 |
]. |
|
68 |
||
69 |
self buildWithOutputTo:stdOut errorTo:stdErr. |
|
70 |
||
71 |
TextView openWith:makeOutput contents. |
|
72 |
! |
|
73 |
||
74 |
buildWithOutputTo:stdOut errorTo:stdErr |
|
75 |
"/ intermediate - this will move into a commonly used utility class |
|
76 |
"/ (where all the project code support will be collected). |
|
77 |
||
2596 | 78 |
|module directory| |
79 |
||
80 |
projectDefinitionClass := ProjectDefinition definitionClassForPackage:package. |
|
81 |
projectDefinitionClass isNil ifTrue:[ |
|
82 |
self error:('Missing ProjectDefinition class for "',package asString,'"') |
|
83 |
]. |
|
84 |
||
85 |
"/ ensure that everything is loaded... |
|
86 |
projectDefinitionClass loadAsAutoloaded:false. |
|
87 |
projectDefinitionClass loadExtensions. |
|
88 |
projectDefinitionClass loadAllClassesAsAutoloaded:false. |
|
89 |
||
90 |
module := package module. |
|
91 |
directory := package directory. |
|
92 |
||
93 |
buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ]. |
|
94 |
buildDirectory isNil ifTrue:[ |
|
95 |
buildDirectory := Filename tempDirectory construct:'stx_build'. |
|
96 |
]. |
|
97 |
buildDirectory := buildDirectory asFilename. |
|
98 |
||
99 |
"/ self validateBuildDirectoryIsPresent. |
|
100 |
||
101 |
PreviousBuildDirectory := buildDirectory. |
|
102 |
||
103 |
"/ UserPreferences current localBuild:true |
|
104 |
UserPreferences current localBuild ifFalse:[ |
|
105 |
SourceCodeManager notNil ifTrue:[ |
|
106 |
sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass. |
|
107 |
] |
|
108 |
]. |
|
109 |
sourceCodeManager := nil. |
|
110 |
||
2598 | 111 |
myTopDirectory := |
2596 | 112 |
Smalltalk packagePath |
113 |
detect:[:aPath | |
|
114 |
(aPath asFilename / 'stx' / 'include') exists |
|
115 |
and: [ (aPath asFilename / 'stx' / 'rules') exists ]] |
|
116 |
ifNone:nil. |
|
2598 | 117 |
myTopDirectory isNil ifTrue:[ |
118 |
self error:('Cannot figure out my top directory (where stx/include and stx/rules are)') |
|
2596 | 119 |
]. |
2598 | 120 |
myTopDirectory := myTopDirectory asFilename. |
121 |
mySTXTopDirectory := myTopDirectory / 'stx'. |
|
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
122 |
|
2596 | 123 |
self setupBuildDirectory. |
2599 | 124 |
self copySTCDirectoryForBuild. |
2596 | 125 |
self generateSourceFiles. |
2600 | 126 |
self copyDLLsForLinkage. |
127 |
self copySupportFilesForLinkage. |
|
128 |
self copyStartupFilesFromSmalltalk. |
|
2596 | 129 |
|
2611 | 130 |
self makeWithOutputTo:stdOut errorTo:stdErr. |
2596 | 131 |
! |
132 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
133 |
stdErr. |
2600 | 134 |
! |
135 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
136 |
]. |
2598 | 137 |
! |
138 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
139 |
'stx'). |
2599 | 140 |
! |
141 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
142 |
ion:nil |
2600 | 143 |
! |
144 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
145 |
]. |
2600 | 146 |
! |
147 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
148 |
ion:nil |
2596 | 149 |
! |
150 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
151 |
] |
2596 | 152 |
! |
153 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
154 |
]. |
2596 | 155 |
! |
156 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
157 |
]. |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
158 |
! |
2598 | 159 |
|
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
160 |
] |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
161 |
! |
2599 | 162 |
|
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
163 |
f halt. |
2596 | 164 |
! |
165 |
||
2611 | 166 |
makeWithOutputTo:stdOut errorTo:stdErr |
167 |
|module directory| |
|
168 |
||
169 |
module := package module. |
|
170 |
directory := package directory. |
|
171 |
||
2612 | 172 |
projectDefinitionClass isLibraryDefinition ifTrue:[ |
173 |
OperatingSystem |
|
174 |
executeCommand:(ParserFlags makeCommand,' classLibRule') |
|
175 |
inputFrom:nil |
|
176 |
outputTo:stdOut |
|
177 |
errorTo:stdErr |
|
178 |
inDirectory:(buildDirectory / module / directory) |
|
179 |
onError:[:status| self error:'make failed']. |
|
180 |
] ifFalse:[ |
|
181 |
OperatingSystem |
|
182 |
executeCommand:(ParserFlags makeCommand,' exe') |
|
183 |
inputFrom:nil |
|
184 |
outputTo:stdOut |
|
185 |
errorTo:stdErr |
|
186 |
inDirectory:(buildDirectory / module / directory) |
|
187 |
onError:[:status| self error:'make failed']. |
|
2611 | 188 |
|
2612 | 189 |
OperatingSystem |
190 |
executeCommand:(ParserFlags makeCommand,' setup') |
|
191 |
inputFrom:nil |
|
192 |
outputTo:stdOut |
|
193 |
errorTo:stdErr |
|
194 |
inDirectory:(buildDirectory / module / directory) |
|
195 |
onError:[:status| self error:'make failed']. |
|
196 |
] |
|
2611 | 197 |
! |
198 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
199 |
errorTo:stdErr |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
200 |
inDirectory:(buildDirectory / module / directory) |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
201 |
onError:[:status| self error:'make failed']. |
2596 | 202 |
|
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
203 |
OperatingSystem |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
204 |
executeCommand:(ParserFlags makeCommand,' setup') |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
205 |
inputFrom:nil |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
206 |
outputTo:stdOut |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
207 |
errorTo:stdErr |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
208 |
inDirectory:(buildDirectory / module / directory) |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
209 |
onError:[:status| self error:'make failed']. |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
210 |
] |
2596 | 211 |
! |
212 |
||
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
213 |
:stdErr |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
214 |
inDirectory:(buildDirectory / module / directory) |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
215 |
onError:[:status| self error:'make failed']. |
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
216 |
] |
2596 | 217 |
! ! |
218 |
||
219 |
!ProjectBuilder class methodsFor:'documentation'! |
|
220 |
||
221 |
version_CVS |
|
222 |
^ '$Header$' |
|
223 |
! ! |