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.

215 lines
4.8 KiB

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S "%0" %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. goto endofperl
  11. @rem ';
  12. #!perl
  13. #line 14
  14. # MAN1 MAN2 MAN3 MAN16 MAN17 MAN18
  15. # 2^6 = 64, but skip 0
  16. sub log2
  17. {
  18. my($x) = ($_[0]);
  19. if ($x >= 64)
  20. {
  21. return 6;
  22. }
  23. if ($x >= 32)
  24. {
  25. return 5;
  26. }
  27. if ($x >= 16)
  28. {
  29. return 4;
  30. }
  31. if ($x >= 8)
  32. {
  33. return 3;
  34. }
  35. if ($x >= 4)
  36. {
  37. return 2;
  38. }
  39. if ($x >= 2)
  40. {
  41. return 1;
  42. }
  43. return 0;
  44. }
  45. @IndexToResourceId = (1, 2, 3, 16, 17, 18);
  46. $Newline = "\n";
  47. $Backslash = "\\";
  48. $Space = ' ';
  49. $Pound = '#';
  50. # $O = 'obj\\' . $ENV{'BUILD_ALT_DIR'} . '\\' . $ENV;
  51. $O = $ARGV[0] . '\\';
  52. # $O =~ s/\\/_/g;
  53. # $O =~ s/_$//g;
  54. mkdir($O, 0777);
  55. sub MakeDirs
  56. {
  57. my($O) = ($_[0]);
  58. my($Newline) = "\n";
  59. my($DirsPath);
  60. my(@OElements);
  61. my($First) = (1);
  62. $O =~ s/\\+/\\/g;
  63. $O =~ s/\/+/\//g;
  64. $O =~ s/\\$//g;
  65. $O =~ s/\/$//g;
  66. mkdir($O, 0777);
  67. @OElements = reverse(split(/\\/, $O));
  68. do
  69. {
  70. $NextElement = pop(@OElements);
  71. #open(fdirs, '> ' . $DirsPath . 'dirs') || die('unable to open ' . $DirsPath . '\\dirs');
  72. open(fdirs, '> ' . $DirsPath . 'mydirs') || die('unable to open ' . $DirsPath . '\\mydirs');
  73. print(fdirs 'DIRS=' . $Backslash . $Newline);
  74. if ($First)
  75. {
  76. $First = 0;
  77. print(fdirs ' tool1 ' . $Backslash . $Newline);
  78. }
  79. print(fdirs ' ' . $NextElement . ' ' . $Backslash . $Newline);
  80. $DirsPath .= $NextElement . '\\';
  81. mkdir($DirsPath, 0777);
  82. } while (@OElements);
  83. }
  84. mkdir($O, 0777);
  85. MakeDirs($O);
  86. open(fdirs, '> ' . $O . '\\dirs');
  87. print(fdirs 'DIRS=' . $Backslash . $Newline);
  88. for ($i = 1 ; $i < (1 << scalar @IndexToResourceId) ; $i += 1)
  89. {
  90. undef @ResourceIds;
  91. $NumberOfManifests = 0;
  92. for ($j = 0 ; $j < 1 + log2($i) ; $j += 1)
  93. {
  94. if (($i & (1 << $j)) != 0)
  95. {
  96. push(@ResourceIds, $IndexToResourceId[$j]);
  97. $NumberOfManifests += 1;
  98. }
  99. }
  100. $Name = 'xp';
  101. foreach $ResourceId (@ResourceIds)
  102. {
  103. $Name .= $ResourceId;
  104. }
  105. print(fdirs ' ' . $Name . $Space . $Backslash . $Newline);
  106. mkdir($O . $Backslash . $Name, 0777);
  107. #
  108. # makefile
  109. #
  110. open(f, '> ' . $O . $Name . $Backslash . 'makefile') || die('unable to open makefile');
  111. print(f '!include $(NTMAKEENV)\makefile.def' . $Newline);
  112. #
  113. # sxid12.manifest
  114. #
  115. open(f, '> ' . $O . $Name . $Backslash . 'sxid12.manifest') || die('unable to open ' . $O . $Name . 'sxid12.manifest');
  116. print(f '
  117. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  118. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  119. <assemblyIdentity
  120. name=SXS_ASSEMBLY_NAME
  121. version=SXS_ASSEMBLY_VERSION
  122. processorArchitecture=SXS_PROCESSOR_ARCHITECTURE
  123. type="win32"
  124. />
  125. </assembly>
  126. ');
  127. #
  128. # sxid12.c
  129. #
  130. open(f, '> ' . $O . $Name . $Backslash . 'sxid12.c') || die('unable to open sxid12.c');
  131. print(f '
  132. ' . $Pound . 'include "windows.h"
  133. ' . $Pound . 'include <stdio.h>
  134. int __cdecl main()
  135. {
  136. char path[MAX_PATH];
  137. path[0] = 0;
  138. if (!GetModuleFileName(NULL, path, MAX_PATH))
  139. printf("error %d\\n", (int)GetLastError());
  140. else
  141. printf("%s ran\n", path);
  142. return 0;
  143. }
  144. ');
  145. #
  146. # sxid12.rc
  147. #
  148. open(f, '> ' . $O . $Name . $Backslash . 'sxid12.rc') || die('unable to open sxid12.rc');
  149. print(f '#include "windows.h"' . $Newline);
  150. foreach $ResourceId (@ResourceIds)
  151. {
  152. print(f $ResourceId . ' RT_MANIFEST SXS_MANIFEST_OBJ1' . $Newline);
  153. }
  154. #
  155. # makefile.inc
  156. #
  157. # We do not want all that SXS_MANIFEST_IN_RESOURCES implies.
  158. # This does not work completely, we still get extra rc_temp files, but their contents
  159. #are ok.
  160. open(f, '> ' . $O . $Name . $Backslash . 'makefile.inc') || die('unable to open ' . $O . $Name . 'makefile.inc');
  161. print(f '
  162. !undef RC_FORCE_INCLUDE_STRING
  163. !undef RC_FORCE_INCLUDE_FILES
  164. RC_FORCE_INCLUDE_FILES_CMD=echo.
  165. ');
  166. #
  167. # sources
  168. #
  169. open(f, '> ' . $O . $Name . $Backslash . 'sources') || die('unable to open ' . $O . $Name . 'sources');
  170. print(f '
  171. TARGETTYPE=PROGRAM
  172. TARGETNAME=sxid12
  173. TARGETPATH=obj
  174. SOURCES=sxid12.rc sxid12.c
  175. SXS_MANIFEST=sxid12.manifest
  176. USE_MAKEFILE_INC=1
  177. SXS_ASSEMBLY_NAME=foo
  178. SXS_ASSEMBLY_VERSION=1.0
  179. SXS_ASSEMBLY_LANGUAGE_INDEPENDENT=1
  180. SXS_NO_BINPLACE=1
  181. NO_BINPLACE=1
  182. SXS_MANIFEST_IN_RESOURCES=1
  183. UMENTRY=main
  184. UMTYPE=console
  185. ');
  186. }
  187. __END__
  188. :endofperl