Changeset 164 for trunk/Rakefile

Show
Ignore:
Timestamp:
04/09/2008 22:32:36 (7 months ago)
Author:
stepheneb
Message:

ragel 6.1 fixes for hpricot_scan.java.rl; update jruby object access

Applied the updates to the ragel code for 6.1 to hpricot_scan.java.rl.

Updated decrated method used to access IRubyObject object:

new IRubyObject[]{runtime.newSymbol("buffer_size")}

becomes:

runtime.getCurrentContext(),new IRubyObject[]{runtime.newSymbol("buffer_size")}

The include statements in the main ragel code didn't
work with paths starting with ext/ so I made them
into relative path references which did work.

Updates to the Rakefile to support easy
compilation of the C ragel source code
using different ragel compilation strategies.
This is the default setting:

DEFAULT_RAGEL_C_CODE_GENERATION = "really_fast goto_driven"

which is -G2

The result is no test failures in C and only
one in Java: test_latin1_entities.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Rakefile

    r163 r164  
    2222      Dir.glob("{bin,doc,test,lib,extras}/**/*") +  
    2323      Dir.glob("ext/**/*.{h,java,c,rb,rl}") +  
    24       %w[ext/hpricot_scan/hpricot_scan.c ext/hpricot_scan/HpricotScanService.java] # needed because it's generated later 
     24      %w[ext/hpricot_scan/hpricot_scan.c ext/hpricot_scan/HpricotScanService.java] # needed because they are generated later 
     25RAGEL_C_CODE_GENERATION_STYLES = { 
     26  "table_driven" => 'T0', 
     27  "faster_table_driven" => 'T1', 
     28  "flat_table_driven" => 'F0', 
     29  "faster_flat_table_driven" => 'F1', 
     30  "goto_driven" => 'G0', 
     31  "faster_goto_driven" => 'G1', 
     32  "really_fast goto_driven" => 'G2' 
     33  # "n_way_split_really_fast_goto_driven" => 'P<N>' 
     34} 
     35DEFAULT_RAGEL_C_CODE_GENERATION = "really_fast goto_driven" 
    2536SPEC = 
    2637  Gem::Specification.new do |s| 
     
    114125task :hpricot_scan => [:ragel] 
    115126 
    116 desc "returns the ragel version" 
     127desc "Determines the Ragel version and displays it on the console along with the location of the Ragel binary." 
    117128task :ragel_version do 
    118129  @ragel_v = `ragel -v`[/(version )(\S*)/,2].to_f 
     130  puts "Using ragel version: #{@ragel_v}, location: #{`which ragel`}" 
     131  @ragel_v 
    119132end 
    120133 
     
    122135task :ragel => [:ragel_version] do 
    123136  if @ragel_v >= 6.1 
    124     sh %{ragel ext/hpricot_scan/hpricot_scan.rl -G2 -o ext/hpricot_scan/hpricot_scan.c} 
     137    @ragel_c_code_generation_style = RAGEL_C_CODE_GENERATION_STYLES[DEFAULT_RAGEL_C_CODE_GENERATION] 
     138    sh %{ragel ext/hpricot_scan/hpricot_scan.rl -#{@ragel_c_code_generation_style} -o ext/hpricot_scan/hpricot_scan.c} 
    125139  else 
    126140    STDERR.puts "Ragel 6.1 or greater is required." 
     
    129143end 
    130144 
    131 desc "Generates the Java scanner code with Ragel." 
     145# Java only supports the table-driven code  
     146# generation style at this point.  
     147desc "Generates the Java scanner code using the Ragel table-driven code generation style." 
    132148task :ragel_java => [:ragel_version] do 
    133149  if @ragel_v >= 6.1 
    134     sh %{ragel -J ext/hpricot_scan/hpricot_scan.java.rl -G2 -o ext/hpricot_scan/HpricotScanService.java} 
     150    puts "compiling with ragel version #{@ragel_v}" 
     151    sh %{ragel -J -o ext/hpricot_scan/HpricotScanService.java ext/hpricot_scan/hpricot_scan.java.rl}     
    135152  else 
    136153    STDERR.puts "Ragel 6.1 or greater is required."