]>
Commit | Line | Data |
---|---|---|
61e89487 GD |
1 | -- |
2 | -- File: BuildSamplesM5.as | |
3 | -- Purpose: Automatic build of samples with CodeWarrior 5 | |
4 | -- Author: Gilles Depeyrot | |
5 | -- Created: 06.10.2001 | |
6 | -- | |
7 | ||
8 | -- | |
9 | -- This AppleScript automatically recurses through the selected folder looking for | |
10 | -- and building CodeWarrior projects. | |
11 | -- To use this script, simply open it with the 'Script Editor' and run it. | |
12 | -- | |
13 | ||
14 | -- | |
15 | -- Suffix used to recognize CodeWarrior project files | |
16 | -- | |
17 | property gProjectSuffix : "M5.mcp" | |
18 | ||
19 | -- | |
20 | -- Values used to create the log file | |
21 | -- | |
22 | property gEol : " | |
23 | " | |
24 | property gSeparator : "--------------------------------------------------------------------------------" & gEol | |
25 | ||
26 | -- | |
27 | -- Project and build success count | |
28 | -- | |
29 | set theProjectCount to 0 | |
30 | set theProjectSuccessCount to 0 | |
31 | ||
32 | -- | |
33 | -- Default log file name | |
34 | -- | |
35 | set theDate to (day of (current date)) & "/" & GetMonthIndex(current date) & "/" & (year of (current date)) | |
36 | set theLogFileName to "wxMac samples " & theDate & ".log" | |
37 | ||
38 | -- | |
39 | -- Ask the user to select the wxWindows samples folder | |
40 | -- | |
41 | set theFolder to choose folder with prompt "Select the wxWindows samples folder" | |
42 | ||
43 | -- | |
44 | -- Ask the user to choose the build log file | |
45 | -- | |
46 | set theLogFile to choose file name with prompt "Create the wxWindows samples build log file" default name theLogFileName | |
47 | ||
48 | -- | |
49 | -- Open the log file to record the build log | |
50 | -- | |
51 | set theLogFileRef to open for access theLogFile with write permission | |
52 | ||
53 | -- | |
54 | -- Write log file header | |
55 | -- | |
56 | write gSeparator starting at 0 to theLogFileRef | |
57 | write "wxWindows samples build log" & gEol to theLogFileRef | |
58 | write gSeparator to theLogFileRef | |
59 | write "start on " & ((current date) as string) & gEol to theLogFileRef | |
60 | write gSeparator to theLogFileRef | |
61 | write "building projects in '" & (theFolder as string) & "'" & gEol to theLogFileRef | |
62 | write gSeparator to theLogFileRef | |
63 | ||
64 | -- | |
65 | -- Build or Rebuild targets? | |
66 | -- | |
67 | set theText to "Build or rebuild projects?" | |
68 | set theBuild to button returned of (display dialog theText buttons {"Cancel", "Build", "Rebuild"} default button "Rebuild" with icon note) | |
69 | if theBuild is not equal to "Cancel" then | |
70 | -- | |
71 | -- Build which targets? | |
72 | -- | |
73 | set theText to theBuild & " Classic or Carbon targets?" | |
74 | set theType to button returned of (display dialog theText buttons {"Cancel", "Classic", "Carbon"} default button "Carbon" with icon note) | |
75 | if theType is not equal to "Cancel" then | |
76 | -- | |
77 | -- Build Debug or Release targets? | |
78 | -- | |
79 | set theText to theBuild & " " & theType & " Debug or " & theType & " Release targets?" | |
80 | set theOption to button returned of (display dialog theText buttons {"Cancel", "Release", "Debug"} default button "Debug" with icon note) | |
81 | if theOption is not equal to "Cancel" then | |
82 | set theTarget to theType & " " & theOption | |
83 | ||
84 | write "building project targets '" & theTarget & "'" & gEol to theLogFileRef | |
85 | write gSeparator to theLogFileRef | |
86 | ||
87 | BuildProjects(theLogFileRef, theFolder, theTarget, theBuild is equal to "Rebuild") | |
88 | ||
89 | end if | |
90 | end if | |
91 | end if | |
92 | ||
93 | -- | |
94 | -- Write log file footer | |
95 | -- | |
96 | write "successful build of " & theProjectSuccessCount & " projects out of " & theProjectCount & gEol to theLogFileRef | |
97 | write gSeparator to theLogFileRef | |
98 | write "end on " & ((current date) as string) & gEol to theLogFileRef | |
99 | write gSeparator to theLogFileRef | |
100 | -- | |
101 | -- Close the log file | |
102 | -- | |
103 | close access theLogFileRef | |
104 | -- | |
105 | -- Open the file in BBEdit Lite | |
106 | -- | |
107 | tell application "BBEdit Lite 6.1" | |
108 | activate | |
109 | open theLogFile | |
110 | end tell | |
111 | ||
112 | -- | |
113 | -- BuildProjects | |
114 | -- | |
115 | on BuildProjects(inLogFileRef, inFolder, inTarget, inRebuild) | |
116 | global theProjectCount, theProjectSuccessCount | |
117 | ||
118 | tell application "Finder" to set theSubFolders to every folder of inFolder | |
119 | ||
120 | repeat with theFolder in theSubFolders | |
121 | ||
122 | tell application "Finder" to set theProject to (the first file of theFolder whose name ends with gProjectSuffix) | |
123 | ||
124 | if theProject as string is not "" then | |
125 | set theProjectCount to theProjectCount + 1 | |
126 | write "building project '" & (theProject as string) & "'" & gEol to inLogFileRef | |
127 | ||
128 | tell application "CodeWarrior IDE 4.0.4" | |
129 | -- | |
130 | -- Open the project in CodeWarrior | |
131 | -- | |
132 | open theProject as string | |
133 | -- | |
134 | -- Change to the requested target | |
135 | -- | |
136 | Set Current Target inTarget | |
137 | -- | |
138 | -- Remove object code if rebuild requested | |
139 | -- | |
140 | if inRebuild then | |
141 | Remove Binaries | |
142 | end if | |
143 | -- | |
144 | -- Build/Rebuild the selected target | |
145 | -- | |
146 | set theBuildInfo to Make Project with ExternalEditor | |
147 | -- | |
148 | -- Close the project | |
149 | -- | |
150 | Close Project | |
151 | end tell | |
152 | -- | |
153 | -- Report errors to build log file | |
154 | -- | |
155 | write gEol to inLogFileRef | |
156 | ReportBuildInfo(inLogFileRef, theBuildInfo) | |
157 | write gSeparator to inLogFileRef | |
158 | else | |
159 | BuildProjects(inLogFileRef, theFolder, inTarget, inRebuild) | |
160 | end if | |
161 | ||
162 | end repeat | |
163 | end BuildProjects | |
164 | ||
165 | -- | |
166 | -- ReportBuildInfo | |
167 | -- | |
168 | on ReportBuildInfo(inLogFileRef, inBuildInfo) | |
169 | global theProjectCount, theProjectSuccessCount | |
170 | ||
171 | set theErrorCount to 0 | |
172 | set theWarningCount to 0 | |
173 | ||
174 | repeat with theInfo in inBuildInfo | |
175 | tell application "CodeWarrior IDE 4.0.4" | |
176 | set theKind to ((messageKind of theInfo) as string) | |
177 | ||
178 | write "*** " & theKind & " *** " & message of theInfo & gEol to inLogFileRef | |
179 | try | |
180 | set theFile to ((file of theInfo) as string) | |
181 | on error | |
182 | set theFile to "" | |
183 | end try | |
184 | if theFile is not "" then | |
185 | write theFile & " line " & lineNumber of theInfo & gEol to inLogFileRef | |
186 | end if | |
187 | write gEol to inLogFileRef | |
188 | end tell | |
189 | ||
190 | if MessageKindIsError(theKind) then | |
191 | set theErrorCount to theErrorCount + 1 | |
192 | else | |
193 | set theWarningCount to theWarningCount + 1 | |
194 | end if | |
195 | end repeat | |
196 | ||
197 | if theErrorCount is 0 then | |
198 | set theProjectSuccessCount to theProjectSuccessCount + 1 | |
199 | write "build succeeded with " & theWarningCount & " warning(s)" & gEol to inLogFileRef | |
200 | else | |
201 | write "build failed with " & theErrorCount & " error(s) and " & theWarningCount & " warning(s)" & gEol to inLogFileRef | |
202 | end if | |
203 | end ReportBuildInfo | |
204 | ||
205 | -- | |
206 | -- MessageKindIsError | |
207 | -- | |
208 | on MessageKindIsError(inKind) | |
209 | if inKind is "compiler error" or inKind is "linker error" or inKind is "generic error" then | |
210 | return true | |
211 | else | |
212 | return false | |
213 | end if | |
214 | end MessageKindIsError | |
215 | ||
216 | -- | |
217 | -- GetMonthIndex | |
218 | -- | |
219 | on GetMonthIndex(inDate) | |
220 | set theMonth to the month of inDate | |
221 | set theMonthList to {January, February, March, April, May, June, July, August, September, October, November, December} | |
222 | repeat with i from 1 to the number of items in theMonthList | |
223 | if theMonth is item i of theMonthList then | |
224 | return i | |
225 | end if | |
226 | end repeat | |
227 | end GetMonthIndex |