Global.msvc.pp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // Global.msvc.pp
  3. //
  4. // This file is read in before any of the individual Sources.pp files
  5. // are read. It defines a few global variables to assist
  6. // Template.msvc.pp.
  7. //
  8. #define REQUIRED_PPREMAKE_VERSION 1.12
  9. #if $[< $[PPREMAKE_VERSION],$[REQUIRED_PPREMAKE_VERSION]]
  10. #error You need at least ppremake version $[REQUIRED_PPREMAKE_VERSION] to use BUILD_TYPE msvc.
  11. #endif
  12. #defun get_metalibs target,complete_libs
  13. // In Windows, we need to know the complete set of metalibs that
  14. // encapsulates each of the libraries we'd be linking with normally.
  15. // In the case where a particular library is not part of a metalib,
  16. // we include the library itself.
  17. #define actual_libs
  18. #foreach lib $[complete_libs]
  19. // Only consider libraries that we're actually building.
  20. #if $[all_libs $[and $[build_directory],$[build_target]],$[lib]]
  21. #define modmeta $[module $[TARGET],$[lib]]
  22. #if $[ne $[modmeta],]
  23. #if $[ne $[modmeta],$[target]] // We don't link with ourselves.
  24. #set actual_libs $[actual_libs] $[modmeta]
  25. #endif
  26. #else
  27. #set actual_libs $[actual_libs] $[lib]
  28. #endif
  29. #endif
  30. #end lib
  31. #set actual_libs $[unique $[actual_libs]] $[patsubst %:m,%,$[filter %:m,$[OTHER_LIBS]]]
  32. $[actual_libs]
  33. #end get_metalibs
  34. #defun decygwin frompat,topat,path
  35. #foreach file $[path]
  36. $[patsubstw $[frompat],$[topat],$[osfilename $[file]]]
  37. #end file
  38. #end decygwin
  39. #define install_lib_dir $[decygwin %,%,$[install_lib_dir]]
  40. #define install_bin_dir $[decygwin %,%,$[install_bin_dir]]
  41. #define install_headers_dir $[decygwin %,%,$[install_headers_dir]]
  42. #define install_data_dir $[decygwin %,%,$[install_data_dir]]
  43. #define install_igatedb_dir $[decygwin %,%,$[install_igatedb_dir]]
  44. #define install_config_dir $[decygwin %,%,$[install_config_dir]]
  45. #define install_parser_inc_dir $[decygwin %,%,$[install_parser_inc_dir]]
  46. // Define this if we want to make .sbr files.
  47. #if $[USE_BROWSEINFO]
  48. #defer BROWSEINFO_FLAG /Fr"$[osfilename $[target:%.obj=%.sbr]]"
  49. #else
  50. #define BROWSEINFO_FLAG
  51. #endif
  52. #define CFLAGS_SHARED
  53. // Define LINK_ALL_STATIC to generate static libs instead of DLL's.
  54. #if $[ne $[LINK_ALL_STATIC],]
  55. #define dlink_all_static LINK_ALL_STATIC
  56. #define build_dlls
  57. #define build_libs yes
  58. #define dlllib lib
  59. #else
  60. #define dlink_all_static
  61. #define build_dlls yes
  62. #define build_libs
  63. #define dlllib dll
  64. #endif
  65. #include $[THISDIRPREFIX]compilerSettings.pp
  66. #if $[TEST_INLINING]
  67. // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
  68. #define WARNING_LEVEL_FLAG /W4
  69. #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
  70. #endif
  71. // do NOT try to do #defer #defer CDEFINES_OPT1 $[CDEFINES_OPT1] here! it wont let Sources.pp define their own CDEFINES_OPT1! they must use EXTRA_CDEFS!
  72. #defer CDEFINES_OPT1 $[if $[NO_DEBUG_CDEF],,_DEBUG] $[dlink_all_static] $[EXTRA_CDEFS]
  73. #defer CDEFINES_OPT2 $[if $[NO_DEBUG_CDEF],,_DEBUG] $[dlink_all_static] $[EXTRA_CDEFS]
  74. #defer CDEFINES_OPT3 $[dlink_all_static] $[EXTRA_CDEFS]
  75. #defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] $[EXTRA_CDEFS]
  76. // Opt1 /GZ disables OPT flags, so make sure its OPT1 only
  77. #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS]
  78. #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS]
  79. #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGPDBFLAGS]
  80. #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[OPT4FLAGS] $[DEBUGPDBFLAGS]
  81. //#if $[FORCE_DEBUG_FLAGS]
  82. // make them all link with non-debug msvc runtime dlls for this case
  83. //#defer DEBUGFLAGS $[subst /MDd,,$[DEBUGFLAGS]]
  84. //#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGFLAGS]
  85. //#define LINKER_FLAGS $[LINKER_FLAGS] /debug
  86. //#else
  87. //#endif
  88. // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
  89. #defer LDFLAGS_OPT1 $[LINKER_FLAGS] $[LDFLAGS_OPT1]
  90. #defer LDFLAGS_OPT2 $[LINKER_FLAGS] $[LDFLAGS_OPT2]
  91. #defer LDFLAGS_OPT3 $[LINKER_FLAGS] $[LDFLAGS_OPT3]
  92. #defer LDFLAGS_OPT4 $[LINKER_FLAGS] $[LDFLAGS_OPT4]
  93. // $[dllext] will be "_d" for debug builds, and empty for non-debug
  94. // builds. This is the extra bit of stuff we tack on to the end of a
  95. // dll name. We name the debug dll's file_d.dll, partly to be
  96. // consistent with Python's convention, and partly for our own benefit
  97. // to differentiate debug-built from non-debug-built dll's (since the
  98. // distinction is so important in Windows).
  99. #define dllext $[if $[<= $[OPTIMIZE],2],_d]
  100. // note: does NOT include .dll or .lib at end
  101. #defun get_dllname dll_basename
  102. $[if $[ne $[DONT_USE_PANDA_DLL_NAMING],], $[dll_basename], lib$[dll_basename]$[dllext]]
  103. #end get_dllname
  104. // Because Visual Studio .NET prefers to generate object files using the same
  105. // base name as the source file, we don't want an object file prefix.
  106. #define obj_prefix
  107. // Additional global defines for building under Microsoft Visual Studio .NET.
  108. #define extra_defines FORCE_INLINING HAVE_DINKUM WIN32_VC WIN32
  109. // Additional compiler flags.
  110. #defer extra_cflags /EHsc /Zm500 $[WARNING_LEVEL_FLAG] $[END_CFLAGS]
  111. #defer interrogate_ipath $[decygwin %,-I"%",$[target_ipath]]
  112. #defer interrogate_spath $[decygwin %,-S"%",$[install_parser_inc_dir]]
  113. #defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH]]
  114. #defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] "$[osfilename $[source]]"
  115. #defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS]
  116. #defer COMPILE_C++ $[COMPILE_C]
  117. #defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]" $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
  118. #defer STATIC_LIB_C++ $[STATIC_LIB_C]
  119. #defer COMPILE_IDL midl /nologo /env win32 /Oicf $[DECYGWINED_INC_PATHLIST_ARGS]
  120. #defer COMPILE_RC rc /R /D "NDEBUG" /L 0x409 $[DECYGWINED_INC_PATHLIST_ARGS]
  121. // if we're attached, use dllbase.txt. otherwise let OS loader resolve dll addrspace collisions
  122. #if $[ne $[CTPROJS],]
  123. // use predefined bases to speed dll loading and simplify debugging
  124. #defer DLLNAMEBASE $[get_dllname $[TARGET]]
  125. #defer DLLBASEADDRFILENAME dllbase.txt
  126. #defer DLLBASEARG "/BASE:@$[dtool_ver_dir]\$[DLLBASEADDRFILENAME],$[DLLNAMEBASE]"
  127. #else
  128. // requires dtool envvar
  129. #define GENERATE_BUILDDATE
  130. #endif
  131. #defer LINKER_DEF_FILE_ARG $[if $[LINKER_DEF_FILE],/DEF:"$[LINKER_DEF_FILE]",]
  132. //#defer ver_resource $[directory]\ver.res
  133. //#defer SHARED_LIB_C link /nologo /dll /VERBOSE:LIB $[LDFLAGS_OPT$[OPTIMIZE]] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
  134. #defer SHARED_LIB_C $[LINKER] /nologo /DLL $[LINKER_DEF_FILE_ARG] $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
  135. #defer SHARED_LIB_C++ $[SHARED_LIB_C]
  136. #defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
  137. #defer LINK_BIN_C++ $[LINK_BIN_C]
  138. #if $[ne $[LINK_ALL_STATIC],]
  139. #defer SHARED_LIB_C $[STATIC_LIB_C]
  140. #defer SHARED_LIB_C++ $[STATIC_LIB_C++]
  141. #defer ODIR_SHARED $[ODIR_STATIC]
  142. #endif