From c299f365221f80e2325d391e9c15f4c1e2632486 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Wed, 27 Dec 2017 17:46:38 -0500 Subject: fixed swig tests to work on windows --- test/SWIG/SWIGPATH.py | 5 +++-- test/SWIG/implicit-dependencies.py | 5 +++-- test/SWIG/live.py | 11 ++++++++--- test/SWIG/recursive-includes-cpp.py | 6 +++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/test/SWIG/SWIGPATH.py b/test/SWIG/SWIGPATH.py index 55e8d7e..d516c0c 100644 --- a/test/SWIG/SWIGPATH.py +++ b/test/SWIG/SWIGPATH.py @@ -40,7 +40,8 @@ python = test.where_is('python') if not python: test,skip_test('Can not find installed "python", skipping test.\n') - +swig = swig.replace('\\','/') +python = python.replace('\\','/') test.subdir('inc1', 'inc2') test.write(['inc2', 'dependency.i'], """\ @@ -95,4 +96,4 @@ test.pass_test() # tab-width:4 # indent-tabs-mode:nil # End: -# vim: set expandtab tabstop=4 shiftwidth=4: +# vim: set expandtab tabstop=4 shiftwidth=4: \ No newline at end of file diff --git a/test/SWIG/implicit-dependencies.py b/test/SWIG/implicit-dependencies.py index 465a0d6..8664bf6 100644 --- a/test/SWIG/implicit-dependencies.py +++ b/test/SWIG/implicit-dependencies.py @@ -40,7 +40,8 @@ python = test.where_is('python') if not python: test.skip_test('Can not find installed "python", skipping test.\n') - +swig = swig.replace('\\','/') +python = python.replace('\\','/') test.write("dependency.i", """\ %module dependency """) @@ -75,4 +76,4 @@ test.pass_test() # tab-width:4 # indent-tabs-mode:nil # End: -# vim: set expandtab tabstop=4 shiftwidth=4: +# vim: set expandtab tabstop=4 shiftwidth=4: \ No newline at end of file diff --git a/test/SWIG/live.py b/test/SWIG/live.py index 05971aa..684cff1 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -48,9 +48,14 @@ if not swig: python, python_include, python_libpath, python_lib = \ test.get_platform_python_info() -Python_h = os.path.join(python_include, 'Python.h') +Python_h = python_include + '/Python.h' if not os.path.exists(Python_h): test.skip_test('Can not find %s, skipping test.\n' % Python_h) +swig = swig.replace('\\','/') +python = python.replace('\\','/') +python_include = python_include.replace('\\','/') +python_libpath = python_libpath.replace('\\','/') +python_lib = python_lib.replace('\\','/') # handle testing on other platforms: ldmodule_prefix = '_' @@ -142,7 +147,7 @@ test.up_to_date(arguments = ldmodule_prefix+'foo' + _dll) test.run(arguments = ldmodule_prefix+'bar' + _dll) -test.must_match('wrapper.out', "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py" + os.linesep) test.run(program = python, stdin = """\ from __future__ import print_function @@ -164,4 +169,4 @@ test.pass_test() # tab-width:4 # indent-tabs-mode:nil # End: -# vim: set expandtab tabstop=4 shiftwidth=4: +# vim: set expandtab tabstop=4 shiftwidth=4: \ No newline at end of file diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index dbcac6d..0baa195 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 @@ -37,6 +38,9 @@ DefaultEnvironment( tools = [ 'swig' ] ) test = TestSCons.TestSCons() +if sys.platform == 'win32': + test.skip_test('test not setup for windows, skipping test') + # Check for prerequisites of this test. for pre_req in ['swig', 'python']: if not test.where_is(pre_req): @@ -124,4 +128,4 @@ test.pass_test() # tab-width:4 # indent-tabs-mode:nil # End: -# vim: set expandtab tabstop=4 shiftwidth=4: +# vim: set expandtab tabstop=4 shiftwidth=4: \ No newline at end of file -- cgit v0.12 From 14083d5ab0b909eb8626fe8e94b47cfd598f45fc Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 09:50:56 -0500 Subject: pr-3052: updated swig test to work for windows. --- test/SWIG/recursive-includes-cpp.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 0baa195..e69b5b9 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -30,7 +30,6 @@ in cases of recursive inclusion. """ import os -import sys import TestSCons from SCons.Defaults import DefaultEnvironment @@ -38,9 +37,6 @@ DefaultEnvironment( tools = [ 'swig' ] ) test = TestSCons.TestSCons() -if sys.platform == 'win32': - test.skip_test('test not setup for windows, skipping test') - # Check for prerequisites of this test. for pre_req in ['swig', 'python']: if not test.where_is(pre_req): @@ -86,7 +82,7 @@ if sys.platform == 'darwin': env['LIBS']=['python%d.%d'%(sys.version_info[0],sys.version_info[1])] env.SharedLibrary( - 'mod.so', + 'mod', [ "mod.i", "main.c", -- cgit v0.12 From 0e5af237a0eff7c49fb354697f348e7f2b0e629e Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 15:07:11 -0500 Subject: pr-3052: Updated swig tool with some default paths and fixed test to build on windows. --- .appveyor.yml | 8 +++---- src/engine/SCons/Tool/swig.py | 12 ++++++++++ test/SWIG/recursive-includes-cpp.py | 44 +++++++++++++++++++++++++++---------- 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 ) -- cgit v0.12 From b20299cf0bbc8b7073838c225d68909d6f021fab Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 15:16:10 -0500 Subject: pr-3052: added a missing comma to the environment args --- test/SWIG/recursive-includes-cpp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 2767c4b..2f2cff2 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -80,7 +80,7 @@ import sys import os env = Environment( - TARGET_ARCH = '""" + TARGET_ARCH +"""' + TARGET_ARCH = '""" + TARGET_ARCH +"""', SWIGFLAGS = [ '-python' ], -- cgit v0.12 From 0f83c3918a0acf84588902c6c3d3f28e764edb56 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 15:20:02 -0500 Subject: pr-3052: removed debug print statements --- test/SWIG/recursive-includes-cpp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 2f2cff2..2494c45 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -126,14 +126,14 @@ expectMod = """\ # Validate that the recursive dependencies are found with SWIG scanning first. 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'+object_suffix +' mod_wrap'+object_suffix) -print(test.stdout()) + test.must_contain_all( test.stdout(), expectMain ) test.must_contain_all( test.stdout(), expectMod ) -- cgit v0.12 From cd53a8f8f59ac6d0400d21044c09c50e92792927 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 15:25:08 -0500 Subject: pr-3052: made target arch transparent to non windows platforms --- test/SWIG/recursive-includes-cpp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 2494c45..738b6c1 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -70,9 +70,9 @@ test.write("mod.i", """\ if sys.platform == 'win32': if(sys.maxsize > 2**32): - TARGET_ARCH = 'x86_64' + TARGET_ARCH = "TARGET_ARCH = 'x86_64'," else: - TARGET_ARCH = 'x86' + TARGET_ARCH = "TARGET_ARCH = 'x86'," test.write('SConstruct', """\ import distutils.sysconfig @@ -80,7 +80,7 @@ import sys import os env = Environment( - TARGET_ARCH = '""" + TARGET_ARCH +"""', + """ + TARGET_ARCH + """ SWIGFLAGS = [ '-python' ], -- cgit v0.12 From d1ad2461b0c9f8a9a19f7509b8334d46bf9f3391 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 15:26:39 -0500 Subject: pr-3052: Needed to define target arch in the non-windows case --- test/SWIG/recursive-includes-cpp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 738b6c1..8fbe7c0 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -68,12 +68,14 @@ test.write("mod.i", """\ #include "main.h" """) + if sys.platform == 'win32': if(sys.maxsize > 2**32): TARGET_ARCH = "TARGET_ARCH = 'x86_64'," else: TARGET_ARCH = "TARGET_ARCH = 'x86'," - +else: + TARGET_ARCH = "" test.write('SConstruct', """\ import distutils.sysconfig import sys -- cgit v0.12 From 2cfbdb0e6ce2d1856c3700f4317a6b2242b36851 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 15:28:23 -0500 Subject: pr-3052: added changes to CHANGES.txt --- src/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index c108378..17ca170 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -19,6 +19,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - Fixed handling of side-effects in task master (fixes #3013). From Daniel Moody: + - Updated swig to setup default paths for windows - Updated gettext tools to setup default paths for windows with Cygwin/MinGW setups - Add common location for default paths for cygwin and mingw in Platform modules - Updated YACC tool to work on windows with Cygwin/MinGW setups -- cgit v0.12 From df543ac63394c2dffd50264d188fa3a237f69bc8 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 25 May 2018 17:06:08 -0500 Subject: pr-3052: moved some 64 bit logic to TestCmd and used TestCmd system checks --- test/SWIG/recursive-includes-cpp.py | 5 +++-- testing/framework/TestCmd.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 8fbe7c0..2c74cc8 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -32,6 +32,7 @@ in cases of recursive inclusion. import os import sys import TestSCons +import TestCmd from SCons.Defaults import DefaultEnvironment DefaultEnvironment( tools = [ 'swig' ] ) @@ -69,8 +70,8 @@ test.write("mod.i", """\ """) -if sys.platform == 'win32': - if(sys.maxsize > 2**32): +if TestCmd.IS_WINDOWS: + if TestCmd.IS_64_BIT: TARGET_ARCH = "TARGET_ARCH = 'x86_64'," else: TARGET_ARCH = "TARGET_ARCH = 'x86'," diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 0aab9a8..9cd6b39 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -309,7 +309,7 @@ import types IS_PY3 = sys.version_info[0] == 3 IS_WINDOWS = sys.platform == 'win32' - +IS_64_BIT = sys.maxsize > 2**32 class null(object): pass -- cgit v0.12