Browse Source

Drop support for VC2008. Add support for VC2010. Split vrpn and ffmpeg out of libpanda. Fixes for cross-compiling 64-bit on 32-bit Windows. Will post new thirdparty packages at the forums.

rdb 12 years ago
parent
commit
4c4b627260
4 changed files with 149 additions and 226 deletions
  1. 11 0
      makepanda/confauto.in
  2. 0 8
      makepanda/makepanda.bat
  3. 91 71
      makepanda/makepanda.py
  4. 47 147
      makepanda/makepandacore.py

+ 11 - 0
makepanda/confauto.in

@@ -21,6 +21,17 @@
 
 load-file-type egg pandaegg
 
+# These entries work very similar to load-file-type, except they are
+# used by the MovieVideo and MovieAudio code to determine which module
+# should be loaded in order to decode files of the given extension.
+
+# ffmpeg is added by default because it used to be compiled in.
+# The * is a special catch-all extension that is consulted unless a
+# loader has been defined with an explicit extension.
+
+load-audio-type * p3ffmpeg
+load-video-type * p3ffmpeg
+
 # The following lines define some handy object types to use within the
 # egg syntax.  This remaps <ObjectType> { name } into whatever egg
 # syntax is given by egg-object-type-name, which makes a handy

+ 0 - 8
makepanda/makepanda.bat

@@ -10,19 +10,11 @@ set thirdparty=thirdparty
 if defined MAKEPANDA_THIRDPARTY set thirdparty=%MAKEPANDA_THIRDPARTY%
 
 if not exist makepanda\makepanda.py goto :missing1
-
 if not exist %thirdparty%\win-python\python.exe goto :missing2
-
-if exist %thirdparty%\win-python-x64\python.exe goto :build64
 %thirdparty%\win-python\python.exe makepanda\makepanda.py %*
 if errorlevel 1 if x%1 == x--slavebuild exit 1
 goto done
 
-:build64
-%thirdparty%\win-python-x64\python.exe makepanda\makepanda.py %*
-if errorlevel 1 if x%1 == x--slavebuild exit 1
-goto done
-
 :missing1
   echo You need to change directory to the root of the panda source tree
   echo before invoking makepanda.  For further install instructions, read 

+ 91 - 71
makepanda/makepanda.py

@@ -80,7 +80,7 @@ PkgListSet(["PYTHON", "DIRECT",                        # Python support
   "EGL",                                               # OpenGL (ES) integration
   "EIGEN",                                             # Linear algebra acceleration
   "OPENAL", "FMODEX",                                  # Audio playback
-  "FFMPEG", "SWSCALE", "SWRESAMPLE",                   # FFMpeg (audio decoding)
+  "VORBIS", "FFMPEG", "SWSCALE", "SWRESAMPLE",         # Audio decoding
   "ODE", "PHYSX", "BULLET", "PANDAPHYSICS",            # Physics
   "SPEEDTREE",                                         # SpeedTree
   "ZLIB", "PNG", "JPEG", "TIFF", "SQUISH", "FREETYPE", # 2D Formats support
@@ -501,13 +501,12 @@ if (COMPILER == "MSVC"):
     if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "quartz.lib")
     if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "odbc32.lib")
     if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "odbccp32.lib")
-    if (PkgSkip("PNG")==0):      LibName("PNG",      GetThirdpartyDir() + "png/lib/libpandapng.lib")
-    if (PkgSkip("JPEG")==0):     LibName("JPEG",     GetThirdpartyDir() + "jpeg/lib/libpandajpeg.lib")
+    if (PkgSkip("PNG")==0):      LibName("PNG",      GetThirdpartyDir() + "png/lib/libpng_static.lib")
+    if (PkgSkip("JPEG")==0):     LibName("JPEG",     GetThirdpartyDir() + "jpeg/lib/jpeg-static.lib")
     if (PkgSkip("TIFF")==0):     LibName("TIFF",     GetThirdpartyDir() + "tiff/lib/libpandatiff.lib")
-    if (PkgSkip("ZLIB")==0):     LibName("ZLIB",     GetThirdpartyDir() + "zlib/lib/libpandazlib1.lib")
+    if (PkgSkip("ZLIB")==0):     LibName("ZLIB",     GetThirdpartyDir() + "zlib/lib/zlibstatic.lib")
     if (PkgSkip("VRPN")==0):     LibName("VRPN",     GetThirdpartyDir() + "vrpn/lib/vrpn.lib")
     if (PkgSkip("VRPN")==0):     LibName("VRPN",     GetThirdpartyDir() + "vrpn/lib/quat.lib")
-    if (PkgSkip("FMODEX")==0):   LibName("FMODEX",   GetThirdpartyDir() + "fmodex/lib/fmodex_vc.lib")
     if (PkgSkip("NVIDIACG")==0): LibName("CGGL",     GetThirdpartyDir() + "nvidiacg/lib/cgGL.lib")
     if (PkgSkip("NVIDIACG")==0): LibName("CGDX9",    GetThirdpartyDir() + "nvidiacg/lib/cgD3D9.lib")
     if (PkgSkip("NVIDIACG")==0): LibName("NVIDIACG", GetThirdpartyDir() + "nvidiacg/lib/cg.lib")
@@ -517,7 +516,6 @@ if (COMPILER == "MSVC"):
     if (PkgSkip("FFTW")==0):     LibName("FFTW",     GetThirdpartyDir() + "fftw/lib/rfftw.lib")
     if (PkgSkip("FFTW")==0):     LibName("FFTW",     GetThirdpartyDir() + "fftw/lib/fftw.lib")
     if (PkgSkip("ARTOOLKIT")==0):LibName("ARTOOLKIT",GetThirdpartyDir() + "artoolkit/lib/libAR.lib")
-    if (PkgSkip("ODE")==0):      LibName("ODE",      GetThirdpartyDir() + "ode/lib/ode.lib")
     if (PkgSkip("FCOLLADA")==0): LibName("FCOLLADA", GetThirdpartyDir() + "fcollada/lib/FCollada.lib")
     if (PkgSkip("SQUISH")==0):   LibName("SQUISH",   GetThirdpartyDir() + "squish/lib/squish.lib")
     if (PkgSkip("OPENCV")==0):   LibName("OPENCV",   GetThirdpartyDir() + "opencv/lib/cv.lib")
