PackageCleanCmd.pas 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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: ''; Symbol: ''; FileSuffix: ''),
  59. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  60. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  61. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  62. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  63. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  64. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  65. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  66. (ProductName: ''; Symbol: ''; FileSuffix: ''),
  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: ''; Symbol: ''; FileSuffix: ''),
  81. (ProductName: ''; Symbol: ''; FileSuffix: '')
  82. );
  83. procedure TCleanCmd.Generate(ACompiler: TCompiler; const AFlags: TGenerateFlags);
  84. begin
  85. //We don't call many of the inherited Protected methods because
  86. //those are for Packages while I'm making a unit.
  87. //inherited;
  88. if (GCleanCompilers[ACompiler].ProductName = '') or
  89. (GCleanCompilers[ACompiler].Symbol = '') then Exit;
  90. FName := 'Clean_' + GCleanCompilers[ACompiler].FileSuffix;
  91. FExt := '.cmd';
  92. FCompiler := ACompiler;
  93. FCode.Clear;
  94. FDesignTime := False;
  95. Code('@echo off');
  96. Code('set DelphiProd=' + GCleanCompilers[ACompiler].ProductName);
  97. Code('');
  98. Code('if exist SetEnv.bat del SetEnv.bat');
  99. Code('if not exist computil.exe goto NoComputil');
  100. Code('computil Setup' + GCleanCompilers[ACompiler].Symbol);
  101. Code('if defined ND' + GCleanCompilers[ACompiler].Symbol + ' goto RSVARS');
  102. Code('if not exist SetEnv.bat goto NoNDD');
  103. Code('');
  104. Code('call SetEnv.bat > nul:');
  105. Code('if not defined ND' + GCleanCompilers[ACompiler].Symbol + ' goto NoNDD');
  106. Code('');
  107. Code(':RSVARS');
  108. Code('call "%ND' + GCleanCompilers[ACompiler].Symbol + '%bin\rsvars.bat"');
  109. Code('if not defined BDS goto NoBDS');
  110. Code('');
  111. Code('set logfn=Clean' + GCleanCompilers[ACompiler].Symbol + '.log');
  112. Code('');
  113. Code('call Clean_IDE.cmd');
  114. Code('goto END');
  115. Code('');
  116. Code(':NoCompUtil');
  117. Code('echo Computil.exe not found--run this batch script from the "Lib" folder of the Indy repository, recently pulled from GitHub.');
  118. Code('goto END');
  119. Code('');
  120. Code(':NoNDD');
  121. Code('echo Computil.exe did not create the batch script for setting up the environment for %DelphiProd%. Aborting.');
  122. Code('goto END');
  123. Code('');
  124. Code(':NoBDS');
  125. Code('echo Calling RSVars did not set up the environment for %DelphiProd%. Aborting.');
  126. Code('');
  127. Code(':END');
  128. Code('set logfn=');
  129. Code('set DelphiProd=');
  130. WriteFile;
  131. end;
  132. end.