1@echo off 2perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 3exit; 4#!perl -w 5#line 6 6######################################################################### 7 8my $debugDir = "debug"; 9my $miniDir = "mini"; 10my $orig = "$debugDir/JsHttpRequest.js"; 11my $minProg = "C:/Program Files/DojoMin/dojomin.bat"; 12 13my $source = readFile($orig); 14my ($comment) = $source =~ m{^\s*(/\*.*?\*/)}s; 15my %parts = reverse($source =~ m[(//\s*{{{ [ \t]* (\w*) .*? //[ \t]* }}})]sgx); 16my $main = $parts{''}; delete $parts{''}; 17 18$parts{'script-xml'} = $parts{script} . "\n\n" . $parts{xml}; 19 20while (my ($k, $v) = each %parts) { 21 my $fname = "JsHttpRequest-$k.js"; 22 my $newComment = $comment; 23 $newComment =~ s/\*\s*\w+[^\r\n]*/$& ($k support only!)/s; 24 writeFile($debugDir . '/' . $fname, $newComment . "\n" . $main . "\n\n" . $v); 25 minify($debugDir . '/' . $fname, $miniDir . '/' . $fname); 26} 27 28minify($orig, "JsHttpRequest.js"); 29minify($orig, $miniDir . "/JsHttpRequest.js"); 30 31 32 33 34sub minify { 35 my ($from, $to, $commentAdd) = @_; 36 my ($comment) = readFile($from) =~ m{^\s*(/\*.*?\*/)}s; 37 $comment =~ s/\*\s*\w+[^\r\n]*\s*\*/$& Minimized version: see debug directory for the complete one.\n */s; 38 system("\"$minProg\" $from > $to"); 39 writeFile($to, $comment . "\n" . readFile($to)); 40} 41 42sub readFile { 43 my ($name) = @_; 44 local $/; 45 open(local *F, $name); 46 return <F>; 47} 48 49sub writeFile { 50 my ($name, $data) = @_; 51 local $/; 52 open(local *F, ">", $name); 53 print F $data; 54}