@@ -534,14 +532,19 @@ if (COMPILER == "MSVC"):
     if (PkgSkip("ROCKET")==0):
         LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketCore.lib")
         LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketControls.lib")
-        LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/boost_python-vc90-mt-1_48.lib")
+        if (PkgSkip("PYTHON")==0):
+            LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/" + SDK["PYTHONVERSION"] + "/boost_python-vc100-mt-1_54.lib")
         if (GetOptimize() <= 3):
             LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketDebugger.lib")
-    if (PkgSkip("OPENAL")==0):
-        if (os.path.exists(GetThirdpartyDir() + "openal/lib/pandaopenal32.lib")):
-            LibName("OPENAL",   GetThirdpartyDir() + "openal/lib/pandaopenal32.lib")
+    if (PkgSkip("OPENAL")==0):   LibName("OPENAL",   GetThirdpartyDir() + "openal/lib/OpenAL32.lib")
+    if (PkgSkip("ODE")==0):
+        LibName("ODE",      GetThirdpartyDir() + "ode/lib/ode_single.lib")
+        DefSymbol("ODE",    "dSINGLE", "")
+    if (PkgSkip("FMODEX")==0):
+        if (GetTargetArch() == 'x64'):
+            LibName("FMODEX",   GetThirdpartyDir() + "fmodex/lib/fmodex64_vc.lib")
         else:
-            LibName("OPENAL",   GetThirdpartyDir() + "openal/lib/OpenAL32.lib")
+            LibName("FMODEX",   GetThirdpartyDir() + "fmodex/lib/fmodex_vc.lib")
     if (PkgSkip("WX")==0):
         LibName("WX",       GetThirdpartyDir() + "wx/lib/wxbase28u.lib")
         LibName("WX",       GetThirdpartyDir() + "wx/lib/wxmsw28u_core.lib")
@@ -550,6 +553,10 @@ if (COMPILER == "MSVC"):
         DefSymbol("WX",     "UNICODE", "")
     if (PkgSkip("FLTK")==0):
         LibName("FLTK",     GetThirdpartyDir() + "fltk/lib/fltk.lib")
+    if (PkgSkip("VORBIS")==0):
+        LibName("VORBIS",   GetThirdpartyDir() + "vorbis/lib/libogg_static.lib")
+        LibName("VORBIS",   GetThirdpartyDir() + "vorbis/lib/libvorbis_static.lib")
+        LibName("VORBIS",   GetThirdpartyDir() + "vorbis/lib/libvorbisfile_static.lib")
     for pkg in MAYAVERSIONS:
         if (PkgSkip(pkg)==0):
             LibName(pkg, '"' + SDK[pkg] + '/lib/Foundation.lib"')
@@ -578,15 +585,15 @@ if (COMPILER == "MSVC"):
         AddToPathEnv("PATH", SDK["PHYSX"]+"/../Bin/win32/")
     if (PkgSkip("SPEEDTREE")==0):
         if GetTargetArch() == 'x64':
-            libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC9.x64/"
+            libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC10.x64/"
             p64ext = '64'
         else:
-            libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC9/"
+            libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC10/"
             p64ext = ''
 
         debugext = ''
         if (GetOptimize() <= 2): debugext = "_d"
