一、准备工具
1.Devexpress vcl 14.1.3
下载地址http://download.csdn.net/user/rfjbco,共用个包,下载后解压,程序目录已带有DxAutoInstaller
2.DxAutoInstaller
最新版下载地址http://forum.delphier.com/forum.php?mod=viewthread&tid=2&extra=page%3D1
二、安装控件
打开DxAutoInstaller ,选择Dev安装路径
按Install,开始安装,安装时会把已经装的版本卸载并安装,生成类似如下的日志
----------------------------------------------------------------------------------------------------
Copying Files: E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\ExpressCore Library\Sources\*.*
----------------------------------------------------------------------------------------------------
Compiling package E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\ExpressCore Library\Packages\dxCoreRS21.dpk
D:\SoftGreen\DelphiXE7\bin\dcc32.exe "E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\ExpressCore Library\Packages\dxCoreRS21.dpk" --no-config -U"D:\SoftGreen\DelphiXE7\lib\Win32\release" -LN"C:\Users\Public\Documents\Embarcadero\Studio\15.0\Dcp" -LE"C:\Users\Public\Documents\Embarcadero\Studio\15.0\Bpl" -$D- -$L- -$Y- -Q -U"C:\Users\Public\Documents\Embarcadero\Studio\15.0\Dcp" -U"E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\Library\Sources" -R"E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\Library\Sources" -B -NU"E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\Library\RAD Studio XE7" -N0"E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\Library\RAD Studio XE7" -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE -NSWinapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;IBX;VclTee; -DUSENATIVELOOKANDFEELASDEFAULT
Embarcadero Delphi for Win32 compiler version 28.0
Copyright (c) 1983,2014 Embarcadero Technologies, Inc.
16227 lines, 0.17 seconds, 109300 bytes code, 1924 bytes data.
Compilation success
。。。。。。。。。。
拷贝此日志
三、生成合并的BPL
思路:提取所有运行时控件包中的contains中的内容,合并在一起。
我写了一个工具,用于提取运行时控件中的contains,后面附上源码
把DxAutoInstaller 生成的日志拷到下面这个程序的右上角框,然后点“提取dpk包”按钮,会把所有的dpk提取出来到左下框,然后再按”提成包含文件“,则把运行时dpk的contains内容提成到右边的框。拷贝右边拷的内容
四、生成合并后的Dev包
新建一个包项目,配置如下,保存到\DevExpressVcl_14.1.3\Library\Sources下
把上面提取出来的包含文件拷进去,用不到的控件包,去掉即可。
Release模式编译,如果提示如下
点Cancle即可。
生成出来Dev.bpl大概30M左右,再用AsPack压缩,大小15M左右
五、例子
新建一个项目,配置如下
再放一堆Dev控件上去,效果如下
工具源码,不能上传附件,这里附上代码
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Xml.xmldom, Xml.XMLIntf, Xml.Win.msxmldom, Xml.XMLDoc; type TFrmMain = class(TForm) MemoGroupFile: TMemo; Button1: TButton; Button2: TButton; Memo1: TMemo; OpenDialog1: TOpenDialog; XMLDocument1: TXMLDocument; Memo2: TMemo; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } GroupPath:string; public { Public declarations } end; var FrmMain: TFrmMain; implementation {$R *.dfm} procedure TFrmMain.Button1Click(Sender: TObject); begin //提取项目组文件 // OpenDialog1.InitialDir := ‘E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3‘; // OpenDialog1.FileName:=‘E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\DelphiXE7.groupproj‘ ; // if OpenDialog1.Execute then // begin // MemoGroupFile.Lines.Clear; // //MemoGroupFile.Lines.LoadFromFile(OpenDialog1.FileName); // XMLDocument1.LoadFromFile(OpenDialog1.FileName); // MemoGroupFile.Lines:=XMLDocument1.XML; // // self.Caption:=OpenDialog1.FileName; // GroupPath:= ExtractFilePath(OpenDialog1.FileName); //文件夹后面带/ // end; end; procedure TFrmMain.Button2Click(Sender: TObject); var // nodeList: IXMLNodeList; // node: IXMLNode; num,i: Integer; // str:string; begin //根据项目组,提取dpk文件 // nodeList := XMLDocument1.DocumentElement.ChildNodes[1].ChildNodes; // num := nodeList.Count; // Memo1.Lines.Clear; // for i := 0 to num - 1 do // begin // node := nodeList[i]; // str:=node.Attributes[‘Include‘]; // str:=GroupPath+ StringReplace(str,‘dproj‘,‘dpk‘,[rfReplaceAll]); // Memo1.Lines.Add(str); // end; Memo1.Lines.Clear; for i := 0 to MemoGroupFile.Lines.Count-1 do begin if Pos(‘Compiling package ‘,MemoGroupFile.Lines[i])>0 then Memo1.Lines.Add(StringReplace(MemoGroupFile.Lines[i],‘Compiling package ‘,‘‘,[])); end; end; procedure TFrmMain.Button3Click(Sender: TObject); var aFile:TStrings; i,j:Integer; CurPackName, PackName:string; IsAdd:Boolean; begin aFile:=TStringList.Create; PackName:=‘‘; CurPackName:=‘‘; Memo2.Lines.Clear; GroupPath :=‘E:\DelphiPackages\DelphiXE7\DevExpressVcl_14.1.3\‘; for I := 0 to Memo1.Lines.Count-1 do begin //提取控件包名 CurPackName:=StringReplace(Memo1.Lines[i],GroupPath,‘‘,[rfReplaceAll]); CurPackName:=Copy(CurPackName,0,Pos(‘\‘,CurPackName)-1); IsAdd:=False; aFile.LoadFromFile(Memo1.Lines[i]); if Pos(‘{$RUNONLY}‘,aFile.Text)>0 then //只提取运行时包 begin if CurPackName<>PackName then begin if i<>0 then Memo2.Lines.Add(‘‘); Memo2.Lines.Add(‘ //‘+CurPackName); end; for j := 0 to aFile.Count-1 do begin if aFile[j]=‘contains‘ then begin IsAdd:=True; Continue; end; if IsAdd then begin if Pos(‘;‘,aFile[j])>0 then IsAdd:=False; Memo2.Lines.Add(StringReplace(aFile[j],‘;‘,‘,‘,[rfReplaceAll])); end; end; PackName:=CurPackName; end; end; i:=Memo2.Lines.Count; Memo2.Lines[i-1]:= StringReplace(Memo2.Lines[i-1],‘,‘,‘;‘,[rfReplaceAll]) ; end; end.
unit1.pas
object Form1: TForm1 Left = 0 Top = 0 Caption = ‘Form1‘ ClientHeight = 357 ClientWidth = 764 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = ‘Tahoma‘ Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object cxFilterControl1: TcxFilterControl Left = 24 Top = 8 Width = 153 Height = 89 TabOrder = 0 end object cxTabControl1: TcxTabControl Left = 216 Top = 0 Width = 209 Height = 121 TabOrder = 1 Properties.CustomButtons.Buttons = <> Properties.TabIndex = 0 Properties.Tabs.Strings = ( ‘asdf‘ ‘asd‘ ‘fa‘ ‘df‘ ‘asdf‘) ClientRectBottom = 117 ClientRectLeft = 4 ClientRectRight = 205 ClientRectTop = 24 end object cxGrid1: TcxGrid Left = 8 Top = 149 Width = 250 Height = 200 TabOrder = 2 object cxGrid1DBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> end object cxGrid1Level1: TcxGridLevel GridView = cxGrid1DBTableView1 end end object cxScheduler1: TcxScheduler Left = 431 Top = 8 Width = 350 Height = 250 ViewDay.Active = True Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = ‘Tahoma‘ Font.Style = [] TabOrder = 3 Splitters = { CE0000007E0000005D01000083000000C900000001000000CE000000F9000000} StoredClientBounds = {01000000010000005D010000F9000000} end object cxHeader1: TcxHeader Left = 336 Top = 168 Width = 25 Height = 25 Sections = <> end object cxShellListView1: TcxShellListView Left = 280 Top = 199 Width = 250 Height = 150 TabOrder = 5 end object cxButton1: TcxButton Left = 576 Top = 288 Width = 75 Height = 33 Caption = ‘cxButton1‘ TabOrder = 6 end object cxScrollBox1: TcxScrollBox Left = 280 Top = 127 Width = 185 Height = 41 TabOrder = 7 end object cxTextEdit1: TcxTextEdit Left = 56 Top = 122 TabOrder = 8 Text = ‘cxTextEdit1‘ Width = 121 end end
unit1.dfm