From acd41653525c78e294530e44644ba2607edeec5b Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Sun, 13 May 2012 22:34:00 +0200 Subject: [PATCH] Generate BridgeSupport for headers at any level. This patch is needed to ensure all headers of Pods will be included in the BS file, with the current state of the motion-cocoapods repo. --- lib/motion/project/vendor.rb | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/motion/project/vendor.rb b/lib/motion/project/vendor.rb index 527559f2..04fefb2f 100644 --- a/lib/motion/project/vendor.rb +++ b/lib/motion/project/vendor.rb @@ -153,9 +153,9 @@ EOS bs_file = File.expand_path(File.basename(@path) + '.bridgesupport') headers_dir = opts.delete(:headers_dir) if !File.exist?(bs_file) and headers_dir - Dir.chdir(headers_dir) do - sh "/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags \"-I.\" *.h -o \"#{bs_file}\"" - end + project_dir = File.expand_path(@config.project_dir) + headers = Dir.glob(File.join(project_dir, headers_dir, '**/*.h')) + BridgeSupport.new(headers).save_as(bs_file) end @bs_files = Dir.glob('*.bridgesupport').map { |x| File.expand_path(x) } @@ -176,5 +176,24 @@ EOS raise "Invalid vendor project type: #{@type}" unless respond_to?(method) method end + + class BridgeSupport + include Rake::DSL if Rake.const_defined?(:DSL) + + attr_reader :headers + + def initialize(headers) + @headers = headers + end + + def search_paths + @headers.map { |header| "-I '#{File.dirname(header)}'" }.uniq + end + + def save_as(path) + sh %{/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags "#{search_paths.join(' ')}" -o '#{path}' '#{headers.join("' '")}'} + end + end + end end; end