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.

1656 lines
54 KiB

  1. @perl -x -w %0 %PROCESSOR_ARCHITECTURE% %*
  2. @goto :eof
  3. #!perl
  4. # line 5
  5. ################################################################################
  6. # 05-Jun-00 : skupec: Add fail safes to avoid hangs in post build
  7. # 1) delete all old lock files before we start
  8. # 2) set max. wait limit for new process to 30*2 seconds
  9. #
  10. # 01-Jul-00 : skupec: Convert to use Win32::Process to avoid sporadic hangs
  11. # that are showing up in postbuild.
  12. #
  13. # 10-Nov-00 : skupec: Add Verbose mode
  14. # No longer use \lib[fre|chk]\%arch%. Now just \lib\%arch%
  15. #
  16. # 11-Jan-01 : skupec: Don't ship checked versions of the tools.
  17. #
  18. # 10-Feb-01 : skupec: Create per-architecture cabs for tools. Instead of just
  19. # TOOL_*.cab, we now also have TOOL_*x.cab and TOOL_*i.cab
  20. # (x86/ia64 respectively) IFF per-arch directories exist
  21. # when cabbing is done. TOOL_*.cab should still be the
  22. # primary cab in cabs.ini so a single checkbox will install
  23. # on either platform.
  24. #
  25. # 27-Feb-01 : skupec: Modify the cabbing of \incs to properly handle the new
  26. # platform specific subdir layout.
  27. #
  28. # 04-Apr-01 : skupec: Add cabbing of legacy libs for Win2K DDK env
  29. #
  30. # 17-May-01 : skupec: Add DDK_DBG[i|x] cabs only on CHK builds
  31. #
  32. # 29-Sep-01 : skupec: Move OS specific files from WXP to WNET. ($OS_SUBDIR)
  33. #
  34. # 21-Jan-02 : skupec: Only make %_BUILDARCH%dbins cabs on %_BUILDARCH%
  35. #
  36. # 28-Jan-02 : skupec: Support IA-64 native tools as well as cross compiler tools
  37. #
  38. # 09-Apr-02 : skupec: Remove dup files from tools cabs. Add AMD64 support.
  39. #
  40. # 03-Jun-02 : skupec: Improve support for picking backports to legacy OSes
  41. #
  42. use lib $ENV{RAZZLETOOLPATH} . '\\postbuildscripts';
  43. use BuildName;
  44. my $ProcArc = shift;
  45. # Only accept one parameter which must be numeric
  46. my ($numproc, $lpCount, $force, $spoof,$verbose) = (2,0,0,0,0);
  47. my $OS_SUBDIR = "wnet";
  48. for ($lpCount=0; $lpCount <= ($#ARGV); $lpCount++) {
  49. SWITCH: {
  50. if ((substr($ARGV[$lpCount],0,1) eq "-") or (substr($ARGV[$lpCount],0,1) eq "/")) {
  51. for ($i=1;$i<length($ARGV[$lpCount]);$i++) {
  52. exit(Usage()) if uc(substr($ARGV[$lpCount],$i,1)) eq "?";
  53. exit(Usage()) if uc(substr($ARGV[$lpCount],$i,1)) eq "H";
  54. if (uc substr($ARGV[$lpCount],$i,1) eq "L") {
  55. if ($ARGV[$lpCount] =~ /:+(.*)/) {
  56. if ((defined $1) and ($1 ne "")) { # handle -l:<language>
  57. $lang = $1;
  58. } else { # handle -l: where language was forgotten
  59. $lang = "usa";
  60. }
  61. $ARGV[$lpCount] =~ s/:+(.*)//;
  62. } elsif (defined $ARGV[$lpCount+1]) { # handle -l <language>
  63. $lang = $ARGV[$lpCount+1];
  64. splice(@ARGV,$lpCount+1,1);
  65. } else { # handle -l where language was forgotten
  66. $lang = "usa"; # default
  67. }
  68. unless (uc $lang eq "USA") { # only execute on USA
  69. exit 0;
  70. }
  71. next;
  72. } elsif (uc substr($ARGV[$lpCount],$i,1) eq "N") {
  73. if (defined($ARGV[$lpCount+1]) and ($ARGV[$lpCount+1] =~ /^\d*$/)) {
  74. $numproc=$ARGV[$lpCount+1];
  75. splice(@ARGV,$lpCount+1,1);
  76. } else {
  77. exit(Usage());
  78. }
  79. } elsif (uc substr($ARGV[$lpCount],$i,1) eq "F") {
  80. $force = 1;
  81. } elsif (uc substr($ARGV[$lpCount],$i,1) eq "S") {
  82. $spoof = 1;
  83. } elsif (uc substr($ARGV[$lpCount],$i,1) eq "V") {
  84. $verbose = 1;
  85. } else {
  86. print("-",substr($ARGV[$lpCount],$i,1)," switch ignored. Use '-?' or '-h' to get usage.\n");
  87. }
  88. }
  89. } else {
  90. print("$ARGV[$lpCount] argument ignored.\n");
  91. }
  92. 1; #Last line should do nothing
  93. }
  94. }
  95. if ($spoof) {
  96. # Create %_NTTREE%/build_logs to hold the generated BuildName.txt file.
  97. mkdir ("$ENV{_NTTREE}/build_logs", 0);
  98. # Create & write the BuildName.txt file.
  99. open (BLDNAME, ">$ENV{_NTTREE}/build_logs/BuildName.txt")
  100. || die "Couldn't open $ENV{_NTTREE}/build_logs/BuildName.txt for writing.\n";
  101. # Write out the build number.
  102. chop ($_ = `getbldno.cmd`);
  103. print BLDNAME "$_.";
  104. # Write out the build type.
  105. print BLDNAME "$ENV{_BuildArch}$ENV{_BuildType}.";
  106. # Write out the build branch.
  107. print BLDNAME "$ENV{_BuildBranch}.";
  108. # Write out the build time. Note that the year value [5] is years since
  109. # 1900, and the month [4] is 0..11.
  110. @_ = localtime(time);
  111. printf BLDNAME "%02u%02u%02u-%02u%02u\n",
  112. $_[5] - 100, $_[4] + 1, $_[3], $_[2], $_[1];
  113. close BLDNAME;
  114. }
  115. # Only build if (1) -f is passed, (2) %OFFICIAL_BUILD_MACHINE% is set, or (3) %__BUILDMACHINE__% == LB6RI
  116. if (! defined $ENV{OFFICIAL_BUILD_MACHINE} && (! $force) && (uc($ENV{__BUILDMACHINE__}) ne "LB6RI") ) {
  117. print STDERR "Not building because this isn't an official build machine. Use -f to force.\n";
  118. exit 0;
  119. };
  120. system("title PB_ddkcabs.bat"); # Required by postbuild. Do not remove.
  121. print(STDERR "$0: Started. ");
  122. use strict;
  123. # use Win32;
  124. use Win32::Process;
  125. # Set %temp% as working directory
  126. Win32::SetCwd $ENV{Temp};
  127. my $time = time();
  128. my $hLogFile;
  129. my $handle;
  130. ################################################################################
  131. #
  132. # Create .tmp file so postbuild.cmd knows we're running.
  133. #
  134. ################################################################################
  135. open (hLogFile, ">$ENV{TEMP}\\ddkcabs.tmp") || die("Can't open $ENV{TEMP}\\ddkcabs.tmp for writing: $!\n");
  136. print (hLogFile "1");
  137. close (hLogFile);
  138. ################################################################################
  139. #
  140. # Find the correct logfile to use
  141. #
  142. ################################################################################
  143. # Either use the defined log file
  144. if (defined $ENV{LOGFILE}) {
  145. $handle="$ENV{LOGFILE}";
  146. # or use our default log file.
  147. } else {
  148. $handle="$ENV{TEMP}\\ddkcabs.log";
  149. }
  150. print(STDERR "Writing log to $handle.\n");
  151. ################################################################################
  152. #
  153. # Test for all conditions that require us to terminate early.
  154. #
  155. ################################################################################
  156. # If %_DDK_NOCAB% is defined, don't make CABS
  157. if (defined $ENV{_DDK_NOCAB} ) {
  158. logmsg("_DDK_NOCAB is set. Not making CABS.");
  159. unlink("$ENV{TEMP}\\ddkcabs.tmp");
  160. exit(0);
  161. }
  162. # If any of the needed environment variables aren't defined, output an
  163. # error and abort the cabbing process
  164. foreach ("_NTDRIVE","_NTROOT","_BUILDARCH","_BUILDTYPE","_NTTREE","RazzleToolPath","PROCESSOR_ARCHITECTURE","NUMBER_OF_PROCESSORS") {
  165. unless (defined $ENV{$_}) {
  166. logerror("Aborting: \%$_\% is not defined.");
  167. unlink("$ENV{TEMP}\\ddkcabs.tmp");
  168. exit(0);
  169. }
  170. }
  171. # Don't build on AXP64 or Alpha
  172. if ($ENV{_BuildArch} =~ /^(axp64|alpha)/i) {
  173. unlink("$ENV{TEMP}\\ddkcabs.tmp");
  174. logmsg("DDK unsupported on $ENV{_BuildArch}. Exiting.");
  175. exit(0);
  176. }
  177. ################################################################################
  178. #
  179. # Global Variables
  180. #
  181. ################################################################################
  182. my $bldno = build_number;
  183. logdebug("$numproc processes per processor");
  184. my $MAX_PROCESSES = $ENV{NUMBER_OF_PROCESSORS}*$numproc;
  185. my @Processes;
  186. my $exe = "$ENV{WINDIR}\\system32\\cmd.exe";
  187. my $global_param = " /c start /min /wait cabarc.exe -s 6144 -m lzx:21 -i 1 N ";
  188. my $INCREMENTAL = 0; # Full build by default
  189. my %MAKECAB;
  190. my @dir_list1;
  191. my @dir_list2;
  192. my $dir;
  193. my $dir2;
  194. my $file;
  195. my $cabname;
  196. my $samplename;
  197. my $friendlyname;
  198. my $kit;
  199. my $i;
  200. sub TRUE {return(1);} # BOOLEAN TRUE
  201. sub FALSE {return(0);} # BOOLEAN FALSE
  202. my $CABDEBUG = FALSE;
  203. $CABDEBUG = TRUE if (defined($ENV{_CABDEBUG}));
  204. my $bindir;
  205. my $sdkincs = "$ENV{_NTTREE}\\ddk_flat\\inc";
  206. # Directory to look for .lib's in
  207. my $libdir = "lib\\$OS_SUBDIR";
  208. if (uc($ENV{_BuildArch}) eq "IA64") {
  209. $libdir .= "\\ia64";
  210. } elsif (uc($ENV{_BuildArch}) eq "AMD64") {
  211. $libdir .= "\\amd64";
  212. } else {
  213. $libdir .= "\\i386";
  214. }
  215. ################################################################################
  216. #
  217. # Determine if we should build incrementally
  218. #
  219. ################################################################################
  220. if ( -e "$ENV{_NTTREE}\\build_logs\\bindiff.txt" ) {
  221. $INCREMENTAL = TRUE;
  222. open(hFile, "$ENV{_NTTREE}\\build_logs\\bindiff.txt");
  223. @dir_list1 = <hFile>;
  224. close(hFile);
  225. # Pass over the array of changed files once and determine which CABs
  226. # need re-built.
  227. foreach $file (@dir_list1) {
  228. # Ignore files we don't care about.
  229. next unless ($file =~ /\\ddk_flat\\/);
  230. chomp $file;
  231. # The easy checks
  232. $MAKECAB{DDKINCS} =TRUE if ($file =~ /\\ddk_flat\\inc\\ddk\\/);
  233. $MAKECAB{DDKLIBS} =TRUE if ($file =~ /\\ddk_flat\\$libdir\\/);
  234. $MAKECAB{DDKBINS} =TRUE if ($file =~ /\\ddk_flat\\bin\\/);
  235. $MAKECAB{DDKDOCS} =TRUE if ($file =~ /\\ddk_flat\\help\\/);
  236. $MAKECAB{DDKTOOLS}=TRUE if ($file =~ /\\ddk_flat\\tools\\/);
  237. $MAKECAB{DDKDBG} =TRUE if ($file =~ /\\ddk_flat\\debug\\/);
  238. $MAKECAB{IFSTOOLS}=TRUE if ($file =~ /\\ifs_flat\\tools\\/);
  239. $MAKECAB{IFSLIBS} =TRUE if ($file =~ /\\ifs_flat\\$libdir\\/);
  240. $MAKECAB{IFSINCS} =TRUE if ($file =~ /\\ifs_flat\\incs\\/);
  241. $MAKECAB{IFSDOCS} =TRUE if ($file =~ /\\ifs_flat\\help\\/);
  242. #$MAKECAB{HALTOOLS}=TRUE if ($file =~ /\\hal_flat\\tools\\/);
  243. $MAKECAB{HALLIBS} =TRUE if ($file =~ /\\hal_flat\\$libdir\\/);
  244. $MAKECAB{HALINCS} =TRUE if ($file =~ /\\hal_flat\\incs\\/);
  245. $MAKECAB{HALBINS} =TRUE if ($file =~ /\\hal_flat\\bins\\/);
  246. #$MAKECAB{HALDOCS} =TRUE if ($file =~ /\\hal_flat\\help\\/);
  247. #$MAKECAB{PDKTOOLS}=TRUE if ($file =~ /\\processor_flat\\tools\\/);
  248. $MAKECAB{PDKLIBS} =TRUE if ($file =~ /\\processor_flat\\$libdir\\/);
  249. $MAKECAB{PDKINCS} =TRUE if ($file =~ /\\processor_flat\\incs\\/);
  250. #$MAKECAB{PDKDOCS} =TRUE if ($file =~ /\\processor_flat\\help\\/);
  251. # The moderate checks
  252. if ($file =~ /\\ddk_flat\\inc\\(.*)/) {
  253. $i = $1;
  254. if ($i =~ /^\\wnet^/) {
  255. $MAKECAB{SDKINCS}=TRUE;
  256. } elsif ($i =~ /^\\[atl..|mfc..|crt]/) {
  257. $MAKECAB{CMNINCS}=TRUE;
  258. }
  259. }
  260. if ($file =~ /\\ddk_flat\\(.*)/) {
  261. $i = $1;
  262. $MAKECAB{COREDDK}=TRUE unless ($i =~ /\\/);
  263. }
  264. if ($file =~ /\\hal_flat\\src\\hals\\(.*)/) {
  265. $i = $1;
  266. $MAKECAB{COREHAL}=TRUE unless ($i =~ /\\/);
  267. }
  268. if ($file =~ /\\processor_flat\\src\\processor\\(.*)/) {
  269. $i = $1;
  270. $MAKECAB{COREPDK}=TRUE unless ($i =~ /\\/);
  271. }
  272. $file =~ s/^[A-Z]:\\binaries\.(ia64|x86|amd64)(chk|fre)\\(ddk|ifs|hal|processor)_flat\\//i;
  273. if ($file =~ /^tools\\(.*?)\\/) {
  274. $dir = $1;
  275. $cabname=sprintf("%s_%s\n","TOOL",lc(substr($dir,0,6)));
  276. chomp $cabname;
  277. $MAKECAB{$cabname} = TRUE;
  278. }
  279. next unless ($file =~ /^src\\(.*?)\\(.*?)\\/);
  280. $dir = $1;
  281. $dir2 = $2;
  282. $cabname=sprintf("%s_%s\n",uc(substr($dir,0,4)),lc(substr($dir2,0,6)));
  283. chomp $cabname;
  284. $MAKECAB{$cabname} = TRUE;
  285. }
  286. }
  287. # --------------------------------------------------------------------------
  288. # Make the samples CABs. One cab per 2nd level directory under src. Name of each cab is
  289. # the first 4 character of the first level directory + the first 6 of the second level
  290. # directory.
  291. # --------------------------------------------------------------------------
  292. SAMPLES:{
  293. foreach $kit ("ddk","ifs", "hal", "processor") {
  294. mkdir("$ENV{_NTTREE}\\${kit}_cd\\common", 777) unless (-e "$ENV{_NTTREE}\\${kit}_cd\\common");
  295. opendir(hDIR, "$ENV{_NTTREE}\\${kit}_flat\\src"); # Get the first level directories
  296. @dir_list1=readdir(hDIR);
  297. closedir(hDIR);
  298. foreach $dir (@dir_list1) {
  299. # Skip . & .. as well as non-directory files (which shouldn't be there anyhow).
  300. next unless ((-d "$ENV{_NTTREE}\\${kit}_flat\\src\\$dir") and ($dir ne ".") and ($dir ne ".."));
  301. chomp $dir;
  302. opendir(hDIR, "$ENV{_NTTREE}\\${kit}_flat\\src\\$dir"); # Get the second level directories
  303. @dir_list2=readdir(hDIR);
  304. closedir(hDIR);
  305. foreach $dir2 (@dir_list2) {
  306. # Skip . & .. as well as non-directory files (which shouldn't be there anyhow).
  307. next unless ((-d "$ENV{_NTTREE}\\${kit}_flat\\src\\$dir\\$dir2") and ($dir2 ne ".") and ($dir2 ne ".."));
  308. chomp $dir2;
  309. $cabname=sprintf("%s_%s\n",uc(substr($dir,0,4)),lc(substr($dir2,0,6)));
  310. chomp $cabname;
  311. next if (($INCREMENTAL) and (! defined $MAKECAB{$cabname}));
  312. # Create a complete listing of files under the second level directory
  313. system("dir $ENV{_NTTREE}\\${kit}_flat\\src\\$dir\\$dir2 /s/b/a-d > ${dir}${dir2}.ddk.ini 2>nul");
  314. # Create the .ini
  315. CreateCAB ("${dir}${dir2}.ddk.ini","$cabname","Samples","$dir", "$kit", "$bldno");
  316. }
  317. }
  318. }
  319. }
  320. # --------------------------------------------------------------------------
  321. DDKINCS: {
  322. if ($INCREMENTAL) {
  323. last DDKINCS unless ( defined $MAKECAB{DDKINCS} );
  324. }
  325. # List all files under \inc\ddk\...
  326. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\$OS_SUBDIR /s/b/a-d > ddkincs.ddk.ini 2>nul");
  327. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\wdm\\$OS_SUBDIR /s/b/a-d >> ddkincs.ddk.ini 2>nul");
  328. # Create the .ini
  329. CreateCAB( "ddkincs.ddk.ini","DDKINCS","Build_Environment",
  330. "DDK_Include_Files", "DDK", $bldno);
  331. #
  332. # Handle backport incs
  333. #
  334. # W2K specific
  335. if ( -e "$ENV{_NTTREE}\\ddk_flat\\inc\\w2k" ) {
  336. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\w2k /s/b/a-d > w2kincs.ddk.ini 2>nul");
  337. }
  338. if ( -e "$ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\w2k" ) {
  339. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\w2k /s/b/a-d >> w2kincs.ddk.ini 2>nul");
  340. }
  341. if ( -e "$ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\wdm\\w2k" ) {
  342. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\wdm\\w2k /s/b/a-d >> w2kincs.ddk.ini 2>nul");
  343. }
  344. # WXP specific
  345. if ( -e "$ENV{_NTTREE}\\ddk_flat\\inc\\wxp" ) {
  346. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\wxp /s/b/a-d > wxpincs.ddk.ini 2>nul");
  347. }
  348. if ( -e "$ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\wxp" ) {
  349. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\wxp /s/b/a-d >> wxpincs.ddk.ini 2>nul");
  350. }
  351. if ( -e "$ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\wdm\\wxp" ) {
  352. system("dir $ENV{_NTTREE}\\ddk_flat\\inc\\ddk\\wdm\\wxp /s/b/a-d >> wxpincs.ddk.ini 2>nul");
  353. }
  354. # Make the cabs
  355. if ( -e "w2kincs.ddk.ini" ) {
  356. # Create the .ini
  357. CreateCAB( "w2kincs.ddk.ini","W2K_INCS","Build_Environment",
  358. "W2K_Include_Files","DDK",$bldno);
  359. }
  360. if ( -e "wxpincs.ddk.ini" ) {
  361. # Create the .ini
  362. CreateCAB( "wxpincs.ddk.ini","WXP_INCS","Build_Environment",
  363. "WXP_Include_Files","DDK",$bldno);
  364. }
  365. }
  366. # --------------------------------------------------------------------------
  367. IFSINCS: {
  368. if ($INCREMENTAL) {
  369. last IFSINCS unless ( defined $MAKECAB{IFSINCS} );
  370. }
  371. system("dir $ENV{_NTTREE}\\ifs_flat\\inc /s/b/a-d > ifsincs.ddk.ini 2>nul");
  372. # Create the .ini
  373. CreateCAB( "ifsincs.ddk.ini","IFSINCS","Build_Environment",
  374. "IFS_Include_Files","IFS",$bldno);
  375. }
  376. # --------------------------------------------------------------------------
  377. PDKINCS: {
  378. if ($INCREMENTAL) {
  379. last PDKINCS unless ( defined $MAKECAB{PDKINCS} );
  380. }
  381. system("dir $ENV{_NTTREE}\\processor_flat\\inc /s/b/a-d > pdkincs.ddk.ini 2>nul");
  382. # Create the .ini
  383. CreateCAB( "pdkincs.ddk.ini","PDKINCS","Build_Environment",
  384. "PDK_Include_Files","processor",$bldno);
  385. }
  386. # --------------------------------------------------------------------------
  387. HALINCS: {
  388. if ($INCREMENTAL) {
  389. last HALINCS unless ( defined $MAKECAB{HALINCS} );
  390. }
  391. system("dir $ENV{_NTTREE}\\HAL_flat\\inc /s/b/a-d > HALincs.ddk.ini 2>nul");
  392. # Create the .ini
  393. CreateCAB( "HALincs.ddk.ini","HALINCS","Build_Environment",
  394. "HAL_Include_Files","HAL",$bldno);
  395. }
  396. # --------------------------------------------------------------------------
  397. HALBINS: {
  398. if ($INCREMENTAL) {
  399. last HALBINS unless ( defined $MAKECAB{HALBINS} );
  400. }
  401. # List all files under \inc\ddk\...
  402. system("dir $ENV{_NTTREE}\\HAL_flat\\bin /s/b/a-d > HALbins.ddk.ini 2>nul");
  403. # Create the .ini
  404. CreateCAB( "HALbins.ddk.ini","HALBINS","Build_Environment",
  405. "HAL_Binary_Files","HAL",$bldno);
  406. }
  407. # --------------------------------------------------------------------------
  408. DDKDBG: {
  409. if ($INCREMENTAL) {
  410. last DDKDBG unless ( defined $MAKECAB{DDKDBG} );
  411. }
  412. # Make DBG cabs only on CHK builds
  413. last DDKDBG if (uc $ENV{_BuildType} ne "CHK");
  414. my $plat = substr($ENV{_BUILDARCH}, 0, 1);
  415. system("dir $ENV{_NTTREE}\\ddk_flat\\debug /s/b/a-d > ddkdbg.ddk.ini 2>nul");
  416. # Create the .ini
  417. CreateCAB( "ddkdbg.ddk.ini","DDK_DBG${plat}","Build_Environment",
  418. "Extra_Debug_Files","DDK",$bldno);
  419. }
  420. # --------------------------------------------------------------------------
  421. DDKTOOLS: {
  422. if ($INCREMENTAL) {
  423. last DDKTOOLS unless ( defined $MAKECAB{DDKTOOLS} );
  424. }
  425. # We don't want to ship checked versions of the tools
  426. last DDKTOOLS if (uc $ENV{_BuildType} eq "CHK");
  427. opendir(hDIR, "$ENV{_NTTREE}\\DDK_flat\\tools"); # Get the first level directories
  428. @dir_list1=readdir(hDIR);
  429. closedir(hDIR);
  430. foreach $dir (@dir_list1) {
  431. # Skip . & .. as well as non-directory files (which shouldn't be there anyhow).
  432. next unless ((-d "$ENV{_NTTREE}\\DDK_flat\\tools\\$dir") and ($dir ne ".") and ($dir ne ".."));
  433. chomp $dir;
  434. $cabname=sprintf("%s_%s\n","TOOL",lc substr($dir,0,6) );
  435. chomp $cabname;
  436. next if (($INCREMENTAL) and (! defined $MAKECAB{$cabname}));
  437. ##
  438. ## Need to handle tools on the per-arch basis. Can't just look for \%arch, since
  439. ## the tools may also have files in root. (.htm's, etc). Instead, break we'll
  440. ## break this into 4 cabs per tool, TOOL_%tool%, TOOL_%tool%x (x86), TOOL_%tool%i (ia64)
  441. ## TOOL_%tool%a (AMD64)
  442. ##
  443. # At tools\\$dir, now, we need all the sub dirs
  444. my @subs = `dir $ENV{_NTTREE}\\DDK_flat\\tools\\$dir /s/b/ad`;
  445. my $sub;
  446. my $plat = substr($ENV{_BUILDARCH}, 0, 1);
  447. # Drop in an empty file as placeholder so we can force the general cab for this tool
  448. # to be built.
  449. system("echo. >$ENV{_NTTREE}\\DDK_flat\\tools\\$dir\\.empty");
  450. # Make sure we're not appending to old .ini's
  451. unlink("TOOLS${dir}${plat}.ddk.ini") if (-e "TOOLS${dir}${plat}.ddk.ini");
  452. unlink("TOOLS${dir}.ddk.ini") if (-e "TOOLS${dir}.ddk.ini");
  453. # Now, create the .ini for the common cab
  454. foreach (`dir $ENV{_NTTREE}\\DDK_flat\\tools\\$dir /b/a-d`) {
  455. chomp;
  456. system("echo $ENV{_NTTREE}\\DDK_flat\\tools\\$dir\\$_ >> TOOLS${dir}.ddk.ini");
  457. }
  458. # For every subdir, if it ends in %arch%, create the arch specific cab, otherwise
  459. # create the general cab.
  460. foreach $sub (@subs) {
  461. chomp $sub;
  462. if ($sub =~ /DDK_flat\\.*\\$ENV{_BUILDARCH}/i) {
  463. system("dir $sub /s/b/a-d >> TOOLS${dir}${plat}.ddk.ini 2>nul");
  464. } elsif ( uc($ENV{_BUILDARCH}) eq "X86" ) {
  465. # i386 is a valid alias of x86
  466. if ($sub =~ /DDK_flat\\.*\\i386/i) {
  467. system("dir $sub /s/b/a-d >> TOOLS${dir}${plat}.ddk.ini 2>nul");
  468. }
  469. }
  470. }
  471. # Create the cabs
  472. CreateCAB ("TOOLS${dir}.ddk.ini","${cabname}","Build_Environment","${dir}_TOOL", "ddk", "$bldno");
  473. CreateCAB ("TOOLS${dir}${plat}.ddk.ini","${cabname}${plat}","Build_Environment","${dir}_TOOL", "ddk", "$bldno")
  474. if (-e "TOOLS${dir}${plat}.ddk.ini"); # May not have arch-specific cab
  475. }
  476. }
  477. # --------------------------------------------------------------------------
  478. IFSTOOLS: {
  479. if ($INCREMENTAL) {
  480. last IFSTOOLS unless ( defined $MAKECAB{IFSTOOLS} );
  481. }
  482. # List all files under \inc\ddk\...
  483. system("dir $ENV{_NTTREE}\\IFS_flat\\tools /s/b/a-d > ifstools.ddk.ini 2>nul");
  484. # Create the .ini
  485. CreateCAB( "ifstools.ddk.ini","IFSTOOLS","Build_Environment",
  486. "Development_Tools","IFS",$bldno);
  487. }
  488. # -- Common Includes -------------------------------------------------------
  489. if ( (! $INCREMENTAL ) || ($INCREMENTAL && defined $MAKECAB{CMNINCS}) ) {
  490. @dir_list1=();
  491. #
  492. # Look for all ATL21 specific headers
  493. #
  494. opendir(hDIR, "$sdkincs\\atl21");
  495. @dir_list2 = readdir(hDIR);
  496. closedir(hDIR);
  497. foreach (@dir_list2) {
  498. $_ = "atl21\\$_";
  499. }
  500. push(@dir_list1, @dir_list2);
  501. undef(@dir_list2);
  502. #
  503. # Look for all ATL30 specific headers
  504. #
  505. opendir(hDIR, "$sdkincs\\atl30");
  506. @dir_list2 = readdir(hDIR);
  507. closedir(hDIR);
  508. foreach (@dir_list2) {
  509. $_ = "atl30\\$_";
  510. }
  511. push(@dir_list1, @dir_list2);
  512. undef(@dir_list2);
  513. #
  514. # Look for all MFC42 specific headers
  515. #
  516. opendir(hDIR, "$sdkincs\\mfc42");
  517. @dir_list2 = readdir(hDIR);
  518. closedir(hDIR);
  519. foreach (@dir_list2) {
  520. $_ = "mfc42\\$_";
  521. }
  522. push(@dir_list1, @dir_list2);
  523. undef(@dir_list2);
  524. #
  525. # Look for all CRT headers
  526. #
  527. opendir(hDIR, "$sdkincs\\crt");
  528. @dir_list2 = readdir(hDIR);
  529. closedir(hDIR);
  530. foreach (@dir_list2) {
  531. $_ = "crt\\$_";
  532. }
  533. push(@dir_list1, @dir_list2);
  534. undef(@dir_list2);
  535. opendir(hDIR, "$sdkincs\\crt\\sys");
  536. @dir_list2 = readdir(hDIR);
  537. closedir(hDIR);
  538. foreach (@dir_list2) {
  539. $_ = "crt\\sys\\$_";
  540. }
  541. push(@dir_list1, @dir_list2);
  542. undef(@dir_list2);
  543. opendir(hDIR, "$sdkincs\\crt\\gl");
  544. @dir_list2 = readdir(hDIR);
  545. closedir(hDIR);
  546. foreach (@dir_list2) {
  547. $_ = "crt\\gl\\$_";
  548. }
  549. push(@dir_list1, @dir_list2);
  550. undef(@dir_list2);
  551. open(cmn1, ">cmn.ddk.ini");
  552. for ($i=0;$i<=$#dir_list1;$i++) {
  553. next if ($dir_list1[$i] =~ /\.$/);
  554. next if (-d "$sdkincs\\$dir_list1[$i]");
  555. print(cmn1 "$sdkincs\\$dir_list1[$i]\n");
  556. }
  557. close(cmn1);
  558. # Create the .ini
  559. CreateCAB( "cmn.ddk.ini","CMNINCS","Build_Environment",
  560. "Common_Include_Files","DDK",$bldno);
  561. }
  562. # --------------------------------------------------------------------------
  563. SDKINCS: {
  564. if ($INCREMENTAL) {
  565. last SDKINCS unless ( defined $MAKECAB{SDKINCS} );
  566. }
  567. # List all files under \inc\.
  568. opendir(hDIR, "$sdkincs");
  569. @dir_list1 = readdir(hDIR);
  570. closedir(hDIR);
  571. #
  572. # Look for all OS specific headers
  573. #
  574. opendir(hDIR, "$sdkincs\\$OS_SUBDIR");
  575. @dir_list2 = readdir(hDIR);
  576. closedir(hDIR);
  577. foreach (@dir_list2) {
  578. $_ = "$OS_SUBDIR\\$_";
  579. }
  580. push(@dir_list1, @dir_list2);
  581. undef(@dir_list2);
  582. opendir(hDIR, "$sdkincs\\crt\\$OS_SUBDIR");
  583. @dir_list2 = readdir(hDIR);
  584. closedir(hDIR);
  585. foreach (@dir_list2) {
  586. $_ = "crt\\$OS_SUBDIR\\$_";
  587. }
  588. push(@dir_list1, @dir_list2);
  589. undef(@dir_list2);
  590. open(sdk1, ">sdk1.ddk.ini");
  591. open(sdk2, ">sdk2.ddk.ini");
  592. open(sdk3, ">sdk3.ddk.ini");
  593. for ($i=0;$i<=$#dir_list1;$i++) {
  594. next if ($dir_list1[$i] =~ /\.$/);
  595. next if (-d "$sdkincs\\$dir_list1[$i]");
  596. if (($i%3) == 0) {
  597. print(sdk1 "$sdkincs\\$dir_list1[$i]\n");
  598. } elsif (($i%3) == 1) {
  599. print(sdk2 "$sdkincs\\$dir_list1[$i]\n");
  600. } else {
  601. print(sdk3 "$sdkincs\\$dir_list1[$i]\n");
  602. }
  603. }
  604. close(sdk1);
  605. close(sdk2);
  606. close(sdk3);
  607. # CAB 1
  608. # Create the .ini
  609. CreateCAB( "sdk1.ddk.ini","SDKINCS1","Build_Environment",
  610. "SDK_Include_Files","DDK",$bldno);
  611. # CAB 2
  612. # Create the .ini
  613. CreateCAB( "sdk2.ddk.ini","SDKINCS2","Build_Environment",
  614. "SDK_Include_Files","DDK",$bldno);
  615. # CAB 3
  616. # Create the .ini
  617. CreateCAB( "sdk3.ddk.ini","SDKINCS3","Build_Environment",
  618. "SDK_Include_Files","DDK",$bldno);
  619. }
  620. # --------------------------------------------------------------------------
  621. DDKLIBS: {
  622. if ($INCREMENTAL) {
  623. last DDKLIBS unless ( defined $MAKECAB{DDKLIBS} );
  624. }
  625. my $libsub;
  626. if (uc($ENV{_BuildArch}) eq "IA64") {
  627. $libsub = "ia64";
  628. } elsif (uc($ENV{_BuildArch}) eq "AMD64") {
  629. $libsub = "amd64";
  630. } else {
  631. $libsub = "i386";
  632. }
  633. #
  634. # Handle backport libs
  635. #
  636. # only make the W2K cabs on x86 machines
  637. if ((uc($ENV{_BuildArch}) ne "IA64") && (uc($ENV{_BuildArch}) ne "AMD64")) {
  638. # W2K specific
  639. if ( -e "$ENV{_NTTREE}\\ddk_flat\\lib\\w2k" ) {
  640. # List all files under \lib\w2k\...
  641. system("dir $ENV{_NTTREE}\\ddk_flat\\lib\\w2k /s/b/a-d > w2klibs.ddk.ini 2>nul");
  642. }
  643. # Make the cabs
  644. if ( -e "w2klibs.ddk.ini" ) {
  645. # Create the .ini
  646. CreateCAB( "w2klibs.ddk.ini","W2K_LIBS","Build_Environment",
  647. "W2K_Library_Files","DDK",$bldno);
  648. }
  649. }
  650. # WXP specific
  651. if ( -e "$ENV{_NTTREE}\\ddk_flat\\lib\\wxp" ) {
  652. # List all files under \lib\wxp\...
  653. system("dir $ENV{_NTTREE}\\ddk_flat\\lib\\wxp /s/b/a-d > wxplibs.ddk.ini 2>nul");
  654. }
  655. if ( -e "wxplibs.ddk.ini" ) {
  656. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  657. $cabname="XPILIB";
  658. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  659. $cabname="XPALIB";
  660. } else {
  661. $cabname="XPXLIB";
  662. }
  663. # Create the .ini
  664. CreateCAB( "wxplibs.ddk.ini","$cabname","Build_Environment",
  665. "Wxp_Library_Files","DDK",$bldno);
  666. }
  667. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  668. $cabname="IA6dLIB";
  669. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  670. $cabname="A64dLIB";
  671. } else {
  672. $cabname="X86dLIB";
  673. }
  674. $samplename ="$ENV{_BuildArch}_Libraries";
  675. $friendlyname="$ENV{_BuildArch}_Libraries";
  676. # List all files under \tools
  677. opendir(hDIR, "$ENV{_NTTREE}\\ddk_flat\\$libdir");
  678. @dir_list1=readdir hDIR;
  679. closedir(hDIR);
  680. open(LIBS1, ">libs1.ddk.ini");
  681. open(LIBS2, ">libs2.ddk.ini");
  682. open(LIBS3, ">libs3.ddk.ini");
  683. for ($i=0;$i<=$#dir_list1;$i++) {
  684. next if ($dir_list1[$i] =~ /^\./);
  685. if (($i % 3) == 0) {
  686. print(LIBS1 "$ENV{_NTTREE}\\ddk_flat\\$libdir\\$dir_list1[$i]\n");
  687. } elsif (($i % 3) == 1) {
  688. print(LIBS2 "$ENV{_NTTREE}\\ddk_flat\\$libdir\\$dir_list1[$i]\n");
  689. } else {
  690. print(LIBS3 "$ENV{_NTTREE}\\ddk_flat\\$libdir\\$dir_list1[$i]\n");
  691. }
  692. }
  693. close(LIBS1);
  694. close(LIBS2);
  695. #
  696. # handle files that are not processor-specific
  697. # put them all in the libs3 cab since we expect very few
  698. #
  699. opendir(hDIR, "$ENV{_NTTREE}\\ddk_flat\\lib\\wnet");
  700. @dir_list1=readdir hDIR;
  701. for ($i=0;$i<=$#dir_list1;$i++) {
  702. next if (-d "$ENV{_NTTREE}\\ddk_flat\\lib\\wnet\\$dir_list1[$i]");
  703. next if ($dir_list1[$i] =~ /^\./);
  704. print(LIBS3 "$ENV{_NTTREE}\\ddk_flat\\lib\\wnet\\$dir_list1[$i]\n");
  705. }
  706. closedir(hDIR);
  707. close(LIBS3);
  708. # CAB 1
  709. # Create the .ini
  710. CreateCAB( "libs1.ddk.ini","${cabname}1","Build_Environment",
  711. "${samplename}","DDK",$bldno);
  712. # CAB 2
  713. # Create the .ini
  714. CreateCAB( "libs2.ddk.ini","${cabname}2","Build_Environment",
  715. "$samplename","DDK",$bldno);
  716. # CAB 3
  717. # Create the .ini
  718. CreateCAB( "libs3.ddk.ini","${cabname}3","Build_Environment",
  719. "$samplename","DDK",$bldno);
  720. }
  721. # --------------------------------------------------------------------------
  722. IFSLIBS: {
  723. if ($INCREMENTAL) {
  724. last IFSLIBS unless ( defined $MAKECAB{IFSLIBS} );
  725. }
  726. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  727. $cabname="IA6iLIB";
  728. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  729. $cabname="A64iLIB";
  730. } else {
  731. $cabname="X86iLIB";
  732. }
  733. # List all files under \inc\ddk\...
  734. system("dir $ENV{_NTTREE}\\ifs_flat\\$libdir /s/b/a-d > ifslibs.ddk.ini 2>nul");
  735. # Create the .ini
  736. CreateCAB( "ifslibs.ddk.ini","${cabname}1","Build_Environment",
  737. "Library_Files","IFS",$bldno);
  738. }
  739. # --------------------------------------------------------------------------
  740. PDKLIBS: {
  741. if ($INCREMENTAL) {
  742. last PDKLIBS unless ( defined $MAKECAB{PDKLIBS} );
  743. }
  744. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  745. $cabname="IA6pLIB";
  746. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  747. $cabname="A64pLIB";
  748. } else {
  749. $cabname="X86pLIB";
  750. }
  751. if (uc($ENV{_BuildType}) eq "CHK" ) {
  752. $cabname .= "c";
  753. } else {
  754. $cabname .= "f";
  755. }
  756. # List all files under \inc\ddk\...
  757. system("dir $ENV{_NTTREE}\\processor_flat\\$libdir /s/b/a-d > pdklibs.ddk.ini 2>nul");
  758. # Create the .ini
  759. CreateCAB( "pdklibs.ddk.ini","${cabname}1","Build_Environment",
  760. "Library_Files","processor",$bldno);
  761. }
  762. # --------------------------------------------------------------------------
  763. HALLIBS: {
  764. if ($INCREMENTAL) {
  765. last HALLIBS unless ( defined $MAKECAB{HALLIBS} );
  766. }
  767. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  768. $cabname="IA6hLIB";
  769. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  770. $cabname="A64hLIB";
  771. } else {
  772. $cabname="X86hLIB";
  773. }
  774. # List all files under \inc\ddk\...
  775. system("dir $ENV{_NTTREE}\\hal_flat\\$libdir /s/b/a-d > hallibs.ddk.ini 2>nul");
  776. # Create the .ini
  777. CreateCAB( "hallibs.ddk.ini","${cabname}1","Build_Environment",
  778. "Library_Files","HAL",$bldno);
  779. }
  780. # --------------------------------------------------------------------------
  781. DDKBINS: {
  782. if ($INCREMENTAL) {
  783. last DDKBINS unless ( defined $MAKECAB{DDKBINS} );
  784. }
  785. $bindir ="$ENV{_NTTREE}\\ddk_flat\\bin";
  786. # List all files under bin
  787. opendir(hDIR, "$bindir"); # Get the first level directories
  788. @dir_list1=readdir(hDIR);
  789. closedir(hDIR);
  790. open(hDIR, ">cmnbins.ddk.ini");
  791. foreach $dir (@dir_list1) {
  792. # Skip . & .. as well as files.
  793. next if ( -d "$bindir\\$dir");
  794. next if (($dir eq ".") or ($dir eq ".."));
  795. print(hDIR "$bindir\\$dir\n");
  796. }
  797. close(hDIR);
  798. system("dir $ENV{_NTTREE}\\ddk_flat\\bin\\wppconfig /s/b/a-d >>cmnbins.ddk.ini 2>nul");
  799. # Create the .ini
  800. CreateCAB( "cmnbins.ddk.ini","CMNBINS","Build_Environment",
  801. "Comon_Build_Tools","DDK",$bldno);
  802. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  803. $cabname="IA6dBIN";
  804. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  805. $cabname="A64dBIN";
  806. } else {
  807. $cabname="X86bBIN";
  808. }
  809. $samplename ="$ENV{_BuildArch}_$ENV{_BuildType}_Binaries";
  810. $friendlyname="$ENV{_BuildArch}_$ENV{_BuildType}_Binaries";
  811. if (uc($ENV{_BUILDARCH}) eq "X86") {
  812. # List all files under bin\x86
  813. @dir_list1=`dir $bindir\\x86 /s/b/a-d`;
  814. open(hDIR, ">x86bins.ddk.ini");
  815. foreach $dir (@dir_list1) {
  816. print(hDIR "$dir\n");
  817. }
  818. close(hDIR);
  819. # Create the .ini
  820. CreateCAB( "x86bins.ddk.ini","X86dBINS","Build_Environment",
  821. "X86_Build_Tools","DDK",$bldno);
  822. }
  823. # Cross compiler tools
  824. if (uc($ENV{_BUILDARCH}) eq "X86") {
  825. opendir(hDIR, "$bindir\\win64\\x86");
  826. @dir_list1=readdir(hDIR);
  827. closedir(hDIR);
  828. open(hDIR, ">xcomp_bins.ddk.ini");
  829. foreach $dir (@dir_list1) {
  830. # Skip . & .. as well as directory files (which shouldn't be there anyhow).
  831. next unless ((! -d "$bindir\\win64\\x86\\$dir") and ($dir ne ".") and ($dir ne ".."));
  832. print(hDIR "$bindir\\win64\\x86\\$dir\n");
  833. }
  834. close(hDIR);
  835. # Create the .ini
  836. CreateCAB( "xcomp_bins.ddk.ini","XCmpdBINS","Build_Environment",
  837. "CrossCompile_Build_Tools","DDK",$bldno);
  838. # AMD64 cross compiler tools
  839. opendir(hDIR, "$bindir\\win64\\x86\\amd64");
  840. @dir_list1=readdir(hDIR);
  841. closedir(hDIR);
  842. open(hDIR, ">axcomp_bins.ddk.ini");
  843. foreach $dir (@dir_list1) {
  844. # Skip . & .. as well as directory files (which shouldn't be there anyhow).
  845. next unless ((! -d "$bindir\\win64\\x86\\amd64\\$dir") and ($dir ne ".") and ($dir ne ".."));
  846. print(hDIR "$bindir\\win64\\x86\\amd64\\$dir\n");
  847. }
  848. close(hDIR);
  849. # Create the .ini
  850. CreateCAB( "axcomp_bins.ddk.ini","A64xdBINS","Build_Environment",
  851. "AMD64_CrossCompile_Build_Tools","DDK",$bldno);
  852. }
  853. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  854. # List all files under bin\ia64
  855. opendir(hDIR, "$bindir\\ia64"); # Get the first level directories
  856. @dir_list1=readdir(hDIR);
  857. closedir(hDIR);
  858. open(hDIR, ">ia64bins.ddk.ini");
  859. foreach $dir (@dir_list1) {
  860. # Skip . & .. as well as directory files (which shouldn't be there anyhow).
  861. next unless ((! -d "$bindir\\ia64\\$dir") and ($dir ne ".") and ($dir ne ".."));
  862. print(hDIR "$bindir\\ia64\\$dir\n");
  863. }
  864. close(hDIR);
  865. # Create the .ini
  866. CreateCAB( "ia64bins.ddk.ini","IA6dBINS","Build_Environment",
  867. "IA64_Build_Tools","DDK",$bldno);
  868. }
  869. if (uc($ENV{_BUILDARCH}) eq "AMD64") {
  870. # no native amd64 tools yet
  871. }
  872. }
  873. # --------------------------------------------------------------------------
  874. COREDDK: {
  875. if ($INCREMENTAL) {
  876. last COREDDK unless ( defined $MAKECAB{COREDDK} );
  877. }
  878. system("dir $ENV{_NTTREE}\\ddk_flat /b/a-d > core.ddk.ini 2>nul");
  879. # Create the .ini
  880. CreateCAB( "core.ddk.ini","COREDDK","Build_Environment",
  881. "DDK_Core_Files","DDK",$bldno);
  882. }
  883. # --------------------------------------------------------------------------
  884. COREPDK: {
  885. if ($INCREMENTAL) {
  886. last COREPDK unless ( defined $MAKECAB{COREPDK} );
  887. }
  888. last COREPDK unless (-e "$ENV{_NTTREE}\\processor_flat\\src\\processor");
  889. @dir_list1=`dir $ENV{_NTTREE}\\processor_flat\\src\\processor /b/a-d`;
  890. foreach (@dir_list1) {
  891. next if (m/^\s*$/);
  892. chomp;
  893. system("echo $ENV{_NTTREE}\\processor_flat\\src\\processor\\$_ >> pdkcore.ddk.ini");
  894. }
  895. # Create the .ini
  896. CreateCAB( "pdkcore.ddk.ini","COREPDK","Build_Environment",
  897. "PDK_Core_Files","processor",$bldno);
  898. }
  899. # --------------------------------------------------------------------------
  900. COREHAL: {
  901. if ($INCREMENTAL) {
  902. last COREHAL unless ( defined $MAKECAB{COREHAL} );
  903. }
  904. last COREHAL unless (-e "$ENV{_NTTREE}\\hal_flat\\src\\hals");
  905. @dir_list1=`dir $ENV{_NTTREE}\\hal_flat\\src\\hals /b/a-d`;
  906. foreach (@dir_list1) {
  907. next if (m/^\s*$/);
  908. chomp;
  909. system("echo $ENV{_NTTREE}\\hal_flat\\src\\hals\\$_ >> halcore.ddk.ini");
  910. }
  911. @dir_list1=`dir $ENV{_NTTREE}\\hal_flat /b/a-d`;
  912. foreach (@dir_list1) {
  913. next if (m/^\s*$/);
  914. chomp;
  915. system("echo $ENV{_NTTREE}\\hal_flat\\\\$_ >> halcore.ddk.ini");
  916. }
  917. # Create the .ini
  918. CreateCAB( "halcore.ddk.ini","COREHAL","Build_Environment",
  919. "HAL_Core_Files","HAL",$bldno);
  920. }
  921. # --------------------------------------------------------------------------
  922. COREIFS: {
  923. if ($INCREMENTAL) {
  924. last COREIFS unless ( defined $MAKECAB{COREIFS} );
  925. }
  926. last COREIFS unless (-e "$ENV{_NTTREE}\\ifs_flat");
  927. @dir_list1=`dir $ENV{_NTTREE}\\ifs_flat\\src\\filesys /b/a-d`;
  928. foreach (@dir_list1) {
  929. next if (m/^\s*$/);
  930. chomp;
  931. system("echo $ENV{_NTTREE}\\ifs_flat\\src\\filesys\\$_ >> ifscore.ddk.ini");
  932. }
  933. # Create the .ini
  934. CreateCAB( "ifscore.ddk.ini","COREIFS","Build_Environment",
  935. "IFS_Core_Files","IFS",$bldno);
  936. }
  937. # --------------------------------------------------------------------------
  938. DDKDOCS: {
  939. if ($INCREMENTAL) {
  940. last DDKDOCS unless ( defined $MAKECAB{DDKDOCS} );
  941. }
  942. # Make the Docs
  943. opendir(hDir, "$ENV{_NTTREE}\\ddk_flat\\help")||warn("Can't open $ENV{_NTTREE}\\ddk_flat\\help: $!\n");
  944. @dir_list1=readdir(hDir);
  945. closedir(hDir);
  946. my @general_cab;
  947. foreach $file (@dir_list1) {
  948. next if ($file =~ /^\./);
  949. next if ($file =~ /\.chi$/); # Don't use .chi, use .chm below
  950. next if (-d "$ENV{_NTTREE}\\ddk_flat\\help\\$file");
  951. if ($file =~ /\.chm$/i) {
  952. # We have a .chm
  953. $file =~ s/\.chm$//i; # Remove the extension
  954. system("dir $ENV{_NTTREE}\\ddk_flat\\help\\$file.* /s/b/a-d > $file.ddk.ini 2>nul");
  955. $file=uc($file); # Force uppercase
  956. # Create the .ini
  957. CreateCAB( "$file.ddk.ini","$file","Documentation",
  958. "${file}_Doc","DDK",$bldno);
  959. } else {
  960. system("dir $ENV{_NTTREE}\\ddk_flat\\help\\$file /s/b/a-d >> general_docs.ddk.ini 2>nul");
  961. }
  962. }
  963. CreateCAB("general_docs.ddk.ini","CMNDOCS", "Documentation", "Common_Docs_Files", "DDK",$bldno);
  964. }
  965. # --------------------------------------------------------------------------
  966. IFSDOCS: {
  967. if ($INCREMENTAL) {
  968. last IFSDOCS unless ( defined $MAKECAB{IFSDOCS} );
  969. }
  970. # Make the Docs
  971. opendir(hDir, "$ENV{_NTTREE}\\ifs_flat\\help")||warn("Can't open $ENV{_NTTREE}\\ifs_flat\\help: $!\n");
  972. @dir_list1=readdir(hDir);
  973. closedir(hDir);
  974. foreach $file (@dir_list1) {
  975. next if ($file =~ /^\./);
  976. next if ($file =~ /\.chi$/); # Don't use .chi, use .chm below
  977. next if (-d "$ENV{_NTTREE}\\ifs_flat\\help\\$file");
  978. if ($file =~ /\.chm$/i) {
  979. # We have a .chm
  980. $file =~ s/\.chm$//i; # Remove the extension
  981. system("dir $ENV{_NTTREE}\\ifs_flat\\help\\$file.* /s/b/a-d > $file.ddk.ini 2>nul");
  982. $file=uc($file); # Force uppercase
  983. # Create the .ini
  984. CreateCAB( "$file.ddk.ini","$file","Documentation",
  985. "${file}_Doc","IFS",$bldno);
  986. } else {
  987. logdebug("Not including \\help\\$file\n");
  988. }
  989. }
  990. }
  991. # Don't exit until all subprocesses have completed.
  992. WaitForAllProcesses();
  993. if (-e "$ENV{_NTTREE}\\ddk_cd\\common\\cabs.in_") {
  994. system("copy $ENV{_NTTREE}\\ddk_cd\\common\\cabs.in_ $ENV{_NTTREE}\\ddk_cd\\common\\cabs.ini >nul");
  995. open(hF, ">>$ENV{_NTTREE}\\ddk_cd\\common\\cabs.ini");
  996. print(hF "Build=$bldno\n");
  997. close(hF);
  998. }
  999. if (-e "$ENV{_NTTREE}\\ifs_cd\\common\\cabs.in_") {
  1000. system("copy $ENV{_NTTREE}\\ifs_cd\\common\\cabs.in_ $ENV{_NTTREE}\\ifs_cd\\common\\cabs.ini >nul");
  1001. open(hF, ">>$ENV{_NTTREE}\\ifs_cd\\common\\cabs.ini");
  1002. print(hF "Build=$bldno\n");
  1003. close(hF);
  1004. }
  1005. if (-e "$ENV{_NTTREE}\\hal_cd\\common\\cabs.in_") {
  1006. system("copy $ENV{_NTTREE}\\hal_cd\\common\\cabs.in_ $ENV{_NTTREE}\\hal_cd\\common\\cabs.ini >nul");
  1007. open(hF, ">>$ENV{_NTTREE}\\hal_cd\\common\\cabs.ini");
  1008. print(hF "Build=$bldno\n");
  1009. close(hF);
  1010. }
  1011. if (-e "$ENV{_NTTREE}\\processor_cd\\common\\cabs.in_") {
  1012. system("copy $ENV{_NTTREE}\\processor_cd\\common\\cabs.in_ $ENV{_NTTREE}\\processor_cd\\common\\cabs.ini >nul");
  1013. open(hF, ">>$ENV{_NTTREE}\\processor_cd\\common\\cabs.ini");
  1014. print(hF "Build=$bldno\n");
  1015. close(hF);
  1016. }
  1017. $time = time() - $time;
  1018. logmsg("Total run time: $time seconds.\n");
  1019. print(STDERR "$0: Finished.\n\n");
  1020. END {
  1021. # Delete .tmp file so postbuild.cmd knows the script has finished
  1022. unlink ("$ENV{TEMP}\\ddkcabs.tmp");
  1023. }
  1024. # --------------------------------------------------------------------------
  1025. # Creates a CAB and INF from a list of files
  1026. # --------------------------------------------------------------------------
  1027. sub CreateCAB {
  1028. print(".") unless ($verbose); # Print something so the user knows the script is still running
  1029. my $filelist = shift;
  1030. my $cabname = shift;
  1031. my $groupname = shift;
  1032. my $samplename = shift;
  1033. my $kit = shift;
  1034. my $bldno = shift;
  1035. my $FileIndex = -1;
  1036. my $friendlyname = $samplename;
  1037. my $GroupIndex = -1;
  1038. my $InfCopyFileList = "InfFiles";
  1039. my $PrevCommand = "";
  1040. my $PrevDestDir = "";
  1041. my $TotalSize = 0;
  1042. my @files;
  1043. my $file;
  1044. my $FileProcessed;
  1045. my $hFILE;
  1046. my $NewSection;
  1047. my $source_file;
  1048. my $source_dir;
  1049. my $dest_dir;
  1050. my $ERRORLEVEL;
  1051. my $FileSize;
  1052. my $CabFileName;
  1053. chomp($cabname);
  1054. unless (-e $filelist) {
  1055. logerror("$filelist did not exist - cannot build cab.");
  1056. return(5);
  1057. }
  1058. # These files get rolled into the INF once the entire filelist
  1059. # is processed.
  1060. open(hFILE, ">${cabname}_DestDirsFiles")
  1061. || die("Couldn't write to ${cabname}_DestDirsFile: $!\n");
  1062. printf(hFILE "[DestinationDirs]\n");
  1063. close(hFILE);
  1064. open(hFILE, ">${cabname}_SourceFiles")
  1065. || die("Couldn't write to ${cabname}_SourceFiles: $!\n");
  1066. printf(hFILE "\n");
  1067. close(hFILE);
  1068. open(hFILE, ">${cabname}_SourceDisk")
  1069. || die("Couldn't write to ${cabname}_SourceDisk: $!\n");
  1070. printf(hFILE "[SourceDisksFiles]\n");
  1071. close(hFILE);
  1072. #
  1073. # Process the filelist
  1074. #
  1075. open(hFILE, "$filelist");
  1076. @files=<hFILE>;
  1077. close(hFILE);
  1078. # For every file in the list, split it up into the format expected by genddkcab.bat:
  1079. # $source_dir, $source_file, $dest_dir, $dest_file, $command
  1080. foreach $file (@files) {
  1081. chomp($file);
  1082. $file =~ m/^(.*)\\.*$/;
  1083. # source_dir is %_NTTREE%\[ddk|hal|ifs]_flat + dest_dir
  1084. if (! defined($1)) {
  1085. $source_dir = "$ENV{_NTTREE}\\ddk_flat";
  1086. } else {
  1087. $source_dir = $1;
  1088. }
  1089. $file =~ m/^.*\\(.*)$/;
  1090. # source_file is filename
  1091. if (! defined($1)) {
  1092. $source_file = $file;
  1093. } else {
  1094. $source_file = $1;
  1095. }
  1096. $file =~ m/^.*_flat(\\.*\\).*$/;
  1097. # dest_dir is dir less %_NTTREE%\[ddk|hal|ifs]_flat
  1098. if (! defined($1)) {
  1099. $dest_dir= "\\";
  1100. } else {
  1101. $dest_dir= $1;
  1102. }
  1103. $FileProcessed=FALSE;
  1104. # Optimization to not generate excessive install sections in the inf.
  1105. $NewSection=TRUE;
  1106. $NewSection=FALSE if (uc($dest_dir) eq uc($PrevDestDir));
  1107. $PrevDestDir=$dest_dir;
  1108. if ($NewSection) {
  1109. $GroupIndex+=1;
  1110. open(hDDF, ">>${cabname}_DestDirsFiles");
  1111. printf(hDDF "Files_${GroupIndex}=49000,\"$dest_dir\"\n");
  1112. close(hDDF);
  1113. $InfCopyFileList="${InfCopyFileList},Files_${GroupIndex}";
  1114. open(hDDF, ">>${cabname}_SourceFiles");
  1115. printf(hDDF "[Files_${GroupIndex}]\n");
  1116. close(hDDF);
  1117. }
  1118. if (! -e "$source_dir\\$source_file") {
  1119. logerror("489: File $source_dir\\$source_file does not exist");
  1120. next;
  1121. }
  1122. # Move on to the next file number
  1123. $FileIndex += 1;
  1124. # Generate the name of the file within the cabfile.
  1125. $CabFileName="${cabname}_FILE_${FileIndex}";
  1126. # process the source file into the temporary cabfile name
  1127. $ERRORLEVEL=system("COPY $source_dir\\$source_file $CabFileName >nul 2>nul");
  1128. # check for errors
  1129. if ($ERRORLEVEL) {
  1130. logerror("545: COPY of file $source_dir\\$source_file failed (ErrorLevel $ERRORLEVEL)");
  1131. }
  1132. # Get the size of the file, so the size requirements of the cab can be computed.
  1133. $FileSize = (stat("$CabFileName"))[7];
  1134. printf("adding $CabFileName size $FileSize\n") if ($CABDEBUG);
  1135. $TotalSize += $FileSize;
  1136. # Write the DestinationFileName, CabFileName into the inf so the files
  1137. # can be extracted and installed properly.
  1138. open(hDDF, ">>${cabname}_SourceDisk")
  1139. || die("Couldn't write to ${cabname}_SourceDisk: $!\n");;
  1140. printf(hDDF "${CabFileName}=1,,$FileSize\n");
  1141. close(hDDF);
  1142. open(hDDF, ">>${cabname}_SourceFiles");
  1143. printf(hDDF "$source_file,$CabFileName,,\n");
  1144. close(hDDF);
  1145. }
  1146. # If there were not files, just leave
  1147. if ($FileIndex == -1) {
  1148. logerror("241: No files in the cab ($cabname)");
  1149. unlink("$filelist") ||die("$!\n");;
  1150. unlink("${cabname}_SourceFiles") ||die("$!\n");;
  1151. unlink("${cabname}_SourceDisk") ||die("$!\n");;
  1152. unlink("${cabname}_DestDirsFiles")||die("$!\n");;
  1153. return(15);
  1154. }
  1155. if ($verbose) {
  1156. print STDERR "Creating $cabname\n";
  1157. }
  1158. # Create the INF
  1159. CreateINF($cabname, $friendlyname, $InfCopyFileList, $FileIndex, $TotalSize);
  1160. # start cabarc
  1161. CreateNewProcess($cabname, $kit);
  1162. # Delete the temporary file list
  1163. unlink("$filelist");
  1164. return(1);
  1165. }
  1166. # --------------------------------------------------------------------------
  1167. # Builds the installation inf
  1168. # --------------------------------------------------------------------------
  1169. sub CreateINF {
  1170. my $CabName = shift;
  1171. my $FriendlyName = shift;
  1172. my $InfCopyFileList = shift;
  1173. my $FileIndex = shift;
  1174. my $TotalSize = shift;
  1175. my @lines;
  1176. open(hFILE, ">>${CabName}.inf")||return(25);
  1177. print hFILE<<EOF;
  1178. [Version]
  1179. AdvancedInf = 2
  1180. Signature =\"\$CHICAGO\$\"
  1181. SetupClass = Base
  1182. [DefaultInstall]
  1183. CopyFiles=${InfCopyFileList}
  1184. CustomDestination= PDCDest
  1185. RequiredEngine = setupapi;
  1186. AddReg = RegVersion,DocKey
  1187. [DefaultUninstall]
  1188. DelFiles=${InfCopyFileList}
  1189. CustomDestination= PDCDest
  1190. DelReg = RegVersion,DocKey
  1191. EOF
  1192. open(hADDFILE, "<${CabName}_DestDirsFiles");
  1193. @lines=<hADDFILE>;
  1194. close(hADDFILE);
  1195. foreach (@lines) {
  1196. printf(hFILE "$_");
  1197. }
  1198. unlink("${CabName}_DestDirsFiles")||die("$!\n");;
  1199. print hFILE<<EOF;
  1200. InfFiles=17,\"msddk\\${bldno}\"
  1201. DefaultDestDir=49000,\"${CabName}\"
  1202. [RegVersion]
  1203. \"HKLM\",\"SOFTWARE\\Microsoft\\WINDDK\\Restart\\Cabs\",\"${CabName}\",0,\"done\"
  1204. [PDCDest]
  1205. 49000,49001,49002=SDKCust, 17
  1206. [SDKCust]
  1207. ;if key below exists, use this string to seed install path
  1208. \"HKLM\", \"Software\\Microsoft\\WINDDK\", \"SFNDirectory\",,\"%DefaultDir%\"
  1209. [DocKey]
  1210. [InfFiles]
  1211. ${CabName}.inf
  1212. EOF
  1213. open(hADDFILE, "<${CabName}_SourceFiles");
  1214. @lines=<hADDFILE>;
  1215. close(hADDFILE);
  1216. foreach (@lines) {
  1217. printf(hFILE "$_");
  1218. }
  1219. unlink("${CabName}_SourceFiles")||die("$!\n");;
  1220. printf(hFILE "\n");
  1221. printf(hFILE "[SourceDisksNames]\n");
  1222. printf(hFILE "1=\"${CabName}.cab\",${CabName}.cab,0\n");
  1223. open(hADDFILE, "<${CabName}_SourceDisk");
  1224. @lines=<hADDFILE>;
  1225. close(hADDFILE);
  1226. foreach (@lines) {
  1227. printf(hFILE "$_");
  1228. }
  1229. unlink("${CabName}_SourceDisk")||die("$!\n");
  1230. $FileIndex++;
  1231. printf(hFILE "\n\n");
  1232. printf(hFILE "[Strings]\n");
  1233. printf(hFILE "FriendlyName=${FriendlyName}\n");
  1234. printf(hFILE "AppKey=SOFTWARE\\Microsoft\\WINDDK\n");
  1235. printf(hFILE "FileCount=${FileIndex}\n");
  1236. printf(hFILE "TotalSize=${TotalSize}\n");
  1237. close(hFILE);
  1238. return(0);
  1239. }
  1240. # --------------------------------------------------------------------------
  1241. # Starts a new process once there is room in the process table
  1242. # --------------------------------------------------------------------------
  1243. sub CreateNewProcess {
  1244. my $CabName = shift;
  1245. my $kit = shift;
  1246. my $ERRORLEVEL = 0;
  1247. my $ExitCode = 0;
  1248. my $i;
  1249. # Limit total running processes- label/goto construct needed because otherwise
  1250. # all processes are tested for instead of just finding the first one that has
  1251. # finished.
  1252. top:
  1253. while (@Processes >= $MAX_PROCESSES) {
  1254. for ($i=0;$i<=$#Processes;$i++) {
  1255. $Processes[$i][0]->GetExitCode( $ExitCode );
  1256. if ($ExitCode != 259 ) {
  1257. # Do post processes commands before removing it
  1258. $ERRORLEVEL= system("move /Y $Processes[$i][1].CAB $ENV{_NTTREE}\\$Processes[$i][2]_cd\\Common >nul 2>nul");
  1259. logerror("341: $Processes[$i][1].CAB could not be placed") if ($ERRORLEVEL);
  1260. $ERRORLEVEL= system("move /Y $Processes[$i][1].INF $ENV{_NTTREE}\\$Processes[$i][2]_cd\\Common >nul 2>nul");
  1261. logerror("342: $Processes[$i][1].INF could not be placed") if ($ERRORLEVEL);
  1262. $ERRORLEVEL=system("del /f $Processes[$i][1]_FILE_* 2>nul");
  1263. splice(@Processes,$i,1);
  1264. $i--; # Decrement count since the array changed
  1265. goto top;
  1266. }
  1267. }
  1268. sleep(2);
  1269. }
  1270. # Create the new process
  1271. Win32::Process::Create($i, $exe, "$exe $global_param ${CabName}.cab ${CabName}_FILE_*",
  1272. 0, DETACHED_PROCESS, "$ENV{TEMP}");
  1273. # Update the process table
  1274. push(@Processes, [$i,$CabName,$kit]);
  1275. }
  1276. # --------------------------------------------------------------------------
  1277. # Waits for all currently running processes to finish
  1278. # --------------------------------------------------------------------------
  1279. sub WaitForAllProcesses {
  1280. my $i;
  1281. my $ERRORLEVEL = 0;
  1282. for ($i=0;$i<=$#Processes;$i++) {
  1283. # Wait for current process to end
  1284. print(".") unless ($verbose);
  1285. $Processes[$i][0]->Wait( INFINITE );
  1286. # Do post processes commands
  1287. $ERRORLEVEL= system("move /Y $Processes[$i][1].CAB $ENV{_NTTREE}\\$Processes[$i][2]_cd\\Common >nul 2>nul");
  1288. $ERRORLEVEL+=system("move /Y $Processes[$i][1].INF $ENV{_NTTREE}\\$Processes[$i][2]_cd\\Common >nul 2>nul");
  1289. logerror(__LINE__.": $Processes[$i][1] could not be placed") if ($ERRORLEVEL);
  1290. $ERRORLEVEL=system("del /f $Processes[$i][1]_FILE_* 2>nul");
  1291. }
  1292. print("\n");
  1293. }
  1294. # --------------------------------------------------------------------------
  1295. # Error logging routines
  1296. # --------------------------------------------------------------------------
  1297. sub logdebug { my($errormsg)="DEBUG_MSG : @_";
  1298. logprint($errormsg);
  1299. return(TRUE);}
  1300. sub logerror { my($errormsg)="ERROR_MSG : @_";
  1301. logprint($errormsg);
  1302. return(TRUE);}
  1303. sub logmsg { my($errormsg)="BUILD_MSG : @_";
  1304. logprint($errormsg);
  1305. return(TRUE);}
  1306. sub logprint { open(hLogFile,">>$handle")||warn("@_\n");
  1307. printf(hLogFile "$0 : @_\n");
  1308. close(hLogFile);
  1309. return(TRUE);}
  1310. # --------------------------------------------------------------------------
  1311. # Program description and usage
  1312. # --------------------------------------------------------------------------
  1313. sub Usage {
  1314. print "
  1315. Usage: $0 [-n <N>] [-f] [-l <language>] [-s] [-v]
  1316. This tool requires a Razzle window.
  1317. Generates CABs for the Kernelmode Development Kits. N, which is
  1318. optional, indicates the number of processes to start per processor.
  1319. The default value is 2.
  1320. By default, $0 will exit early if the environment variable
  1321. OFFICAL_BUILD_MACHINE is not defined. To override this behavior,
  1322. and for CAB generation, use -F.
  1323. -L is used, and any language other than 'usa' is passed, CAB
  1324. generation will not take place.
  1325. -V turns on verbose mode. See what cabs are being built.
  1326. -S spoofs full postbuild. (DDKCabs.bat otherwise relies upon build_number.cmd)
  1327. Dependencies:
  1328. o The following environment variables are expected to be defined:
  1329. %_NTDRIVE%, %_NTROOT%, %_BUILDARCH%, %_BUILDTYPE%, %_NTTREE%,
  1330. %RazzleToolPath%, %NUMBER_OF_PROCESSORS%, %TEMP%, and
  1331. %PROCESSOR_ARCHITECTURE%.
  1332. o The following directory trees are assumed to exist:
  1333. 1) %_NTTREE%\\ddk_cd
  1334. 2) %_NTTREE%\\ddk_flat
  1335. 3) %_NTTREE%\\ifs_cd
  1336. 4) %_NTTREE%\\ifs_flat
  1337. 5) %_NTTREE%\\hal_cd
  1338. 6) %_NTTREE%\\hal_flat
  1339. ";
  1340. return(30);
  1341. }
  1342. __END__
  1343. :endofperl