Skip to content
This repository
Browse code

Warn only once.

Reduce to only one the display of warnings about usage
of ExtensionTask or JavaExtensionTask in mixed environments.
  • Loading branch information...
commit f729a4bcd7ecbb4b45cc77b60625779ffedfabd4 1 parent e84b76c
Luis Lavena authored
7 lib/rake/baseextensiontask.rb
@@ -69,5 +69,12 @@ def binary(platform = nil)
69 69 def source_files
70 70 @source_files ||= FileList["#{@ext_dir}/#{@source_pattern}"]
71 71 end
  72 +
  73 + def warn_once(message)
  74 + @@already_warned ||= false
  75 + return if @@already_warned
  76 + @@already_warned = true
  77 + warn message
  78 + end
72 79 end
73 80 end
2  lib/rake/extensiontask.rb
@@ -34,7 +34,7 @@ def cross_compiling(&block)
34 34
35 35 def define
36 36 if RUBY_PLATFORM == 'java' || (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby')
37   - warn <<-EOF
  37 + warn_once <<-EOF
38 38 WARNING: You're attempting to (cross-)compile C extensions from a platform
39 39 (#{RUBY_ENGINE}) that does not support native extensions or mkmf.rb.
40 40 Rerun `rake` under MRI Ruby 1.8.x/1.9.x to cross/native compile.
2  lib/rake/javaextensiontask.rb
@@ -65,7 +65,7 @@ def define_compile_tasks(for_platform = nil, ruby_ver = RUBY_VERSION)
65 65 execute the Rake compilation task using the JRuby interpreter.
66 66 (e.g. `jruby -S rake compile:java`)
67 67 EOF
68   - warn(not_jruby_compile_msg) unless defined?(JRUBY_VERSION)
  68 + warn_once(not_jruby_compile_msg) unless defined?(JRUBY_VERSION)
69 69
70 70 file "#{tmp_path}/#{binary(platf)}" => "#{tmp_path}/.build" do
71 71 sh "jar cf #{tmp_path}/#{binary(platf)} -C #{tmp_path} ."

0 comments on commit f729a4b

Please sign in to comment.
Something went wrong with that request. Please try again.