Skip to content
This repository
Browse code

Remove all custom rake tasks in favor of rake-compiler based extensio…

…n building and packaging
  • Loading branch information...
commit a569635a004fd9fbd16eee1b3e32d1f19fc17fba 1 parent bb2c0db
Aman Gupta authored November 20, 2010
305  Rakefile
... ...
@@ -1,302 +1,11 @@
1  
-#!/usr/bin/env rake
2  
-#
3  
-# Ruby/EventMachine
4  
-#   http://rubyeventmachine.com
5  
-#   Copyright (C) 2006-07 by Francis Cianfrocca
6  
-#
7  
-#   This program is copyrighted free software. You may use it under
8  
-#   the terms of either the GPL or Ruby's License. See the file
9  
-#   COPYING in the EventMachine distribution for full licensing
10  
-#   information.
11  
-#
  1
+require 'rubygems' unless defined?(Gem)
  2
+require 'rake'     unless defined?(Rake)
  3
+import  *Dir['tasks/*.rake']
12 4
 
13  
-require 'rubygems'  unless defined?(Gem)
14  
-require 'rake'      unless defined?(Rake)
15  
-
16  
-Package = false # Build zips and tarballs?
17  
-Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
18  
-
19  
-MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
20  
-  'nmake'
21  
-else
22  
-  'make'
23  
-end
24  
-
25  
-desc "Build gemspec, then build eventmachine, then run tests."
26  
-task :default => [:build, :test]
27  
-
28  
-desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
29  
-build_task = 'ext:build'
30  
-build_task = 'java:build' if RUBY_PLATFORM =~ /java/
31  
-task :build => build_task do |t|
32  
-  Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f|
33  
-    mv f, "lib"
34  
-  end
35  
-end
36  
-
37  
-task :dummy_build
38  
-
39  
-require 'rake/testtask'
40  
-Rake::TestTask.new(:test) do |t|
41  
-  t.pattern = 'tests/**/test_*.rb'
42  
-  t.warning = true
43  
-end
44  
-
45  
-# Basic clean definition, this is enhanced by imports aswell.
46  
-task :clean do
47  
-  chdir 'ext' do
48  
-    sh "#{MAKE} clean" if test ?e, 'Makefile'
49  
-  end
50  
-  chdir 'ext/fastfilereader' do
51  
-    sh "#{MAKE} clean" if test ?e, 'Makefile'
52  
-  end
53  
-  Dir.glob('**/Makefile').each { |file| rm file }
54  
-  Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
55  
-  Dir.glob('ext/**/conftest.dSYM').each{ |file| rm_rf file }
56  
-end
57  
-
58  
-Spec = eval(File.read(File.expand_path('../eventmachine.gemspec', __FILE__)))
59  
-
60  
-if RUBY_PLATFORM =~ /mswin/
61  
-  Spec.platform = 'x86-mswin32-60'
62  
-  Spec.files += %w[ lib/rubyeventmachine.so lib/fastfilereaderext.so ]
63  
-  Spec.extensions = nil
64  
-elsif RUBY_PLATFORM =~ /java/
65  
-  Spec.platform = 'java'
66  
-  Spec.files += %w[ lib/em_reactor.jar ]
67  
-  Spec.extensions = nil
68  
-end
69  
-
70  
-# this is a hack right now, it requires installing msysgit in the global path so it can use tar/curl/etc.
71  
-namespace :win32 do
72  
-  task :check_git do
73  
-    unless `git` =~ /rebase/
74  
-      raise 'git not found, install msys git into the GLOBAL PATH: http://msysgit.googlecode.com/files/Git-1.6.2-preview20090308.exe'
75  
-    end
76  
-  end
77  
-
78  
-  task :check_vc6 do
79  
-    begin
80  
-      raise unless `nmake 2>&1` =~ /Microsoft/
81  
-    rescue
82  
-      raise 'VC6 not found, please run c:\vc\setvc.bat vc6'
83  
-    end
84  
-  end
85  
-
86  
-  task :check_perl do
87  
-    unless `perl --version` =~ /ActiveState/
88  
-      raise 'ActiveState perl required to build OpenSSL: http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi'
89  
-    end
90  
-  end
91  
-
92  
-  task :build_openssl => [:check_git, :check_perl, :check_vc6] do
93  
-    mkdir_p 'build'
94  
-    chdir 'build' do
95  
-      unless File.exists?('openssl-0.9.8j')
96  
-        sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl.tar.gz'
97  
-        sh 'tar zxvf openssl.tar.gz' rescue nil # fails because of symlinks
98  
-      end
99  
-
100  
-      mkdir_p 'local'
101  
-      chdir 'openssl-0.9.8j' do
102  
-        sh "perl Configure VC-WIN32 --prefix=\"../local/\""
103  
-        sh 'ms\do_ms.bat'
104  
-        sh 'nmake -f ms\nt.mak install'
105  
-      end
106  
-
107  
-      chdir '../ext' do
108  
-        sh 'git clean -fd .'
109  
-      end
110  
-
111  
-      mv 'local/include/openssl', '../ext/'
112  
-      mv 'local/lib/ssleay32.lib', '../ext/'
113  
-      mv 'local/lib/libeay32.lib', '../ext/'
114  
-    end
115  
-  end
116  
-
117  
-  desc "build binary win32 gem"
118  
-  task :gem => :build_openssl do
119  
-    Rake::Task['build'].invoke
120  
-    Rake::Task['gem'].invoke
121  
-  end
122  
-end
123  
-
124  
-namespace :ext do
125  
-  ext_sources = FileList['ext/*.{h,cpp,rb,c}']
126  
-  ffr_sources = FileList['ext/fastfilereader/*.{h,cpp,rb}']
127  
-  file ext_extconf = 'ext/extconf.rb'
128  
-  file ffr_extconf = 'ext/fastfilereader/extconf.rb'
129  
-  ext_libname = "lib/rubyeventmachine.#{Config::CONFIG['DLEXT']}"
130  
-  ffr_libname = "lib/fastfilereaderext.#{Config::CONFIG['DLEXT']}"
131  
-
132  
-  file ext_libname => ext_sources + ['ext/Makefile'] do
133  
-    chdir('ext') { sh MAKE }
134  
-  end
135  
-  
136  
-  file ffr_libname => ffr_sources + ['ext/fastfilereader/Makefile'] do
137  
-    chdir('ext/fastfilereader') { sh MAKE }
138  
-  end
139  
-
140  
-  desc "Build C++ extension"
141  
-  task :build => [:make]
142  
-
143  
-  task :make => ext_libname
144  
-  task :make => ffr_libname
145  
-
146  
-  file 'ext/Makefile' => ext_extconf do
147  
-    chdir 'ext' do
148  
-      ruby 'extconf.rb'
149  
-    end
150  
-  end
151  
-
152  
-  file 'ext/fastfilereader/Makefile' => ffr_extconf do
153  
-    chdir 'ext/fastfilereader' do
154  
-      ruby 'extconf.rb'
155  
-    end
156  
-  end
157  
-end
158  
-
159  
-namespace :java do
160  
-  # This task creates the JRuby JAR file and leaves it in the lib directory.
161  
-  # This step is required before executing the jgem task.
162  
-  desc "Build java extension"
163  
-  task :build => [:jar] do |t|
164  
-    mv 'java/em_reactor.jar', 'lib/'
165  
-  end
166  
-
167  
-  task :compile do
168  
-    chdir('java') do
169  
-      mkdir_p "build"
170  
-      sh 'javac src/com/rubyeventmachine/*.java -d build'
171  
-    end
172  
-  end
173  
-
174  
-  task :jar => [:compile] do
175  
-    chdir('java/build') do
176  
-      sh "jar -cf ../em_reactor.jar com/rubyeventmachine/*.class"
177  
-    end
178  
-  end
179  
-
180  
-  desc "build a java binary gem"
181  
-  task :gem => :build do
182  
-    Spec.platform = 'java'
183  
-    Spec.files += %w[ lib/em_reactor.jar ]
184  
-    Spec.extensions = nil
185  
-
186  
-    Rake::Task['gem'].invoke
187  
-  end
188  
-end
189  
-
190  
-namespace :osx do
191  
-  desc "Build OSX binary gem"
192  
-  task :gem do
193  
-    Spec.platform = RUBY_PLATFORM.sub(/darwin.+$/, 'darwin')
194  
-    Spec.files += %w[ lib/rubyeventmachine.bundle lib/fastfilereaderext.bundle ]
195  
-    Spec.extensions = nil
196  
-
197  
-    Rake::Task['build'].invoke
198  
-    Rake::Task['gem'].invoke
199  
-  end
200  
-
201  
-  # XXX gcc will still prefer the shared libssl on the system, so we need to hack the extconf
202  
-  # XXX to use the static library to make this actually work
203  
-  task :static_gem => [:build_openssl, :gem]
204  
-
205  
-  task :build_openssl do
206  
-    mkdir_p 'build'
207  
-    chdir 'build' do
208  
-      unless File.exists?('openssl-0.9.8j')
209  
-        sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl-0.9.8j.tar.gz'
210  
-        sh 'tar zxvf openssl-0.9.8j.tar.gz'
211  
-      end
212  
-
213  
-      mkdir_p 'local'
214  
-      chdir 'openssl-0.9.8j' do
215  
-        local_dir = File.expand_path(File.join(File.dirname(__FILE__),'build','local'))
216  
-        sh "./config --prefix=#{local_dir}"
217  
-        sh 'make'
218  
-        sh 'make install'
219  
-      end
220  
-
221  
-      chdir '../ext' do
222  
-        sh 'git clean -fd .'
223  
-      end
224  
-
225  
-      mv 'local/include/openssl', '../ext/'
226  
-      mv 'local/lib/libssl.a', '../ext/'
227  
-      mv 'local/lib/libcrypto.a', '../ext/'
228  
-    end
229  
-  end
230  
-end
  5
+GEMSPEC = eval(File.read(File.expand_path('../eventmachine.gemspec', __FILE__)))
231 6
 
232 7
 require 'rake/clean'
233  
-
234  
-rdoc_task_type = begin
235  
-  require 'rdoc/task'
236  
-  RDoc::Task
237  
-rescue LoadError
238  
-  require 'rake/rdoctask'
239  
-  Rake::RDocTask
240  
-end
241  
-df = begin; require 'rdoc/rdoc'; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
242  
-rdtask = rdoc_task_type.new do |rd|
243  
-  rd.title = Spec.name
244  
-  rd.rdoc_dir = 'rdoc'
245  
-  rd.main = "README"
246  
-  rd.rdoc_files.include("lib/**/*.rb", *Spec.extra_rdoc_files)
247  
-  rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
248  
-  rd.template = 'darkfish' if df
249  
-end
250  
-Rake::Task[:clean].enhance [:clobber_rdoc]
251  
-
252  
-desc 'Generate and open documentation'
253  
-task :docs => :rdoc do
254  
-  case RUBY_PLATFORM
255  
-  when /darwin/       ; sh 'open rdoc/index.html'
256  
-  when /mswin|mingw/  ; sh 'start rdoc\index.html'
257  
-  else 
258  
-    sh 'firefox rdoc/index.html'
259  
-  end
260  
-end
261  
-
262  
-def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
263  
-def sudo(cmd)
264  
-  if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
265  
-    sh cmd
266  
-  else
267  
-    sh "sudo #{cmd}"
268  
-  end
269  
-end
270  
-def gem_cmd(action, name, *args)
271  
-  rb = Gem.ruby rescue nil
272  
-  rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
273  
-  sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
274  
-end
275  
-
276  
-begin
277  
-  require 'rubygems/package_task'
278  
-  Gem::PackageTask
279  
-rescue LoadError
280  
-  require 'rake/gempackagetask'
281  
-  Rake::GemPackageTask
282  
-end.new(Spec) do |pkg|
283  
-  pkg.need_tar, pkg.need_tar_gz, pkg.need_zip = true, true, true if Package
284  
-  pkg.gem_spec = Spec
285  
-end
286  
-
287  
-Rake::Task[:clean].enhance [:clobber_package]
288  
-
289  
-namespace :gem do
290  
-  desc 'Install gem (and sudo if required)'
291  
-  task :install => :package do 
292  
-    gem_cmd(:install, "pkg/#{Spec.name}-#{Spec.version}.gem")
293  
-  end
294  
-
295  
-  desc 'Uninstall gem (and sudo if required)'
296  
-  task :uninstall do
297  
-    gem_cmd(:uninstall, "#{Spec.name}", "-v=#{Spec.version}")
298  
-  end
299  
-end
300  
-
301 8
 task :clobber => :clean
