root/branches/raggi/Rakefile

Revision 784, 5.0 kB (checked in by raggi, 10 months ago)

Copy back to be completed merge commit on trunk, to this branch. Many fixes in tests, rake test now reliable

  • 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 # If running under rubygems...
42 __DIR__ ||= File.expand_path(File.dirname(__FILE__))
43 if Gem.path.any? {|path| %r(^#{Regexp.escape path}) =~ __DIR__}
44   task :default => :gem_build
45 else
46   desc "Run tests."
47   task :default => :test
48 end
49
50 desc ":default build when running under rubygems."
51 task :gem_build => :build
52
53 desc "Build extension (or EVENTMACHIINE_LIBRARY) and place in lib"
54 build_task = 'ext:build'
55 build_task = 'java:build' if $eventmachine_library == :java
56 build_task = :dummy_build if $eventmachine_library == :pure_ruby
57 task :build => build_task do |t|
58   Dir.glob('{ext,java/src}/*.{so,bundle,dll,jar}').each do |f|
59     mv f, "lib"
60   end
61 end
62
63 task :dummy_build
64
65 # Basic clean definition, this is enhanced by imports aswell.
66 task :clean do
67   chdir 'ext' do
68     sh 'make clean' if test ?e, 'Makefile'
69   end
70   Dir.glob('**/Makefile').each { |file| rm file }
71   Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
72 end
73
74 Spec = Gem::Specification.new do |s|
75   s.name              = "eventmachine"
76   s.summary           = "Ruby/EventMachine library"
77   s.platform          = Gem::Platform::RUBY
78
79   s.has_rdoc          = true
80   s.rdoc_options      = %w(--title EventMachine --main docs/README --line-numbers)
81   s.extra_rdoc_files  = Dir['docs/*']
82
83   s.files             = %w(Rakefile) + Dir["{bin,tests,lib,ext,java,tasks}/**/*"]
84
85   s.require_path      = 'lib'
86
87   s.test_file         = "tests/testem.rb"
88   s.extensions        = "Rakefile"
89
90   s.author            = "Francis Cianfrocca"
91   s.email             = "garbagecat10@gmail.com"
92   s.rubyforge_project = 'eventmachine'
93   s.homepage          = "http://rubyeventmachine.com"
94
95   # Pulled in from readme, as code to pull from readme was not working!
96   # Might be worth removing as no one seems to use gem info anyway.
97   s.description = <<-EOD
98 EventMachine implements a fast, single-threaded engine for arbitrary network
99 communications. It's extremely easy to use in Ruby. EventMachine wraps all
100 interactions with IP sockets, allowing programs to concentrate on the
101 implementation of network protocols. It can be used to create both network
102 servers and clients. To create a server or client, a Ruby program only needs
103 to specify the IP address and port, and provide a Module that implements the
104 communications protocol. Implementations of several standard network protocols
105 are provided with the package, primarily to serve as examples. The real goal
106 of EventMachine is to enable programs to easily interface with other programs
107 using TCP/IP, especially if custom protocols are required.
108   EOD
109
110   require 'lib/eventmachine_version'
111   s.version = EventMachine::VERSION
112 end
113
114 namespace :ext do
115   desc "Build C++ extension"
116   task :build => [:clean, :make]
117  
118   desc "make extension"
119   task :make => [:makefile] do
120     chdir 'ext' do
121       sh 'make'
122     end
123   end
124
125   desc 'Compile the makefile'
126   task :makefile do |t|
127     chdir 'ext' do
128       ruby 'extconf.rb'
129     end
130   end
131 end
132  
133 namespace :java do
134   # This task creates the JRuby JAR file and leaves it in the lib directory.
135   # This step is required before executing the jgem task.
136   desc "Build java extension"
137   task :build => [:jar] do |t|
138     chdir('java/src') do
139       mv 'em_reactor.jar', '../../lib/em_reactor.jar'
140     end
141   end
142  
143   desc "compile .java to .class"
144   task :compile do
145     chdir('java/src') do
146       sh 'javac com/rubyeventmachine/*.java'
147     end
148   end
149  
150   desc "compile .classes to .jar"
151   task :jar => [:compile] do
152     chdir('java/src') do
153       sh "jar -cf em_reactor.jar com/rubyeventmachine/*.class"
154     end
155   end
156 end
Note: See TracBrowser for help on using the browser.