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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/windows_gui/uiribbon.rb', line 34
def Build(opts = {})
opts[:name] ||= File.basename($0, '.rbw')
path = File.dirname(File.expand_path($0))
xml_path = "#{path}/#{opts[:name]}.xml"
rb_path = "#{path}/#{opts[:name]}.rb"
dll_path = "#{path}/#{opts[:name]}.dll"
log_path = "#{path}/#{opts[:name]}.log"
opts[:sdkroot] ||= "#{ENV['ProgramFiles']}/Windows Kits/10"
opts[:vcroot] ||= "#{ENV['ProgramFiles']}/Microsoft Visual Studio 14.0/VC"
opts[:uicc] ||= "#{opts[:sdkroot]}/bin/x86/uicc.exe"
opts[:rc] ||= "#{opts[:sdkroot]}/bin/x86/rc.exe"
opts[:vcvars] ||= "#{opts[:vcroot]}/bin/vcvars32.bat"
opts[:link] ||= "#{opts[:vcroot]}/bin/link.exe"
raise 'Building the UIRibbon resources requires Windows SDK and VC' unless
[:uicc, :rc, :vcvars, :link].all? { |tool| File.exist?(opts[tool]) }
STDERR.puts "UIRibbon resources build toolchain OK"
File.delete(log_path) if File.exist?(log_path)
system "@echo off && \\\n\"\#{opts[:uicc]}\" \"\#{opts[:name]}.xml\" \"\#{opts[:name]}.bml\" /header:\"\#{opts[:name]}.h\" /res:\"\#{opts[:name]}.rc\" > \"\#{opts[:name]}.log\" && \\\n\"\#{opts[:rc]}\" /nologo /fo\"\#{ENV['TEMP']}/\#{opts[:name]}.res\" \"\#{opts[:name]}.rc\" >> \"\#{opts[:name]}.log\" && \\\ncall \"\#{opts[:vcvars]}\" >> \"\#{opts[:name]}.log\" && \\\n\"\#{opts[:link]}\" /nologo /machine:x86 /dll /noentry /out:\"\#{opts[:name]}.dll\" \"\#{ENV['TEMP']}/\#{opts[:name]}.res\" >> \"\#{opts[:name]}.log\"\n CMD\n\n if File.read(log_path) =~ /error/im\n ShellExecute(nil, L('open'), L(log_path.dup), nil, nil, SW_SHOWNORMAL) if\n opts[:showLog]\n\n raise \"UIRibbon resources build FAILED - see \#{log_path} for details\"\n end\n\n File.open(rb_path, 'w') { |rb|\n rb.puts \"# Generated by the UIRibbon build, do NOT modify\\n\\n\"\n\n File.foreach(\"\#{path}/\#{opts[:name]}.h\") { |line|\n rb.puts \"\#{$1[0].upcase}\#{$1[1..-1]} = \#{$2}\" if line =~ /^\\s*#define\\s+(\\w+)\\s+(\\d+)/\n }\n }\n\n %w{bml h rc}.each { |ext|\n File.delete(\"\#{path}/\#{opts[:name]}.\#{ext}\") if File.exist?(\"\#{path}/\#{opts[:name]}.\#{ext}\")\n } if opts[:clean]\n\n STDERR.puts \"UIRibbon resources build succeeded\"\nend\n"
|