Commits

Anonymous committed 96898da

Added support for Windows Phone 8 compilers; added feature support for Windows Desktop Application and Windows Phone Application compilation

  • Participants
  • Parent commits 4a8ee16

Comments (0)

Files changed (1)

waflib/Tools/msvc.py

 Compilers supported:
 
 * msvc       => Visual Studio, versions 6.0 (VC 98, VC .NET 2002) to 11.0 (Visual Studio 2012)
-* wsdk       => Windows SDK, versions 6.0, 6.1, 7.0, 7.1
+* wsdk       => Windows SDK, versions 6.0, 6.1, 7.0, 7.1, 8.0
 * icl        => Intel compiler, versions 9, 10, 11, 13
+* winphone   => Visual Studio to target Windows Phone 8 native (version 8.0 for now)
 * Smartphone => Compiler/SDK for Smartphone devices (armv4/v4i)
 * PocketPC   => Compiler/SDK for PocketPC devices (armv4/v4i)
 
 """
 
 import os, sys, re, tempfile
-from waflib import Utils, Task, Logs, Options
+from waflib import Utils, Task, Logs, Options, Errors
 from waflib.Logs import debug, warn
 from waflib.TaskGen import after_method, feature
 
 '''.split()
 """importlibs provided by MSVC/Platform SDK. Do NOT search them"""
 
-all_msvc_platforms = [ ('x64', 'amd64'), ('x86', 'x86'), ('ia64', 'ia64'), ('x86_amd64', 'amd64'), ('x86_ia64', 'ia64') ]
+all_msvc_platforms = [ ('x64', 'amd64'), ('x86', 'x86'), ('ia64', 'ia64'), ('x86_amd64', 'amd64'), ('x86_ia64', 'ia64'), ('x86_arm', 'arm') ]
 """List of msvc platforms"""
 
 all_wince_platforms = [ ('armv4', 'arm'), ('armv4i', 'arm'), ('mipsii', 'mips'), ('mipsii_fp', 'mips'), ('mipsiv', 'mips'), ('mipsiv_fp', 'mips'), ('sh4', 'sh'), ('x86', 'cex86') ]
 call "%s" %s
 echo PATH=%%PATH%%
 echo INCLUDE=%%INCLUDE%%
-echo LIB=%%LIB%%
+echo LIB=%%LIB%%;%%LIBPATH%%
 """ % (vcvars,target))
 	sout = conf.cmd_and_log(['cmd', '/E:on', '/V:on', '/C', batfile.abspath()])
 	lines = sout.splitlines()
 	if not lines[0]:
 		lines.pop(0)
 
-	if version == '11.0':
-		if lines[0].startswith('Error'):
-			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_1)')
-	else:
-		for x in ('Setting environment', 'Setting SDK environment', 'Intel(R) C++ Compiler',
-				'Intel Parallel Studio', 'Intel(R) Parallel Studio', 'Intel(R) Composer',
-				'Intel Corporation. All rights reserved.'):
-			if lines[0].find(x) > -1:
-				lines.pop(0)
-				break
-		else:
-			debug('msvc: get_msvc_version: %r %r %r -> not found', compiler, version, target)
-			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_2)')
-
 	MSVC_PATH = MSVC_INCDIR = MSVC_LIBDIR = None
 	for line in lines:
 		if line.startswith('PATH='):
 			MSVC_INCDIR = [i for i in line[8:].split(';') if i]
 		elif line.startswith('LIB='):
 			MSVC_LIBDIR = [i for i in line[4:].split(';') if i]
-
 	if None in (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR):
 		conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_3)')
 
 			targets.append(('x86', ('x86', conf.get_msvc_version('msvc', version, '', os.path.join(vc_path, 'Bin', 'vcvars32.bat')))))
 		except conf.errors.ConfigurationError:
 			pass
-	versions.append(('msvc '+ version, targets))
+	if targets:
+		versions.append(('msvc '+ version, targets))
 
 @conf
 def gather_wince_targets(conf, versions, version, vc_path, vsvars, supported_platforms):
 			versions.append((device + ' ' + version, cetargets))
 
 @conf
+def gather_winphone_targets(conf, versions, version, vc_path, vsvars):
+	#Looking for WinPhone compilers
+	targets = []
+	for target,realtarget in all_msvc_platforms[::-1]:
+		try:
+			targets.append((target, (realtarget, conf.get_msvc_version('winphone', version, target, vsvars))))
+		except conf.errors.ConfigurationError as e:
+			pass
+	if targets:
+		versions.append(('winphone '+ version, targets))
+
+@conf
 def gather_msvc_versions(conf, versions):
 	vc_paths = []
 	for (v,version,reg) in gather_msvc_detected_versions():
 		if wince_supported_platforms and os.path.isfile(vsvars):
 			conf.gather_wince_targets(versions, version, vc_path, vsvars, wince_supported_platforms)
 
+		vsvars = os.path.join(vs_path, 'VC', 'WPSDK', 'WP80', 'vcvarsphoneall.bat')
+		if os.path.isfile(vsvars):
+			conf.gather_winphone_targets(versions, '8.0', vc_path, vsvars)
+
 	for version,vc_path in vc_paths:
 		vs_path = os.path.dirname(vc_path)
 		conf.gather_msvc_targets(versions, version, vc_path)
 		conf.find_program('MT', path_list=path, var='MT')
 		v['MTFLAGS'] = ['/NOLOGO']
 
-	conf.load('winres')
-
-	if not conf.env['WINRC']:
+	try:
+		conf.load('winres')
+	except Errors.WafError:
 		warn('Resource compiler not found. Compiling resource file is disabled')
 
 @conf
 for k in 'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split():
 	wrap_class(k)
 
+def make_winapp(self, family):
+	append = self.env.append_unique
+	append('DEFINES', 'WINAPI_FAMILY=%s' % family)
+	append('CXXFLAGS', '/ZW')
+	append('CXXFLAGS', '/TP')
+	for lib_path in self.env.LIBPATH:
+		append('CXXFLAGS','/AI%s'%lib_path)
+
+@feature('winphoneapp')
+@after_method('process_use')
+@after_method('propagate_uselib_vars')
+def make_winphone_app(self):
+	make_winapp(self, 'WINAPI_FAMILY_PHONE_APP')
+	conf.env.append_unique('LINKFLAGS', '/NODEFAULTLIB:ole32.lib')
+	conf.env.append_unique('LINKFLAGS', 'PhoneAppModelHost.lib')
+
+
+@feature('winapp')
+@after_method('process_use')
+@after_method('propagate_uselib_vars')
+def make_windows_app(self):
+	make_winapp(self, 'WINAPI_FAMILY_DESKTOP_APP')