[GBM] Generate a tmp file with headers instead of passing all as arguments.

Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-581.
This commit is contained in:
Eloy Durán
2014-09-02 16:34:03 +02:00
parent 49b6607659
commit 63926a22c6
3 changed files with 22 additions and 1 deletions

2
NEWS
View File

@@ -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.

View File

@@ -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

View File

@@ -395,11 +395,20 @@ 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) }
# 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}"
ensure
headers_file.close
end
def define_global_env_txt