X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=site_scons%2Fsite_tools%2FCustomTests.py;h=6128ea6c65ea51581fc3314efb4a143828f46083;hb=1434d9ffc860a7b90da5b00d90a094f4ef20fab4;hp=e482f800fd033fb639ec5b49506fa31c4b01d1d2;hpb=c29d34d85b7066dcfe96dfd70fc893d803691958;p=senf.git diff --git a/site_scons/site_tools/CustomTests.py b/site_scons/site_tools/CustomTests.py index e482f80..6128ea6 100644 --- a/site_scons/site_tools/CustomTests.py +++ b/site_scons/site_tools/CustomTests.py @@ -1,5 +1,5 @@ import SCons.Environment, SCons.Util, SCons.Script, SCons.Conftest -import re +import re, os.path # Fix for SCons 0.97 compatibility import SCons.SConf @@ -140,14 +140,17 @@ def CheckSymbolWithExpression(context, symbol, expression, header="", language=" @DefaultTest def CheckByteorder(context): context.Message("Checking byteorder... ") - ret = context.TryRun('#include \n' - 'union byteorder_test { int i; char b; };\n' - 'int main() {\n' - ' union byteorder_test t; t.i=1;\n' - ' printf(t.b ? "little\\n" : "big\\n");\n' - ' return 0;\n' - '}\n', - ".c")[-1].strip() + if context.env.has_key("BYTEORDER"): + ret = context.env["BYTEORDER"] + else: + ret = context.TryRun('#include \n' + 'union byteorder_test { int i; char b; };\n' + 'int main() {\n' + ' union byteorder_test t; t.i=1;\n' + ' printf(t.b ? "little\\n" : "big\\n");\n' + ' return 0;\n' + '}\n', + ".c")[-1].strip() if not ret: context.Result("failed") return False @@ -157,6 +160,23 @@ def CheckByteorder(context): "Define BYTEORDER_LITTLE_ENDIAN or BYTEORDER_BIG_ENDIAN") return ret +@DefaultTest +def FindCHeader(context, name, dirs): + defn = name.upper() + defn = re.sub('[^A-Z0-9_]', '_', defn) + defn += "_PATH" + + context.Message("Checking for %s... " % name) + for dir in dirs: + path = os.path.join(dir, name); + ret = context.TryCompile("#include <%s>" % path, ".c"); + if ret: + context.Result(path) + context.sconf.Define(defn, "<%s>" % path, + "Define %s as " % (defn, name)) + return ret + return False + def generate(env): env.Append( CUSTOM_TESTS = DefaultTest.tests ) env._CustomTests_orig_Configure = env.Configure