PackageCleanCmd.pas 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. { Rev 1.0 1/24/2024 4:49:00 PM RLebeau
  18. { Clean_xxx.cmd generation.
  19. }
  20. unit PackageCleanCmd;
  21. interface
  22. uses
  23. Package;
  24. type
  25. TCleanCmd = class(TPackage)
  26. public
  27. constructor Create; override;
  28. procedure Generate(ACompiler: TCompiler; const AFlags: TGenerateFlags); override;
  29. end;
  30. implementation
  31. uses
  32. SysUtils;
  33. { TCleanCmd }
  34. constructor TCleanCmd.Create;
  35. begin
  36. inherited;
  37. FOutputSubDir := 'Lib';
  38. end;
  39. type
  40. TCleanInfo = record
  41. ProductName: string;
  42. Symbol: string;
  43. FileSuffix: string;
  44. end;
  45. const
  46. GCleanCompilers: array[TCompiler] of TCleanInfo = (
  47. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  48. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  49. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  50. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  51. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  52. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  53. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  54. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  55. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  56. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  57. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  58. (ProductName: 'Delphi 2007'; Symbol: 'D12'; FileSuffix: '2007'),
  59. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  60. (ProductName: 'Delphi 2009'; Symbol: 'D13'; FileSuffix: '2009'),
  61. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  62. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  63. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  64. (ProductName: 'Delphi 2010'; Symbol: 'D14'; FileSuffix: '2010'),
  65. (ProductName: 'Delphi XE'; Symbol: 'D15'; FileSuffix: 'XE'),
  66. (ProductName: 'Delphi XE2'; Symbol: 'D16'; FileSuffix: 'XE2'),
  67. (ProductName: 'Delphi XE3'; Symbol: 'D17'; FileSuffix: 'XE3'),
  68. (ProductName: 'Delphi XE4'; Symbol: 'D18'; FileSuffix: 'XE4'),
  69. (ProductName: 'Delphi XE5'; Symbol: 'D19'; FileSuffix: 'XE5'),
  70. (ProductName: 'Delphi XE6'; Symbol: 'D20'; FileSuffix: 'XE6'),
  71. (ProductName: 'Delphi XE7'; Symbol: 'D21'; FileSuffix: 'XE7'),
  72. (ProductName: 'Delphi XE8'; Symbol: 'D22'; FileSuffix: 'XE8'),
  73. (ProductName: 'Delphi 10.0 Seattle'; Symbol: 'D23'; FileSuffix: 'Seattle'),
  74. (ProductName: 'Delphi 10.1 Berlin'; Symbol: 'D24'; FileSuffix: 'Berlin'),
  75. (ProductName: 'Delphi 10.2 Tokyo'; Symbol: 'D25'; FileSuffix: 'Tokyo'),
  76. (ProductName: 'Delphi 10.3 Rio'; Symbol: 'D26'; FileSuffix: 'Rio'),
  77. (ProductName: 'Delphi 10.4 Sydney'; Symbol: 'D27'; FileSuffix: 'Sydney'),
  78. (ProductName: 'Delphi 11 Alexandria'; Symbol: 'D28'; FileSuffix: 'Alexandria'),
  79. (ProductName: 'Delphi 12 Athens'; Symbol: 'D29'; FileSuffix: 'Athens'),
  80. (ProductName: 'Delphi 13 Florence'; Symbol: 'D37'; FileSuffix: 'Florence'),
  81. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  82. (ProductName: ''; Symbol: ''; FileSuffix: '')
  83. );
  84. procedure TCleanCmd.Generate(ACompiler: TCompiler; const AFlags: TGenerateFlags);
  85. begin
  86. //We don't call many of the inherited Protected methods because
  87. //those are for Packages while I'm making a unit.
  88. //inherited;
  89. if (GCleanCompilers[ACompiler].ProductName = '') or
  90. (GCleanCompilers[ACompiler].Symbol = '') then Exit;
  91. FName := 'Clean_' + GCleanCompilers[ACompiler].FileSuffix;
  92. FExt := '.cmd';
  93. FCompiler := ACompiler;
  94. FCode.Clear;
  95. FDesignTime := False;
  96. Code('@echo off');
  97. Code('set DelphiProd=' + GCleanCompilers[ACompiler].ProductName);
  98. Code('');
  99. Code('if exist SetEnv.bat del SetEnv.bat');
  100. Code('if not exist computil.exe goto NoComputil');
  101. Code('computil Setup' + GCleanCompilers[ACompiler].Symbol);
  102. Code('if defined ND' + GCleanCompilers[ACompiler].Symbol + ' goto RSVARS');
  103. Code('if not exist SetEnv.bat goto NoNDD');
  104. Code('');
  105. Code('call SetEnv.bat > nul:');
  106. Code('if not defined ND' + GCleanCompilers[ACompiler].Symbol + ' goto NoNDD');
  107. Code('');
  108. Code(':RSVARS');
  109. Code('call "%ND' + GCleanCompilers[ACompiler].Symbol + '%bin\rsvars.bat"');
  110. Code('if not defined BDS goto NoBDS');
  111. Code('');
  112. Code('set logfn=Clean' + GCleanCompilers[ACompiler].Symbol + '.log');
  113. Code('');
  114. Code('call Clean_IDE.cmd');
  115. Code('goto END');
  116. Code('');
  117. Code(':NoCompUtil');
  118. Code('echo Computil.exe not found--run this batch script from the "Lib" folder of the Indy repository, recently pulled from GitHub.');
  119. Code('goto END');
  120. Code('');
  121. Code(':NoNDD');
  122. Code('echo Computil.exe did not create the batch script for setting up the environment for %DelphiProd%. Aborting.');
  123. Code('goto END');
  124. Code('');
  125. Code(':NoBDS');
  126. Code('echo Calling RSVars did not set up the environment for %DelphiProd%. Aborting.');
  127. Code('');
  128. Code(':END');
  129. Code('set logfn=');
  130. Code('set DelphiProd=');
  131. WriteFile;
  132. end;
  133. end.