Skip to content

Commit

Permalink
(submodule:build) update build process
Browse files Browse the repository at this point in the history
Libuv uses make by preference over GYP
  • Loading branch information
Stephen von Takach committed Jun 10, 2018
1 parent 7e5e932 commit 0d31f69
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 50 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ rvm:
- ruby-2.3.5
- ruby-2.4.2
- ruby-head
- rubinius-3.86
- rubinius
- jruby-9.1.13.0
- jruby-head
Expand Down
10 changes: 0 additions & 10 deletions lib/libuv/ext/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ def self.x64?
system "git", "submodule", "update", "--init"
end

file 'ext/libuv/build/gyp' => 'ext/libuv/build' do
result = true
if not File.directory?('ext/libuv/build/gyp')
result = system "git", "clone", "https://chromium.googlesource.com/external/gyp", "ext/libuv/build/gyp"
end
raise 'unable to download gyp' unless result
end

CLEAN.include('ext/libuv/build/gyp')

if FFI::Platform.windows?
require File.join File.expand_path("../", __FILE__), 'tasks/win'
elsif FFI::Platform.mac?
Expand Down
26 changes: 8 additions & 18 deletions lib/libuv/ext/tasks/mac.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
# frozen_string_literal: true

file 'ext/libuv/uv.xcodeproj' => 'ext/libuv/build/gyp' do
target_arch = 'ia32'if FFI::Platform.ia32?
target_arch = 'x64' if FFI::Platform.x64?

abort "Don't know how to build on #{FFI::Platform::ARCH} (yet)" unless target_arch

Dir.chdir("ext/libuv") do |path|
system "./gyp_uv.py -f xcode -Dtarget_arch=#{target_arch} -Duv_library=shared_library -Dcomponent=shared_library"
end
end

file "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/uv.xcodeproj' do
file "ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/build' do
Dir.chdir("ext/libuv") do |path|
system 'xcodebuild -project uv.xcodeproj -configuration Release -target libuv'
system "sh", "autogen.sh"
system "./configure"
system "make"
end
end

file "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
file "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}" do
FileUtils.mkdir('ext/libuv/lib') unless File.directory?('ext/libuv/lib')

user_lib = "#{ENV['HOME']}/lib"
FileUtils.mkdir(user_lib) unless File.directory?(user_lib)

# Useful for building other libraries that wish to use Libuv
FileUtils.cp("ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")

# Primrary load location - falls back to above if not available
FileUtils.cp("ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "#{user_lib}/libuv.#{FFI::Platform::LIBSUFFIX}")
FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "#{user_lib}/libuv.#{FFI::Platform::LIBSUFFIX}")
end

CLEAN.include('ext/libuv/uv.xcodeproj')
CLOBBER.include("ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}")
CLOBBER.include("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}")
30 changes: 10 additions & 20 deletions lib/libuv/ext/tasks/unix.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
# frozen_string_literal: true

file 'ext/libuv/out' => 'ext/libuv/build/gyp' do
target_arch = 'ia32'if FFI::Platform.ia32?
target_arch = 'x64' if FFI::Platform.x64?

abort "Don't know how to build on #{FFI::Platform::ARCH} (yet)" unless target_arch

Dir.chdir("ext/libuv") do |path|
system "./gyp_uv.py -f make -Dtarget_arch=#{target_arch} -Duv_library=shared_library -Dcomponent=shared_library"
end
end

file "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/out' do
file "ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/build' do
Dir.chdir("ext/libuv") do |path|
system 'make -C out BUILDTYPE=Release'
system "sh", "autogen.sh"
system "./configure"
system "make"
end
end

file "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" do
file "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}" do
FileUtils.mkdir('ext/libuv/lib') unless File.directory?('ext/libuv/lib')
begin
FileUtils.cp("ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
rescue => e
FileUtils.cp("ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}.1", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")

Dir.chdir("ext/libuv") do |path|
system "make", "install"
end
end

CLEAN.include('ext/libuv/out')
CLOBBER.include("ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}")
CLOBBER.include("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}")
10 changes: 10 additions & 0 deletions lib/libuv/ext/tasks/win.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# frozen_string_literal: true

file 'ext/libuv/build/gyp' => 'ext/libuv/build' do
result = true
if not File.directory?('ext/libuv/build/gyp')
result = system "git", "clone", "https://chromium.googlesource.com/external/gyp", "ext/libuv/build/gyp"
end
raise 'unable to download gyp' unless result
end

CLEAN.include('ext/libuv/build/gyp')

file "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
target_arch = 'ia32'
target_arch = 'x64' if FFI::Platform.x64?
Expand Down
2 changes: 1 addition & 1 deletion lib/libuv/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Libuv
VERSION = '4.0.2'
VERSION = '4.0.3'
end

0 comments on commit 0d31f69

Please sign in to comment.