Class: PackageConfig
- Inherits:
-
Object
show all
- Defined in:
- lib/pkg-config.rb
Defined Under Namespace
Classes: Error, NotFoundError
Constant Summary
collapse
- SEPARATOR =
File::PATH_SEPARATOR
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, options = {}) ⇒ PackageConfig
Returns a new instance of PackageConfig.
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
# File 'lib/pkg-config.rb', line 269
def initialize(name, options={})
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 = options
path = @options[:path] || ENV["PKG_CONFIG_PATH"]
@paths = [path, self.class.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.
268
269
270
|
# File 'lib/pkg-config.rb', line 268
def msvc_syntax
@msvc_syntax
end
|
#name ⇒ Object
Returns the value of attribute name.
266
267
268
|
# File 'lib/pkg-config.rb', line 266
def name
@name
end
|
#paths ⇒ Object
Returns the value of attribute paths.
267
268
269
|
# File 'lib/pkg-config.rb', line 267
def paths
@paths
end
|
Class Method Details
57
58
59
60
61
62
|
# File 'lib/pkg-config.rb', line 57
def clear_configure_args_cache
@native_pkg_config = nil
@native_pkg_config_prefix = nil
@default_path = nil
@custom_override_variables = nil
end
|
.custom_override_variables ⇒ Object
53
54
55
|
# File 'lib/pkg-config.rb', line 53
def custom_override_variables
@custom_override_variables ||= with_config("override-variables", "")
end
|
.default_path ⇒ Object
48
49
50
|
# File 'lib/pkg-config.rb', line 48
def default_path
@default_path ||= compute_default_path
end
|
.native_pkg_config ⇒ Object
38
39
40
|
# File 'lib/pkg-config.rb', line 38
def native_pkg_config
@native_pkg_config ||= guess_native_pkg_config
end
|
.native_pkg_config_prefix ⇒ Object
43
44
45
|
# File 'lib/pkg-config.rb', line 43
def native_pkg_config_prefix
@native_pkg_config_prefix ||= compute_native_pkg_config_prefix
end
|
Instance Method Details
#cflags ⇒ Object
304
305
306
307
|
# File 'lib/pkg-config.rb', line 304
def cflags
path_flags, other_flags = collect_cflags
(other_flags + path_flags).join(" ")
end
|
#cflags_only_I ⇒ Object
309
310
311
|
# File 'lib/pkg-config.rb', line 309
def cflags_only_I
collect_cflags[0].join(" ")
end
|
#cflags_only_other ⇒ Object
313
314
315
|
# File 'lib/pkg-config.rb', line 313
def cflags_only_other
collect_cflags[1].join(" ")
end
|
#declaration(name) ⇒ Object
355
356
357
358
|
# File 'lib/pkg-config.rb', line 355
def declaration(name)
parse_pc if @declarations.nil?
expand_value(@declarations[name])
end
|
#description ⇒ Object
346
347
348
|
# File 'lib/pkg-config.rb', line 346
def description
declaration("Description")
end
|
#exist? ⇒ Boolean
292
293
294
|
# File 'lib/pkg-config.rb', line 292
def exist?
not pc_path.nil?
end
|
#libs ⇒ Object
317
318
319
320
|
# File 'lib/pkg-config.rb', line 317
def libs
path_flags, other_flags = collect_libs
(path_flags + other_flags).join(" ")
end
|
#libs_only_l ⇒ Object
322
323
324
325
326
327
328
329
330
|
# File 'lib/pkg-config.rb', line 322
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
332
333
334
335
336
337
338
339
340
|
# File 'lib/pkg-config.rb', line 332
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
# File 'lib/pkg-config.rb', line 360
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
296
297
298
|
# File 'lib/pkg-config.rb', line 296
def requires
parse_requires(declaration("Requires"))
end
|
#requires_private ⇒ Object
300
301
302
|
# File 'lib/pkg-config.rb', line 300
def requires_private
parse_requires(declaration("Requires.private"))
end
|
#variable(name) ⇒ Object
350
351
352
353
|
# File 'lib/pkg-config.rb', line 350
def variable(name)
parse_pc if @variables.nil?
expand_value(@override_variables[name] || @variables[name])
end
|
#version ⇒ Object
342
343
344
|
# File 'lib/pkg-config.rb', line 342
def version
declaration("Version")
end
|