Hi Charlie, I'd prefer to take care of this simply b/c I'm going to do
some work on the build process as a whole. But I may need some help
along the way and certianly will need help testing it one Windows. So
if I can call on you then, that would be great.

Sure.  Let me tell you how I did it for ruby-prof in case it helps.

First, I've attached the Rakefile I created for ruby-prof which setups gems for *nix and Windows. In particular, look at line 82 and on. It took me a while to puzzle through it - with a lot of inspiration from how RCov does it.

Second, I created a separate directory for a MingW build which contains a hand-crafted Makefile. You have to do this because the standard mkmf built-in to Ruby assume you are linking against the same libraries Ruby itself was built with. That assumption fails because Ruby on Windows is built with VC++. And the reason to not use VC++ is because you then introduce dependencies on the right version of the C Runtime (MingW uses a version which is on just about every windows computer). Thus I separately run the make file to build the executable - the rakefile just copies it over for packaging.

Third, for debugging purposes, I have a separate directory for a VC++ project file. That isn't so important for building gems...but it sure makes it a lot easier to debug stuff on Windows.

Maybe this is easier now with mkrf, but I haven't tried it so I'm not sure. If only Ruby had something like Python's distutils that handles all these various compiler/os combinations...

Charlie





How do you want to split it?Sure

T.
_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel
require 'rubygems'
require 'rake/gempackagetask'
require 'rake/rdoctask'

SO_NAME = "ruby_prof.so"

# ------- Default Package ----------
RUBY_PROF_VERSION = "0.5.2"

FILES = FileList[
  'Rakefile',
  'README',
  'LICENSE',
  'CHANGES',
  'bin/*',
  'lib/**/*',
  'rails_plugin/**/*',
  'examples/*',
  'ext/*',
  'doc/**/*',
  'test/*'
]

# Default GEM Specification
default_spec = Gem::Specification.new do |spec|
  spec.name = "ruby-prof"
  
  spec.homepage = "http://rubyforge.org/projects/ruby-prof/";
  spec.summary = "Fast Ruby profiler"
  spec.description = <<-EOF
ruby-prof is a fast code profiler for Ruby. It is a C extension and
therefore is many times faster than the standard Ruby profiler. It
supports both flat and graph profiles.  For each method, graph profiles
show how long the method ran, which methods called it and which 
methods it called. RubyProf generate both text and html and can output
it to standard out or to a file.
EOF

  spec.version = RUBY_PROF_VERSION

  spec.author = "Shugo Maeda and Charlie Savage"
  spec.email = "[EMAIL PROTECTED] and [EMAIL PROTECTED]"
  spec.platform = Gem::Platform::RUBY
  spec.require_path = "lib" 
  spec.bindir = "bin"
  spec.executables = ["ruby-prof"]
  spec.extensions = ["ext/extconf.rb"]
  spec.autorequire = "ruby-prof"
  spec.files = FILES.to_a
  spec.test_files = Dir["test/test_*.rb"]
  

  spec.required_ruby_version = '>= 1.8.4'
  spec.date = DateTime.now
  spec.rubyforge_project = 'ruby-prof'
  
  # rdoc
  spec.has_rdoc = true
  spec.rdoc_options << "--title" << "ruby-prof"
  # Show source inline with line numbers
  spec.rdoc_options << "--inline-source" << "--line-numbers"
  # Make the readme file the start page for the generated html
  spec.rdoc_options << '--main' << 'README'
  spec.extra_rdoc_files = ['bin/ruby-prof',
                           'ext/ruby_prof.c',
                           'examples/flat.txt',
                           'examples/graph.txt',
                           'examples/graph.html',
                           'README',
                           'LICENSE']

end


# Rake task to build the default package
Rake::GemPackageTask.new(default_spec) do |pkg|
  pkg.need_tar = true
  pkg.need_zip = true
end


# ------- Windows Package ----------

# Windows specification
win_spec = default_spec.clone
win_spec.extensions = []
win_spec.platform = Gem::Platform::WIN32
win_spec.files += ["lib/#{SO_NAME}"]


desc "Create Windows Gem"
task :create_win32_gem do
  # Copy the win32 extension built by MingW - easier to install
  # since there are no dependencies of msvcr80.dll
  current_dir = File.expand_path(File.dirname(__FILE__))
  source = File.join(current_dir, "mingw", SO_NAME)
  target = File.join(current_dir, "lib", SO_NAME)
  cp(source, target)

  # Create the gem, then move it to pkg
  Gem::Builder.new(win_spec).build
  gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
  mv(gem_file, "pkg/#{gem_file}")

  # Remove win extension from top level directory  
  rm(target)
end


task :package => :create_win32_gem

# ---------  RDoc Documentation ------
desc "Generate rdoc documentation"
Rake::RDocTask.new("rdoc") do |rdoc|
  rdoc.rdoc_dir = 'doc'
  rdoc.title    = "ruby-prof"
  # Show source inline with line numbers
  rdoc.options << "--inline-source" << "--line-numbers"
  # Make the readme file the start page for the generated html
  rdoc.options << '--main' << 'README'
  rdoc.rdoc_files.include('bin/**/*',
                          'doc/*.rdoc',
                          'examples/flat.txt',
                          'examples/graph.txt',
                          'examples/graph.html',
                          'lib/**/*.rb',
                          'ext/**/ruby_prof.c',
                          'README',
                          'LICENSE')
end


# ---------  Publish to RubyForge  ----------------
desc "Publish ruby-prof to RubyForge."
task :publish do 
  require 'rake/contrib/sshpublisher'
  
  # Get ruby-prof path
  ruby_prof_path = File.expand_path(File.dirname(__FILE__))

  publisher = Rake::SshDirPublisher.new("[EMAIL PROTECTED]",
        "/var/www/gforge-projects/ruby-prof", ruby_prof_path)
end

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to