Spoke to soon. My change works for the case where BUILD_PLATFORM_XYZ is not defined but the case where it is defined I guess INCLUDE_XYZ_FDF needs to be defined in a different way with proper escape characters.

Thanks
Ashish

From: Ashish Singhal <ashishsingha@nvidia.com>
Sent: Monday, April 20, 2020 1:07 AM
To: Lin, Derek (HPS SW) <derek.lin2@hpe.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Bob Feng <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2-devel] Conditionally Include FDF File
 
It seems like this is happening because in FdfParser.py, include files are processed before processing the conditional statements. I think this is being done so that all defines (even from the included files) can be accounted for before processing any conditionals. This seems to be a valid flow from pre-processing perspective, although this leaves out the use case where a file may be conditionally included.

Bob/Liming,

For now, I have fixed the issue by changing my conditional include to be the following:

In top-level FDF:
!ifdef $(BUILD_PLATFORM_XYZ)
  $(INCLUDE_XYZ_FDF)
!endif

In top-level DSC:
!ifdef $(BUILD_PLATFORM_XYZ)
  INCLUDE_XYZ_FDF = !include Platform/NVIDIA/XYZ.fdf.inc
!endif

Please suggest me if there is a batter way of working around this issue.

Thanks
Ashish

From: Lin, Derek (HPS SW) <derek.lin2@hpe.com>
Sent: Monday, April 20, 2020 12:16 AM
To: Ashish Singhal <ashishsingha@nvidia.com>; devel@edk2.groups.io <devel@edk2.groups.io>
Subject: Re: [edk2-devel] Conditionally Include FDF File
 
External email: Use caution opening links or attachments

I saw this issue too.

The included file is always included no matter the condition is TRUE or FALSE.
```
!if FALSE
  !include abc.fdf
!endif
```


This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.