Package learning 2: What is the runtime package and design package 2

Source: Internet
Author: User

What is a runtime package and a design phase package?

  

CnPack Open Source Software Project 15:14:55

CnPackTip #8 What is the runtime package and design package?

Participate in the discussion: JingYu, Passion, Xiaoxia
Sorting: SkyJacker 2007.10.16, 2007.11.05
Http://www.cnpack.org
CnPack iii qq Group: 32712412
CnPack iv qq Group: 130970

Reprinted, please keep it complete and indicate the source.

========================================================== ====================================
1. Content Overview
========================================================== ====================================

This document describes in depth what is the runtime package and the design phase package, and explains the cause of the DesignIntf error.

========================================================== ====================================
2. Text
========================================================== ====================================

This article takes CnPack. dpk (runtime package) and dclCnPack. dpk (design phase package) as examples. These two packages, one is the runtime package, the other is the design phase package, the design phase package contains the component editor. The component package is usually released based on the runtime package and the design phase package. The runtime package contains the actual units required for application compilation, the component editor and Attribute Editor are not required in the application exe for the code specially written during IDE design, therefore, the source code of the component will put the code of the design editor into a separate pas file. These units containing the design period pas are only included in the dpk of the design period package, even those Register functions that Register components in the IDE can not be placed in component units.

The runtime package is referenced in the design phase. The Delphi package technology is based on the unit. In fact, when building a package with runtime, it is in the connection phase, converts the connection to the unit referenced by the program into an external reference to the running package.

In this case, we need to compile a component that can be installed and used in IDE. We need to implement a TMyComp component, and then a Register function registers the component to the IDE control panel. If the attributes of this component need an editor, or the component itself has an editor, you also need to write some editor code. These codes used to edit components and their attributes in IDE are meaningless registration components for applications. The editor's Register function is meaningless to applications, these editors depend on IDE's ToolsAPI, DesnIntf, and Other OTA units.
If the TMyComp code is compiled in a pas, the application needs to indirectly reference these OTA units of the IDE. In fact, this processing is not appropriate.
Therefore, the author of the development package introduces the concept of runtime package and design package, and puts the source code of those applications that need to be compiled into EXE in the PAS unit of component implementation, for example, the Unit contained in dclcnpack_d7.dpk is not used in applications and is only used in IDE.

These PAAs are included in the dpk file of the runtime package. In the project option, the runtime package is set to runtime only mode. It can only be used at runtime and cannot be installed. Therefore, open the cnpack_d7.dpk file in the IDE. Clicking install will prompt the incorrect component registration and editor content. Obviously, the code of the component must be referenced.
Of course, for a single component, it may be too difficult to write the two units separately. However, for large component packages, the separate design is very clear.
The code structure of the cnpack component is basically handled according to this principle.

For example, the code that contains the tmycomp component is in mycomp. Pas, and the component registration and editor for tmycomp is in mycompeditor. Pas. In mycompeditor. Pas, the uses mycomp unit is enough. One is a pure runtime package, and the other is the design phase code appended to the runtime package.
The register function should also be stored in mycompeditor. Pas. The EXE of this function application is not called. Of course, there will be no error in mycomp.

If you only register a component, it is okay because RegisterComponents is defined in Classes. However, if you want to register the Attribute Editor RegisterPropertyEditor, It is defined in DesignIntf. The DesignIntf unit is useless to applications. It is only the design stage interface provided by IDE. If you place the Register function in the component implementation code and indirectly reference it to a unit, the system may fail to find the DesignIntf when installing and compiling the component, because DesignIntf and other units are not in the IDE's search path by default.

From D6, a design phase unit has not released the source code (Proxies. dcu), In the D6 or later version of The DesignEditor. in pas, the implementation Part references this unit, while Borland does not provide the source code, resulting in a large number of components not being compiled during runtime.
The Proxies unit seems to be in dsnIDEXX. bpl references the DesignEditor component, which is correct when installed in IDE because the design package contains dsnIDE. bpl compilation, but the application compilation will fail.

Therefore, we advocate separating the package during the design period from the package during the running period. Basically, the component packages of the regular points are all made in this way.

The following is an example of the installation sequence of CnPack. dpk (runtime package) and dclCnPack. dpk:

1. If CnPack. dpk is installed first, the following error is prompted:

Error:
Package c: \ program files \ Borland \ delphi6 \ Projects \ Bpl \ CnPack_D6.bpl
Can't be installed because it is not a design time package.

2. If you install dclcnpack directly, this problem will not occur.
Because dclcnpack references cnpack. dpk, IDE automatically compiles the latter (cnpack. dpk) and installs the former (dclcnpack. dpk ).
As mentioned above, runtime only is set in the project of the runtime package and cannot be installed as the design period package. design only is set in the project option of the design period package, it is not allowed to be used as a runtime package, so that the purposes of the two packages are separated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.