Module: GRCommons::SearchSharedLibrary

Included in:
GR, GR3, GRM
Defined in:
lib/gr_commons/search_shared_library.rb

Instance Method Summary collapse

Instance Method Details

#recursive_search(name, base_dir) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/gr_commons/search_shared_library.rb', line 21

def recursive_search(name, base_dir)
  Dir.chdir(base_dir) do
    if path = Dir["**/#{name}"].first
      File.expand_path(path)
    else
      raise StandardError '#{name} not found in #{base_dir}'
    end
  end
end

#search_shared_library(gr_lib_name) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gr_commons/search_shared_library.rb', line 3

def search_shared_library(gr_lib_name)
  if Object.const_defined?(:RubyInstaller)
    ENV['GRDIR'] ||= [
      RubyInstaller::Runtime.msys2_installation.msys_path,
      RubyInstaller::Runtime.msys2_installation.mingwarch
    ].join(File::ALT_SEPARATOR)
    recursive_search(gr_lib_name, ENV['GRDIR']).tap do |path|
      RubyInstaller::Runtime.add_dll_directory(File.dirname(path))
    end
  else
    unless ENV['GRDIR']
      warn 'Please set environment variable GRDIR'
      exit 1
    end
    recursive_search(gr_lib_name, ENV['GRDIR'])
  end
end