Skip to content

Commit

Permalink
remove hacks preventing jruby from using racc and rexical
Browse files Browse the repository at this point in the history
modern versions of both run fine on jruby, so as dev tools this is
fine.

also update parser.rb with output from modern racc.
  • Loading branch information
flavorjones committed Dec 16, 2018
1 parent dfb25f3 commit 9bb0226
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 93 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -14,8 +14,8 @@ gem "minitest", "~>5.8.4", :group => [:development, :test]
gem "rake", "~>12.0", :group => [:development, :test]
gem "rake-compiler", "~>1.0.3", :group => [:development, :test]
gem "rake-compiler-dock", "~>0.6.2", :group => [:development, :test]
gem "racc", "~>1.4.14", :group => [:development, :test], :platform => [:ruby, :mingw, :x64_mingw]
gem "rexical", "~>1.0.5", :group => [:development, :test], :platform => [:ruby, :mingw, :x64_mingw]
gem "racc", "~>1.4.14", :group => [:development, :test]
gem "rexical", "~>1.0.5", :group => [:development, :test]
gem "concourse", "~>0.15", :group => [:development, :test]
gem "rdoc", ">=4.0", "<7", :group => [:development, :test]
gem "hoe", "~>3.17", :group => [:development, :test]
Expand Down
35 changes: 5 additions & 30 deletions Rakefile
Expand Up @@ -250,42 +250,17 @@ end
desc "Generate css/parser.rb and css/tokenizer.rex"
task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")

# This is a big hack to make sure that the racc and rexical
# dependencies in the Gemfile are constrainted to ruby platforms
# (i.e. MRI and Rubinius). There's no way to do that through hoe,
# and any solution will require changing hoe and hoe-bundler.
old_gemfile_task = Rake::Task['bundler:gemfile'] rescue nil
task 'bundler:gemfile' do
old_gemfile_task.invoke if old_gemfile_task

lines = File.open('Gemfile', 'r') { |f| f.readlines }.map do |line|
line =~ /racc|rexical/ ? "#{line.strip}, :platform => [:ruby, :mingw, :x64_mingw]" : line
end
File.open('Gemfile', 'w') { |f| lines.each { |line| f.puts line } }
[:compile, :check_manifest].each do |task_name|
Rake::Task[task_name].prerequisites << GENERATED_PARSER
Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
end

file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
if java?
warn "WARNING: #{GENERATED_PARSER} may be out of date:"
sh "ls -lt #{t.name} #{t.prerequisites.first}"
else
sh "racc -l -o #{t.name} #{t.prerequisites.first}"
end
sh "racc -l -o #{t.name} #{t.prerequisites.first}"
end

file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
if java?
warn "WARNING: #{GENERATED_TOKENIZER} may be out of date:"
sh "ls -lt #{t.name} #{t.prerequisites.first}"
else
sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
end
end

[:compile, :check_manifest].each do |task_name|
Rake::Task[task_name].prerequisites << GENERATED_PARSER
Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
end

# ----------------------------------------
Expand Down
122 changes: 61 additions & 61 deletions lib/nokogiri/css/parser.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9bb0226

Please sign in to comment.