From 95266ff25dd0be222e1838a439190317c60601d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carn=C3=AB=20Draug?= Date: Fri, 18 Sep 2015 01:39:38 +0100 Subject: Add configure check CheckProg, to check for existence of a program. --- src/engine/SCons/Conftest.py | 16 ++++++++++++++++ src/engine/SCons/SConf.py | 9 +++++++++ src/engine/SCons/SConfTests.py | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/src/engine/SCons/Conftest.py b/src/engine/SCons/Conftest.py index e9702ff..87a3022 100644 --- a/src/engine/SCons/Conftest.py +++ b/src/engine/SCons/Conftest.py @@ -684,6 +684,22 @@ return 0; return ret +def CheckProg(context, prog_name): + """ + Configure check for a specific program. + + Check whether program prog_name exists in path. If it is found, + returns the path for it, otherwise returns None. + """ + context.Display("Checking whether %s program exists..." % prog_name) + path = context.env.WhereIs(prog_name) + if path: + context.Display(path + "\n") + else: + context.Display("no\n") + return path + + # # END OF PUBLIC FUNCTIONS # diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 8bce8ce..987b8ea 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -444,6 +444,7 @@ class SConfBase(object): 'CheckCXXHeader' : CheckCXXHeader, 'CheckLib' : CheckLib, 'CheckLibWithHeader' : CheckLibWithHeader, + 'CheckProg' : CheckProg, } self.AddTests(default_tests) self.AddTests(custom_tests) @@ -1047,6 +1048,14 @@ def CheckLibWithHeader(context, libs, header, language, context.did_show_result = 1 return not res +def CheckProg(context, prog_name): + """Simple check if a program exists in the path. Returns the path + for the application, or None if not found. + """ + res = SCons.Conftest.CheckProg(context, prog_name) + context.did_show_result = 1 + return res + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index 233ee78..57a9d04 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -611,6 +611,24 @@ int main() { finally: sconf.Finish() + def test_CheckProg(self): + """Test SConf.CheckProg() + """ + self._resetSConfState() + sconf = self.SConf.SConf(self.scons_env, + conf_dir=self.test.workpath('config.tests'), + log_file=self.test.workpath('config.log')) + + try: + r = sconf.CheckProg('sh') + assert r, "/bin/sh" + r = sconf.CheckProg('hopefully-not-a-program') + assert r is None + + finally: + sconf.Finish() + + def test_Define(self): """Test SConf.Define() """ -- cgit v0.12 From 72d8407c28fc02cb986fa561c793e1b202e53867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carn=C3=AB=20Draug?= Date: Sat, 26 Sep 2015 19:01:04 +0100 Subject: Add new CheckProg configure method to documentation and list of changes. --- doc/scons.mod | 1 + doc/user/sconf.xml | 20 ++++++++++++++++++++ src/CHANGES.txt | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/doc/scons.mod b/doc/scons.mod index 72dc7ff..8d64054 100644 --- a/doc/scons.mod +++ b/doc/scons.mod @@ -276,6 +276,7 @@ CheckHeader"> CheckLib"> CheckLibWithHeader"> +CheckProg"> CheckType"> CheckTypeSize"> TryAction"> diff --git a/doc/user/sconf.xml b/doc/user/sconf.xml index 569ab1a..fe933f1 100644 --- a/doc/user/sconf.xml +++ b/doc/user/sconf.xml @@ -304,6 +304,26 @@ scons: `.' is up to date.
+ Checking for the Presence of a program + + + + Check for the presence of a program + by using the &CheckProg; method: + + + + +env = Environment() +conf = Configure(env) +if not conf.CheckProg('foobar'): + print 'Unable to find the program foobar on the system' + Exit(1) +env = conf.Finish() + + +
+
Adding Your Own Custom Checks diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 977d00f..3869621 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Memoizer counting uses decorators now, instead of the old metaclasses approach. + From Carnë Draug: + - Added new configure check, CheckProg, to check for + existence of a program. + RELEASE 2.3.6 - Mon, 31 Jul 2015 14:35:03 -0700 From Rob Smith: -- cgit v0.12