1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Add rudimentary tasks for building Windows gems.

This commit is contained in:
Andy Brody 2014-03-31 20:34:30 -07:00
parent a229af471e
commit e503e61154
3 changed files with 73 additions and 3 deletions

View file

@ -2,8 +2,6 @@ source "https://rubygems.org"
gemspec
gem 'ffi', '~> 1.9', :platforms => [:mswin, :mingw]
group :test do
gem 'rake'
end

View file

@ -32,7 +32,56 @@ RSpec::Core::RakeTask.new('rcov') do |t|
t.rcov_opts = ['--exclude', 'examples']
end
task :default => :spec
task :default do
sh 'rake -T'
end
def alias_task(alias_task, original)
desc "Alias for rake #{original}"
task alias_task, Rake.application[original].arg_names => original
end
alias_task(:test, :spec)
############################
WindowsPlatforms = %w{x86-mingw32 x64-mingw32 x86-mswin32}
desc "build all platform gems at once"
task :gems => [:rm_gems, 'ruby:gem'] + \
WindowsPlatforms.map {|p| "windows:#{p}:gem"}
task :rm_gems => ['ruby:clobber_package']
def built_gem_path
base = '.'
Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
end
namespace :windows do
spec_path = File.join(File.dirname(__FILE__), 'rest-client.gemspec')
WindowsPlatforms.each do |platform|
namespace platform do
desc "build gem for #{platform}"
task 'build' do
orig_platform = ENV['BUILD_PLATFORM']
begin
ENV['BUILD_PLATFORM'] = platform
sh("gem build -V #{spec_path + '.windows'}") do |ok, res|
if !ok
puts "not OK: #{ok.inspect} #{res.inspect}"
end
end
ensure
ENV['BUILD_PLATFORM'] = orig_platform
end
end
end
end
end
############################

View file

@ -0,0 +1,23 @@
#
# Gemspec for Windows platforms. We can't put these in the main gemspec because
# it results in bundler platform hell when trying to build the gem.
#
# Set $BUILD_PLATFORM when calling gem build with this gemspec to build for
# Windows platforms like x86-mingw32.
#
s = eval(File.read(File.join(File.dirname(__FILE__), 'rest-client.gemspec')))
platform = ENV['BUILD_PLATFORM']
case platform
when /(mingw32|mswin32)/
s.add_dependency('ffi', '~> 1.9.3')
s.platform = platform
else
raise NotImplementedError.new("Must specify $BUILD_PLATFORM")
end
s
# vim: ft=ruby :