mirror of
https://github.com/openbsd/src.git
synced 2026-04-26 23:26:11 +00:00
cosmetic changes to conform to style of other existing OpenBSD code.
Okay jasper@
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: PkgConfig.pm,v 1.7 2018/05/18 17:01:57 espie Exp $
|
||||
# $OpenBSD: PkgConfig.pm,v 1.8 2019/12/08 14:22:14 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2006 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@@ -67,11 +67,11 @@ sub new
|
||||
sub add_variable
|
||||
{
|
||||
my ($self, $name, $value) = @_;
|
||||
if (defined $self->{variables}->{$name}) {
|
||||
if (defined $self->{variables}{$name}) {
|
||||
die "Duplicate variable $name";
|
||||
}
|
||||
push(@{$self->{vlist}}, $name);
|
||||
$self->{variables}->{$name} = ($value =~ s/^\"|\"$//rg);
|
||||
$self->{variables}{$name} = ($value =~ s/^\"|\"$//rg);
|
||||
}
|
||||
|
||||
sub parse_value
|
||||
@@ -87,7 +87,7 @@ sub parse_value
|
||||
sub add_property
|
||||
{
|
||||
my ($self, $name, $value) = @_;
|
||||
if (defined $self->{properties}->{$name}) {
|
||||
if (defined $self->{properties}{$name}) {
|
||||
die "Duplicate property $name";
|
||||
}
|
||||
push(@{$self->{proplist}}, $name);
|
||||
@@ -97,16 +97,15 @@ sub add_property
|
||||
} else {
|
||||
$v = [];
|
||||
}
|
||||
$self->{properties}->{$name} = $v;
|
||||
$self->{properties}{$name} = $v;
|
||||
}
|
||||
|
||||
sub read_fh
|
||||
{
|
||||
my ($class, $fh, $name) = @_;
|
||||
my $cfg = $class->new;
|
||||
#my $_;
|
||||
|
||||
$name = '' if !defined $name;
|
||||
$name //= '';
|
||||
while (<$fh>) {
|
||||
chomp;
|
||||
# continuation lines
|
||||
@@ -129,9 +128,9 @@ sub read_fh
|
||||
die "Incorrect cfg file $name";
|
||||
}
|
||||
}
|
||||
if (defined $cfg->{properties}->{Libs}) {
|
||||
$cfg->{properties}->{Libs} =
|
||||
$cfg->compress_list($cfg->{properties}->{Libs});
|
||||
if (defined $cfg->{properties}{Libs}) {
|
||||
$cfg->{properties}{Libs} =
|
||||
$cfg->compress_list($cfg->{properties}{Libs});
|
||||
}
|
||||
return $cfg;
|
||||
}
|
||||
@@ -149,11 +148,11 @@ sub write_fh
|
||||
my ($self, $fh) = @_;
|
||||
|
||||
foreach my $variable (@{$self->{vlist}}) {
|
||||
print $fh "$variable=", $self->{variables}->{$variable}, "\n";
|
||||
print $fh "$variable=", $self->{variables}{$variable}, "\n";
|
||||
}
|
||||
print $fh "\n\n";
|
||||
foreach my $property (@{$self->{proplist}}) {
|
||||
my $p = $self->{properties}->{$property};
|
||||
my $p = $self->{properties}{$property};
|
||||
print $fh "$property:";
|
||||
if (defined $write->{$property}) {
|
||||
print $fh $write->{$property}($p);
|
||||
@@ -212,8 +211,8 @@ sub expanded
|
||||
} else {
|
||||
return $extra->{$var};
|
||||
}
|
||||
} elsif (defined $self->{variables}->{$var}) {
|
||||
return $self->{variables}->{$var};
|
||||
} elsif (defined $self->{variables}{$var}) {
|
||||
return $self->{variables}{$var};
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@@ -235,7 +234,7 @@ sub get_property
|
||||
{
|
||||
my ($self, $k, $extra) = @_;
|
||||
|
||||
my $l = $self->{properties}->{$k};
|
||||
my $l = $self->{properties}{$k};
|
||||
if (!defined $l) {
|
||||
return undef;
|
||||
}
|
||||
@@ -257,7 +256,7 @@ sub get_variable
|
||||
{
|
||||
my ($self, $k, $extra) = @_;
|
||||
|
||||
my $v = $self->{variables}->{$k};
|
||||
my $v = $self->{variables}{$k};
|
||||
if (defined $v) {
|
||||
return $self->expanded($v, $extra);
|
||||
} else {
|
||||
@@ -274,14 +273,14 @@ sub add_bases
|
||||
|
||||
while (my ($k, $v) = each %$extra) {
|
||||
for my $name (keys %{$self->{variables}}) {
|
||||
$self->{variables}->{$name} =~ s/\Q$v\E\b/\$\{\Q$k\E\}/g;
|
||||
$self->{variables}{$name} =~ s/\Q$v\E\b/\$\{\Q$k\E\}/g;
|
||||
}
|
||||
for my $name (keys %{$self->{properties}}) {
|
||||
for my $e (@{$self->{properties}->{$name}}) {
|
||||
for my $e (@{$self->{properties}{$name}}) {
|
||||
$e =~ s/\Q$v\E\b/\$\{\Q$k\E\}/g;
|
||||
}
|
||||
}
|
||||
$self->{variables}->{$k} = $v;
|
||||
$self->{variables}{$k} = $v;
|
||||
unshift(@{$self->{vlist}}, $k);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
# $OpenBSD: pkg-config,v 1.92 2019/02/04 20:18:11 jasper Exp $
|
||||
# $OpenBSD: pkg-config,v 1.93 2019/12/08 14:22:14 espie Exp $
|
||||
# $CSK: pkgconfig.pl,v 1.39 2006/11/27 16:26:20 ckuethe Exp $
|
||||
|
||||
# Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org>
|
||||
@@ -165,7 +165,8 @@ if (!@ARGV){
|
||||
|
||||
# Return the next module from @ARGV, if it turns out to be a comma separated
|
||||
# module list, take the first one and put the rest back to the front.
|
||||
sub get_next_module {
|
||||
sub get_next_module
|
||||
{
|
||||
my $module = shift @ARGV;
|
||||
my $m;
|
||||
if ($module =~ m/,/) {
|
||||
@@ -288,34 +289,34 @@ sub handle_config
|
||||
}
|
||||
|
||||
my $get_props = sub {
|
||||
my $property = shift;
|
||||
my $pkg;
|
||||
my $property = shift;
|
||||
my $pkg;
|
||||
|
||||
# See if there's anyting in the environment that we need to take into account.
|
||||
($pkg = $p) =~ s/(^.*\/)?(.*?)\.pc$/$2/g;
|
||||
$pkg = uc($pkg);
|
||||
# See if there's anything in the environment that we need to
|
||||
# take into account.
|
||||
($pkg = $p) =~ s/(^.*\/)?(.*?)\.pc$/$2/g;
|
||||
$pkg = uc($pkg);
|
||||
|
||||
if (grep {/PKG_CONFIG_${pkg}.*/} keys %ENV) {
|
||||
# Now that we know we have something to look for, do the inefficient
|
||||
# iteration.
|
||||
while (my ($k, $v) = each %ENV) {
|
||||
if ($k =~ /^PKG_CONFIG_${pkg}_(\w+)/) {
|
||||
$variables->{lc($1)} = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (grep {/PKG_CONFIG_${pkg}.*/} keys %ENV) {
|
||||
# Now that we know we have something to look for, do
|
||||
# the inefficient iteration.
|
||||
while (my ($k, $v) = each %ENV) {
|
||||
if ($k =~ /^PKG_CONFIG_${pkg}_(\w+)/) {
|
||||
$variables->{lc($1)} = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $deps = $cfg->get_property($property, $variables);
|
||||
if (defined $deps) {
|
||||
for my $dep (@$deps) {
|
||||
if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+|[\d\.]+[\w]*[\d]+)$/) {
|
||||
handle_config($1, $2, $3, $list);
|
||||
} else {
|
||||
handle_config($dep, undef, undef, $list);
|
||||
}
|
||||
}
|
||||
say_debug("package $p " . lc($property) . " " . join(',', @$deps));
|
||||
}
|
||||
my $deps = $cfg->get_property($property, $variables);
|
||||
return unless defined $deps;
|
||||
for my $dep (@$deps) {
|
||||
if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+|[\d\.]+[\w]*[\d]+)$/) {
|
||||
handle_config($1, $2, $3, $list);
|
||||
} else {
|
||||
handle_config($dep, undef, undef, $list);
|
||||
}
|
||||
}
|
||||
say_debug("package $p " . lc($property) . " " . join(',', @$deps));
|
||||
};
|
||||
|
||||
if (defined $mode{cflags}
|
||||
@@ -328,7 +329,6 @@ sub handle_config
|
||||
unless (defined $mode{validate}) {
|
||||
&$get_props("Requires");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# look for the .pc file in each of the PKGPATH elements. Return the path or
|
||||
@@ -338,7 +338,7 @@ sub pathresolve
|
||||
my ($p) = @_;
|
||||
|
||||
if ($allow_uninstalled && $p !~ m/\-uninstalled$/) {
|
||||
foreach my $d (@PKGPATH) {
|
||||
for my $d (@PKGPATH) {
|
||||
my $f = "$d/$p-uninstalled.pc";
|
||||
say_debug("pathresolve($p) looking in $f");
|
||||
if (-f $f) {
|
||||
@@ -348,7 +348,7 @@ sub pathresolve
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $d (@PKGPATH) {
|
||||
for my $d (@PKGPATH) {
|
||||
my $f = "$d/$p.pc";
|
||||
say_debug("pathresolve($p) looking in $f");
|
||||
return $f if -f $f;
|
||||
@@ -397,11 +397,11 @@ sub validate_config
|
||||
say_error("Package file '$f' appears to be empty");
|
||||
}
|
||||
|
||||
foreach (@required_elems) {
|
||||
my $e = $cfg->get_property($_, $variables);
|
||||
for my $p (@required_elems) {
|
||||
my $e = $cfg->get_property($p, $variables);
|
||||
if (!defined $e) {
|
||||
$f =~ s/(^.*\/)?(.*?)\.pc$/$2/g;
|
||||
say_error("Package '$f' has no $_: field");
|
||||
say_error("Package '$f' has no $p: field");
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
@@ -494,11 +494,11 @@ sub do_cflags
|
||||
|
||||
my $cflags = [];
|
||||
|
||||
foreach my $pkg (@$list) {
|
||||
for my $pkg (@$list) {
|
||||
my $l = $configs{$pkg}->get_property('Cflags', $variables);
|
||||
foreach (@$l) {
|
||||
unless ($_ =~ /-I\/usr\/include\/*$/) {
|
||||
push(@$cflags, $_);
|
||||
for my $path (@$l) {
|
||||
unless ($path =~ /-I\/usr\/include\/*$/) {
|
||||
push(@$cflags, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -530,18 +530,18 @@ sub do_libs
|
||||
# order, not in search order. Ordering matters for static linking:
|
||||
# Start with Libs (first our own, then dependencies), and append
|
||||
# Libs.private (same order as for Libs).
|
||||
foreach my $pkg (@$list) {
|
||||
for my $pkg (@$list) {
|
||||
my $l = $configs{$pkg}->get_property('Libs', $variables);
|
||||
foreach (@$l) {
|
||||
unless ($_ =~ /-L\/usr\/lib\/*$/) {
|
||||
push(@$libs, $_);
|
||||
for my $path (@$l) {
|
||||
unless ($path =~ /-L\/usr\/lib\/*$/) {
|
||||
push(@$libs, $path);
|
||||
}
|
||||
}
|
||||
if ($mode{static}) {
|
||||
my $lp = $configs{$pkg}->get_property('Libs.private', $variables);
|
||||
foreach (@$lp) {
|
||||
unless ($_ =~ /-L\/usr\/lib\/*/) {
|
||||
push(@$libs, $_);
|
||||
for my $path (@$lp) {
|
||||
unless ($path =~ /-L\/usr\/lib\/*/) {
|
||||
push(@$libs, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,15 +550,15 @@ sub do_libs
|
||||
# Get the linker path directives (-L) and store it in $a.
|
||||
# $b will be the actual libraries.
|
||||
my $a = OpenBSD::PkgConfig->compress($libs,
|
||||
sub {
|
||||
local $_ = shift;
|
||||
if (($mode{libs} & 2) && /^-L/ ||
|
||||
($mode{libs} & 4) && !/^-[lL]/) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
sub {
|
||||
local $_ = shift;
|
||||
if (($mode{libs} & 2) && /^-L/ ||
|
||||
($mode{libs} & 4) && !/^-[lL]/) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
if (defined($variables->{pc_sysrootdir})){
|
||||
$a =~ s/[\w]?-[lL]/$&$variables->{pc_sysrootdir}/g;
|
||||
@@ -566,7 +566,7 @@ sub do_libs
|
||||
|
||||
if ($mode{libs} & 1) {
|
||||
my $b = OpenBSD::PkgConfig->rcompress($libs,
|
||||
sub { shift =~ m/^-l/; });
|
||||
sub { shift =~ m/^-l/; });
|
||||
return ($a, $b);
|
||||
} else {
|
||||
return $a;
|
||||
@@ -579,21 +579,21 @@ sub do_list
|
||||
my ($p, $x, $y, @files, $fname, $name);
|
||||
my $error = 0;
|
||||
|
||||
foreach my $p (@PKGPATH) {
|
||||
for my $p (@PKGPATH) {
|
||||
push(@files, <$p/*.pc>);
|
||||
}
|
||||
|
||||
# Scan the lengths of the package names so I can make a format
|
||||
# string to line the list up just like the real pkgconfig does.
|
||||
$x = 0;
|
||||
foreach my $f (@files) {
|
||||
for my $f (@files) {
|
||||
$fname = basename($f, '.pc');
|
||||
$y = length $fname;
|
||||
$x = (($y > $x) ? $y : $x);
|
||||
}
|
||||
$x *= -1;
|
||||
|
||||
foreach my $f (@files) {
|
||||
for my $f (@files) {
|
||||
my $cfg = get_config($f);
|
||||
if (!defined $cfg) {
|
||||
say_warning("Problem reading file $f");
|
||||
@@ -841,7 +841,7 @@ sub print_requires
|
||||
}
|
||||
|
||||
if (defined($value)) {
|
||||
print "$_\n" foreach (@$value);
|
||||
print "$_\n" for @$value;
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
@@ -882,5 +882,5 @@ sub say_msg
|
||||
delete($mode{estdout});
|
||||
}
|
||||
|
||||
print STDERR $str . "\n";
|
||||
print STDERR $str, "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user