From 1812e2083da133aee79a40255f97ddcb035078cc Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Thu, 21 Jul 2011 17:35:03 -0700 Subject: [PATCH] add 'config' rake task which dumps the config variables, change the 'sdk_version' variable to auto-detect the latest SDK installed --- lib/rubixir/rake.rb | 8 +++++++ lib/rubixir/rake/config.rb | 44 ++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/lib/rubixir/rake.rb b/lib/rubixir/rake.rb index 9a98a98a..b1098081 100644 --- a/lib/rubixir/rake.rb +++ b/lib/rubixir/rake.rb @@ -56,3 +56,11 @@ desc "Clear build objects" task :clean do rm_rf(Rubixir::CONFIG.build_dir) end + +desc "Show project config" +task :config do + map = Rubixir::CONFIG.variables + map.keys.sort.each do |key| + puts key.ljust(20) + " = #{map[key].inspect}" + end +end diff --git a/lib/rubixir/rake/config.rb b/lib/rubixir/rake/config.rb index 6cf160f3..a2196581 100644 --- a/lib/rubixir/rake/config.rb +++ b/lib/rubixir/rake/config.rb @@ -1,13 +1,21 @@ module Rubixir class Config - attr_accessor :files, :platforms_dir, :sdk_version, :frameworks, + VARS = [] + + def self.variable(*syms) + syms.each do |sym| + attr_accessor sym + VARS << sym.to_s + end + end + + variable :files, :platforms_dir, :sdk_version, :frameworks, :app_delegate_class, :app_name, :build_dir, :resources_dir, :codesign_certificate, :provisioning_profile def initialize(project_dir) @files = Dir.glob(File.join(project_dir, 'app/**/*.rb')) @platforms_dir = '/Developer/Platforms' - @sdk_version = '4.3' @frameworks = ['UIKit', 'Foundation', 'CoreGraphics'] @app_delegate_class = 'AppDelegate' @app_name = 'My App' @@ -16,6 +24,15 @@ module Rubixir @bundle_signature = '????' end + def variables + map = {} + VARS.each do |sym| + val = send(sym) rescue "ERROR" + map[sym] = val + end + map + end + def datadir File.expand_path(File.join(File.dirname(__FILE__), '../../../data')) end @@ -24,9 +41,24 @@ module Rubixir File.join(@platforms_dir, platform + '.platform') end + def sdk_version + @sdk_version ||= begin + versions = Dir.glob(File.join(platforms_dir, 'iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk')).map do |path| + File.basename(path).scan(/iPhoneOS(.*)\.sdk/)[0][0] + end + if versions.size == 0 + $stderr.puts "can't locate any iPhone SDK" + exit 1 + elsif versions.size > 1 + $stderr.puts "found #{versions.size} SDKs, will use the latest one" + end + versions.max + end + end + def sdk(platform) File.join(platform_dir(platform), 'Developer/SDKs', - platform + @sdk_version + '.sdk') + platform + sdk_version + '.sdk') end def app_bundle(platform, exec=false) @@ -80,11 +112,11 @@ module Rubixir DTPlatformName iphoneos DTPlatformVersion - #{@sdk_version} + #{sdk_version} DTSDKBuild 8H7 DTSDKName - iphoneos#{@sdk_version} + iphoneos#{sdk_version} DTXcode 0402 DTXcodeBuild @@ -92,7 +124,7 @@ module Rubixir LSRequiresIPhoneOS MinimumOSVersion - #{@sdk_version} + #{sdk_version} UIDeviceFamily 1