public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: KarunakarPoosapalli@Dell.com, edk2-devel@lists.01.org
Subject: Re: Conditional Compilation support in INF file
Date: Wed, 9 Jan 2019 12:00:02 +0100	[thread overview]
Message-ID: <03c8ee0d-dca5-a7ca-b941-f45bd0fd6c38@redhat.com> (raw)
In-Reply-To: <1a62f519f4b2466fb97c0dd7a81057e6@BLRX13MDC432.AMER.DELL.COM>

On 01/09/19 07:55, KarunakarPoosapalli@Dell.com wrote:
> Hi ALL,
> 
> 
> 
> I've an idea regards "Adding conditional compilation  support in INF files"
> 
> 
> 
> Ides is like, we can condition check in INF file like below
> 
> 
> 
> #if Condition1
> 
>    Protocol1
> 
> #elif Condition2
> 
>    Protocol2
> 
> #else
> 
>    Protocol3
> 
> #endif
> 
> 
> 
> If we've this support we can add different protocols in DEPEX section, Like we can put condition check and add rotococol1 for Notebook and Protocol2 for Desktop.
> 
> And will have so many benefits adding this support.
> 
> 
> 
> I don't think current EDK2 support this.
> 
> Please let me know comments/suggestions, so that I will start working on it.

I'm not sure this feature is really required. We already have the
following tools at our disposal, to customize module builds at the INF
file level:

(1) Please see <https://bugzilla.tianocore.org/show_bug.cgi?id=443>.
(Unfortunately, the INF file spec doesn't seem to document the syntax;
<https://lists.01.org/pipermail/edk2-devel/2017-March/008976.html>
should help however.)

(2) If the number of cases that need to be distinguished is low, it's
possible to duplicate the INF file, keep the [Sources] section(s) and
similar sections identical, and only customize the sections that need
changes. Then include the right INF file in the platform DSC and FDF
files, dependent on PCD settings or build defines (macros).

(3) Sometimes it makes sense to delay the dispatching of a module until
another module makes a decision about a platform feature, dynamically.
An important characteristic of this case is that the dependent module
should not be prevented from starting *completely* in case the platform
feature is absent; it should only be made wait until the decision is
recorded, by the other module. This way the dependent module will not
incorrectly customize its own behavior before the decision on the
platform feature is made.

In this case, it's usually possible to write the depex such as

  (gProtocolGuid1 AND gProtocolGuid2) OR
  (gProtocolGuid3 AND gProtocolGuid4) OR
  gThisParticularFeatureDisabledProtocolGuid

Here:
- gProtocolGuid1 and gProtocolGuid2 could be specific to "Notebook",
- gProtocolGuid3 and gProtocolGuid4 could be specific to "Desktop",
- and gThisParticularFeatureDisabledProtocolGuid would be a *synthetic*
protocol GUID -- installed in the protocol database with a NULL
interface -- through which the decision-making module would simply
advertize, "none of the relevant features are available, and you need
not wait any longer".

"gThisParticularFeatureDisabledProtocolGuid" is usually defined /
declared as a platform Pkg-specific GUID, in the appropriate DEC file,
and in Include/Guid/...., under the same Pkg.

(4) It is possible to hook such dependencies into other (core) modules.
In the platform Package, you can implement a library that (a) has an
empty constructor function, and (b) the DEPEX of your choosing (see
above). The library should do nothing else. Then, in the package DSC
file, hook the library into the core module in question via NULL class
resolution. As a result, the library will not alter the behavior of the
core module, but the core module will inherit the depex (it will be
AND-ed together with other dependencies that the core module might have).

Thanks
Laszlo


  reply	other threads:[~2019-01-09 11:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09  6:55 Conditional Compilation support in INF file KarunakarPoosapalli
2019-01-09 11:00 ` Laszlo Ersek [this message]
2019-01-09 12:42   ` Gao, Liming
2019-01-09 14:37     ` Laszlo Ersek
2019-01-10  6:03     ` KarunakarPoosapalli
2019-01-10 12:54       ` Laszlo Ersek
2019-01-10 15:48         ` Gao, Liming
2019-01-10 16:53           ` Kinney, Michael D
2019-01-11  6:33             ` KarunakarPoosapalli
2019-01-11 18:54               ` Kinney, Michael D
2019-01-15 15:10                 ` Gao, Liming
2019-01-28  7:50                   ` KarunakarPoosapalli
2019-01-28  8:36                   ` KarunakarPoosapalli
2019-01-31  6:56                     ` Gao, Liming
2019-01-31 16:26                       ` stephano
2019-02-01 10:52                         ` KarunakarPoosapalli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03c8ee0d-dca5-a7ca-b941-f45bd0fd6c38@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox