diff --git a/Rakefile b/Rakefile index 42507fc0..2a971cc6 100644 --- a/Rakefile +++ b/Rakefile @@ -83,7 +83,7 @@ end desc "Install" task :install do - public_binaries = ['./bin/motion'] + public_binaries = ['./bin/motion', './bin/gen_bridge_metadata'] binaries = public_binaries.dup.concat(['./bin/ios/deploy', './bin/ios/sim', './bin/osx/sim', './bin/ruby', './bin/ctags', './bin/nfd', 'lib/yard/bin/yard', 'lib/yard/bin/yardoc', 'lib/yard/bin/yri', './lldb/lldb.py']) diff --git a/bin/gen_bridge_metadata b/bin/gen_bridge_metadata new file mode 100755 index 00000000..7048e9a3 --- /dev/null +++ b/bin/gen_bridge_metadata @@ -0,0 +1,126 @@ +#!/usr/bin/ruby + +# Monkey-patch gen_bridge_metadata + +load '/usr/bin/gen_bridge_metadata' + +module Bridgesupportparser + class Parser + # From /System/Library/BridgeSupport/ruby-1.8/bridgesupportparser.rb + def recursivefuncptr(f) + return nil if f.nil? + func, rettype, retenc, retattrs, retfunc, fattrs, variadic, inline = f.info + ret = Bridgesupportparser::RetvalPtrInfo.new(self, nil, rettype, retenc, retattrs, recursivefuncptr(retfunc)) + args = Bridgesupportparser::MergingSequence.new('recursivefuncptr') + f.each_argument do |name, type, enc, attrs, funcptr| + # RubyMotion change: + # + # In the original implementation the last argument is always nil, + # but we need to enable recursive parsing. + # + # Related to: http://hipbyte.myjetbrains.com/youtrack/issue/RM-288 + args << Bridgesupportparser::ArgInfo.new(self, name, type, enc, attrs, recursivefuncptr(funcptr)) + end + Bridgesupportparser::FuncInfo.new(self, func, ret, args, fattrs, variadic, inline) + end + end +end + +# Because this is not a method, in the original implementation, we need to copy it verbatim. +if __FILE__ == $0 + g = BridgeSupportGenerator.new + OptionParser.new do |opts| + opts.banner = "Usage: #{File.basename(__FILE__)} [options] " + opts.separator '' + opts.separator 'Options:' + + opts.on('-f', '--framework FRAMEWORK', 'Generate metadata for the given framework.') do |opt| + g.frameworks << opt + end + + opts.on('-p', '--private', 'Support private frameworks headers.') do + g.private = true + end + + formats = BridgeSupportGenerator::FORMATS + opts.on('-F', '--format FORMAT', formats, {}, "Select metadata format.") do |opt| + g.generate_format = opt + end + + opts.on('-e', '--exception EXCEPTION', 'Use the given exception file.') do |opt| + g.exception_paths << opt + end + + enable_64 = true # both 32 & 64 bit is now the default + opts.on(nil, '--64-bit', 'Write 64-bit annotations (now the default).') do + enable_64 = true + end + opts.on(nil, '--no-64-bit', 'Do not write 64-bit annotations.') do + enable_64 = false + end + + opts.on('-c', '--cflags FLAGS', 'Specify custom compiler flags.') do |flags| + g.compiler_flags ||= '' + g.compiler_flags << ' ' + flags + ' ' + end + + compiler_flags_64 = nil + opts.on('-C', '--cflags-64 FLAGS', 'Specify custom 64-bit compiler flags.') do |flags| + compiler_flags_64 ||= '' + compiler_flags_64 << ' ' + flags + ' ' + end + + opts.on('-o', '--output FILE', 'Write output to the given file.') do |opt| + die 'Output file can\'t be specified more than once' if @out_file + g.out_file = opt + end + + help_msg = "Use the `-h' flag or consult gen_bridge_metadata(1) for help." + opts.on('-h', '--help', 'Show this message.') do + puts opts, help_msg + exit + end + + opts.on('-d', '--debug', 'Turn on debugging messages.') do + $DEBUG = true + end + + opts.on('-v', '--version', 'Show version.') do + puts BridgeSupportGenerator::VERSION + exit + end + + opts.separator '' + + if ARGV.empty? + die opts.banner + else + begin + opts.parse!(ARGV) + ARGV.each { |header| g.add_header(header) } + g.parse(enable_64, compiler_flags_64) + # g.collect + # if enable_64 + # g2 = g.duplicate + # g2.enable_64 = true + # if compiler_flags_64 != g.compiler_flags + # g2.compiler_flags = compiler_flags_64 + # end + # g2.collect + # g.merge_64_metadata(g2) + # end + g.write + # g.cleanup + rescue => e + msg = e.message + msg = 'Internal error' if msg.empty? + $DEBUG = true #DEBUG + if $DEBUG + $stderr.puts "Received exception: #{e}:" + $stderr.puts e.backtrace.join("\n") + end + die msg, opts.banner, help_msg + end + end + end +end diff --git a/data/Rakefile b/data/Rakefile index 94e692fd..11a2d230 100644 --- a/data/Rakefile +++ b/data/Rakefile @@ -103,7 +103,7 @@ task :bridgesupport_files do unless File.exist?(dest) a = sdk_version.scan(/(\d+)\.(\d+)/)[0] sdk_version_headers = ((a[0].to_i * 10000) + (a[1].to_i * 100)).to_s - sh "/usr/bin/gen_bridge_metadata --format complete --cflags \"-isysroot #{sdk_path} -mmacosx-version-min=#{sdk_version} -DTARGET_OS_MAC -D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -framework #{framework}\" --framework #{framework_path} > #{dest}" + sh "../bin/gen_bridge_metadata --format complete --cflags \"-isysroot #{sdk_path} -mmacosx-version-min=#{sdk_version} -DTARGET_OS_MAC -D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -framework #{framework}\" --framework #{framework_path} > #{dest}" apply_bridgesupport_fixes(dest) return dest end @@ -118,7 +118,7 @@ task :bridgesupport_files do child_framework_paths.each do |child_framework_path| if sdk_version == "10.7" && child_framework_path.include?("CoreGraphics") dest = 'osx/10.7/BridgeSupport/child/CoreGraphics.bridgesupport' - sh "/usr/bin/gen_bridge_metadata --format complete --cflags \"-isysroot #{sdk_path} -F#{sdk_path}/System/Library/Frameworks/ApplicationServices.framework/Frameworks -mmacosx-version-min=10.7 -DTARGET_OS_MAC -D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=100700 -framework ApplicationServices\" --framework #{child_framework_path} > #{dest}" + sh "../bin/gen_bridge_metadata --format complete --cflags \"-isysroot #{sdk_path} -F#{sdk_path}/System/Library/Frameworks/ApplicationServices.framework/Frameworks -mmacosx-version-min=10.7 -DTARGET_OS_MAC -D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=100700 -framework ApplicationServices\" --framework #{child_framework_path} > #{dest}" apply_bridgesupport_fixes(dest) merge_path = dest else @@ -151,12 +151,12 @@ task :bridgesupport_files do a = sdk_version.scan(/(\d+)\.(\d+)/)[0] sdk_version_headers = ((a[0].to_i * 10000) + (a[1].to_i * 100)).to_s extra_flags = (sdk_version >= '7.0') ? '--64-bit' : '--no-64-bit' - sh "/usr/bin/gen_bridge_metadata --format complete #{extra_flags} --cflags \"-isysroot #{sdk_path} -miphoneos-version-min=#{sdk_version} -DTARGET_OS_IPHONE -D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -framework #{framework}\" --framework #{framework_path} > #{dest}" + sh "../bin/gen_bridge_metadata --format complete #{extra_flags} --cflags \"-isysroot #{sdk_path} -miphoneos-version-min=#{sdk_version} -DTARGET_OS_IPHONE -D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -framework #{framework}\" --framework #{framework_path} > #{dest}" apply_bridgesupport_fixes(dest) if framework == 'Foundation' and sdk_version >= '7.0' # In iOS 7.0, NSObject is defined in /usr/include/objc/NSObject.h - sh "/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags \"-isysroot #{sdk_path} -miphoneos-version-min=#{sdk_version} -DTARGET_OS_IPHONE -D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -framework #{framework} -I#{sdk_path}/usr/include \" objc/NSObject.h objc/NSObjCRuntime.h > /tmp/NSObject.bridgesupport" + sh "../bin/gen_bridge_metadata --format complete --no-64-bit --cflags \"-isysroot #{sdk_path} -miphoneos-version-min=#{sdk_version} -DTARGET_OS_IPHONE -D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -framework #{framework} -I#{sdk_path}/usr/include \" objc/NSObject.h objc/NSObjCRuntime.h > /tmp/NSObject.bridgesupport" merge_bridgesupport dest, '/tmp/NSObject.bridgesupport' end diff --git a/lib/motion/project/xcode_config.rb b/lib/motion/project/xcode_config.rb index 63ba6298..96ee6007 100644 --- a/lib/motion/project/xcode_config.rb +++ b/lib/motion/project/xcode_config.rb @@ -307,7 +307,7 @@ EOS (OSX_VERSION >= 10.7 && sdk_version < '7.0') ? '--no-64-bit' : '' end end - sh "RUBYOPT='' /usr/bin/gen_bridge_metadata --format complete #{extra_flags} --cflags \" #{c_flags} -isysroot \"#{sdk_path}\" -miphoneos-version-min=#{sdk_version} -D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -I. #{includes.join(' ')}\" #{headers.map { |x| "\"#{x}\"" }.join(' ')} -o \"#{bs_file}\" #{ "-e #{exceptions}" if exceptions.length != 0}" + sh "RUBYOPT='' '#{File.join(bindir, 'gen_bridge_metadata')}' --format complete #{extra_flags} --cflags \" #{c_flags} -isysroot \"#{sdk_path}\" -miphoneos-version-min=#{sdk_version} -D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -I. #{includes.join(' ')}\" #{headers.map { |x| "\"#{x}\"" }.join(' ')} -o \"#{bs_file}\" #{ "-e #{exceptions}" if exceptions.length != 0}" end def define_global_env_txt diff --git a/vm b/vm index b0b90511..b1ade08c 160000 --- a/vm +++ b/vm @@ -1 +1 @@ -Subproject commit b0b905112b3050e1a2dcabc461a8db9258709597 +Subproject commit b1ade08c2390759b18cbd39f09b1c9e39a571894