Top Level Namespace
Defined Under Namespace
Modules: Bdb, Replication Classes: Array, Object
Instance Method Summary collapse
Instance Method Details
#create_header ⇒ Object
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'ext/extconf.rb', line 28 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 |