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)