Leaked source code of windows server 2003
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.

164 lines
4.5 KiB

  1. // This is an includefile containing the common
  2. // stuff for slave.js and task.js
  3. // Static Defintions
  4. var g_strAbortTask = 'ATaskAbort';
  5. var g_strStepAck = 'StepAck';
  6. var g_strRootDepotName = 'root';
  7. var g_strMergedDepotName = 'mergedcomponents';
  8. // These are bitfield flags. Values should be 1,2,4,8,...
  9. var RAZOPT_PERSIST = 1;
  10. var RAZOPT_SETUP = 2;
  11. var WAITANDABORTDEBUGTIMEOUT = (1000 * 60 * 10); // 10 minutes
  12. function MakeRazzleCmd(strSDRoot, nOptions)
  13. {
  14. var strBuildType;
  15. var strBuildPlatform;
  16. var strRazzleParams;
  17. var fIsLab;
  18. var fOfficialBuild;
  19. var strCmd;
  20. var strPersistFlag = '/c ';
  21. // nOptions is an optional argument, so we have to make sure it's not 'undefined'
  22. if (!nOptions)
  23. {
  24. nOptions = 0;
  25. }
  26. if (nOptions & RAZOPT_PERSIST)
  27. {
  28. strPersistFlag = '/k ';
  29. }
  30. //
  31. // Construct the standard portion of the cmd to be issued
  32. //
  33. strCmd = 'cmd ' + strPersistFlag + strSDRoot + '\\Tools\\razzle.cmd';
  34. // Get the build options
  35. // Required template fields
  36. strBuildType = PrivateData.objConfig.Options.BuildType;
  37. strBuildPlatform = PrivateData.objConfig.Options.Platform;
  38. fOfficialBuild = PrivateData.objConfig.PostBuild.fOfficialBuild;
  39. fIsLab = PrivateData.objEnviron.Options.fIsLab;
  40. if (PrivateData.objConfig.Options.RazzleParams)
  41. strCmd += ' ' + PrivateData.objConfig.Options.RazzleParams;
  42. if (PrivateData.objEnviron.Options.BinariesDir)
  43. strCmd += ' binaries_dir ' + PrivateData.objEnviron.Options.BinariesDir;
  44. // Construct the remainder of the razzle command.
  45. if (strBuildPlatform.IsEqualNoCase('64bit')) {
  46. strCmd += ' win64';
  47. }
  48. if (strBuildType.IsEqualNoCase('free')) {
  49. strCmd += ' free';
  50. }
  51. if (fIsLab && fOfficialBuild)
  52. {
  53. strCmd += ' officialbuild';
  54. }
  55. // Add other misc. options to the razzle cmd and run sdinit.
  56. if (!(nOptions & RAZOPT_SETUP))
  57. {
  58. strCmd = strCmd + ' no_certcheck no_sdrefresh';
  59. }
  60. strCmd = strCmd + ' no_title & sdinit';
  61. return strCmd;
  62. }
  63. function AppendToFile(file, strFileName, strText)
  64. {
  65. try
  66. {
  67. if (!file)
  68. {
  69. file = g_FSObj.OpenTextFile(strFileName,
  70. 8 /* Append */,
  71. true /* Create if it does not exist */);
  72. file.WriteLine(strText);
  73. file.Close();
  74. }
  75. else // Append to already open file.
  76. file.WriteLine(strText);
  77. LogMsg("Append to file '" + strFileName + "', text: '" + strText);
  78. }
  79. catch(ex)
  80. {
  81. //LogMsg("Failed to append to file '" + strFileName + "', text: '" + strText + "' " + ex);
  82. SimpleErrorDialog("Logfile Error",
  83. "While reporting an error, another error occurred appending to the logfile '" +
  84. strFileName +
  85. "'\nOriginal Error Message: '" + strText + "\n" + ex, false);
  86. }
  87. }
  88. function WaitForMultipleSyncsWrapper(strSyncs, nTimeOut)
  89. {
  90. var nMyTimeOut = 0;
  91. var nRetryCount = 0;
  92. var nEvent;
  93. // LogMsg('Waiting for ' + strSyncs + ', timeout is ' + nTimeOut, 1);
  94. if (nTimeOut == 0)
  95. {
  96. do
  97. {
  98. nMyTimeOut = (nRetryCount > 0) ? 0 : WAITANDABORTDEBUGTIMEOUT;
  99. nEvent = WaitForMultipleSyncs(strSyncs, false, nMyTimeOut);
  100. if (nEvent == 0)
  101. {
  102. LogMsg("WaitAndAbort(" + strSyncs + ") Wait time has exceeded 10 min...");
  103. nRetryCount++;
  104. }
  105. }
  106. while (nEvent == 0);
  107. if (nRetryCount > 0)
  108. {
  109. LogMsg("WaitAndAbort(" + strSyncs + ") done waiting. (signal=" + nEvent + ")");
  110. }
  111. }
  112. else
  113. nEvent = WaitForMultipleSyncs(strSyncs, false, nTimeOut);
  114. return nEvent;
  115. }
  116. /*
  117. SetSuccess(objTask, fSuccess)
  118. Set the fSuccess field of the given task.
  119. We also must make sure that our StatusValue(0)
  120. is kept in sync with changes to all of the task
  121. fSuccess fields.
  122. We cannot directly set StatusValue(0)=true -- we must
  123. scan all tasks fSuccess - so we just signal the update
  124. thread to do this for us.
  125. */
  126. function SetSuccess(objTask, fSuccess)
  127. {
  128. objTask.fSuccess = fSuccess;
  129. SignalThreadSync('updatestatusvaluenow');
  130. if (!fSuccess)
  131. {
  132. PublicData.aBuild[0].hMachine[g_MachineName].fSuccess = fSuccess;
  133. StatusValue(0) = false;
  134. }
  135. }