ext/extconf.rb in nyara-0.1.pre.0 vs ext/extconf.rb in nyara-0.1.pre.1
- old
+ new
@@ -1,7 +1,25 @@
+Dir.chdir __dir__
require "mkmf"
+def generate_version_file
+ version_file = 'inc/version.inc'
+ puts "generating: #{version_file}"
+ lines = File.readlines('../nyara.gemspec')
+ version = nil
+ lines.each do |line|
+ if line =~ /s\.version =/
+ version = line[/\d+(\.\d+)*(\.pre\.\d+)?/]
+ break
+ end
+ end
+ abort 'version not found' unless version
+ File.open version_file, 'w' do |f|
+ f.puts %Q{#define NYARA_VERSION "#{version}"}
+ end
+end
+
def tweak_include
dir = File.dirname __FILE__
multipart_dir = File.join dir, "multipart-parser-c"
http_parser_dir = File.join dir, "http-parser"
flags = " -I#{multipart_dir.shellescape} -I#{http_parser_dir.shellescape}"
@@ -33,6 +51,7 @@
have_func('rb_ary_new_capa', 'ruby.h')
tweak_include
tweak_cflags
+generate_version_file
create_makefile 'nyara'