Jamfile 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. import feature : feature ;
  2. project libdatachannel ;
  3. path-constant CWD : . ;
  4. feature gnutls : off on : composite propagated ;
  5. feature.compose <gnutls>off
  6. : <define>USE_GNUTLS=0 ;
  7. feature.compose <gnutls>on
  8. : <define>USE_GNUTLS=1 ;
  9. lib libdatachannel
  10. : # sources
  11. [ glob ./src/*.cpp ]
  12. [ glob ./src/impl/*.cpp ]
  13. : # requirements
  14. <cxxstd>17
  15. <include>./include
  16. <include>./include/rtc
  17. <include>./src
  18. <define>RTC_ENABLE_MEDIA=0
  19. <define>RTC_ENABLE_WEBSOCKET=0
  20. <define>USE_NICE=0
  21. <define>RTC_EXPORTS
  22. <define>RTC_STATIC
  23. <toolset>msvc:<define>WIN32_LEAN_AND_MEAN
  24. <toolset>msvc:<define>NOMINMAX
  25. <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
  26. <toolset>msvc:<define>_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
  27. <library>/libdatachannel//usrsctp
  28. <library>/libdatachannel//juice
  29. <library>/libdatachannel//plog
  30. <gnutls>on:<library>gnutls/<link>shared
  31. <gnutls>off:<library>ssl
  32. <gnutls>off:<library>crypto
  33. : # default build
  34. <link>static
  35. : # usage requirements
  36. <include>./include
  37. <define>RTC_ENABLE_MEDIA=0
  38. <define>RTC_ENABLE_WEBSOCKET=0
  39. <define>RTC_STATIC
  40. <library>/libdatachannel//plog
  41. <toolset>gcc:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
  42. <toolset>clang:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
  43. ;
  44. alias plog
  45. : # no sources
  46. : # no build requirements
  47. : # no default build
  48. : # usage requirements
  49. <include>./deps/plog/include
  50. ;
  51. alias usrsctp
  52. : # no sources
  53. : # no build requirements
  54. : # no default build
  55. : # usage requirements
  56. <include>./deps/usrsctp/usrsctplib
  57. <library>libusrsctp.a
  58. ;
  59. alias usrsctp
  60. : # no sources
  61. : <toolset>msvc
  62. : # no default build
  63. : # usage requirements
  64. <include>./deps/usrsctp/usrsctplib
  65. <library>usrsctp.lib
  66. ;
  67. alias juice
  68. : # no sources
  69. : # no build requirements
  70. : # no default build
  71. : # usage requirements
  72. <include>./deps/libjuice/include
  73. <define>JUICE_STATIC
  74. <gnutls>on:<library>libjuice-gnutls.a
  75. <gnutls>on:<library>nettle/<link>shared
  76. <gnutls>off:<library>libjuice-openssl.a
  77. ;
  78. alias juice
  79. : # no sources
  80. : <toolset>msvc
  81. : # no default build
  82. : # usage requirements
  83. <include>./deps/libjuice/include
  84. <define>JUICE_STATIC
  85. <library>juice-static.lib
  86. ;
  87. make libusrsctp.a : : @make_libusrsctp ;
  88. make usrsctp.lib : : @make_libusrsctp_msvc ;
  89. rule make_libusrsctp ( targets * : sources * : properties * )
  90. {
  91. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  92. VARIANT on $(targets) = $(VARIANT) ;
  93. BUILD_DIR on $(targets) = "build-$(VARIANT)" ;
  94. }
  95. actions make_libusrsctp
  96. {
  97. (cd $(CWD)/deps/usrsctp && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake -DCMAKE_BUILD_TYPE=$(VARIANT) -DCMAKE_C_FLAGS="-fPIC -Wno-unknown-warning-option -Wno-format-truncation" -Dsctp_build_shared_lib=0 -Dsctp_build_programs=0 -Dsctp_inet=0 -Dsctp_inet6=0 .. && make -j2 usrsctp)
  98. cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/libusrsctp.a $(<)
  99. }
  100. rule make_libusrsctp_msvc ( targets * : sources * : properties * )
  101. {
  102. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  103. VARIANT on $(targets) = $(VARIANT) ;
  104. BUILD_DIR on $(targets) = "build-$(VARIANT)" ;
  105. }
  106. actions make_libusrsctp_msvc
  107. {
  108. SET OLDD=%CD%
  109. cd $(CWD)/deps/usrsctp
  110. mkdir $(BUILD_DIR)
  111. cd $(BUILD_DIR)
  112. cmake -G "Visual Studio 16 2019" -Dsctp_build_shared_lib=0 -Dsctp_build_programs=0 ..
  113. msbuild usrsctplib.sln /property:Configuration=$(VARIANT)
  114. cd %OLDD%
  115. cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/Release/usrsctp.lib $(<)
  116. }
  117. make libjuice-gnutls.a : : @make_libjuice_gnutls ;
  118. make libjuice-openssl.a : : @make_libjuice_openssl ;
  119. make juice-static.lib : : @make_libjuice_msvc ;
  120. rule make_libjuice_gnutls ( targets * : sources * : properties * )
  121. {
  122. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  123. BUILD_DIR on $(targets) = "build-gnutls-$(VARIANT)" ;
  124. CMAKEOPTS on $(targets) = "-DCMAKE_C_FLAGS=\"-fPIC\" -DCMAKE_BUILD_TYPE=$(VARIANT) -DUSE_NETTLE=1" ;
  125. }
  126. actions make_libjuice_gnutls
  127. {
  128. (cd $(CWD)/deps/libjuice && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(CMAKEOPTS) .. && make -j2 juice-static)
  129. cp $(CWD)/deps/libjuice/$(BUILD_DIR)/libjuice-static.a $(<)
  130. }
  131. rule make_libjuice_openssl ( targets * : sources * : properties * )
  132. {
  133. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  134. BUILD_DIR on $(targets) = "build-openssl-$(VARIANT)" ;
  135. CMAKEOPTS on $(targets) = "-DCMAKE_C_FLAGS=\"-fPIC\" -DCMAKE_BUILD_TYPE=$(VARIANT) -DUSE_NETTLE=0" ;
  136. local OPENSSL_INCLUDE = [ feature.get-values <openssl-include> : $(properties) ] ;
  137. if <target-os>darwin in $(properties) && $(OPENSSL_INCLUDE) = ""
  138. {
  139. # on macOS, default to pick up openssl from the homebrew installation
  140. # brew install openssl
  141. OPENSSL_INCLUDE = /opt/homebrew/opt/openssl /usr/local/opt/openssl/include ;
  142. }
  143. if $(OPENSSL_INCLUDE) != ""
  144. { CMAKEOPTS on $(targets) += " -DOPENSSL_ROOT_DIR=$(OPENSSL_INCLUDE)/.." ; }
  145. }
  146. actions make_libjuice_openssl
  147. {
  148. (cd $(CWD)/deps/libjuice && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(CMAKEOPTS) .. && make -j2 juice-static)
  149. cp $(CWD)/deps/libjuice/$(BUILD_DIR)/libjuice-static.a $(<)
  150. }
  151. rule make_libjuice_msvc ( targets * : sources * : properties * )
  152. {
  153. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  154. VARIANT on $(targets) = $(VARIANT) ;
  155. if <gnutls>on in $(properties)
  156. {
  157. BUILD_DIR on $(targets) += "build-gnutls-$(VARIANT)" ;
  158. CMAKEOPTS on $(targets) = "-DUSE_NETTLE=1" ;
  159. }
  160. else
  161. {
  162. BUILD_DIR on $(targets) += "build-openssl-$(VARIANT)" ;
  163. CMAKEOPTS on $(targets) = "-DUSE_NETTLE=0" ;
  164. }
  165. }
  166. actions make_libjuice_msvc
  167. {
  168. SET OLDD=%CD%
  169. cd $(CWD)/deps/libjuice
  170. mkdir $(BUILD_DIR)
  171. cd $(BUILD_DIR)
  172. cmake -G "Visual Studio 16 2019" $(CMAKEOPTS) ..
  173. msbuild libjuice.sln /property:Configuration=$(VARIANT)
  174. cd %OLDD%
  175. cp $(CWD)/deps/libjuice/$(BUILD_DIR)/Release/juice-static.lib $(<)
  176. }
  177. # the search path to pick up the openssl libraries from. This is the <search>
  178. # property of those libraries
  179. rule openssl-lib-path ( properties * )
  180. {
  181. local OPENSSL_LIB = [ feature.get-values <openssl-lib> : $(properties) ] ;
  182. if <target-os>darwin in $(properties) && $(OPENSSL_LIB) = ""
  183. {
  184. # on macOS, default to pick up openssl from the homebrew installation
  185. # brew install openssl
  186. OPENSSL_LIB = /opt/homebrew/opt/openssl/lib /usr/local/opt/openssl/lib ;
  187. }
  188. else if <target-os>windows in $(properties) && $(OPENSSL_LIB) = ""
  189. {
  190. # on windows, assume openssl is installed to c:\OpenSSL-Win32
  191. if <address-model>64 in $(properties)
  192. { OPENSSL_LIB = c:\\OpenSSL-Win64\\lib ; }
  193. else
  194. { OPENSSL_LIB = c:\\OpenSSL-Win32\\lib ; }
  195. }
  196. local result ;
  197. result += <search>$(OPENSSL_LIB) ;
  198. return $(result) ;
  199. }
  200. # the include path to pick up openssl headers from. This is the
  201. # usage-requirement for the openssl-related libraries
  202. rule openssl-include-path ( properties * )
  203. {
  204. local OPENSSL_INCLUDE = [ feature.get-values <openssl-include> : $(properties) ] ;
  205. if <target-os>darwin in $(properties) && $(OPENSSL_INCLUDE) = ""
  206. {
  207. # on macOS, default to pick up openssl from the homebrew installation
  208. # brew install openssl
  209. OPENSSL_INCLUDE = /opt/homebrew/opt/openssl/include /usr/local/opt/openssl/include ;
  210. }
  211. else if <target-os>windows in $(properties) && $(OPENSSL_INCLUDE) = ""
  212. {
  213. # on windows, assume openssl is installed to c:\OpenSSL-Win32
  214. if <address-model>64 in $(properties)
  215. { OPENSSL_INCLUDE = c:\\OpenSSL-Win64\\include ; }
  216. else
  217. { OPENSSL_INCLUDE = c:\\OpenSSL-Win32\\include ; }
  218. }
  219. local result ;
  220. result += <include>$(OPENSSL_INCLUDE) ;
  221. return $(result) ;
  222. }
  223. # libraries for OpenSSL on Windows
  224. lib advapi32 : : <name>advapi32 ;
  225. lib user32 : : <name>user32 ;
  226. lib shell32 : : <name>shell32 ;
  227. lib gdi32 : : <name>gdi32 ;
  228. lib bcrypt : : <name>bcrypt ;
  229. lib z : : <link>shared <name>z ;
  230. alias ssl-deps : advapi32 user32 shell32 gdi32 ;
  231. # OpenSSL on Windows
  232. lib crypto : ssl-deps : <toolset>msvc <openssl-version>1.1 <name>libcrypto
  233. <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
  234. lib ssl : ssl-deps : <toolset>msvc <openssl-version>1.1 <name>libssl <use>crypto
  235. <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
  236. # OpenSSL on other platforms
  237. lib crypto : : <name>crypto <use>z <conditional>@openssl-lib-path : :
  238. <conditional>@openssl-include-path ;
  239. lib ssl : : <name>ssl <use>crypto <conditional>@openssl-lib-path : :
  240. <conditional>@openssl-include-path ;
  241. # GnuTLS
  242. lib gnutls : : <link>shared <name>gnutls ;
  243. lib nettle : : <link>shared <name>nettle ;