[edk2-devel] [PATCH 04/11] OvmfPkg: Shell*.inc: allow building without network support

Gerd Hoffmann posted 11 patches 8 months, 3 weeks ago
[edk2-devel] [PATCH 04/11] OvmfPkg: Shell*.inc: allow building without network support
Posted by Gerd Hoffmann 8 months, 3 weeks ago
Add NETWORK_ENABLE conditionals for the components
which need network support.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 OvmfPkg/Include/Dsc/ShellComponents.dsc.inc | 4 ++++
 OvmfPkg/Include/Fdf/ShellDxe.fdf.inc        | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc
index 1a3a349a9de5..248b4b454b70 100644
--- a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc
+++ b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc
@@ -5,6 +5,7 @@
 !if $(BUILD_SHELL) == TRUE
 
 !if $(TOOL_CHAIN_TAG) != "XCODE5"
+!if $(NETWORK_ENABLE) == TRUE
   ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf {
     <PcdsFixedAtBuild>
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
@@ -13,6 +14,7 @@
     <PcdsFixedAtBuild>
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
+!endif
   ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf {
     <PcdsFixedAtBuild>
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
@@ -32,7 +34,9 @@
       NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
       NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
       NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
+!if $(NETWORK_ENABLE) == TRUE
       NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
+!endif
 !if $(NETWORK_IP6_ENABLE) == TRUE
       NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
 !endif
diff --git a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc
index 0935f06fa368..6536c30c5413 100644
--- a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc
+++ b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc
@@ -5,8 +5,10 @@
 !if $(BUILD_SHELL) == TRUE
 
 !if $(TOOL_CHAIN_TAG) != "XCODE5"
+!if $(NETWORK_ENABLE) == TRUE
 INF  ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
 INF  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
+!endif
 INF  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
 !endif
 
-- 
2.43.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114322): https://edk2.groups.io/g/devel/message/114322
Mute This Topic: https://groups.io/mt/103935345/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 04/11] OvmfPkg: Shell*.inc: allow building without network support
Posted by Laszlo Ersek 8 months, 3 weeks ago
On 1/24/24 17:37, Gerd Hoffmann wrote:
> Add NETWORK_ENABLE conditionals for the components
> which need network support.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  OvmfPkg/Include/Dsc/ShellComponents.dsc.inc | 4 ++++
>  OvmfPkg/Include/Fdf/ShellDxe.fdf.inc        | 2 ++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc
> index 1a3a349a9de5..248b4b454b70 100644
> --- a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc
> +++ b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc
> @@ -5,6 +5,7 @@
>  !if $(BUILD_SHELL) == TRUE
>  
>  !if $(TOOL_CHAIN_TAG) != "XCODE5"
> +!if $(NETWORK_ENABLE) == TRUE
>    ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf {
>      <PcdsFixedAtBuild>
>        gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> @@ -13,6 +14,7 @@
>      <PcdsFixedAtBuild>
>        gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>    }
> +!endif
>    ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf {
>      <PcdsFixedAtBuild>
>        gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE

(1) This will prevent testing those code paths in these utilities that deal with *not finding* the underlying networking protocols. That's an argument against this hunk.

However, we already have something similar in place, for UefiShellNetwork2CommandsLib and NETWORK_IP6_ENABLE. So, for consistency's sake, this hunk does seem justified. OK.

(2) Further verification:

- if NETWORK_ENABLE is false, then none of the networking stack is built (see NetworkPkg/NetworkComponents.dsc.inc), and then we don't need these utilities.

- if NETWORK_ENABLE is true, then *at least one* of the IPv4 and IPv6 stacks will be available (see NetworkPkg/NetworkDefines.dsc.inc), and then these utilities should be functional.

OK.

> @@ -32,7 +34,9 @@
>        NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
>        NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
>        NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
> +!if $(NETWORK_ENABLE) == TRUE
>        NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
> +!endif
>  !if $(NETWORK_IP6_ENABLE) == TRUE
>        NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
>  !endif

(3) This looks incorrect. The Network1 command set is related to IPv4, so we should check NETWORK_IP4_ENABLE.

More precisely, the conditionals should look like

!if $(NETWORK_ENABLE) == TRUE
!if $(NETWORK_IP4_ENABLE) == TRUE
      NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
!endif
!if $(NETWORK_IP6_ENABLE) == TRUE
      NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
!endif
!endif

(Meaning that the extant NETWORK_IP6_ENABLE check isn't fully correct either.)


> diff --git a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc
> index 0935f06fa368..6536c30c5413 100644
> --- a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc
> +++ b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc
> @@ -5,8 +5,10 @@
>  !if $(BUILD_SHELL) == TRUE
>  
>  !if $(TOOL_CHAIN_TAG) != "XCODE5"
> +!if $(NETWORK_ENABLE) == TRUE
>  INF  ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
>  INF  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
> +!endif
>  INF  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
>  !endif
>  

Seems OK.

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114404): https://edk2.groups.io/g/devel/message/114404
Mute This Topic: https://groups.io/mt/103935345/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-