| 12 | | CLEAN.include ['ext/hpricot_scan/*.{bundle,so,obj,pdb,lib,def,exp}', 'ext/hpricot_scan/Makefile', |
| | 12 | PKG = "#{NAME}-#{VERS}" |
| | 13 | BIN = "*.{bundle,jar,so,obj,pdb,lib,def,exp}" |
| | 14 | CLEAN.include ["ext/hpricot_scan/#{BIN}", "lib/#{BIN}", 'ext/hpricot_scan/Makefile', |
| | 17 | PKG_FILES = %w(CHANGELOG COPYING README Rakefile) + |
| | 18 | Dir.glob("{bin,doc,test,lib,extras}/**/*") + |
| | 19 | Dir.glob("ext/**/*.{h,java,c,rb,rl}") + |
| | 20 | %w[ext/hpricot_scan/hpricot_scan.c] # needed because it's generated later |
| | 21 | SPEC = |
| | 22 | Gem::Specification.new do |s| |
| | 23 | s.name = NAME |
| | 24 | s.version = VERS |
| | 25 | s.platform = Gem::Platform::RUBY |
| | 26 | s.has_rdoc = true |
| | 27 | s.rdoc_options += RDOC_OPTS |
| | 28 | s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"] |
| | 29 | s.summary = "a swift, liberal HTML parser with a fantastic library" |
| | 30 | s.description = s.summary |
| | 31 | s.author = "why the lucky stiff" |
| | 32 | s.email = 'why@ruby-lang.org' |
| | 33 | s.homepage = 'http://code.whytheluckystiff.net/hpricot/' |
| | 34 | s.files = PKG_FILES |
| | 35 | s.require_path = "lib" |
| | 36 | s.extensions = FileList["ext/**/extconf.rb"].to_a |
| | 37 | s.bindir = "bin" |
| | 38 | end |
| 19 | | desc "Compiles all extensions" |
| 20 | | task :compile => [:hpricot_scan] do |
| 21 | | if Dir.glob(File.join("lib","hpricot_scan.*")).length == 0 |
| 22 | | STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 23 | | STDERR.puts "Gem actually failed to build. Your system is" |
| 24 | | STDERR.puts "NOT configured properly to build hpricot." |
| 25 | | STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 26 | | exit(1) |
| 27 | | end |
| 28 | | end |
| 29 | | task :hpricot_scan => [:ragel] |
| 30 | | |
| 51 | | spec = |
| 52 | | Gem::Specification.new do |s| |
| 53 | | s.name = NAME |
| 54 | | s.version = VERS |
| 55 | | s.platform = Gem::Platform::RUBY |
| 56 | | s.has_rdoc = true |
| 57 | | s.rdoc_options += RDOC_OPTS |
| 58 | | s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"] |
| 59 | | s.summary = "a swift, liberal HTML parser with a fantastic library" |
| 60 | | s.description = s.summary |
| 61 | | s.author = "why the lucky stiff" |
| 62 | | s.email = 'why@ruby-lang.org' |
| 63 | | s.homepage = 'http://code.whytheluckystiff.net/hpricot/' |
| 64 | | |
| 65 | | s.files = %w(COPYING README Rakefile) + |
| 66 | | Dir.glob("{bin,doc,test,lib,extras}/**/*") + |
| 67 | | Dir.glob("ext/**/*.{h,c,rb,rl}") + |
| 68 | | %w[ext/hpricot_scan/hpricot_scan.c] # needed because it's generated later |
| 69 | | |
| 70 | | s.require_path = "lib" |
| 71 | | #s.autorequire = "hpricot" # no no no this is tHe 3v1l |
| 72 | | s.extensions = FileList["ext/**/extconf.rb"].to_a |
| 73 | | s.bindir = "bin" |
| 74 | | end |
| 75 | | |
| 76 | | Rake::GemPackageTask.new(spec) do |p| |
| | 63 | Rake::GemPackageTask.new(SPEC) do |p| |
| | 84 | desc "Compiles the Ruby extension" |
| | 85 | task :compile => [:hpricot_scan] do |
| | 86 | if Dir.glob(File.join("lib","hpricot_scan.*")).length == 0 |
| | 87 | STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| | 88 | STDERR.puts "Gem actually failed to build. Your system is" |
| | 89 | STDERR.puts "NOT configured properly to build hpricot." |
| | 90 | STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| | 91 | exit(1) |
| | 92 | end |
| | 93 | end |
| | 94 | task :hpricot_scan => [:ragel] |
| | 95 | |
| 116 | | PKG_FILES = FileList[ |
| 117 | | "test/**/*.{rb,html,xhtml}", |
| 118 | | "lib/**/*.rb", |
| 119 | | "ext/**/*.{c,rb,h,rl}", |
| 120 | | "CHANGELOG", "README", "Rakefile", "COPYING", |
| 121 | | "extras/**/*", "lib/hpricot_scan.so"] |
| 122 | | |
| 123 | | Win32Spec = Gem::Specification.new do |s| |
| 124 | | s.name = NAME |
| 125 | | s.version = VERS |
| 126 | | s.platform = Gem::Platform::WIN32 |
| 127 | | s.has_rdoc = false |
| 128 | | s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"] |
| 129 | | s.summary = "a swift, liberal HTML parser with a fantastic library" |
| 130 | | s.description = s.summary |
| 131 | | s.author = "why the lucky stiff" |
| 132 | | s.email = 'why@ruby-lang.org' |
| 133 | | s.homepage = 'http://code.whytheluckystiff.net/hpricot/' |
| 134 | | |
| 135 | | s.files = PKG_FILES |
| 136 | | |
| 137 | | s.require_path = "lib" |
| 138 | | #s.autorequire = "hpricot" # no no no this is tHe 3v1l |
| 139 | | s.extensions = [] |
| 140 | | s.bindir = "bin" |
| 141 | | end |
| | 115 | desc "Generates the Java scanner code with Ragel." |
| | 116 | task :ragel_java do |
| | 117 | sh %{ragel -J ext/hpricot_scan/hpricot_scan.java.rl | rlcodegen -o ext/hpricot_scan/HpricotScanService.java} |
| | 118 | end |
| | 119 | |
| | 120 | ### Win32 Packages ### |
| | 121 | |
| | 122 | Win32Spec = SPEC.dup |
| | 123 | Win32Spec.platform = Gem::Platform::WIN32 |
| | 124 | Win32Spec.files = PKG_FILES + ['lib/hpricot_scan.so'] |
| | 125 | Win32Spec.extensions = [] |
| | 153 | |
| | 154 | ### JRuby Packages ### |
| | 155 | |
| | 156 | compile_java = proc do |
| | 157 | sh %{javac -classpath $JRUBY_HOME/lib/jruby.jar HpricotScanService.java} |
| | 158 | sh %{jar cf hpricot_scan.jar HpricotScanService.class} |
| | 159 | end |
| | 160 | |
| | 161 | desc "Compiles the JRuby extension" |
| | 162 | task :hpricot_scan_java => [:ragel_java] do |
| | 163 | Dir.chdir("ext/hpricot_scan", &compile_java) |
| | 164 | end |
| | 165 | |
| | 166 | JRubySpec = SPEC.dup |
| | 167 | JRubySpec.platform = Gem::Platform::RUBY |
| | 168 | JRubySpec.files = PKG_FILES + ['lib/hpricot_scan.jar'] |
| | 169 | JRubySpec.extensions = [] |
| | 170 | |
| | 171 | JRUBY_PKG_DIR = "#{PKG}-jruby" |
| | 172 | |
| | 173 | desc "Package up the JRuby distribution." |
| | 174 | file JRUBY_PKG_DIR => [:ragel_java, :package] do |
| | 175 | sh "tar zxf pkg/#{PKG}.tgz" |
| | 176 | mv PKG, JRUBY_PKG_DIR |
| | 177 | end |
| | 178 | |
| | 179 | desc "Cross-compile the hpricot_scan extension for JRuby" |
| | 180 | file "hpricot_scan_jruby" => [JRUBY_PKG_DIR] do |
| | 181 | Dir.chdir("#{JRUBY_PKG_DIR}/ext/hpricot_scan", &compile_java) |
| | 182 | mv "#{JRUBY_PKG_DIR}/ext/hpricot_scan/hpricot_scan.jar", "#{JRUBY_PKG_DIR}/lib" |
| | 183 | end |
| | 184 | |
| | 185 | desc "Build the RubyGems package for JRuby" |
| | 186 | task :package_jruby => ["hpricot_scan_jruby"] do |
| | 187 | Dir.chdir("#{JRUBY_PKG_DIR}") do |
| | 188 | Gem::Builder.new(JRubySpec).build |
| | 189 | verbose(true) { |
| | 190 | mv Dir["*.gem"].first, "../pkg/#{JRUBY_PKG_DIR}.gem" |
| | 191 | } |
| | 192 | end |
| | 193 | end |
| | 194 | |
| | 195 | CLEAN.include JRUBY_PKG_DIR |