📄 ref.active-if.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>active_if</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="cdl_interface"HREF="ref.cdl-interface.html"><LINKREL="NEXT"TITLE="calculated"HREF="ref.calculated.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.cdl-interface.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="ref.calculated.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="REF.ACTIVE-IF"><SPANCLASS="PROPERTY">active_if</SPAN></H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN3662"></A><H2>Name</H2>Property <SPANCLASS="PROPERTY">active_if</SPAN> -- Allow additional control over the active state of anoption or other CDL entity.</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN3666"><H2>Synopsis</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="SYNOPSIS">cdl_option <name> { active_if <condition> …}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN3668"></A><H2>Description</H2><P>Configuration options or other entities may be either active orinactive. Typically this is controlled by the option's location in theoverall hierarchy. Consider the option<TTCLASS="LITERAL">CYGDBG_INFRA_DEBUG_PRECONDITIONS</TT>, which existsbelow the component <TTCLASS="LITERAL">CYGDBG_USE_ASSERT</TT>. If the wholecomponent is disabled then the options it contains are inactive: thereis no point in enabling preconditions unless there is genericassertion support; any <SPANCLASS="PROPERTY">requires</SPAN> constraints associated withpreconditions are irrelevant; any <SPANCLASS="PROPERTY">compile</SPAN> property or otherbuild-related property is ignored.</P><P>In some cases the hierarchy does not provide sufficient control overwhether or not a particular option should be active. For example, themath library could have support for floating point exceptions whichis only worthwhile if the hardware implements appropriatefunctionality, as specified by the architectural HAL. The relevantmath library configuration options should remain below the<TTCLASS="LITERAL">CYGPKG_LIBM</TT> package in the overall hierarchy, butshould be inactive unless there is appropriate hardware support. Incases like this an <SPANCLASS="PROPERTY">active_if</SPAN> property is appropriate.</P><P>Another common use of <SPANCLASS="PROPERTY">active_if</SPAN> properties is to avoid excessivenesting in the configuration hierarchy. If some option B is onlyrelevant if option A is enabled, it is possible to turn A into acomponent that contains B. However adding another level to thehierarchy for a component which will contain just one entry may beconsidered excessive. In such cases it is possible for B to have an<SPANCLASS="PROPERTY">active_if</SPAN> dependency on A.</P><P><SPANCLASS="PROPERTY">active_if</SPAN> takes a goal expression as argument. For details of goalexpression syntax see <AHREF="language.values.html#LANGUAGE.GOAL-EXPRESSION">the Section called <I>Goal Expressions</I> in Chapter 3</A>. Inmost cases the goal expression will be very simple, often involvingjust one other option, but more complicated expressions can be usedwhen appropriate. It is also possible to have multiple <SPANCLASS="PROPERTY">active_if</SPAN>conditions in a single option, in which case all of the conditionshave to be satisfied if the option is to be active.</P><P>The <SPANCLASS="PROPERTY">active_if</SPAN> and <SPANCLASS="PROPERTY">requires</SPAN> properties have certain similarities,but they serve a different purpose. Suppose there are two options Aand B, and option B relies on functionality provided by A. This couldbe expressed as either <TTCLASS="LITERAL">active_if A</TT> or as<TTCLASS="LITERAL">requires A</TT>. The points to note are:</P><P></P><UL><LI><P>If <TTCLASS="LITERAL">active_if A</TT> is used and A is disabled orinactive, then graphical tools will generally prevent any attempt atmodifying B. For example the text for B could be grayed out, and theassociated checkbutton (if B is a boolean option) would be disabled.If the user needs the functionality provided by option B then it isnecessary to go to option A first and manipulate it appropriately.</P></LI><LI><P>If <TTCLASS="LITERAL">requires A</TT> is used and A is disabled orinactive, 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.</P></LI><LI><P>If there are hardware dependencies then an <SPANCLASS="PROPERTY">active_if</SPAN> 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<TTCLASS="LITERAL">active_if CYGPKG_NET</TT> 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. </P></LI><LI><P>If option B exists to provide additional debugging information aboutthe functionality provided by A then again an <SPANCLASS="PROPERTY">active_if</SPAN> constraintis appropriate. There is no point in letting users enable extradebugging facilities for a feature that is not actually present.</P></LI><LI><P>The configuration system's inference engine will cope equally wellwith <SPANCLASS="PROPERTY">active_if</SPAN> and <SPANCLASS="PROPERTY">requires</SPAN> properties. Suppose there is aconflict because some third option depends on B. If B is<TTCLASS="LITERAL">active_if A</TT> then the inference engine willattempt to make A active and enabled, and then to enable B ifnecessary. If B <TTCLASS="LITERAL">requires A</TT> 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.</P></LI></UL></DIV><DIVCLASS="REFSECT1"><ANAME="AEN3710"></A><H2>Example</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"># 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 …}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN3713"></A><H2>See Also</H2><P>Property <AHREF="ref.requires.html"><SPANCLASS="PROPERTY">requires</SPAN></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.cdl-interface.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.calculated.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><TTCLASS="LITERAL">cdl_interface</TT></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="reference.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><SPANCLASS="PROPERTY">calculated</SPAN></TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -