Sha256: b46e0b66229690f5a4eb2c1460f9444a8a2ec7e6becbba027afa853cac99d92d

Contents?: true

Size: 1.29 KB

Versions: 16

Compression:

Stored size: 1.29 KB

Contents

require "rubygems"
require "rake"
require "mkmf"

desc "Building event log dll"

def ensure_present(commands)
  commands.each do |c|
    unless find_executable c
      warn "Could not find #{c}. Windows Event Logging will not correctly function."
    end
  end
end

EVT_MC_FILE = "chef-log.man"
EVT_RC_FILE = "chef-log.rc"
EVT_RESOURCE_OBJECT = "resource.o"
EVT_SHARED_OBJECT = "chef-log.dll"
MC = "windmc"
RC = "windres"
CC = "gcc"

ensure_present [MC, RC, CC]

task :build => [EVT_RESOURCE_OBJECT, EVT_SHARED_OBJECT]
task :default => [:build, :register]

file EVT_RC_FILE => EVT_MC_FILE do
  sh "#{MC} #{EVT_MC_FILE}"
end

file EVT_RESOURCE_OBJECT => EVT_RC_FILE do
  sh "#{RC} -i #{EVT_RC_FILE} -o #{EVT_RESOURCE_OBJECT}"
end

file EVT_SHARED_OBJECT => EVT_RESOURCE_OBJECT do
  sh "#{CC} -o #{EVT_SHARED_OBJECT} -shared #{EVT_RESOURCE_OBJECT}"
end

task :register => EVT_SHARED_OBJECT do
  require "win32/eventlog"
  dll_file = File.expand_path(EVT_SHARED_OBJECT)
  begin
    Win32::EventLog.add_event_source(
      :source => "Application",
      :key_name => "Chef",
      :event_message_file => dll_file,
      :category_message_file => dll_file
    )
  rescue Errno::EIO => e
    puts "Skipping event log registration due to missing privileges: #{e}"
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
chef-13.12.14-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.12.3-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.11.3-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.10.4-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.10.0-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.9.4-universal-mingw32 ext/win32-eventlog/Rakefile
chef-14.2.0-universal-mingw32 ext/win32-eventlog/Rakefile
chef-14.1.12-universal-mingw32 ext/win32-eventlog/Rakefile
chef-14.1.1-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.9.1-universal-mingw32 ext/win32-eventlog/Rakefile
chef-14.0.190-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.8.5-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.8.3-universal-mingw32 ext/win32-eventlog/Rakefile
chef-12.22.1-universal-mingw32 ext/win32-eventlog/Rakefile
chef-13.8.0-universal-mingw32 ext/win32-eventlog/Rakefile
chef-12.8.1-universal-mingw32 ext/win32-eventlog/Rakefile