Skip to content

Commit

Permalink
coordinate building of gems for 3 different platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
copiousfreetime committed Jul 27, 2010
1 parent 4164d12 commit ebf77c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
7 changes: 6 additions & 1 deletion gemspec.rb
Expand Up @@ -57,4 +57,9 @@
Hitimes::GEM_SPEC_MINGW32.platform = ::Gem::Platform.new( "i386-mingw32" ) Hitimes::GEM_SPEC_MINGW32.platform = ::Gem::Platform.new( "i386-mingw32" )
Hitimes::GEM_SPEC_MINGW32.extensions = [] Hitimes::GEM_SPEC_MINGW32.extensions = []


Hitimes::SPECS = [ Hitimes::GEM_SPEC, Hitimes::GEM_SPEC_MSWIN32, Hitimes::GEM_SPEC_MINGW32 ] Hitimes::GEM_SPEC_JAVA = Hitimes::GEM_SPEC.clone
Hitimes::GEM_SPEC_JAVA.platform = ::Gem::Platform.new( 'java' )
Hitimes::GEM_SPEC_JAVA.extensions = []

Hitimes::SPECS = [ Hitimes::GEM_SPEC, Hitimes::GEM_SPEC_MSWIN32, Hitimes::GEM_SPEC_MINGW32, Hitimes::GEM_SPEC_JAVA ]

21 changes: 18 additions & 3 deletions tasks/distribution.rake
Expand Up @@ -36,11 +36,16 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
puts Hitimes::GEM_SPEC_WIN.to_ruby puts Hitimes::GEM_SPEC_WIN.to_ruby
end end


desc "dump gemspec for java"
task :gemspec_java do
puts Hitimes::GEM_SPEC_JAVA.to_ruby
end

desc "reinstall gem" desc "reinstall gem"
task :reinstall => [:uninstall, :repackage, :install] task :reinstall => [:uninstall, :repackage, :install]


desc "package up a windows gem" desc "package up a windows gem"
task :package_win => :clean do task :package_win => :clean do
Configuration.for("extension").cross_rbconfig.keys.each do |rbconfig| Configuration.for("extension").cross_rbconfig.keys.each do |rbconfig|
v = rbconfig.split("-").last v = rbconfig.split("-").last
s = v.sub(/\.\d$/,'') s = v.sub(/\.\d$/,'')
Expand All @@ -58,15 +63,25 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
end end
end end


if RUBY_PLATFORM == "java" then
desc "package up a jruby gem"
task :package_java => "ext:build_java" do
Hitimes::GEM_SPEC_JAVA.files += FileList["lib/hitimes/java/*.jar"]
Gem::Builder.new( Hitimes::GEM_SPEC_JAVA ).build
mv Dir["*.gem"].first, "pkg"
end
end

task :clobber do task :clobber do
rm_rf "lib/hitimes/1.8" rm_rf "lib/hitimes/1.8"
rm_rf "lib/hitimes/1.9" rm_rf "lib/hitimes/1.9"
rm_rf "lib/hitimes/*.jar"
end end


task :prep => [:clean, :package, :package_win] task :prep => [:clean, :package, :package_win, :package_java ]


desc "distribute copiously" desc "distribute copiously"
task :copious => [:clean, :package, :package_win ] do task :copious => [:clean, :package, :package_win, :package_java ] do
gems = Hitimes::SPECS.collect { |s| "#{s.full_name}.gem" } gems = Hitimes::SPECS.collect { |s| "#{s.full_name}.gem" }
Rake::SshFilePublisher.new('jeremy@copiousfreetime.org', Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
'/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems', '/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
Expand Down
25 changes: 14 additions & 11 deletions tasks/extension.rake
Expand Up @@ -8,7 +8,7 @@ require 'pathname'
if ext_config = Configuration.for_if_exist?('extension') then if ext_config = Configuration.for_if_exist?('extension') then
namespace :ext do namespace :ext do
desc "Build the extension(s)" desc "Build the extension(s)"
task :build => :clean do task :build => :clobber do
ext_config.configs.each do |extension| ext_config.configs.each do |extension|
path = Pathname.new(extension) path = Pathname.new(extension)
parts = path.split parts = path.split
Expand All @@ -26,17 +26,20 @@ if ext_config = Configuration.for_if_exist?('extension') then
end end
end end


desc "Build the jruby extension" if RUBY_PLATFORM == "java" then
task :build_jruby => :clean do desc "Build the jruby extension"
path = "ext/java" task :build_java => [ :clobber, "lib/hitimes/hitimes.jar" ]
Dir.chdir( path ) do |d|
#java_ext = "lib/hitimes/java/#{RUBY_VERSION.sub(/\.\d$/,'')}/hitimes_ext.#{Config::CONFIG['DLEXT']}" file "lib/hitimes/hitimes.jar" => FileList["ext/java/src/hitimes/*.java"] do |t|
java_ext = "lib/hitimes/hitimes.jar"
jruby_home = Config::CONFIG['prefix'] jruby_home = Config::CONFIG['prefix']
classpath = "#{jruby_home}/lib/jruby.jar" jruby_jar = File.join( jruby_home, 'lib', 'jruby.jar' )
FileUtils.mkdir_p "../../#{File.dirname( java_ext )}"
sh "javac -g -cp #{classpath} hitimes/*.java" mkdir_p 'pkg/classes'
sh "jar cf ../../#{java_ext} hitimes/*.class" sh "javac -classpath #{jruby_jar} -d pkg/classes #{t.prerequisites.join(' ')}"

dest_dir = File.dirname(t.name)
mkdir_p dest_dir
sh "jar cf #{t.name} -C pkg/classes ."
end end
end end


Expand Down

0 comments on commit ebf77c7

Please sign in to comment.