Major reorganization and cleanup.
[wine.git] / tools / winapi / config.pm
blob9b463789f7fdfe06d75ed18347b69225a613d0a9
1 package config;
3 use strict;
5 use setup qw($current_dir $wine_dir $winapi_dir $winapi_check_dir);
7 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
8 require Exporter;
10 @ISA = qw(Exporter);
11 @EXPORT = qw(
12 &file_absolutize &file_normalize
13 &file_type &files_filter
14 &file_skip &files_skip
15 &get_spec_files
17 @EXPORT_OK = qw(
18 $current_dir $wine_dir $winapi_dir $winapi_check_dir
21 use vars qw($current_dir $wine_dir $winapi_dir $winapi_check_dir);
23 my $output = "output";
25 sub file_type {
26 local $_ = shift;
28 $_ = file_absolutize($_);
30 m%^(?:libtest|rc|server|tests|tools)/% && return "";
31 m%^(?:programs|debugger|miscemu)/% && return "wineapp";
32 m%^(?:library|tsx11|unicode)/% && return "library";
33 m%^windows/x11drv/wineclipsrv.c% && return "application";
35 return "winelib";
38 sub files_filter {
39 my $type = shift;
41 my @files;
42 foreach my $file (@_) {
43 if(file_type($file) eq $type) {
44 push @files, $file;
48 return @files;
51 sub file_skip {
52 local $_ = shift;
54 $_ = file_absolutize($_);
56 m%^(?:libtest|programs|rc|server|tests|tools)/% && return 1;
57 m%^(?:debugger|miscemu|tsx11|server|unicode)/% && return 1;
58 m%^dlls/wineps/data/% && return 1;
59 m%^windows/x11drv/wineclipsrv.c% && return 1;
60 m%^dlls/winmm/wineoss/midipatch.c% && return 1;
62 return 0;
65 sub files_skip {
66 my @files;
67 foreach my $file (@_) {
68 if(!file_skip($file)) {
69 push @files, $file;
73 return @files;
76 sub file_absolutize {
77 local $_ = shift;
79 $_ = file_normalize($_);
80 if(!s%^$wine_dir/%%) {
81 $_ = "$current_dir/$_";
83 s%^\./%%;
85 return $_;
88 sub file_normalize {
89 local $_ = shift;
91 foreach my $dir (split(m%/%, $current_dir)) {
92 s%^(\.\./)*\.\./$dir/%%;
93 if(defined($1)) {
94 $_ = "$1$_";
98 return $_;
101 sub get_spec_files {
102 $output->progress("$wine_dir: searching for *.spec");
104 my @spec_files = map {
105 s%^\./%%;
106 s%^$wine_dir/%%;
107 if(file_type($_) eq "winelib") {
109 } else {
112 } split(/\n/, `find $wine_dir -name \\*.spec`);
114 return @spec_files;