update readme and add gitignore
[client-tools.git] / tools / objectTemplateCreateCommands.pl
blob6f0820b7eddc8055aff24d7d3b32fafe35047a0f
1 use strict;
2 use warnings;
4 my $branch;
7 # =====================================================================
9 sub perforceWhere
11 # find out where a perforce file resides on the local machine
12 my $result;
14 open(P4, "p4 where $_[0] |");
15 while ( <P4> )
17 next if ( /^-/ );
18 chomp;
19 my @where = split;
20 $result = $where[2];
22 close(P4);
25 return $result;
28 sub usage
30 die "usage: $0 <branch> <output>\n";
33 # =====================================================================
35 sub perforceGatherAndPrune
37 local $_;
38 my %files;
40 foreach my $spec (@_)
42 open(P4, "p4 files $spec/... |");
43 while (<P4>)
45 chomp;
46 next if (/ delete /)/
47 s%//depot/swg/$branch/data/sku\.0/sys\.(shared|server)/compiled/game/%%;
48 s/#.*//;
49 $files{$_} = 1;
51 close(P4);
53 open(P4, "p4 opened -a $spec/... |");
54 while (<P4>)
56 chomp;
57 s%//depot/swg/$branch/data/sku\.0/sys\.(shared|server)/compiled/game/%%;
58 s/#.*//;
59 $files{$_} = 1;
61 close(P4);
64 return sort keys %files;
67 # =====================================================================
69 usage() unless (@ARGV == 2 && $ARGV[0] =~ m%^(current|test|live|x1|x2|s0|s1|s2|s3|s4|s5)$%);
71 $branch = $ARGV[0];
72 my $output = $ARGV[1];
75 my @files = perforceGatherAndPrune("//depot/swg/$branch/data/sku.0/sys.shared/compiled/game/object");
77 open(B, ">" . $output);
78 foreach (@files)
80 print B "/rem object createAt ", $_, "\n";
82 close(B);