root/trunk/Rakefile

Revision 805, 5.4 kB (checked in by raggi, 7 months ago)

Another make adjustment for win32

  • Property svn:keywords set to Id
Line 
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 #
12 # $Id$
13 #++
14
15 ### OLD RAKE: ###
16 # # The tasks and external gemspecs we used to generate binary gems are now
17 # # obsolete. Use Patrick Hurley's gembuilder to build binary gems for any
18 # # desired platform.
19 # # To build a binary gem on Win32, ensure that the include and lib paths
20 # # both contain the proper references to OPENSSL. Use the static version
21 # # of the libraries, not the dynamic, otherwise we expose the user to a
22 # # runtime dependency.
23 #
24 # # To build a binary gem for win32, first build rubyeventmachine.so
25 # # using VC6 outside of the build tree (the normal way: ruby extconf.rb,
26 # # and then nmake). Then copy rubyeventmachine.so into the lib directory,
27 # # and run rake gemwin32.
28 #
29
30 require 'rubygems'  unless defined?(Gem)
31 require 'rake'      unless defined?(Rake)
32 require 'rake/gempackagetask'
33
34 Package = false # Build zips and tarballs?
35 Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
36
37 # e.g. rake EVENTMACHINE_LIBRARY=java for forcing java build tasks as defaults!
38 $eventmachine_library = :java if RUBY_PLATFORM =~ /java/ || ENV['EVENTMACHINE_LIBRARY'] == 'java'
39 $eventmachine_library = :pure_ruby if ENV['EVENTMACHINE_LIBRARY'] == 'pure_ruby'
40
41 MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
42   'nmake'
43 else
44   'make'
45 end
46
47 # If running under rubygems...
48 __DIR__ ||= File.expand_path(File.dirname(__FILE__))
49 if Gem.path.any? {|path| %r(^#{Regexp.escape path}) =~ __DIR__}
50   task :default => :gem_build
51 else
52   desc "Build gemspec, then build eventmachine, then run tests."
53   task :default => [:gemspec, :build, :test]
54 end
55
56 desc ":default build when running under rubygems."
57 task :gem_build => :build
58
59 desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
60 build_task = 'ext:build'
61 build_task = 'java:build' if $eventmachine_library == :java
62 build_task = :dummy_build if $eventmachine_library == :pure_ruby
63 task :build => build_task do |t|
64   Dir.glob('{ext,java/src}/*.{so,bundle,dll,jar}').each do |f|
65     mv f, "lib"
66   end
67 end
68
69 task :dummy_build
70
71 # Basic clean definition, this is enhanced by imports aswell.
72 task :clean do
73   chdir 'ext' do
74     sh "#{MAKE} clean" if test ?e, 'Makefile'
75   end
76   Dir.glob('**/Makefile').each { |file| rm file }
77   Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
78 end
79
80 Spec = Gem::Specification.new do |s|
81   s.name              = "eventmachine"
82   s.summary           = "Ruby/EventMachine library"
83   s.platform          = Gem::Platform::RUBY
84
85   s.has_rdoc          = true
86   s.rdoc_options      = %w(--title EventMachine --main docs/README --line-numbers)
87   s.extra_rdoc_files  = Dir['docs/*']
88
89   s.files             = %w(Rakefile) + Dir["{bin,tests,lib,ext,java,tasks}/**/*"]
90
91   s.require_path      = 'lib'
92
93   # TODO / XXX - should we enable this? rubygems fails the install if anything
94   # is broken. What we could do is CI submission, though, and always terminate
95   # with a positive code...
96   # s.test_file         = "tests/testem.rb"
97   s.extensions        = "Rakefile"
98
99   s.author            = "Francis Cianfrocca"
100   s.email             = "garbagecat10@gmail.com"
101   s.rubyforge_project = 'eventmachine'
102   s.homepage          = "http://rubyeventmachine.com"
103
104   # Pulled in from readme, as code to pull from readme was not working!
105   # Might be worth removing as no one seems to use gem info anyway.
106   s.description = <<-EOD
107 EventMachine implements a fast, single-threaded engine for arbitrary network
108 communications. It's extremely easy to use in Ruby. EventMachine wraps all
109 interactions with IP sockets, allowing programs to concentrate on the
110 implementation of network protocols. It can be used to create both network
111 servers and clients. To create a server or client, a Ruby program only needs
112 to specify the IP address and port, and provide a Module that implements the
113 communications protocol. Implementations of several standard network protocols
114 are provided with the package, primarily to serve as examples. The real goal
115 of EventMachine is to enable programs to easily interface with other programs
116 using TCP/IP, especially if custom protocols are required.
117   EOD
118
119   require 'lib/eventmachine_version'
120   s.version = EventMachine::VERSION
121 end
122
123 namespace :ext do
124   desc "Build C++ extension"
125   task :build => [:clean, :make]
126  
127   desc "make extension"
128   task :make => [:makefile] do
129     chdir 'ext' do
130       sh MAKE
131     end
132   end
133
134   desc 'Compile the makefile'
135   task :makefile do |t|
136     chdir 'ext' do
137       ruby 'extconf.rb'
138     end
139   end
140 end
141  
142 namespace :java do
143   # This task creates the JRuby JAR file and leaves it in the lib directory.
144   # This step is required before executing the jgem task.
145   desc "Build java extension"
146   task :build => [:jar] do |t|
147     chdir('java/src') do
148       mv 'em_reactor.jar', '../../lib/em_reactor.jar'
149     end
150   end
151  
152   desc "compile .java to .class"
153   task :compile do
154     chdir('java/src') do
155       sh 'javac com/rubyeventmachine/*.java'
156     end
157   end
158  
159   desc "compile .classes to .jar"
160   task :jar => [:compile] do
161     chdir('java/src') do
162       sh "jar -cf em_reactor.jar com/rubyeventmachine/*.class"
163     end
164   end
165 end
166
167 task :gemspec => :clean do
168   open("eventmachine.gemspec", 'w') { |f| f.write Spec.to_ruby }
169 end
Note: See TracBrowser for help on using the browser.