2002-03-09 23:29:33 +00:00
|
|
|
#
|
|
|
|
# Copyright 1999, 2000, 2001 Patrik Stridvall
|
|
|
|
#
|
|
|
|
# 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
|
2006-05-18 12:49:52 +00:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-09 23:29:33 +00:00
|
|
|
#
|
|
|
|
|
2001-06-13 19:38:29 +00:00
|
|
|
package config;
|
|
|
|
|
|
|
|
use strict;
|
2020-07-21 22:10:10 +00:00
|
|
|
use warnings 'all';
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2005-05-04 10:43:00 +00:00
|
|
|
use setup qw($current_dir $wine_dir $winapi_dir);
|
2001-06-13 19:38:29 +00:00
|
|
|
|
|
|
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
|
|
|
require Exporter;
|
|
|
|
|
|
|
|
@ISA = qw(Exporter);
|
|
|
|
@EXPORT = qw(
|
2004-10-26 00:12:21 +00:00
|
|
|
file_absolutize file_normalize
|
|
|
|
file_directory
|
|
|
|
file_type files_filter
|
|
|
|
file_skip files_skip
|
|
|
|
get_c_files
|
|
|
|
get_h_files
|
|
|
|
get_makefile_in_files
|
|
|
|
get_spec_files
|
2001-06-13 19:38:29 +00:00
|
|
|
);
|
|
|
|
@EXPORT_OK = qw(
|
2005-05-04 10:43:00 +00:00
|
|
|
$current_dir $wine_dir $winapi_dir
|
2001-06-13 19:38:29 +00:00
|
|
|
);
|
|
|
|
|
2005-05-04 10:43:00 +00:00
|
|
|
use vars qw($current_dir $wine_dir $winapi_dir);
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2001-07-23 23:20:56 +00:00
|
|
|
use output qw($output);
|
2001-07-11 17:27:45 +00:00
|
|
|
|
2001-07-26 21:42:12 +00:00
|
|
|
use File::Find;
|
|
|
|
|
2004-10-26 00:12:21 +00:00
|
|
|
sub file_normalize($) {
|
|
|
|
local $_ = shift;
|
|
|
|
|
|
|
|
foreach my $dir (split(m%/%, $current_dir)) {
|
|
|
|
if(s%^(\.\./)*\.\./$dir/%%) {
|
|
|
|
if(defined($1)) {
|
|
|
|
$_ = "$1$_";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while(m%^(.*?)([^/\.]+)/\.\./(.*?)$%) {
|
|
|
|
if($2 ne "." && $2 ne "..") {
|
|
|
|
$_ = "$1$3";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $_;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub file_absolutize($) {
|
|
|
|
local $_ = shift;
|
|
|
|
|
|
|
|
$_ = file_normalize($_);
|
|
|
|
if(!s%^$wine_dir/%%) {
|
|
|
|
$_ = "$current_dir/$_";
|
|
|
|
}
|
|
|
|
s%^\./%%;
|
|
|
|
|
|
|
|
return $_;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub file_type($) {
|
2001-06-20 22:53:21 +00:00
|
|
|
local $_ = shift;
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2001-06-20 22:53:21 +00:00
|
|
|
$_ = file_absolutize($_);
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2005-06-09 10:24:51 +00:00
|
|
|
m%^(?:server|tests|tools)/% && return "";
|
|
|
|
m%^(?:programs)/% && return "wineapp";
|
2003-08-08 21:04:17 +00:00
|
|
|
m%^(?:libs)/% && return "library";
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2001-06-20 22:53:21 +00:00
|
|
|
return "winelib";
|
|
|
|
}
|
|
|
|
|
2004-10-26 00:12:21 +00:00
|
|
|
sub files_filter($@) {
|
2001-06-20 22:53:21 +00:00
|
|
|
my $type = shift;
|
|
|
|
|
|
|
|
my @files;
|
|
|
|
foreach my $file (@_) {
|
|
|
|
if(file_type($file) eq $type) {
|
|
|
|
push @files, $file;
|
|
|
|
}
|
2001-06-13 19:38:29 +00:00
|
|
|
}
|
2001-06-20 22:53:21 +00:00
|
|
|
|
|
|
|
return @files;
|
2001-06-13 19:38:29 +00:00
|
|
|
}
|
|
|
|
|
2004-10-26 00:12:21 +00:00
|
|
|
sub file_skip($) {
|
2001-06-13 19:38:29 +00:00
|
|
|
local $_ = shift;
|
|
|
|
|
2001-06-20 22:53:21 +00:00
|
|
|
$_ = file_absolutize($_);
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2007-02-20 14:50:21 +00:00
|
|
|
m%^(?:dlls|include)/% || return 1;
|
|
|
|
m%^dlls/wineps\.drv/data/% && return 1;
|
2001-06-13 19:38:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-26 00:12:21 +00:00
|
|
|
sub files_skip(@) {
|
2001-06-13 19:38:29 +00:00
|
|
|
my @files;
|
|
|
|
foreach my $file (@_) {
|
|
|
|
if(!file_skip($file)) {
|
|
|
|
push @files, $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return @files;
|
|
|
|
}
|
|
|
|
|
2004-10-26 00:12:21 +00:00
|
|
|
sub file_directory($) {
|
2001-07-30 18:49:10 +00:00
|
|
|
local $_ = shift;
|
2001-07-26 21:42:12 +00:00
|
|
|
|
2001-07-30 18:49:10 +00:00
|
|
|
s%/?[^/]*$%%;
|
|
|
|
if(!$_) {
|
|
|
|
$_ = ".";
|
2001-07-26 21:42:12 +00:00
|
|
|
}
|
2001-07-30 18:49:10 +00:00
|
|
|
|
|
|
|
s%^(?:\./)?(.*?)(?:/\.)?%$1%;
|
|
|
|
|
|
|
|
return $_;
|
2001-07-26 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
2004-10-26 00:12:21 +00:00
|
|
|
sub _get_files($$;$) {
|
2002-08-27 00:29:36 +00:00
|
|
|
my $pattern = shift;
|
2001-07-18 20:09:12 +00:00
|
|
|
my $type = shift;
|
2001-07-26 21:42:12 +00:00
|
|
|
my $dir = shift;
|
2001-07-18 20:09:12 +00:00
|
|
|
|
2002-08-27 00:29:36 +00:00
|
|
|
$output->progress("$wine_dir: searching for /$pattern/");
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2001-07-26 21:42:12 +00:00
|
|
|
if(!defined($dir)) {
|
|
|
|
$dir = $wine_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
my @files;
|
|
|
|
|
|
|
|
my @dirs = ($dir);
|
|
|
|
while(defined(my $dir = shift @dirs)) {
|
2006-08-08 10:19:31 +00:00
|
|
|
opendir(DIR, $dir) || die "Can't open directory $dir: $!\n";
|
2001-07-26 21:42:12 +00:00
|
|
|
my @entries= readdir(DIR);
|
|
|
|
closedir(DIR);
|
|
|
|
foreach (@entries) {
|
2002-08-27 00:29:36 +00:00
|
|
|
my $basefile = $_;
|
2002-06-01 02:55:48 +00:00
|
|
|
$_ = "$dir/$_";
|
2001-07-26 21:42:12 +00:00
|
|
|
if(/\.\.?$/) {
|
|
|
|
# Nothing
|
|
|
|
} elsif(-d $_) {
|
|
|
|
push @dirs, $_;
|
2002-08-27 00:29:36 +00:00
|
|
|
} elsif($basefile =~ /$pattern/ && (!defined($type) || file_type($_) eq $type)) {
|
2001-07-26 21:42:12 +00:00
|
|
|
s%^$wine_dir/%%;
|
|
|
|
push @files, $_;
|
|
|
|
}
|
2001-06-13 19:38:29 +00:00
|
|
|
}
|
2001-07-26 21:42:12 +00:00
|
|
|
}
|
2001-06-13 19:38:29 +00:00
|
|
|
|
2001-07-18 20:09:12 +00:00
|
|
|
return @files;
|
2001-06-13 19:38:29 +00:00
|
|
|
}
|
|
|
|
|
2004-10-26 00:12:21 +00:00
|
|
|
sub get_c_files($;$) { return _get_files('\.c$', $_[0], $_[1]); }
|
|
|
|
sub get_h_files($;$) { return _get_files('\.h$', $_[0], $_[1]); }
|
|
|
|
sub get_spec_files($;$) { return _get_files('\.spec$', $_[0], $_[1]); }
|
|
|
|
sub get_makefile_in_files($;$) { return _get_files('^Makefile.in$', $_[0], $_[1]); }
|
2001-07-18 20:09:12 +00:00
|
|
|
|
2001-06-13 19:38:29 +00:00
|
|
|
1;
|