summaryrefslogtreecommitdiffstats
path: root/test/SWIG
diff options
context:
space:
mode:
authorDaniel Moody <dmoody256@gmail.com>2018-05-25 20:07:11 (GMT)
committerDaniel Moody <dmoody256@gmail.com>2018-05-25 20:07:11 (GMT)
commit0e5af237a0eff7c49fb354697f348e7f2b0e629e (patch)
treef928e8b997168fc11b1e98f7cfc659be18ce1127 /test/SWIG
parent14083d5ab0b909eb8626fe8e94b47cfd598f45fc (diff)
downloadSCons-0e5af237a0eff7c49fb354697f348e7f2b0e629e.zip
SCons-0e5af237a0eff7c49fb354697f348e7f2b0e629e.tar.gz
SCons-0e5af237a0eff7c49fb354697f348e7f2b0e629e.tar.bz2
pr-3052: Updated swig tool with some default paths and fixed test to build on windows.
Diffstat (limited to 'test/SWIG')
-rw-r--r--test/SWIG/recursive-includes-cpp.py44
1 files changed, 33 insertions, 11 deletions
diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py
index e69b5b9..2767c4b 100644
--- a/test/SWIG/recursive-includes-cpp.py
+++ b/test/SWIG/recursive-includes-cpp.py
@@ -30,6 +30,7 @@ in cases of recursive inclusion.
"""
import os
+import sys
import TestSCons
from SCons.Defaults import DefaultEnvironment
@@ -42,6 +43,11 @@ for pre_req in ['swig', 'python']:
if not test.where_is(pre_req):
test.skip_test('Can not find installed "' + pre_req + '", skipping test.%s' % os.linesep)
+if sys.platform == 'win32':
+ python_lib = os.path.dirname(sys.executable) + "/libs/" + ('python%d%d'%(sys.version_info[0],sys.version_info[1])) + '.lib'
+ if( not os.path.isfile(python_lib)):
+ test.skip_test('Can not find python lib at "' + python_lib + '", skipping test.%s' % os.linesep)
+
test.write("recursive.h", """\
/* An empty header file. */
""")
@@ -62,24 +68,34 @@ test.write("mod.i", """\
#include "main.h"
""")
+if sys.platform == 'win32':
+ if(sys.maxsize > 2**32):
+ TARGET_ARCH = 'x86_64'
+ else:
+ TARGET_ARCH = 'x86'
+
test.write('SConstruct', """\
import distutils.sysconfig
import sys
-
-DefaultEnvironment( tools = [ 'swig' ] )
+import os
env = Environment(
+ TARGET_ARCH = '""" + TARGET_ARCH +"""'
SWIGFLAGS = [
'-python'
],
CPPPATH = [
distutils.sysconfig.get_python_inc()
],
- SHLIBPREFIX = ""
+ SHLIBPREFIX = "",
+ tools = [ 'default', 'swig' ]
)
if sys.platform == 'darwin':
env['LIBS']=['python%d.%d'%(sys.version_info[0],sys.version_info[1])]
+elif sys.platform == 'win32':
+ env.Append(LIBS=['python%d%d'%(sys.version_info[0],sys.version_info[1])])
+ env.Append(LIBPATH=[os.path.dirname(sys.executable) + "/libs"])
env.SharedLibrary(
'mod',
@@ -90,28 +106,34 @@ env.SharedLibrary(
)
""")
+if sys.platform == 'win32':
+ object_suffix = ".obj"
+else:
+ object_suffix = ".os"
+
expectMain = """\
-+-main.os
++-main%s
+-main.c
+-main.h
- +-recursive.h"""
+ +-recursive.h""" % object_suffix
expectMod = """\
-+-mod_wrap.os
++-mod_wrap%s
+-mod_wrap.c
| +-mod.i
| +-main.h
- | +-recursive.h"""
+ | +-recursive.h""" % object_suffix
# Validate that the recursive dependencies are found with SWIG scanning first.
-test.run( arguments = '--tree=all mod_wrap.os main.os' )
-
+test.run( arguments = '--tree=all mod_wrap'+object_suffix +' main'+object_suffix)
+print(test.stdout())
test.must_contain_all( test.stdout(), expectMain )
test.must_contain_all( test.stdout(), expectMod )
-# Validate that the recursive dependencies are found consistently.
-test.run( arguments = '--tree=all main.os mod_wrap.os' )
+# Validate that the recursive dependencies are found consistently.
+test.run( arguments = '--tree=all main'+object_suffix +' mod_wrap'+object_suffix)
+print(test.stdout())
test.must_contain_all( test.stdout(), expectMain )
test.must_contain_all( test.stdout(), expectMod )