302  
-task :test => :build
  9
+
  10
+desc "Build eventmachine, then run tests."
  11
+task :default => [:compile, :test]
96  ext/extconf.rb
... ...
@@ -1,3 +1,4 @@
  1
+require 'fileutils'
1 2
 require 'mkmf'
2 3
 
3 4
 def check_libs libs = [], fatal = false
@@ -12,12 +13,62 @@ def add_define(name)
12 13
   $defs.push("-D#{name}")
13 14
 end
14 15
 
  16
+##
  17
+# OpenSSL:
  18
+
  19
+# override append_library, so it actually appends (instead of prepending)
  20
+# this fixes issues with linking ssl, since libcrypto depends on symbols in libssl
  21
+def append_library(libs, lib)
  22
+  libs + " " + format(LIBARG, lib)
  23
+end
  24
+
  25
+def manual_ssl_config
  26
+  ssl_libs_heads_args = {
  27
+    :unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
  28
+    :mswin => [%w[ssleay32 libeay32], %w[openssl/ssl.h openssl/err.h]],
  29
+  }
  30
+
  31
+  dc_flags = ['ssl']
  32
+  dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM and ENV['OPENSSL']
  33
+
  34
+  libs, heads = case RUBY_PLATFORM
  35
+  when /mswin/    ; ssl_libs_heads_args[:mswin]
  36
+  else              ssl_libs_heads_args[:unix]
  37
+  end
  38
+  dir_config(*dc_flags)
  39
+  check_libs(libs) and check_heads(heads)
  40
+end
  41
+
  42
+if ENV['CROSS_COMPILING']
  43
+  openssl_dir = File.expand_path("~/.rake-compiler/builds/openssl-1.0.0a/")
  44
+  if File.exists?(openssl_dir)
  45
+    FileUtils.mkdir_p Dir.pwd+"/openssl/"
  46
+    FileUtils.cp Dir[openssl_dir+"/include/openssl/*.h"], Dir.pwd+"/openssl/", :verbose => true
  47
+    FileUtils.cp Dir[openssl_dir+"/lib*.a"], Dir.pwd, :verbose => true
  48
+  else
  49
+    STDERR.puts
  50
+    STDERR.puts "*************************************************************************************"
  51
+    STDERR.puts "**** Cross-compiled OpenSSL not found"
  52
+    STDERR.puts "**** Run: hg clone http://bitbucket.org/ged/ruby-pg && cd ruby-pg && rake openssl_lib"
  53
+    STDERR.puts "*************************************************************************************"
  54
+    STDERR.puts
  55
+  end
  56
+end
  57
+
  58
+# Try to use pkg_config first, fixes #73
  59
+if pkg_config('openssl') || manual_ssl_config
  60
+  add_define "WITH_SSL"
  61
+else
  62
+  add_define "WITHOUT_SSL"
  63
+end
  64
+
15 65
 add_define 'BUILD_FOR_RUBY'
16 66
 add_define 'HAVE_RBTRAP' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
17 67
 add_define "HAVE_TBR" if have_func('rb_thread_blocking_region')# and have_macro('RUBY_UBF_IO', 'ruby.h')
18 68
 add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
19 69
 add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
20 70
 add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
  71
+
21 72
 have_func('rb_thread_check_ints')
22 73
 have_func('rb_time_new')
23 74
 
@@ -81,19 +132,6 @@ def add_define(name)
81 132
 when /linux/
82 133
   add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h')
83 134
 
