I’m trying to automate our build on Windows. Our requirement is to validate changes for the target platform combination: Windows + Visual Studio tools, so it’s no good using GCC or Clang for this. We specifically need to check compilation with Microsoft’s compiler, and indeed NMAKE.
So I’m trying to invoke CMD.EXE to run our make using Visual Studio tools. But I can’t seem to get a literal string through to CMD. Here is what I’m trying:
MSYS2_ARG_CONV_EXCL="*" cmd /k '"C:\Program Files (x86)\Microsoft Visual Studio 2017\BuildTools\Common7\Tools\VsDevCmd.bat" && cd code && nmake'
But what I get back is an error from CMD like:
'\"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat\"' is not recognized...
So you see something is inserting extra backslash escapes into the string I want to pass to CMD. This alone works:
MSYS2_ARG_CONV_EXCL="*" cmd /k 'C:\Program Files (x86)\Microsoft Visual Studio 2017\BuildTools\Common7\Tools\VsDevCmd.bat'
If any Travis CI folks read this: we want CMD (or maybe Powershell) and the Microsoft compilers to be first-class! We need to build using Visual Studio. Thanks!
@rem w3i6mv.bat -- set up and invoke build from raw CMD on Windows
@rem This can be invoked from a plain CMD from the MPS workspace
@rem like this::
@rem code\w3i6mv.bat
@rem or from Git Bash in Travis CI build machines like this::
@rem MSYS2_ARG_CONV_EXCL='*' cmd /k 'code\w3i6mv.bat'
@rem which is how it's invoked from .travis.yml
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
cd code
nmake /f w3i6mv.nmk
include:
- os: windows
arch: amd64
compiler: clang # This is a lie since we invoke MV (Microsoft C)
script: MSYS2_ARG_CONV_EXCL='*' cmd /c 'code\w3i6mv.bat'
So we have to lie to Travis CI about the toolchain, which is a shame, but this is only a few lines of extra stuff, so it keeps Travis integration lightweight, which is what we need.