From: stevenknight Date: Thu, 14 Aug 2003 13:57:25 +0000 (+0000) Subject: More portability fixes. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=79184393058e42ef2a6852b3e661de23751496b1;p=scons.git More portability fixes. git-svn-id: http://scons.tigris.org/svn/scons/trunk@766 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/test/SWIG.py b/test/SWIG.py index 74e73c49..d36c77e8 100644 --- a/test/SWIG.py +++ b/test/SWIG.py @@ -32,6 +32,7 @@ import TestSCons python = TestSCons.python _exe = TestSCons._exe _obj = TestSCons._obj +_dll = TestSCons._dll test = TestSCons.TestSCons() @@ -60,7 +61,7 @@ env.Copy(SWIGFLAGS = '-c++').Program(target = 'test3', source = 'test3.i') """ % (python)) test.write('test1.i', r""" -void +int main(int argc, char *argv[]) { argv[argc++] = "--"; printf("test1.i\n"); @@ -76,7 +77,7 @@ swig test.write('test3.i', r""" #include #include -void +int main(int argc, char *argv[]) { argv[argc++] = "--"; printf("test3.i\n"); @@ -103,6 +104,8 @@ swig = test.where_is('swig') if swig: + version = string.join(string.split(sys.version, '.')[:2], '.') + test.write("wrapper.py", """import os import string @@ -113,65 +116,79 @@ os.system(string.join(sys.argv[1:], " ")) test.write('SConstruct', """ foo = Environment(SWIGFLAGS='-python', - CPPPATH='/usr/include/python1.5/', + CPPPATH='/usr/include/python%s/', SHCCFLAGS='', SHOBJSUFFIX='.o', SHLIBPREFIX='') swig = foo.Dictionary('SWIG') -#bar = Environment(SWIG = r'%s wrapper.py ' + swig) -foo.SharedLibrary(target = 'example', source = ['example.c', 'example.i']) -#foo.SharedLibrary(target = 'foo', source = ['example.c']) -#foo.SharedLibrary(target = 'foo', source = ['example.i']) -#bar.SharedLibrary(target = 'bar', source = 'example.i') -""" % python) - - # Simple example.c and example.i stolen from the SWIG tutorial. - test.write("example.c", """\ -#include -double My_variable = 3.0; - -int fact(int n) { - if (n <= 1) return 1; - else return n*fact(n-1); +bar = foo.Copy(SWIG = r'%s wrapper.py ' + swig) +foo.SharedLibrary(target = 'foo', source = ['foo.c', 'foo.i']) +bar.SharedLibrary(target = 'bar', source = ['bar.c', 'bar.i']) +""" % (version, python)) + + test.write("foo.c", """\ +char * +foo_string() +{ + return "This is foo.c!"; } +""") -int my_mod(int x, int y) { - return (x%y); -} - -char *get_time() + test.write("foo.i", """\ +%module foo +%{ +/* Put header files here (optional) */ +%} + +extern char *foo_string(); +""") + + test.write("bar.c", """\ +char * +bar_string() { - return "Tue Aug 12 23:32:15 2003"; + return "This is bar.c!"; } """) - test.write("example.i", """\ -%module example + test.write("bar.i", """\ +%module bar %{ /* Put header files here (optional) */ %} -extern double My_variable; -extern int fact(int n); -extern int my_mod(int x, int y); -extern char *get_time(); +extern char *bar_string(); """) - test.run(arguments = '.') + test.run(arguments = 'foo' + _dll) - test.up_to_date(arguments = '.') + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.run(program = python, stdin = """\ +import foo +print foo.foo_string() +""", stdout="""\ +This is foo.c! +""") + + test.up_to_date(arguments = 'foo' + _dll) + + test.run(arguments = 'bar' + _dll) + + test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.run(program = python, stdin = """\ -import example -print example.fact(5) -print example.my_mod(7, 3) -print example.get_time() +import foo +import bar +print foo.foo_string() +print bar.bar_string() """, stdout="""\ -120 -1 -Tue Aug 12 23:32:15 2003 +This is foo.c! +This is bar.c! """) + test.up_to_date(arguments = '.') + test.pass_test() diff --git a/test/scan-once.py b/test/scan-once.py index ea4dbee0..8a468b4d 100644 --- a/test/scan-once.py +++ b/test/scan-once.py @@ -303,10 +303,14 @@ import re for k in fromdict.keys(): if k != "ENV" and k != "SCANNERS" and k != "CFLAGS" and k != "CXXFLAGS" \ and not SCons.Util.is_Dict(fromdict[k]): - # the next line fails in Cygwin because it tries to do env.subst on - # $RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} ... - # when $TARGET is None, so $TARGET.attributes throws an exception - todict[k] = env.subst(str(fromdict[k])) + # The next line can fail on some systems because it would try to + # do env.subst on: + # $RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} ... + # When $TARGET is None, so $TARGET.attributes would throw an + # exception. + f = fromdict[k] + if SCons.Util.is_String(f) and string.find(f, "TARGET") == -1: + todict[k] = env.subst(f) todict["CFLAGS"] = fromdict["CPPFLAGS"] + " " + \ string.join(map(lambda x: "-I" + x, env["CPPPATH"])) + " " + \ string.join(map(lambda x: "-L" + x, env["LIBPATH"]))