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

📄 reference.sgml

📁 ecos实时嵌入式操作系统
💻 SGML
📖 第 1 页 / 共 5 页
字号:
to say: &ldquo;if option <literal>A</literal> is enabled then compilefile <filename>x.c</filename>, otherwise compile file<filename>y.c</filename>. There are two simple ways of achieving this: </para><itemizedlist><listitem><para>Always compile <filename>y.c</filename>, typically by listing it inthe body of the &cdl-package;, but use<literal>#ifndef&nbsp;A</literal> to produce an empty object file ifoption <literal>A</literal> is not enabled. This has the bigdisadvantage that the file always gets compiled and hence for someconfigurations builds will take longer than necessary.</para></listitem><listitem><para>Use a &calculated; option whose value is <literal>!A</literal>, andhave a <literal>compile&nbsp;y.c</literal> property in its body. Thishas the big disadvantage of adding another calculated option to theconfiguration.</para></listitem></itemizedlist><para>It is likely that this will be resolved in the future, possibly byusing some sort of expression as the argument to a &compile; property.</para></note><note><para>Currently it is not possible to control the priority of a &compile;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.</para></note></refsect1><refsect1><title>Example</title><programlisting width=72>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}</programlisting></refsect1><refsect1><title>See Also</title><para>Properties <link linkend="ref.make">make</link>,<link linkend="ref.make-object">make_object</link> and<link linkend="ref.library">library</link>.</para></refsect1></refentry><!-- }}} --><!-- {{{ default_value  --><refentry id="ref.default-value"><refmeta><refentrytitle>&default-value;</refentrytitle></refmeta><refnamediv><refname>Property &default-value;</refname><refpurpose>Provide a default value for this option using a CDL expression.</refpurpose></refnamediv><refsynopsisdiv><synopsis>cdl_option &lt;name&gt; {    default_value &lt;expression&gt;    &hellip;}</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>The &default-value; property allows the initial value of aconfiguration option to depend on other configuration options. Thearguments to the property should be a &CDL; expression, see<xref linkend="language.expression"> for the syntactic details.In many cases a simple constant value will suffice, for example:</para><programlisting width=72>cdl_component CYGPKG_KERNEL_EXCEPTIONS {    &hellip;    default_value 1    cdl_option CYGSEM_KERNEL_EXCEPTIONS_DECODE {        &hellip;        default_value 0    }}</programlisting><para>However it is also possible for an option's default value to depend onother options. For example the common HAL package provides somesupport functions that are needed by the &eCos; kernel, but areunlikely to be useful if the kernel is not being used. Thisrelationship can be expressed using:</para><programlisting width=72>cdl_option CYGFUN_HAL_COMMON_KERNEL_SUPPORT {    ...    default_value CYGPKG_KERNEL}</programlisting><para>If the kernel is loaded then this HAL option is automatically enabled,although the user can still disable it explicitly should this provenecessary. If the kernel is not loaded then the option is disabled,although it can still be enabled by the user if desired.&default-value; expressions can be more complicated than this ifappropriate, and provide a very powerful facility for componentwriters who want their code to &ldquo;just do the right thing&rdquo;in a wide variety of configurations.</para><para>The &CDL; configuration system evaluates the &default-value;expression when the current package is loaded and whenever there is achange to any other option referenced in the expression. The resultdepends on the option's flavor:</para><variablelist TermLength=16><varlistentry><term><literal>flavor none</literal></term><listitem><para>Options with this flavor have no value, so the &default-value;property is not applicable.</para></listitem></varlistentry><varlistentry><term><literal>flavor bool</literal></term><listitem><para>If the expression evaluates to a non-zero result the option isenabled by default, otherwise it is disabled.</para></listitem></varlistentry><varlistentry><term><literal>flavor booldata</literal></term><listitem><para>If the result of evaluating the expression is zero then the option isdisabled, otherwise the option is enabled and its value is the result.</para></listitem></varlistentry><varlistentry><term><literal>flavor data</literal></term><listitem><para>The default value of the option is the result of evaluating theexpression.</para></listitem></varlistentry></variablelist><para>A &cdl-option; or other entity can have at most one &default-value;property, and it is illegal to have both a &calculated; and a&default-value; property in one body. If an option does not haveeither a &default-value; or a &calculated; property and it does nothave the flavor <literal>none</literal> then the configuration toolswill assume a default value expression of <literal>0</literal>.</para><para>On occasion it is useful to have a configuration option<literal>A</literal> which has both a &requires; constraint on someother option <literal>B</literal> and a &default-value; expression of<literal>B</literal>. If option <literal>B</literal> is not enabledthen <literal>A</literal> will also be disabled by default and noconflict arises. If <literal>B</literal> is enabled then<literal>A</literal> also becomes enabled and again no conflictarises. If a user attempts to enable <literal>B</literal> but not<literal>A</literal> then there will be a conflict. Users should beable to deduce that the two options are closely interlinked and shouldnot be manipulated independently except in very unusual circumstances.</para><tip><para>If the first entry in a &default-value; expression is a negativenumber, for example <literal>default_value&nbsp;-1</literal> then thiscan be misinterpreted as an option instead of as part of theexpression. Currently the &default-value; property does not take anyoptions, but this may change in future. Option processing halts at thesequence <literal>--</literal>, so the desired value can be expressedsafely using<literal>default_value&nbsp;--&nbsp;-1</literal></para></tip><note><para>In many cases it would be useful to calculate default values usingsome global preferences, for example:</para><programlisting width=72>cdl_option CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST {    &hellip;    default_value CYGGLO_CODESIZE > CYGGLO_SPEED}</programlisting><para>Such global preference options do not yet exist, but are likely to beadded in a future version.</para></note><note><para>For options with the booldata flavor the current syntax does not allowthe default values of the enabled flag and the value to be controlledseparately. Functionality to permit this may be added in a futurerelease.</para></note></refsect1><refsect1><title>Example</title><programlisting width=72>cdl_option CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT {    display       "Include GDB multi-threading debug support"    requires      CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT    default_value CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT    description   "        This option enables some extra HAL code which is needed        to support multi-threaded source level debugging."}</programlisting></refsect1><refsect1><title>See Also</title><para>Properties <link linkend="ref.calculated">&calculated;</link>,<link linkend="ref.flavor">&flavor;</link> and<link linkend="ref.legal-values">&legal-values;</link>.</para></refsect1></refentry><!-- }}} --><!-- {{{ define         --><refentry id="ref.define"><refmeta><refentrytitle>&define;</refentrytitle></refmeta><refnamediv><refname>Property &define;</refname><refpurpose>Specify additional <literal>#define</literal> symbols thatshould go into the owning package's configuration header file.</refpurpose></refnamediv><refsynopsisdiv><synopsis>cdl_option &lt;name&gt; {    define [-file=&lt;filename&gt;] [-format=&lt;format&gt;] &lt;symbol&gt;    &hellip;}</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>Normally the configuration system generates a single<literal>#define</literal> for each option that is active and enabled,with the defined symbol being the name of the option. These<literal>#define's</literal> go to the package's own configurationheader file, for example <filename class="HeaderFile">pkgconf/kernel.h</filename>for kernel configuration options. For the majority of options this issufficient. Sometimes it is useful to have more control over which<literal>#define's</literal> get generated.</para><para>The &define; property can be used to generate an addition<literal>#define</literal> if the option is both active and enabled,for example:</para><programlisting width=72>cdl_option CYGNUM_LIBC_STDIO_FOPEN_MAX {    &hellip;    define FOPEN_MAX}</programlisting><para>If this option is given the value 40 then the following<literal>#define's</literal> will be generated in the configurationheader <filename class="HeaderFile">pkgconf/libc.h</filename>:</para><screen width=72>#define CYGNUM_LIBC_STDIO_FOPEN_MAX 40#define FOPEN_MAX 40</screen><para>The default <literal>#define</literal> can be suppressed if desiredusing the &no-define; property. This is useful if the symbol shouldonly be defined in<filename class="HeaderFile">pkgconf/system.h</filename> and not inthe package's own configuration header file. The value that will beused for this <literal>#define</literal> is the same as for thedefault one, and depends on the option's flavor as follows:</para><variablelist TermLength=16><varlistentry><term><literal>flavor none</literal></term><listitem><para>Options with this flavor are always enabled and have no value, so theconstant <literal>1</literal> will be used.</para></listitem></varlistentry><varlistentry><term><literal>flavor bool</literal></term><listitem><para>If the option is disabled then no <literal>#define</literal> will begenerated. Otherwise the constant <literal>1</literal> will be used.</para></listitem></varlistentry><varlistentry><term><literal>flavor booldata</literal></term><listitem><para>If the option is disabled then no <literal>#define</literal> will begenerated. Otherwise the option's current value will be used.</para></listitem></varlistentry><varlistentry><term><literal>flavor data</literal></term><listitem><para>The option's current value will be used.</para></listitem></varlistentry></variablelist><para>For active options with the <literal>data</literal> flavor, and foractive and enabled options with the <literal>booldata</literal>flavor, either one or two <literal>#define's</literal> will begenerated. These take the following forms:</para><programlisting width=72>#define &lt;symbol&gt; &lt;value&gt;#define &lt;symbol&gt;_&lt;value&gt;</programlisting><para>For the first <literal>#define</literal> it is possible to control theformat used for the value using a<literal>-format=&lt;format&gt;</literal> option. For example, thefollowing can be used to output some configuration data as a C string:</para><programlisting width=72>cdl_option &lt;name&gt; {

⌨️ 快捷键说明

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