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.

125 lines
4.0 KiB

  1. ###################################################
  2. # See layout.txt for explanation of what this does.
  3. ###################################################
  4. open(hLAYOUT, $ARGV[0]) || die "Can't open $ARGV[0]";
  5. open(hPLACEFIL, ">placefil.txt") || die "Can't open placefil.txt";
  6. open(hMAKE, ">layout.inc") || die "Can't open layout.inc";
  7. open(hPOSTMAKE, ">sdkmake.inc") || die "Can't open sdkmake.inc";
  8. print(hPLACEFIL "# --------- DO NOT EDIT THIS FILE ------------ DO NOT EDIT THIS FILE ---------\n");
  9. print(hPLACEFIL "# --------- DO NOT EDIT --- see layout.txt --- DO NOT EDIT -------------------\n");
  10. print(hPLACEFIL "# --------- DO NOT EDIT THIS FILE ------------ DO NOT EDIT THIS FILE ---------\n");
  11. print(hMAKE "# --------- DO NOT EDIT THIS FILE ------------ DO NOT EDIT THIS FILE ---------\n");
  12. print(hMAKE "# --------- DO NOT EDIT --- see layout.txt --- DO NOT EDIT -------------------\n");
  13. print(hMAKE "# --------- DO NOT EDIT THIS FILE ------------ DO NOT EDIT THIS FILE ---------\n");
  14. print(hLAYOUT "# --------- DO NOT EDIT THIS FILE ------------ DO NOT EDIT THIS FILE ---------\n");
  15. print(hLAYOUT "# --------- DO NOT EDIT --- see layout.txt --- DO NOT EDIT -------------------\n");
  16. print(hLAYOUT "# --------- DO NOT EDIT THIS FILE ------------ DO NOT EDIT THIS FILE ---------\n");
  17. while($_ = <hLAYOUT>) {
  18. if (/^[ \t]*REM/i) {
  19. s/-+//g;
  20. print $_;
  21. }
  22. elsif (/^[ \t]*$/) {
  23. }
  24. else {
  25. $DUPEFILE="";
  26. if (/^[0-9]/)
  27. {
  28. $DUPEFILE=substr($_,0,1);
  29. print "Creating special rules for same-name file ($DUPEFILE) in multiple locations.\n";
  30. s/^.//;
  31. }
  32. $PLACEFILE=$_;
  33. $SOURCE=$_;
  34. $PLACEFILE =~ s/.*[ \t]+//;
  35. $PLACEFILE =~ s/\\$//;
  36. $PLACEFILE =~ s/\n//;
  37. $PLACEFILE =~ s/^.$//;
  38. $_ = $PLACEFILE;
  39. if (!(/^retail$/i)) {
  40. if (/^$/) {
  41. $PLACEFILE =~ s/^/sdk/;
  42. }
  43. else {
  44. $PLACEFILE =~ s/^/sdk\\/ ;
  45. }
  46. }
  47. $SOURCE =~ s/[ \t]+.*\n//;
  48. # replace environment variable syntax with makefile. %var% -> $(var)
  49. $SOURCEMAKE = $SOURCEENV = $SOURCE;
  50. $SOURCEMAKE =~ s/%([_A-Z-]+)%/\$($1)/gi;
  51. #print SOURCE."\=".$SOURCE."\n";
  52. #print PLACEFILE."\=".$PLACEFILE."\n";
  53. #print "\n";
  54. print "Source: $SOURCEENV\n";
  55. open(FILELIST, "dir /on /b $SOURCEENV|");
  56. $ONCE = 0;
  57. while (($FILENAME = <FILELIST>) || !$ONCE) {
  58. if (! $ONCE)
  59. {
  60. $ONCE = 1;
  61. #
  62. # We need to handle lines in layout.txt that have wildcard characters in them. e.g. ActionTe.*, Error.*
  63. # In order to do that, we need to extract the dir for the files. This needs to be done only once for each
  64. # line because the dir will be the same for all the files that match the wildcard character. Then all we
  65. # need to do during each iteration of the loop is tag on the name of the file to the end of the dir.
  66. #
  67. $SOURCEDIR = $SOURCEMAKE;
  68. $SOURCEDIR =~ s/[^\\]+$//;
  69. }
  70. $_ = $FILENAME =~ s/\n$//;
  71. if (/^$/)
  72. {
  73. print "File has not been built yet.\n";
  74. $FILENAME = $SOURCEMAKE;
  75. $FILENAME =~ s/.+\\//g;
  76. }
  77. #
  78. # Append the filename to the dir to get the fullpath to the file.
  79. #
  80. $SOURCEMAKE = $SOURCEDIR.$FILENAME;
  81. $POSTMAKE=0;
  82. $_ = $SOURCEMAKE;
  83. if (/_NTTREE/i | /_NTPOSTBLD/i) {
  84. $SOURCEMAKE =~ s/_NTTREE/_NTPOSTBLD/i;
  85. $POSTDEPENDENCY ="$POSTDEPENDENCY $PLACEFILE\\$FILENAME$DUPEFILE";
  86. print(hPOSTMAKE "$PLACEFILE\\$FILENAME$DUPEFILE : \n\tif not exist $PLACEFILE md $PLACEFILE\n\tcopy $SOURCEMAKE \$@\n");
  87. $POSTMAKE=1;
  88. }
  89. else {
  90. $DEPENDENCY ="$DEPENDENCY \$(O)\\$FILENAME$DUPEFILE";
  91. print(hMAKE "\$(O)\\$FILENAME$DUPEFILE : $SOURCEMAKE\n\tcopy $SOURCEMAKE \$@\n\t\$(BINPLACE_CMD)\n");
  92. print(hPLACEFIL "$FILENAME$DUPEFILE $DUPEFILE$PLACEFILE\n");
  93. }
  94. if ($DUPEFILE) {
  95. print(hPOSTMAKE "$PLACEFILE\\$FILENAME : $DUPEFILE$PLACEFILE\\$FILENAME$DUPEFILE\n\tif not exist $PLACEFILE md $PLACEFILE\n\tcopy $DUPEFILE$PLACEFILE\\$FILENAME$DUPEFILE \$@\n");
  96. $POSTDEPENDENCY = "$POSTDEPENDENCY $PLACEFILE\\$FILENAME"
  97. }
  98. print $FILENAME."\n";
  99. }
  100. close FILELIST;
  101. }
  102. }
  103. print(hPOSTMAKE "sdklayout : $POSTDEPENDENCY\n");
  104. print(hMAKE "layout : $DEPENDENCY\n");
  105. close hMAKE;
  106. close hPOSTMAKE;
  107. close hLAYOUT;