Module: GRCommons::SearchSharedLibrary
Overview
This module helps GR, GR and GRM to search the shared library.
The order of priority:
-
RubyInstaller ( for Windows only )
-
Environment variable GRDIR
-
pkg-config : github.com/ruby-gnome/pkg-config
The following packages (should) support pkg-config.
-
Linux
-
Red Data Tools github.com/red-data-tools/packages.red-data-tools.org
-
libgr-dev
-
libgr3-dev
-
libgrm-dev
-
-
-
Mac
-
Homebrew github.com/Homebrew/homebrew-core
-
libgr
-
-
-
Windows
-
MinGW github.com/msys2/MINGW-packages
-
mingw-w64-gr
-
-
Instance Method Summary collapse
- #pkg_config_search(gr_lib_name, pkg_name) ⇒ Object
- #recursive_search(name, base_dir) ⇒ Object
-
#search_shared_library(gr_lib_name, pkg_name) ⇒ Object
Search the shared library.
Instance Method Details
#pkg_config_search(gr_lib_name, pkg_name) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/gr_commons/search_shared_library.rb', line 66 def pkg_config_search(gr_lib_name, pkg_name) PKGConfig.variable(pkg_name, 'sopath') rescue PackageConfig::NotFoundError => e raise "#{e.} Cannot find #{gr_lib_name}. " \ "Please Make sure that GR is installed and the environment ” \ ”variable GRDIR is set correctly." end |
#recursive_search(name, base_dir) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gr_commons/search_shared_library.rb', line 55 def recursive_search(name, base_dir) Dir.chdir(base_dir) do path = Dir["**/#{name}"].first # FIXME if path File.(path) else raise "#{name} not found in #{base_dir}" end end end |
#search_shared_library(gr_lib_name, pkg_name) ⇒ Object
Note:
This method does not detect the Operating System.
Search the shared library.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gr_commons/search_shared_library.rb', line 30 def search_shared_library(gr_lib_name, pkg_name) # Windows + RubyInstaller 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 # ENV['GRDIR'] (Linux, Mac, Windows) elsif ENV['GRDIR'] begin recursive_search(gr_lib_name, ENV['GRDIR']) rescue StandardError => e warn "\nWhile searching for #{gr_lib_name} in the directory specified " \ "in the GRDIR environment variable, ENV['GRDIR']=#{ENV['GRDIR']}, " \ "the following error occurred : #{e.}" pkg_config_search(gr_lib_name, pkg_name) end else pkg_config_search(gr_lib_name, pkg_name) end end |