Module: ICuke::SDK
- Defined in:
- lib/icuke/sdk.rb
Constant Summary collapse
- ICUKE_EXT_DIR =
File.(File.join(File.dirname(__FILE__), '..', '..', 'ext', 'iCuke'))
- ICUKE_BIN_DIR =
File.(File.join(File.dirname(__FILE__), '..', '..', 'ext', 'bin'))
- CFLAGS =
'-arch i386 -pipe -ggdb -std=c99 -DTARGET_OS_IPHONE'
Class Method Summary collapse
- .all ⇒ Object
- .cflags ⇒ Object
- .dylib(name = 'libicuke') ⇒ Object
- .dylib_fullpath(name = 'libicuke') ⇒ Object
- .ext_dir ⇒ Object
- .fullname ⇒ Object
- .gcc ⇒ Object
- .home ⇒ Object
- .installed?(sdk) ⇒ Boolean
- .latest(version = nil) ⇒ Object
- .launch(application, family, environment = {}) ⇒ Object
- .ld ⇒ Object
- .major_version ⇒ Object
- .major_versions ⇒ Object
- .minor_version ⇒ Object
- .minor_versions ⇒ Object
- .root ⇒ Object
- .use(version) ⇒ Object
- .use_latest(major_version = nil) ⇒ Object
- .version ⇒ Object
Class Method Details
.all ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/icuke/sdk.rb', line 7 def self.all @all ||= begin `xcodebuild -showsdks`.split(/\n/).grep(/iphonesimulator/).map do |s| s.sub(/.* iphonesimulator([0-9.]+).*/, '\1').chomp end.sort end end |
.cflags ⇒ Object
97 98 99 |
# File 'lib/icuke/sdk.rb', line 97 def self.cflags "#{CFLAGS} -isysroot #{root} -F/System/Library/PrivateFrameworks -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000" end |
.dylib(name = 'libicuke') ⇒ Object
85 86 87 |
# File 'lib/icuke/sdk.rb', line 85 def self.dylib(name = 'libicuke') "#{name}.dylib" end |
.dylib_fullpath(name = 'libicuke') ⇒ Object
89 90 91 |
# File 'lib/icuke/sdk.rb', line 89 def self.dylib_fullpath(name = 'libicuke') File.join(ICUKE_EXT_DIR, dylib(name)) end |
.ext_dir ⇒ Object
93 94 95 |
# File 'lib/icuke/sdk.rb', line 93 def self.ext_dir ICUKE_EXT_DIR end |
.fullname ⇒ Object
67 68 69 70 71 |
# File 'lib/icuke/sdk.rb', line 67 def self.fullname require_sdk "iphonesimulator#{version}" end |
.gcc ⇒ Object
101 102 103 104 105 106 |
# File 'lib/icuke/sdk.rb', line 101 def self.gcc if major_version == '4' abi_flags = "-fobjc-abi-version=2 -fobjc-legacy-dispatch" end "xcrun -sdk #{fullname} gcc -I. -I#{ext_dir} -I#{ext_dir}/json #{cflags} -x objective-c #{abi_flags}" end |
.home ⇒ Object
79 80 81 82 83 |
# File 'lib/icuke/sdk.rb', line 79 def self.home require_sdk "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{version}" end |
.installed?(sdk) ⇒ Boolean
15 16 17 |
# File 'lib/icuke/sdk.rb', line 15 def self.installed?(sdk) all.include?(sdk) end |
.latest(version = nil) ⇒ Object
27 28 29 |
# File 'lib/icuke/sdk.rb', line 27 def self.latest(version = nil) @latest ||= version ? all.grep(/^#{version}(?:\.|$)/).last : all.last end |
.launch(application, family, environment = {}) ⇒ Object
115 116 117 118 119 |
# File 'lib/icuke/sdk.rb', line 115 def self.launch(application, family, environment = {}) family ||= :iphone environment_args = environment.map { |k, v| %Q{-e "#{k}=#{v}"} }.join(' ') %Q{#{ICUKE_BIN_DIR}/waxsim -s #{version} -f #{family} #{environment_args} "#{application}"} end |
.ld ⇒ Object
108 109 110 111 112 113 |
# File 'lib/icuke/sdk.rb', line 108 def self.ld if major_version == '4' abi_flags = "-Xlinker -objc_abi_version -Xlinker 2" end "xcrun -sdk #{fullname} gcc -I. -I#{ext_dir} -I#{ext_dir}/json #{cflags} #{abi_flags}" end |
.major_version ⇒ Object
55 56 57 58 59 |
# File 'lib/icuke/sdk.rb', line 55 def self.major_version require_sdk version.split('.')[0] end |
.major_versions ⇒ Object
19 20 21 |
# File 'lib/icuke/sdk.rb', line 19 def self.major_versions all.map { |s| s.split('.').first }.uniq end |
.minor_version ⇒ Object
61 62 63 64 65 |
# File 'lib/icuke/sdk.rb', line 61 def self.minor_version require_sdk version.split('.')[0 .. 1].join('.') end |
.minor_versions ⇒ Object
23 24 25 |
# File 'lib/icuke/sdk.rb', line 23 def self.minor_versions all.map { |s| s.split('.')[0 .. 1].join('.') }.uniq end |
.root ⇒ Object
73 74 75 76 77 |
# File 'lib/icuke/sdk.rb', line 73 def self.root require_sdk "#{`xcode-select -print-path`.chomp}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator#{version}.sdk" end |
.use(version) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/icuke/sdk.rb', line 31 def self.use(version) unless installed?(version) raise "The requested SDK version #{version} doesn't appear to be installed" end @sdk = version end |
.use_latest(major_version = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/icuke/sdk.rb', line 39 def self.use_latest(major_version = nil) case major_version when :iphone major_version = installed?('4.0') ? '4.0' : '3.1' when :ipad major_version = installed?('4.0') ? '4.0' : '3.2' end use latest(major_version) end |
.version ⇒ Object
49 50 51 52 53 |
# File 'lib/icuke/sdk.rb', line 49 def self.version require_sdk @sdk end |