Source code for gdeps.visual

#!python3

# Copyright 2007-2017 Gemr. All Rights Reserved.
# Licensed to MIT see LICENSE.txt

import os
import warnings
import gdeps as GDeps

__author__ = 'Suryavarman (http://sourceforge.net/u/suryavarman/profile/)'


[docs]class Visual2008(GDeps.Ide): def __init__(self, inConfigFile, inSectionName, inCompilers, inCompilersAlias=[]): GDeps.Ide.__init__(self, inConfigFile, inSectionName, Visual2008.getTypeName(), inCompilers, inCompilersAlias) self.m_ErrorRegexp = r"(.*: error.*|Error:.*|.*incorrect.*|.*invalid.*)" self.m_WarningRegexp = r".*: warning.*"
[docs] def getMachineFlag(self, inCompiler): return "Win32" if inCompiler.getAdressModel() == GDeps.AdressModel.x86 else "Win64"
[docs] def build(self, inProjectPath, inProjectName, inCompiler, inTargetName="Release", inLogFilePath=".\\Output_Buid_Visual2008.log", inWildCard="sln", inRebuildAll=True, inIdeParams={}, inCompilerArgs={}): """ Default directory : C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages Microsoft (R) Visual C++ Project Builder - Command Line Version 9.00.30729 Copyright (C) Microsoft Corporation. All rights reserved. Usage: vcbuild [options] [project|solution] [config|$ALL] Options: /clean (/c) Clean build outputs only /error:<str> Prefix to add to error lines on output to stderr /errfile:<file> Log all errors to the file specified /htmllog:<file> Logs output to html file specified (default: $(IntDir)\BuildLog.htm) /implib Makes an import library for a DLL configuration (does not link) /info:<str> Prefix to add to information lines on output to stdout /link (/l) Performs a link without building sources /logcommands Prints commands and response files to screen /logfile:<file> Log all output and build information to the file specified /override:<file>Override the project settings with the settings in the given property sheet file /M<number> Specifies the number of concurrent builds to run, if possible /msbuild:<opt> Pass <opt> to msbuild.exe /nocolor Do not output error and warning messages in color /nohtmllog Do not write an html build log file /noimplib Does not generate an import library. NOTE: this option overrides /implib. /nologo Suppress version and copyright message /nondefmsbuild Do not use the copy of msbuild.exe located in the .NET Frameworks installation /platform:<str> Build only configurations for the given platform /implibobjs:<s> Additional dependencies for the librarian /rebuild (/r) Clean build outputs and perform a build /forcelink Forces a link without building sources /showenv Show environment in the html build log /time Times the build from start to finish /upgrade Upgrades the project file to the latest format supported NOTE: the upgrade switch does not perform a build NOTE: this option is ignored for solution files /useenv (/u) Use environment variables for INCLUDE and LIB paths /overrideRefVer When upgrading, assume .NET Framework Version 3.5 for any assemb ly references. Requires /upgrade switch. /wrnfile:<file> Log all warnings to the file specified /warning:<str> Prefix to add to warning lines on output to stdout @<file> Read options from the specified response file Default Behavior: =============================================================================== If no project is specified, and there is only a single .vcproj file in the directory, that project will be built. If no configuration is specified, and the VCBUILD_DEFAULT_CFG environment variable is set, the configuration it specifies will be built. If it is not set, then all configurations will be built. The default action is to build the specified configurations without cleaning. Options will also be read from the VCBUILD_DEFAULT_OPTIONS environment variable. =============================================================================== For the target with the sln we need to add https://stackoverflow.com/questions/22668149/qprocess-with-non-wrapped-pipe-symbol-in-argument-list inTargetName + "^|Win32" https://msdn.microsoft.com/fr-fr/library/kdxzbw9t(v=vs.90).aspx $ALL Nom symbolique qui signifie que toutes les configurations sont générées. https://msdn.microsoft.com/fr-fr/library/cz553aa1(v=vs.90).aspx """ # GDeps.call('"' + self.m_Dir + "\\vcbuild.exe" + '" "' + inProjectPath + inProjectName + "." + inWildCard + '" ' + "/rebuild " + inTargetName + "^|" + self.getMachineFlag(inCompiler) + " /logcommands /logfile:" + '"' + inLogFilePath + '"') aBatFilePath = os.path.normpath(inProjectPath + r'\\Gdeps_' + inTargetName + '_' + inCompiler.m_TypeName + '_bakefile.bat') if os.path.exists(aBatFilePath): if not os.path.isfile(aBatFilePath): warnings.warn('The path ' + aBatFilePath + 'already exist and is a directory') GDeps.rmdir(aBatFilePath, inLogFilePath) aProjectPath = os.path.normpath(inProjectPath) print(aProjectPath) aSolutionPath = os.path.normpath(aProjectPath + r'\\' + inProjectName + "." + inWildCard) aBuildCmd = "/rebuild " if inRebuildAll else "/build " aLogFilePath = os.path.normpath(inLogFilePath) with open(aBatFilePath, 'w') as aBat: aBat.write('"' + os.path.normpath(self.m_Dir + r"\\vcbuild.exe") + '" "' + aSolutionPath + '" ' + aBuildCmd + inTargetName + "^|" + self.getMachineFlag(inCompiler) + " /logcommands /logfile:" + '"' + aLogFilePath + '"') aBat.write(os.linesep) GDeps.callWithLogFile(aBatFilePath, inLogFilePath=aLogFilePath, inOverwriteLog=True, inEnv=os.environ.copy()) assert os.path.exists(aLogFilePath), 'The path ' + aLogFilePath + " doesn't exist!"
@staticmethod
[docs] def getTypeName(): return "Visual2008"
[docs]class Visual2010(GDeps.Ide): def __init__(self, inConfigFile, inSectionName, inCompilers, inCompilersAlias=[]): GDeps.Ide.__init__(self, inConfigFile, inSectionName, Visual2010.getTypeName(), inCompilers, inCompilersAlias) self.m_ErrorRegexp = r"(.*>.*: error.*|.*>.*: Solution file error.*)" self.m_WarningRegexp = r".*>.*: warning.*"
[docs] def getMachineFlag(self, inCompiler): return "/machine:X86" if inCompiler.getAdressModel() == GDeps.AdressModel.x86 else "/machine:x64"
[docs] def build(self, inProjectPath, inProjectName, inCompiler, inTargetName="Release", inLogFilePath=".\\Output_Buid_Visual2010.log", inWildCard="sln", inRebuildAll=True, inIdeParams={}, inCompilerArgs={}): GDeps.call('"' + os.path.normpath(self.m_Dir) + "\\MSBuild.exe" + '" "' + os.path.normpath(inProjectPath) + "\\" + inProjectName + "." + inWildCard + '" ' + "/t:Rebuild /p:Configuration=" + inTargetName + ' /noconlog /flp:Summary;Verbosity=normal;LogFile="' + os.path.normpath(inLogFilePath) + '"; /p:VisualStudioVersion=10.0 /m')
@staticmethod
[docs] def getTypeName(): return "Visual2010"
[docs]class Visual2012(GDeps.Ide): def __init__(self, inConfigFile, inSectionName, inCompilers, inCompilersAlias=[]): GDeps.Ide.__init__(self, inConfigFile, inSectionName, Visual2012.getTypeName(), inCompilers, inCompilersAlias) self.m_ErrorRegexp = r"(.*>.*: error.*|.*>.*: Solution file error.*)" self.m_WarningRegexp = r".*>.*: warning.*"
[docs] def getMachineFlag(self, inCompiler): return "/machine:X86" if inCompiler.getAdressModel() == GDeps.AdressModel.x86 else "/machine:x64"
r""" %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"" x86_amd64 %comspec% /k ""%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"" x86 https://social.msdn.microsoft.com/Forums/en-US/51e5ba40-e250-4728-a727-35e0736280f5/msbuild-vs-tfsbuild?forum=tfsgeneral https://social.msdn.microsoft.com/Forums/en-US/09e51771-c6dd-4049-a73c-622aa3e6b67d/specified-platform-toolset-v110-is-not-installed-or-invalid?forum=TFService """
[docs] def build(self, inProjectPath, inProjectName, inCompiler, inTargetName="Release", inLogFilePath=".\\Output_Buid_Visual2012.log", inWildCard="sln", inRebuildAll=True, inIdeParams={}, inCompilerArgs={}): GDeps.call('"' + os.path.normpath(self.m_Dir) + "\\MSBuild.exe" + '" "' + os.path.normpath(inProjectPath) + "\\" + inProjectName + "." + inWildCard + '" ' + "/t:Rebuild /p:Configuration=" + inTargetName + ' /noconlog /flp:Summary;Verbosity=normal;LogFile="' + os.path.normpath(inLogFilePath) + '"; /p:VisualStudioVersion=11.0 /m')
@staticmethod
[docs] def getTypeName(): return "Visual2012"
[docs]class Visual2013(GDeps.Ide): def __init__(self, inConfigFile, inSectionName, inCompilers, inCompilersAlias=[]): GDeps.Ide.__init__(self, inConfigFile, inSectionName, Visual2013.getTypeName(), inCompilers, inCompilersAlias) self.m_ErrorRegexp = r"(.*>.*: error.*|.*>.*: Solution file error.*)" self.m_WarningRegexp = r".*>.*: warning.*"
[docs] def getMachineFlag(self, inCompiler): return "/machine:X86" if inCompiler.getAdressModel() == GDeps.AdressModel.x86 else "/machine:x64"
[docs] def build(self, inProjectPath, inProjectName, inCompiler, inTargetName="Release", inLogFilePath="Output_Buid_Visual2013.log", inWildCard="sln", inRebuildAll=True, inIdeParams={}, inCompilerArgs={}): GDeps.call('"' + os.path.normpath(self.m_Dir) + "\\MSBuild.exe" + '" "' + os.path.normpath(inProjectPath) + "\\" + inProjectName + "." + inWildCard + '" ' + "/t:Rebuild /p:Configuration=" + inTargetName + ' /noconlog /flp:Summary;Verbosity=normal;LogFile="' + os.path.normpath(inLogFilePath) + '"; /m')
@staticmethod
[docs] def getTypeName(): return "Visual2013"
[docs]class Visual2015(GDeps.Ide): def __init__(self, inConfigFile, inSectionName, inCompilers, inCompilersAlias=[]): GDeps.Ide.__init__(self, inConfigFile, inSectionName, Visual2015.getTypeName(), inCompilers, inCompilersAlias) self.m_ErrorRegexp = r"(.*>.*: error.*|.*>.*: Solution file error.*)" self.m_WarningRegexp = r".*>.*: warning.*"
[docs] def getMachineFlag(self, inCompiler): return "/machine:X86" if inCompiler.getAdressModel() == GDeps.AdressModel.x86 else "/machine:x64"
[docs] def build( self, inProjectPath, inProjectName, inCompiler, inTargetName="Release", inLogFilePath="Output_Buid_Visual2015.log", inWildCard="sln", inRebuildAll=True, inIdeParams={}, inCompilerArgs={}): """ https://msdn.microsoft.com/en-us/library/ms164311%28v=vs.140%29.aspx """ GDeps.call('"' + os.path.normpath(self.m_Dir) + "\\MSBuild.exe" + '" "' + os.path.normpath(inProjectPath) + "\\" + inProjectName + "." + inWildCard + '" ' + "/t:Rebuild /p:Configuration=" + inTargetName + ' /noconlog /flp:Summary;Verbosity=normal;LogFile="' + os.path.normpath(inLogFilePath) + '"; /m')
@staticmethod
[docs] def getTypeName(): return "Visual2015"