📄 reference.sgml
字号:
inactive, graphical tools will still allow B to be manipulated andenabled. This would result in a new conflict which may get resolvedautomatically or which may need user intervention.</para></listitem><listitem><para>If there are hardware dependencies then an &active-if; condition isusually the preferred approach. There is no point in allowing the userto manipulate a configuration option if the correspondingfunctionality cannot possibly work on the currently-selected hardware.Much the same argument applies to coarse-grained dependencies, forexample if an option depends on the presence of a TCP/IP stack then an<literal>active_if CYGPKG_NET</literal> condition is appropriate:it may be possible to satisfy the condition, but it requires thefairly drastic step of loading another package; further more, if theuser wanted a TCP/IP stack in the configuration then it would probablyhave been loaded already. </para></listitem><listitem><para>If option B exists to provide additional debugging information aboutthe functionality provided by A then again an &active-if; constraintis appropriate. There is no point in letting users enable extradebugging facilities for a feature that is not actually present.</para></listitem><listitem><para>The configuration system's inference engine will cope equally wellwith &active-if; and &requires; properties. Suppose there is aconflict because some third option depends on B. If B is<literal>active_if A</literal> then the inference engine willattempt to make A active and enabled, and then to enable B ifnecessary. If B <literal>requires A</literal> then the inferenceengine will attempt to enable B and resolve the resulting conflict bycausing A to be both active and enabled. Although the inference occursin a different order, in most cases the effect will be the same.</para></listitem></itemizedlist></refsect1><refsect1><title>Example</title><programlisting width=72># Do not provide extra semaphore debugging if there are no semaphorescdl_option CYGDBG_KERNEL_INSTRUMENT_BINSEM { active_if CYGPKG_KERNEL_SYNCH …}# Avoid another level in the configuration hierarchycdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE_RELAY { active_if CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE …}# Functionality that is only relevant if another package is loadedcdl_option CYGSEM_START_UITRON_COMPATIBILITY { active_if CYGPKG_UITRON …}# Check that the hardware or HAL provide the appropriate functionalitycdl_option CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT { active_if CYGINT_HAL_DEBUG_GDB_STUBS_BREAK …}</programlisting></refsect1><refsect1><title>See Also</title><para>Property <link linkend="ref.requires">&requires;</link>.</para></refsect1></refentry><!-- }}} --><!-- {{{ calculated --><refentry id="ref.calculated"><refmeta><refentrytitle>&calculated;</refentrytitle></refmeta><refnamediv><refname>Property &calculated;</refname><refpurpose>Used if the current option's value is not user-modifiable,but is calculated using a suitable CDL expression.</refpurpose></refnamediv><refsynopsisdiv><synopsis>cdl_option <name> { calculated <expression> …}</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>In some cases it is useful to have a configuration option whose valuecannot be modified directly by the user. This can be achieved using a&calculated;, which takes a CDL expression as argument (see <xreflinkend="language.expression"> for a description of expressionsyntax). The configuration system evaluates the expression when thecurrent package is loaded and whenever there is a change to any otheroption referenced in the expression. The result depends on theoption's flavor:</para><variablelist TermLength=16><varlistentry><term><literal>flavor none</literal></term><listitem><para>Options with this flavor have no value, so the &calculated;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, 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 value of the option is the result of evaluating the expression.</para></listitem></varlistentry></variablelist><para>There are a number of valid uses for calculated options, and there arealso many cases where some other CDL facility would be moreappropriate. Valid uses of calculated options include the following:</para><itemizedlist><listitem><para>On some target hardware a particular feature may be user-configurable,while on other targets it is fixed. For example some processors canoperate in either big-endian or little-endian mode, while otherprocessors do not provide any choice. It is possible to have anoption <literal>CYGARC_BIGENDIAN</literal> which is calculated insome architectural HAL packages but user-modifiable in others.</para></listitem><listitem><para>Calculated options can provide an alternative way for one package toaffect the behavior of another one. Suppose a package may provide twopossible implementations, a preferred one involving self-modifyingcode and a slower alternative. If the system involves a ROM bootstrapthen the slower alternative must be used, but it would beinappropriate to modify the startup option in every HAL to imposeconstraints on this package. Instead it is possible to have acalculated option whose value is<literal>{ CYG_HAL_STARTUP == "ROM" }</literal>,and which has appropriate consequences. Arguably this is a spuriousexample, and it should be a user choice whether or not to useself-modifying code with a &default-value; based on<literal>CYG_HAL_STARTUP</literal>, but that is for the componentwriter to decide.</para></listitem><listitem><para>Sometimes it should be possible to perform a particular test atcompile-time, for example by using a C preprocessor<literal>#if</literal> construct. However the preprocessor has onlylimited functionality, for example it cannot perform stringcomparisons. CDL expressions are more powerful.</para></listitem><listitem><para>Occasionally a particular sub-expression may occur multiple times ina CDL script. If the sub-expression is sufficiently complex then itmay be worthwhile to have a calculated option whose value is thesub-expression, and then reference that calculated option in theappropriate places. </para></listitem></itemizedlist><para>Alternatives to using calculated options include the following:</para><itemizedlist><listitem><para>CDL <link linkend="language.interface">interfaces</link> are a form ofcalculated option intended as an abstraction mechanism. An interfacecan be used to express the concept of <emphasis>anyscheduler</emphasis>, as opposed to a specific one such as the bitmap scheduler.</para></listitem><listitem><para>If a calculated option would serve only to add additional informationto a configuration header file, it may be possible to achieve the sameeffect using a <link linkend="ref.define-proc">&define-proc</link>property or one of the other properties related to header filegeneration.</para></listitem></itemizedlist><tip><para>If the first entry in a &calculated; expression is a negativenumber, for example <literal>calculated -1</literal> then thiscan be misinterpreted as an option instead of as part of theexpression. Currently the &calculated; 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>calculated -- -1</literal></para></tip><warning><para>Some of the CDL scripts in current &eCos; releases make excessive useof calculated options. This is partly because the recommendedalternatives were not always available at the time the scripts werewritten. It is also partly because there is still some missingfunctionality, for example &define-proc; properties cannot yet accessthe configuration data so it may be necessary to use &calculated;properties to access the data and perform the desired manipulation viaa &CDL; expression. New scripts should use calculated options only inaccordance with the guidelines.</para></warning><note><para>For options with the booldata flavor the current CDL syntax does notallow the enabled flag and the value to be calculated separately.Functionality to permit this may be added in a future release.</para></note><note><para>It has been suggested that having options which are notuser-modifiable is potentially confusing, and that a top-level<literal>cdl_constant</literal> command should be added to thelanguage instead of or in addition to the &calculated; property. Sucha change is under consideration. However because the value of acalculated option can depend on other options, it is not necessarilyconstant.</para></note></refsect1><refsect1><title>Example</title><programlisting width=72># A constant on some target hardware, perhaps user-modifiable on other# targets.cdl_option CYGNUM_HAL_RTC_PERIOD { display "Real-time clock period" flavor data calculated 12500}</programlisting></refsect1><refsect1><title>See Also</title><para>Properties <link linkend="ref.default-value">&default-value;</link>,<link linkend="ref.flavor">&flavor;</link> and<link linkend="ref.legal-values">&legal-values;</link>,</para></refsect1></refentry><!-- }}} --><!-- {{{ compile --><refentry id="ref.compile"><refmeta><refentrytitle>&compile;</refentrytitle></refmeta><refnamediv><refname>Property &compile;</refname><refpurpose>List the source files that should be built if this optionis active and enabled.</refpurpose></refnamediv><refsynopsisdiv><synopsis>cdl_option <name> { compile [-library=libxxx.a] <list of files> …}</synopsis></refsynopsisdiv><refsect1><title>Description</title><para>The &compile; 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<filename>libtarget.a</filename>. It is possible for component writersto specify an alternative library for an entire package using the<link linkend="ref.library">&library;</link> property. Alternativelythe desired library can be specified on the &compile; line itself. Forexample, to add a particular source file to the<filename>libextras.a</filename> library the following could be used:</para><programlisting width=72>cdl_package CYGPKG_IO_SERIAL { … compile -library=libextras.a common/tty.c}</programlisting><para>Details of the build process including such issues as compiler flagsand the order in which things happen can be found in<xref linkend="build">. </para><para>&compile; properties can occur in any of &cdl-option;,&cdl-component;, &cdl-package; or &cdl-interface;. A &compile;property has effect if and only if the entity that contains it isactive and enabled. Typically the body of a &cdl-package; will defineany source files that need to be built irrespective of individualoptions, and each &cdl-component;, &cdl-option;, and &cdl-interface;will define source files that are more specific. A single &compile;property can list any number of source files, all destined for thesame library. A &cdl-option; or other entity can contain multiple&compile; properties, each of which can specify a different library.It is possible for a given source file to be specified in &compile;properties for several different options, in which case the sourcefile will get built if any of these options are active and enabled.</para><para>If the package follows the <link linkend="package.hierarchy">directorylayout conventions</link> then the configuration tools will search forthe specified source files first in the<filename class="directory">src</filename> subdirectory of thepackage, then relative to the package directory itself. </para><note><para>A shortcoming of the current specification of &compile; 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 able
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -