builder.pl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. #!perl
  2. #NOTE: this script assumes you are running the Cygwin perl, which uses the
  3. # Cygwin file paths (i.e. '/' corresponds to 'C:\cygwin')
  4. my $WIN_INSTALLDIR="\\\\dimbo\\panda\\win";
  5. # my $WIN_INSTALLDIR="\\\\cxgeorge-d01\\c\\win";
  6. # my $DEBUG_TREECOPY = 1;
  7. # my $DEBUG_GENERATE_PYTHON_CODE_ONLY = 1; $ENV{'PANDA_OPTIMIZE'} ='2';
  8. my $DONT_ARCHIVE_OLD_BUILDS = 0;
  9. my $BLD_DTOOL_ONLY=0;
  10. my $DIRPATH_SEPARATOR=':'; # set to ';' for non-cygwin NT perl
  11. my @inst_dirnames=("archive","debug","install","release");
  12. my $ARCHIVENUM=0;
  13. my $DEBUGNUM=1;
  14. my $INSTALLNUM=2;
  15. my $RELEASENUM=3;
  16. my @inst_dirs;
  17. for(my $i=0;$i<=$#inst_dirnames;$i++) {
  18. $inst_dirs[$i]=$WIN_INSTALLDIR."\\".$inst_dirnames[$i];
  19. }
  20. if(! $DEBUG_GENERATE_PYTHON_CODE_ONLY) {
  21. $ENV{'PANDA_OPTIMIZE'}='1'; # var has meaning to my special Config.pp
  22. }
  23. $ENV{'PPREMAKE_CONFIG'} = '/usr/local/etc/Config.pp';
  24. $ENV{'TCSH_NO_CSHRC_CHDIR'}='1';
  25. $ENV{'HOME'}="/home/builder";
  26. $ENV{'USER'}="builder";
  27. $ENV{'USERNAME'}=$ENV{'USER'};
  28. my $DONT_ARCHIVE_OLD_BUILDS = (($ENV{'DONT_ARCHIVE_OLD_BUILDS'} ne "") || $DONT_ARCHIVE_OLD_BUILDS);
  29. sub logmsg() {
  30. my $msg = shift;
  31. print $msg."\n";
  32. open(LOGFILE,">>".$fulllogfilename) || die "can't open log file '$fulllogfilename'\n";
  33. print LOGFILE $msg."\n";
  34. close(LOGFILE);
  35. }
  36. #could change this to use eval, but it would require doubling the '\''s again in filename
  37. sub mychdir() {
  38. my $newdir = shift;
  39. my $retval = chdir($newdir);
  40. &logmsg("chdir(".$newdir.")");
  41. if(! $retval) {
  42. &logmsg("chdir(".$newdir.") failed!!");
  43. exit(1);
  44. }
  45. }
  46. sub mymkdir() {
  47. my $newdir=shift;
  48. if(!(-e $newdir)) {
  49. if(!mkdir($newdir,0xfff)) {
  50. &logmsg("cant create new dir '".$newdir."' !!");
  51. exit(1);
  52. }
  53. }
  54. }
  55. sub myrename() {
  56. my $n1 = shift;
  57. my $n2 = shift;
  58. my $retval;
  59. &logmsg("rename(".$n1.",".$n2.")");
  60. if(-e $n2) {
  61. # find name we can move old target to
  62. my $newnum=1;
  63. while(-e $n2.".old.".$newnum) {
  64. $newnum++;
  65. }
  66. $newconflicttargetname=$n2.".old.".$newnum;
  67. &logmsg("avoiding rename conflict, renaming old ".$n2." to ".$newconflicttargetname);
  68. $retval = rename($n2,$newconflicttargetname);
  69. if(! $retval) {
  70. &logmsg("rename failing, giving up (check if files or dirs are open in other apps)");
  71. exit(1);
  72. }
  73. }
  74. $retval = rename($n1,$n2);
  75. if(! $retval) {
  76. &logmsg("rename(".$n1.",".$n2.") failed!!! (check if files or dirs are open in other apps)");
  77. exit(1);
  78. }
  79. }
  80. sub myexecstr() {
  81. my $cmdstr = shift;
  82. my $errstr = shift;
  83. my $dologstr = shift;
  84. my $exec_cshrc_type = shift;
  85. if($dologstr eq "DO_LOG") {
  86. if($exec_cshrc_type eq "NT cmd") {
  87. $cmdstr.=" >> ".$fulllogfilename_win." 2>&1"; # 2>&1 tells nt cmd.exe to redirect stderr to stdout
  88. } else {
  89. $cmdstr.=" >>& ".$fulllogfilename; # for tcsh
  90. }
  91. &logmsg($cmdstr);
  92. }
  93. my $savedhome = $ENV{'HOME'};
  94. if( $exec_cshrc_type eq "NO_CSHRC") {
  95. # change $HOME so .cshrc doesn't get sources by tcsh
  96. $ENV{'HOME'}="/";
  97. } elsif( $exec_cshrc_type eq "NO_PANDA_ATTACH") {
  98. $ENV{'TCSH_NO_PANDA_ATTACH'}="1";
  99. }
  100. if($exec_cshrc_type eq "NT cmd") {
  101. my @args = ("cmd.exe", "/c", "$cmdstr");
  102. $retval = system(@args);
  103. } else {
  104. my @args = ("tcsh.exe", "-c", "$cmdstr");
  105. $retval = system(@args);
  106. }
  107. if($retval!=0) {
  108. $retval= $retval/256; # actual retval
  109. if($errstr eq "") {
  110. &logmsg($cmdstr." failed!!!!! continuing anyway...\nError return value=".$retval);
  111. } elsif($errstr ne "nomsg") {
  112. &logmsg($errstr."\nError return value=".$retval);
  113. exit($retval);
  114. }
  115. }
  116. if($exec_cshrc_type eq "NO_CSHRC") {
  117. $ENV{'HOME'}=$savedhome;
  118. } elsif( $exec_cshrc_type eq "NO_PANDA_ATTACH") {
  119. delete $ENV{'TCSH_NO_PANDA_ATTACH'};
  120. }
  121. }
  122. sub gettimestr() {
  123. my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time);
  124. $mon++;
  125. return $mon."/".$mday." ".$hour.":".($min<10 ? "0":"").$min;
  126. }
  127. sub appendpath() {
  128. # note cygwin perl.exe requires ':' instead of ';' as path dir separator
  129. foreach $dir1 (@_) {
  130. $ENV{'PATH'}.=$DIRPATH_SEPARATOR.$CYGBLDROOT.$dir1;
  131. }
  132. }
  133. sub make_bsc_file() {
  134. &logmsg("*** Generating panda.bsc at ".&gettimestr()." ***");
  135. # &mychdir($CYGBLDROOT."/debug");
  136. # $outputdir=$WINBLDROOT."\\debug";
  137. &mychdir($CYGBLDROOT);
  138. $outputdir=$WINBLDROOT;
  139. $outputname="panda.bsc";
  140. $outputfilepath=$outputdir."\\".$outputname;
  141. $cmdfilepath=$outputdir."\\makebsc.txt";
  142. #open(FILES, "where -r . *.sbr |") || die "Couldn't run 'where'!\n";
  143. #requires unix/cygwin style find.exe
  144. open(FILES, "find ".$dirstodostr." -name \"*.sbr\" -print |") || die "Couldn't run 'find'!\n";
  145. open(OUTFILE, ">".$cmdfilepath) || die "Couldn't open ".$cmdfilepath."!\n";
  146. $filename = <FILES>; #skip initial line
  147. $filestr="";
  148. $duline = <FILES>;
  149. chop $duline;
  150. $filestr=$duline;
  151. while ($duline = <FILES>)
  152. {
  153. chop $duline; # Remove the newline from the end of the filename
  154. $filestr=$filestr."\n".$duline;
  155. }
  156. print OUTFILE "/n /o ".$outputfilepath." \n";
  157. print OUTFILE "$filestr","\n";
  158. close(OUTFILE);
  159. close(FILES);
  160. $bscmake_str="bscmake /o ".$outputfilepath." @".$cmdfilepath."\n";
  161. &myexecstr($bscmake_str,"bscmake failed!!!", "DO_LOG","NT cmd");
  162. &myexecstr("copy ".$outputfilepath." ".$inst_dirs[$DEBUGNUM], "copy of ".$outputfilepath." failed!!", "DO_LOG","NT cmd");
  163. unlink($cmdfilepath);
  164. &mychdir($CYGBLDROOT);
  165. }
  166. sub addpathsfromfile() {
  167. my $dirname = shift;
  168. my $envvarname = shift;
  169. my $pathfile=$WINBLDROOT."\\".$dirname."\\src\\configfiles\\".$dirname.".pth";
  170. if(!open(PTHFILE, $pathfile)) {
  171. &logmsg("Couldn't open ".$pathfile."!");
  172. exit(1);
  173. }
  174. my @filestrs=<PTHFILE>;
  175. close(PTHFILE);
  176. foreach my $i (@filestrs) {
  177. chop($i);
  178. $i =~ s/\//\\/g; # switch fwdslash to backslsh
  179. # print $i,"\n";
  180. $ENV{$envvarname}.=";".$WINBLDROOT."\\".$dirname."\\".$i;
  181. }
  182. }
  183. sub gen_python_code() {
  184. # ETC_PATH required by generatePythonCode
  185. $ENV{'ETC_PATH'}='/home/builder/player/panda/etc /home/builder/player/direct/etc /home/builder/player/dtool/etc /home/builder/player/toontown/etc';
  186. my $origpath=$ENV{'PATH'};
  187. $ENV{'PATH'}="/usr/lib:/c/python16:/bin:/contrib/bin:/mscommon/Tools/WinNT:/mscommon/MSDev98/Bin:/mscommon/Tools:/msvc98/bin:/home/builder/player/dtool/bin:/home/builder/player/dtool/lib:/home/builder/player/direct/bin:/home/builder/player/direct/lib::/home/builder/player/toontown/bin:/home/builder/player/toontown/lib:/home/builder/player/panda/lib:/home/builder/player/panda/bin:/usr/local/bin:.:/c/WINNT/system32:/c/WINNT:/c/WINNT/System32/Wbem:/c/bin:/c/PROGRA~1/TCL/bin:/mspsdk/Bin/:/mspsdk/Bin/WinNT:/mscommon/Tools/WinNT:/mscommon/MSDev98/Bin:/mscommon/Tools:/msvc98/bin::/usr/local/panda/bin:/home/builder/scripts";
  188. my $directsrcroot=$WINBLDROOT."\\direct\\src";
  189. $ENV{'PYTHONPATH'}= $WINBLDROOT."\\panda\\lib;".$WINBLDROOT."\\dtool\\lib";
  190. &addpathsfromfile("direct","PYTHONPATH");
  191. &addpathsfromfile("toontown","PYTHONPATH");
  192. $ENV{'TCSH_NO_CHANGEPATH'}='1';
  193. &logmsg($ENV{'PYTHONPATH'}."\n");
  194. &mychdir($CYGBLDROOT."/direct/bin");
  195. $outputdir = $WINBLDROOT."\\direct\\lib\\py";
  196. # &mymkdir($outputdir);
  197. # $outputdir.= "\\Opt".$ENV{'PANDA_OPTIMIZE'}."-Win32";
  198. # &mymkdir($outputdir);
  199. # now back to 1 build-type per tree
  200. my $genpyth_str;
  201. my $genargstr="-v -d";
  202. if(($ENV{'PANDA_OPTIMIZE'} eq '1') || ($ENV{'PANDA_OPTIMIZE'} eq '2')) {
  203. $genpyth_str="python_d ";
  204. } else {
  205. $genpyth_str="python -O ";
  206. $genargstr="-O ".$genargstr;
  207. }
  208. $genpyth_str.="generatePythonCode ".$genargstr." '".$outputdir."' -e '".$WINBLDROOT."\\direct\\src\\extensions' -i libdtool libpandaexpress libpanda libdirect libtoontown";
  209. &myexecstr($genpyth_str,"generate python code failed!!!","DO_LOG","NO_PANDA_ATTACH");
  210. $ENV{'PATH'}=$origpath;
  211. delete $ENV{'TCSH_NO_CHANGEPATH'};
  212. &mychdir($CYGBLDROOT);
  213. }
  214. my $newdayarchivedirname;
  215. sub archivetree() {
  216. $treenum=shift;
  217. if(!(-e $inst_dirs[$treenum])) {
  218. return;
  219. }
  220. if($newdayarchivename eq "") {
  221. ($devicenum,$inodenum,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)
  222. = stat($inst_dirs[2]);
  223. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
  224. = localtime($mtime);
  225. $mon++;
  226. $newdayarchivedirname=$inst_dirs[$ARCHIVENUM]."\\".($mon<10 ? "0":"").$mon."-".($mday<10 ? "0":"").$mday;
  227. &mymkdir($newdayarchivedirname);
  228. }
  229. &logmsg("*** Archiving ".$inst_dirnames[$treenum]." build on install server at ".&gettimestr()." ***");
  230. my $archdirname=$newdayarchivedirname."\\".$inst_dirnames[$treenum];
  231. &myrename($inst_dirs[$treenum],$archdirname);
  232. foreach my $dir1 (@dirstodolist) {
  233. # copy DLL .pdb up to lib dir so we can blow away metalibs subdir
  234. # could do this is the makefiles instead
  235. &myexecstr("( for /R ".$archdirname."\\".$dir1."\\metalibs %i in (lib*.pdb) do copy %i ".$archdirname."\\".$dir1."\\lib )","nomsg","DO_LOG","NT cmd");
  236. if($dir1 eq "panda") {
  237. # audio libs seem to not have a metalib dir
  238. &myexecstr("( for /R ".$archdirname."\\".$dir1."\\src\audiotraits %i in (lib*.pdb) do copy %i ".$archdirname."\\".$dir1."\\lib )","nomsg","DO_LOG","NT cmd");
  239. }
  240. # NT cmd 'for' always returns 144 for some reason, impossible to detect error cond, so just dont check retval
  241. # delete old objs/pdbs/etc out of archived trees (just blow away the Opt[Win32] dir)
  242. # &myexecstr("( for /D /R ".$archdirname."\\".$dir1."\\src %i in (Opt*Win32) do rd /s /q %i )","nomsg","DO_LOG","NT cmd");
  243. # instead blow away src,CVS,include,metalibs dirs completely
  244. # doing every rd twice since samba-netapp-RAID link seems to screw up and cause some files to not be deleted the 1st time
  245. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\src","nomsg","DO_LOG","NT cmd");
  246. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\CVS","nomsg","DO_LOG","NT cmd");
  247. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\include","nomsg","DO_LOG","NT cmd");
  248. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\metalibs","nomsg","DO_LOG","NT cmd");
  249. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\src","nomsg","DO_LOG","NT cmd");
  250. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\CVS","nomsg","DO_LOG","NT cmd");
  251. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\include","nomsg","DO_LOG","NT cmd");
  252. &myexecstr("rd /s /q ".$archdirname."\\".$dir1."\\metalibs","nomsg","DO_LOG","NT cmd");
  253. # del xtra files at root of subdirs
  254. &myexecstr("del /Q /F ".$archdirname."\\".$dir1."\\*","nomsg","DO_LOG","NT cmd");
  255. }
  256. # delete old browse files
  257. &myexecstr("del /q ".$archdirname."\\*.bsc","nomsg","DO_LOG","NT cmd");
  258. # could also move .pdb from metalibs to lib, then del metalibs, include, src dirs
  259. }
  260. sub checkoutfiles {
  261. my $existing_module_str="";
  262. my $nonexisting_module_str="";
  263. &mychdir($CYGBLDROOT);
  264. foreach my $dir1 (@dirstodolist) {
  265. if(-e $dir1) {
  266. $existing_module_str.=$dir1." ";
  267. } else {
  268. $nonexisting_module_str.=$dir1." ";
  269. }
  270. }
  271. if($existing_module_str ne "") {
  272. # flaw: will bomb is any CVS subdirs are missing
  273. &myexecstr("( for /D /R . %i in (Opt*Win32) do rd /s /q %i )","nomsg","DO_LOG","NT cmd");
  274. &logmsg("*** REMOVING ALL FILES IN OLD SRC TREES ***");
  275. # use cvs update to grab new copy
  276. # note: instead of blowing these away, may want to rename and save them
  277. # also, I could just blow everything away and check out again
  278. # cant blow away if people are sitting in those dirs, so we do this instead
  279. $rmcmd="find ".$existing_module_str." -path '*CVS*' -prune -or -not -name 'bldlog*' -and -not -type d -print | xargs --no-run-if-empty -n 40 rm";
  280. #&myexecstr($rmcmd,"Removal of old files failed!","DO_LOG","NO_CSHRC");
  281. &myexecstr($rmcmd,"Removal of old files failed!","DO_LOG","NO_PANDA_ATTACH");
  282. &myexecstr("cvs update -d -R ".$existing_module_str." |& egrep -v 'Updating|^\\?'",
  283. "cvs update failed!","DO_LOG","NO_PANDA_ATTACH");
  284. }
  285. if($nonexisting_module_str ne "") {
  286. &myexecstr("cvs checkout -R ".$nonexisting_module_str." |& egrep -v 'Updating|^\\?'",
  287. "cvs checkout failed!","DO_LOG","NO_PANDA_ATTACH");
  288. }
  289. }
  290. sub buildall() {
  291. $treenum=shift;
  292. # DTOOL ppremake may have already run by DTOOL 'initialize make'
  293. &logmsg("*** Starting ".uc($inst_dirnames[$treenum])." Build (Opt=".$ENV{'PANDA_OPTIMIZE'}.") at ".&gettimestr()." ***");
  294. &checkoutfiles();
  295. # cant do attachment, since that often hangs on NT
  296. # must use non-attachment build system (BUILD_TYPE 'gmsvc', not 'stopgap', in $PPREMAKE_CONFIG)
  297. # hacks to fix multiproc build issue (cp file to dir occurs before dir creation)
  298. foreach my $dir1 (@dirstodolist) {
  299. &mymkdir($CYGBLDROOT."/".$dir1."/etc");
  300. &mymkdir($CYGBLDROOT."/".$dir1."/bin");
  301. &mymkdir($CYGBLDROOT."/".$dir1."/lib");
  302. &mymkdir($CYGBLDROOT."/".$dir1."/include");
  303. }
  304. &mymkdir($CYGBLDROOT."/dtool/include/parser-inc"); # hack to fix makefile multiproc issue
  305. foreach my $dir1 (@dirstodolist) {
  306. my $dir1_upcase = uc($dir1);
  307. &logmsg("*** PPREMAKE ".$dir1_upcase." ***");
  308. &mychdir($CYGBLDROOT."/".$dir1);
  309. &myexecstr("ppremake",$dir1_upcase." ppremake failed!","DO_LOG","NO_PANDA_ATTACH");
  310. }
  311. # debug stuff
  312. # &mychdir($CYGBLDROOT);
  313. # &myexecstr("dir dtool","dir failed","DO_LOG","NT cmd");
  314. foreach my $dir1 (@dirstodolist) {
  315. my $dir1_upcase = uc($dir1);
  316. &logmsg("*** BUILDING ".$dir1_upcase." ***");
  317. &mychdir($CYGBLDROOT."/".$dir1);
  318. &myexecstr("make install",$dir1_upcase." make install failed!","DO_LOG","NO_PANDA_ATTACH");
  319. }
  320. &mychdir($CYGBLDROOT); # get out of src dirs to allow them to be moved/renamed
  321. unlink($CYGBLDROOT."/dtool/dtool_config.h"); # fix freakish NTFS bug, this file is regenerated by ppremake anyway
  322. if($#dirstodolist>1) {
  323. &gen_python_code(); # must run AFTER toontown bld
  324. }
  325. &mychdir($CYGBLDROOT); # get out of src dirs to allow them to be moved/renamed
  326. # archive old current srvr build & copy build to server, if its accessible
  327. if(!(-e $WIN_INSTALLDIR)) {
  328. &logmsg("ERROR: Cant access install directory!! (Is Server down??) ".$WIN_INSTALLDIR);
  329. &logmsg("Skipping archive and copy-build-to-server steps for ".$inst_dirnames[$treenum]." build");
  330. return;
  331. }
  332. if($DONT_ARCHIVE_OLD_BUILDS) {
  333. &myexecstr("rd /s /q ".$inst_dirs[$treenum],"DO_LOG","NT cmd"); # dont bother checking errors here, probably just some shell has the dir cd'd to
  334. } else {
  335. &archivetree($treenum);
  336. }
  337. &logmsg("*** Copying ".$inst_dirnames[$treenum]." build to install server at ".&gettimestr()." ***");
  338. &mymkdir($inst_dirs[$treenum]);
  339. my $xcopy_opt_str="/E /K /C /R /Y /H ";
  340. if($DEBUG_TREECOPY) {
  341. $xcopy_opt_str.="/T"; #debug only
  342. }
  343. # hopefully there are no extra dirs underneath
  344. foreach my $dir1 (@dirstodolist) {
  345. &mymkdir($inst_dirs[$treenum]."\\".$dir1);
  346. &myexecstr("xcopy ".$xcopy_opt_str." ".$WINBLDROOT."\\".$dir1."\\* ".$inst_dirs[$treenum]."\\".$dir1,
  347. "xcopy of ".$inst_dirnames[$treenum]." tree failed!!", "DO_LOG","NT cmd");
  348. }
  349. }
  350. # assumes environment already attached to TOOL/PANDA/DIRECT/TOONTOWN
  351. # assumes cygwin env, BLDROOT must use fwd slashes
  352. if($ENV{'BLDROOT'} eq "") {
  353. $ENV{'BLDROOT'} = "/home/builder/player";
  354. }
  355. if($ENV{'CYGWIN_ROOT'} eq "") {
  356. $ENV{'CYGWIN_ROOT'} = "C:\\Cygwin";
  357. }
  358. $CYGROOT= $ENV{'CYGWIN_ROOT'};
  359. $CYGROOT =~ s/(.*)\\$/$1/; # get rid of trailing '\'
  360. #$CYGROOT =~ s/\\/\//g; # switch backslash to fwdslash (setting up for cygwin)
  361. $CYGBLDROOT = $ENV{'BLDROOT'};
  362. print "\$CYGBLDROOT='",$CYGBLDROOT,"'\n";
  363. if(($CYGBLDROOT eq "")||(!(-e $CYGBLDROOT))) {
  364. die "Bad \$CYGBLDROOT !!\n";
  365. }
  366. $WINBLDROOT=$CYGROOT.$CYGBLDROOT;
  367. $WINBLDROOT =~ s/\//\\/g; # switch fwdslash to backslash
  368. print "\$WINBLDROOT='",$WINBLDROOT,"'\n";
  369. my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time);
  370. $mon++;
  371. $logfilenamebase="bldlog-".($mon<10 ? "0":"").$mon."-".($mday<10 ? "0":"").$mday.".txt";
  372. $fulllogfilename = $CYGBLDROOT."/".$logfilenamebase;
  373. $fulllogfilename_win = $WINBLDROOT."\\".$logfilenamebase;
  374. # recreate the log to blow away any old one
  375. open(LOGFILE,">".$fulllogfilename) || die "can't open log file '$fulllogfilename'\n";
  376. close(LOGFILE);
  377. &logmsg("*** Panda Build Log Started at ".&gettimestr()." ***");
  378. my @do_install_dir=(1,1,1,1);
  379. if($#ARGV>=0) {
  380. @do_install_dir=(0,0,0,0);
  381. if($ARGV[0] eq $inst_dirnames[$INSTALLNUM]) {
  382. $do_install_dir[$INSTALLNUM]=1;
  383. } elsif($ARGV[0] eq $inst_dirnames[$DEBUGNUM]) {
  384. $do_install_dir[$DEBUGNUM]=1;
  385. } elsif($ARGV[0] eq $inst_dirnames[$RELEASENUM]) {
  386. $do_install_dir[$RELEASENUM]=1;
  387. } else {
  388. &logmsg("invalid argument '".$ARGV[0]."' to builder.pl. arg must be 'install','debug', or 'release'\n");
  389. exit(1);
  390. }
  391. }
  392. if(!(-e $WIN_INSTALLDIR)) {
  393. &logmsg("ERROR: Cant access install directory!! ".$WIN_INSTALLDIR);
  394. exit(1);
  395. }
  396. &mychdir($CYGBLDROOT);
  397. # remove all old files (remove every file except for dirs and CVS files and bldlog*)
  398. # and grab every file clean from CVS
  399. if($BLD_DTOOL_ONLY) {
  400. @dirstodolist=("dtool");
  401. } else {
  402. @dirstodolist=("dtool","panda","direct","toontown");
  403. }
  404. $dirstodostr="";
  405. foreach my $dir1 (@dirstodolist) {
  406. $dirstodostr.=$dir1." ";
  407. }
  408. # makes ppremake build headers, libs in module dirs (panda/lib,dtool/bin,etc), not /usr/local/panda/inc...
  409. foreach my $dir1 (@dirstodolist) {
  410. my $dir1_upcase = uc($dir1);
  411. $ENV{$dir1_upcase}=$CYGBLDROOT."/".$dir1;
  412. # need this since we are building in src dirs, not install dir
  413. # so 'interrogate' needs to find its dlls when building panda, etc
  414. &appendpath("/".$dir1."/bin","/".$dir1."/lib");
  415. }
  416. # pick up cygwin utils
  417. $ENV{'PATH'}="/bin".$DIRPATH_SEPARATOR."/contrib/bin".$DIRPATH_SEPARATOR.$ENV{'PATH'};
  418. # want build to pick up python dll's from /usr/lib before /c/python16
  419. $ENV{'PATH'}="/usr/lib".$DIRPATH_SEPARATOR.$ENV{'PATH'};
  420. if($DEBUG_TREECOPY) {
  421. goto 'DBGTREECOPY';
  422. }
  423. if($DEBUG_GENERATE_PYTHON_CODE_ONLY) {
  424. &gen_python_code();
  425. exit(0);
  426. }
  427. # goto 'SKIP_REMOVE';
  428. SKIP_REMOVE:
  429. # this doesnt work unless you can completely remove the dirs, since cvs checkout
  430. # bombs if dirs exist but CVS dirs do not.
  431. if($do_install_dir[$INSTALLNUM]) {
  432. $ENV{'PANDA_OPTIMIZE'}='2';
  433. &buildall($INSTALLNUM);
  434. }
  435. BEFORE_DBGBUILD:
  436. if($do_install_dir[$DEBUGNUM]) {
  437. $ENV{'USE_BROWSEINFO'}='1'; # make .sbr files, this is probably obsolete
  438. if(! $DEBUG_GENERATE_PYTHON_CODE_ONLY) {
  439. $ENV{'PANDA_OPTIMIZE'}='1';
  440. }
  441. &buildall($DEBUGNUM);
  442. &make_bsc_file();
  443. delete $ENV{'USE_BROWSEINFO'}; # this is probably obsolete
  444. }
  445. AFTER_DBGBUILD:
  446. if($do_install_dir[$RELEASENUM]) {
  447. $ENV{'PANDA_OPTIMIZE'}='3';
  448. &buildall($RELEASENUM);
  449. }
  450. &logmsg("*** Panda Build Log Finished at ".&gettimestr()." ***");
  451. # store log in 'debug' dir
  452. &myexecstr("copy ".$fulllogfilename_win." ".$inst_dirs[$DEBUGNUM], "copy of ".$fulllogfilename_win." failed!!", "","NT cmd");
  453. exit(0);
  454. # TODO:
  455. # compress old archived blds?
  456. # build DLLs with version stamp set by this script
  457. # implement build-specific opttype mode