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

📄 build.make.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 4 页
字号:
delete them.</P></LI></OL><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>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.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="BUILD.MAKE.COMPILES">Compiling</H2><P>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 <SPANCLASS="PROPERTY">compile</SPAN> properties in the <SPANCLASS="APPLICATION">CDL</SPAN>scripts for the various packages, for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_package CYGPKG_ERROR {    display       "Common error code support"    compile       strerror.cxx    &#8230;}</PRE></TD></TR></TABLE><P><SPANCLASS="PROPERTY">compile</SPAN> properties may appear in the body of a <TTCLASS="LITERAL">cdl_package</TT>,<TTCLASS="LITERAL">cdl_component</TT>, <TTCLASS="LITERAL">cdl_option</TT> or <TTCLASS="LITERAL">cdl_interface</TT>. If the option orother <SPANCLASS="APPLICATION">CDL</SPAN> entity is active and enabled, the property takes effect.If the option is inactive or disabled the property is ignored. It ispossible for a <SPANCLASS="PROPERTY">compile</SPAN> property to list multiple source files, andit is also possible for a given <SPANCLASS="APPLICATION">CDL</SPAN> entity to contain multiple<SPANCLASS="PROPERTY">compile</SPAN> properties. The following three examples are equivalent:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_option &lt;some_option&gt; {    &#8230;    compile file1.c file2.c file3.c}cdl_option &lt;some_option&gt; {    &#8230;    compile file1.c    compile file2.c    compile file3.c}cdl_option &lt;some_option&gt; {    &#8230;    compile file1.c file2.c    compile file3.c}</PRE></TD></TR></TABLE><P>Packages that follow the directory layout conventions should have asubdirectory <TTCLASS="FILENAME">src</TT>, 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 <TTCLASS="FILENAME">strerror.cxx</TT> then the following two linesare equivalent:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    compile strerror.cxx    compile src/strerror.cxx</PRE></TD></TR></TABLE><P>In the first case the component framework will find the fileimmediately in the packages <TTCLASS="FILENAME">src</TT>subdirectory. In the second case the framework will first look for afile <TTCLASS="FILENAME">src/src/strerror.cxx</TT>, and then for<TTCLASS="FILENAME">str/strerror.cxx</TT> relative to the package's rootdirectory. The result is the same.</P><P>The file names may be relative paths, allowing the source code to besplit over multiple directories. For example if a package contains afile <TTCLASS="FILENAME">src/sync/mutex.cxx</TT> then the corresponding<SPANCLASS="APPLICATION">CDL</SPAN> entry would be:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    compile sync/mutex.cxx</PRE></TD></TR></TABLE><P>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:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">&lt;object file&gt; : &lt;source file&gt;        $(CC) -c $(INCLUDE_PATH) $(CFLAGS) -o $@ $&#60;</PRE></TD></TR></TABLE><P>The component framework has built-in knowledge for processing sourcefiles written in C, C++ or assembler. These should have a<TTCLASS="LITERAL">.c</TT>, <TTCLASS="LITERAL">.cxx</TT> and<TTCLASS="LITERAL">.S</TT> 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.</P><P>The compiler command that will be used is something like<TTCLASS="LITERAL">arm-elf-gcc</TT>. This consists of a command prefix, inthis case <TTCLASS="LITERAL">arm-elf</TT>, and a specific command such as<TTCLASS="LITERAL">gcc</TT>. 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.</P><P>The <TTCLASS="LITERAL">$(INCLUDE_PATH)</TT> header file search pathconsists of at least the following:</P><P></P><OLTYPE="1"><LI><P>The <TTCLASS="FILENAME">include</TT> 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.</P></LI><LI><P>The current package's root directory. This ensures that all files inthe package are accessible at build time.</P></LI><LI><P>The current package's <TTCLASS="FILENAME">src</TT>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.</P></LI></OL><P>The compiler flags <TTCLASS="LITERAL">$(CFLAGS)</TT> 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<TTCLASS="LITERAL">-mcpu=arm9</TT>, various flags related to warnings,debugging and optimization, and flags such as<TTCLASS="LITERAL">-finit-priority</TT> which are needed by <SPANCLASS="APPLICATION">eCos</SPAN> 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.</P><P>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.</P><P>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.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="BUILD.MAKE.LIBRARIES">Generating the Libraries</H2><P>Once all the <SPANCLASS="PROPERTY">compile</SPAN> and <SPANCLASS="PROPERTY">make_object</SPAN> 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 <SPANCLASS="APPLICATION">ar</SPAN> commandcorresponding to the current architecture, for example <SPANCLASS="APPLICATION">powerpc-eabi-ar</SPAN>. By default al of theobject files will end up in a single library<TTCLASS="FILENAME">libtarget.a</TT>. This can be changed on a per-packagebasis using the <AHREF="ref.library.html"><SPANCLASS="PROPERTY">library</SPAN></A> propertyin the body of the corresponding <TTCLASS="LITERAL">cdl_package</TT> command, for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_package &lt;SOME_PACKAGE&gt; {    &#8230;    library  libSomePackage.a}</PRE></TD></TR></TABLE><P>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<TTCLASS="FILENAME">libtarget.a</TT> avoids any complications.</P><P>It is also possible to change the target library for individual files,using a <TTCLASS="LITERAL">-library</TT> option with the corresponding<SPANCLASS="PROPERTY">compile</SPAN> or <SPANCLASS="PROPERTY">make_object</SPAN> property. For example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    compile -library=libSomePackage.a hello.c    make_object -library=libSomePackage.a {        &#8230;    }</PRE></TD></TR></TABLE><P>Again this should be avoided because it makes application developmentmore difficult. There is one special library which can be used freely,<TTCLASS="FILENAME">libextras.a</TT>, which is used to generate the<TTCLASS="FILENAME">extras.o</TT> file as described below.</P><P>The order in which object files end up in a library is not defined.Typically each library will be created directly in the install tree,since there is little point in generating a file in the build tree andthen immediately copying it to the install tree.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="BUILD.EXTRAS">The <TTCLASS="FILENAME">extras.o</TT> file</H2><P>Package sources files normally get compiled and then added to alibrary, by default <TTCLASS="FILENAME">libtarget.a</TT>, which is thenlinked with the application code. Because of the usual rules forlinking with libraries, augmented by the use of link-time garbagecollection, this means that code will only end up in the finalexecutable if there is a direct or indirect reference to it in theapplication. Usually this is the desired behaviour: if the applicationdoes not make any use of say kernel message boxes, directly orindirectly, then that code should not end up in the final executabletaking up valuable memory space.</P><P>In a few cases it is desirable for package code to end up in the finalexecutable even if there are no direct or indirect references. Forexample, device driver functions are often not called directly.Instead the application will access the device via the string<TTCLASS="LITERAL">"/dev/xyzzy"</TT> and call the device functionsindirectly. This will be impossible if the functions have beenremoved at link-time.</P><P>Another example involves static C++ objects. It is possible to have astatic C++ object, preferably with a suitable constructor priority,where all of the interesting work happens as a side effect of runningthe constructor. For example a package might include a monitoringthread or a garbage collection thread created from inside such aconstructor. Without a reference by the application to the staticobject the latter will never get linked in, and the package will notfunction as expected.</P><P>A third example would be copyright messages. A package vendor may wantto insist that all products shipped using that package include aparticular message in memory, even though many users of that packagewill object to such a restriction.</P><P>To meet requirements such as these the build system provides supportfor a file <TTCLASS="FILENAME">extras.o</TT>, which always gets linkedwith the application code via the linker script. Because it is anobject file rather than a library everything in the file will belinked in. The <TTCLASS="FILENAME">extras.o</TT> file is generated at theend of a build from a library <TTCLASS="FILENAME">libextras.a</TT>, sopackages can put functions and variables in suitable source files andadd them to that library explicitly:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    compile -library=libextras.a xyzzy.c    compile xyzzy_support.c</PRE></TD></TR></TABLE><P>In this example <TTCLASS="FILENAME">xyzzy.o</TT> will end up in<TTCLASS="FILENAME">libextras.a</TT>, and hence in<TTCLASS="FILENAME">extras.o</TT> and in the final executable.<TTCLASS="FILENAME">xyzzy_support.o</TT> will end up in<TTCLASS="FILENAME">libtarget.a</TT> as usual, and is subject to linkergarbage collection.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="BUILD.FLAGS">Compilers and Flags</H2><DIVCLASS="CAUTION"><P></P><TABLECLASS="CAUTION"BORDER="1"WIDTH="100%"><TR><TDALIGN="CENTER"><B>Caution</B></TD></TR><TR><TDALIGN="LEFT"><P>Some of the details of compiler selection and compiler flags describedbelow are subject to change in future revisions of the componentframework, although every reasonable attempt will be made to avoidbreaking backwards compatibility.</P></TD></TR></TABLE></DIV><P>The build system needs to know what compiler to use, what compilerflags should be used for different stages of the build and so on. Muchof this information will vary from target to target, although usersshould be able to override this when appropriate. There may also be aneed for some packages to modify the compiler flags. All platform HALpackages should define a number of options with well-known names,along the following lines (any existing platform HAL package can beconsulted for a complete example):</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"

⌨️ 快捷键说明

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