Global.msvc.pp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 build_dlls
  56. #define build_libs yes
  57. #define dlllib lib
  58. #else
  59. #define build_dlls yes
  60. #define build_libs
  61. #define dlllib dll
  62. #endif
  63. #include $[THISDIRPREFIX]compilerSettings.pp
  64. #if $[TEST_INLINING]
  65. // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
  66. #define WARNING_LEVEL_FLAG /W4
  67. #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
  68. #endif
  69. // 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!
  70. #defer CDEFINES_OPT1 $[EXTRA_CDEFS]
  71. #defer CDEFINES_OPT2 $[EXTRA_CDEFS]
  72. #defer CDEFINES_OPT3 $[EXTRA_CDEFS]
  73. #defer CDEFINES_OPT4 $[EXTRA_CDEFS]
  74. // Opt1 /GZ disables OPT flags, so make sure its OPT1 only
  75. #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS]
  76. #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS]
  77. #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGPDBFLAGS]
  78. #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[OPT4FLAGS] $[DEBUGPDBFLAGS]
  79. //#if $[FORCE_DEBUG_FLAGS]
  80. // make them all link with non-debug msvc runtime dlls for this case
  81. //#defer DEBUGFLAGS $[subst /MDd,,$[DEBUGFLAGS]]
  82. //#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGFLAGS]
  83. //#define LINKER_FLAGS $[LINKER_FLAGS] /debug
  84. //#else
  85. //#endif
  86. // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
  87. #defer LDFLAGS_OPT1 $[LINKER_FLAGS] $[LDFLAGS_OPT1]
  88. #defer LDFLAGS_OPT2 $[LINKER_FLAGS] $[LDFLAGS_OPT2]
  89. #defer LDFLAGS_OPT3 $[LINKER_FLAGS] $[LDFLAGS_OPT3]
  90. #defer LDFLAGS_OPT4 $[LINKER_FLAGS] $[LDFLAGS_OPT4]
  91. // $[dllext] will be "_d" for debug builds, and empty for non-debug
  92. // builds. This is the extra bit of stuff we tack on to the end of a
  93. // dll name. We name the debug dll's file_d.dll, partly to be
  94. // consistent with Python's convention, and partly for our own benefit
  95. // to differentiate debug-built from non-debug-built dll's (since the
  96. // distinction is so important in Windows).
  97. #define dllext $[if $[<= $[OPTIMIZE],2],_d]
  98. // Because Visual Studio .NET prefers to generate object files using the same
  99. // base name as the source file, we don't want an object file prefix.
  100. #define obj_prefix
  101. // Additional global defines for building under Microsoft Visual Studio .NET.
  102. #define extra_defines FORCE_INLINING HAVE_DINKUM WIN32_VC WIN32
  103. // Additional compiler flags.
  104. #defer extra_cflags /EHsc /Zm500 $[WARNING_LEVEL_FLAG] $[END_CFLAGS]
  105. #defer interrogate_ipath $[decygwin %,-S"%",$[install_parser_inc_dir]] $[decygwin %,-I"%",$[target_ipath]]
  106. #defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH]]
  107. #defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] "$[osfilename $[source]]"
  108. #defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS]
  109. #defer COMPILE_C++ $[COMPILE_C]
  110. #defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]" $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
  111. #defer STATIC_LIB_C++ $[STATIC_LIB_C]
  112. #defer COMPILE_IDL midl /nologo /env win32 /Oicf $[DECYGWINED_INC_PATHLIST_ARGS]
  113. #defer COMPILE_RC rc /R /L 0x409 $[DECYGWINED_INC_PATHLIST_ARGS]
  114. // if we're attached, use dllbase.txt. otherwise let OS loader resolve dll addrspace collisions
  115. #if $[ne $[CTPROJS],]
  116. // use predefined bases to speed dll loading and simplify debugging
  117. #defer DLLNAMEBASE $[lib_prefix]$[TARGET]
  118. #defer DLLBASEADDRFILENAME dllbase.txt
  119. #defer DLLBASEARG "/BASE:@$[dtool_ver_dir]\$[DLLBASEADDRFILENAME],$[DLLNAMEBASE]"
  120. #else
  121. // requires dtool envvar
  122. #define GENERATE_BUILDDATE
  123. #endif
  124. #defer LINKER_DEF_FILE_ARG $[if $[LINKER_DEF_FILE],/DEF:"$[LINKER_DEF_FILE]",]
  125. //#defer ver_resource $[directory]\ver.res
  126. //#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]]
  127. #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]]
  128. #defer SHARED_LIB_C++ $[SHARED_LIB_C]
  129. #defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
  130. #defer LINK_BIN_C++ $[LINK_BIN_C]
  131. #if $[ne $[LINK_ALL_STATIC],]
  132. #defer SHARED_LIB_C $[STATIC_LIB_C]
  133. #defer SHARED_LIB_C++ $[STATIC_LIB_C++]
  134. #defer ODIR_SHARED $[ODIR_STATIC]
  135. #endif