summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--.appveyor.yml8
-rw-r--r--src/engine/SCons/Tool/swig.py12
-rw-r--r--test/SWIG/recursive-includes-cpp.py44
3 files changed, 49 insertions, 15 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index a735070..fe231d2 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -6,10 +6,10 @@ install:
- python --version
- pip install lxml
- pip install pypiwin32
- - choco install dmd
- - choco install ldc
- - choco install swig
- - choco install vswhere
+ - choco install --allow-empty-checksums dmd
+ - choco install --allow-empty-checksums ldc
+ - choco install --allow-empty-checksums swig
+ - choco install --allow-empty-checksums vswhere
environment:
matrix:
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index da4472f..08881a0 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -35,6 +35,7 @@ from __future__ import print_function
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os.path
+import sys
import re
import subprocess
@@ -169,6 +170,17 @@ def generate(env):
java_file.add_action('.i', SwigAction)
java_file.add_emitter('.i', _swigEmitter)
+ from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
+ from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+
+ if sys.platform == 'win32':
+ swig = SCons.Tool.find_program_path(env, 'swig', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS + [r'C:\ProgramData\chocolatey\bin'] )
+ if swig:
+ swig_bin_dir = os.path.dirname(swig)
+ env.AppendENVPath('PATH', swig_bin_dir)
+ else:
+ SCons.Warnings.Warning('swig tool requested, but binary not found in ENV PATH')
+
if 'SWIG' not in env:
env['SWIG'] = env.Detect(swigs) or swigs[0]
env['SWIGVERSION'] = _get_swig_version(env, env['SWIG'])
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 )