12 -- retrieves the files from the xml node including optional conditions
13 on parseSources(theName, theElement, theVariables, theConditions)
14 set AppleScript's text item delimiters to " "
16 repeat with currElement in XML contents of theElement
17 if class of currElement is text then
18 set allElements to allElements & (every text item of currElement)
20 if class of currElement is XML element and XML tag of currElement is "if" then
21 if (cond of XML attributes of currElement is in theConditions) then
22 set allElements to allElements & (every text item of (item 1 of XML contents of currElement))
27 set AppleScript's text item delimiters to oldDelimiters
28 copy {varname:theName, entries:allElements} to end of theVariables
31 on parseEntry(theElement, theVariables, theConditions)
32 set theName to var of XML attributes of theElement
33 parseSources(theName, theElement, theVariables, theConditions)
36 on parseLib(theElement, theVariables, theConditions)
37 set theName to |id| of XML attributes of theElement
38 repeat with currElement in XML contents of theElement
39 if class of currElement is XML element and XML tag of currElement is "sources" then
40 parseSources(theName, currElement, theVariables, theConditions)
45 on parseNode(anElement, theVariables, theConditions)
46 if class of anElement is XML element and Â
47 XML tag of anElement is "set" then
48 parseEntry(anElement, theVariables, theConditions)
50 if class of anElement is XML element and Â
51 XML tag of anElement is "lib" then
52 parseLib(anElement, theVariables, theConditions)
57 -- iterates through the entire xml tree and populates the variables
58 on parseFiles(theXML, theVariables, theConditions)
59 if class of theXML is XML element or class of theXML is XML document then
60 repeat with anElement in XML contents of theXML
62 parseNode(anElement, theVariables, theConditions)
67 else if class of theXML is list then
68 repeat with anElement in theXML
70 parseNode(anElement, theVariables, theConditions)
78 -- gets the entries of the variable named theName
80 repeat with anElement in variablesRef
81 if (varname of anElement is theName) then
82 return entries of anElement
87 -- adds sources from fileList to a group named container
88 on addNode(theContainer, fileList)
89 tell application "Xcode"
91 set theTargets to targets
92 repeat with listItem in fileList
93 if (listItem starts with "$(") then
94 set AppleScript's text item delimiters to ""
95 set variableName to (characters 3 through ((length of listItem) - 1) of listItem) as text
96 set AppleScript's text item delimiters to oldDelimiters
97 my addNode(theContainer, my getVar(variableName))
99 set AppleScript's text item delimiters to "/"
100 set currPath to every text item in listItem
101 set currFile to "../../" & listItem
102 set currFileName to (item -1 in currPath)
103 set currGroup to (items 1 through -2 in currPath as text)
104 set AppleScript's text item delimiters to oldDelimiters
106 set theGroup to group theContainer
109 make new group with properties {name:theContainer}
112 tell group theContainer
114 set theGroup to group named currGroup
116 make new group with properties {name:currGroup}
119 set newFile to make new file reference with properties {name:currFileName, path:currFile, path type:project relative}
120 repeat with theTarget in theTargets
121 add newFile to (get compile sources phase of theTarget)
131 -- retrieves contents of file at posixFilePath
132 on readFile(posixFilePath)
133 set fileRef to open for access POSIX file posixFilePath
134 set theData to read fileRef
140 tell application "Xcode"
143 set variablesRef to a reference to variables
144 set bakefilesXMLRef to a reference to bakefilesXML
145 set oldDelimiters to AppleScript's text item delimiters
146 tell application "Finder"
147 set osxBuildFolder to POSIX path of ((folder of (path to me)) as Unicode text)
151 -- reads the files list and evaluates the conditions
152 on readFilesList(theFiles, theConditions)
154 repeat with theFile in theFiles
155 set bakefilesXML to parse XML (readFile(osxBuildFolder & theFile))
156 parseFiles(bakefilesXMLRef, variablesRef, theConditions)
160 -- creates a new project file from the respective template
161 on instantiateProject(theProject)
162 set projectName to projectName of theProject
163 set template to POSIX file (osxBuildFolder & projectName & "_in.xcodeproj")
164 set projectFile to POSIX file (osxBuildFolder & projectName & ".xcodeproj")
165 tell application "Finder"
167 delete file projectFile
169 set duplicateProject to duplicate template with replace
170 set name of duplicateProject to (projectName & ".xcodeproj")
172 end instantiateProject
174 -- adds the source files of the nodes of theProject to the xcode project
175 on populateProject(theProject)
176 tell application "Xcode"
179 repeat with theNode in nodes of theProject
180 -- reopen xcode for each pass, as otherwise the undomanager
181 -- happens to crash quite frequently
182 addNode(label of theNode, entries of theNode)
184 tell application "Xcode"
187 do shell script (osxBuildFolder as text) & "fix_xcode_ids.py \"" & (POSIX path of projectFile as Unicode text) & "\""
188 -- reopen again to let Xcode sort identifiers
189 tell application "Xcode"
192 tell application "Xcode"
197 on makeProject(theProject)
198 instantiateProject(theProject)
199 readFilesList(bklfiles of theProject, conditions of theProject)
200 populateProject(theProject)
206 set theProject to {conditions:{"PLATFORM_MACOSX=='1'", "TOOLKIT=='OSX_CARBON'", "WXUNIV=='0'", "USE_GUI=='1' and WXUNIV=='0'"}, projectName:Â
207 "wxcarbon", bklfiles:{Â
208 "../bakefiles/files.bkl", "../bakefiles/regex.bkl", "../bakefiles/tiff.bkl", "../bakefiles/png.bkl", "../bakefiles/jpeg.bkl", "../bakefiles/scintilla.bkl", "../bakefiles/expat.bkl"}, nodes:{Â
209 {label:"base", entries:{"$(BASE_SRC)"}}, Â
210 {label:"base", entries:{"$(BASE_AND_GUI_SRC)"}}, Â
211 {label:"core", entries:{"$(CORE_SRC)"}}, Â
212 {label:"net", entries:{"$(NET_SRC)"}}, Â
213 {label:"adv", entries:{"$(ADVANCED_SRC)"}}, Â
214 {label:"media", entries:{"$(MEDIA_SRC)"}}, Â
215 {label:"html", entries:{"$(HTML_SRC)"}}, Â
216 {label:"xrc", entries:{"$(XRC_SRC)"}}, Â
217 {label:"xml", entries:{"$(XML_SRC)"}}, Â
218 {label:"opengl", entries:{"$(OPENGL_SRC)"}}, Â
219 {label:"aui", entries:{"$(AUI_SRC)"}}, Â
220 {label:"ribbon", entries:{"$(RIBBON_SRC)"}}, Â
221 {label:"propgrid", entries:{"$(PROPGRID_SRC)"}}, Â
222 {label:"richtext", entries:{"$(RICHTEXT_SRC)"}}, Â
223 {label:"stc", entries:{"$(STC_SRC)"}}, Â
224 {label:"libtiff", entries:{"$(wxtiff)"}}, Â
225 {label:"libjpeg", entries:{"$(wxjpeg)"}}, Â
226 {label:"libpng", entries:{"$(wxpng)"}}, Â
227 {label:"libregex", entries:{"$(wxregex)"}}, Â
228 {label:"libscintilla", entries:{"$(wxscintilla)"}}, Â
229 {label:"libexpat", entries:{"$(wxexpat)"}} Â
231 makeProject(theProject)
233 set theProject to {conditions:{"PLATFORM_MACOSX=='1'", "TOOLKIT=='OSX_COCOA'", "WXUNIV=='0'", "USE_GUI=='1' and WXUNIV=='0'"}, projectName:Â
234 "wxcocoa", bklfiles:{Â
235 "../bakefiles/files.bkl", "../bakefiles/regex.bkl", "../bakefiles/tiff.bkl", "../bakefiles/png.bkl", "../bakefiles/jpeg.bkl", "../bakefiles/scintilla.bkl", "../bakefiles/expat.bkl"}, nodes:{Â
236 {label:"base", entries:{"$(BASE_SRC)"}}, Â
237 {label:"base", entries:{"$(BASE_AND_GUI_SRC)"}}, Â
238 {label:"core", entries:{"$(CORE_SRC)"}}, Â
239 {label:"net", entries:{"$(NET_SRC)"}}, Â
240 {label:"adv", entries:{"$(ADVANCED_SRC)"}}, Â
241 {label:"media", entries:{"$(MEDIA_SRC)"}}, Â
242 {label:"html", entries:{"$(HTML_SRC)"}}, Â
243 {label:"xrc", entries:{"$(XRC_SRC)"}}, Â
244 {label:"xml", entries:{"$(XML_SRC)"}}, Â
245 {label:"opengl", entries:{"$(OPENGL_SRC)"}}, Â
246 {label:"aui", entries:{"$(AUI_SRC)"}}, Â
247 {label:"ribbon", entries:{"$(RIBBON_SRC)"}}, Â
248 {label:"propgrid", entries:{"$(PROPGRID_SRC)"}}, Â
249 {label:"richtext", entries:{"$(RICHTEXT_SRC)"}}, Â
250 {label:"stc", entries:{"$(STC_SRC)"}}, Â
251 {label:"libtiff", entries:{"$(wxtiff)"}}, Â
252 {label:"libjpeg", entries:{"$(wxjpeg)"}}, Â
253 {label:"libpng", entries:{"$(wxpng)"}}, Â
254 {label:"libregex", entries:{"$(wxregex)"}}, Â
255 {label:"libscintilla", entries:{"$(wxscintilla)"}}, Â
256 {label:"libexpat", entries:{"$(wxexpat)"}} Â
258 makeProject(theProject)
260 set theProject to {conditions:{"PLATFORM_MACOSX=='1'", "TOOLKIT=='OSX_IPHONE'", "WXUNIV=='0'", "USE_GUI=='1' and WXUNIV=='0'"}, projectName:Â
261 "wxiphone", bklfiles:{Â
262 "../bakefiles/files.bkl", "../bakefiles/regex.bkl", "../bakefiles/tiff.bkl", "../bakefiles/png.bkl", "../bakefiles/jpeg.bkl", "../bakefiles/scintilla.bkl", "../bakefiles/expat.bkl"}, nodes:{Â
263 {label:"base", entries:{"$(BASE_SRC)"}}, Â
264 {label:"base", entries:{"$(BASE_AND_GUI_SRC)"}}, Â
265 {label:"core", entries:{"$(CORE_SRC)"}}, Â
266 {label:"net", entries:{"$(NET_SRC)"}}, Â
267 {label:"adv", entries:{"$(ADVANCED_SRC)"}}, Â
268 {label:"media", entries:{"$(MEDIA_SRC)"}}, Â
269 {label:"html", entries:{"$(HTML_SRC)"}}, Â
270 {label:"xrc", entries:{"$(XRC_SRC)"}}, Â
271 {label:"xml", entries:{"$(XML_SRC)"}}, Â
272 {label:"opengl", entries:{"$(OPENGL_SRC)"}}, Â
273 {label:"aui", entries:{"$(AUI_SRC)"}}, Â
274 {label:"ribbon", entries:{"$(RIBBON_SRC)"}}, Â
275 {label:"propgrid", entries:{"$(PROPGRID_SRC)"}}, Â
276 {label:"richtext", entries:{"$(RICHTEXT_SRC)"}}, Â
277 {label:"stc", entries:{"$(STC_SRC)"}}, Â
278 {label:"libtiff", entries:{"$(wxtiff)"}}, Â
279 {label:"libjpeg", entries:{"$(wxjpeg)"}}, Â
280 {label:"libpng", entries:{"$(wxpng)"}}, Â
281 {label:"libregex", entries:{"$(wxregex)"}}, Â
282 {label:"libscintilla", entries:{"$(wxscintilla)"}}, Â
283 {label:"libexpat", entries:{"$(wxexpat)"}} Â
285 makeProject(theProject)