📄 ref.compile.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>compile</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="The eCos Component Writer's Guide"HREF="cdl-guide.html"><LINKREL="UP"TITLE="CDL Language Specification"HREF="reference.html"><LINKREL="PREVIOUS"TITLE="calculated"HREF="ref.calculated.html"><LINKREL="NEXT"TITLE="default_value"HREF="ref.default-value.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">The <SPANCLASS="APPLICATION">eCos</SPAN> Component Writer's Guide</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="ref.calculated.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="ref.default-value.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="REF.COMPILE"><SPANCLASS="PROPERTY">compile</SPAN></H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN3815"></A><H2>Name</H2>Property <SPANCLASS="PROPERTY">compile</SPAN> -- List the source files that should be built if this optionis active and enabled.</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN3819"><H2>Synopsis</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="SYNOPSIS">cdl_option <name> { compile [-library=libxxx.a] <list of files> …}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN3821"></A><H2>Description</H2><P>The <SPANCLASS="PROPERTY">compile</SPAN> property allows component developers to specify sourcefiles which should be compiled and added to one of the targetlibraries. Usually each source file will end up the library<TTCLASS="FILENAME">libtarget.a</TT>. It is possible for component writersto specify an alternative library for an entire package using the<AHREF="ref.library.html"><SPANCLASS="PROPERTY">library</SPAN></A> property. Alternativelythe desired library can be specified on the <SPANCLASS="PROPERTY">compile</SPAN> line itself. Forexample, to add a particular source file to the<TTCLASS="FILENAME">libextras.a</TT> library the following could be used:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_package CYGPKG_IO_SERIAL { … compile -library=libextras.a common/tty.c}</PRE></TD></TR></TABLE><P>Details of the build process including such issues as compiler flagsand the order in which things happen can be found in<AHREF="build.html">Chapter 4</A>. </P><P><SPANCLASS="PROPERTY">compile</SPAN> properties can occur in any of <TTCLASS="LITERAL">cdl_option</TT>,<TTCLASS="LITERAL">cdl_component</TT>, <TTCLASS="LITERAL">cdl_package</TT> or <TTCLASS="LITERAL">cdl_interface</TT>. A <SPANCLASS="PROPERTY">compile</SPAN>property has effect if and only if the entity that contains it isactive and enabled. Typically the body of a <TTCLASS="LITERAL">cdl_package</TT> will defineany source files that need to be built irrespective of individualoptions, and each <TTCLASS="LITERAL">cdl_component</TT>, <TTCLASS="LITERAL">cdl_option</TT>, and <TTCLASS="LITERAL">cdl_interface</TT>will define source files that are more specific. A single <SPANCLASS="PROPERTY">compile</SPAN>property can list any number of source files, all destined for thesame library. A <TTCLASS="LITERAL">cdl_option</TT> or other entity can contain multiple<SPANCLASS="PROPERTY">compile</SPAN> properties, each of which can specify a different library.It is possible for a given source file to be specified in <SPANCLASS="PROPERTY">compile</SPAN>properties for several different options, in which case the sourcefile will get built if any of these options are active and enabled.</P><P>If the package follows the <AHREF="package.html#PACKAGE.HIERARCHY">directorylayout conventions</A> then the configuration tools will search forthe specified source files first in the<TTCLASS="FILENAME">src</TT> subdirectory of thepackage, then relative to the package directory itself. </P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>A shortcoming of the current specification of <SPANCLASS="PROPERTY">compile</SPAN> properties isthat there is no easy way to specify source files that should be builtunless an option is enabled. It would sometimes be useful to be ableto say: “if option <TTCLASS="LITERAL">A</TT> is enabled then compilefile <TTCLASS="FILENAME">x.c</TT>, otherwise compile file<TTCLASS="FILENAME">y.c</TT>. There are two simple ways of achieving this: </P><P></P><UL><LI><P>Always compile <TTCLASS="FILENAME">y.c</TT>, typically by listing it inthe body of the <TTCLASS="LITERAL">cdl_package</TT>, but use<TTCLASS="LITERAL">#ifndef A</TT> to produce an empty object file ifoption <TTCLASS="LITERAL">A</TT> is not enabled. This has the bigdisadvantage that the file always gets compiled and hence for someconfigurations builds will take longer than necessary.</P></LI><LI><P>Use a <SPANCLASS="PROPERTY">calculated</SPAN> option whose value is <TTCLASS="LITERAL">!A</TT>, andhave a <TTCLASS="LITERAL">compile y.c</TT> property in its body. Thishas the big disadvantage of adding another calculated option to theconfiguration.</P></LI></UL><P>It is likely that this will be resolved in the future, possibly byusing some sort of expression as the argument to a <SPANCLASS="PROPERTY">compile</SPAN> property.</P></BLOCKQUOTE></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>Currently it is not possible to control the priority of a <SPANCLASS="PROPERTY">compile</SPAN>property, in other words the order in which a file gets compiledrelative to other build steps. This functionality might prove usefulfor complicated packages and should be added.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN3874"></A><H2>Example</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_package CYGPKG_INFRA { display "Infrastructure" include_dir cyg/infra description " Common types and useful macros. Tracing and assertion facilities. Package startup options." compile startup.cxx prestart.cxx pkgstart.cxx userstart.cxx \ dummyxxmain.cxx memcpy.c memset.c delete.cxx \ diag.cxx tcdiag.cxx}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN3877"></A><H2>See Also</H2><P>Properties <AHREF="ref.make.html">make</A>,<AHREF="ref.make-object.html">make_object</A> and<AHREF="ref.library.html">library</A>.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="ref.calculated.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="cdl-guide.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="ref.default-value.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><SPANCLASS="PROPERTY">calculated</SPAN></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="reference.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><SPANCLASS="PROPERTY">default_value</SPAN></TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -