]> git.saurik.com Git - wxWidgets.git/blob - docs/mac/M5build.applescript
fixes for handling WM_SYSCOLORCHANGE - now seems to work
[wxWidgets.git] / docs / mac / M5build.applescript
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 -----------------------------------------------------------------------------
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 "build-" & 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 folder in which to build the projects"
45
46 --
47 -- Ask the user to choose the build log file
48 --
49 set theLogFile to choose file name with prompt "Save the 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 "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 --
109 -- BuildProjects
110 --
111 on BuildProjects(inLogFileRef, inFolder, inTarget, inRebuild)
112 global theProjectCount, theProjectSuccessCount
113
114 tell application "Finder" to update inFolder
115
116 try
117 tell application "Finder" to set theProject to ((the first file of inFolder whose name ends with gProjectSuffix) as string)
118 on error
119 set theProject to ""
120 end try
121
122 if theProject is not "" then
123 set theProjectCount to theProjectCount + 1
124
125 write "building project '" & theProject & "'" & gEol to inLogFileRef
126
127 tell application "CodeWarrior IDE 4.0.4"
128 --
129 -- Open the project in CodeWarrior
130 --
131 open theProject
132 --
133 -- Change to the requested target
134 --
135 Set Current Target inTarget
136 --
137 -- Remove object code if rebuild requested
138 --
139 if inRebuild then
140 Remove Binaries
141 end if
142 --
143 -- Build/Rebuild the selected target
144 --
145 set theBuildInfo to Make Project with ExternalEditor
146 --
147 -- Close the project
148 --
149 Close Project
150 end tell
151 --
152 -- Report errors to build log file
153 --
154 write gEol to inLogFileRef
155 ReportBuildInfo(inLogFileRef, theBuildInfo)
156 write gSeparator to inLogFileRef
157 end if
158
159 tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
160 repeat with theFolder in theSubFolders
161 BuildProjects(inLogFileRef, theFolder, inTarget, inRebuild)
162 end repeat
163
164 end BuildProjects
165
166 --
167 -- ReportBuildInfo
168 --
169 on ReportBuildInfo(inLogFileRef, inBuildInfo)
170 global theProjectCount, theProjectSuccessCount
171
172 set theErrorCount to 0
173 set theWarningCount to 0
174
175 repeat with theInfo in inBuildInfo
176 tell application "CodeWarrior IDE 4.0.4"
177 set theKind to ((messageKind of theInfo) as string)
178
179 tell me to write "*** " & theKind & " *** " & message of theInfo & gEol to inLogFileRef
180 try
181 set theFile to ((file of theInfo) as string)
182 on error
183 set theFile to ""
184 end try
185 if theFile is not "" then
186 tell me to write theFile & " line " & lineNumber of theInfo & gEol to inLogFileRef
187 end if
188 tell me to write gEol to inLogFileRef
189 end tell
190
191 if MessageKindIsError(theKind) then
192 set theErrorCount to theErrorCount + 1
193 else
194 set theWarningCount to theWarningCount + 1
195 end if
196 end repeat
197
198 if theErrorCount is 0 then
199 set theProjectSuccessCount to theProjectSuccessCount + 1
200 write "build succeeded with " & theWarningCount & " warning(s)" & gEol to inLogFileRef
201 else
202 write "build failed with " & theErrorCount & " error(s) and " & theWarningCount & " warning(s)" & gEol to inLogFileRef
203 end if
204 end ReportBuildInfo
205
206 --
207 -- MessageKindIsError
208 --
209 on MessageKindIsError(inKind)
210 if inKind is "compiler error" or inKind is "linker error" or inKind is "generic error" then
211 return true
212 else
213 return false
214 end if
215 end MessageKindIsError
216
217 --
218 -- GetMonthIndex
219 --
220 on GetMonthIndex(inDate)
221 set theMonth to the month of inDate
222 set theMonthList to {January, February, March, April, May, June, July, August, September, October, November, December}
223 repeat with i from 1 to the number of items in theMonthList
224 if theMonth is item i of theMonthList then
225 return i
226 end if
227 end repeat
228 end GetMonthIndex