зеркало из https://github.com/github/ruby.git
mkmf.rb: Refine message from `pkg_config`
This commit is contained in:
Родитель
0d7bbfc941
Коммит
29dc9378d9
123
lib/mkmf.rb
123
lib/mkmf.rb
|
@ -1849,66 +1849,73 @@ SRC
|
|||
# invoked with the options and a stripped output string is returned without
|
||||
# modifying any of the global values mentioned above.
|
||||
def pkg_config(pkg, *options)
|
||||
_, ldir = dir_config(pkg)
|
||||
if ldir
|
||||
pkg_config_path = "#{ldir}/pkgconfig"
|
||||
if File.directory?(pkg_config_path)
|
||||
Logging.message("PKG_CONFIG_PATH = %s\n", pkg_config_path)
|
||||
envs = ["PKG_CONFIG_PATH"=>[pkg_config_path, ENV["PKG_CONFIG_PATH"]].compact.join(File::PATH_SEPARATOR)]
|
||||
end
|
||||
fmt = "not found"
|
||||
def fmt.%(x)
|
||||
x ? x.inspect : self
|
||||
end
|
||||
if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
|
||||
# if and only if package specific config command is given
|
||||
elsif ($PKGCONFIG ||=
|
||||
(pkgconfig = with_config("pkg-config") {config_string("PKG_CONFIG") || "pkg-config"}) &&
|
||||
find_executable0(pkgconfig) && pkgconfig) and
|
||||
xsystem([*envs, $PKGCONFIG, "--exists", pkg])
|
||||
# default to pkg-config command
|
||||
pkgconfig = $PKGCONFIG
|
||||
args = [pkg]
|
||||
elsif find_executable0(pkgconfig = "#{pkg}-config")
|
||||
# default to package specific config command, as a last resort.
|
||||
else
|
||||
pkgconfig = nil
|
||||
end
|
||||
if pkgconfig
|
||||
get = proc {|opts|
|
||||
opts = Array(opts).map { |o| "--#{o}" }
|
||||
opts = xpopen([*envs, pkgconfig, *opts, *args], err:[:child, :out], &:read)
|
||||
Logging.open {puts opts.each_line.map{|s|"=> #{s.inspect}"}}
|
||||
opts.strip if $?.success?
|
||||
}
|
||||
end
|
||||
orig_ldflags = $LDFLAGS
|
||||
if get and !options.empty?
|
||||
get[options]
|
||||
elsif get and try_ldflags(ldflags = get['libs'])
|
||||
if incflags = get['cflags-only-I']
|
||||
$INCFLAGS << " " << incflags
|
||||
cflags = get['cflags-only-other']
|
||||
else
|
||||
cflags = get['cflags']
|
||||
end
|
||||
libs = get['libs-only-l']
|
||||
if cflags
|
||||
$CFLAGS += " " << cflags
|
||||
$CXXFLAGS += " " << cflags
|
||||
end
|
||||
if libs
|
||||
ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ")
|
||||
else
|
||||
libs, ldflags = Shellwords.shellwords(ldflags).partition {|s| s =~ /-l([^ ]+)/ }.map {|l|l.quote.join(" ")}
|
||||
end
|
||||
$libs += " " << libs
|
||||
|
||||
$LDFLAGS = [orig_ldflags, ldflags].join(' ')
|
||||
Logging::message "package configuration for %s\n", pkg
|
||||
Logging::message "incflags: %s\ncflags: %s\nldflags: %s\nlibs: %s\n\n",
|
||||
incflags, cflags, ldflags, libs
|
||||
[[incflags, cflags].join(' '), ldflags, libs]
|
||||
else
|
||||
Logging::message "package configuration for %s is not found\n", pkg
|
||||
nil
|
||||
checking_for "pkg-config for #{pkg}", fmt do
|
||||
_, ldir = dir_config(pkg)
|
||||
if ldir
|
||||
pkg_config_path = "#{ldir}/pkgconfig"
|
||||
if File.directory?(pkg_config_path)
|
||||
Logging.message("PKG_CONFIG_PATH = %s\n", pkg_config_path)
|
||||
envs = ["PKG_CONFIG_PATH"=>[pkg_config_path, ENV["PKG_CONFIG_PATH"]].compact.join(File::PATH_SEPARATOR)]
|
||||
end
|
||||
end
|
||||
if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
|
||||
# if and only if package specific config command is given
|
||||
elsif ($PKGCONFIG ||=
|
||||
(pkgconfig = with_config("pkg-config") {config_string("PKG_CONFIG") || "pkg-config"}) &&
|
||||
find_executable0(pkgconfig) && pkgconfig) and
|
||||
xsystem([*envs, $PKGCONFIG, "--exists", pkg])
|
||||
# default to pkg-config command
|
||||
pkgconfig = $PKGCONFIG
|
||||
args = [pkg]
|
||||
elsif find_executable0(pkgconfig = "#{pkg}-config")
|
||||
# default to package specific config command, as a last resort.
|
||||
else
|
||||
pkgconfig = nil
|
||||
end
|
||||
if pkgconfig
|
||||
get = proc {|opts|
|
||||
opts = Array(opts).map { |o| "--#{o}" }
|
||||
opts = xpopen([*envs, pkgconfig, *opts, *args], err:[:child, :out], &:read)
|
||||
Logging.open {puts opts.each_line.map{|s|"=> #{s.inspect}"}}
|
||||
opts.strip if $?.success?
|
||||
}
|
||||
end
|
||||
orig_ldflags = $LDFLAGS
|
||||
if get and !options.empty?
|
||||
get[options]
|
||||
elsif get and try_ldflags(ldflags = get['libs'])
|
||||
if incflags = get['cflags-only-I']
|
||||
$INCFLAGS << " " << incflags
|
||||
cflags = get['cflags-only-other']
|
||||
else
|
||||
cflags = get['cflags']
|
||||
end
|
||||
libs = get['libs-only-l']
|
||||
if cflags
|
||||
$CFLAGS += " " << cflags
|
||||
$CXXFLAGS += " " << cflags
|
||||
end
|
||||
if libs
|
||||
ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ")
|
||||
else
|
||||
libs, ldflags = Shellwords.shellwords(ldflags).partition {|s| s =~ /-l([^ ]+)/ }.map {|l|l.quote.join(" ")}
|
||||
end
|
||||
$libs += " " << libs
|
||||
|
||||
$LDFLAGS = [orig_ldflags, ldflags].join(' ')
|
||||
Logging::message "package configuration for %s\n", pkg
|
||||
Logging::message "incflags: %s\ncflags: %s\nldflags: %s\nlibs: %s\n\n",
|
||||
incflags, cflags, ldflags, libs
|
||||
[[incflags, cflags].join(' '), ldflags, libs]
|
||||
else
|
||||
Logging::message "package configuration for %s is not found\n", pkg
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче