Top Level Namespace
Defined Under Namespace
Modules: CharlockHolmes
Classes: String
Instance Method Summary
collapse
Instance Method Details
#libflag_to_filename(ldflag) ⇒ Object
78
79
80
81
82
83
|
# File 'ext/charlock_holmes/extconf.rb', line 78
def libflag_to_filename(ldflag)
case ldflag
when /\A-l(.+)/
"lib#{Regexp.last_match(1)}.#{$LIBEXT}"
end
end
|
#resolve_static_library(libflag, dirs) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'ext/charlock_holmes/extconf.rb', line 85
def resolve_static_library(libflag, dirs)
filename = libflag_to_filename(libflag)
dir = dirs.find { |path| File.exist?(File.join(path, filename)) }
raise "Unable to find #{filename} in #{dirs}" unless dir
File.join(dir, filename)
end
|
#substitute_static_libs(packages) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'ext/charlock_holmes/extconf.rb', line 95
def substitute_static_libs(packages)
packages.each do |pkg|
unless pkg_config(pkg)
message = <<~MSG
Unable to run `pkg-config #{pkg}`.
Check that PKG_CONFIG_PATH includes #{pkg}.pc (or unset it if it's already set).
Current environment:
PKG_CONFIG_PATH=#{ENV['PKG_CONFIG_PATH']}
MSG
raise message
end
end
libflags = packages.map do |pkg|
pkg_config(pkg, 'libs-only-l')&.strip&.split(' ')
end.flatten.uniq
lib_paths = packages.map do |pkg|
include_path = pkg_config(pkg, 'libs-only-L')&.strip
include_path&.split(' ')&.map { |lib| lib.gsub(/^-L/, '') }
end.flatten.uniq
new_libs = $libs.shellsplit
new_libs.reject! { |arg| libflags.include?(arg) }
libflags.each { |flag| new_libs << resolve_static_library(flag, lib_paths) }
$libs = new_libs.uniq.shelljoin
end
|