⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jclinstall.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 4 页
字号:
{**************************************************************************************************}
{                                                                                                  }
{ Project JEDI Code Library (JCL) extension                                                        }
{                                                                                                  }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the    }
{ License at http://www.mozilla.org/MPL/                                                           }
{                                                                                                  }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF   }
{ ANY KIND, either express or implied. See the License for the specific language governing rights  }
{ and limitations under the License.                                                               }
{                                                                                                  }
{ The Original Code is JclInstall.pas.                                                             }
{                                                                                                  }
{ The Initial Developer of the Original Code is Petr Vones. Portions created by Petr Vones are     }
{ Copyright (C) of Petr Vones. All Rights Reserved.                                                }
{                                                                                                  }
{ Contributor(s): Robert Rossmair (crossplatform & BCB support, refactoring)                       }
{                                                                                                  }
{ Last modified: $Date: 2005/03/05 06:33:17 $                                                      }
{                                                                                                  }
{**************************************************************************************************}

unit JclInstall;

interface

{$I jcl.inc}
{$I crossplatform.inc}

uses
  SysUtils, Classes, IniFiles, Contnrs,
  JclSysUtils, JclBorlandTools, JediInstall;

type
  TJclDistribution = class;

  TJclInstallation = class
  private
    FDistribution: TJclDistribution;
    FTarget: TJclBorRADToolInstallation;
    FDebugDcuDir: string;
    FLibDir: string;
    FLibObjDir: string;
    FDefines: TStringList;
    FUnits: TStringList;
    FOnWriteLog: TTextHandler;
    procedure AddDialogToRepository(const DialogName: string; const DialogFileName: string;
      const DialogIconFileName: string; const Designer: string; const Ancestor: string = '');
    procedure BuildUnitList(const SubDir: string; Units: TStrings);
    function GetProgressTotal: Integer;
    function GetTool: IJediInstallTool;
    function GetUnits(const SourceDir: string): TStrings;
    function InitOptions: Boolean;
    procedure InstallationStarted;
    procedure InstallationFinished;
    procedure InstallFailedOn(const InstallObj: string);
    function InstallPackageSourceFile(const Name: string): Boolean;
    function InstallRunTimePackage(const BaseName: string): Boolean;
    function InstallOption(Option: TJediInstallOption): Boolean;
    procedure RemoveDialogFromRepository(const DialogName, DialogFileName: string);
    function UninstallPackage(const Name: string): Boolean;
    function UninstallRunTimePackage(const BaseName: string): Boolean;
    function UninstallOption(Option: TJediInstallOption): Boolean;
    function LogFileName: string;
    function MakeUnits(Debug: Boolean): Boolean;
    function MakePath(const FormatStr: string): string;
    function Description(Option: TJediInstallOption): string;
    procedure SaveOption(Option: TJediInstallOption);
    procedure SaveOptions;
    procedure Progress(Steps: Integer);
    function StoredOption(Option: TJediInstallOption; Default: Boolean = True): Boolean;
    function TotalUnitCount: Integer;
    procedure WriteLog(const Msg: string);
  protected
    constructor Create(JclDistribution: TJclDistribution; InstallTarget: TJclBorRADToolInstallation);
    function CompileLibraryUnits(const SubDir: string; Debug: Boolean): Boolean;
    {$IFDEF MSWINDOWS}
    procedure AddHelpToIdeTools;
    procedure AddHelpToOpenHelp;
    procedure RemoveHelpFromIdeTools;
    procedure RemoveHelpFromOpenHelp;
    {$ENDIF MSWINDOWS}
    function BplPath: string;
    function DcpPath: string;
    function CheckDirectories: Boolean;
    procedure CleanupRepository;
    function InstallSelectedOptions: Boolean;
    function UninstallSelectedOptions: Boolean;
    function OptionSelected(Option: TJediInstallOption): Boolean;
    function ProgressWeight(Option: TJediInstallOption): Integer;
    function Run: Boolean;
    function Undo: Boolean;
    function StoredBplPath: string;
    function StoredDcpPath: string;
    property Defines: TStringList read FDefines;
    property Distribution: TJclDistribution read FDistribution;
    property Tool: IJediInstallTool read GetTool;
    property DebugDcuDir: string read FDebugDcuDir;
    property LibDir: string read FLibDir;
    property LibObjDir: string read FLibObjDir;
    property ProgressTotal: Integer read GetProgressTotal;
    property Target: TJclBorRADToolInstallation read FTarget;
    property Units[const SourceDir: string]: TStrings read GetUnits;
  public
    destructor Destroy; override;
    property OnWriteLog: TTextHandler read FOnWriteLog write FOnWriteLog;
  end;

  TJclDistribution = class (TInterfacedObject, IJediInstall)
  private
    FJclPath: string;
    FLibDirMask: string;
    FLibDebugDirMask: string;
    FLibObjDirMask: string;
    FJclSourceDir: string;
    FJclSourcePath: string;
    FClxDialogFileName: string;
    FClxDialogIconFileName: string;
    {$IFDEF MSWINDOWS}
    FVclDialogFileName: string;
    FVclDialogSendFileName: string;
    FVclDialogIconFileName: string;
    FVclDialogSendIconFileName: string;
    {$ENDIF MSWINDOWS}
    FJclChmHelpFileName: string;
    FJclHlpHelpFileName: string;
    FJclReadmeFileName: string;
    FTool: IJediInstallTool;
    FTargetInstalls: TObjectList;
    FIniFile: TMemIniFile;
    FProgress: Integer;
    FProgressTotal: Integer;
    FProgressPercent: Integer;
    FOnStarting: TInstallationEvent;
    FOnEnding: TInstallationEvent;
    FOnProgress: TInstallationProgressEvent;
    function CreateInstall(Target: TJclBorRADToolInstallation): Boolean;
    function GetTargetInstall(Installation: TJclBorRADToolInstallation): TJclInstallation;
    procedure InitInstallationTargets;
    procedure InitProgress;
  protected
    constructor Create;
    function DocFileName(const BaseFileName: string): string;
    procedure InstallProgress(Steps: Integer);
    procedure SetTool(const Value: IJediInstallTool);
    procedure ShowProgress;
    property TargetInstall[Target: TJclBorRADToolInstallation]: TJclInstallation read GetTargetInstall;
  public
    destructor Destroy; override;
    function FeatureInfoFileName(FeatureID: Cardinal): string;
    function GetHint(Option: TJediInstallOption): string;
    function InitInformation(const ApplicationFileName: string): Boolean;
    function Install: Boolean;
    function Uninstall: Boolean;
    function ReadmeFileName: string;
    procedure SetOnWriteLog(Installation: TJclBorRADToolInstallation; Value: TTextHandler);
    procedure SetOnEnding(Value: TInstallationEvent);
    procedure SetOnProgress(Value: TInstallationProgressEvent);
    procedure SetOnStarting(Value: TInstallationEvent);
    function Supports(Target: TJclBorRADToolInstallation): Boolean;
    property ChmHelpFileName: string read FJclChmHelpFileName;
    property HlpHelpFileName: string read FJclHlpHelpFileName;
    property Path: string read FJclPath;
    property SourceDir: string read FJclSourceDir;
    property SourcePath: string read FJclSourcePath;
    property Tool: IJediInstallTool read FTool write SetTool;
  end;

