After copying the patch into the OS X pasteboard, the patch like so:
$ cd /Library/RubyMotion
$ pbpaste | patch -p1
After copying the patch into the OS X pasteboard, the patch like so:
$ cd /Library/RubyMotion
$ pbpaste | patch -p1
commit 5ed4422f739eb19673d969377bdc8cdaf7bf9c4b | |
Author: Eloy Durán <eloy.de.enige@gmail.com> | |
Date: Tue Sep 2 16:34:03 2014 +0200 | |
[GBM] Generate a tmp file with headers instead of passing all as arguments. | |
Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-581. | |
diff --git a/NEWS b/NEWS | |
index dece64b..24af7dd 100644 | |
--- a/NEWS | |
+++ b/NEWS | |
@@ -1,6 +1,8 @@ | |
= RubyMotion 2.33 = | |
* Improved Enumerable#inject performance. ~40% times faster. | |
+ * Fixed a bug that could cause `gen_bridge_metadata' to be called with too | |
+ many arguments for a shell (on Yosemite) to handle. | |
* [OSX] Fixed a bug that made it impossible to use a `NSApplication' subclass. | |
* [OSX] Fixed a bug where it would trigger a crash when it will evaluates a | |
expression on REPL on Yosemite. | |
diff --git a/bin/gen_bridge_metadata b/bin/gen_bridge_metadata | |
index d0567a0..7f27e98 100755 | |
--- a/bin/gen_bridge_metadata | |
+++ b/bin/gen_bridge_metadata | |
@@ -91,6 +91,16 @@ if __FILE__ == $0 | |
g.out_file = opt | |
end | |
+ # RubyMotion addition that allows us to overcome 'too many arguments' error | |
+ # when passing many headers to this tool. | |
+ opts.on('--headers FILE', 'Use headers listed in file as input.') do |file| | |
+ File.open(file, 'r') do |io| | |
+ io.each_line do |header| | |
+ g.add_header(header.strip) | |
+ end | |
+ end | |
+ 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 | |
diff --git a/lib/motion/project/xcode_config.rb b/lib/motion/project/xcode_config.rb | |
index df4a26c..2219d11 100644 | |
--- a/lib/motion/project/xcode_config.rb | |
+++ b/lib/motion/project/xcode_config.rb | |
@@ -395,11 +395,19 @@ EOS | |
end | |
def gen_bridge_metadata(platform, headers, bs_file, c_flags, exceptions=[]) | |
+ # Instead of potentially passing hundreds of arguments to the | |
+ # `gen_bridge_metadata` command, which can lead to a 'too many arguments' | |
+ # error, we list them in a temp file and pass that to the command. | |
+ require 'tempfile' | |
+ headers_file = Tempfile.new('gen_bridge_metadata-headers-list') | |
+ headers.each { |header| headers_file.puts(header) } | |
+ headers_file.close # flush | |
+ # Prepare rest of options. | |
sdk_path = self.sdk(local_platform) | |
includes = ['-I.'] + headers.map { |header| "-I'#{File.dirname(header)}'" }.uniq | |
exceptions = exceptions.map { |x| "\"#{x}\"" }.join(' ') | |
c_flags = "#{c_flags} -isysroot '#{sdk_path}' #{bridgesupport_cflags} #{includes.join(' ')}" | |
- sh "RUBYOPT='' '#{File.join(bindir, 'gen_bridge_metadata')}' #{bridgesupport_flags} --cflags \"#{c_flags}\" #{headers.map { |x| "'#{x}'" }.join(' ')} -o '#{bs_file}' #{ "-e #{exceptions}" if exceptions.length != 0}" | |
+ sh "RUBYOPT='' '#{File.join(bindir, 'gen_bridge_metadata')}' #{bridgesupport_flags} --cflags \"#{c_flags}\" --headers \"#{headers_file.path}\" -o '#{bs_file}' #{ "-e #{exceptions}" if exceptions.length != 0}" | |
end | |
def define_global_env_txt |