Changeset 699

Show
Ignore:
Timestamp:
06/16/08 04:56:37 (5 months ago)
Author:
raggi
Message:

Forwarding changes from github fork:

  • Added a .gitignore for tempfiles
  • Moved extra docs into a docs subfolder, corrected gemspec
  • General refactors in Rakefile
  • Namespaced ext and java builds
  • Changed default rake task to be an interpreter specific build
  • Changed spec.extensions to use rakefile instead of extconf.rb (java + c++ gem in one!)
  • Added java/ dir to gemspec
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/raggi/Rakefile

    r694 r699  
    1212# $Id$ 
    1313#++ 
     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 
    1430require 'rubygems'  unless defined?(Gem) 
    1531require 'rake'      unless defined?(Rake) 
     
    1733 
    1834Package = true # Build zips and tarballs? 
     35Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r } 
     36 
     37# e.g. rake EM_JAVA=true for forcing java build tasks as defaults! 
     38Java = ENV['EM_JAVA'] || RUBY_PLATFORM =~ /java/ 
     39 
     40# The default task is invoked by rubygems during install, change with caution. 
     41desc "Build suitable for run & gem install." 
     42task :default => [:build] 
     43 
     44desc "Build extension and place in lib" 
     45task :build => (Java ? 'java:build' : 'ext:build') do |t| 
     46  Dir.glob('{ext,java/src}/*.{so,bundle,dll,jar}').each do |f| 
     47    mv f, "lib" 
     48  end 
     49end 
     50 
     51# Basic clean definition, this is enhanced by imports aswell. 
     52task :clean do 
     53  chdir 'ext' do 
     54    sh 'make clean' if test ?e, 'Makefile' 
     55  end 
     56  Dir.glob('**/Makefile').each { |file| rm file } 
     57  Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file } 
     58end 
    1959 
    2060Spec = Gem::Specification.new do |s| 
     
    2464 
    2565  s.has_rdoc          = true 
    26   s.rdoc_options      = %w(--title EventMachine --main README --line-numbers) 
    27   s.extra_rdoc_files  = %w( 
    28     README RELEASE_NOTES TODO 
    29     LIGHTWEIGHT_CONCURRENCY SPAWNED_PROCESSES DEFERRABLES 
    30     PURE_RUBY EPOLL KEYBOARD SMTP 
    31     COPYING GNU LEGAL 
    32   ) 
     66  s.rdoc_options      = %w(--title EventMachine --main docs/README --line-numbers) 
     67  s.extra_rdoc_files  = Dir['docs/*'] 
    3368 
    34   s.files             = %w(Rakefile) + Dir.glob("{bin,tests,lib,ext,tasks}/**/*") 
     69  s.files             = %w(Rakefile) + Dir["{bin,tests,lib,ext,java,tasks}/**/*"] 
    3570 
    3671  s.require_path      = 'lib' 
    3772 
    3873  s.test_file         = "tests/testem.rb" 
    39   s.extensions        = "ext/extconf.rb
     74  s.extensions        = "Rakefile
    4075 
    4176  s.author            = "Francis Cianfrocca" 
     
    6196  require 'lib/eventmachine_version' 
    6297  s.version = EventMachine::VERSION 
    63   # s.requirements << 'Java' # TODO 
    6498end 
    6599 
    66 Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r } 
     100namespace :ext do 
     101  desc "Build C++ extension" 
     102  task :build => [:clean, :make] 
     103   
     104  desc "make extension" 
     105  task :make => [:makefile] do 
     106    chdir 'ext' do 
     107      sh 'make' 
     108    end 
     109  end 
    67110 
    68 desc "Compile the extension." 
    69 task :build do |t| 
    70   mkdir "nonversioned" unless File.directory?("nonversioned") 
    71   chdir("nonversioned") do 
    72     system "ruby ../ext/extconf.rb" 
    73     system "make clean" 
    74     system "make" 
    75     Dir.glob('*.{so,bundle,dll,jar}').each do |f| 
    76       cp f, "../lib" 
     111  desc 'Compile the makefile' 
     112  task :makefile do |t| 
     113    chdir 'ext' do 
     114      ruby 'extconf.rb' 
    77115    end 
    78116  end 
    79117end 
    80  
    81 # Basic clean definition, this is enhanced by imports aswell. 
    82 task :clean do 
    83   Dir.glob('lib/*.{so,bundle,jar,dll}').each { |file| rm file } 
    84   rm_rf 'nonversioned' 
    85   Dir.glob('java/**/*.{class,jar}').each { |file| rm file } 
    86 end 
    87  
    88 ### OLD RAKE: ### 
    89 # # The tasks and external gemspecs we used to generate binary gems are now 
    90 # # obsolete. Use Patrick Hurley's gembuilder to build binary gems for any 
    91 # # desired platform. 
    92 # # To build a binary gem on Win32, ensure that the include and lib paths 
    93 # # both contain the proper references to OPENSSL. Use the static version 
    94 # # of the libraries, not the dynamic, otherwise we expose the user to a 
    95 # # runtime dependency. 
    96 #  
    97 # =begin 
    98 # # To build a binary gem for win32, first build rubyeventmachine.so 
    99 # # using VC6 outside of the build tree (the normal way: ruby extconf.rb, 
    100 # # and then nmake). Then copy rubyeventmachine.so into the lib directory, 
    101 # # and run rake gemwin32. 
    102 # =end 
    103 #  
    104  
    105  
    106 JSpec = Spec.dup 
    107 JSpec.name = 'eventmachine-java' 
    108 JSpec.extensions = nil 
    109 JSpec.files << 'lib/em_reactor.jar' 
    110  
    111 Rake::GemPackageTask.new(JSpec) do end 
    112 desc "Build the EventMachine RubyGem for JRuby" 
    113 task :jgem => [:clean, :jar, "pkg/eventmachine-java-#{JSpec.version}.gem"] 
    114  
    115 namespace :jgem do 
    116   desc "Build and install the jruby gem" 
    117   task :install => :jgem do 
    118     sudo "gem inst pkg/#{JSpec.name}*.gem" 
     118   
     119namespace :java do 
     120  # This task creates the JRuby JAR file and leaves it in the lib directory. 
     121  # This step is required before executing the jgem task. 
     122  desc "Build java extension" 
     123  task :build => [:jar] do |t| 
     124    chdir('java/src') do 
     125      mv 'em_reactor.jar', '../../lib/em_reactor.jar' 
     126    end 
     127  end 
     128   
     129  desc "compile .java to .class" 
     130  task :compile do 
     131    chdir('java/src') do 
     132      sh 'javac com/rubyeventmachine/*.java' 
     133    end 
     134  end 
     135   
     136  desc "compile .classes to .jar" 
     137  task :jar => [:compile] do 
     138    chdir('java/src') do 
     139      sh "jar -cf em_reactor.jar com/rubyeventmachine/*.class" 
     140    end 
    119141  end 
    120142end 
    121  
    122  
    123 # This task creates the JRuby JAR file and leaves it in the lib directory. 
    124 # This step is required before executing the jgem task. 
    125 desc "Compile the JAR" 
    126 task :jar do |t| 
    127   chdir('java/src') do 
    128     sh 'javac com/rubyeventmachine/*.java' 
    129     sh "jar -cf em_reactor.jar com/rubyeventmachine/*.class" 
    130     mv 'em_reactor.jar', '../../lib/em_reactor.jar' 
    131   end 
    132 end 
    133  
    134 # The idea for using Rakefile instead of extconf: task :default => [RUBY_PLATFORM == 'java' ? :jar : :extension]