function CreateJclInstall: IJediInstall;
function LogFileName(Target: TJclBorRADToolInstallation): string;

implementation

uses
  JclBase, JclSysInfo, JclFileUtils, JclStrings;

{ Install option data }

resourcestring
// Captions

  // Products
  RsJCL                  = 'JEDI Code Library';

  // Common features
  RsDefThreadSafe        = 'Thread safe container classes';
  RsDefDropObsoleteCode  = 'Drop obsolete code';
  RsDefMathPrecSingle    = 'Single float precision';
  RsDefMathPrecDouble    = 'Double float precision';
  RsDefMathPrecExtended  = 'Extended float precision';
  RsEnvironment          = 'Environment';
  RsEnvLibPath           = 'Add JCL to IDE Library Path';
  RsEnvBrowsingPath      = 'Add JCL to IDE Browsing Path';
  RsEnvDebugDCUPath      = 'Add JCL to Debug DCU Path';
  RsMake                 = 'Make library units';
  RsMakeRelease          = 'Release';
  RsMakeDebug            = 'Debug';
  RsMakeVClx             = 'Visual CLX';

  RsHelpFiles            = 'Help files';
  RsIdeExperts           = 'IDE experts';
  RsJCLPackages          = 'Packages';
  RsIdeHelpHlp           = 'Add help file to IDE help system';
  RsIdeHelpChm           = 'Add HTML help to the Tools menu';
  RsCopyHppFiles         = 'Copy HPP files to %s';
  RsCopyPackagesHppFiles = 'Output HPP files to %s';

  // Product specific features
  RsJCLExceptDlg         = 'Sample Exception Dialogs in the Object Reporitory';
  RsJCLDialogVCL         = 'VCL Exception Dialog';
  RsJCLDialogVCLSnd      = 'VCL Exception Dialog with Send button';
  RsJCLDialogCLX         = 'CLX Exception Dialog';
  RsJCLIdeDebug          = 'Debug Extension';
  RsJCLIdeAnalyzer       = 'Project Analyzer';
  RsJCLIdeFavorite       = 'Favorite combobox in Open/Save dialogs';
  RsJCLIdeThrNames       = 'Displaying thread names in Thread Status window';
  RsJCLIdeUses           = 'Uses Wizard';

