Global.msvc.pp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.02
  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. #if $[isfullpath $[file]]
  37. $[patsubstw $[frompat],$[topat],$[cygpath_w $[file]]]
  38. #else
  39. $[patsubstw $[frompat],$[topat],$[osfilename $[file]]]
  40. #endif
  41. #end file
  42. #end decygwin
  43. #define install_lib_dir $[decygwin %,%,$[install_lib_dir]]
  44. #define install_bin_dir $[decygwin %,%,$[install_bin_dir]]
  45. #define install_headers_dir $[decygwin %,%,$[install_headers_dir]]
  46. #define install_data_dir $[decygwin %,%,$[install_data_dir]]
  47. #define install_igatedb_dir $[decygwin %,%,$[install_igatedb_dir]]
  48. #define install_config_dir $[decygwin %,%,$[install_config_dir]]
  49. #define install_parser_inc_dir $[decygwin %,%,$[install_parser_inc_dir]]
  50. // In the Windows command shell, we need to use double quotes instead
  51. // of single quotes.
  52. #defer SED ppremake -s "$[script]" <$[source] >$[target]
  53. // Define this if we want to make .sbr files.
  54. #if $[USE_BROWSEINFO]
  55. #defer BROWSEINFO_FLAG /Fr"$[osfilename $[target:%.obj=%.sbr]]"
  56. #else
  57. #define BROWSEINFO_FLAG
  58. #endif
  59. // Define LINK_ALL_STATIC to generate static libs instead of DLL's.
  60. #if $[LINK_ALL_STATIC]
  61. #define dlink_all_static LINK_ALL_STATIC
  62. #define build_dlls
  63. #define dlllib lib
  64. #else
  65. #define dlink_all_static
  66. #define build_dlls yes
  67. #define dlllib dll
  68. #endif
  69. #define CFLAGS_SHARED
  70. #include $[THISDIRPREFIX]compilerSettings.pp
  71. #if $[TEST_INLINING]
  72. // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
  73. #define WARNING_LEVEL_FLAG /W4
  74. #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
  75. #endif
  76. #defer CDEFINES_OPT1 _DEBUG $[dlink_all_static] $[EXTRA_CDEFS] $[CDEFINES_OPT1]
  77. #defer CDEFINES_OPT2 _DEBUG $[dlink_all_static] $[EXTRA_CDEFS] $[CDEFINES_OPT2]
  78. #defer CDEFINES_OPT3 $[dlink_all_static] $[EXTRA_CDEFS] $[CDEFINES_OPT3]
  79. #defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] $[EXTRA_CDEFS] $[CDEFINES_OPT4]
  80. #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[OPT1FLAGS] $[DEBUGFLAGS]
  81. #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS]
  82. #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGPDBFLAGS]
  83. #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[OPT4FLAGS] $[DEBUGPDBFLAGS]
  84. #defer LDFLAGS_OPT1 $[LINKER_FLAGS] $[LDFLAGS_OPT1]
  85. #defer LDFLAGS_OPT2 $[LINKER_FLAGS] $[LDFLAGS_OPT2]
  86. #defer LDFLAGS_OPT3 $[LINKER_FLAGS] $[LDFLAGS_OPT3]
  87. #defer LDFLAGS_OPT4 $[LINKER_FLAGS] $[LDFLAGS_OPT4]
  88. // $[dllext] will be "_d" for debug builds, and empty for non-debug
  89. // builds. This is the extra bit of stuff we tack on to the end of a
  90. // dll name. We name the debug dll's file_d.dll, partly to be
  91. // consistent with Python's convention, and partly for our own benefit
  92. // to differentiate debug-built from non-debug-built dll's (since the
  93. // distinction is so important in Windows).
  94. #define dllext $[if $[<= $[OPTIMIZE],2],_d]
  95. #defer interrogate_ipath $[decygwin %,-I"%",$[target_ipath]]
  96. #defer interrogate_spath $[decygwin %,-S"%",$[install_parser_inc_dir]]
  97. #defer extra_cflags /EHsc /Zm300 /DWIN32_VC /DWIN32 $[WARNING_LEVEL_FLAG] $[END_CFLAGS]
  98. #defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH]]
  99. #defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] $[source]
  100. #defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS]
  101. #defer COMPILE_C++ $[COMPILE_C]
  102. #defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]"
  103. #defer STATIC_LIB_C++ $[STATIC_LIB_C]
  104. // if we're attached, use dllbase.txt. otherwise let OS loader resolve dll addrspace collisions
  105. #if $[ne $[DTOOL],]
  106. // use predefined bases to speed dll loading and simplify debugging
  107. #defer DLLNAMEBASE lib$[TARGET]$[dllext]
  108. #defer DLLBASEADDRFILENAME dllbase.txt
  109. #defer DLLBASEARG "/BASE:@$[dtool_ver_dir]\$[DLLBASEADDRFILENAME],$[DLLNAMEBASE]"
  110. #if $[GENERATE_BUILDDATE]
  111. #defer ver_resource "$[directory]\ver.res"
  112. #else
  113. #define ver_resource
  114. #endif
  115. #else
  116. // cant get builddate without dtool envvar
  117. #define GENERATE_BUILDDATE
  118. #endif
  119. #defer SHARED_LIB_C $[LINKER] /nologo /dll $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] $[sources] $[ver_resource] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
  120. #defer SHARED_LIB_C++ $[SHARED_LIB_C]
  121. #defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
  122. #defer LINK_BIN_C++ $[LINK_BIN_C]
  123. #if $[ne $[LINK_ALL_STATIC],]
  124. #defer SHARED_LIB_C $[STATIC_LIB_C]
  125. #defer SHARED_LIB_C++ $[STATIC_LIB_C++]
  126. #defer ODIR_SHARED $[ODIR_STATIC]
  127. #endif