Explorar el Código

P3D_PLUGIN_MT

David Rose hace 16 años
padre
commit
7c73b6a661

+ 37 - 9
direct/src/plugin/Sources.pp

@@ -13,6 +13,16 @@
 // who are preparing a custom Panda3D package for download by the
 // plugin will need to build this.
 
+// If P3D_PLUGIN_MT is defined, then (on Windows) /MT is used to
+// compile the core API and the NPAPI and ActiveX plugins, instead of
+// /MD.  This links the plugin with the static C runtime library,
+// instead of the dynamic runtime library, which is much better for
+// distributing the plugin with the XPI and CAB interfaces.  This
+// requires that special /MT versions of OpenSSL, libjpeg, libpng,
+// zlib, and TinyXML are available.
+
+#define _MT $[if $[P3D_PLUGIN_MT],_mt]
+
 #define COREAPI_SOURCES \
     fileSpec.cxx fileSpec.h fileSpec.I \
     find_root_dir.cxx find_root_dir.h \
@@ -100,10 +110,11 @@
 //
 
   #define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_OPENSSL],$[HAVE_ZLIB],$[HAVE_JPEG],$[HAVE_PNG]]
-  #define USE_PACKAGES tinyxml openssl zlib jpeg png x11
+  #define USE_PACKAGES tinyxml$[_MT] openssl$[_MT] zlib$[_MT] jpeg$[_MT] png$[_MT] x11
   #define TARGET p3d_plugin
   #define LIB_PREFIX
   #define BUILDING_DLL BUILDING_P3D_PLUGIN
+  #define LINK_FORCE_STATIC_RELEASE_C_RUNTIME $[P3D_PLUGIN_MT]
 
   #define OTHER_LIBS \
     $[if $[OSX_PLATFORM],subprocbuffer]
@@ -159,8 +170,15 @@
 #end bin_target
 
 
-#begin static_lib_target
+#define PLUGIN_COMMON_SOURCES \
+    load_plugin.cxx load_plugin.h \
+    fileSpec.cxx fileSpec.h fileSpec.I \
+    find_root_dir.cxx find_root_dir.h \
+    $[if $[IS_OSX],find_root_dir_assist.mm] \
+    is_pathsep.h is_pathsep.I \
+    mkdir_complete.cxx mkdir_complete.h
 
+#begin static_lib_target
 // 
 // libplugin_common.lib, a repository of code shared between the core
 // API and the various plugin implementations.
@@ -170,15 +188,25 @@
   #define TARGET plugin_common
   #define USE_PACKAGES tinyxml openssl
 
-  #define SOURCES \
-    load_plugin.cxx load_plugin.h \
-    fileSpec.cxx fileSpec.h fileSpec.I \
-    find_root_dir.cxx find_root_dir.h \
-    $[if $[IS_OSX],find_root_dir_assist.mm] \
-    is_pathsep.h is_pathsep.I \
-    mkdir_complete.cxx mkdir_complete.h
+  #define SOURCES $[PLUGIN_COMMON_SOURCES]
+
+#end static_lib_target
+
+#if $[P3D_PLUGIN_MT]
+#begin static_lib_target
+// 
+// libplugin_common_mt.lib, the same as above, with /MT compilation.
+//
+
+  #define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_OPENSSL]]
+  #define TARGET plugin_common_mt
+  #define USE_PACKAGES tinyxml_mt openssl_mt
+  #define LINK_FORCE_STATIC_RELEASE_C_RUNTIME 1
+
+  #define SOURCES $[PLUGIN_COMMON_SOURCES]
 
 #end static_lib_target
+#endif
 
 
 

+ 5 - 3
direct/src/plugin_activex/Sources.pp

@@ -6,14 +6,16 @@
 
 #define BUILD_DIRECTORY $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[WINDOWS_PLATFORM],$[HAVE_ACTIVEX]]
 
-#define USE_PACKAGES tinyxml
+#define _MT $[if $[P3D_PLUGIN_MT],_mt]
+#define USE_PACKAGES tinyxml$[_MT]
 
 #begin lib_target
   #define TARGET p3dactivex
   #define LIB_PREFIX
   #define DYNAMIC_LIB_EXT .ocx
 
-  #define LOCAL_LIBS plugin_common
+  #define LOCAL_LIBS plugin_common$[_MT]
+  #define LINK_FORCE_STATIC_RELEASE_C_RUNTIME $[P3D_PLUGIN_MT]
 
   #define COMBINED_SOURCES \
     $[TARGET]_composite1.cxx
@@ -29,7 +31,7 @@
     PPBrowserObject.cpp PPDownloadCallback.cpp PPDownloadRequest.cpp \
     PPInstance.cpp PPInterface.cpp PPLogger.cpp PPPandaObject.cpp
 
-  #define EXTRA_CDEFS _USRDLL _WINDLL _AFXDLL _MBCS
+  #define EXTRA_CDEFS _USRDLL _WINDLL _MBCS $[if $[not $[P3D_PLUGIN_MT]],_AFXDLL]
   #define WIN_RESOURCE_FILE P3DActiveX.rc
   #define LINKER_DEF_FILE P3DActiveX.def
 

+ 4 - 2
direct/src/plugin_npapi/Sources.pp

@@ -6,7 +6,8 @@
 
 #define BUILD_DIRECTORY $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_NPAPI]]
 
-#define USE_PACKAGES tinyxml npapi
+#define _MT $[if $[P3D_PLUGIN_MT],_mt]
+#define USE_PACKAGES tinyxml$[_MT] npapi
 
 #begin lib_target
   // By Mozilla convention, on Windows at least, the generated DLL
@@ -16,7 +17,8 @@
   #define TARGET nppanda3d
   #define LIB_PREFIX
 
-  #define LOCAL_LIBS plugin_common
+  #define LOCAL_LIBS plugin_common$[_MT]
+  #define LINK_FORCE_STATIC_RELEASE_C_RUNTIME $[P3D_PLUGIN_MT]
 
   #define COMBINED_SOURCES \
     $[TARGET]_composite1.cxx