Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-release-src > by-pkgid > 48a073ea26f34ae1acadbd8a31759f47 > files > 1

ruby-hpricot-0.6-2mdv2010.0.src.rpm

--- Rakefile.ragel6	2007-06-16 00:28:48.000000000 +0200
+++ Rakefile	2008-08-02 19:40:49.000000000 +0200
@@ -7,7 +7,8 @@
 include FileUtils
 
 NAME = "hpricot"
-REV = `svn info`[/Revision: (\d+)/, 1] rescue nil
+REV = nil
+#`svn info`[/Revision: (\d+)/, 1] rescue nil
 VERS = ENV['VERSION'] || "0.6" + (REV ? ".#{REV}" : "")
 PKG = "#{NAME}-#{VERS}"
 BIN = "*.{bundle,jar,so,obj,pdb,lib,def,exp}"
@@ -109,97 +110,26 @@
   cp ext_so, ARCHLIB
 end
 
+### Extension Building ###
 desc "returns the ragel version"
 task :ragel_version do
   @ragel_v = `ragel -v`[/(version )(\S*)/,2].to_f
 end
 
-desc "Generates the C scanner code with Ragel."
-task :ragel => [:ragel_version] do
-  sh %{ragel ext/hpricot_scan/hpricot_scan.rl | #{@ragel_v >= 5.18 ? 'rlgen-cd' : 'rlcodegen'} -G2 -o ext/hpricot_scan/hpricot_scan.c}
-end
-
-desc "Generates the Java scanner code with Ragel."
-task :ragel_java => [:ragel_version] do
-  sh %{ragel -J ext/hpricot_scan/hpricot_scan.java.rl | #{@ragel_v >= 5.18 ? 'rlgen-java' : 'rlcodegen'} -o  ext/hpricot_scan/HpricotScanService.java}
-end
-
-### Win32 Packages ###
-
-Win32Spec = SPEC.dup
-Win32Spec.platform = Gem::Platform::WIN32
-Win32Spec.files = PKG_FILES + ["#{ARCHLIB}/hpricot_scan.so"]
-Win32Spec.extensions = []
-  
-WIN32_PKG_DIR = "#{PKG}-mswin32"
-
-desc "Package up the Win32 distribution."
-file WIN32_PKG_DIR => [:package] do
-  sh "tar zxf pkg/#{PKG}.tgz"
-  mv PKG, WIN32_PKG_DIR
-end
-
-desc "Cross-compile the hpricot_scan extension for win32"
-file "hpricot_scan_win32" => [WIN32_PKG_DIR] do
-  cp "extras/mingw-rbconfig.rb", "#{WIN32_PKG_DIR}/ext/hpricot_scan/rbconfig.rb"
-  sh "cd #{WIN32_PKG_DIR}/ext/hpricot_scan/ && ruby -I. extconf.rb && make"
-  mv "#{WIN32_PKG_DIR}/ext/hpricot_scan/hpricot_scan.so", "#{WIN32_PKG_DIR}/#{ARCHLIB}"
-end
-
-desc "Build the binary RubyGems package for win32"
-task :package_win32 => ["hpricot_scan_win32"] do
-  Dir.chdir("#{WIN32_PKG_DIR}") do
-    Gem::Builder.new(Win32Spec).build
-    verbose(true) {
-      mv Dir["*.gem"].first, "../pkg/#{WIN32_PKG_DIR}.gem"
-    }
-  end
-end
-
-CLEAN.include WIN32_PKG_DIR
-
-### JRuby Packages ###
-
-compile_java = proc do
-  sh %{javac -source 1.4 -target 1.4 -classpath $JRUBY_HOME/lib/jruby.jar HpricotScanService.java}
-  sh %{jar cf hpricot_scan.jar HpricotScanService.class}
-end
-
-desc "Compiles the JRuby extension"
-task :hpricot_scan_java => [:ragel_java] do
-  Dir.chdir("ext/hpricot_scan", &compile_java)
-end
-
-JRubySpec = SPEC.dup
-JRubySpec.platform = 'jruby'
-JRubySpec.files = PKG_FILES + ["#{ARCHLIB}/hpricot_scan.jar"]
-JRubySpec.extensions = []
-
-JRUBY_PKG_DIR = "#{PKG}-jruby"
-
-desc "Package up the JRuby distribution."
-file JRUBY_PKG_DIR => [:ragel_java, :package] do
-  sh "tar zxf pkg/#{PKG}.tgz"
-  mv PKG, JRUBY_PKG_DIR
-end
-
-desc "Cross-compile the hpricot_scan extension for JRuby"
-file "hpricot_scan_jruby" => [JRUBY_PKG_DIR] do
-  Dir.chdir("#{JRUBY_PKG_DIR}/ext/hpricot_scan", &compile_java)
-  mv "#{JRUBY_PKG_DIR}/ext/hpricot_scan/hpricot_scan.jar", "#{JRUBY_PKG_DIR}/#{ARCHLIB}"
+RAGEL_COMMON  = "ext/hpricot_scan/hpricot_common.rl"
+RAGEL_C_FILES = [ RAGEL_COMMON, "ext/hpricot_scan/hpricot_scan.rl" ]
+RAGEL_J_FILES = [ RAGEL_COMMON, "ext/hpricot_scan/hpricot_scan.java.rl" ]
+C_OUTPUT      = "ext/hpricot_scan/hpricot_scan.c"
+JAVA_OUTPUT   = "ext/hpricot_scan/HpricotScanService.java"
+
+file C_OUTPUT => RAGEL_C_FILES do |t|
+  cmd = "ragel #{@ragel_v >= 6.0 ? "-G2 -o #{t.name}" : '' } #{RAGEL_C_FILES.last}"
+  cmd += %{ | #{@ragel_v >= 5.18 ? 'rlgen-cd' : 'rlcodegen'} -G2 -o #{t.name}} if @ragel_v < 6.0
+  sh cmd
 end
 
-desc "Build the RubyGems package for JRuby"
-task :package_jruby => ["hpricot_scan_jruby"] do
-  Dir.chdir("#{JRUBY_PKG_DIR}") do
-    Gem::Builder.new(JRubySpec).build
-    verbose(true) {
-      mv Dir["*.gem"].first, "../pkg/#{JRUBY_PKG_DIR}.gem"
-    }
-  end
-end
-
-CLEAN.include JRUBY_PKG_DIR
+desc "Generates the C scanner code with Ragel."
+task :ragel => [:ragel_version, C_OUTPUT] 
 
 task :install do
   sh %{rake package}