// Hints
  RsHintTarget = 'Installation target';
  RsHintJCL = 'Select to install JCL for this target.';
  RsHintJclDefThreadSafe        = 'Thread safe container classes';
  RsHintJclDefDropObsoleteCode  = 'Drop obsolete code';
  RsHintJclDefMathPrecSingle    = 'Single float precision';
  RsHintJclDefMathPrecDouble    = 'Double float precision';
  RsHintJclDefMathPrecExtended  = 'Extended float precision';
  RsHintJclEnv = 'Set selected environment items';
  RsHintJclEnvLibPath = 'Add JCL precompiled unit directories to library path';
  RsHintJclEnvBrowsingPath = 'Add JCL source directories to browsing path';
  RsHintJclEnvDebugDCUPath = 'This is a prerequisite for using the precompiled JCL debug units ' +
    'by means of the respective'#13#10'Project Options|Compiler switch. See "Make library ' +
    'units/Debug" option below.';
  RsHintJclMake = 'Generate .dcu and .dpu (Kylix only) files.'#13#10'Recommended.';
  RsHintJclMakeRelease = 'Make precompiled units for release, i.e. optimized, w/o debug information.';
  RsHintJclMakeReleaseVcl = 'Make precompiled VCL units for release';
  RsHintJclMakeReleaseVClx = 'Make precompiled Visual CLX units for release';
  RsHintJclMakeDebug = 'Make precompiled units for debugging, i.e.optimization off, debug ' +
    'information included.'#13#10'When installed, available through Project Options|Compiler|Use ' +
    'Debug DCUs.';
  RsHintJclMakeDebugVcl = 'Make precompiled VCL units for debugging';
  RsHintJclMakeDebugVClx = 'Make precompiled Visual CLX units for debugging';
  RsHintJclCopyHppFiles = 'Copy .hhp files into C++Builder''s include path.';
  RsHintJclPackages = 'Build and eventually install JCL runtime packages (RTL, VCL and Visual ' +
    'CLX) and optional IDE experts.';
  RsHintJclExperts = 'Build and install selected IDE experts.';
  RsHintJclExpertDebug = 'Install IDE expert which assists to insert JCL Debug information into ' +
    'executable files.';
  RsHintJclExpertAnalyzer = 'Install IDE Project Analyzer.';
  RsHintJclExpertFavorite = 'Install "Favorites" combobox in IDE Open/Save dialogs.';
  RsHintJclExpertsThrNames = 'Display thread names in Thread Status window IDE extension.';
  RsHintJclExpertUses = 'Install IDE Uses Wizard.';
  RsHintJclCopyPackagesHppFiles = 'Output .hhp files into C++Builder''s include path instead of ' +
    'the source paths.';
  RsHintJclExcDialog = 'Add selected Exception dialogs to the Object Repository.';
  RsHintJclExcDialogVCL = 'Add VCL exception dialog to the Object Repository.';
  RsHintJclExcDialogVCLSnd = 'Add VCL exception dialog with "Send Button" to the Object Repository.';
  RsHintJclExcDialogCLX = 'Add CLX exception dialog (Windows only) to the Object Repository.';
  RsHintJclHelp = 'Install JCL help files.';
  RsHintJclHelpHlp = 'Customize Borland Open Help to include JCL help files.';
  RsHintJclHelpChm = '';

