Global.gmsvc.pp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // Global.gmsvc.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.gmsvc.pp.
  7. //
  8. #defun get_metalibs target,complete_libs
  9. // In Windows, we need to know the complete set of metalibs that
  10. // encapsulates each of the libraries we'd be linking with normally.
  11. // In the case where a particular library is not part of a metalib,
  12. // we include the library itself.
  13. #define actual_libs
  14. #foreach lib $[complete_libs]
  15. // Only consider libraries that we're actually building.
  16. #if $[all_libs $[and $[build_directory],$[build_target]],$[lib]]
  17. #define modmeta $[module $[TARGET],$[lib]]
  18. #if $[ne $[modmeta],]
  19. #if $[ne $[modmeta],$[target]] // We don't link with ourselves.
  20. #set actual_libs $[actual_libs] $[modmeta]
  21. #endif
  22. #else
  23. #set actual_libs $[actual_libs] $[lib]
  24. #endif
  25. #endif
  26. #end lib
  27. #set actual_libs $[unique $[actual_libs]] $[patsubst %:m,%,$[filter %:m,$[OTHER_LIBS]]]
  28. $[actual_libs]
  29. #end get_metalibs
  30. #defer actual_local_libs $[get_metalibs $[TARGET],$[complete_local_libs]]
  31. #defun decygwin frompat,topat,path
  32. #foreach file $[path]
  33. $[patsubstw $[frompat],$[topat],$[osfilename $[file]]]
  34. #end file
  35. #end decygwin
  36. #define install_lib_dir $[install_lib_dir]
  37. #define install_bin_dir $[install_bin_dir]
  38. #define install_headers_dir $[install_headers_dir]
  39. #define install_data_dir $[install_data_dir]
  40. #define install_igatedb_dir $[install_igatedb_dir]
  41. #define install_config_dir $[install_config_dir]
  42. #define install_parser_inc_dir $[install_parser_inc_dir]
  43. // Define this if we want to make .sbr files.
  44. #if $[USE_BROWSEINFO]
  45. #defer BROWSEINFO_FLAG /Fr"$[osfilename $[target:%.obj=%.sbr]]"
  46. #else
  47. #define BROWSEINFO_FLAG
  48. #endif
  49. #define CFLAGS_SHARED
  50. #include $[THISDIRPREFIX]compilerSettings.pp
  51. #if $[TEST_INLINING]
  52. // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
  53. #define WARNING_LEVEL_FLAG /W4
  54. #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
  55. #endif
  56. // 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!
  57. #defer CDEFINES_OPT1 $[EXTRA_CDEFS]
  58. #defer CDEFINES_OPT2 $[EXTRA_CDEFS]
  59. #defer CDEFINES_OPT3 $[EXTRA_CDEFS]
  60. #defer CDEFINES_OPT4 $[EXTRA_CDEFS]
  61. #defer cdefines $[CDEFINES_OPT$[OPTIMIZE]]
  62. // Opt1 /GZ disables OPT flags, so make sure its OPT1 only
  63. #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS]
  64. #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[if $[no_opt],$[OPT1FLAGS],$[OPTFLAGS]]
  65. #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[if $[no_opt],$[OPT1FLAGS],$[OPTFLAGS]] $[DEBUGPDBFLAGS]
  66. #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[if $[no_opt],$[OPT1FLAGS],$[OPTFLAGS] $[OPT4FLAGS]] $[DEBUGPDBFLAGS]
  67. //#if $[FORCE_DEBUG_FLAGS]
  68. // make them all link with non-debug msvc runtime dlls for this case
  69. //#defer DEBUGFLAGS $[subst /MDd,,$[DEBUGFLAGS]]
  70. //#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGFLAGS]
  71. //#define LINKER_FLAGS $[LINKER_FLAGS] /debug
  72. //#else
  73. //#endif
  74. // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
  75. #defer LDFLAGS_OPT1 $[LINKER_FLAGS] $[LDFLAGS_OPT1]
  76. #defer LDFLAGS_OPT2 $[LINKER_FLAGS] $[LDFLAGS_OPT2]
  77. #defer LDFLAGS_OPT3 $[LINKER_FLAGS] $[LDFLAGS_OPT3]
  78. #defer LDFLAGS_OPT4 $[LINKER_FLAGS] $[LDFLAGS_OPT4]
  79. // $[dllext] will be "_d" for debug builds, and empty for non-debug
  80. // builds. This is the extra bit of stuff we tack on to the end of a
  81. // dll name. We name the debug dll's file_d.dll, partly to be
  82. // consistent with Python's convention, and partly for our own benefit
  83. // to differentiate debug-built from non-debug-built dll's (since the
  84. // distinction is so important in Windows).
  85. #define dllext $[if $[<= $[OPTIMIZE],2],_d]
  86. #defer interrogate_ipath $[decygwin %,-S"%",$[install_parser_inc_dir]] $[decygwin %,-I"%",$[target_ipath]]
  87. // '#defer extra_cflags $[extra_cflags] /STUFF' will never work because extra_cflags hasnt been
  88. // defined yet, so this just evaluates the reference to null and removes the reference and the
  89. // the defining extra_cflags in individual sources.pp's will not picked up. use END_FLAGS instead
  90. #if $[eq $[USE_COMPILER], MSVC9x64]
  91. #defer extra_cflags /EHsc /Zm500 /DWIN64_VC /DWIN64=1 $[WARNING_LEVEL_FLAG] $[END_CFLAGS]
  92. #else
  93. #defer extra_cflags /EHsc /Zm500 /DWIN32_VC /DWIN32=1 $[WARNING_LEVEL_FLAG] $[END_CFLAGS]
  94. #endif
  95. #if $[direct_tau]
  96. #define tau_ipath $[TAU_ROOT]/include
  97. #define tau_cflags /DPROFILING_ON /DTAU_STDCXXLIB /DTAU_USE_C_API
  98. #define tau_lpath $[TAU_ROOT]/lib/VC7
  99. #define tau_libs pytau.lib
  100. #else // direct_tau
  101. #define tau_ipath
  102. #define tau_cflags
  103. #define tau_lpath
  104. #define tau_libs
  105. #endif // direct_tau
  106. #defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH] $[tau_ipath]]
  107. #defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] $[tau_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]]"
  111. #defer STATIC_LIB_C++ $[STATIC_LIB_C]
  112. #if $[eq $[USE_COMPILER], MSVC9x64]
  113. #defer COMPILE_IDL midl /nologo /env win64 /Oicf $[DECYGWINED_INC_PATHLIST_ARGS]
  114. #else
  115. #defer COMPILE_IDL midl /nologo /env win32 /Oicf $[DECYGWINED_INC_PATHLIST_ARGS]
  116. #endif
  117. #defer COMPILE_RC rc /R /L 0x409 $[DECYGWINED_INC_PATHLIST_ARGS]
  118. // if we're attached, use dllbase.txt. otherwise let OS loader resolve dll addrspace collisions
  119. #if $[ne $[CTPROJS],]
  120. // use predefined bases to speed dll loading and simplify debugging
  121. #defer DLLNAMEBASE $[lib_prefix]$[TARGET]
  122. #defer DLLBASEADDRFILENAME dllbase.txt
  123. #defer DLLBASEARG "/BASE:@$[dtool_ver_dir]\$[DLLBASEADDRFILENAME],$[DLLNAMEBASE]"
  124. #else
  125. // requires dtool envvar
  126. #define GENERATE_BUILDDATE
  127. #endif
  128. #defer LINKER_DEF_FILE_ARG $[if $[LINKER_DEF_FILE],/DEF:"$[LINKER_DEF_FILE]",]
  129. #defer SHARED_LIB_C $[LINKER] /nologo /DLL $[LINKER_DEF_FILE_ARG] $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH] $[tau_lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] $[tau_libs] $[VER_RESOURCE]
  130. #defer SHARED_LIB_C++ $[SHARED_LIB_C]
  131. #defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH] $[tau_lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] $[tau_libs] /OUT:"$[osfilename $[target]]"
  132. #defer LINK_BIN_C++ $[LINK_BIN_C]
  133. #defer MIDL_COMMAND $[COMPILE_IDL] /out $[ODIR] $[IDL_CDEFS:%=/D%] $[idl]