Permalink
Browse files

Warn if compiled files exists in extension's source directory. Closes G…

  • Loading branch information...
luislavena committed Apr 22, 2011
1 parent 5cfac57 commit 51a1c3f4b43df199f7b85ba3feb5b17943cb2dd4
Showing with 25 additions and 6 deletions.
  1. +3 −0 History.txt
  2. +7 −2 lib/rake/extensiontask.rb
  3. +15 −4 spec/lib/rake/extensiontask_spec.rb
View
@@ -8,6 +8,9 @@
ext.config_includes << File.expand_path("my", "custom", "dir")
end
+* Bugfixes:
+ * Warn if compiled files exists in extension's source directory. Closes GH-35
+
=== 0.7.7 / 2011-04-04
* Bugfixes:
@@ -19,6 +19,7 @@ def init(name = nil, gem_spec = nil)
super
@config_script = 'extconf.rb'
@source_pattern = "*.c"
+ @compiled_pattern = "*.{o,obj,so,bundle,dSYM}"
@cross_compile = false
@cross_config_options = []
@cross_compiling = nil
@@ -58,6 +59,10 @@ def define
super
+ unless compiled_files.empty?
+ warn "WARNING: rake-compiler found compiled files in '#{@ext_dir}' directory. Please remove them."
+ end
+
# only gems with 'ruby' platforms are allowed to define native tasks
define_native_tasks if !@no_native && (@gem_spec && @gem_spec.platform == 'ruby')
@@ -364,8 +369,8 @@ def dev_null
windows? ? 'NUL' : '/dev/null'
end
- def source_files
- @source_files ||= FileList["#{@ext_dir}/#{@source_pattern}"]
+ def compiled_files
+ FileList["#{@ext_dir}/#{@compiled_pattern}"]
end
def compiles_cross_platform
@@ -110,7 +110,7 @@
context '(one extension)' do
before :each do
- Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"])
+ Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
@ext = Rake::ExtensionTask.new('extension_one')
@ext_bin = ext_bin('extension_one')
@platform = RUBY_PLATFORM
@@ -194,11 +194,22 @@
CLOBBER.should include('tmp')
end
end
+
+ it "should warn when pre-compiled files exist in extension directory" do
+ Rake::FileList.stub!(:[]).
+ and_return(["ext/extension_one/source.c"],
+ ["ext/extension_one/source.o"])
+
+ _, err = capture_output do
+ Rake::ExtensionTask.new('extension_one')
+ end
+ err.should match(/rake-compiler found compiled files in 'ext\/extension_one' directory. Please remove them./)
+ end
end
context '(extension in custom location)' do
before :each do
- Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"])
+ Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
@ext = Rake::ExtensionTask.new('extension_one') do |ext|
ext.ext_dir = 'custom/ext/foo'
end
@@ -216,7 +227,7 @@
context '(native tasks)' do
before :each do
- Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"])
+ Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
@spec = mock_gem_spec
@ext_bin = ext_bin('extension_one')
@platform = RUBY_PLATFORM
@@ -263,7 +274,7 @@
before :each do
File.stub!(:exist?).and_return(true)
YAML.stub!(:load_file).and_return(mock_config_yml)
- Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"])
+ Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
@spec = mock_gem_spec
@config_file = File.expand_path("~/.rake-compiler/config.yml")
@ruby_ver = RUBY_VERSION

0 comments on commit 51a1c3f

Please sign in to comment.