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 = " Unable to run `pkg-config \#{pkg}`.\n\n Check that PKG_CONFIG_PATH includes \#{pkg}.pc (or unset it if it's already set).\n\n Current environment:\n PKG_CONFIG_PATH=\#{ENV['PKG_CONFIG_PATH']}\n MSG\n\n raise message\n end\n end\n\n # First, find all the -l<lib> flags added by pkg-config. We want to drop\n # these dynamically linked libraries and substitute them with the static libraries.\n libflags = packages.map do |pkg|\n pkg_config(pkg, 'libs-only-l')&.strip&.split(' ')\n end.flatten.uniq\n\n # To find where the static libraries live, we need to search the\n # library paths given by the -L flag from pkg-config.\n lib_paths = packages.map do |pkg|\n include_path = pkg_config(pkg, 'libs-only-L')&.strip\n include_path&.split(' ')&.map { |lib| lib.gsub(/^-L/, '') }\n end.flatten.uniq\n\n # Drop the -l<lib> flags and add in the static libraries.\n new_libs = $libs.shellsplit\n new_libs.reject! { |arg| libflags.include?(arg) }\n libflags.each { |flag| new_libs << resolve_static_library(flag, lib_paths) }\n $libs = new_libs.uniq.shelljoin\nend\n"
|