1# 2# Copyright Andrey Semashev 2007 - 2020. 3# Distributed under the Boost Software License, Version 1.0. 4# (See accompanying file LICENSE_1_0.txt or copy at 5# http://www.boost.org/LICENSE_1_0.txt) 6# 7 8import common ; 9import modules ; 10import os ; 11import path ; 12import project ; 13import feature ; 14import configure ; 15import log-architecture ; 16import log-platform-config ; 17using mc ; 18 19local here = [ modules.binding $(__name__) ] ; 20 21project.push-current [ project.current ] ; 22project.load [ path.join [ path.make $(here:D) ] ../config/message-compiler ] ; 23project.load [ path.join [ path.make $(here:D) ] ../config/x86-ext ] ; 24project.load [ path.join [ path.make $(here:D) ] ../config/pthread-mutex-robust ] ; 25project.load [ path.join [ path.make $(here:D) ] ../config/native-syslog ] ; 26project.load [ path.join [ path.make $(here:D) ] ../config/atomic-int32 ] ; 27project.pop-current ; 28 29# Windows libs 30lib psapi ; 31lib advapi32 ; 32lib secur32 ; 33lib ws2_32 ; 34lib mswsock ; 35explicit psapi advapi32 secur32 ws2_32 mswsock ; 36 37# UNIX libs 38lib rt ; 39lib socket ; 40lib nsl ; 41lib ipv6 ; 42explicit rt socket nsl ipv6 ; 43 44rule has-config-flag ( flag : properties * ) 45{ 46 if ( "<define>$(flag)" in $(properties) || "<define>$(flag)=1" in $(properties) ) 47 { 48 return 1 ; 49 } 50 else 51 { 52 return ; 53 } 54} 55 56rule check-instruction-set ( properties * ) 57{ 58 local result ; 59 local instruction_set = [ feature.get-values "log-instruction-set" : [ log-architecture.deduce-instruction-set $(properties) ] ] ; 60 61 if $(instruction_set) = i386 || $(instruction_set) = i486 62 { 63 if ! $(.annouced-failure) 64 { 65 ECHO Boost.Log is not supported on the specified target CPU and will not be built. At least i586 class CPU is required. ; 66 .annouced-failure = 1 ; 67 } 68 result = <build>no ; 69 } 70 71 return $(result) ; 72} 73 74rule select-regex-backend ( properties * ) 75{ 76 local result ; 77 78 # Use Boost.Regex backend by default. It produces smaller executables and also has the best performance for small string matching. 79 if ! ( 80 [ has-config-flag BOOST_LOG_WITHOUT_SETTINGS_PARSERS : $(properties) ] || 81 [ has-config-flag BOOST_LOG_WITHOUT_DEFAULT_FACTORIES : $(properties) ] || 82 [ has-config-flag BOOST_LOG_USE_STD_REGEX : $(properties) ] || 83 [ has-config-flag BOOST_LOG_USE_BOOST_XPRESSIVE : $(properties) ] ) 84 { 85 result = <library>/boost/regex//boost_regex ; 86 } 87 88 return $(result) ; 89} 90 91rule check-pthread-mutex-robust ( properties * ) 92{ 93 local result ; 94 95 local has_pthread_mutex_robust = [ configure.builds /boost/log/pthread-mutex-robust//pthread_mutex_robust : $(properties) : pthread-supports-robust-mutexes ] ; 96 if $(has_pthread_mutex_robust) 97 { 98 result = <define>BOOST_LOG_HAS_PTHREAD_MUTEX_ROBUST ; 99 } 100 101 return $(result) ; 102} 103 104rule check-atomic-int32 ( properties * ) 105{ 106 local result ; 107 108 local has_atomic_int32 = [ configure.builds /boost/log/atomic-int32//atomic_int32 : $(properties) : native-atomic-int32-supported ] ; 109 if ! $(has_atomic_int32) 110 { 111 result = <define>BOOST_LOG_WITHOUT_IPC ; 112 } 113 114 return $(result) ; 115} 116 117rule check-native-syslog ( properties * ) 118{ 119 local result ; 120 121 if ! [ has-config-flag BOOST_LOG_WITHOUT_SYSLOG : $(properties) ] 122 { 123 local has_native_syslog = [ configure.builds /boost/log/native-syslog//native_syslog : $(properties) : native-syslog-supported ] ; 124 if $(has_native_syslog) 125 { 126 result = <define>BOOST_LOG_USE_NATIVE_SYSLOG ; 127 } 128 } 129 130 return $(result) ; 131} 132 133rule check-message-compiler ( properties * ) 134{ 135 local result ; 136 137 if <target-os>windows in $(properties) 138 { 139 if ! [ has-config-flag BOOST_LOG_WITHOUT_EVENT_LOG : $(properties) ] 140 { 141 local has_mc = [ configure.builds /boost/log/message-compiler//test-availability : $(properties) : message-compiler ] ; 142 if ! $(has_mc) 143 { 144 result = <define>BOOST_LOG_WITHOUT_EVENT_LOG ; 145 } 146 } 147 else 148 { 149 # This branch is needed to fix building with MinGW 150 result = <define>BOOST_LOG_WITHOUT_EVENT_LOG ; 151 } 152 } 153 else 154 { 155 result = <define>BOOST_LOG_WITHOUT_EVENT_LOG ; 156 } 157 158 return $(result) ; 159} 160 161project boost/log 162 : source-location ../src 163 : requirements 164 <conditional>@check-instruction-set 165 <conditional>@check-atomic-int32 166 <conditional>@select-regex-backend 167 <conditional>@check-pthread-mutex-robust 168 <conditional>@check-native-syslog 169 <conditional>@check-message-compiler 170 <conditional>@log-platform-config.set-platform-defines 171 172 <include>../src 173 174 <define>__STDC_CONSTANT_MACROS # Use system-defined macros for integer constants, if possible 175 <define>BOOST_SPIRIT_USE_PHOENIX_V3=1 176 <define>BOOST_THREAD_DONT_USE_CHRONO=1 # Don't introduce false dependency on Boost.Chrono 177 178 # Disable warnings about using 'insecure' standard C functions 179 <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS 180 <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE 181 <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS 182 <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE 183 <toolset>intel-win:<define>_SCL_SECURE_NO_WARNINGS 184 <toolset>intel-win:<define>_SCL_SECURE_NO_DEPRECATE 185 <toolset>intel-win:<define>_CRT_SECURE_NO_WARNINGS 186 <toolset>intel-win:<define>_CRT_SECURE_NO_DEPRECATE 187 188 <toolset>msvc:<cxxflags>/bigobj 189 <toolset>msvc:<cxxflags>/wd4503 # decorated name length exceeded, name was truncated 190 <toolset>msvc:<cxxflags>/wd4456 # declaration of 'A' hides previous local declaration 191 <toolset>msvc:<cxxflags>/wd4459 # declaration of 'A' hides global declaration 192 <toolset>msvc:<cxxflags>/wd4003 # not enough actual parameters for macro 'X' - caused by BOOST_PP_IS_EMPTY and BOOST_PP_IS_BEGIN_PARENS which are used by Fusion 193 194 # Disable Intel warnings: 195 # warning #177: function "X" was declared but never referenced 196 # warning #780: using-declaration ignored -- it refers to the current namespace 197 # warning #2196: routine is both "inline" and "noinline" 198 # remark #1782: #pragma once is obsolete. Use #ifndef guard instead. 199 # remark #193: zero used for undefined preprocessing identifier "X" 200 # remark #304: access control not specified ("public" by default) 201 # remark #981: operands are evaluated in unspecified order 202 # remark #1418: external function definition with no prior declaration 203 # Mostly comes from Boost.Phoenix: warning #411: class "X" defines no constructor to initialize the following: reference member "Y"... 204 # warning #734: "X" (declared at line N of "file.hpp"), required for copy that was eliminated, is inaccessible 205 # warning #279: controlling expression is constant 206 <toolset>intel-win:<cxxflags>"/Qwd177,780,2196,1782,193,304,981,1418,411,734,279" 207 <toolset>intel-linux:<cxxflags>"-wd177,780,2196,1782,193,304,981,1418,411,734,279" 208 <toolset>intel-darwin:<cxxflags>"-wd177,780,2196,1782,193,304,981,1418,411,734,279" 209 210 <toolset>darwin:<cxxflags>-ftemplate-depth-1024 211 <toolset>clang:<cxxflags>-ftemplate-depth-1024 212 <toolset>gcc:<cxxflags>-ftemplate-depth-1024 213 214 <toolset>gcc:<cxxflags>-fno-strict-aliasing # avoids strict aliasing violations in other Boost components 215 <toolset>gcc,<target-os>windows:<linkflags>-Wl,--enable-auto-import 216 <toolset>gcc,<target-os>cygwin:<linkflags>-Wl,--enable-auto-import 217 218 <library>/boost/filesystem//boost_filesystem 219 <threading>single:<define>BOOST_LOG_NO_THREADS 220 <threading>multi:<library>/boost/atomic//boost_atomic 221 <threading>multi:<library>/boost/thread//boost_thread 222 223 <target-os>windows:<library>ws2_32 224 <target-os>windows:<library>mswsock 225 <target-os>windows:<library>advapi32 226 227 <target-os>cygwin:<library>ws2_32 228 <target-os>cygwin:<library>mswsock 229 <target-os>cygwin:<library>advapi32 230 # Boost.Interprocess does not compile on Cygwin: https://github.com/boostorg/interprocess/issues/76 231 <target-os>cygwin:<define>BOOST_LOG_WITHOUT_IPC 232 233 <target-os>linux:<library>rt 234 235 <target-os>solaris:<library>socket 236 <target-os>solaris:<library>nsl 237 238 <target-os>hpux:<library>ipv6 239 240 <target-os>freebsd:<library>rt 241 <target-os>qnxnto:<library>socket 242 <toolset>pgi:<library>rt 243 : usage-requirements 244 <toolset>clang:<cxxflags>-Wno-bind-to-temporary-copy 245 <toolset>clang:<cxxflags>-Wno-unused-function 246 ; 247 248local BOOST_LOG_COMMON_SRC = 249 attribute_name.cpp 250 attribute_set.cpp 251 attribute_value_set.cpp 252 code_conversion.cpp 253 core.cpp 254 record_ostream.cpp 255 severity_level.cpp 256 global_logger_storage.cpp 257 named_scope.cpp 258 process_name.cpp 259 process_id.cpp 260 thread_id.cpp 261 timer.cpp 262 exceptions.cpp 263 default_attribute_names.cpp 264 default_sink.cpp 265 text_ostream_backend.cpp 266 text_file_backend.cpp 267 text_multifile_backend.cpp 268 thread_specific.cpp 269 once_block.cpp 270 timestamp.cpp 271 threadsafe_queue.cpp 272 event.cpp 273 trivial.cpp 274 spirit_encoding.cpp 275 format_parser.cpp 276 date_time_format_parser.cpp 277 named_scope_format_parser.cpp 278 permissions.cpp 279 dump.cpp 280 ; 281 282BOOST_LOG_COMMON_SSSE3_SRC = 283 dump_ssse3 284 ; 285 286BOOST_LOG_COMMON_AVX2_SRC = 287 dump_avx2 288 ; 289 290rule ssse3-targets-cond ( properties * ) 291{ 292 local result = <build>no ; 293 294 if <log-architecture>x86 in [ log-architecture.deduce-architecture $(properties) ] 295 { 296 local has_ssse3 = [ configure.builds /boost/log/x86-extensions//ssse3 : $(properties) : compiler-supports-ssse3 ] ; 297 if $(has_ssse3) 298 { 299 result = ; 300 if <toolset>gcc in $(properties) || <toolset>clang in $(properties) 301 { 302 result = <cxxflags>"-msse -msse2 -msse3 -mssse3" ; 303 } 304 else if <toolset>intel in $(properties) 305 { 306 if <toolset-intel:platform>win in $(properties) 307 { 308 result = <cxxflags>"/QxSSSE3" ; 309 } 310 else 311 { 312 result = <cxxflags>"-xSSSE3" ; 313 } 314 } 315 else if <toolset>msvc in $(properties) 316 { 317 # MSVC doesn't really care about these switches, all SSE intrinsics are always available, but still... 318 # Also 64 bit MSVC doesn't have the /arch:SSE2 switch as it is the default. 319 if <log-address-model>32 in [ log-architecture.deduce-address-model $(properties) ] 320 { 321 result = <cxxflags>"/arch:SSE2" ; 322 } 323 } 324 } 325 } 326 327# if ! <build>no in $(result) 328# { 329# ECHO Boost.Log: Using SSSE3 optimized implementation ; 330# } 331# ECHO $(result) ; 332 333 return $(result) ; 334} 335 336for local src in $(BOOST_LOG_COMMON_SSSE3_SRC) 337{ 338 obj $(src) 339 : ## sources ## 340 $(src).cpp 341 : ## requirements ## 342 <conditional>@ssse3-targets-cond 343 <link>shared:<define>BOOST_LOG_DLL 344 <define>BOOST_LOG_BUILDING_THE_LIB=1 345 : ## default-build ## 346 : ## usage-requirements ## 347 <define>BOOST_LOG_USE_SSSE3 348 ; 349 350 explicit $(src) ; 351} 352 353rule avx2-targets-cond ( properties * ) 354{ 355 local result = <build>no ; 356 357 if <log-architecture>x86 in [ log-architecture.deduce-architecture $(properties) ] 358 { 359 local has_avx2 = [ configure.builds /boost/log/x86-extensions//avx2 : $(properties) : compiler-supports-avx2 ] ; 360 if $(has_avx2) 361 { 362 result = ; 363 if <toolset>gcc in $(properties) 364 { 365 result = <cxxflags>"-mavx -mavx2 -fabi-version=0" ; 366 } 367 else if <toolset>clang in $(properties) 368 { 369 result = <cxxflags>"-mavx -mavx2" ; 370 } 371 else if <toolset>intel in $(properties) 372 { 373 if <toolset-intel:platform>win in $(properties) 374 { 375 result = <cxxflags>"/arch:CORE-AVX2" ; 376 } 377 else 378 { 379 result = <cxxflags>"-xCORE-AVX2 -fabi-version=0" ; 380 } 381 } 382 else if <toolset>msvc in $(properties) 383 { 384 result = <cxxflags>"/arch:AVX" ; 385 } 386 } 387 } 388 389# if ! <build>no in $(result) 390# { 391# ECHO Boost.Log: Using AVX2 optimized implementation ; 392# } 393# ECHO $(result) ; 394 395 return $(result) ; 396} 397 398for local src in $(BOOST_LOG_COMMON_AVX2_SRC) 399{ 400 obj $(src) 401 : ## sources ## 402 $(src).cpp 403 : ## requirements ## 404 <conditional>@avx2-targets-cond 405 <link>shared:<define>BOOST_LOG_DLL 406 <define>BOOST_LOG_BUILDING_THE_LIB=1 407 : ## default-build ## 408 : ## usage-requirements ## 409 <define>BOOST_LOG_USE_AVX2 410 ; 411 412 explicit $(src) ; 413} 414 415rule select-arch-specific-sources ( properties * ) 416{ 417 local result ; 418 419 if <log-architecture>x86 in [ log-architecture.deduce-architecture $(properties) ] 420 { 421 local has_ssse3 = [ configure.builds /boost/log/x86-extensions//ssse3 : $(properties) : compiler-supports-ssse3 ] ; 422 if $(has_ssse3) 423 { 424 result += <define>BOOST_LOG_USE_SSSE3 ; 425 result += <source>$(BOOST_LOG_COMMON_SSSE3_SRC) ; 426 } 427 428 local has_avx2 = [ configure.builds /boost/log/x86-extensions//avx2 : $(properties) : compiler-supports-avx2 ] ; 429 if $(has_avx2) 430 { 431 result += <define>BOOST_LOG_USE_AVX2 ; 432 result += <source>$(BOOST_LOG_COMMON_AVX2_SRC) ; 433 } 434 } 435 436# ECHO Arch sources: $(result) ; 437 438 return $(result) ; 439} 440 441rule select-platform-specific-sources ( properties * ) 442{ 443 local result ; 444 445 if <target-os>windows in $(properties) 446 { 447 result += <source>windows/light_rw_mutex.cpp ; 448 449 if ! [ has-config-flag BOOST_LOG_WITHOUT_IPC : $(properties) ] 450 { 451 result += <source>windows/object_name.cpp ; 452 result += <source>windows/mapped_shared_memory.cpp ; 453 result += <source>windows/ipc_sync_wrappers.cpp ; 454 result += <source>windows/ipc_reliable_message_queue.cpp ; 455 result += <library>secur32 ; 456 } 457 458 if ! [ has-config-flag BOOST_LOG_WITHOUT_DEBUG_OUTPUT : $(properties) ] 459 { 460 result += <source>windows/debug_output_backend.cpp ; 461 } 462 463 if ! [ has-config-flag BOOST_LOG_WITHOUT_EVENT_LOG : $(properties) ] 464 { 465 result += <source>windows/simple_event_log.mc ; 466 result += <source>windows/event_log_backend.cpp ; 467 result += <library>psapi ; 468 469 DEPENDS windows/event_log_backend.cpp : windows/simple_event_log.mc ; 470 } 471 } 472 else 473 { 474 result += <define>BOOST_LOG_WITHOUT_EVENT_LOG ; 475 result += <define>BOOST_LOG_WITHOUT_DEBUG_OUTPUT ; 476 477 if ! [ has-config-flag BOOST_LOG_WITHOUT_IPC : $(properties) ] 478 { 479 result += <source>posix/object_name.cpp ; 480 result += <source>posix/ipc_reliable_message_queue.cpp ; 481 } 482 } 483 484 if ! [ has-config-flag BOOST_LOG_WITHOUT_SYSLOG : $(properties) ] 485 { 486 result += <source>syslog_backend.cpp ; 487 } 488 489# ECHO Platform sources: $(result) ; 490 491 return $(result) ; 492} 493 494lib boost_log 495 : ## sources ## 496 $(BOOST_LOG_COMMON_SRC) 497 : ## requirements ## 498 <conditional>@select-arch-specific-sources 499 <conditional>@select-platform-specific-sources 500 <link>shared:<define>BOOST_LOG_DLL 501 <define>BOOST_LOG_BUILDING_THE_LIB=1 502 : ## default-build ## 503 : ## usage-requirements ## 504 <link>shared:<define>BOOST_LOG_DYN_LINK=1 505 <threading>single:<define>BOOST_LOG_NO_THREADS 506 ; 507 508 509local BOOST_LOG_SETUP_COMMON_SRC = 510 parser_utils.cpp 511 init_from_stream.cpp 512 init_from_settings.cpp 513 settings_parser.cpp 514 filter_parser.cpp 515 formatter_parser.cpp 516 default_filter_factory.cpp 517 matches_relation_factory.cpp 518 default_formatter_factory.cpp 519 ; 520 521lib boost_log_setup 522 : ## sources ## 523 setup/$(BOOST_LOG_SETUP_COMMON_SRC) 524 : ## requirements ## 525 <link>shared:<define>BOOST_LOG_DYN_LINK=1 526 <link>shared:<define>BOOST_LOG_SETUP_DLL 527 <define>BOOST_LOG_SETUP_BUILDING_THE_LIB=1 528 <library>boost_log 529 : ## default-build ## 530 : ## usage-requirements ## 531 <link>shared:<define>BOOST_LOG_SETUP_DYN_LINK=1 532 <threading>single:<define>BOOST_LOG_NO_THREADS 533 ; 534 535boost-install boost_log boost_log_setup ; 536