summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarnë Draug <carandraug+dev@gmail.com>2015-09-18 00:39:38 (GMT)
committerCarnë Draug <carandraug+dev@gmail.com>2015-09-18 00:39:38 (GMT)
commit95266ff25dd0be222e1838a439190317c60601d4 (patch)
tree534fba582c560f5bc9500fd479608e4fa0a2b8e4
parenta6a65ee80272d61fa2e09e33eeedfa0e08aed333 (diff)
downloadSCons-95266ff25dd0be222e1838a439190317c60601d4.zip
SCons-95266ff25dd0be222e1838a439190317c60601d4.tar.gz
SCons-95266ff25dd0be222e1838a439190317c60601d4.tar.bz2
Add configure check CheckProg, to check for existence of a program.
-rw-r--r--src/engine/SCons/Conftest.py16
-rw-r--r--src/engine/SCons/SConf.py9
-rw-r--r--src/engine/SCons/SConfTests.py18
3 files changed, 43 insertions, 0 deletions
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()
"""