const
  Invalid = -1;
  LineBreak = AnsiLineBreak;
  ioUndef = TJediInstallOption(Invalid);

  InitData: array[TJediInstallOption] of TInstallOptionData =
    (
      (Parent: ioUndef;                  // ioTarget
       Caption: '';
       Hint: RsHintTarget),
      (Parent: ioTarget;                 // ioJCL
       Caption: RsJCL;
       Hint: RsHintJcl),
      (Parent: ioJCL;                   // ioJclDefThreadSafe
       Caption: RsDefThreadSafe;
       Hint: RsHintJclDefThreadSafe),
      (Parent: ioJCL;                   // ioJclDefDropObsoleteCode
       Caption: RsDefDropObsoleteCode;
       Hint: RsHintJclDefDropObsoleteCode),
      (Parent: ioJCL;                   // ioJclDefMathPrecSingle
       Caption: RsDefMathPrecSingle;
       Hint: RsHintJclDefMathPrecSingle),
      (Parent: ioJCL;                   // ioJclDefMathPrecDouble
       Caption: RsDefMathPrecDouble;
       Hint: RsHintJclDefMathPrecDouble),
      (Parent: ioJCL;                   // ioJclDefMathPrecExtended
       Caption: RsDefMathPrecExtended;
       Hint: RsHintJclDefMathPrecExtended),
      (Parent: ioJCL;                    // ioJclEnv
       Caption: RsEnvironment;
       Hint: RsHintJclEnv),
      (Parent: ioJclEnv;                 // ioJclEnvLibPath
       Caption: RsEnvLibPath;
       Hint: RsHintJclEnvLibPath),
      (Parent: ioJclEnv;                 // ioJclEnvBrowsingPath
       Caption: RsEnvBrowsingPath;
       Hint: RsHintJclEnvBrowsingPath),
      (Parent: ioJclEnv;                 // ioJclEnvDebugDCUPath
       Caption: RsEnvDebugDCUPath;
       Hint: RsHintJclEnvDebugDCUPath),
      (Parent: ioJCL;                    // ioJclMake
       Caption: RsMake;
       Hint: RsHintJclMake),
      (Parent: ioJclMake;                // ioJclMakeRelease
       Caption: RsMakeRelease;
       Hint: RsHintJclMakeRelease),
      (Parent: ioJclMake;                // ioJclMakeReleaseVClx
       Caption: RsMakeVClx;
       Hint: RsHintJclMakeReleaseVClx),
      (Parent: ioJclMake;                // ioJclMakeDebug
       Caption: RsMakeDebug;
       Hint: RsHintJclMakeDebug),
      (Parent: ioJclMake;                // ioJclMakeDebugVClx
       Caption: RsMakeVClx;
       Hint: RsHintJclMakeDebugVClx),
      (Parent: ioJclMake;                // ioJclCopyHppFiles
       Caption: RsCopyHppFiles;
       Hint: RsHintJclCopyHppFiles),
      (Parent: ioJCL;                    // ioJclPackages
       Caption: RsJCLPackages;
       Hint: RsHintJclPackages),
      (Parent: ioJclPackages;            // ioJclExperts
       Caption: RsIdeExperts;
       Hint: RsHintJclExperts),
      (Parent: ioJclExperts;             // ioJclExpertDebug
       Caption: RsJCLIdeDebug;
       Hint: RsHintJclExpertDebug),
      (Parent: ioJclExperts;             // ioJclExpertAnalyzer
       Caption: RsJCLIdeAnalyzer;
       Hint: RsHintJclExpertAnalyzer),
      (Parent: ioJclExperts;             // ioJclExpertFavorite
       Caption: RsJCLIdeFavorite;
       Hint: RsHintJclExpertFavorite),
      (Parent: ioJclExperts;             // ioJclExpertsThrNames
       Caption: RsJCLIdeThrNames;
       Hint: RsHintJclExpertsThrNames),
      (Parent: ioJclExperts;             // ioJclExpertUses
       Caption: RsJCLIdeUses;
       Hint: RsHintJclExpertUses),
      (Parent: ioJclPackages;            // ioJclCopyPackagesHppFiles
       Caption: RsCopyPackagesHppFiles;
       Hint: RsHintJclCopyPackagesHppFiles),
      (Parent: ioJCL;                    // ioJclExcDialog
       Caption: RsJCLExceptDlg;
       Hint: RsHintJclExcDialog),
      (Parent: ioJclExcDialog;           // ioJclExcDialogVCL
       Caption: RsJCLDialogVCL;
       Hint: RsHintJclExcDialogVCL),
      (Parent: ioJclExcDialog;           // ioJclExcDialogVCLSnd
       Caption: RsJCLDialogVCLSnd;
       Hint: RsHintJclExcDialogVCLSnd),
      (Parent: ioJclExcDialog;           // ioJclExcDialogCLX
       Caption: RsJCLDialogCLX;
       Hint: RsHintJclExcDialogCLX),
      (Parent: ioJCL;                    // ioJclHelp
       Caption: RsHelpFiles;
       Hint: RsHintJclHelp),
      (Parent: ioJclHelp;                // ioJclHelpHlp
       Caption: RsIdeHelpHlp;
       Hint: RsHintJclHelpHlp),
      (Parent: ioJclHelp;                // ioJclHelpChm
       Caption: RsIdeHelpChm;
       Hint: RsHintJclHelpChm)
    );

