From 7c73b6a661ede7b4140e28107c7442236582599d Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 8 Jan 2010 23:46:40 +0000 Subject: [PATCH] P3D_PLUGIN_MT --- direct/src/plugin/Sources.pp | 46 ++++++++++++++++++++++------ direct/src/plugin_activex/Sources.pp | 8 +++-- direct/src/plugin_npapi/Sources.pp | 6 ++-- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/direct/src/plugin/Sources.pp b/direct/src/plugin/Sources.pp index 06567e957d..09aedd319a 100644 --- a/direct/src/plugin/Sources.pp +++ b/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,16 +188,26 @@ #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 + // The remaining targets build p3dpython.exe and variants. diff --git a/direct/src/plugin_activex/Sources.pp b/direct/src/plugin_activex/Sources.pp index e21314b2ba..30015088c0 100755 --- a/direct/src/plugin_activex/Sources.pp +++ b/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 diff --git a/direct/src/plugin_npapi/Sources.pp b/direct/src/plugin_npapi/Sources.pp index 5f45b77ec8..78bb3b1934 100644 --- a/direct/src/plugin_npapi/Sources.pp +++ b/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