Module: PKGConfig
- Defined in:
- lib/pkg-config/version.rb,
lib/pkg-config.rb
Overview
Copyright 2012-2020 Sutou Kouhei <[email protected]>
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Constant Summary collapse
- VERSION =
"1.4.2"
- @@paths =
[]
- @@override_variables =
{}
Class Method Summary collapse
- .add_path(path) ⇒ Object
- .cflags(pkg) ⇒ Object
- .cflags_only_I(pkg) ⇒ Object
- .cflags_only_other(pkg) ⇒ Object
- .check_version?(pkg, major = 0, minor = 0, micro = 0) ⇒ Boolean
- .description(pkg) ⇒ Object
- .exist?(pkg) ⇒ Boolean
- .have_package(pkg, major = nil, minor = 0, micro = 0) ⇒ Object
- .libs(pkg) ⇒ Object
- .libs_only_l(pkg) ⇒ Object
- .libs_only_L(pkg) ⇒ Object
- .modversion(pkg) ⇒ Object
- .msvc? ⇒ Boolean
- .package_config(package) ⇒ Object
- .set_override_variable(key, value) ⇒ Object
- .variable(pkg, name) ⇒ Object
Class Method Details
.add_path(path) ⇒ Object
514 515 516 |
# File 'lib/pkg-config.rb', line 514 def add_path(path) @@paths << path end |
.cflags(pkg) ⇒ Object
549 550 551 |
# File 'lib/pkg-config.rb', line 549 def cflags(pkg) package_config(pkg).cflags end |
.cflags_only_I(pkg) ⇒ Object
553 554 555 |
# File 'lib/pkg-config.rb', line 553 def cflags_only_I(pkg) package_config(pkg).cflags_only_I end |
.cflags_only_other(pkg) ⇒ Object
557 558 559 |
# File 'lib/pkg-config.rb', line 557 def cflags_only_other(pkg) package_config(pkg).cflags_only_other end |
.check_version?(pkg, major = 0, minor = 0, micro = 0) ⇒ Boolean
573 574 575 576 577 578 579 580 581 582 |
# File 'lib/pkg-config.rb', line 573 def check_version?(pkg, major=0, minor=0, micro=0) return false unless exist?(pkg) ver = modversion(pkg).split(".").collect {|item| item.to_i} (0..2).each {|i| ver[i] = 0 unless ver[i]} (ver[0] > major || (ver[0] == major && ver[1] > minor) || (ver[0] == major && ver[1] == minor && ver[2] >= micro)) end |
.description(pkg) ⇒ Object
565 566 567 |
# File 'lib/pkg-config.rb', line 565 def description(pkg) package_config(pkg).description end |
.exist?(pkg) ⇒ Boolean
533 534 535 |
# File 'lib/pkg-config.rb', line 533 def exist?(pkg) package_config(pkg).exist? end |
.have_package(pkg, major = nil, minor = 0, micro = 0) ⇒ Object
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File 'lib/pkg-config.rb', line 584 def have_package(pkg, major=nil, minor=0, micro=0) = "#{pkg}" unless major.nil? << " version (>= #{major}.#{minor}.#{micro})" end major ||= 0 enough_version = checking_for(()) do check_version?(pkg, major, minor, micro) end if enough_version libraries = libs_only_l(pkg) dldflags = libs(pkg) dldflags = (Shellwords.shellwords(dldflags) - Shellwords.shellwords(libraries)) dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(" ") $libs += " " + libraries if /mswin/ =~ RUBY_PLATFORM $DLDFLAGS += " " + dldflags else $LDFLAGS += " " + dldflags end $CFLAGS += " " + cflags_only_other(pkg) if defined?($CXXFLAGS) $CXXFLAGS += " " + cflags_only_other(pkg) end $INCFLAGS += " " + cflags_only_I(pkg) end enough_version end |
.libs(pkg) ⇒ Object
537 538 539 |
# File 'lib/pkg-config.rb', line 537 def libs(pkg) package_config(pkg).libs end |
.libs_only_l(pkg) ⇒ Object
541 542 543 |
# File 'lib/pkg-config.rb', line 541 def libs_only_l(pkg) package_config(pkg).libs_only_l end |
.libs_only_L(pkg) ⇒ Object
545 546 547 |
# File 'lib/pkg-config.rb', line 545 def libs_only_L(pkg) package_config(pkg).libs_only_L end |
.modversion(pkg) ⇒ Object
561 562 563 |
# File 'lib/pkg-config.rb', line 561 def modversion(pkg) package_config(pkg).version end |
.msvc? ⇒ Boolean
522 523 524 |
# File 'lib/pkg-config.rb', line 522 def msvc? /mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG["CC"]) end |
.package_config(package) ⇒ Object
526 527 528 529 530 531 |
# File 'lib/pkg-config.rb', line 526 def package_config(package) PackageConfig.new(package, :msvc_syntax => msvc?, :override_variables => @@override_variables, :paths => @@paths) end |
.set_override_variable(key, value) ⇒ Object
518 519 520 |
# File 'lib/pkg-config.rb', line 518 def set_override_variable(key, value) @@override_variables[key] = value end |
.variable(pkg, name) ⇒ Object
569 570 571 |
# File 'lib/pkg-config.rb', line 569 def variable(pkg, name) package_config(pkg).variable(name) end |