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

📄 build.sgml

📁 ecos实时嵌入式操作系统
💻 SGML
📖 第 1 页 / 共 5 页
字号:
to an &eCos; package, to avoid rearranging the sources.</para></listitem><listitem><para>If there is no &include-files; property then the component frameworkwill look for an <filename class="directory">include</filename>subdirectory in the package, as per the layout conventions. All files,including those in subdirectories, will be treated as exported headerfiles. For example, the math library package contains files <filenameclass="headerfile">include/math.h</filename> and <filenameclass="headerfile">include/sys/ieeefp.h</filename>, both of which willbe exported to the install tree.</para></listitem><listitem><para>As a last resort, if there is neither an &include-files; property noran <filename class="directory">include</filename> subdirectory, thecomponent framework will search the package's toplevel directory andall of its subdirectories for files with one of the followingsuffixes: <literal>.h</literal>, <literal>.hxx</literal>,<literal>.inl</literal> or <literal>.inc</literal>. All such fileswill be interpreted as exported header files.</para><para>This last resort rule could cause confusion for packages which have noexported header files but which do contain one or more private headerfiles. For example a typical device driver simply implements anexisting interface rather than define a new one, so it does not needto export a header file. However it may still have one or more privateheader files. Such packages should use an &include-files; propertywith no arguments.</para></listitem></orderedlist></listitem><listitem><para>If the package has one or more exported header files, the next step isto determine where the files should end up. By default all exportedheader files will just end up relative to the install tree's <filenameclass="directory">include</filename> subdirectory. For example themath library's <filename class="headerfile">math.h</filename> headerwould end up as <filename>/usr/local/ecos/include/math.h</filename>,and the <filename class="headerfile">sys/ieeefp.h</filename> headerwould end up as<filename>/usr/local/ecos/include/sys/ieeefp.h</filename>. Thisbehaviour is correct for packages like the C library where theinterface is defined by appropriate standards. For other packages thisbehaviour can lead to file name clashes, and the <linklinkend="ref.include-dir">&include-dir;</link> property should be usedto avoid this:</para><programlisting width=72>cdl_package CYGPKG_KERNEL {    include_dir cyg/kernel}</programlisting><para>This means that the kernel's exported header file<filename>include/kapi.h</filename> should be copied to<filename>/usr/local/ecos/include/cyg/kernel/kapi.h</filename>, whereit is very unlikely to clash with a header file from some otherpackage.</para></listitem><listitem><para>For typical application developers there will be little or no need forthe installed header files to change after the first build. Changeswill be necessary only if packages are added to or removed from theconfiguration. For component writers, the build system should detectchanges to the master copy of the header file source code and updatethe installed copies automatically during the next build. The buildsystem is expected to perform a header file dependency analysis, soany source files affected should get rebuilt as well.</para></listitem><listitem><para>Some build systems may provide additional support for applicationdevelopers who want to make minor changes to a package, especially fordebugging purposes. A header file could be copied from thecomponent repository (which for application developers is assumed tobe a read-only resource) into the build tree and edited there. Thebuild system would detect a more recent version of such a header filein the build tree and install it. Care would have to be taken torecover properly if the modified copy in the build tree issubsequently removed, in order to revert to the original behaviour.</para></listitem><listitem><para>When updating the install tree's <filenameclass="directory">include</filename> subdirectory, the build tree mayalso perform a clean-up operation. Specifically, it may check for anyfiles which do not correspond to known exported header files anddelete them.</para></listitem></orderedlist><note><para>At present there is no defined support in the build system fordefining custom build steps that generate exported header files. Anyattempt to use the existing custom build step support may fall foul ofunexpected header files being deleted automatically by the buildsystem. This limitation will be addressed in a future release of thecomponent framework, and may require changing the priority forexporting header files so that a custom build step can happen first.</para></note></sect2><!-- }}} --><!-- {{{ Compiling              --><sect2 id="build.make.compiles"><title>Compiling</title><para>Once there are up to date copies of all the exported header files inthe build tree, the main build can proceed. Most of this involvescompiling source files listed in &compile; properties in the &CDL;scripts for the various packages, for example:</para><programlisting width=72>cdl_package CYGPKG_ERROR {    display       "Common error code support"    compile       strerror.cxx    &hellip;}</programlisting><para>&compile; properties may appear in the body of a &cdl-package;,&cdl-component;, &cdl-option; or &cdl-interface;. If the option orother &CDL; entity is active and enabled, the property takes effect.If the option is inactive or disabled the property is ignored. It ispossible for a &compile; property to list multiple source files, andit is also possible for a given &CDL; entity to contain multiple&compile; properties. The following three examples are equivalent:</para><programlisting width=72>cdl_option &lt;some_option&gt; {    &hellip;    compile file1.c file2.c file3.c}cdl_option &lt;some_option&gt; {    &hellip;    compile file1.c    compile file2.c    compile file3.c}cdl_option &lt;some_option&gt; {    &hellip;    compile file1.c file2.c    compile file3.c}</programlisting><para>Packages that follow the directory layout conventions should have asubdirectory <filename class="directory">src</filename>, and thecomponent framework will first look for the specified files there.Failing that it will look for the specified files relative to thepackage's root directory. For example if a package contains a sourcefile <filename>strerror.cxx</filename> then the following two linesare equivalent:</para><programlisting width=72>    compile strerror.cxx    compile src/strerror.cxx</programlisting><para>In the first case the component framework will find the fileimmediately in the packages <filename class="directory">src</filename>subdirectory. In the second case the framework will first look for afile <filename>src/src/strerror.cxx</filename>, and then for<filename>str/strerror.cxx</filename> relative to the package's rootdirectory. The result is the same.</para><para>The file names may be relative paths, allowing the source code to besplit over multiple directories. For example if a package contains afile <filename>src/sync/mutex.cxx</filename> then the corresponding&CDL; entry would be:</para><programlisting width=72>    compile sync/mutex.cxx</programlisting><para>All the source files relevant to the current configuration will beidentified when the build tree is generated or updated, and added tothe appropriate makefile (or its equivalent for other build systems).The actual build will involve a rule of the form:</para><programlisting width=72>&lt;object file&gt; : &lt;source file&gt;        $(CC) -c $(INCLUDE_PATH) $(CFLAGS) -o $@ $<</programlisting><para>The component framework has built-in knowledge for processing sourcefiles written in C, C++ or assembler. These should have a<literal>.c</literal>, <literal>.cxx</literal> and<literal>.S</literal> suffix respectively. The current implementationhas no simple mechanism for extending this with support for otherlanguages or for alternative suffixes, but this should be addressed ina future release.</para><para>The compiler command that will be used is something like<literal>arm-elf-gcc</literal>. This consists of a command prefix, inthis case <literal>arm-elf</literal>, and a specific command such as<literal>gcc</literal>. The command prefix will depend on the targetarchitecture and is controlled by a configuration option in theappropriate HAL package. It will have a sensible default value for thecurrent architecture, but users can modify this option when necessary.The command prefix cannot be changed on a per-package basis, sinceit is usually essential that all packages are built with a consistentset of tools.</para><para>The <literal>$(INCLUDE_PATH)</literal> header file search pathconsists of at least the following:</para><orderedlist><listitem><para>The <filename class="directory">include</filename> directory in theinstall tree. This allows source files to access the various headerfiles exported by all the packages in the configuration, and also theconfiguration header files.</para></listitem><listitem><para>The current package's root directory. This ensures that all files inthe package are accessible at build time.</para></listitem><listitem><para>The current package's <filename class="directory">src</filename>subdirectory, if it is present. Generally all files to be compiled arelocated in or below this directory. Typically this is used to accessprivate header files containing implementation details only.</para></listitem></orderedlist><para>The compiler flags <literal>$(CFLAGS)</literal> are determined in twosteps. First the appropriate HAL package will provide a configurationoption defining the global flags. Typically this includes flags thatare needed for the target processor, for example<literal>-mcpu=arm9</literal>, various flags related to warnings,debugging and optimization, and flags such as<literal>-finit-priority</literal> which are needed by &eCos; itself.Users can modify the global flags option as required. In addition itis possible for existing flags to be removed from and new flags to beadded to the current set on a per-package basis, again by means ofuser-modifiable configuration options. More details are given below.</para><para>Component writers can assume that the build system will perform fullheader file dependency analysis, including dependencies onconfiguration headers, but the exact means by which this happens isimplementation-defined. Typical application developers are unlikely tomodify exported or private header files, but configuration headers arelikely to change as the configuration is changed to better meet theneeds of the application. Full header file dependency analysis alsomakes things easier for the component writers themselves.</para><para>The current directory used during a compilation is an implementationdetail of the build system. However it can be assumed that eachpackage will have its own directory somewhere in the build tree, toprevent file name clashes, that this will be the current directory,and that intermediate object files will end up here.</para></sect2><!-- }}} --><!-- {{{ Library Generation     --><sect2 id="build.make.libraries"><title>Generating the Libraries</title><para>Once all the &compile; and &make-object; properties have beenprocessed and the required object files have been built or rebuilt,these can be collected together in one or more libraries. The archiverwill be the <application class="software">ar</application> commandcorresponding to the current architecture, for example <applicationclass="software">powerpc-eabi-ar</application>. By default al of theobject files will end up in a single library<filename>libtarget.a</filename>. This can be changed on a per-packagebasis using the <link linkend="ref.library">&library</link> propertyin the body of the corresponding &cdl-package; command, for example:</para><programlisting width=72>cdl_package &lt;SOME_PACKAGE&gt; {    &hellip;    library  libSomePackage.a}</programlisting><para>However using different libraries for each package should be avoided.It makes things more difficult for application developers since theynow have to link the application code with more libraries, andpossibly even change this set of libraries when packages are added toor removed from the configuration. The use of a single library<filename>libtarget.a</filename> avoids any complications.</para><para>It is also possible to change the target library for individual files,using a <literal>-library</literal> option with the corresponding&compile; or &make-object; property. For example:</para><programlisting width=72>    compile -library=libSomePackage.a hello.c

⌨️ 快捷键说明

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