Class: PackageConfig
- Inherits:
-
Object
- Object
- PackageConfig
- Defined in:
- lib/pkg-config.rb
Constant Summary collapse
- SEPARATOR =
File::PATH_SEPARATOR
Instance Attribute Summary collapse
-
#msvc_syntax ⇒ Object
Returns the value of attribute msvc_syntax.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Class Method Summary collapse
- .clear_configure_args_cache ⇒ Object
- .custom_override_variables ⇒ Object
- .native_pkg_config ⇒ Object
- .native_pkg_config_prefix ⇒ Object
Instance Method Summary collapse
- #cflags ⇒ Object
- #cflags_only_I ⇒ Object
- #cflags_only_other ⇒ Object
- #declaration(name) ⇒ Object
- #description ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(name, options = {}) ⇒ PackageConfig
constructor
A new instance of PackageConfig.
- #libs ⇒ Object
- #libs_only_l ⇒ Object
- #libs_only_L ⇒ Object
- #pc_path ⇒ Object
- #requires ⇒ Object
- #requires_private ⇒ Object
- #variable(name) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ PackageConfig
Returns a new instance of PackageConfig.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/pkg-config.rb', line 140 def initialize(name, ={}) if Pathname(name).absolute? @pc_path = name @path_position = 0 @name = File.basename(@pc_path, ".*") else @pc_path = nil @path_position = nil @name = name end @options = path = @options[:path] || ENV["PKG_CONFIG_PATH"] @paths = [path, guess_default_path].compact.join(SEPARATOR).split(SEPARATOR) @paths.unshift(*(@options[:paths] || [])) @paths = normalize_paths(@paths) @msvc_syntax = @options[:msvc_syntax] @variables = @declarations = nil override_variables = self.class.custom_override_variables @override_variables = parse_override_variables(override_variables) default_override_variables = @options[:override_variables] || {} @override_variables = default_override_variables.merge(@override_variables) end |
Instance Attribute Details
#msvc_syntax ⇒ Object
Returns the value of attribute msvc_syntax.
139 140 141 |
# File 'lib/pkg-config.rb', line 139 def msvc_syntax @msvc_syntax end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
137 138 139 |
# File 'lib/pkg-config.rb', line 137 def name @name end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
138 139 140 |
# File 'lib/pkg-config.rb', line 138 def paths @paths end |
Class Method Details
.clear_configure_args_cache ⇒ Object
46 47 48 49 50 |
# File 'lib/pkg-config.rb', line 46 def clear_configure_args_cache @native_pkg_config = nil @native_pkg_config_prefix = nil @custom_override_variables = nil end |
.custom_override_variables ⇒ Object
42 43 44 |
# File 'lib/pkg-config.rb', line 42 def custom_override_variables @custom_override_variables ||= with_config("override-variables", "") end |
.native_pkg_config ⇒ Object
32 33 34 |
# File 'lib/pkg-config.rb', line 32 def native_pkg_config @native_pkg_config ||= guess_native_pkg_config end |
.native_pkg_config_prefix ⇒ Object
37 38 39 |
# File 'lib/pkg-config.rb', line 37 def native_pkg_config_prefix @native_pkg_config_prefix ||= compute_native_pkg_config_prefix end |
Instance Method Details
#cflags ⇒ Object
175 176 177 178 |
# File 'lib/pkg-config.rb', line 175 def cflags path_flags, other_flags = collect_cflags (other_flags + path_flags).join(" ") end |
#cflags_only_I ⇒ Object
180 181 182 |
# File 'lib/pkg-config.rb', line 180 def cflags_only_I collect_cflags[0].join(" ") end |
#cflags_only_other ⇒ Object
184 185 186 |
# File 'lib/pkg-config.rb', line 184 def cflags_only_other collect_cflags[1].join(" ") end |
#declaration(name) ⇒ Object
226 227 228 229 |
# File 'lib/pkg-config.rb', line 226 def declaration(name) parse_pc if @declarations.nil? (@declarations[name]) end |
#description ⇒ Object
217 218 219 |
# File 'lib/pkg-config.rb', line 217 def description declaration("Description") end |
#exist? ⇒ Boolean
163 164 165 |
# File 'lib/pkg-config.rb', line 163 def exist? not pc_path.nil? end |
#libs ⇒ Object
188 189 190 191 |
# File 'lib/pkg-config.rb', line 188 def libs path_flags, other_flags = collect_libs (path_flags + other_flags).join(" ") end |
#libs_only_l ⇒ Object
193 194 195 196 197 198 199 200 201 |
# File 'lib/pkg-config.rb', line 193 def libs_only_l collect_libs[1].find_all do |arg| if @msvc_syntax /\.lib\z/ =~ arg else /\A-l/ =~ arg end end.join(" ") end |
#libs_only_L ⇒ Object
203 204 205 206 207 208 209 210 211 |
# File 'lib/pkg-config.rb', line 203 def libs_only_L collect_libs[0].find_all do |arg| if @msvc_syntax /\A\/libpath:/ =~ arg else /\A-L/ =~ arg end end.join(" ") end |
#pc_path ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/pkg-config.rb', line 231 def pc_path if @pc_path return @pc_path if File.exist?(@pc_path) else @paths.each_with_index do |path, i| _pc_path = File.join(path, "#{@name}.pc") if File.exist?(_pc_path) @path_position = i + 1 return _pc_path end end end nil end |
#requires ⇒ Object
167 168 169 |
# File 'lib/pkg-config.rb', line 167 def requires parse_requires(declaration("Requires")) end |
#requires_private ⇒ Object
171 172 173 |
# File 'lib/pkg-config.rb', line 171 def requires_private parse_requires(declaration("Requires.private")) end |
#variable(name) ⇒ Object
221 222 223 224 |
# File 'lib/pkg-config.rb', line 221 def variable(name) parse_pc if @variables.nil? (@override_variables[name] || @variables[name]) end |
#version ⇒ Object
213 214 215 |
# File 'lib/pkg-config.rb', line 213 def version declaration("Version") end |