class MotionHeader
Constants
- BRIDGESUPPORT_DIR
Public Class Methods
new(header_file, config, options={})
click to toggle source
@param [String] header_file Requested C header file. @param [Motion::Project::Config] config RubyMotion config provided in App.setup. @param [Hash] options Options for customizing BridgeSupport file generation @option options [String] :prefix Subdirectory of /usr/include used for root of included header files. @option options [String] :bridgesupport_dir Path where the generated bridgesupport file is saved. Defaults to ./build
# File lib/motion.h.rb, line 42 def initialize(header_file, config, options={}) @header_file = header_file @config = config @prefix = options[:prefix] @bridgesupport_dir = options[:bridgesupport_dir] || BRIDGESUPPORT_DIR end
Public Instance Methods
bridgesupport_file()
click to toggle source
# File lib/motion.h.rb, line 111 def bridgesupport_file file_name = @header_file.tr('/', '_').chomp('.h') "#{@bridgesupport_dir}/#{file_name}.bridgesupport" end
catalina_version()
click to toggle source
# File lib/motion.h.rb, line 75 def catalina_version Gem::Version.new('10.15') end
frameworks_path()
click to toggle source
# File lib/motion.h.rb, line 89 def frameworks_path sdk_dir = sdk_dir(@config.sdk_version) path_components = [@config.xcode_dir, *sdk_dir, 'System', 'Library', 'Frameworks'].compact File.join(*path_components) end
generate_bridgesupport_file()
click to toggle source
# File lib/motion.h.rb, line 60 def generate_bridgesupport_file return if File.exist?(bridgesupport_file) Dir.mkdir(@bridgesupport_dir) unless Dir.exist?(@bridgesupport_dir) cflags = [ "-I#{include_path}", "-F#{frameworks_path}" ] if product_version >= catalina_version cflags << "--isysroot #{isysroot_dir}" end Bundler.with_unbundled_env do `/Library/RubyMotion/bin/gen_bridge_metadata --format complete --64-bit --cflags '#{cflags.join(' ')}' #{@header_file} > #{bridgesupport_file}` end end
include_path()
click to toggle source
# File lib/motion.h.rb, line 83 def include_path sdk_dir = sdk_dir(@config.sdk_version) path_components = [@config.xcode_dir, *sdk_dir, 'usr', 'include', @prefix].compact File.join(*path_components) end
integrate()
click to toggle source
# File lib/motion.h.rb, line 49 def integrate verify_header_file generate_bridgesupport_file bridgesupport_file end
isysroot_dir()
click to toggle source
# File lib/motion.h.rb, line 95 def isysroot_dir case platform when :ios then 'iPhoneOS' when :osx then 'MacOSX' end end
platform()
click to toggle source
# File lib/motion.h.rb, line 116 def platform Motion::Project::App.respond_to?(:template) ? Motion::Project::App.template : :ios end
product_version()
click to toggle source
# File lib/motion.h.rb, line 79 def product_version Gem::Version.new(`sw_vers -productVersion`) end
sdk_dir(sdk_version)
click to toggle source
# File lib/motion.h.rb, line 102 def sdk_dir(sdk_version) case platform when :ios ['Platforms', 'iPhoneOS.platform', 'Developer', 'SDKs', "iPhoneOS#{sdk_version}.sdk"] when :osx ['Platforms', 'MacOSX.platform', 'Developer', 'SDKs', "MacOSX#{sdk_version}.sdk"] end end
verify_header_file()
click to toggle source
# File lib/motion.h.rb, line 55 def verify_header_file path = "#{include_path}/#{@header_file}" File.exist?(path) or raise "Header file `#{@header_file}' does not exist (#{path})." end