84  
-  # Original epoll test is inadequate because 2.4 kernels have the header
85  
-  # but not the code.
86  
-  # add_define 'HAVE_EPOLL' if have_header('sys/epoll.h')
87  
-  # if have_header('sys/epoll.h')
88  
-  #   File.open("hasEpollTest.c", "w") {|f|
89  
-  #     f.puts "#include <sys/epoll.h>"
90  
-  #     f.puts "int main() { epoll_create(1024); return 0;}"
91  
-  #   }
92  
-  #   (e = system( "gcc hasEpollTest.c -o hasEpollTest " )) and (e = $?.to_i)
93  
-  #   `rm -f hasEpollTest.c hasEpollTest`
94  
-  #   add_define 'HAVE_EPOLL' if e == 0
95  
-  # end
96  
-
97 135
   # on Unix we need a g++ link, not gcc.
98 136
   CONFIG['LDSHARED'] = "$(CXX) -shared"
99 137
 
@@ -105,38 +143,6 @@ def add_define(name)
105 143
   CONFIG['LDSHARED'] = "$(CXX) -shared"
106 144
 end
107 145
 
108  
-# OpenSSL:
109  
-
110  
-def manual_ssl_config
111  
-  ssl_libs_heads_args = {
112  
-    :unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
113  
-    :darwin => [%w[ssl crypto C], %w[openssl/ssl.h openssl/err.h]],
114  
-    # openbsd and linux:
115  
-    :crypto_hack => [%w[crypto ssl crypto], %w[openssl/ssl.h openssl/err.h]],
116  
-    :mswin => [%w[ssleay32 libeay32], %w[openssl/ssl.h openssl/err.h]],
117  
-  }
118  
-
119  
-  dc_flags = ['ssl']
120  
-  dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM
121  
-
122  
-  libs, heads = case RUBY_PLATFORM
123  
-  when /mswin/    ; ssl_libs_heads_args[:mswin]
124  
-  when /mingw/    ; ssl_libs_heads_args[:unix]
125  
-  when /darwin/   ; ssl_libs_heads_args[:darwin]
126  
-  when /openbsd/  ; ssl_libs_heads_args[:crypto_hack]
127  
-  when /linux/    ; ssl_libs_heads_args[:crypto_hack]
128  
-  else              ssl_libs_heads_args[:unix]
129  
-  end
130  
-  dir_config(*dc_flags)
131  
-  check_libs(libs) and check_heads(heads)
132  
-end
133  
-
134  
-# Try to use pkg_config first, fixes #73
135  
-if pkg_config('openssl') || manual_ssl_config
136  
-  add_define "WITH_SSL"
137  
-else
138  
-  add_define "WITHOUT_SSL"
139  
-end
140 146
 
141 147
 # solaris c++ compiler doesn't have make_pair()
142 148
 TRY_LINK.sub!('$(CC)', '$(CXX)')
2  lib/jeventmachine.rb
@@ -28,7 +28,7 @@
28 28
 # which is a garden-variety Ruby-extension glue module.
29 29
 
30 30
 require 'java'
31  
-require 'em_reactor'
  31
+require 'rubyeventmachine'
32 32
 require 'socket'
33 33
 
34 34
 java_import java.io.FileDescriptor
30  tasks/doc.rake
... ...
@@ -0,0 +1,30 @@
  1
+rdoc_task_type = begin
  2
+  require 'rdoc/task'
  3
+  RDoc::Task
  4
+rescue LoadError
  5
+  require 'rake/rdoctask'
  6
+  Rake::RDocTask
  7
+end
  8
+
  9
+df = begin; require 'rdoc/rdoc'; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
  10
+
  11
+rdtask = rdoc_task_type.new do |rd|
  12
+  rd.title = GEMSPEC.name
  13
+  rd.rdoc_dir = 'rdoc'
  14
+  rd.main = "README"
  15
+  rd.rdoc_files.include("lib/**/*.rb", *GEMSPEC.extra_rdoc_files)
  16
+  rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
  17
+  rd.template = 'darkfish' if df
  18
+end
  19
+
  20
+Rake::Task[:clean].enhance [:clobber_rdoc]
  21
+
  22
+desc 'Generate and open documentation'
  23
+task :docs => :rdoc do
  24
+  case RUBY_PLATFORM
  25
+  when /darwin/       ; sh 'open rdoc/index.html'
  26
