swig/swig — pull request #141 by marvingreenberg (2014-02-21 20:59:44+00:00)
Title: Msvc patches

These patches work for me to build swig and the test suite using msvc (cl.exe). I've used VS2012 32 bit and VS2010 64 bit windows (I didn't try all the combinations yet), and I've only run the CSHARP test suite so far, since that was my main goal (testing csharp changes I'm making on the "real" C#/.Net environment). I imagine other test suites will work or fail to differing degrees, but this should be a significant step in supporting Windows development (better?). I built without pcre to prevent needing to building native pcre, although I came close to getting a native build of pcre.

I had earlier tried getting mingw/cygwin builds as described at swig.org, unsuccessfully. In any case, that was not what I wanted since I wanted to actually build using cl/csc. This (to me) is simpler than getting (some old version) mingw installed and configured, if you have the MS compiler. I assume you could also use Visual Studio express but did not try that.

Right now the whole csharp test suite passes on VS2010 W7 x64, except for tests needing the disabled pcre. Interestingly there is a test failure on VS2010 W7 x86, li_std_auto_ptr. System.Exception,: number of objects should be 1. I haven't looked at that.

Here are my instructions to use this patch:

Install cygwin, with automake, autoconf, git, make, byacc, bison. I
initially also installed cygwin gcc/g++ toolchains, which allows
building swig with gcc, and then reconfiguring to run/build the tests
using cl (msvc) (and csc for .Net). But the patch now works to build
swig itself.

Install a boost distribution, just unzip. I installed boost without building
anything - Swig only needs headers, thankfully. There is a twist -
autotools 'compile' changes all -I includes to be -I/include,
so you need to unzip it and then move ./boost to ./include/boost. Suggestions?

Source the environment for MSVC toolchain using provided scripts.
Alternatively use visual studio vcvars.bat script somehow before
starting cygwin. I added scripts under Win/ that seem to work.

$ . Win/env-vs2010-64.sh

Configure swig to build and run tests using native MS tool chain
It may be possible to configure/build pcre natively. I came close.

$ ./autogen.sh; ./configure CC='cl' CXX='cl' --with-boost=c:/boost_1_55_0 --without-pcre
$ make && make install

Run some tests, or run a single tests showing commands

$ make check-csharp-test-suite
$ make check-csharp-test-suite FLAGS= CPP_TEST_CASES=li_std_auto_ptr \
> C_TEST_CASES= MULTI_CPP_TEST_CASES=