Skip to content

Commit

Permalink
Call cross_compiling block for native platform too
Browse files Browse the repository at this point in the history
Currently the cross_compiling block isn't called when cross compiling for the build platform.
This is due to the fact that define_native_tasks() is called first for the build platform
and later on for the cross platforms. The task "native:<gemname>:<platform>" is defined
only once and therefore only without the callback. The callback is therefore not called
for the cross platform that equals the build platform.

OMHO the root issue is that rake-compiler doesn't has a clear separation between
native and cross tasks. However I think calling cross_compiling for any binary gem
(native or cross) is a suitable workaround.

This fixes bug sparklemotion/nokogiri#1991 (comment)
  • Loading branch information
larskanis committed Mar 3, 2020
1 parent a86722f commit c974a8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rake/extensiontask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def define_compile_tasks(for_platform = nil, ruby_ver = RUBY_VERSION)
end
end

def define_native_tasks(for_platform = nil, ruby_ver = RUBY_VERSION, callback = nil)
def define_native_tasks(for_platform = nil, ruby_ver = RUBY_VERSION)
platf = for_platform || platform

# tmp_path
Expand Down Expand Up @@ -280,7 +280,7 @@ def define_native_tasks(for_platform = nil, ruby_ver = RUBY_VERSION, callback =
spec.files += ext_files

# expose gem specification for customization
callback.call(spec) if callback
@cross_compiling.call(spec) if @cross_compiling

# Generate a package for this gem
pkg = Gem::PackageTask.new(spec) do |p|
Expand Down Expand Up @@ -425,7 +425,7 @@ def define_cross_platform_tasks_with_version(for_platform, ruby_ver)

# now define native tasks for cross compiled files
if @gem_spec && @gem_spec.platform == 'ruby' then
define_native_tasks(for_platform, ruby_ver, @cross_compiling)
define_native_tasks(for_platform, ruby_ver)
end

# create cross task
Expand Down

0 comments on commit c974a8b

Please sign in to comment.