Class: Magica::PackageConfig
Constant Summary collapse
- LIBRARY_PATH_RULE =
/-L([^\s]+)/
- LIBRARY_RULE =
/-l([^\s]+)/
- LIBRARY_FLAG_RULE =
/-[^lL][^\s]+/
- INCLUDE_RULE =
/-I([^\s]+)/
- DEFINE_RULE =
/-D([^\s]+)/
- FLAG_RULE =
/-[^ID][^\s]+/
Instance Attribute Summary collapse
-
#defines ⇒ Object
readonly
Returns the value of attribute defines.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#include_paths ⇒ Object
readonly
Returns the value of attribute include_paths.
-
#libraries ⇒ Object
readonly
Returns the value of attribute libraries.
-
#library_flags ⇒ Object
readonly
Returns the value of attribute library_flags.
-
#library_paths ⇒ Object
readonly
Returns the value of attribute library_paths.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ PackageConfig
constructor
A new instance of PackageConfig.
Constructor Details
#initialize(name) ⇒ PackageConfig
Returns a new instance of PackageConfig.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/magica/package_config.rb', line 21 def initialize(name) fail "Cannot found library #{name}" unless system "pkg-config --exists #{name}" @package_libraries = `pkg-config --libs #{name}`.strip @library_paths = @package_libraries.scan(LIBRARY_PATH_RULE).flatten @libraries = @package_libraries.scan(LIBRARY_RULE).flatten @library_flags = @package_libraries.scan(LIBRARY_FLAG_RULE).flatten @package_cflags = `pkg-config --cflags #{name}`.strip @include_paths = @package_cflags.scan(INCLUDE_RULE).flatten @defines = @package_cflags.scan(DEFINE_RULE).flatten @flags = @package_cflags.scan(FLAG_RULE).flatten @version = `pkg-config --modversion #{name}`.strip end |
Instance Attribute Details
#defines ⇒ Object (readonly)
Returns the value of attribute defines.
19 20 21 |
# File 'lib/magica/package_config.rb', line 19 def defines @defines end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
19 20 21 |
# File 'lib/magica/package_config.rb', line 19 def flags @flags end |
#include_paths ⇒ Object (readonly)
Returns the value of attribute include_paths.
19 20 21 |
# File 'lib/magica/package_config.rb', line 19 def include_paths @include_paths end |
#libraries ⇒ Object (readonly)
Returns the value of attribute libraries.
19 20 21 |
# File 'lib/magica/package_config.rb', line 19 def libraries @libraries end |
#library_flags ⇒ Object (readonly)
Returns the value of attribute library_flags.
19 20 21 |
# File 'lib/magica/package_config.rb', line 19 def library_flags @library_flags end |
#library_paths ⇒ Object (readonly)
Returns the value of attribute library_paths.
19 20 21 |
# File 'lib/magica/package_config.rb', line 19 def library_paths @library_paths end |
Class Method Details
.[](name) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/magica/package_config.rb', line 4 def [](name) @packages ||= {} config = @packages[name.to_s] config = @packages[name.to_s] = PackageConfig.new(name) if config.nil? config end |