const
  {$IFDEF KYLIX}
  VersionDir = '/k%d';
  VersionDirExp = '/k%%d';
  {$ELSE}
  VersionDir = '\%s%d';
  VersionDirExp = '\%%s%%d';
  {$ENDIF}

  JclSrcDirCommon   = 'common';
  JclSrcDirVisClx   = 'visclx';

  {$IFDEF MSWINDOWS}
  {$IFNDEF RTL140_UP}
  PathSep = ';';
  {$ENDIF RTL140_UP}
  VclDialogFileName = 'ExceptDlg.pas';
  VclDlgSndFileName = 'ExceptDlgMail.pas';
  VclDialogName     = 'Exception Dialog';
  VclDialogNameSend = 'Exception Dialog with Send';

  JclIdeDebugDpk    = 'examples\vcl\debugextension\JclDebugIde%d0.dpk';
  JclIdeAnalyzerDpk = 'examples\vcl\projectanalyzer\ProjectAnalyzer%d0.dpk';
  JclIdeFavoriteDpk = 'examples\vcl\idefavopendialogs\IdeOpenDlgFavorite%d0.dpk';
  JclIdeThrNamesDpk = 'examples\vcl\debugextension\threadnames\ThreadNameExpert%d0.dpk';
  JclIdeUsesDpk     = 'examples\vcl\juw\JediUsesD%d0.dpk';  

  ExpertPaths: array[ioJclExpertDebug..ioJclExpertUses] of string =
    (
      JclIdeDebugDpk,
      JclIdeAnalyzerDpk,
      JclIdeFavoriteDpk,
      JclIdeThrNamesDpk,
      JclIdeUsesDpk
    );

  JclSrcDirOS       = 'windows';
  JclSrcDirVcl      = 'vcl';
  JclSourceDirs: array[0..3] of string = (JclSrcDirCommon, JclSrcDirOS, JclSrcDirVcl, JclSrcDirVisClx);
  JclSourcePath     = '%0:s\' + JclSrcDirOS +
                     ';%0:s\' + JclSrcDirCommon +
                     ';%0:s\' + JclSrcDirVcl +
                     ';%0:s\' + JclSrcDirVisClx;
  BCBIncludePath    = '%s;%s;$(BCB)\include;$(BCB)\include\vcl';
  BCBObjectPath     = '%s;%s;$(BCB)\Lib\Obj';
  {$ENDIF MSWINDOWS}
  {$IFDEF UNIX}
  JclSrcDirOS       = 'unix';
  JclSourceDirs: array[0..2] of string = (JclSrcDirCommon, JclSrcDirOS, JclSrcDirVisClx);
  JclSourcePath     = '%0:s\' + JclSrcDirOS +
                     ':%0:s\' + JclSrcDirCommon +
                     ':%0:s\' + JclSrcDirVisClx;
  BCBIncludePath    = '%s:%s:$(BCB)/include:$(BCB)/include/vcl';
  BCBObjectPath     = BCBIncludePath;
  {$ENDIF UNIX}

  DialogsPath       = 'examples' + PathSeparator + 'vcl' + PathSeparator + 'debugextension'
                      + PathSeparator + 'dialog' + PathSeparator;
  ClxDialogFileName = 'ClxExceptDlg.pas';
  ClxDialogName     = 'CLX Exception Dialog';
  DialogDescription = 'JCL Application exception dialog';
  DialogAuthor      = 'Project JEDI';
  DialogPage        = 'Dialogs';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -