Merged in Governor-Tarkin/swg-src (pull request #17)
[swg-src.git] / tools / buildObjectTemplateCrcStringTables.pl
blob259d5f35139fea3b91a10ea71acf9e647ead1538
1 use strict;
2 use warnings;
4 my $branch;
5 my $all = "";
6 my $only = "";
9 # =====================================================================
11 sub perforceWhere
13 # find out where a perforce file resides on the local machine
14 my $result;
16 open(P4, "p4 where $_[0] |");
17 while ( <P4> )
19 next if ( /^-/ );
20 chomp;
21 my @where = split;
22 $result = $where[2];
24 close(P4);
27 return $result;
30 sub usage
32 die "usage: buildObjectTemplateCrcStringTables [--local|--all|--only <changelist#>] <current|test|live|x1|x2|ep3|demo|s#>\n" .
33 "\t--local : include pending files only from the local client\n" .
34 "\t--all : include pending files from all clients\n" .
35 "\t--only <changelist#> : include pending files only from <changelist#>\n" .
36 "\tif no option is provided, --local is assumed.\n";
39 # =====================================================================
41 sub perforceGatherAndPrune
43 local $_;
44 my %files;
46 foreach my $spec (@_)
48 open(P4, "p4 files $spec/... |");
49 while (<P4>)
51 chomp;
52 next if (/ delete /)/
53 s%//depot/swg/$branch/data/sku\.0/sys\.(shared|server)/compiled/game/%%;
54 s/#.*//;
55 $files{$_} = 1;
57 close(P4);
59 open(P4, "p4 opened " . $all . " " . $only . " $spec/... |");
60 while (<P4>)
62 chomp;
63 s%//depot/swg/$branch/data/sku\.0/sys\.(shared|server)/compiled/game/%%;
64 s/#.*//;
65 $files{$_} = 1;
67 close(P4);
70 return sort keys %files;
73 # =====================================================================
75 if ($#ARGV == 1 || $#ARGV == 2)
77 if ($ARGV[0] eq "--local")
79 $all = "";
81 elsif ($ARGV[0] eq "--all")
83 $all = "-a";
85 elsif ($ARGV[0] eq "--only" && $#ARGV == 2)
87 $all = "";
88 $only = "-c " . $ARGV[1];
89 shift;
91 else
93 usage();
96 shift;
99 usage() unless (defined($ARGV[0]) && $ARGV[0] =~ m%^(current|test|stage|live|x1|x2|ep3|demo|s\d+)$%);
101 $branch = $ARGV[0];
103 my $buildCrcStringTable = perforceWhere("//depot/swg/$branch/tools/buildCrcStringTable.pl");
105 my $tab = perforceWhere("//depot/swg/$branch/dsrc/sku.0/sys.client/built/game/misc/object_template_crc_string_table.tab");
106 my $output = perforceWhere("//depot/swg/$branch/data/sku.0/sys.client/built/game/misc/object_template_crc_string_table.iff");
107 print "building client object template strings:\n\t$tab\n\t$output\n";
108 system("p4 edit $tab $output");
110 my @files = perforceGatherAndPrune(
111 "//depot/swg/$branch/data/sku.0/sys.shared/compiled/game/object",
112 "//depot/swg/$branch/data/sku.0/sys.server/compiled/game/object/creature/player");
114 open(B, "| perl $buildCrcStringTable -t $tab $output");
115 foreach (@files)
117 print B $_, "\n";
119 close(B);
123 my $tab = perforceWhere("//depot/swg/$branch/dsrc/sku.0/sys.server/built/game/misc/object_template_crc_string_table.tab");
124 my $output = perforceWhere("//depot/swg/$branch/data/sku.0/sys.server/built/game/misc/object_template_crc_string_table.iff");
125 print "building server object template strings:\n\t$tab\n\t$output\n";
126 system("p4 edit $tab $output");
128 my @files = perforceGatherAndPrune(
129 "//depot/swg/$branch/data/sku.0/sys.shared/compiled/game/object",
130 "//depot/swg/$branch/data/sku.0/sys.server/compiled/game/object");
132 open(B, "| perl $buildCrcStringTable -t $tab $output");
133 foreach (@files)
135 print B $_, "\n";
137 close(B);