diff --git a/lib/rubygems/commands/compile_command.rb b/lib/rubygems/commands/compile_command.rb index cbdc65a..8a42327 100644 --- a/lib/rubygems/commands/compile_command.rb +++ b/lib/rubygems/commands/compile_command.rb @@ -5,7 +5,8 @@ class Gem::Commands::CompileCommand < Gem::Command def initialize super 'compile', 'Create binary gems from gems with extensions', :platform => Gem::Platform::CURRENT, - :fat => "" + :fat => "", + :add_files => [] add_option('-p', '--platform PLATFORM', 'Output platform name') do |value, options| options[:platform] = value @@ -14,6 +15,10 @@ def initialize add_option('-f', '--fat VERSION:RUBY,...', 'Create fat binary (e.g. --fat 1.8:ruby,1.9:ruby19)') do |value, options| options[:fat] = value end + + add_option('-a', '--add-files DIR', 'Add files only binary gem (e.g. --add-files vendor/app/local )') do |value, options| + options[:add_files] << value + end end def arguments # :nodoc: @@ -42,7 +47,7 @@ def execute fat_commands[ver] = cmd end - Gem::Compiler.compile(gem, options[:platform], fat_commands) + Gem::Compiler.compile(gem, options[:platform], fat_commands, options[:add_files]) end end diff --git a/lib/rubygems/compiler.rb b/lib/rubygems/compiler.rb index cec97cd..c7b6398 100644 --- a/lib/rubygems/compiler.rb +++ b/lib/rubygems/compiler.rb @@ -10,7 +10,7 @@ class Gem::Compiler extend Gem::UserInteraction - def self.compile(gem, platform = Gem::Platform::CURRENT, fat_commands = {}) + def self.compile(gem, platform = Gem::Platform::CURRENT, fat_commands = {}, add_files = []) gem_dir = "#{File.basename(gem)}.build" gem_dir = File.expand_path(gem_dir) @@ -135,7 +135,24 @@ def self.compile(gem, platform = Gem::Platform::CURRENT, fat_commands = {}) built_files = built_paths.map {|path| path[File.join(gem_dir,'').length..-1] } built_files.reject! {|path| path =~ /\.o$/ } # FIXME - spec.files = (spec.files + built_files).sort.uniq + result_add_files = [] + + Dir.chdir gem_dir + begin + add_files.each do |f_or_d| + if File.file? f_or_d + result_add_files << f_or_d + else + Find.find(f_or_d) do |fpath| + result_add_files << fpath if File.file? fpath + end + end + end + ensure + Dir.chdir start_dir + end + + spec.files = (spec.files + built_files + result_add_files).sort.uniq spec.platform = platform if platform Dir.chdir gem_dir