瀏覽代碼

add support for building using MSVC 2008-2013

Ashish Kulkarni 11 年之前
父節點
當前提交
0f43cd77ac
共有 2 個文件被更改,包括 58 次插入2 次删除
  1. 2 2
      INSTALL.md
  2. 56 0
      scripts/build.py

+ 2 - 2
INSTALL.md

@@ -16,14 +16,14 @@ Building is currently supported only on the current 64-bit Debian stable release
 Prerequisites: Windows
 ----------------------
 
-* Install MSVC 2010: see http://qt-project.org/wiki/Category:Tools::msvc
+* Install Visual Studio ([2013 Express](http://www.microsoft.com/en-US/download/details.aspx?id=40787) is recommended) or follow instructions for [Windows SDK 7.1](http://qt-project.org/wiki/Category:Tools::msvc)
 * Do "Windows Update" to ensure that VC/SDK security patches are up-to-date
 * Install latest ActivePerl from http://www.activestate.com/activeperl/downloads
 * Install latest Python 2.7 from http://www.python.org/downloads/windows/
 * Install NSIS 2.46 from http://nsis.sourceforge.net/Download
 * Make sure that you can run "git". If not, add it to the PATH or reinstall
   with option "Run Git from the Windows Command Prompt".
-* Start "Windows SDK 7.1 Command Prompt" for "Windows Server 2008 Release".
+* **Skip this step if you are using Visual Studio**. If you are using Windows SDK 7.1, then start "Windows SDK 7.1 Command Prompt" for "Windows Server 2008 Release".
   A 32-bit environment is available by running (all on one line)
 
       %WINDIR%\System32\cmd.exe /E:ON /V:ON /T:0E /K "%ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /2008 /Release /x86

+ 56 - 0
scripts/build.py

@@ -155,6 +155,14 @@ QT_CONFIG = {
 }
 
 BUILDERS = {
+    'msvc2008-win32':        'msvc',
+    'msvc2008-win64':        'msvc',
+    'msvc2010-win32':        'msvc',
+    'msvc2010-win64':        'msvc',
+    'msvc2012-win32':        'msvc',
+    'msvc2012-win64':        'msvc',
+    'msvc2013-win32':        'msvc',
+    'msvc2013-win64':        'msvc',
     'msvc-winsdk71-win32':   'msvc_winsdk71',
     'msvc-winsdk71-win64':   'msvc_winsdk71',
     'centos5-i386':          'linux_schroot',
@@ -239,6 +247,54 @@ def build_openssl(config, basedir):
 
     return OPENSSL['build'][cfg]['os_libs']
 
+# --------------------------------------------------------------- MSVC (2008-2013)
+
+MSVC_LOCATION = {
+    'msvc2008': 'VS90COMNTOOLS',
+    'msvc2010': 'VS100COMNTOOLS',
+    'msvc2012': 'VS110COMNTOOLS',
+    'msvc2013': 'VS120COMNTOOLS'
+}
+
+def check_msvc(config):
+    version, arch = config.split('-')
+    env_var = MSVC_LOCATION[version]
+    if not env_var in os.environ:
+        error("%s does not seem to be installed." % version)
+
+    vcdir = os.path.join(os.environ[env_var], '..', '..', 'VC')
+    if not exists(os.path.join(vcdir, 'vcvarsall.bat')):
+        error("%s: unable to find vcvarsall.bat" % version)
+
+    if arch == 'win32' and not exists(os.path.join(vcdir, 'bin', 'cl.exe')):
+        error("%s: unable to find the x86 compiler" % version)
+
+    if arch == 'win64' and not exists(os.path.join(vcdir, 'amd64', 'bin', 'cl.exe')) \
+                       and not exists(os.path.join(vcdir, 'x86_amd64', 'bin', 'cl.exe')):
+        error("%s: unable to find the amd64 compiler" % version)
+
+def build_msvc(config, basedir):
+    msvc, arch = config.split('-')
+    vcdir = os.path.join(os.environ[MSVC_LOCATION[msvc]], '..', '..', 'VC')
+    vcarg = 'x86'
+    if arch == 'win64':
+        if exists(os.path.join(vcdir, 'amd64', 'bin', 'cl.exe')):
+            vcarg = 'amd64'
+        else:
+            vcarg = 'x86_amd64'
+
+    python = sys.executable
+    process = subprocess.Popen('("%s" %s>nul)&&"%s" -c "import os; print repr(os.environ)"' % (
+        os.path.join(vcdir, 'vcvarsall.bat'), vcarg, python), stdout=subprocess.PIPE, shell=True)
+    stdout, _ = process.communicate()
+    exitcode = process.wait()
+    if exitcode != 0:
+        error("%s: unable to initialize the environment" % msvc)
+
+    os.environ.update(eval(stdout.strip()))
+
+    build_msvc_winsdk71(config, basedir)
+
 # --------------------------------------------------------------- MSVC via Windows SDK 7.1
 
 def check_msvc_winsdk71(config):