summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile95
1 files changed, 69 insertions, 26 deletions
diff --git a/Rakefile b/Rakefile
index 5d120a6..c911a3d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,41 +1,84 @@
-# -*- ruby -*-
+require "bundler"
+
+Bundler::GemHelper.install_tasks
-require 'rubygems'
-require 'hoe'
begin
require 'rake/extensiontask'
rescue LoadError => e
warn "\nmissing #{e.path} (for rake-compiler)" if e.respond_to? :path
- warn "run: rake newb\n\n"
+ warn "run: bundle install\n\n"
end
-Hoe.plugin :git
-Hoe.plugin :minitest
-Hoe.plugin :travis
-
-HOE = Hoe.spec 'curses' do
- self.version = '1.0.2'
-
- developer 'Eric Hodel', 'drbrain@segment7.net'
- developer 'Shugo Maeda', ''
+$mswin = /mswin/ =~ RUBY_PLATFORM
- license 'Ruby'
- license 'BSD-2-Clause'
+CLOBBER.include("vendor/#{RUBY_PLATFORM}") if $mswin
+CLOBBER.include("vendor/x86-mingw32")
+CLOBBER.include("vendor/x64-mingw32")
+CLOBBER.include("lib/2.*")
+CLOBBER.include("pkg")
- self.extra_rdoc_files << 'ext/curses/curses.c'
- self.spec_extras[:extensions] = 'ext/curses/extconf.rb'
+namespace :build do
+ desc "Build PDCurses"
+ task :pdcurses do
+ mkdir_p "vendor/#{RUBY_PLATFORM}/PDCurses" if $mswin
+ mkdir_p "vendor/x86-mingw32/PDCurses"
+ mkdir_p "vendor/x64-mingw32/PDCurses"
+ chdir "vendor/PDCurses/win32" do
+ if $mswin
+ sh "nmake -f vcwin32.mak clean all WIDE=Y DLL=Y"
+ cp %w[pdcurses.dll pdcurses.lib], "../../#{RUBY_PLATFORM}/PDCurses"
+ else
+ sh "make -f mingwin32.mak clean all WIDE=Y DLL=Y"
+ cp "pdcurses.dll", "../../x86-mingw32/PDCurses"
- self.readme_file = 'README.md'
- self.history_file = 'History.md'
+ sh "make -f mingwin32.mak clean all _w64=1 WIDE=Y DLL=Y"
+ cp "pdcurses.dll", "../../x64-mingw32/PDCurses"
+ end
+ end
+ end
+end
- self.extra_dev_deps << ['rake-compiler', '~> 0.8']
+namespace :clean do
+ desc "Clean PDCurses"
+ task :pdcurses do
+ chdir "vendor/PDCurses/win32" do
+ sh "nmake -f vcwin32.mak clean" if $mswin
+ sh "make -f mingwin32.mak clean _linux_w64=1"
+ end
+ end
end
-if Rake.const_defined? :ExtensionTask then
- Rake::ExtensionTask.new 'curses', HOE.spec
+spec = eval(File.read(File.expand_path("curses.gemspec", __dir__)))
+Rake::ExtensionTask.new(spec.name, spec) do |ext|
+ if $mswin
+ ext.config_options << '--with-curses-include=' +
+ File.expand_path("vendor/PDCurses", __dir__) +
+ ' --with-curses-version=function --enable-pdcurses-wide' +
+ ' --enable-pdcurses-dll' +
+ ' --with-curses-lib=' +
+ File.expand_path("vendor/#{RUBY_PLATFORM}/PDCurses", __dir__)
+ spec.files += ["vendor/#{RUBY_PLATFORM}/PDCurses/pdcurses.dll"]
+ end
- task default: :compile
- task test: :compile
+ ext.cross_compile = true
+ ext.cross_platform = ["x86-mingw32", "x64-mingw32"]
+ ext.cross_config_options << '--with-curses-include=' +
+ File.expand_path("vendor/PDCurses", __dir__) +
+ ' --with-curses-version=function --enable-pdcurses-wide'
+ ext.cross_config_options << {
+ 'x86-mingw32' => '--with-curses-lib=' +
+ File.expand_path("vendor/x86-mingw32/PDCurses", __dir__),
+ 'x64-mingw32' => '--with-curses-lib=' +
+ File.expand_path("vendor/x64-mingw32/PDCurses", __dir__)
+ }
+ ext.cross_compiling do |_spec|
+ bin_file = "vendor/#{_spec.platform}/PDCurses/pdcurses.dll"
+ _spec.files += [bin_file]
+ stage_file = "#{ext.tmp_dir}/#{_spec.platform}/stage/#{bin_file}"
+ stage_dir = File.dirname(stage_file)
+ directory stage_dir
+ file stage_file => [stage_dir, bin_file] do
+ cp bin_file, stage_file
+ end
+ end
end
-
-# vim: syntax=ruby