diff --git a/dtool/Config.Win32.pp b/dtool/Config.Win32.pp index 2ff882be43..32ae7b8c93 100644 --- a/dtool/Config.Win32.pp +++ b/dtool/Config.Win32.pp @@ -11,7 +11,7 @@ #define SYSTEM_IGATE_FLAGS -longlong __int64 -D_X86_ -DWIN32_VC -D"_declspec(param)=" -D"__declspec(param)=" -D_near -D_far -D__near -D__far -D_WIN32 -D__stdcall -Dvolatile= // Additional flags to pass to the Tau instrumentor. -#define TAU_INSTRUMENTOR_FLAGS -DWIN32_VC -D_WIN32 -D__cdecl= -D__stdcall= -D__fastcall= -D__i386 -D_MSC_VER=1310 -D_W64= -D_INTEGRAL_MAX_BITS=64 --exceptions --late_tiebreaker --no_class_name_injection --no_warnings --restrict --microsoft --new_for_init +#define TAU_INSTRUMENTOR_FLAGS -DTAU_USE_C_API -DPROFILING_ON -DWIN32_VC -D_WIN32 -D__cdecl= -D__stdcall= -D__fastcall= -D__i386 -D_MSC_VER=1310 -D_W64= -D_INTEGRAL_MAX_BITS=64 --exceptions --late_tiebreaker --no_class_name_injection --no_warnings --restrict --microsoft --new_for_init // Is the platform big-endian (like an SGI workstation) or // little-endian (like a PC)? Define this to the empty string to diff --git a/dtool/Config.pp b/dtool/Config.pp index c3fccfb4ca..35d669ad90 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -643,9 +643,17 @@ #define HAVE_AUDIO 1 // The Tau profiler provides a multiplatform, thread-aware profiler. -// To use it, define TAU_MAKEFILE appropriately, define USE_TAU to 1, -// and rebuild the code with ppremake; make install. +// To use it, define USE_TAU to 1, and set TAU_MAKEFILE to the +// filename that contains the Tau-provided Makefile for your platform. +// Then rebuild the code with ppremake; make install. Alternatively, +// instead of setting TAU_MAKEFILE, you can also define TAU_ROOT and +// PDT_ROOT, to point to the root directory of the tau and pdtoolkit +// installations, respectively; then the individual Tau components +// will be invoked directly. This is especially useful on Windows, +// where there is no Tau Makefile. #define TAU_MAKEFILE +#define TAU_ROOT +#define PDT_ROOT #define TAU_OPTS -optKeepFiles #define TAU_CFLAGS -D_GNU_SOURCE #define USE_TAU diff --git a/dtool/pptempl/Global.gmsvc.pp b/dtool/pptempl/Global.gmsvc.pp index da4477151f..d5134df6ea 100644 --- a/dtool/pptempl/Global.gmsvc.pp +++ b/dtool/pptempl/Global.gmsvc.pp @@ -124,9 +124,9 @@ #defer extra_cflags /EHsc /Zm500 /DWIN32_VC /DWIN32 $[WARNING_LEVEL_FLAG] $[END_CFLAGS] #if $[direct_tau] -#define tau_ipath $[ROOT_TAU]/include +#define tau_ipath $[TAU_ROOT]/include #define tau_cflags /DPROFILING_ON /DTAU_STDCXXLIB /DTAU_USE_C_API -#define tau_lpath $[ROOT_TAU]/lib/VC7 +#define tau_lpath $[TAU_ROOT]/lib/VC7 #define tau_libs tau-profile.lib #else // direct_tau #define tau_ipath diff --git a/dtool/pptempl/Template.gmsvc.pp b/dtool/pptempl/Template.gmsvc.pp index 1ac5df14d0..26c288f8c1 100644 --- a/dtool/pptempl/Template.gmsvc.pp +++ b/dtool/pptempl/Template.gmsvc.pp @@ -878,7 +878,7 @@ $[pdb_source] : $[il_source] $[TAB] $[TAU_MAKE_PDB] $[inst_source] : $[pdb_source] -$[TAB] $[TAU_MAKE_INST] -c +$[TAB] $[TAU_MAKE_INST] -c++ $[target] : $[inst_source] $[get_depends $[source]] #define source $[inst_source] diff --git a/dtool/pptempl/compilerSettings.pp b/dtool/pptempl/compilerSettings.pp index dfc9fd391b..a222a0880f 100644 --- a/dtool/pptempl/compilerSettings.pp +++ b/dtool/pptempl/compilerSettings.pp @@ -224,6 +224,6 @@ #endif #defer tau_opts $[decygwin %,-I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH] $[tau_ipath]] $[building_var:%=-D%] -#defer TAU_MAKE_IL $[ROOT_PDT]/Windows/bin/edgcpfe -o $[il_source] $[tau_opts] $[cdefines:%=-D%] $[TAU_INSTRUMENTOR_FLAGS] $[source] -#defer TAU_MAKE_PDB $[ROOT_PDT]/Windows/bin/taucpdisp $[il_source] > $[pdb_source] -#defer TAU_MAKE_INST $[ROOT_TAU]/bin/tau_instrumentor $[pdb_source] $[source] -o $[inst_source] +#defer TAU_MAKE_IL $[PDT_ROOT]/Windows/bin/edgcpfe -o $[il_source] $[tau_opts] $[cdefines:%=-D%] $[TAU_INSTRUMENTOR_FLAGS] $[source] +#defer TAU_MAKE_PDB $[PDT_ROOT]/Windows/bin/taucpdisp $[il_source] > $[pdb_source] +#defer TAU_MAKE_INST $[TAU_ROOT]/bin/tau_instrumentor $[pdb_source] $[source] -o $[inst_source] diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index b0579bb5f3..5ec13bddb3 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -142,6 +142,7 @@ /* If we're building with the Tau instrumentor, include the appropriate header file to pick up the TAU macros. */ #include +#include #else /* Otherwise, if we're not building with the Tau instrumentor, turn off all the TAU macros. We could include the Tau header file to do diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index f990e90e6f..c9c335e122 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -16,12 +16,13 @@ // //////////////////////////////////////////////////////////////////// -#ifndef PANDABASE_CC_H -#define PANDABASE_CC_H +#ifndef DTOOLBASE_CC_H +#define DTOOLBASE_CC_H // This file should never be included directly; it's intended to be // included only from dtoolbase.h. Include that file instead. +#ifdef __cplusplus #ifdef CPPPARSER #include @@ -182,7 +183,30 @@ INLINE void operator delete[](void *ptr) { (*global_operator_delete)(ptr); } +#if defined(USE_TAU) && defined(WIN32) +// Hack around tau's lack of DLL export declarations for Profiler class. +class EXPCL_DTOOL TauProfile { +public: + TauProfile(char *name, char *type, int group, char *group_name) { + _tautimer = NULL; + Tau_profile_c_timer(&_tautimer, name, type, group, group_name); + TAU_PROFILE_START(_tautimer); + } + ~TauProfile() { + TAU_PROFILE_STOP(_tautimer); + } + +private: + void *_tautimer; +}; + +#undef TAU_PROFILE +#define TAU_PROFILE(name, type, group) TauProfile _taupr(name, type, group, #group) +#endif // USE_TAU + #endif // GLOBAL_OPERATOR_NEW_EXCEPTIONS #endif // USE_MEMORY_NOWRAPPERS +#endif // __cplusplus + #endif