Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
6.5 KiB

  1. # BuildComponent.pm
  2. #
  3. # created: 4/02/99
  4. # 7/21/99 - return value is 2 if update build not needed
  5. package main;
  6. if (!$__IITBUILDPM ) { use iit::build; }
  7. sub BuildComponent
  8. {
  9. my $cmdNMake = "nmake -nologo -x-";
  10. my $rc = 1;
  11. my @buildlist = ();
  12. my $strTargets = "";
  13. my $sName = "";
  14. my $bNotNeeded = 0;
  15. PrintL("buildcomp(@_)\n", PL_VERBOSE);
  16. # process arguments
  17. foreach $i (@_)
  18. {
  19. if (uc($i) eq "-D" or uc($i) eq "DEBUG")
  20. {
  21. @buildlist = (@buildlist, "DEBUG");
  22. }
  23. elsif (uc($i) eq "-P" or uc($i) eq "PROFILE")
  24. {
  25. # ignore profile requests on non-x86 machines
  26. if ($ENV{"PROCESSOR_ARCHITECTURE"} eq "x86")
  27. {
  28. @buildlist=(@buildlist, "PROFILE");
  29. }
  30. }
  31. elsif (uc($i) eq "-S" or uc($i) eq "-R" or uc($i) eq "RELEASE")
  32. {
  33. @buildlist=(@buildlist, "RELEASE");
  34. }
  35. elsif (uc($i) eq "BVT")
  36. {
  37. $strTargets .= " bvt";
  38. }
  39. elsif ($i =~ /\=/)
  40. {
  41. $cmdNMake .= ' '.$i;
  42. }
  43. elsif ($i =~ /\w+.mak/)
  44. {
  45. $cmdNMake .= " -f ".$i;
  46. }
  47. elsif ($i eq "")
  48. {
  49. }
  50. elsif ($sName eq "")
  51. {
  52. $sName = $i;
  53. }
  54. else
  55. {
  56. $strTargets .= " $i";
  57. }
  58. }
  59. if ($bVerbose)
  60. {
  61. $strTargets .= " VERBOSE=1";
  62. }
  63. if (not defined $sName)
  64. {
  65. $sName = "Unknown Component";
  66. }
  67. if ($strLanguage ne "")
  68. {
  69. $cmdNMake .= " LANGUAGE=".uc($strLanguage);
  70. }
  71. local @faillist=();
  72. if ($#buildlist < 0)
  73. { #if no targets, use a blank one
  74. @buildlist=(" ");
  75. }
  76. foreach $buildtype (@buildlist)
  77. {
  78. $targetname = "$strLanguage $sName $buildtype";
  79. PrintLTip("\n"."#" x (39 - ((length($targetname) + (length($targetname) % 2)) / 2)).
  80. ' '.$targetname.' '."#" x (39 - ((length($targetname) - (length($targetname) % 2)) / 2))."\n\n",
  81. "Build Directory: ".cwd(),
  82. PL_GREEN | PL_FLUSH);
  83. BEGIN_DHTML_NODE("(click to expand)");
  84. my $startTime = time();
  85. my $strMsg = "";
  86. PrintL($cmdNMake." BUILDTYPE=".$buildtype.$strTargets."\n", PL_BOLD);
  87. eval
  88. {
  89. if ($bUpdate)
  90. {
  91. open (NMAKEIN, $cmdNMake." BUILDTYPE=".$buildtype." -q".$strTargets.' 2>&1 |');
  92. while(<NMAKEIN>)
  93. {
  94. PrintL($_);
  95. }
  96. close(NMAKEIN);
  97. if ($CHILD_ERROR)
  98. {
  99. PrintL("Clean build needed, at least one of dependency has changed\n (see $sUpdateLog for details)\n");
  100. ExecuteAndOutputToFile($cmdNMake." BUILDTYPE=".$buildtype." -nd".$strTargets, $sUpdateLog, 0, 1);
  101. open (NMAKEIN, $cmdNMake." BUILDTYPE=".$buildtype." clean" . ' 2>&1 |');
  102. while(<NMAKEIN>)
  103. {
  104. PrintL($_);
  105. }
  106. close(NMAKEIN);
  107. if ($CHILD_ERROR) #must not have a clean build, do it manually
  108. {
  109. Delnode($buildtype);
  110. }
  111. }
  112. else
  113. {
  114. $bNotNeeded = 1;
  115. PrintL("Skipping ".$targetname." - not needed\n");
  116. END_DHTML_NODE();
  117. next; # skip this build - not needed
  118. }
  119. }
  120. $bNotNeeded = 0;
  121. $bNothingDone = 0;
  122. if ($bcStatus & BC_NOTHINGDONE)
  123. {
  124. $bcStatus -= BC_NOTHINGDONE;
  125. }
  126. ++$nTotalBuilds;
  127. open (NMAKEIN, "$cmdNMake BUILDTYPE=$buildtype$strTargets" . ' 2>&1 |');
  128. while(<NMAKEIN>)
  129. {
  130. PrintL($_);
  131. if
  132. ( /: (error|fatal error|info|information|assert)(,| )/i ||
  133. (/: warning(,| )/i &&
  134. !(/different attributes \(40000040\)/ ||
  135. /glang\.cpp\(\d+\) : warning C410(1|2)/ || # gtran warnings from pccts stuff
  136. /LINK : warning LNK4089/ # discarded by /OPT:REF
  137. )
  138. ) ||
  139. /\*\*\* (Error|Warning|Info): /i ||
  140. ( /WARNING: /i &&
  141. !( /^mkdep: warning: ignoring line : \#include / # pccts stuff
  142. || m/OffInst: warning: The binary .* is emitted by BBT/ # can't do anything about this warning
  143. )
  144. ) ||
  145. # format of error from cmp
  146. / differ: char / ||
  147. # c compiler has certain errors formatted like this
  148. /^error C[1-4]\d{3}: /
  149. )
  150. {
  151. $strMsg .= $_;
  152. }
  153. }
  154. close(NMAKEIN);
  155. };
  156. END_DHTML_NODE();
  157. PrintL("\n");
  158. my($stopTime) = time();
  159. my($sDiff) = FmtDeltaTime($stopTime - $startTime);
  160. if ($CHILD_ERROR)
  161. {
  162. $rc = 0;
  163. ++$nFailedBuilds;
  164. PrintLTip($targetname." FAILED\n\n", "Build Time: ".$sDiff,
  165. PL_BIGERROR);
  166. @faillist=(@faillist, substr $buildtype, 0, 1);
  167. }
  168. else
  169. {
  170. PrintLTip($targetname." Succeeded\n\n", "Build Time: ".$sDiff,
  171. PL_NOTAG | PL_MSG | PL_GREEN);
  172. }
  173. if ($strMsg ne "")
  174. {
  175. PrintMsgBlock(split(/\n/, $strMsg));
  176. }
  177. if (!$rc && IsCritical())
  178. {
  179. $bcStatus |= &BC_FAILED;
  180. $bBuildFailed = 1;
  181. if ($bDieOnError)
  182. {
  183. BuildDie("\nBuild failed, exiting build ...\n(don't use HALT parameter if you wish to continue building after failures)\n\n");
  184. }
  185. }
  186. }
  187. PrintL("BuildComponent returns $rc\n", PL_VERBOSE);
  188. if ($rgstrBuildResults{$sName} ne "")
  189. {
  190. $rgstrBuildResults{$sName} .= ", ";
  191. }
  192. if ($bAddLanguageString)
  193. {
  194. $rgstrBuildResults{$sName} .= "$strLanguage: ";
  195. }
  196. $rgstrBuildResults{$sName} .= $rc ?
  197. "<font color=green>OK</font>" :
  198. "<b><font color=red>@faillist FAIL</font></b>";
  199. if ($bNotNeeded)
  200. {
  201. $rc = 2;
  202. }
  203. return($rc);
  204. }
  205. $__IITBUILDCOMPONENTPM = 1;
  206. 1;