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

📄 build.headers.html

📁 ecos源代码包
💻 HTML
📖 第 1 页 / 共 3 页
字号:
>eCos</SPAN
> packages do not yet make use of this facility. Instead
there is a single global configuration option
<TT
CLASS="VARNAME"
>CYGDBG_USE_ASSERTS</TT
> which is used to enable or
disable assertions for all packages. This issue should be addressed in
a future release of the system.</P
></BLOCKQUOTE
></DIV
><P
>As with the <SPAN
CLASS="PROPERTY"
>define</SPAN
> property, the <SPAN
CLASS="PROPERTY"
>if_define</SPAN
> property takes an
option <TT
CLASS="LITERAL"
>-file</TT
> with a single legal value
<TT
CLASS="LITERAL"
>system.h</TT
>. This allows the output to be redirected
to <TT
CLASS="FILENAME"
>pkgconf/system.h</TT
> if and when
necessary. </P
></LI
><LI
><P
>The final property that is relevant to configuration header file
generation is <SPAN
CLASS="PROPERTY"
>define_proc</SPAN
>. This takes a single argument, a <SPAN
CLASS="APPLICATION"
>Tcl</SPAN
>
fragment that can add arbitrary data to the global header <TT
CLASS="FILENAME"
>pkgconf/system.h</TT
> and to the package's own
header. When the <SPAN
CLASS="PROPERTY"
>define_proc</SPAN
> script is invoked two variables will be
set up to allow access to these headers: <TT
CLASS="LITERAL"
>cdl_header</TT
>
will be a channel to the package's own header file, for example
<TT
CLASS="FILENAME"
>pkgconf/kernel.h</TT
>;
<TT
CLASS="LITERAL"
>cdl_system_header</TT
> will be a channel to <TT
CLASS="FILENAME"
>pkgconf/system.h</TT
>. A typical <SPAN
CLASS="PROPERTY"
>define_proc</SPAN
>
script will use the <SPAN
CLASS="APPLICATION"
>Tcl</SPAN
> <TT
CLASS="LITERAL"
>puts</TT
> command to output
data to one of these channels, for example:</P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>cdl_option &lt;name&gt; {
    &#8230;
    define_proc {
        puts $::cdl_header "#define XXX 1"
    }
}</PRE
></TD
></TR
></TABLE
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>In the current implementation the use of <SPAN
CLASS="PROPERTY"
>define_proc</SPAN
> is limited
because the <SPAN
CLASS="APPLICATION"
>Tcl</SPAN
> script cannot access any of the configuration data.
Therefore the script is limited to writing constant data to the
configuration headers. This is a major limitation which will be
addressed in a future release of the component framework.</P
></BLOCKQUOTE
></DIV
></LI
></OL
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>Generating C header files with <TT
CLASS="LITERAL"
>#define's</TT
> for the
configuration data suffices for existing packages written in some
combination of C, C++ and assembler. It can also be used in
conjunction with some other languages, for example by first passing
the source code through the C preprocessor and feeding the result into
the appropriate compiler. In future versions of the component
framework additional programming languages such as Java may be
supported, and the configuration data may also be written to files in
some format other than C preprocessor directives. </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>At present there is no way for application or package source code to
get hold of all the configuration details related to the current
hardware. Instead that information is spread over various different
configuration headers for the HAL and device driver packages, with
some of the information going into <TT
CLASS="FILENAME"
>pkgconf/system.h</TT
>. It is possible that in
some future release of the system there will be another global
configuration header file <TT
CLASS="FILENAME"
>pkgconf/hardware.h</TT
> which either contains the
configuration details for the various hardware-specific packages or
which <TT
CLASS="LITERAL"
>#include's</TT
> all the hardware-specific
configuration headers. The desirability and feasibility of such a
scheme are still to be determined. To avoid future incompatibility
problems as a result of any such changes, it is recommended that all
hardware packages (in other packages containing the <SPAN
CLASS="PROPERTY"
>hardware</SPAN
>
property) use the <SPAN
CLASS="PROPERTY"
>define_header</SPAN
> property to specify explicitly which
configuration header should be generated.</P
></BLOCKQUOTE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="BUILD.HEADERS.SYSTEM.H">The <TT
CLASS="FILENAME"
>system.h</TT
> Header</H2
><P
>Typically configuration header files are <TT
CLASS="LITERAL"
>#include'd</TT
>
only by the package's source code at build time, or by a package's
exported header files if the interface provided by the package may be
affected by a configuration option. There should be no need for
application code to know the details of individual configuration
options, instead the configuration should specifically meet the needs
of the application.</P
><P
>There are always exceptions. Application code may want to adapt to
configuration options, for example to do different things for ROM and
RAM booting systems, or when it is necessary to support several
different target boards. This is especially true if the code in question
is really re-usable library code which has not been converted to an
eCos package, and hence cannot use any CDL facilities.</P
><P
>A major problem here is determining which packages are in the
configuration: attempting to <TT
CLASS="LITERAL"
>#include</TT
> a header file
such as <TT
CLASS="FILENAME"
>pkgconf/net.h</TT
>
when it is not known for certain that that particular package is part
of the configuration will result in compilation errors. The global
header file <TT
CLASS="FILENAME"
>pkgconf/system.h</TT
>
serves to provide such information, so application code can use
techniques like the following:</P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#include &lt;pkgconf/system.h&gt;
#ifdef CYGPKG_NET
# include &lt;pkgconf/net.h&gt;
#endif</PRE
></TD
></TR
></TABLE
><P
>This will compile correctly irrespective of the eCos configuration,
and subsequent code can use <TT
CLASS="LITERAL"
>#ifdef</TT
> or similar
directives on <TT
CLASS="LITERAL"
>CYGPKG_NET</TT
> or any of the
configuration options in that package. </P
><P
>In addition to determining whether or not a package is present, the
global configuration header file can also be used to find out the
specific version of a package that is being used. This can be useful
if a more recent version exports additional functionality. It may also
be necessary to adapt to incompatible changes in the exported
interface or to changes in behaviour. For each package the
configuration system will typically <TT
CLASS="LITERAL"
>#define</TT
> three
symbols, for example for a V1.3.1 release:</P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define CYGNUM_NET_VERSION_MAJOR 1
#define CYGNUM_NET_VERSION_MINOR 3
#define CYGNUM_NET_VERSION_RELEASE 1</PRE
></TD
></TR
></TABLE
><P
>There are a number of problems associated with such version
<TT
CLASS="LITERAL"
>#define's</TT
>. The first restriction is that the
package must follow the standard naming conventions, so the package
name must be of the form <TT
CLASS="LITERAL"
>xxxPKG_yyy</TT
>. The three
characters immediately preceding the first underscore must be
<TT
CLASS="LITERAL"
>PKG</TT
>, and will be replaced with
<TT
CLASS="LITERAL"
>NUM</TT
> when generating the version
<TT
CLASS="LITERAL"
>#define's</TT
>. If a package does not follow the naming
convention then no version <TT
CLASS="LITERAL"
>#define's</TT
> will be
generated. </P
><P
>Assuming the package does follow the naming conventions, the
configuration tools will always generate three version
<TT
CLASS="LITERAL"
>#define's</TT
> for the major, minor, and release
numbers. The symbol names are obtained from the package name by
replacing <TT
CLASS="LITERAL"
>PKG</TT
> with <TT
CLASS="LITERAL"
>NUM</TT
> and
appending <TT
CLASS="LITERAL"
>_VERSION_MAJOR</TT
>,
<TT
CLASS="LITERAL"
>_VERSION_MINOR</TT
> and
<TT
CLASS="LITERAL"
>_VERSION_RELEASE</TT
>. It is assumed that the resulting
symbols will not clash with any configuration option names. The values
for the <TT
CLASS="LITERAL"
>#define's</TT
> are determined by searching the
version string for sequences of digits, optionally preceded by a minus
sign. It is possible that some or all of the numbers are absent in any
given version string, in which case <TT
CLASS="LITERAL"
>-1</TT
> will be used
in the <TT
CLASS="LITERAL"
>#define</TT
>. For example, given a version string
of <TT
CLASS="LITERAL"
>V1.12beta</TT
>, the major version number is
<TT
CLASS="LITERAL"
>1</TT
>, the minor number is <TT
CLASS="LITERAL"
>12</TT
>, and
the release number is <TT
CLASS="LITERAL"
>-1</TT
>. Given a version string of
<TT
CLASS="LITERAL"
>beta</TT
> all three numbers would be set to
<TT
CLASS="LITERAL"
>-1</TT
>.</P
><P
>There is special case code for the version <TT
CLASS="LITERAL"
>current</TT
>,
which typically corresponds to a development version obtained via
anonymous CVS or similar means. The configuration system has special
built-in knowledge of this version, and will assume it is more recent
than any specific release number. The global configuration header
defines a special symbol <TT
CLASS="LITERAL"
>CYGNUM_VERSION_CURRENT</TT
>,
and this will be used as the major version number when version
<TT
CLASS="LITERAL"
>current</TT
> of a package is used:</P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define CYGNUM_VERSION_CURRENT 0x7fffff00
...
#define CYGNUM_INFRA_VERSION_MAJOR CYGNUM_VERSION_CURRENT
#define CYGNUM_INFRA_VERSION_MINOR -1
#define CYGNUM_INFRA_VERSION_RELEASE -1</PRE
></TD
></TR
></TABLE
><P
>The large number used for <TT
CLASS="LITERAL"
>CYGNUM_VERSION_CURRENT</TT
>
should ensure that major version comparisons work as expected, while
still allowing for a small amount of arithmetic in case that proves
useful. </P
><P
>It should be noted that this implementation of version
<TT
CLASS="LITERAL"
>#define's</TT
> will not cope with all version number
schemes. However for many cases it should suffice.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="build.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="cdl-guide.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="build.make.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>The Build Process</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="build.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Building eCos</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

⌨️ 快捷键说明

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