Top Level Namespace
Defined Under Namespace
Modules: Bdb, Replication Classes: Array, Object
Instance Method Summary collapse
Instance Method Details
#create_header ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'ext/extconf.rb', line 14 def create_header if File.exist?("bdb_aux._c") ("Not writing bdb_aux._c (defines), already exists\n") return end ("Writing bdb_aux._c (defines), this takes a while\n") db_header = $CPPFLAGS.split.select { |f| f =~ /^-I/ }.map { |e| f = File.join(e[2..-1], 'db.h') File.exists?(f) ? f : nil }.select { |e| e }.first n=0 defines=[] File.open(db_header) {|fd| File.open("bdb_aux._c","w") {|hd| hd.puts("/* This file automatically generated by extconf.rb */\n") fd.each_line {|l| if l =~ %r{^#define\s+(DBC?_\w*)\s+([^\/]*)\s*(.*?)(\/\*.*)?$} name = $1 value = $2 if macro_defined?(name,"#include <db.h>") case value when /^"/ hd.print(%Q{cs(mBdb,%s);\n}%[name]) when /^\(?(0x|\d)/ hd.print(%Q{cu(mBdb,%s);\n}%[name]) when /^\(?-/ hd.print(%Q{ci(mBdb,%s);\n}%[name]) else $stderr.puts "don't know how to handle #{name} #{value.strip}, guessing UINT" hd.print(%Q{cu(mBdb,%s);\n}%[name]) end n+=1 end end } } ("\nwrote #{n} defines\n") } end |