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.
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
# File 'lib/pkg-config.rb', line 388
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
@paths = [
@options[: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.
387
388
389
|
# File 'lib/pkg-config.rb', line 387
def msvc_syntax
@msvc_syntax
end
|
#name ⇒ Object
Returns the value of attribute name.
385
386
387
|
# File 'lib/pkg-config.rb', line 385
def name
@name
end
|
#paths ⇒ Object
Returns the value of attribute paths.
386
387
388
|
# File 'lib/pkg-config.rb', line 386
def paths
@paths
end
|
Class Method Details
168
169
170
171
172
173
|
# File 'lib/pkg-config.rb', line 168
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
164
165
166
|
# File 'lib/pkg-config.rb', line 164
def custom_override_variables
@custom_override_variables ||= with_config("override-variables", "")
end
|
.default_path ⇒ Object
159
160
161
|
# File 'lib/pkg-config.rb', line 159
def default_path
@default_path ||= compute_default_path
end
|
.native_pkg_config ⇒ Object
149
150
151
|
# File 'lib/pkg-config.rb', line 149
def native_pkg_config
@native_pkg_config ||= guess_native_pkg_config
end
|
.native_pkg_config_prefix ⇒ Object
154
155
156
|
# File 'lib/pkg-config.rb', line 154
def native_pkg_config_prefix
@native_pkg_config_prefix ||= compute_native_pkg_config_prefix
end
|
Instance Method Details
#cflags ⇒ Object
433
434
435
436
|
# File 'lib/pkg-config.rb', line 433
def cflags
path_flags, other_flags = collect_cflags
(path_flags + other_flags).join(" ")
end
|
#cflags_only_I ⇒ Object
438
439
440
|
# File 'lib/pkg-config.rb', line 438
def cflags_only_I
collect_cflags[0].join(" ")
end
|
#cflags_only_other ⇒ Object
442
443
444
|
# File 'lib/pkg-config.rb', line 442
def cflags_only_other
collect_cflags[1].join(" ")
end
|
#declaration(name) ⇒ Object
483
484
485
486
|
# File 'lib/pkg-config.rb', line 483
def declaration(name)
parse_pc if @declarations.nil?
expand_value(@declarations[name])
end
|
#description ⇒ Object
474
475
476
|
# File 'lib/pkg-config.rb', line 474
def description
declaration("Description")
end
|
#eql?(other) ⇒ Boolean
413
414
415
|
# File 'lib/pkg-config.rb', line 413
def eql?(other)
other.is_a?(self.class) and @name == other.name
end
|
#exist? ⇒ Boolean
421
422
423
|
# File 'lib/pkg-config.rb', line 421
def exist?
not pc_path.nil?
end
|
#hash ⇒ Object
417
418
419
|
# File 'lib/pkg-config.rb', line 417
def hash
@name.hash
end
|
#libs ⇒ Object
446
447
448
|
# File 'lib/pkg-config.rb', line 446
def libs
collect_libs.join(" ")
end
|
#libs_only_l ⇒ Object
450
451
452
453
454
455
456
457
458
|
# File 'lib/pkg-config.rb', line 450
def libs_only_l
collect_libs.find_all do |arg|
if @msvc_syntax
arg.end_with?(".lib")
else
arg.start_with?("-l")
end
end.join(" ")
end
|
#libs_only_L ⇒ Object
460
461
462
463
464
465
466
467
468
|
# File 'lib/pkg-config.rb', line 460
def libs_only_L
collect_libs.find_all do |arg|
if @msvc_syntax
arg.start_with?("/libpath:")
else
arg.start_with?("-L")
end
end.join(" ")
end
|
#pc_path ⇒ Object
488
489
490
491
492
493
494
495
496
497
498
499
500
501
|
# File 'lib/pkg-config.rb', line 488
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
425
426
427
|
# File 'lib/pkg-config.rb', line 425
def requires
parse_requires(declaration("Requires"))
end
|
#requires_private ⇒ Object
429
430
431
|
# File 'lib/pkg-config.rb', line 429
def requires_private
parse_requires(declaration("Requires.private"))
end
|
#variable(name) ⇒ Object
478
479
480
481
|
# File 'lib/pkg-config.rb', line 478
def variable(name)
parse_pc if @variables.nil?
expand_value(@override_variables[name] || @variables[name])
end
|
#version ⇒ Object
470
471
472
|
# File 'lib/pkg-config.rb', line 470
def version
declaration("Version")
end
|