-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.pl
56 lines (44 loc) · 1.21 KB
/
build.pl
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use strict;
use warnings;
use File::Spec;
use File::Copy;
use File::Path qw(make_path rmtree);
my @roots = ('Data', 'Textures', 'Models');
my $destination = '..\\ElectronicWarfareDistro\\';
foreach my $r (@roots) {
my $remove = File::Spec->catfile($destination, $r);
if(-e $remove) {
print("Cleaning root $remove\n");
rmtree($remove);
}
processDir($r);
}
sub processDir {
my ($path) = @_;
print("Processing directory $path\n");
opendir(DIR, $path) or die $!;
my @files = readdir(DIR);
closedir(DIR);
# Smoosh all the namespace directories down
my $destPath = "";
if($path =~ m!Data\\Scripts\\SEEW\\!) {
$destPath = File::Spec->catfile($destination, 'Data\\Scripts\\SEEW');
} else {
$destPath = File::Spec->catfile($destination, $path);
}
unless(-e $destPath) {
make_path($destPath);
}
foreach my $entry (@files) {
next if($entry eq '.' || $entry eq '..');
next if($entry eq 'bin' || $entry eq 'obj');
my $full = File::Spec->catfile($path, $entry);
if(-d $full) {
processDir($full);
} elsif($entry =~ /\.(cs|sbc|dds|mwm)$/) {
my $dest = File::Spec->catfile($destPath, $entry);
print("Copying file $entry -> $dest\n");
copy($full, $dest) or die "Could not copy: $!";
}
}
}