From 01b337b57b72687c19accdc8b91ea270edc8b0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Fri, 1 Nov 2013 14:27:41 +0100 Subject: [PATCH] [profiler] Add tasks to list available instruments templates. --- lib/motion/project/template/ios.rb | 53 ++++++++++++++++++++++++++++++ lib/motion/project/template/osx.rb | 22 +++++++++++++ 2 files changed, 75 insertions(+) diff --git a/lib/motion/project/template/ios.rb b/lib/motion/project/template/ios.rb index 8fc696d4..af715a16 100644 --- a/lib/motion/project/template/ios.rb +++ b/lib/motion/project/template/ios.rb @@ -193,6 +193,33 @@ namespace :profile do App.profile('iPhoneSimulator', plist) end + namespace :simulator do + desc 'List all built-in iOS Simulator Instruments templates' + task :templates do + list = `/usr/bin/xcrun instruments -s 2>&1`.strip.split("\n").map do |line| + line.sub(/^\s+"/, '').sub(/",*$/, '') + end + + instruments_path = File.expand_path('../Applications/Instruments.app/Contents', App.config.xcode_dir) + + regexp = Regexp.new(Regexp.escape(File.join(instruments_path, 'Resources/templates'))) + templates_for_all_platforms = list.grep(regexp) + + # TODO figure out if there is a way to programatically determine these. + templates_for_ios_sim_platform = [ + File.join(instruments_path, "PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate"), + File.join(App.config.xcode_dir, "Platforms/MacOSX.platform/Developer/Library/Instruments/PlugIns/CoreData/Core Data.tracetemplate"), + ] + + templates = templates_for_all_platforms + templates_for_ios_sim_platform + + puts "Built-in templates:" + templates.each do |template| + puts "* #{File.basename(template, File.extname(template))}" + end + end + end + desc "Run a build on the device through Instruments" task :device do # Create a build that allows debugging but doesn’t start a debugger on deploy. @@ -209,5 +236,31 @@ namespace :profile do plist['deviceIdentifier'] = (ENV['id'] or App.config.device_id) App.profile('iPhoneOS', plist) end + + namespace :device do + desc 'List all built-in iOS device Instruments templates' + task :templates do + list = `/usr/bin/xcrun instruments -s 2>&1`.strip.split("\n").map do |line| + line.sub(/^\s+"/, '').sub(/",*$/, '') + end + + instruments_path = File.expand_path('../Applications/Instruments.app/Contents', App.config.xcode_dir) + + regexp = Regexp.new(Regexp.escape(File.join(instruments_path, 'Resources/templates'))) + templates_for_all_platforms = list.grep(regexp) + + # TODO figure out if there is a way to programatically determine these. + templates_for_ios_sim_platform = [ + File.join(instruments_path, "PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate"), + ] + + templates = templates_for_all_platforms + templates_for_ios_sim_platform + + puts "Built-in templates:" + templates.each do |template| + puts "* #{File.basename(template, File.extname(template))}" + end + end + end end diff --git a/lib/motion/project/template/osx.rb b/lib/motion/project/template/osx.rb index 9bb44676..2ae8ba14 100644 --- a/lib/motion/project/template/osx.rb +++ b/lib/motion/project/template/osx.rb @@ -103,6 +103,28 @@ namespace :profile do App.profile('MacOSX', plist) end end + + desc 'List all built-in OS X Instruments templates' + task :templates do + list = `/usr/bin/xcrun instruments -s 2>&1`.strip.split("\n").map do |line| + line.sub(/^\s+"/, '').sub(/",*$/, '') + end + + instruments_path = File.expand_path('../Applications/Instruments.app/Contents', App.config.xcode_dir) + + regexp = Regexp.new(Regexp.escape(File.join(instruments_path, 'Resources/templates'))) + templates_for_all_platforms = list.grep(regexp) + + regexp = Regexp.new(Regexp.escape(File.join(App.config.xcode_dir, 'Platforms/MacOSX.platform/Developer/Library/Instruments/PlugIns'))) + templates_for_osx_platform = list.grep(regexp) + + templates = templates_for_all_platforms + templates_for_osx_platform + + puts "Built-in templates:" + templates.each do |template| + puts "* #{File.basename(template, File.extname(template))}" + end + end end desc 'Same as profile:development'