VersionMarker.dpr 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 115447: VersionMarker.dpr
  11. {
  12. { Rev 1.5 3/28/2005 6:02:02 AM JPMugaas
  13. { New packages.
  14. }
  15. {
  16. { Rev 1.4 3/3/2005 7:44:44 PM JPMugaas
  17. { Version information for packages.
  18. }
  19. {
  20. { Rev 1.3 3/3/2005 4:46:10 PM JPMugaas
  21. { Now manages version info for other stuff.
  22. }
  23. {
  24. { Rev 1.2 3/03/05 1:32:34 PM czhower
  25. { update
  26. }
  27. program VersionMarker;
  28. {$APPTYPE CONSOLE}
  29. uses
  30. Classes,
  31. INIFiles,
  32. SysUtils;
  33. const
  34. MASK_COPYRIGHT = '{COPYRIGHT}';
  35. MASK_COMPANY = '{COMPANY}';
  36. MASK_MAJOR = '{MAJORVER}';
  37. MASK_MINOR = '{MINORVER}';
  38. MASK_POINT = '{POINTVER}';
  39. NASK_TITLE = '{TITLE}';
  40. MASK_DESCRIPTION = '{DESCRIPTION}';
  41. //I know that globals look sloppy but this might be a good case
  42. //for them
  43. const
  44. // xIdVersFile = 'W:\source\Indy10\Lib\System\IdVers.inc';
  45. gIdVersFile = 'Lib\System\IdVers.inc';
  46. var
  47. gBasePath : string;
  48. gIniPath : String;
  49. xINI: TINIFile;
  50. xVerMajor: Integer;
  51. xVerMinor: Integer;
  52. xVerPoint: Integer;
  53. xVerString: string;
  54. xCopyright: string;
  55. xCompany : String;
  56. xTitle : String;
  57. xDescription : String;
  58. procedure ReplaceInFile(const ASourceFileName, ADestFileName : String);
  59. var S : TStrings;
  60. LTmp : String;
  61. begin
  62. s := TStringList.Create;
  63. try
  64. s.LoadFromFile( ASourceFileName);
  65. LTmp := s.Text; //xVerString
  66. LTmp := SysUtils.StringReplace(LTmp,MASK_COPYRIGHT,xCopyright,[rfReplaceAll]);
  67. LTmp := SysUtils.StringReplace(LTmp,MASK_COMPANY,xCompany,[rfReplaceAll]);
  68. LTmp := SysUtils.StringReplace(LTmp,MASK_DESCRIPTION,xDescription+' '+ xVerString,[rfReplaceAll]);
  69. LTmp := SysUtils.StringReplace(LTmp,NASK_TITLE,xTitle,[rfReplaceAll]);
  70. LTmp := SysUtils.StringReplace(LTmp,MASK_MAJOR,IntToStr(xVerMajor),[rfReplaceAll]);
  71. LTmp := SysUtils.StringReplace(LTmp,MASK_MINOR,IntToStr(xVerMinor),[rfReplaceAll]);
  72. LTmp := SysUtils.StringReplace(LTmp,MASK_POINT,IntToStr(xVerPoint),[rfReplaceAll]);
  73. s.Text := LTmp;
  74. s.SaveToFile( ADestFileName );
  75. finally
  76. FreeAndNil(s);
  77. end;
  78. end;
  79. function CurrentYear : Word;
  80. var lm, ld : Word;
  81. begin
  82. SysUtils.DecodeDate(Now,Result,lm,ld);
  83. end;
  84. procedure Main;
  85. begin
  86. //find base path
  87. if ParamCount > 0 then
  88. begin
  89. gBasePath := ParamStr(1)+'\';
  90. end
  91. else
  92. begin
  93. gBasePath := ExtractFilePath(ParamStr(0));
  94. end;
  95. gIniPath := gBasePath+'Builder\VersionMarker\'+ExtractFileName(ChangeFileExt(ParamStr(0), '.ini'));
  96. try
  97. //10.2.5
  98. xINI := TINIFile.Create(gIniPath); try
  99. xVerMajor := xINI.ReadInteger('Version', 'Major', 10);
  100. xVerMinor := xINI.ReadInteger('Version', 'Minor', 0);
  101. xVerPoint := xINI.ReadInteger('Version', 'Point', 60) + 1;
  102. xVerString := IntToStr(xVerMajor) + '.' + IntToStr(xVerMinor) + '.'
  103. + IntToStr(xVerPoint);
  104. xCopyright := xINI.ReadString('Version','Copyright','Copyright © 1993 - '+ IntToStr(CurrentYear)+ ' Chad Z. Hower a.k.a Kudzu and the Indy Pit Crew');
  105. xCompany := xINI.ReadString('Version','Company','Chad Z. Hower a.k.a Kudzu and the Indy Pit Crew');
  106. xTitle := xINI.ReadString('Version','Title','Indy');
  107. xDescription := xINI.ReadString('Version','Description','Internet Direct (Indy)');
  108. with TStringList.Create do try
  109. LoadFromFile(gBasePath + gIdVersFile);
  110. Strings[0] := ' gsIdVersion = ''' + xVerString + '''; {do not localize}';
  111. SaveToFile(gBasePath + gIdVersFile);
  112. finally Free; end;
  113. // FB script for VS.NET
  114. xINI.WriteInteger('Version', 'Major', xVerMajor);
  115. xINI.WriteInteger('Version', 'Minor', xVerMinor);
  116. xINI.WriteInteger('Version', 'Point', xVerPoint);
  117. xINI.WriteString('Version', 'String', xVerString);
  118. //
  119. xINI.WriteString(xVerString, 'Date', DateToStr(Date));
  120. WriteLn(xVerString);
  121. finally FreeAndNil(xINI); end;
  122. //protocols packages - design time
  123. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndy100.rc',gBasePath+'\Lib\Protocols\dclIndyProtocols120.rc');
  124. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndy100.rc',gBasePath+'\Lib\Protocols\dclIndyProtocols100.rc');
  125. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndy90.rc',gBasePath+'Lib\Protocols\dclIndyProtocols90.rc');
  126. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndy70.rc',gBasePath+'Lib\Protocols\dclIndyProtocols70.rc');
  127. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndy60.rc',gBasePath+'Lib\Protocols\dclIndyProtocols60.rc');
  128. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndy50.rc',gBasePath+'Lib\Protocols\dclIndyProtocols50.rc');
  129. //protocols packages - run time
  130. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\Indy100.rc',gBasePath+'Lib\Protocols\IndyProtocols120.rc');
  131. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\Indy100.rc',gBasePath+'Lib\Protocols\IndyProtocols100.rc');
  132. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\Indy90.rc',gBasePath+'Lib\Protocols\IndyProtocols90.rc');
  133. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\Indy70.rc',gBasePath+'Lib\Protocols\IndyProtocols70.rc');
  134. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\Indy60.rc',gBasePath+'Lib\Protocols\IndyProtocols60.rc');
  135. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\Indy50.rc',gBasePath+'Lib\Protocols\IndyProtocols50.rc');
  136. //core package - design time
  137. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndyCore120.rc',gBasePath+'Lib\Core\dclIndyCore120.rc');
  138. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndyCore100.rc',gBasePath+'Lib\Core\dclIndyCore100.rc');
  139. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndyCore90.rc',gBasePath+'Lib\Core\dclIndyCore90.rc');
  140. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndyCore70.rc',gBasePath+'Lib\Core\dclIndyCore70.rc');
  141. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndyCore60.rc',gBasePath+'Lib\Core\dclIndyCore60.rc');
  142. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\dclIndyCore50.rc',gBasePath+'Lib\Core\dclIndyCore50.rc');
  143. //core package - run time
  144. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndyCore120.rc',gBasePath+'Lib\Core\IndyCore120.rc');
  145. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndyCore100.rc',gBasePath+'Lib\Core\IndyCore100.rc');
  146. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndyCore90.rc',gBasePath+'Lib\Core\IndyCore90.rc');
  147. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndyCore70.rc',gBasePath+'Lib\Core\IndyCore70.rc');
  148. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndyCore60.rc',gBasePath+'Lib\Core\IndyCore60.rc');
  149. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndyCore50.rc',gBasePath+'Lib\Core\IndyCore50.rc');
  150. //core package - run time
  151. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndySystem120.rc',gBasePath+'Lib\System\IndySystem120.rc');
  152. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndySystem100.rc',gBasePath+'Lib\System\IndySystem100.rc');
  153. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndySystem90.rc',gBasePath+'Lib\System\IndySystem90.rc');
  154. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndySystem70.rc',gBasePath+'Lib\System\IndySystem70.rc');
  155. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndySystem60.rc',gBasePath+'Lib\System\IndySystem60.rc');
  156. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IndySystem50.rc',gBasePath+'Lib\System\IndySystem50.rc');
  157. // Borland Delphi Studio Packages for DotNET version info
  158. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IdSystem90ASM90.inc',gBasePath+'Lib\System\IdSystem90ASM90.inc');
  159. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IddclCore90ASM90.inc',gBasePath+'Lib\Core\IddclCore90ASM90.inc');
  160. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IdCore90ASM90.inc',gBasePath+'Lib\Core\IdCore90ASM90.inc');
  161. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IddclProtocols90ASM90.inc',gBasePath+'Lib\Protocols\IddclProtocols90ASM90.inc');
  162. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IdProtocols90ASM90.inc',gBasePath+'Lib\Protocols\IdProtocols90ASM90.inc');
  163. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IddclSecurity90ASM90.inc',gBasePath+'Lib\Security\IddclSecurity90ASM90.inc');
  164. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IdSecurity90ASM90.inc',gBasePath+'Lib\Security\IdSecurity90ASM90.inc');
  165. //IdAssemblyInfo for Visual Studio .NET
  166. ReplaceInFile(gBasePath+ 'Builder\VersionMarker\Data\IdAssemblyInfo.pas',gBasePath+'Lib\System\IdAssemblyInfo.pas');
  167. except
  168. on E: Exception do begin
  169. WriteLn(E.Message);
  170. ReadLn;
  171. end;
  172. end;
  173. end;
  174. begin
  175. Main;
  176. end.