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

cannot define two Rake::ExtensionTasks with separate cross_compiling blocks #36

Open
tmm1 opened this issue Mar 1, 2011 · 9 comments
Open
Assignees
Labels

Comments

@tmm1
Copy link

tmm1 commented Mar 1, 2011

eventmachine defines two extension tasks: https://github.com/eventmachine/eventmachine/blob/master/tasks/package.rake#L25-33

each one uses its own cross_compiling block to add a .rb fat-binary wrapper to spec.files, but the second extension gets rubyeventmachine.rb added to it instead of fastfilereader.rb

with this patch:

diff --git a/tasks/package.rake b/tasks/package.rake
index 84e317e..73a5c6f 100644
--- a/tasks/package.rake
+++ b/tasks/package.rake
@@ -16,7 +16,9 @@ else
       ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']

       # inject 1.8/1.9 pure-ruby entry point
+      p [:outside, ext.object_id, ext.name]
       ext.cross_compiling do |spec|
+        p [:inside, ext.object_id, ext.name]
         spec.files += ["lib/#{ext.name}.rb"]
       end
     end

you can see the first block is getting called twice:

[:outside, 2159882380, "rubyeventmachine"]
[:outside, 2159788460, "fastfilereaderext"]
[:inside, 2159882380, "rubyeventmachine"]
[:inside, 2159882380, "rubyeventmachine"]
@luislavena
Copy link
Contributor

Indeed.

Rake ExtensionTask defines a single cross task and that is invoked. Multiple files been added will generate duplicate spec entries.

A workaround will be always place the ruby entry point inside the gem.

The whole cross task approach needs to be changed, so will left this open until I decide how to tackle it.

Thank you for the report.

@tmm1
Copy link
Author

tmm1 commented Oct 5, 2011

Are there any workarounds for this? See eventmachine/eventmachine#222

@ghost ghost assigned luislavena Oct 5, 2011
@luislavena
Copy link
Contributor

Will see what can be done, sorry for the delay.

@luislavena
Copy link
Contributor

@tmm1: can you try this on EventMachine?

  def setup_cross_compilation(ext)
    unless RUBY_PLATFORM =~ /mswin|mingw/
      ext.cross_compile = true
      ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']

      # inject 1.8/1.9 pure-ruby entry point
      # HACK: add these dependencies to the task instead of using cross_compiling
      ext.cross_platform.each do |platf|
        Rake::Task["native:#{GEMSPEC.name}:#{platf}"].prerequisites.unshift "lib/#{ext.name}.rb"
      end
    end
  end

@luislavena
Copy link
Contributor

@tmm1, ping? did the above code help you out? please let me know.

@tmm1
Copy link
Author

tmm1 commented Oct 20, 2011

No luck:

Don't know how to build task 'native:eventmachine:x86-mingw32'
/Users/test/.rvm/gems/ruby-1.8.7-p330/gems/rake-0.9.2/lib/rake/task_manager.rb:49:in `[]'
/Users/test/.rvm/gems/ruby-1.8.7-p330/gems/rake-0.9.2/lib/rake/task.rb:298:in `[]'
/Users/test/code/em/tasks/package.rake:31:in `setup_cross_compilation'
/Users/test/code/em/tasks/package.rake:30:in `each'
/Users/test/code/em/tasks/package.rake:30:in `setup_cross_compilation'
/Users/test/code/em/tasks/package.rake:39
/Users/test/.rvm/gems/ruby-1.8.7-p330/gems/rake-compiler-0.7.9/lib/rake/baseextensiontask.rb:34:in `initialize'
/Users/test/code/em/tasks/package.rake:36:in `new'
/Users/test/code/em/tasks/package.rake:36

@luislavena
Copy link
Contributor

@tmm1, can you try this weird-and-shameful-hack-that-I-m-not-proud-of?

https://gist.github.com/1340253

@Harrison-Uhl
Copy link

How about packaging fastfilereader in its own gem? Wouldn't this provide the needed separation?

tmm1 added a commit to eventmachine/eventmachine that referenced this issue Mar 8, 2013
@tmm1
Copy link
Author

tmm1 commented Mar 9, 2013

The rakefile hack works. I've merged into EM 1.0.2 to work around this bug until it is resolved. Thanks @luislavena

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants