Sha256: d46033e1d71e40bccfffe13cbbde4ac50af9c3cca8a9cb3446ffdf4eb9b99dec
Contents?: true
Size: 983 Bytes
Versions: 2
Compression:
Stored size: 983 Bytes
Contents
require 'fileutils' raise unless ARGV.length == 5 template_file_name = ARGV.shift output_directory = ARGV.shift token_list_file_name = ARGV.shift lang_abbrev = ARGV.shift module_name = ARGV.shift token_list = File.open(token_list_file_name).readlines.map {|line| line.chomp } lines = ["#define LANGSCAN_LANGNAME_TOKEN_LIST"] token_list.each {|token| lines.push(" LANGSCAN_LANGNAME_TOKEN(#{token})") } macro = lines.join(" \\\n") template = File.read(template_file_name) template.gsub!(/@LANGSCAN_LANGNAME_TOKEN_LIST@/, macro) template.gsub!(/LANGNAME/, lang_abbrev.upcase) template.gsub!(/langname/, lang_abbrev.downcase) template.gsub!(/LangName/, module_name) h_file_name = File.join( output_directory, lang_abbrev + ".h" ) FileUtils.rm_rf(h_file_name) File.open(h_file_name, "w") {|f| # f.printf("/* %s generated automatically from %s */\n", # h_file_name, template_file_name) f.print template } #File.chmod(0444, h_file_name)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
langscan-1.2-x86-mswin32-60 | ext/langscan/_make_h.rb |
langscan-1.2 | ext/langscan/_make_h.rb |