[profiler] Configure Instruments to optionally launch specific template.

This commit is contained in:
Eloy Durán
2013-11-01 14:57:30 +01:00
parent 600f727117
commit 3207c10cfb
3 changed files with 22 additions and 5 deletions

View File

@@ -198,7 +198,7 @@ task :profile => ['profile:simulator']
namespace :profile do
desc "Run a build on the simulator through Instruments"
task :simulator => 'build:simulator' do
plist = App.config.profiler_config_plist('iPhoneSimulator', ENV['args'])
plist = App.config.profiler_config_plist('iPhoneSimulator', ENV['args'], ENV['template'], IOS_SIM_INSTRUMENTS_TEMPLATES)
plist['com.apple.xcode.simulatedDeviceFamily'] = App.config.device_family_ints.first
plist['com.apple.xcode.SDKPath'] = App.config.sdk('iPhoneSimulator')
plist['optionalData']['launchOptions']['architectureType'] = 0
@@ -227,7 +227,7 @@ namespace :profile do
App.fail 'Unable to determine remote app path'
end
plist = App.config.profiler_config_plist('iPhoneOS', ENV['args'], false)
plist = App.config.profiler_config_plist('iPhoneOS', ENV['args'], ENV['template'], IOS_DEVICE_INSTRUMENTS_TEMPLATES, false)
plist['absolutePathOfLaunchable'] = File.join($deployed_app_path, App.config.bundle_name)
plist['deviceIdentifier'] = (ENV['id'] or App.config.device_id)
App.profile('iPhoneOS', plist)

View File

@@ -107,7 +107,7 @@ namespace :profile do
%w{ development release }.each do |mode|
desc "Run a #{mode} build through Instruments"
task mode => "build:#{mode}" do
plist = App.config.profiler_config_plist('MacOSX', "-NSDocumentRevisionsDebugMode YES #{ENV['args']}")
plist = App.config.profiler_config_plist('MacOSX', "-NSDocumentRevisionsDebugMode YES #{ENV['args']}", ENV['template'], OSX_INSTRUMENTS_TEMPLATES)
App.profile('MacOSX', plist)
end
end

View File

@@ -280,8 +280,24 @@ EOS
# TODO
# * Add env vars from user.
# * Add optional Instruments template to use.
def profiler_config_plist(platform, args, set_build_env = true)
def profiler_config_plist(platform, args, template, builtin_templates, set_build_env = true)
working_dir = File.expand_path(versionized_build_dir(platform))
optional_data = {}
if template
template_path = nil
if File.exist?(template)
template_path = template
elsif !builtin_templates.grep(/#{template}/i).empty?
list = `/usr/bin/xcrun instruments -s 2>&1`.strip.split("\n").map { |line| line.sub(/^\s+"/, '').sub(/",*$/, '') }
template = template.downcase
template_path = list.find { |path| File.basename(path, File.extname(path)).downcase == template }
else
App.fail("Invalid Instruments template path or name.")
end
optional_data['XrayTemplatePath'] = template_path
end
env = ENV.to_hash
if set_build_env
env.merge!({
@@ -292,6 +308,7 @@ EOS
'__XPC_DYLD_LIBRARY_PATH' => working_dir,
})
end
{
'CFBundleIdentifier' => identifier,
'absolutePathOfLaunchable' => File.expand_path(app_bundle_executable(platform)),
@@ -303,7 +320,7 @@ EOS
'launchOptions' => {
'architectureType' => 1,
},
},
}.merge(optional_data),
}
end