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