extconf.rb

Path: ext/smartcard_pcsc/extconf.rb
Last Update: Sat Oct 24 05:56:39 -0400 2009

Required files

mkmf  

Methods

Public Instance methods

[Source]

    # File ext/smartcard_pcsc/extconf.rb, line 50
50: def win32_hack(mf_name)
51:   # get the version of MSVC
52:   Kernel.system `cl 2> msvc_version.txt`
53:   msvc_logo = File.open('msvc_version.txt') { |f| f.read }
54:   print msvc_logo
55:   File.delete 'msvc_version.txt'
56:   if msvc_logo =~ /Optimizing Compiler Version (\d+)/
57:     msvc_ver = $1.to_i  
58:     # for MSVC 6.0, no manifest BS is needed -- straight-up compilation is good
59:     return if msvc_ver == 12
60:   end
61:     
62:   # HACK: monkey-patch the makefile to embed a manifest in the extension dll
63:   make_contents = File.open(mf_name, 'r') { |f| f.read }
64:   make_rules = make_contents.split(/(\n|\r)(\n|\r)+/)
65:   new_make_rules = make_rules.map do |rule|
66:     if rule =~ /^\$\(DLLIB\)\:/
67:       rule + "\n\tmt.exe -manifest $(@).manifest -outputresource:$(@);2"
68:     else
69:       rule
70:     end
71:   end
72:   File.open(mf_name, 'w') { |f| f.write new_make_rules.join("\n\n")}
73: end

[Validate]