[PATCH 2/6] build: Add "find-optional-program" action

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Feb 27 15:15:19 UTC 2024


Update #4272.
---
 wscript | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/wscript b/wscript
index 6c81083b2c..e43ae8ba3e 100755
--- a/wscript
+++ b/wscript
@@ -976,6 +976,17 @@ class OptionItem(Item):
     def _find_program(self, conf, cic, value, arg):
         return conf.find_program(value, path_list=cic.path_list)
 
+    def _find_optional_program(self, conf, cic, value, arg):
+        from waflib.Errors import ConfigurationError
+        try:
+            program = conf.find_program(value, path_list=cic.path_list)
+        except ConfigurationError:
+            return None
+        else:
+            name = self.data["name"] if arg is None else arg
+            conf.env.append_value("ENABLE", "HAVE_" + name)
+            return program
+
     def _format_and_define(self, conf, cic, value, arg):
         name = self.data["name"] if arg is None else arg
         if value is not None:
@@ -1107,6 +1118,7 @@ class OptionItem(Item):
             "env-assign": self._env_assign,
             "env-enable": self._env_enable,
             "find-program": self._find_program,
+            "find-optional-program": self._find_optional_program,
             "format-and-define": self._format_and_define,
             "get-boolean": self._get_boolean,
             "get-env": self._get_env,
-- 
2.35.3



More information about the devel mailing list