📄 build.sgml
字号:
<para>At present there is no way for application or package source code toget hold of all the configuration details related to the currenthardware. Instead that information is spread over various differentconfiguration headers for the HAL and device driver packages, withsome of the information going into <filenameclass="headerfile">pkgconf/system.h</filename>. It is possible that insome future release of the system there will be another globalconfiguration header file <filenameclass="headerfile">pkgconf/hardware.h</filename> which either contains theconfiguration details for the various hardware-specific packages orwhich <literal>#include's</literal> all the hardware-specificconfiguration headers. The desirability and feasibility of such ascheme are still to be determined. To avoid future incompatibilityproblems as a result of any such changes, it is recommended that allhardware packages (in other packages containing the &hardware;property) use the &define-header; property to specify explicitly whichconfiguration header should be generated.</para></note><sect2 id = "build.headers.system.h"><title>The <filename class="headerfile">system.h</filename> Header</title><para>Typically configuration header files are <literal>#include'd</literal>only by the package's source code at build time, or by a package'sexported header files if the interface provided by the package may beaffected by a configuration option. There should be no need forapplication code to know the details of individual configurationoptions, instead the configuration should specifically meet the needsof the application.</para><para>There are always exceptions. Application code may want to adapt toconfiguration options, for example to do different things for ROM andRAM booting systems, or when it is necessary to support severaldifferent target boards. This is especially true if the code in questionis really re-usable library code which has not been converted to aneCos package, and hence cannot use any CDL facilities.</para><para>A major problem here is determining which packages are in theconfiguration: attempting to <literal>#include</literal> a header filesuch as <filename class="headerfile">pkgconf/net.h</filename>when it is not known for certain that that particular package is partof the configuration will result in compilation errors. The globalheader file <filename class="headerfile">pkgconf/system.h</filename>serves to provide such information, so application code can usetechniques like the following:</para><programlisting width=72>#include <pkgconf/system.h>#ifdef CYGPKG_NET# include <pkgconf/net.h>#endif</programlisting><para>This will compile correctly irrespective of the eCos configuration,and subsequent code can use <literal>#ifdef</literal> or similardirectives on <literal>CYGPKG_NET</literal> or any of theconfiguration options in that package. </para><para>In addition to determining whether or not a package is present, theglobal configuration header file can also be used to find out thespecific version of a package that is being used. This can be usefulif a more recent version exports additional functionality. It may alsobe necessary to adapt to incompatible changes in the exportedinterface or to changes in behaviour. For each package theconfiguration system will typically <literal>#define</literal> threesymbols, for example for a V1.3.1 release:</para><programlisting width=72>#define CYGNUM_NET_VERSION_MAJOR 1#define CYGNUM_NET_VERSION_MINOR 3#define CYGNUM_NET_VERSION_RELEASE 1</programlisting><para>There are a number of problems associated with such version<literal>#define's</literal>. The first restriction is that thepackage must follow the standard naming conventions, so the packagename must be of the form <literal>xxxPKG_yyy</literal>. The threecharacters immediately preceding the first underscore must be<literal>PKG</literal>, and will be replaced with<literal>NUM</literal> when generating the version<literal>#define's</literal>. If a package does not follow the namingconvention then no version <literal>#define's</literal> will begenerated. </para><para>Assuming the package does follow the naming conventions, theconfiguration tools will always generate three version<literal>#define's</literal> for the major, minor, and releasenumbers. The symbol names are obtained from the package name byreplacing <literal>PKG</literal> with <literal>NUM</literal> andappending <literal>_VERSION_MAJOR</literal>,<literal>_VERSION_MINOR</literal> and<literal>_VERSION_RELEASE</literal>. It is assumed that the resultingsymbols will not clash with any configuration option names. The valuesfor the <literal>#define's</literal> are determined by searching theversion string for sequences of digits, optionally preceded by a minussign. It is possible that some or all of the numbers are absent in anygiven version string, in which case <literal>-1</literal> will be usedin the <literal>#define</literal>. For example, given a version stringof <literal>V1.12beta</literal>, the major version number is<literal>1</literal>, the minor number is <literal>12</literal>, andthe release number is <literal>-1</literal>. Given a version string of<literal>beta</literal> all three numbers would be set to<literal>-1</literal>.</para><para>There is special case code for the version <literal>current</literal>,which typically corresponds to a development version obtained viaanonymous CVS or similar means. The configuration system has specialbuilt-in knowledge of this version, and will assume it is more recentthan any specific release number. The global configuration headerdefines a special symbol <literal>CYGNUM_VERSION_CURRENT</literal>,and this will be used as the major version number when version<literal>current</literal> of a package is used:</para><programlisting width=72>#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</programlisting><para>The large number used for <literal>CYGNUM_VERSION_CURRENT</literal>should ensure that major version comparisons work as expected, whilestill allowing for a small amount of arithmetic in case that provesuseful. </para><para>It should be noted that this implementation of version<literal>#define's</literal> will not cope with all version numberschemes. However for many cases it should suffice.</para></sect2></sect1><!-- }}} --><!-- {{{ The Build --><sect1 id="build.make"><title>Building eCos</title><!-- {{{ Introit --><para>The primary goal of an eCos build is to produce the library<filename>libtarget.a</filename>. A typical &eCos; build will alsogenerate a number of other targets: <filename>extras.o</filename>,startup code <filename>vectors.o</filename>, and a linker script. Somepackages may cause additional libraries or targets to be generated.The basic build process involves a number of different phases withcorresponding priorities. There are a number of predefined priorities:</para><informaltable frame="all" colsep=1 rowsep=1 pgwide=0><tgroup cols=2 colsep=1 rowsep=1><colspec colnum=1 align=right><colspec colnum=2 align=left><thead> <row> <entry>Priority</entry> <entry>Action</entry> </row></thead><tbody> <row> <entry>0</entry> <entry>Export header files</entry> </row> <row> <entry>100</entry> <entry>Process &compile; properties</entry> </row> <row> <entry> </entry> <entry>and most &make-object; custom build steps</entry> </row> <row> <entry>200</entry> <entry>Generate libraries</entry> </row> <row> <entry>300</entry> <entry>Process &make; custom build steps</entry> </row></tbody></tgroup></informaltable><para>Generation of the <filename>extras.o</filename> file, the startup codeand the linker script actually happens via &make; custom build steps,typically defined in appropriate HAL packages. The component frameworkhas no special knowledge of these targets.</para><para>By default custom build steps for a &make-object; property happenduring the same phase as most compilations, but this can be changedusing a <literal>-priority</literal> option. Similarly custom buildsteps for a &make; property happen at the end of a build, but this canalso be changed with a <literal>-priority</literal> option. Forexample a priority of 50 can be used to run a custom build stepbetween the header file export phase and the main compilation phase.Custom build steps are discussed in more detail below.</para><para>Some build systems may run several commands of the same priority inparallel. For example files listed in &compile; properties may getcompiled in parallel, concurrently with &make-object; custom buildsteps with default priorities. Since most of the time for an &eCos;build involves processing &compile; properties, this allows builds tobe speeded up on suitable host hardware. All build steps for a givenphase will complete before the next phase is started.</para><!-- }}} --><!-- {{{ Update --><sect2 id="build.make.update"><title>Updating the Build Tree</title><para>Some build systems may involve a phase before the header files getexported, to update the build and install trees automatically whenthere has been a change to the configuration savefile<filename>ecos.ecc</filename>. This is useful mainly for applicationdevelopers using the command line tools: it would allow users tocreate the build tree only once, and after any subsequentconfiguration changes the tree would be updated automatically by thebuild system. The facility would be analogous to the<literal>--enable-maintainer-mode</literal> option provide by the<application class="software">autoconf</application> and <applicationclass="software">automake</application> programs. At present no &eCos;build system implements this functionality, but it is likely to beadded in a future release.</para></sect2><!-- }}} --><!-- {{{ Exporting headers --><sect2 id="build.make.export"><title>Exporting Public Header Files</title><para>The first compulsory phase involves making sure that there is an up todate set of header files in the install tree. Each package can containsome number of header files defining the exported interface.Applications should only use exported functionality. A package canalso contain some number of private header files which are only ofinterest to the implementation, and which should not be visible toapplication code. The various packages that go into a particularconfiguration can be spread all over the component repository. Intheory it might be possible to make all the exported header filesaccessible by having a lengthy <literal>-I</literal> header filesearch path, but this would be inconvenient both for building eCos andfor building applications. Instead all the relevant header files arecopied to a single location, the <filenameclass="directory">include</filename> subdirectory of the install tree.The process involves the following:</para><orderedlist><listitem><para>The install tree, for example <filenameclass="directory">/usr/local/ecos/install</filename>, and its <filenameclass="directory">include</filename> subdirectory <filenameclass="directory">/usr/local/ecos/install/include</filename> will typically becreated when the build tree is generated or updated. At the same timeconfiguration header files will be written to the <filenameclass="directory">pkgconf</filename> subdirectory, for example<filenameclass="directory">/usr/local/ecos/include/pkgconf</filename>, so thatthe configuration data is visible to all the packages and toapplication code that may wish to examine some of the configurationoptions.</para></listitem><listitem><para>Each package in the configuration is examined for exported headerfiles. The exact order in which the packages are processed is notdefined, but should not matter.</para><orderedlist><listitem><para>If the package has an <linklinkend="ref.include-files">&include-files;</link> property then thislists all the exported header files:</para><programlisting width=72>cdl_package <some_package> { … include_files header1.h header2.h} </programlisting><para>If no arguments are given then the package does not export any headerfiles.</para><programlisting width=72>cdl_package <some_package> { … include_files} </programlisting><para>The listed files may be in an <filenameclass="directory">include</filename> subdirectory within the package'shierarchy, or they may be relative to the package's topleveldirectory. The &include-files; property is intended mainly for verysimple packages. It can also be useful when converting existing code
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -