Sha256: 7f9b618f09703d536f07ef07f0b68e993078cbed430392700766f9a987820e9a
Contents?: true
Size: 1.35 KB
Versions: 11
Compression:
Stored size: 1.35 KB
Contents
require 'rbconfig' dl_ext = RbConfig::CONFIG['DLEXT'] namespace :rbx_parser do _ = lambda { |file| File.expand_path(file, File.dirname(__FILE__)); } lexer_c = file _["lexer.c"] => _["lexer.lex"] do |task| Dir.chdir _["."] do sh 'flex', '--outfile', task.to_s, '--header-file=lexer.h', task.prerequisites.first end end parser_c = file _["parser.c"] => _["parser.y"] do |task| Dir.chdir(_["."]) { sh "bison", "--output", task.to_s, "-d", "-v", task.prerequisites.first } end makefile = file _["Makefile"] => [_["extconf.rb"], lexer_c, parser_c] do |task| Dir.chdir(_["."]) { sh 'rbx', task.prerequisites.first } end desc "Builds the parser." task :parser => parser_c desc "Builds the lexer." task :lexer => lexer_c desc "Compiles the generated lexer and parser." task :compile => [makefile, parser_c, lexer_c] do sh 'make', '-C', _["."] end desc "Cleans up generated files." task :clean do rm_f lexer_c.to_s rm_f parser_c.to_s rm_f makefile.to_s rm_f _["lexer.h"] rm_f _["parser.h"] rm_f _["parser.output"] rm_f Dir.glob(_["*.{o,so,rbc,log}"]) sh 'make', '-C', _["."], "clean" rescue nil end parser_e = file _["fancy_parser.#{dl_ext}"] => :compile task :ext => parser_e desc "Invokes the compile task." task :default => :compile end task :clean => "rbx_parser:clean"
Version data entries
11 entries across 11 versions & 1 rubygems