summaryrefslogtreecommitdiffstats
path: root/src/windows/build/pruneFiles.pl
blob: 091a6a090a465526381295d416b0f8f5309f9214 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!perl -w


#use strict;

require "makeZip.pl";

sub pruneFiles {
    local ($xml, $config)   = @_;
    local $prunes   = $xml->{Prunes};
    if (! $prunes) {return 0;}
    
    # Use Unix find instead of Windows find.  Save PATH so we can restore it when we're done:

    local $savedPATH    = $ENV{PATH};
    $ENV{PATH}          = $config->{Config}->{unixfind}->{value}.";".$savedPATH;
    local $j=0;
    print "Info -- Processing prunes in ".`cd`."\n"     if ($verbose);
    while ($prunes->{Prune}->[$j]) {
        if (exists $prunes->{Prune}->[$j]->{name}) {    ## Don't process dummy entry!

            local $prune    = $prunes->{Prune}->[$j]->{name};
            local $flags    = $prunes->{Prune}->[$j]->{flags};
            $flags = "" if (!$flags);
            local $cmd    = "find . -".$flags."name $prune";
            print "Info -- Looking for filenames containing $prune\n";
            local $list = `$cmd`;
            foreach $target (split("\n", $list)) {
                print "Info -- Pruning $target\n" if ($verbose);
                ! system("rm -rf $target")              or die "Unable to prune $target";
                }
            }
        $j++;
        }
    $ENV{PATH} = $savedPATH;
    }

return 1;