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.

193 lines
6.0 KiB

  1. if (!$__SPGBUILDPM ) { use spg::build; }
  2. sub BuildCABs($$)
  3. {
  4. # SEDfile (no ext) => dropDirTarget
  5. # keep release and debug separate (order is important, watch the targetnames)
  6. @lCABs =
  7. (
  8. # "voices => ",
  9. # "lexicons => ",
  10. "srd1033 => ".$sDropDir."\\srd1033.exe",
  11. "srd1041 => ".$sDropDir."\\srd1041.exe",
  12. "srd2052 => ".$sDropDir."\\srd2052.exe",
  13. # RELEASE:
  14. # "mscsr5r => ".$sDropDir."\\release\\cab\\".PROC."\\mscsr5.exe",
  15. # "mscsr5rq => ".$sDropDir."\\release\\cab\\".PROC."\\mscsr5q.exe",
  16. # "sapi5_r => ".$sDropDir."\\release\\cab\\".PROC."\\sapi5sym.exe",
  17. # "sapi5sdk_r => ".$sDropDir."\\release\\cab\\".PROC."\\sapi5sdk.exe",
  18. # "sapi5rt => ".$sDropDir."\\release\\cab\\".PROC."\\sapi5.exe",
  19. # "sapi5all_r => ".$sDropDir."\\release\\cab\\".PROC."\\sapi5all.exe",
  20. # "sapi5all_rq => ".$sDropDir."\\release\\cab\\".PROC."\\sapi5allq.exe",
  21. # DEBUG:
  22. # "mscsr5d => ".$sDropDir."\\debug\\cab\\".PROC."\\mscsr5.exe",
  23. # "sapi5_d => ".$sDropDir."\\debug\\cab\\".PROC."\\sapi5sym.exe",
  24. # "sapi5sdk_d => ".$sDropDir."\\debug\\cab\\".PROC."\\sapi5sdk.exe",
  25. # "sapi5all_d => ".$sDropDir."\\debug\\cab\\".PROC."\\sapi5all.exe",
  26. );
  27. local($sIniFile, $sTargetDir) = @_;
  28. my($rc) = 1;
  29. PushD($SAPIROOT);
  30. # ************* formerly precab.cmd ***************
  31. local(%hRenamedCABFiles) = ParseCabIni($sIniFile);
  32. foreach $key (keys(%hRenamedCABFiles))
  33. {
  34. EchoedCopy($SAPIROOT."\\".$key, $SAPIROOT."\\".$hRenamedCABFiles{$key});
  35. SetReadOnly($SAPIROOT."\\".$hRenamedCABFiles{$key}, 0);
  36. }
  37. # ************* formerly bldcabs.cmd ***************
  38. PrintL("\nBuilding SAPI 5 cabpacks\n\n", PL_LARGE | PL_BOLD);
  39. PrintL("\nInitializing...\n\n", PL_BOLD);
  40. Delnode($sTargetDir);
  41. EchoedMkdir($sTargetDir);
  42. PrintL("\nMaking certification ...\n\n", PL_BOLD);
  43. local($sCertFile) = $sTargetDir."\\sapikey.cer";
  44. local($sSpcFile) = $sTargetDir."\\sapikey.spc";
  45. unlink($sCertFile, $sSpcFile);
  46. $rc = Execute($cmdMakeCert.' -u:SAPIKey -n:CN="Microsoft Corporation" '.$sCertFile) && $rc;
  47. $rc = Execute($cmdCert2Spc.' '.$sCertFile.' '.$sSpcFile) && $rc;
  48. PushD($sTargetDir);
  49. PrintL("\nBuilding and Digitally signing cabpacks ...\n\n", PL_BOLD);
  50. local(@lSEDFiles) = ();
  51. foreach $elem (@lCABs)
  52. {
  53. my($sSEDFile, $sDestFile) = split(/\s*=>\s*/, $elem);
  54. my($sCABName) = "";
  55. my($fhIn) = OpenFile($SAPIROOT."\\build\\".$sSEDFile.".sed", "read");
  56. if ($fhIn)
  57. {
  58. my($fhOut) = OpenFile($sTargetDir."\\".$sSEDFile.".sed", "write");
  59. while(!$fhIn->eof())
  60. {
  61. my($text) = $fhIn->getline();
  62. if ($text =~ /^TARGETNAME=/i)
  63. {
  64. $text =~ s/d:\\sapi5\\build/$sTargetDir/i;
  65. my($tmp) = $text;
  66. $tmp =~ s/^TARGETNAME=//i;
  67. chomp($tmp);
  68. $sCABName = $tmp;
  69. }
  70. elsif ($text =~ /^FILE.*\.inf/)
  71. {
  72. my($inf) = $text;
  73. $inf =~ s/^[^\"]*\"([^\"]*)\"(.|\s)*$/$1/;
  74. EchoedCopy($SAPIROOT."\\build\\".$inf, $sTargetDir."\\".$inf);
  75. }
  76. else
  77. {
  78. $text =~ s/d:\\sapi5\\build/$sTargetDir/ig;
  79. $text =~ s/d:\\sapi5\\Src\\SR\\bin\\(\s)/$sTargetDir\\$1/ig;
  80. $text =~ s/d:\\sapi5/$SAPIROOT/ig;
  81. }
  82. $fhOut->print($text);
  83. }
  84. CloseFile($fhIn);
  85. CloseFile($fhOut);
  86. }
  87. else
  88. {
  89. PrintL("Error: could not read ".$sSEDFile.".sed, cannot create cab\n", PL_ERROR);
  90. }
  91. if (Execute($cmdIExpress.' /n /q '.$sTargetDir."\\".$sSEDFile.".sed"))
  92. {
  93. my($pDigSign) = SpawnProcess($cmdSignCode, '-spc "'.$sSpcFile.'" -'.(IsAlpha() ? 'v "'.$sCertFile.'"' : 'pvk "SAPIKey"').
  94. ' -prog "'.$sCABName.'" -name "Microsoft SAPI 5.0" -info "http://www.microsoft.com/iit"');
  95. if ($pDigSign)
  96. {
  97. $pDigSign->Wait(60000); #shouldn't take longer than 1 minute
  98. $pDigSign->Kill(1);
  99. }
  100. if (!$bNoCopy)
  101. {
  102. if (($sCABName ne "") && ($sDestFile ne ""))
  103. {
  104. EchoedCopy($sCABName, $sDestFile);
  105. }
  106. }
  107. }
  108. else
  109. {
  110. $rc = 0;
  111. }
  112. }
  113. PopD(); #$sTargetDir
  114. # ************* formerly postcab.cmd ***************
  115. foreach $key (keys(%hRenamedCABFiles))
  116. {
  117. EchoedUnlink($SAPIROOT."\\".$hRenamedCABFiles{$key});
  118. }
  119. PopD(); #$SAPIROOT
  120. return($rc);
  121. }
  122. sub ParseCabIni($)
  123. {
  124. my(%hIniHash) = ();
  125. my($fhIni) = OpenFile($_[0], "read");
  126. if ($fhIni)
  127. {
  128. my($curLine) = 0;
  129. my($curText) = "";
  130. my($dir) = "";
  131. while (!$fhIni->eof())
  132. {
  133. $curText = $fhIni->getline();
  134. ++$curLine;
  135. $curText =~ s/^\s*//;
  136. chomp($curText);
  137. if (($curText =~ /^#/) || ($curText eq ""))
  138. {
  139. }
  140. elsif ($curText =~ /^\[.*\]/)
  141. {
  142. $dir = $curText;
  143. $dir =~ s/^\[([^\]]*)\]/$1/;
  144. }
  145. else
  146. {
  147. local(@lFiles) = split(/\-\>/, $curText);
  148. if (scalar(@lFiles) != 2)
  149. {
  150. PrintL("Error parsing ".$_[0].", line ".$curLine.": Invalid syntax\n", PL_BIGERROR);
  151. }
  152. else
  153. {
  154. %hIniHash = (%hIniHash, $dir."\\".$lFiles[0] => $dir."\\".$lFiles[1]);
  155. }
  156. }
  157. }
  158. }
  159. return(%hIniHash);
  160. }
  161. $__BUILDCABSPM = 1;
  162. 1;