Automated Clang From Xcode - [video]
Anyone who uses Clang will appreciate this script.
What It DoesThe AppleScript will see if you have more then one project open. If so, a dialog appears asking you to choose which project you wish to run clang against. Once chosen a new Terminal window will open, cd into the chosen projects directory and execute the clang commands.
Pretty cool, huh!
Save the AppleScript on your computer and name it clang.scpt. Create a new User Script in Xcode and paste the following.
running time: 00:01:57 Large ViewMake sure to change the path to where the clang.scpt resides on your computer.
#!/bin/sh /usr/bin/osascript /path/to/clang.scpt
As always, please let me know if you have any bugs, complaints, suggestion or such.
--GNU Standard GNU applies
--
--Date: Thursday February 5, 2009
--Author: Craig Williams
--Desc: Run clang from Xcode using AppleScript
tell application "Xcode"
try
set openProjects to every project
on error
display dialog "No Projects Open"
return
end try
set projectList to {}
if (count of openProjects) is greater than 1 then
repeat with i from 1 to count of openProjects
set thisProj to item i of openProjects
set end of projectList to (name of thisProj)
end repeat
set chosenProj to choose from list projectList ¬
with title ¬
"Choose project to run clang against." with prompt "Choose Project"
if chosenProj is false then return
set theProject to item 1 of chosenProj
set theProject to project theProject
else
set theProject to project 1
end if
my runClang(project directory of theProject)
end tell
on runClang(projectPath)
set clangCmd to "cd " & quoted form of projectPath & ";"
set clangCmd to clangCmd & "scan-build xcodebuild -configuration Debug clean;"
set clangCmd to clangCmd & "scan-build -V xcodebuild -configuration Debug"
tell application "Terminal"
activate
do script with command clangCmd
end tell
end runClang

Comments
RSS feed for comments to this post.