+  when /mswin|mingw/  ; sh 'start rdoc\index.html'
  27
+  else
  28
+    sh 'firefox rdoc/index.html'
  29
+  end
  30
+end
85  tasks/package.rake
... ...
@@ -0,0 +1,85 @@
  1
+require 'rake/gempackagetask'
  2
+require 'rake/extensiontask'
  3
+require 'rake/javaextensiontask'
  4
+
  5
+Rake::GemPackageTask.new(GEMSPEC) do |pkg|
  6
+end
  7
+
  8
+if RUBY_PLATFORM =~ /java/
  9
+  Rake::JavaExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext|
  10
+    ext.ext_dir = 'java/src'
  11
+  end
  12
+else
  13
+  def setup_cross_compilation(ext)
  14
+    unless RUBY_PLATFORM =~ /mswin|mingw/
  15
+      ext.cross_compile = true
  16
+      ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
  17
+
  18
+      # inject 1.8/1.9 pure-ruby entry point
  19
+      ext.cross_compiling do |spec|
  20
+        spec.files += ["lib/#{ext.name}.rb"]
  21
+      end
  22
+    end
  23
+  end
  24
+
  25
+  Rake::ExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext|
  26
+    ext.ext_dir = 'ext'
  27
+    setup_cross_compilation(ext)
  28
+  end
  29
+  Rake::ExtensionTask.new("fastfilereaderext", GEMSPEC) do |ext|
  30
+    ext.ext_dir = 'ext/fastfilereader'
  31
+    setup_cross_compilation(ext)
  32
+  end
  33
+end
  34
+
  35
+# Setup shim files that require 1.8 vs 1.9 extensions in win32 bin gems
  36
+%w[ rubyeventmachine fastfilereaderext ].each do |filename|
  37
+  file("lib/#{filename}.rb") do |t|
  38
+    File.open(t.name, 'wb') do |f|
  39
+      f.write <<-eoruby
  40
+  RUBY_VERSION =~ /(\\d+.\\d+)/
  41
+  require "\#{$1}/#{File.basename(t.name, '.rb')}"
  42
+      eoruby
  43
+    end
  44
+    at_exit{ FileUtils.rm t.name if File.exists?(t.name) }
  45
+  end
  46
+end
  47
+
  48
+task :cross_cxx do
  49
+  ENV['CROSS_COMPILING'] = 'yes'
  50
+  ENV['CXX'] = 'i386-mingw32-g++'
  51
+end
  52
+
  53
+if Rake::Task.task_defined?(:cross)
  54
+  task :cross => 'lib/rubyeventmachine.rb'
  55
+  task :cross => 'lib/fastfilereaderext.rb'
  56
+  task :cross => :cross_cxx
  57
+end
  58
+
  59
+def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
  60
+def sudo(cmd)
  61
+  if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
  62
+    sh cmd
  63
+  else
  64
+    sh "sudo #{cmd}"
  65
+  end
  66
+end
  67
+def gem_cmd(action, name, *args)
  68
+  rb = Gem.ruby rescue nil
  69
+  rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
  70
+  sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
  71
+end
  72
+
  73
+Rake::Task[:clean].enhance [:clobber_package]
  74
+
  75
+namespace :gem do
  76
+  desc 'Install gem (and sudo if required)'
  77
+  task :install => :package do
  78
+    gem_cmd(:install, "pkg/#{GEMSPEC.name}-#{GEMSPEC.version}.gem")
  79
+  end
  80
+
  81
+  desc 'Uninstall gem (and sudo if required)'
  82
+  task :uninstall do
  83
+    gem_cmd(:uninstall, "#{GEMSPEC.name}", "-v=#{GEMSPEC.version}")
  84
+  end
  85
+end
6  tasks/test.rake
... ...
@@ -0,0 +1,6 @@
  1
+require 'rake/testtask'
  2
+
  3
+Rake::TestTask.new(:test) do |t|
  4
+  t.pattern = 'tests/**/test_*.rb'
  5
+  t.warning = true
  6
+end

0 notes on commit a569635

Please sign in to comment.
Something went wrong with that request. Please try again.