[PATCH 36/38] sandbox: Rework how SDL is enabled / disabled

Tom Rini
2022-11-19T23:52:56Z

Given that we can use Kconfig logic directly to see if we have a program
available on the host or not, change from passing NO_SDL to instead
controlling CONFIG_SANDBOX_SDL in Kconfig directly. Introduce
CONFIG_HOST_HAS_SDL as the way to test for sdl2-config and default
CONFIG_SANDBOX_SDL on if we have that, or not.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
.azure-pipelines.yml | 4 ++--
arch/sandbox/Kconfig | 7 +++++++
arch/sandbox/config.mk | 4 +---
doc/arch/sandbox/sandbox.rst | 9 +++------
doc/build/tools.rst | 2 +-
drivers/video/Kconfig | 2 +-
include/configs/sandbox.h | 4 ----
7 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index bda762451fd0..a767fb1008c2 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -30,7 +30,7 @@ stages:
%CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm --needed -Sy make gcc bison flex diffutils openssl-devel libgnutls-devel libutil-linux-devel"
displayName: 'Install Toolchain'
- script: |
- echo make tools-only_defconfig tools-only NO_SDL=1 > build-tools.sh
+ echo make tools-only_defconfig tools-only > build-tools.sh
%CD:~0,2%\msys64\usr\bin\bash -lc "bash build-tools.sh"
displayName: 'Build Host Tools'
env:
@@ -47,7 +47,7 @@ stages:
- script: brew install make ossp-uuid
displayName: Brew install dependencies
- script: |
- gmake tools-only_config tools-only NO_SDL=1 \
+ gmake tools-only_config tools-only \
HOSTCFLAGS="-I/usr/local/opt/openssl@1.1/include" \
HOSTLDFLAGS="-L/usr/local/opt/openssl@1.1/lib" \
-j$(sysctl -n hw.logicalcpu)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 96b3402b47c1..0ce77de2fcb4 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -47,6 +47,13 @@ config HOST_32BIT
config HOST_64BIT
def_bool $(cc-define,_LP64)

+config HOST_HAS_SDL
+ def_bool $(success,sdl2-config --version)
+
+config SANDBOX_SDL
+ bool "Enable SDL2 support in sandbox"
+ default HOST_HAS_SDL
+
config SANDBOX_CRASH_RESET
bool "Reset on crash"
help
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 3e2c7f9ebe55..1284ef390b51 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -8,9 +8,7 @@ SDL_CONFIG ?= sdl2-config

# Define this to avoid linking with SDL, which requires SDL libraries
# This can solve 'sdl-config: Command not found' errors
-ifneq ($(NO_SDL),)
-PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL
-else
+ifeq ($(CONFIG_SANDBOX_SDL),y)
PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs)
PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags)
endif
diff --git a/doc/arch/sandbox/sandbox.rst b/doc/arch/sandbox/sandbox.rst
index 34c4e06d9b8d..e6d840365166 100644
--- a/doc/arch/sandbox/sandbox.rst
+++ b/doc/arch/sandbox/sandbox.rst
@@ -56,11 +56,8 @@ To run sandbox U-Boot use something like::

Note: If you get errors about 'sdl-config: Command not found' you may need to
install libsdl2.0-dev or similar to get SDL support. Alternatively you can
-build sandbox without SDL (i.e. no display/keyboard support) by removing
-the CONFIG_SANDBOX_SDL line in include/configs/sandbox.h or using::
-
- make sandbox_defconfig all NO_SDL=1
- ./u-boot
+build sandbox without SDL (i.e. no display/keyboard support) by disabling
+CONFIG_SANDBOX_SDL in the .config file.

U-Boot will start on your computer, showing a sandbox emulation of the serial
console::
@@ -84,7 +81,7 @@ To exit, type 'poweroff' or press Ctrl-C.
Console / LCD support
---------------------

-Assuming that CONFIG_SANDBOX_SDL is defined when building, you can run the
+Assuming that CONFIG_SANDBOX_SDL is enabled when building, you can run the
sandbox with LCD and keyboard emulation, using something like::

./u-boot -d u-boot.dtb -l
diff --git a/doc/build/tools.rst b/doc/build/tools.rst
index c06f91527417..ec0172292585 100644
--- a/doc/build/tools.rst
+++ b/doc/build/tools.rst
@@ -44,4 +44,4 @@ applications using a linux toolchain (gcc, bash, etc), targeting respectively
Launch the MSYS2 shell of the MSYS2 environment, and do the following::

$ make tools-only_defconfig
- $ make tools-only NO_SDL=1
+ $ make tools-only
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c841b99bb30d..f539977d9b73 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -622,7 +622,7 @@ config VIDEO_ARM_MALIDP

config VIDEO_SANDBOX_SDL
bool "Enable sandbox video console using SDL"
- depends on SANDBOX
+ depends on SANDBOX_SDL
help
When using sandbox you can enable an emulated LCD display which
appears as an SDL (Simple DirectMedia Layer) window. This is a
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 3a5af4b3b609..c9e57da0160a 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -31,8 +31,4 @@
#define CFG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600,\
115200}

-#ifndef SANDBOX_NO_SDL
-#define CONFIG_SANDBOX_SDL
-#endif
-
#endif
--
2.25.1