Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--add-files オプションを入れてみました。 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/rubygems/commands/compile_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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

21 changes: 19 additions & 2 deletions lib/rubygems/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down