-        libsuffix = "_v%s_VC90MT%s_Static%s.lib" % (
+        libsuffix = "_v%s_VC100MT%s_Static%s.lib" % (
             SDK["SPEEDTREEVERSION"], p64ext, debugext)
         LibName("SPEEDTREE", "%sSpeedTreeCore%s" % (libdir, libsuffix))
         LibName("SPEEDTREE", "%sSpeedTreeForest%s" % (libdir, libsuffix))
@@ -597,10 +604,13 @@ if (COMPILER == "MSVC"):
             LibName("SPEEDTREE",  "glu32.lib")
         IncDirectory("SPEEDTREE", SDK["SPEEDTREE"] + "/Include")
     if (PkgSkip("BULLET")==0):
-        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/LinearMath.lib")
-        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletCollision.lib")
-        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletDynamics.lib")
-        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletSoftBody.lib")
+        suffix = '.lib'
+        if GetTargetArch() == 'x64':
+            suffix = '_x64.lib'
+        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/LinearMath" + suffix)
+        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletCollision" + suffix)
+        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletDynamics" + suffix)
+        LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletSoftBody" + suffix)
 
 if (COMPILER=="GCC"):
     PkgDisable("AWESOMIUM")
@@ -665,6 +675,7 @@ if (COMPILER=="GCC"):
         SmartPkgEnable("TIFF",      "",          ("tiff"), "tiff.h")
         SmartPkgEnable("VRPN",      "",          ("vrpn", "quat"), ("vrpn", "quat.h", "vrpn/vrpn_Types.h"))
         SmartPkgEnable("BULLET", "bullet", ("BulletSoftBody", "BulletDynamics", "BulletCollision", "LinearMath"), ("bullet", "bullet/btBulletDynamicsCommon.h"))
+        SmartPkgEnable("VORBIS",    "vorbisfile",("vorbisfile", "vorbis", "ogg"), ("ogg/ogg.h", "vorbis/vorbisfile.h"))
 
         rocket_libs = ("RocketCore", "RocketControls")
         if (GetOptimize() <= 3):
@@ -801,7 +812,6 @@ if (COMPILER=="GCC"):
             LibName("PHYSX", "-lPhysXLoader")
             LibName("PHYSX", "-lNxCharacter")
 
-DefSymbol("ALWAYS", "MAKEPANDA", "")
 DefSymbol("WITHINPANDA", "WITHIN_PANDA", "1")
 if GetLinkAllStatic():
     DefSymbol("ALWAYS", "LINK_ALL_STATIC", "")
@@ -951,7 +961,7 @@ def CompileCxx(obj,src,opts):
                 cmd += " /QxHost"                            # compile for target host; Compiling for distribs should probably strictly enforce /arch:..
                 cmd += " /Quse-intel-optimized-headers"        # use intel optimized headers
                 cmd += " /Qparallel"                        # enable parallelization
-                cmd += " /Qvc9"                                # for Microsoft Visual C++ 2008
+                cmd += " /Qvc10"                                # for Microsoft Visual C++ 2010
 
             ## PCH files coexistence: the /Qpchi option causes the Intel C++ Compiler to name its
             ## PCH files with a .pchi filename suffix and reduce build time.
@@ -1152,16 +1162,17 @@ def CompileIgate(woutd,wsrc,opts):
         # If we're compiling for this platform, we can use the one we've built.
         cmd = os.path.join(GetOutputDir(), 'bin', 'interrogate')
     else:
+        # Assume that interrogate is on the PATH somewhere.
         cmd = 'interrogate'
 
     cmd += ' -srcdir %s -I%s -Dvolatile -Dmutable' % (srcdir, srcdir)
     if (COMPILER=="MSVC"):
         cmd += ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -longlong __int64 -D_X86_ -DWIN32_VC -D_WIN32'
-        #NOTE: this 1500 value is the version number for VC2008.
-        cmd += ' -D_MSC_VER=1500 -D"_declspec(param)=" -D_near -D_far -D__near -D__far -D__stdcall'
+        # NOTE: this 1600 value is the version number for VC2010.
+        cmd += ' -D_MSC_VER=1600 -D"_declspec(param)=" -D_near -D_far -D__near -D__far -D__stdcall'
     if (COMPILER=="GCC"):
         cmd += ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -D__const=const'
-        if is_64:
+        if GetTargetArch() in ("x86_64", "amd64"):
             cmd += ' -D_LP64'
         else:
             cmd += ' -D__i386__'
@@ -1219,6 +1230,7 @@ def CompileImod(wobj, wsrc, opts):
         # If we're compiling for this platform, we can use the one we've built.
         cmd = os.path.join(GetOutputDir(), 'bin', 'interrogate_module')
     else:
+        # Assume that interrogate_module is on the PATH somewhere.
         cmd = 'interrogate_module'
 
     cmd += ' -oc ' + woutc + ' -module ' + module + ' -library ' + library + ' -python-native '
@@ -1237,7 +1249,7 @@ def CompileLib(lib, obj, opts):
     if (COMPILER=="MSVC"):
         if not BOOUSEINTELCOMPILER:
             #Use MSVC Linker
-            cmd = 'link /lib /nologo /MANIFEST '
+            cmd = 'link /lib /nologo '
             if GetTargetArch() == 'x64':
                 cmd += "/MACHINE:X64 "
             cmd += '/OUT:' + BracketNameWithQuotes(lib)
@@ -1251,7 +1263,7 @@ def CompileLib(lib, obj, opts):
             cmd += '/OUT:' + BracketNameWithQuotes(lib)
             for x in obj: cmd += ' ' + BracketNameWithQuotes(x)
             cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\ipp\lib\ia32"'
-            cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\TBB\Lib\ia32\vc9"'
+            cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\TBB\Lib\ia32\vc10"'
             cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\compiler\lib\ia32"'
             oscmd(cmd)
 
@@ -1275,7 +1287,7 @@ def CompileLib(lib, obj, opts):
 def CompileLink(dll, obj, opts):
     if (COMPILER=="MSVC"):
         if not BOOUSEINTELCOMPILER:
-            cmd = "link /nologo /manifest "
+            cmd = "link /nologo "
             if GetTargetArch() == 'x64':
                 cmd += " /MACHINE:X64"
             if ("MFC" not in opts):
@@ -1289,8 +1301,8 @@ def CompileLink(dll, obj, opts):
             if (optlevel==3): cmd += " /MAP:NUL /NOD:MSVCRTD.LIB /NOD:MSVCPRTD.LIB /NOD:MSVCIRTD.LIB"
             if (optlevel==4): cmd += " /MAP:NUL /LTCG /NOD:MSVCRTD.LIB /NOD:MSVCPRTD.LIB /NOD:MSVCIRTD.LIB"
             if ("MFC" in opts):
-                if (optlevel<=2): cmd += " /NOD:MSVCRTD.LIB mfcs90d.lib MSVCRTD.lib"
-                else: cmd += " /NOD:MSVCRT.LIB mfcs90.lib MSVCRT.lib"
+                if (optlevel<=2): cmd += " /NOD:MSVCRTD.LIB mfcs100d.lib MSVCRTD.lib"
+                else: cmd += " /NOD:MSVCRT.LIB mfcs100.lib MSVCRT.lib"
             cmd += " /FIXED:NO /OPT:REF /STACK:4194304 /INCREMENTAL:NO "
             cmd += ' /OUT:' + BracketNameWithQuotes(dll)
             subsystem = GetValueOption(opts, "SUBSYSTEM:")
@@ -1317,11 +1329,6 @@ def CompileLink(dll, obj, opts):
             for (opt, name) in LIBNAMES:
                 if (opt=="ALWAYS") or (opt in opts): cmd += " " + BracketNameWithQuotes(name)
             oscmd(cmd)
-            SetVC90CRTVersion(dll+".manifest")
-            mtcmd = "mt -manifest " + dll + ".manifest -outputresource:" + dll
-            if (dll.endswith(".exe")==0): mtcmd = mtcmd + ";2"
-            else:                          mtcmd = mtcmd + ";1"
-            oscmd(mtcmd, ignoreError=True) # HACK: For some reason, mt sometimes gives a non-zero return value, even when it works
         else:
             cmd = "xilink"
             if GetVerbose(): cmd += " /verbose:lib"            
@@ -1332,7 +1339,7 @@ def CompileLink(dll, obj, opts):
             cmd += " /NOD:LIBCI.LIB /DEBUG"
             cmd += " /nod:libc /nod:libcmtd /nod:atlthunk /nod:atls"
             cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\ipp\lib\ia32"'
-            cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\TBB\Lib\ia32\vc9"'
+            cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\TBB\Lib\ia32\vc10"'
             cmd += ' /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\compiler\lib\ia32"'
             if (GetOrigExt(dll) != ".exe"): cmd += " /DLL"
             optlevel = GetOptimizeOption(opts)
@@ -1341,8 +1348,8 @@ def CompileLink(dll, obj, opts):
             if (optlevel==3): cmd += " /MAP:NUL /NOD:MSVCRTD.LIB /NOD:MSVCPRTD.LIB /NOD:MSVCIRTD.LIB"
             if (optlevel==4): cmd += " /MAP:NUL /LTCG /NOD:MSVCRTD.LIB /NOD:MSVCPRTD.LIB /NOD:MSVCIRTD.LIB"
             if ("MFC" in opts):
-                if (optlevel<=2): cmd += " /NOD:MSVCRTD.LIB mfcs90d.lib MSVCRTD.lib"
-                else: cmd += " /NOD:MSVCRT.LIB mfcs90.lib MSVCRT.lib"
+                if (optlevel<=2): cmd += " /NOD:MSVCRTD.LIB mfcs100d.lib MSVCRTD.lib"
+                else: cmd += " /NOD:MSVCRT.LIB mfcs100.lib MSVCRT.lib"
             cmd += " /FIXED:NO /OPT:REF /STACK:4194304 /INCREMENTAL:NO "
             cmd += ' /OUT:' + BracketNameWithQuotes(dll)
             subsystem = GetValueOption(opts, "SUBSYSTEM:")
@@ -1369,11 +1376,6 @@ def CompileLink(dll, obj, opts):
             for (opt, name) in LIBNAMES:
                 if (opt=="ALWAYS") or (opt in opts): cmd += " " + BracketNameWithQuotes(name)
             oscmd(cmd)
-            SetVC90CRTVersion(dll+".manifest")
-            mtcmd = "mt -manifest " + dll + ".manifest -outputresource:" + dll
-            if (dll.endswith(".exe")==0): mtcmd = mtcmd + ";2"
-            else:                          mtcmd = mtcmd + ";1"
-            oscmd(mtcmd, ignoreError=True) # HACK: For some reason, mt sometimes gives a non-zero return value, even when it works
 
     if COMPILER == "GCC":
         cxx = GetCXX()
@@ -1911,7 +1913,7 @@ DTOOL_CONFIG=[
     ("HAVE_SOFTIMAGE_PIC",             '1',                      '1'),
     ("HAVE_BMP",                       '1',                      '1'),
     ("HAVE_PNM",                       '1',                      '1'),
-    ("HAVE_VRPN",                      'UNDEF',                  'UNDEF'),
+    ("HAVE_VORBIS",                    'UNDEF',                  'UNDEF'),
     ("HAVE_FMODEX",                    'UNDEF',                  'UNDEF'),
     ("HAVE_OPENAL",                    'UNDEF',                  'UNDEF'),
     ("HAVE_NVIDIACG",                  'UNDEF',                  'UNDEF'),
@@ -2507,6 +2509,8 @@ CopyAllHeaders('panda/src/grutil')
 if (PkgSkip("VISION")==0):
     CopyAllHeaders('panda/src/vision')
 CopyAllHeaders('panda/src/awesomium')
+if (PkgSkip("FFMPEG")==0):
+    CopyAllHeaders('panda/src/ffmpeg')
 CopyAllHeaders('panda/src/tform')
 CopyAllHeaders('panda/src/collide')
 CopyAllHeaders('panda/src/parametrics')
@@ -3213,9 +3217,8 @@ if (not RUNTIME):
 #
 
 if (not RUNTIME):
-  OPTS=['DIR:panda/src/movies', 'BUILDING:PANDA', 'FFMPEG']
+  OPTS=['DIR:panda/src/movies', 'BUILDING:PANDA', 'VORBIS']
   TargetAdd('p3movies_composite1.obj', opts=OPTS, input='p3movies_composite1.cxx')
-  TargetAdd('p3movies_composite2.obj', opts=OPTS, input='p3movies_composite2.cxx')
   IGATEFILES=GetDirectoryContents('panda/src/movies', ["*.h", "*_composite*.cxx"])
   TargetAdd('libp3movies.in', opts=OPTS, input=IGATEFILES)
   TargetAdd('libp3movies.in', opts=['IMOD:panda', 'ILIB:libp3movies', 'SRCDIR:panda/src/movies'])
@@ -3226,7 +3229,7 @@ if (not RUNTIME):
 #
 
 if (not RUNTIME):
-  OPTS=['DIR:panda/src/grutil', 'BUILDING:PANDA', 'FFMPEG', 'BIGOBJ']
+  OPTS=['DIR:panda/src/grutil', 'BUILDING:PANDA', 'BIGOBJ']
   TargetAdd('p3grutil_multitexReducer.obj', opts=OPTS, input='multitexReducer.cxx')
   TargetAdd('p3grutil_composite1.obj', opts=OPTS, input='p3grutil_composite1.cxx')
   TargetAdd('p3grutil_composite2.obj', opts=OPTS, input='p3grutil_composite2.cxx')
@@ -3309,18 +3312,6 @@ if (not RUNTIME):
   TargetAdd('libp3recorder.in', opts=['IMOD:panda', 'ILIB:libp3recorder', 'SRCDIR:panda/src/recorder'])
   TargetAdd('libp3recorder_igate.obj', input='libp3recorder.in', opts=["DEPENDENCYONLY"])
 
-#
-# DIRECTORY: panda/src/vrpn/
-#
-
-if (PkgSkip("VRPN")==0 and not RUNTIME):
-  OPTS=['DIR:panda/src/vrpn', 'BUILDING:PANDA',  'VRPN']
-  TargetAdd('p3vrpn_composite1.obj', opts=OPTS, input='p3vrpn_composite1.cxx')
-  IGATEFILES=GetDirectoryContents('panda/src/vrpn', ["*.h", "*_composite*.cxx"])
-  TargetAdd('libp3vrpn.in', opts=OPTS, input=IGATEFILES)
-  TargetAdd('libp3vrpn.in', opts=['IMOD:panda', 'ILIB:libp3vrpn', 'SRCDIR:panda/src/vrpn'])
-  TargetAdd('libp3vrpn_igate.obj', input='libp3vrpn.in', opts=["DEPENDENCYONLY"])
-
 #
 # DIRECTORY: panda/src/dxml/
 #
@@ -3345,9 +3336,9 @@ if (not RUNTIME):
 #
 
 if (not RUNTIME):
-  OPTS=['DIR:panda/metalibs/panda', 'BUILDING:PANDA', 'VRPN', 'JPEG', 'PNG',
-      'TIFF', 'ZLIB', 'OPENSSL', 'FREETYPE', 'FFTW', 'ADVAPI', 'WINSOCK2','SQUISH',
-      'NVIDIACG', 'WINUSER', 'WINMM', 'FFMPEG', 'SWSCALE', 'SWRESAMPLE', 'WINGDI', 'IPHLPAPI']
+  OPTS=['DIR:panda/metalibs/panda', 'BUILDING:PANDA', 'JPEG', 'PNG',
+      'TIFF', 'ZLIB', 'OPENSSL', 'FREETYPE', 'FFTW', 'ADVAPI', 'WINSOCK2',
+      'SQUISH', 'NVIDIACG', 'VORBIS', 'WINUSER', 'WINMM', 'WINGDI', 'IPHLPAPI']
 
   TargetAdd('panda_panda.obj', opts=OPTS, input='panda.cxx')
 
@@ -3398,7 +3389,6 @@ if (not RUNTIME):
   TargetAdd('libpanda.dll', input='p3cull_composite1.obj')
   TargetAdd('libpanda.dll', input='p3cull_composite2.obj')
   TargetAdd('libpanda.dll', input='p3movies_composite1.obj')
-  TargetAdd('libpanda.dll', input='p3movies_composite2.obj')
   TargetAdd('libpanda.dll', input='libp3movies_igate.obj')
   TargetAdd('libpanda.dll', input='p3grutil_multitexReducer.obj')
   TargetAdd('libpanda.dll', input='p3grutil_composite1.obj')
@@ -3477,11 +3467,6 @@ if (not RUNTIME):
   TargetAdd('libpanda.dll', input='libp3dtoolconfig.dll')
   TargetAdd('libpanda.dll', input='libp3dtool.dll')
 
-  if PkgSkip("VRPN")==0:
-    TargetAdd('libpanda.dll', input="p3vrpn_composite1.obj")
-    TargetAdd('libpanda.dll', input="libp3vrpn_igate.obj")
-    TargetAdd('libpanda_module.obj', input='libp3vrpn.in')
-
   if PkgSkip("FREETYPE")==0:
     TargetAdd('libpanda.dll', input="p3pnmtext_composite1.obj")
     TargetAdd('libpanda.dll', input="libp3pnmtext_igate.obj")
@@ -3490,7 +3475,6 @@ if (not RUNTIME):
   TargetAdd('libpanda_module.obj', opts=OPTS)
   TargetAdd('libpanda_module.obj', opts=['IMOD:panda', 'ILIB:libpanda'])
 
-  TargetAdd('libpanda.dll', dep='dtool_have_vrpn.dat')
   TargetAdd('libpanda.dll', dep='dtool_have_freetype.dat')
   TargetAdd('libpanda.dll', opts=OPTS)
 
@@ -3560,7 +3544,6 @@ if PkgSkip("AWESOMIUM") == 0 and not RUNTIME:
   TargetAdd('libp3awesomium.dll', input=COMMON_PANDA_LIBS)
   TargetAdd('libp3awesomium.dll', opts=OPTS)
 
-
 #
 # DIRECTORY: panda/src/p3skel
 #
@@ -3621,6 +3604,38 @@ if (PkgSkip('PANDAFX')==0) and (not RUNTIME):
   TargetAdd('libpandafx.dll', input=COMMON_PANDA_LIBS)
   TargetAdd('libpandafx.dll', opts=['ADVAPI',  'NVIDIACG'])
 
+#
+# DIRECTORY: panda/src/vrpn/
+#
+
+if (PkgSkip("VRPN")==0 and not RUNTIME):
+  OPTS=['DIR:panda/src/vrpn', 'BUILDING:VRPN',  'VRPN']
+  TargetAdd('p3vrpn_composite1.obj', opts=OPTS, input='p3vrpn_composite1.cxx')
+  IGATEFILES=GetDirectoryContents('panda/src/vrpn', ["*.h", "*_composite*.cxx"])
+  TargetAdd('libp3vrpn.in', opts=OPTS, input=IGATEFILES)
+  TargetAdd('libp3vrpn.in', opts=['IMOD:p3vrpn', 'ILIB:libp3vrpn', 'SRCDIR:panda/src/vrpn'])
+  TargetAdd('libp3vrpn_igate.obj', input='libp3vrpn.in', opts=["DEPENDENCYONLY"])
+
+  TargetAdd('libp3vrpn_module.obj', input='libp3vrpn.in')
+  TargetAdd('libp3vrpn_module.obj', opts=OPTS)
+  TargetAdd('libp3vrpn_module.obj', opts=['IMOD:p3vrpn', 'ILIB:libp3vrpn'])
+
+  TargetAdd('libp3vrpn.dll', input='libp3vrpn_module.obj')
+  TargetAdd('libp3vrpn.dll', input='p3vrpn_composite1.obj')
+  TargetAdd('libp3vrpn.dll', input='libp3vrpn_igate.obj')
+  TargetAdd('libp3vrpn.dll', input=COMMON_PANDA_LIBS)
+  TargetAdd('libp3vrpn.dll', opts=['VRPN'])
+
+#
+# DIRECTORY: panda/src/ffmpeg
+#
+if PkgSkip("FFMPEG") == 0 and not RUNTIME:
+  OPTS=['DIR:panda/src/ffmpeg', 'BUILDING:FFMPEG', 'FFMPEG', 'SWSCALE', 'SWRESAMPLE']
+  TargetAdd('p3ffmpeg_composite1.obj', opts=OPTS, input='p3ffmpeg_composite1.cxx')
+  TargetAdd('libp3ffmpeg.dll', input='p3ffmpeg_composite1.obj')
+  TargetAdd('libp3ffmpeg.dll', input=COMMON_PANDA_LIBS)
+  TargetAdd('libp3ffmpeg.dll', opts=OPTS)
+
 #
 # DIRECTORY: panda/src/audiotraits/
 #
@@ -5574,7 +5589,10 @@ if (PkgSkip("CONTRIB")==0 and not RUNTIME):
 
 if (PkgSkip("PYTHON")==0 and not RUNTIME):
   # We're phasing out the concept of PandaModules, so do not
-  # add new libraries here. See direct/src/ffi/panda3d.py
+  # add new libraries here.  Only add new libraries when you've
+  # split them out of libpanda and need to maintain backward
+  # compatibility with old imports.  See direct/src/ffi/panda3d.py
+
   TargetAdd('PandaModules.py', input='libpandaexpress.dll')
   TargetAdd('PandaModules.py', input='libpanda.dll')
   if (PkgSkip("PANDAPHYSICS")==0):
@@ -5592,6 +5610,8 @@ if (PkgSkip("PYTHON")==0 and not RUNTIME):
     TargetAdd('PandaModules.py', input='libp3awesomium.dll')
   if (PkgSkip("ODE")==0):
     TargetAdd('PandaModules.py', input='libpandaode.dll')
+  if (PkgSkip("VRPN")==0):
+    TargetAdd('PandaModules.py', input='libp3vrpn.dll')
 
 #
 # Generate the models directory and samples directory
@@ -6403,9 +6423,9 @@ if (INSTALLER != 0):
         if (GetOptimize() <= 2): dbg = "-dbg"
         if GetTargetArch() == 'x64':
             if (RUNTIME):
-                MakeInstallerNSIS("Panda3D-Runtime-"+VERSION+dbg+"-x64.exe", "Panda3D", "Panda3D "+VERSION, "C:\\Panda3D-"+VERSION)
+                MakeInstallerNSIS("Panda3D-Runtime-"+VERSION+dbg+"-x64.exe", "Panda3D", "Panda3D "+VERSION, "C:\\Panda3D-"+VERSION+"-x64")
             else:
-                MakeInstallerNSIS("Panda3D-"+VERSION+dbg+"-x64.exe", "Panda3D", "Panda3D "+VERSION, "C:\\Panda3D-"+VERSION)
+                MakeInstallerNSIS("Panda3D-"+VERSION+dbg+"-x64.exe", "Panda3D", "Panda3D "+VERSION, "C:\\Panda3D-"+VERSION+"-x64")
         else:
             if (RUNTIME):
                 MakeInstallerNSIS("Panda3D-Runtime-"+VERSION+dbg+".exe", "Panda3D", "Panda3D "+VERSION, "C:\\Panda3D-"+VERSION)

+ 47 - 147
makepanda/makepandacore.py

@@ -43,14 +43,14 @@ if sys.platform == 'darwin':
     # currently running in 32-bit mode.  But sys.maxint is a reliable
     # indicator.
     if sys.version_info >= (3, 0):
-        is_64 = (sys.maxsize > 0x100000000)
+        host_64 = (sys.maxsize > 0x100000000)
     else:
-        is_64 = (sys.maxint > 0x100000000)
+        host_64 = (sys.maxint > 0x100000000)
 else:
     # On Windows (and Linux?) sys.maxint reports 0x7fffffff even on a
     # 64-bit build.  So we stick with platform.architecture in that
     # case.
-    is_64 = (platform.architecture()[0] == '64bit')
+    host_64 = (platform.architecture()[0] == '64bit')
 
 ########################################################################
 ##
@@ -260,7 +260,7 @@ def GetHostArch():
 
     target = GetTarget()
     if target == 'windows':
-        return 'x64' if is_64 else 'x86'
+        return 'x64' if host_64 else 'x86'
     else: #TODO
         return platform.machine()
 
@@ -284,6 +284,11 @@ def SetTarget(target, arch=None):
     TOOLCHAIN_PREFIX = ''
 
     if target == 'windows':
+        if arch == 'i386':
+             arch = 'x86'
+        elif arch == 'amd64':
+            arch = 'x64'
+
         if arch is not None and arch != 'x86' and arch != 'x64':
             exit("Windows architecture must be x86 or x64")
 
@@ -846,7 +851,7 @@ def ListRegistryValues(path):
     return result
 
 def GetRegistryKey(path, subkey, override64=True):
-    if (is_64 and override64==True):
+    if (host_64 and override64):
         path = path.replace("SOFTWARE\\", "SOFTWARE\\Wow6432Node\\")
     k1=0
     key = TryRegistryKey(path)
@@ -1064,7 +1069,7 @@ def GetThirdpartyBase():
 
 def GetThirdpartyDir():
     """Returns the thirdparty directory for the target platform,
-    ie. thirdparty/win-libs-vc9/.  May return None in the future."""
+    ie. thirdparty/win-libs-vc10/.  May return None in the future."""
     global THIRDPARTYDIR
     if THIRDPARTYDIR != None:
         return THIRDPARTYDIR
@@ -1075,28 +1080,28 @@ def GetThirdpartyDir():
 
     if (target == 'windows'):
         if target_arch == 'x64':
-            THIRDPARTYDIR = base + "/win-libs-vc9-x64/"
+            THIRDPARTYDIR = base + "/win-libs-vc10-x64/"
             if not os.path.isdir(THIRDPARTYDIR):
-                THIRDPARTYDIR = base + "/win-libs-vc9/"
+                THIRDPARTYDIR = base + "/win-libs-vc10/"
         else:
-            THIRDPARTYDIR = base + "/win-libs-vc9/"
+            THIRDPARTYDIR = base + "/win-libs-vc10/"
 
     elif (target == 'darwin'):
         # OSX thirdparty binaries are universal, where possible.
         THIRDPARTYDIR = base + "/darwin-libs-a/"
 
     elif (target == 'linux'):
-        if (platform.machine().startswith("arm")):
+        if (target_arch.startswith("arm")):
             THIRDPARTYDIR = base + "/linux-libs-arm/"
-        elif (is_64):
+        elif (target_arch in ("x86_64", "amd64")):
             THIRDPARTYDIR = base + "/linux-libs-x64/"
         else:
             THIRDPARTYDIR = base + "/linux-libs-a/"
 
     elif (target == 'freebsd'):
-        if (platform.machine().startswith("arm")):
+        if (target_arch.startswith("arm")):
             THIRDPARTYDIR = base + "/freebsd-libs-arm/"
-        elif (is_64):
+        elif (target_arch in ("x86_64", "amd64")):
             THIRDPARTYDIR = base + "/freebsd-libs-x64/"
         else:
             THIRDPARTYDIR = base + "/freebsd-libs-a/"
@@ -1113,46 +1118,6 @@ def GetThirdpartyDir():
 
     return THIRDPARTYDIR
 
-########################################################################
-##
-## Visual Studio Manifest Manipulation.
-## These functions exist to make sure we are referencing the same
-## version of the VC runtime in the manifests that we are shipping
-## with Panda3D, to avoid side-by-side configuration errors. Also,
-## it also removes any dependency the VC80 CRT (as we only want to
-## depend on the VC90 CRT).
-##
-########################################################################
-
-VC90CRTVERSIONRE=re.compile("name=['\"]Microsoft.VC90.CRT['\"]\\s+version=['\"]([0-9.]+)['\"]")
-VC80CRTASSEMBLYRE=re.compile("<dependency>[\t \r\n]*<dependentAssembly>[\t \r\n]*<assemblyIdentity[\t \r\na-zA-Z0-9.'\"=]*name=['\"]Microsoft[.]VC80[.]CRT['\"][\t \r\na-zA-Z0-9.'\"=/]*>[\t \r\n]*(</assemblyIdentity>)?[\t \r\n]*</dependentAssembly>[\t \r\n]*</dependency>[\t \r\n]*")
-VC90CRTVERSION=None
-
-def GetVC90CRTVersion(fn = None):
-    global VC90CRTVERSION
-    if (VC90CRTVERSION != None):
-        return VC90CRTVERSION
-    if (not sys.platform.startswith("win")):
-        VC90CRTVERSION = 0
-        return 0
-    if (fn == None):
-        fn = GetThirdpartyDir() + "extras/bin/Microsoft.VC90.CRT.manifest"
-    manifest = ReadFile(fn)
-    version = VC90CRTVERSIONRE.search(manifest)
-    if (version == None):
-        exit("Cannot locate version number in " + fn)
-    VC90CRTVERSION = version.group(1)
-    return version.group(1)
-
-def SetVC90CRTVersion(fn, ver = None):
-    if (ver == None):
-        ver = GetVC90CRTVersion()
-    manifest = ReadFile(fn)
-    subst = " name='Microsoft.VC90.CRT' version='" + ver + "' "
-    manifest = VC90CRTVERSIONRE.sub(subst, manifest)
-    manifest = VC80CRTASSEMBLYRE.sub("", manifest)
-    WriteFile(fn, manifest)
-
 ########################################################################
 ##
 ## Gets or sets the output directory, by default "built".
@@ -1672,8 +1637,7 @@ def SdkLocateDirectX( strMode = 'default' ):
             if (dir != 0):
                 print("Using DirectX SDK March 2009")
                 SDK["DX9"] = dir.replace("\\", "/").rstrip("/")
-        archStr = "x86"
-        if (is_64): archStr = "x64"
+        archStr = GetTargetArch()
         if ("DX9" not in SDK) or ("DX8" not in SDK):
             uninstaller = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
             for subdir in ListRegistryKeys(uninstaller):
@@ -1735,8 +1699,7 @@ def SdkLocateDirectX( strMode = 'default' ):
         if ("DX9" not in SDK):
             exit("Couldn't find DirectX March 2009 SDK")
     elif strMode == 'aug2006':
-        archStr = "x86"
-        if (is_64): archStr = "x64"
+        archStr = GetTargetArch()
         if ("DX9" not in SDK) or ("DX8" not in SDK):
             uninstaller = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
             for subdir in ListRegistryKeys(uninstaller):
@@ -1777,7 +1740,7 @@ def SdkLocateMaya():
                     ddir = "/Applications/Autodesk/maya"+key
                     if (os.path.isdir(ddir)): SDK[ver] = ddir
                 else:
-                    if (is_64):
+                    if (GetTargetArch() == 'x64'):
                         ddir1 = "/usr/autodesk/maya"+key+"-x64"
                         ddir2 = "/usr/aw/maya"+key+"-x64"
                     else:
@@ -1810,7 +1773,7 @@ def SdkLocatePython(force_use_sys_executable = False):
             SDK["PYTHON"] = GetThirdpartyBase()+"/win-python"
             if (GetOptimize() <= 2):
                 SDK["PYTHON"] += "-dbg"
-            if (is_64 and os.path.isdir(SDK["PYTHON"] + "-x64")):
+            if (GetTargetArch() == 'x64' and os.path.isdir(SDK["PYTHON"] + "-x64")):
                 SDK["PYTHON"] += "-x64"
 
             SDK["PYTHONEXEC"] = SDK["PYTHON"].replace('/', '\\') + "\\python"
@@ -1844,7 +1807,7 @@ def SdkLocatePython(force_use_sys_executable = False):
 
 def SdkLocateVisualStudio():
     if (sys.platform != "win32"): return
-    vcdir = GetRegistryKey("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7", "9.0")
+    vcdir = GetRegistryKey("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7", "10.0")
     if (vcdir != 0) and (vcdir[-4:] == "\\VC\\"):
         vcdir = vcdir[:-3]
         SDK["VISUALSTUDIO"] = vcdir
@@ -1856,87 +1819,19 @@ def SdkLocateVisualStudio():
             vcdir = vcdir[:-3]
         SDK["VISUALSTUDIO"] = vcdir
 
-def SdkLocateMSPlatform( strMode = 'default'):
+def SdkLocateMSPlatform(strMode = 'default'):
     if (sys.platform != "win32"): return
     platsdk = 0
-    if (strMode == 'default'):
-        platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1", "InstallationFolder")
-        if (platsdk and not os.path.isdir(platsdk)):
-            platsdk = 0
-            
-        if (platsdk == 0):
-            platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1", "Install Dir")
-            if (platsdk and not os.path.isdir(platsdk)): 
-                platsdk = 0
-                
-        if (platsdk == 0):
-            platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v6.1","InstallationFolder")
-            if (platsdk and not os.path.isdir(platsdk)): 
-                platsdk = 0
-                
-        if (platsdk == 0):
-            platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v6.0A","InstallationFolder")
-            if (platsdk and not os.path.isdir(platsdk)):           
-                platsdk = 0
-                
-        if (platsdk == 0 and os.path.isdir(os.path.join(GetProgramFiles(), "Microsoft Platform SDK for Windows Server 2003 R2"))):
-            if (not is_64 or os.path.isdir(os.path.join(GetProgramFiles(), "Microsoft Platform SDK for Windows Server 2003 R2", "Lib", "AMD64"))):
-                platsdk = os.path.join(GetProgramFiles(), "Microsoft Platform SDK for Windows Server 2003 R2")
-                if (not os.path.isdir(platsdk)): 
-                    platsdk = 0
-
-        # Doesn't work with the Express versions, so we're checking for the "atlmfc" dir, which is not in the Express
-        if (platsdk == 0 and os.path.isdir(os.path.join(GetProgramFiles(), "Microsoft Visual Studio 9\\VC\\atlmfc"))
-                         and os.path.isdir(os.path.join(GetProgramFiles(), "Microsoft Visual Studio 9\\VC\\PlatformSDK"))):
-            platsdk = os.path.join(GetProgramFiles(), "Microsoft Visual Studio 9\\VC\\PlatformSDK")
-            if (not os.path.isdir(platsdk)): 
-                platsdk = 0
-
-        # This may not be the best idea but it does give a warning
-        if (platsdk == 0):
-            if ("WindowsSdkDir" in os.environ):
-                WARNINGS.append("Windows SDK directory not found in registry, found in Environment variables instead")
-                platsdk = os.environ["WindowsSdkDir"]
-                
-    elif (strMode == 'win71'):
-        platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1", "InstallationFolder")
-        if (platsdk and not os.path.isdir(platsdk)):
-            platsdk = 0
-        if not platsdk:
-            exit("Couldn't find Win7.1 Platform SDK")
-    elif (strMode == 'win61'):
-        platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v6.1","InstallationFolder")
-        if (platsdk and not os.path.isdir(platsdk)):
-            platsdk = 0
-        if not platsdk:
-            exit("Couldn't find Win6.1 Platform SDK")
-    elif (strMode == 'win60A'):
-        platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v6.0A","InstallationFolder")
-        if (platsdk and not os.path.isdir(platsdk)):           
-            platsdk = 0
-        if not platsdk:
-            exit("Couldn't find Win6.0 Platform SDK")
-    elif (strMode == 'winserver2003r2'):
-        platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1", "Install Dir")
-        if (platsdk and not os.path.isdir(platsdk)): 
-            platsdk = 0
-        if (platsdk == 0 and os.path.isdir(os.path.join(GetProgramFiles(), "Microsoft Platform SDK for Windows Server 2003 R2"))):
-            if (not is_64 or os.path.isdir(os.path.join(GetProgramFiles(), "Microsoft Platform SDK for Windows Server 2003 R2", "Lib", "AMD64"))):
-                platsdk = os.path.join(GetProgramFiles(), "Microsoft Platform SDK for Windows Server 2003 R2")
-                if (not os.path.isdir(platsdk)): 
-                    platsdk = 0
-        if (platsdk == 0 and os.path.isdir("C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2")):
-            if (not is_64 or os.path.isdir(os.path.join("C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2", "Lib", "AMD64"))):
-                platsdk = os.path.join("C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2")
-                if (not os.path.isdir(platsdk)): 
-                    platsdk = 0
-        if not platsdk:
-            exit("Couldn't find Windows Server 2003 R2 PlatformSDK")                
-                
-    if (platsdk != 0):
-        if (not platsdk.endswith("\\")):
-            platsdk += "\\"
-        SDK["MSPLATFORM"] = platsdk
+
+    platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1", "InstallationFolder")
+    if (platsdk and not os.path.isdir(platsdk)):
+        platsdk = 0
+    if not platsdk:
+        exit("Couldn't find Windows SDK v7.1")
+
+    if (not platsdk.endswith("\\")):
+        platsdk += "\\"
+    SDK["MSPLATFORM"] = platsdk
 
 def SdkLocateMacOSX(osxtarget = None):
     if (sys.platform != "darwin"): return
@@ -2134,7 +2029,8 @@ def SetupVisualStudioEnviron():
     os.environ["VCINSTALLDIR"] = SDK["VISUALSTUDIO"] + "VC"
     os.environ["WindowsSdkDir"] = SDK["MSPLATFORM"]
     suffix=""
-    if (is_64): suffix = "\\amd64"
+    arch = GetTargetArch()
+    if (arch == 'x64'): suffix = "\\amd64"
     AddToPathEnv("PATH",    SDK["VISUALSTUDIO"] + "VC\\bin"+suffix)
     AddToPathEnv("PATH",    SDK["VISUALSTUDIO"] + "Common7\\IDE")
     AddToPathEnv("INCLUDE", SDK["VISUALSTUDIO"] + "VC\\include")
@@ -2145,10 +2041,10 @@ def SetupVisualStudioEnviron():
     AddToPathEnv("INCLUDE", SDK["MSPLATFORM"] + "include")
     AddToPathEnv("INCLUDE", SDK["MSPLATFORM"] + "include\\atl")
     AddToPathEnv("INCLUDE", SDK["MSPLATFORM"] + "include\\mfc")
-    if (not is_64):
+    if (arch != 'x64'):
         AddToPathEnv("LIB", SDK["MSPLATFORM"] + "lib")
-        AddToPathEnv("PATH",SDK["VISUALSTUDIO"] + "VC\\redist\\x86\\Microsoft.VC90.CRT")
-        AddToPathEnv("PATH",SDK["VISUALSTUDIO"] + "VC\\redist\\x86\\Microsoft.VC90.MFC")
+        AddToPathEnv("PATH",SDK["VISUALSTUDIO"] + "VC\\redist\\x86\\Microsoft.VC100.CRT")
+        AddToPathEnv("PATH",SDK["VISUALSTUDIO"] + "VC\\redist\\x86\\Microsoft.VC100.MFC")
     elif (os.path.isdir(SDK["MSPLATFORM"] + "lib\\x64")):
         AddToPathEnv("LIB", SDK["MSPLATFORM"] + "lib\\x64")
     elif (os.path.isdir(SDK["MSPLATFORM"] + "lib\\amd64")):
@@ -2207,6 +2103,10 @@ def DefSymbol(opt, sym, val=""):
 def SetupBuildEnvironment(compiler):
     if GetVerbose():
         print("Using compiler: %s" % compiler)
+        print("Host OS: %s" % GetHost())
+        print("Host arch: %s" % GetHostArch())
+        print("Target OS: %s" % GetTarget())
+        print("Target arch: %s" % GetTargetArch())
 
     if compiler == "MSVC":
         # Add the visual studio tools to PATH et al.
@@ -2251,18 +2151,18 @@ def SetupBuildEnvironment(compiler):
             exit('Not found: %s' % (prebuilt_dir))
 
         host_tag = GetHost() + '-x86'
-        if is_64:
+        if host_64:
             host_tag += '_64'
-        if host_tag == 'windows-x86':
+        elif host_tag == 'windows-x86':
             host_tag = 'windows'
 
         prebuilt_dir = os.path.join(prebuilt_dir, host_tag)
-        if is_64 and not os.path.isdir(prebuilt_dir):
+        if host_64 and not os.path.isdir(prebuilt_dir):
             # Try the 32-bits toolchain instead.
             prebuilt_dir = os.path.join(prebuilt_dir, host_tag)
 
         if not os.path.isdir(prebuilt_dir):
-            if is_64:
+            if host_64:
                 exit('Not found: %s or %s' % (prebuilt_dir, host_tag))
             else:
                 exit('Not found: %s' % (prebuilt_dir))