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

📄 package.sgml

📁 ecos实时嵌入式操作系统
💻 SGML
📖 第 1 页 / 共 4 页
字号:
<para>A typical package contains the following:</para><orderedlist><listitem><para>Some number of source files which will end up in a library. Theapplication code will be linked with this library to produce anexecutable. Some source files may serve other purposes, for example toprovide a linker script.</para></listitem><listitem><para>Exported header files which define the interface provided by thepackage. </para></listitem><listitem><para>On-line documentation, for example reference pages for each exportedfunction. </para></listitem><listitem><para>Some number of test cases, shipped in source format, allowing users tocheck that the package is working as expected on their particularhardware and in their specific configuration.</para></listitem><listitem><para>One or more &CDL; scripts describing the package to the configurationsystem.</para></listitem></orderedlist><para>It is also conventional to have a per-package<filename>ChangeLog</filename> file used to keep track of changes tothat package. This is especially valuable to end users of the packagewho may not have convenient access to the source code control systemused to manage the master copy of the package, and hence cannot findout easily what has changed. Often it can be very useful to the maindevelopers as well.</para><para>Any given packages need not contain all of these. It is compulsory tohave at least one &CDL; script describing the package, otherwise thecomponent framework would be unable to process it. Some packages maynot have any source code: it is possible to have a package that merelydefines a common interface which can then be implemented by severalother packages, especially in the context of device drivers; howeverit is still common to have some code in such packages to avoidreplicating shareable code in all of the implementation packages.Similarly it is possible to have a package with no exported headerfiles, just source code that implements an existing interface: forexample an ethernet device driver might just implement a standardinterface and not provide any additional functionality. Packages donot need to come with any on-line documentation, although this mayaffect how many people will want to use the package. Much the sameapplies to per-package test cases.</para><para>The component framework has a recommended per-package directory layoutwhich splits the package contents on a functional basis:</para><informalfigure PgWide=1><mediaobject><imageobject><imagedata fileref="package.png" Scalefit=1 Align="Center"></imageobject></mediaobject></informalfigure><para>For example, if a package has an <filenameclass="directory">include</filename> sub-directory then the componentframework will assume that all header files in and below thatdirectory are exported header files and will do the right thing atbuild time. Similarly if there is &doc; property indicating thelocation of on-line documentation then the component framework willfirst look in the <filename class="directory">doc</filename>sub-directory.</para><para>This directory layout is just a guideline, it is not enforced by thecomponent framework. For simple packages it often makes more sense tohave all of the files in just one directory. For example a packagecould just contain the files <filename>hello.cxx</filename>,<filename>hello.h</filename>, <filename>hello.html</filename> and<filename>hello.cdl</filename>. By default<filename>hello.h</filename> will be treated as an exported headerfile, although this can be overridden with the <linklinkend="ref.include-files">&include-files;</link> property. Assumingthere is a &doc; property referring to <filename>hello.html</filename>and there is no <filename class="directory">doc</filename>sub-directory then the tools will search for this file relative to thepackage's top-level and everything will just work. Much the sameapplies to <filename>hello.cxx</filename> and<filename>hello.cdl</filename>. </para><tip><para>Older versions of the &eCos; build system only supported packages thatfollowed the directory structure exactly. Hence certain core packagessuch as <filename>error</filename> implement the full directorystructure, even though that is a particularly simple package and thefull directory structure is inappropriate. Component writers candecide for themselves whether or not the directory structureguidelines are appropriate for their package.</para></tip><!-- }}} --><!-- {{{ Build process          --><sect2 id="package.build"><title>Outline of the Build Process</title><para>The full build process is described in <xref linkend="build">, but a summary is appropriate here. A build involves three directorystructures: </para><orderedlist><listitem><para>The component repository. This is where all the package source code isheld, along with &CDL; scripts, documentation, and so on. For buildpurposes a component repository is read-only. Application developerswill only modify the component repository when installing or removingpackages, via the administration tool. Component writers willtypically work on just one package in the component repository.</para></listitem><listitem><para>The build tree. Each configuration has its own build tree, which canbe regenerated at any time using the configuration's<filename>ecos.ecc</filename> savefile. The build tree contains onlyintermediate files, primarily object files. Once a build is completethe build tree contains no information that is useful for applicationdevelopment and can be wiped, although this would slow down anyrebuilds following changes to the configuration.</para></listitem><listitem><para>The install tree. This is populated during a build, and contains allthe files relevant to application development. There will be a<filename class="directory">lib</filename> sub-directory whichtypically contains <filename>libtarget.a</filename>, a linker script,start-up code, and so on. There will also be an <filenameclass="directory">include</filename> sub-directory containing all theheader files exported by the various packages. There will also be a<filename class="directory">include/pkgconf</filename> sub-directorycontaining various configuration header files with<literal>#define's</literal> for the options. Typically the installtree is created within the build tree, but this is not a requirement.</para></listitem></orderedlist><para>The build process involves the following steps:</para><orderedlist><listitem><para>Given a configuration, the component framework is responsible forcreating all the directories in the build and install trees. If thesetrees already exist then the component framework is responsible forany clean-ups that may be necessary, for example if a package has beenremoved then all related files should be expunged from the build andinstall trees. The configuration header files will be generated atthis time. Depending on the host environment, the component frameworkwill also generate makefiles or some other way of building the variouspackages. Every time the configuration is modified this step needs tobe repeated, to ensure that all option consequences take effect. Careis taken that this will not result in unnecessary rebuilds.</para><note><para>At present this step needs to be invoked manually. In a future versionthe generated makefile may if desired perform this step automatically,using a dependency on the <filename>ecos.ecc</filename> savefile.</para></note></listitem><listitem><para>The first step in an actual build is to make sure that the installtree contains all exported header files. All compilations will usethe install tree's <filename class="directory">include</filename>directory as one of the places to search for header files.</para></listitem><listitem><para>All source files relevant to the current configuration get compiled.This involves a set of compiler flags initialized on a per-targetbasis, with each package being able to modify these flags, and withthe ability for the user to override the flags as well. Care has to betaken here to avoid inappropriate target-dependencies in packages thatare intended to be portable. The component framework has built-inknowledge of how to handle C, C++ and assembler source files &mdash;other languages may be added in future, as and when necessary. The<link linkend="ref.compile">&compile;</link> property is used tolist the files that should get compiled. All object files end up inthe build tree.</para></listitem><listitem><para>Once all the object files have been built they are collected into alibrary, typically <filename>libtarget.a</filename>, which can then belinked with application code. The library is generated in the installtree. </para></listitem><listitem><para>The component framework provides support for custom build steps, usingthe <link linkend="ref.make-object">&make-object;</link> and<link linkend="ref.make">&make;</link> properties. The results ofthese custom build steps can either be object files that should end upin a library, or other files such as a linker script. It is possibleto control the order in which these custom build steps take place, forexample it is possible to run a particular build step before any ofthe compilations happen.</para></listitem></orderedlist></sect2><!-- }}} --><!-- {{{ Sources                --><sect2 id="package.source"><title>Configurable Source Code</title><para>All packages should be totally portable to all target hardware (withthe obvious exceptions of HAL and device driver packages). They shouldalso be totally bug-free, require the absolute minimum amount of codeand data space, be so efficient that cpu time usage is negligible, andprovide lots of configuration options so that application developershave full control over the behavior. The configuration options areoptional only if a package can meet the requirements of everypotential application without any overheads. It is not the purpose ofthis guide to explain how to achieve all of these requirements.</para><para>The &eCos; component framework does have some important implicationsfor the source code: compiler flag dependencies; package interfacesvs. implementations; and how configuration options affect source code.</para><sect3 id="package.source.flags"><title>Compiler Flag Dependencies</title><para>Wherever possible component writers should avoid dependencies onparticular compiler flags. Any such dependencies are likely to impactportability. For example, if one package needs to be built inbig-endian mode and another package needs to be built in little-endianmode then usually it will not be possible for application developersto use both packages at the same time; in addition the applicationdeveloper is no longer given a choice in the matter. It is far betterfor the package source code to adapt the endianness at compile-time,or possibly at run-time although that will involve code-sizeoverheads.</para><note><para>A related issue is that the current support for handling compilerflags in the component framework is still limited and incapable ofhandling flags at a very fine-grain. The support is likely to beenhanced in future versions of the framework, but there arenon-trivial problems to be resolved.</para></note></sect3><sect3 id="package.source.interfaces"><title>Package Interfaces and Implementations</title><para>The component framework provides encapsulation at the package level. Apackage <literal>A</literal> has no way of accessing theimplementation details of another package <literal>B</literal> atcompile-time. In particular, if there is a private header filesomewhere in a package's <filename class="directory">src</filename>sub-directory then this header file is completely invisible to otherpackages. Any attempts to cheat by using relative pathnames beginningwith <filename class="directory">../..</filename> are generally doomedto failure because of the presence of package version directories.There are two ways in which one package can affect another: by meansof the exported header files, which define a public interface; or viathe &CDL; scripts.</para><para>This encapsulation is a deliberate aspect of the overall &eCos;component framework design. In most cases it does not cause anyproblems for component writers. In some cases enforcing a cleanseparation between interface and implementation details can improvethe code. Also it reduces problems when a package gets upgraded:component writers are free to do pretty much anything on theimplementation side, including renaming every single source file; carehas to be taken only with the exported header files and with the &CDL;data, because those have the potential of impacting other packages.Application code is similarly unable to access package implementationdetails, only the exported interface.

⌨️ 快捷键说明

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