Skip to content

Commit

Permalink
Revert "Don't generate additional rake tasks when files don't exist (#…
Browse files Browse the repository at this point in the history
…240)"

This reverts commit 5a2d669.

Users must specify valid `spec.files`. rake-compiler doesn't
repair invalid `spec.files` automatically. It's users'
responsibility.
  • Loading branch information
kou committed Dec 31, 2024
1 parent 2509abc commit bf67eda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/rake/extensiontask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def define_staging_file_tasks(files, lib_path, stage_path, platf, ruby_ver)
lib_binary_path = "#{lib_path}/#{File.basename(binary(platf))}"

files.each do |gem_file|
# ignore directories, the binary extension and non-existent files
next if File.directory?(gem_file) || gem_file == lib_binary_path || !File.exist?(gem_file)
# ignore directories and the binary extension
next if File.directory?(gem_file) || gem_file == lib_binary_path
stage_file = "#{stage_path}/#{gem_file}"

# copy each file from base to stage directory
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/rake/extensiontask_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,10 @@
}.should_not raise_error
end

it 'should generate additional rake tasks if files are added when cross compiling and files exist' do
it 'should generate additional rake tasks if files are added when cross compiling' do
allow_any_instance_of(Rake::CompilerConfig).to(
receive(:find).and_return("/rubies/1.9.1/rbconfig.rb")
)
expect(File).to receive(:exist?).with('somedir/non-existent-file').and_return(false)

# Use a real spec instead of a mock because define_native_tasks dups and
# calls methods on Gem::Specification, which is more than mock can do.
Expand All @@ -528,13 +527,11 @@
ext.cross_platform = 'universal-unknown'
ext.cross_compiling do |gem_spec|
gem_spec.files << 'somedir/somefile'
gem_spec.files << 'somedir/non-existent-file'
end
end
Rake::Task['native:my_gem:universal-unknown'].execute
Rake::Task.should have_defined("tmp/universal-unknown/stage/somedir")
Rake::Task.should have_defined("tmp/universal-unknown/stage/somedir/somefile")
Rake::Task.should_not have_defined("tmp/universal-unknown/stage/somedir/non-existent-file")
end

it 'should allow usage of RUBY_CC_VERSION to indicate a different version of ruby' do
Expand Down

0 comments on commit bf67eda

Please sign in to comment.