@@ -304,7 +304,7 @@ def run_gyp(self, gyp_file, *args, **kw):
304304 # TODO: --depth=. works around Chromium-specific tree climbing.
305305 depth = kw .pop ('depth' , '.' )
306306 run_args = ['--depth=' + depth ]
307- run_args .extend (['--format=' + f for f in self .formats ]);
307+ run_args .extend (['--format=' + f for f in self .formats ])
308308 run_args .append (gyp_file )
309309 if self .no_parallel :
310310 run_args += ['--no-parallel' ]
@@ -313,8 +313,9 @@ def run_gyp(self, gyp_file, *args, **kw):
313313 run_args .extend (self .extra_args )
314314 # Default xcode_ninja_target_pattern to ^.*$ to fix xcode-ninja tests
315315 xcode_ninja_target_pattern = kw .pop ('xcode_ninja_target_pattern' , '.*' )
316- run_args .extend (
317- ['-G' , 'xcode_ninja_target_pattern=%s' % xcode_ninja_target_pattern ])
316+ if self is TestGypXcodeNinja :
317+ run_args .extend (
318+ ['-G' , 'xcode_ninja_target_pattern=%s' % xcode_ninja_target_pattern ])
318319 run_args .extend (args )
319320 return self .run (program = self .gyp , arguments = run_args , ** kw )
320321
@@ -703,10 +704,15 @@ def FindVisualStudioInstallation():
703704 search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable.
704705 Failing that, we search for likely deployment paths.
705706 """
707+ override_build_tool = os .environ .get ('GYP_BUILD_TOOL' )
708+ if override_build_tool :
709+ return override_build_tool , True , override_build_tool
710+
706711 possible_roots = ['%s:\\ Program Files%s' % (chr (drive ), suffix )
707712 for drive in range (ord ('C' ), ord ('Z' ) + 1 )
708713 for suffix in ['' , ' (x86)' ]]
709714 possible_paths = {
715+ '2017' : r'Microsoft Visual Studio\2017' ,
710716 '2015' : r'Microsoft Visual Studio 14.0\Common7\IDE\devenv.com' ,
711717 '2013' : r'Microsoft Visual Studio 12.0\Common7\IDE\devenv.com' ,
712718 '2012' : r'Microsoft Visual Studio 11.0\Common7\IDE\devenv.com' ,
@@ -721,6 +727,36 @@ def FindVisualStudioInstallation():
721727 msvs_version = flag .split ('=' )[- 1 ]
722728 msvs_version = os .environ .get ('GYP_MSVS_VERSION' , msvs_version )
723729
730+ if msvs_version in ['2017' , 'auto' ]:
731+ msbuild_exes = []
732+ try :
733+ path = possible_paths ['2017' ]
734+ for r in possible_roots :
735+ build_tool = os .path .join (r , path )
736+ if os .path .exists (build_tool ):
737+ break ;
738+ else :
739+ build_tool = None
740+ if not build_tool :
741+ args1 = ['reg' , 'query' ,
742+ 'HKLM\Software\Microsoft\VisualStudio\SxS\VS7' ,
743+ '/v' , '15.0' , '/reg:32' ]
744+ build_tool = subprocess .check_output (args1 )\
745+ .strip ().split ('\r \n ' ).pop ().split (' ' ).pop ()
746+ if build_tool :
747+ args2 = ['cmd.exe' , '/d' , '/c' ,
748+ 'cd' , '/d' , build_tool ,
749+ '&' , 'dir' , '/b' , '/s' , 'msbuild.exe' ]
750+ msbuild_exes = subprocess .check_output (args2 ).strip ().split ('\r \n ' )
751+ if len (msbuild_exes ):
752+ msbuild_Path = os .path .join (build_tool , msbuild_exes [0 ])
753+ if os .path .exists (msbuild_Path ):
754+ os .environ ['GYP_MSVS_VERSION' ] = '2017'
755+ os .environ ['GYP_BUILD_TOOL' ] = msbuild_Path
756+ return msbuild_Path , True , msbuild_Path
757+ except Exception as e :
758+ pass
759+
724760 if msvs_version in possible_paths :
725761 # Check that the path to the specified GYP_MSVS_VERSION exists.
726762 path = possible_paths [msvs_version ]
@@ -865,22 +901,38 @@ def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw):
865901 Runs a Visual Studio build using the configuration generated
866902 from the specified gyp_file.
867903 """
868- configuration = self .configuration_buildname ()
869- if clean :
870- build = '/Clean'
871- elif rebuild :
872- build = '/Rebuild'
904+ if '15.0' in self .build_tool :
905+ configuration = '/p:Configuration=' + (
906+ self .configuration or self .configuration_buildname ())
907+ build = '/t'
908+ if target not in (None , self .ALL , self .DEFAULT ):
909+ build += ':' + target
910+ if clean :
911+ build += ':Clean'
912+ elif rebuild :
913+ build += ':Rebuild'
914+ elif ':' not in build :
915+ build += ':Build'
916+ arguments = kw .get ('arguments' , [])[:]
917+ arguments .extend ([gyp_file .replace ('.gyp' , '.sln' ),
918+ build , configuration ])
873919 else :
874- build = '/Build'
875- arguments = kw .get ('arguments' , [])[:]
876- arguments .extend ([gyp_file .replace ('.gyp' , '.sln' ),
877- build , configuration ])
878- # Note: the Visual Studio generator doesn't add an explicit 'all'
879- # target, so we just treat it the same as the default.
880- if target not in (None , self .ALL , self .DEFAULT ):
881- arguments .extend (['/Project' , target ])
882- if self .configuration :
883- arguments .extend (['/ProjectConfig' , self .configuration ])
920+ configuration = self .configuration_buildname ()
921+ if clean :
922+ build = '/Clean'
923+ elif rebuild :
924+ build = '/Rebuild'
925+ else :
926+ build = '/Build'
927+ arguments = kw .get ('arguments' , [])[:]
928+ arguments .extend ([gyp_file .replace ('.gyp' , '.sln' ),
929+ build , configuration ])
930+ # Note: the Visual Studio generator doesn't add an explicit 'all'
931+ # target, so we just treat it the same as the default.
932+ if target not in (None , self .ALL , self .DEFAULT ):
933+ arguments .extend (['/Project' , target ])
934+ if self .configuration :
935+ arguments .extend (['/ProjectConfig' , self .configuration ])
884936 kw ['arguments' ] = arguments
885937 return self .run (program = self .build_tool , ** kw )
886938 def up_to_date (self , gyp_file , target = None , ** kw ):
0 commit comments