Jamfile.v2 13.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
#
#          Copyright Andrey Semashev 2007 - 2020.
# Distributed under the Boost Software License, Version 1.0.
#    (See accompanying file LICENSE_1_0.txt or copy at
#          http://www.boost.org/LICENSE_1_0.txt)
#

import common ;
import modules ;
import os ;
import path ;
import project ;
import feature ;
import configure ;
import log-arch-config ;
import log-platform-config ;
using mc ;

local here = [ modules.binding $(__name__) ] ;

project.push-current [ project.current ] ;
project.load [ path.join [ path.make $(here:D) ] ../config/message-compiler ] ;
project.load [ path.join [ path.make $(here:D) ] ../config/x86-ext ] ;
project.load [ path.join [ path.make $(here:D) ] ../config/pthread-mutex-robust ] ;
project.load [ path.join [ path.make $(here:D) ] ../config/native-syslog ] ;
project.load [ path.join [ path.make $(here:D) ] ../config/atomic-int32 ] ;
project.pop-current ;

# Windows libs
lib psapi ;
lib advapi32 ;
lib secur32 ;
lib ws2_32 ;
lib mswsock ;
explicit psapi advapi32 secur32 ws2_32 mswsock ;

# UNIX libs
lib rt ;
lib socket ;
lib nsl ;
lib ipv6 ;
explicit rt socket nsl ipv6 ;

rule has-config-flag ( flag : properties * )
{
    if ( "<define>$(flag)" in $(properties) || "<define>$(flag)=1" in $(properties) )
    {
        return 1 ;
    }
    else
    {
        return ;
    }
}

rule check-instruction-set ( properties * )
{
    local result ;
    local instruction_set = [ log-arch-config.deduce-instruction-set $(properties) ] ;

    if $(instruction_set) = i386 || $(instruction_set) = i486
    {
        if ! $(.annouced-failure)
        {
            ECHO Boost.Log is not supported on the specified target CPU and will not be built. At least i586 class CPU is required. ;
            .annouced-failure = 1 ;
        }
        result = <build>no ;
    }

    return $(result) ;
}

rule select-regex-backend ( properties * )
{
    local result ;

    # Use Boost.Regex backend by default. It produces smaller executables and also has the best performance for small string matching.
    if ! (
        [ has-config-flag BOOST_LOG_WITHOUT_SETTINGS_PARSERS : $(properties) ] ||
        [ has-config-flag BOOST_LOG_WITHOUT_DEFAULT_FACTORIES : $(properties) ] ||
        [ has-config-flag BOOST_LOG_USE_STD_REGEX : $(properties) ] ||
        [ has-config-flag BOOST_LOG_USE_BOOST_XPRESSIVE : $(properties) ] )
    {
        result = <library>/boost/regex//boost_regex ;
    }

    return $(result) ;
}

rule check-pthread-mutex-robust ( properties * )
{
    local result ;

    local has_pthread_mutex_robust = [ configure.builds /boost/log/pthread-mutex-robust//pthread_mutex_robust : $(properties) : "pthread supports robust mutexes" ] ;
    if $(has_pthread_mutex_robust)
    {
        result = <define>BOOST_LOG_HAS_PTHREAD_MUTEX_ROBUST ;
    }

    return $(result) ;
}

rule check-atomic-int32 ( properties * )
{
    local result ;

    local has_atomic_int32 = [ configure.builds /boost/log/atomic-int32//atomic_int32 : $(properties) : "native atomic int32 supported" ] ;
    if ! $(has_atomic_int32)
    {
        result = <define>BOOST_LOG_WITHOUT_IPC ;
    }

    return $(result) ;
}

rule check-native-syslog ( properties * )
{
    local result ;

    if ! [ has-config-flag BOOST_LOG_WITHOUT_SYSLOG : $(properties) ]
    {
        local has_native_syslog = [ configure.builds /boost/log/native-syslog//native_syslog : $(properties) : "native syslog supported" ] ;
        if $(has_native_syslog)
        {
            result = <define>BOOST_LOG_USE_NATIVE_SYSLOG ;
        }
    }

    return $(result) ;
}

rule check-message-compiler ( properties * )
{
    local result ;

    if <target-os>windows in $(properties)
    {
        if ! [ has-config-flag BOOST_LOG_WITHOUT_EVENT_LOG : $(properties) ]
        {
            local has_mc = [ configure.builds /boost/log/message-compiler//test-availability : $(properties) : "has message compiler" ] ;
            if ! $(has_mc)
            {
                result = <define>BOOST_LOG_WITHOUT_EVENT_LOG ;
            }
        }
        else
        {
            # This branch is needed to fix building with MinGW
            result = <define>BOOST_LOG_WITHOUT_EVENT_LOG ;
        }
    }
    else
    {
        result = <define>BOOST_LOG_WITHOUT_EVENT_LOG ;
    }

    return $(result) ;
}

project boost/log
    : source-location ../src
    : requirements
        <conditional>@check-instruction-set
        <conditional>@check-atomic-int32
        <conditional>@select-regex-backend
        <conditional>@check-pthread-mutex-robust
        <conditional>@check-native-syslog
        <conditional>@check-message-compiler
        <conditional>@log-platform-config.set-platform-defines

        <include>../src

        <define>__STDC_CONSTANT_MACROS # Use system-defined macros for integer constants, if possible
        <define>BOOST_SPIRIT_USE_PHOENIX_V3=1
        <define>BOOST_THREAD_DONT_USE_CHRONO=1 # Don't introduce false dependency on Boost.Chrono

        <c++-template-depth>1024

        <toolset>msvc:<cxxflags>/bigobj
        <toolset>msvc:<cxxflags>/wd4503 # decorated name length exceeded, name was truncated
        <toolset>msvc:<cxxflags>/wd4456 # declaration of 'A' hides previous local declaration
        <toolset>msvc:<cxxflags>/wd4459 # declaration of 'A' hides global declaration
        <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

        # Disable Intel warnings:
        # warning #177: function "X" was declared but never referenced
        # warning #780: using-declaration ignored -- it refers to the current namespace
        # warning #2196: routine is both "inline" and "noinline"
        # remark #1782: #pragma once is obsolete. Use #ifndef guard instead.
        # remark #193: zero used for undefined preprocessing identifier "X"
        # remark #304: access control not specified ("public" by default)
        # remark #981: operands are evaluated in unspecified order
        # remark #1418: external function definition with no prior declaration
        # Mostly comes from Boost.Phoenix: warning #411: class "X" defines no constructor to initialize the following: reference member "Y"...
        # warning #734: "X" (declared at line N of "file.hpp"), required for copy that was eliminated, is inaccessible
        # warning #279: controlling expression is constant
        <toolset>intel-win:<cxxflags>"/Qwd177,780,2196,1782,193,304,981,1418,411,734,279"
        <toolset>intel-linux:<cxxflags>"-wd177,780,2196,1782,193,304,981,1418,411,734,279"
        <toolset>intel-darwin:<cxxflags>"-wd177,780,2196,1782,193,304,981,1418,411,734,279"

        <toolset>gcc:<cxxflags>-fno-strict-aliasing  # avoids strict aliasing violations in other Boost components
        <toolset>gcc,<target-os>windows:<linkflags>-Wl,--enable-auto-import
        <toolset>gcc,<target-os>cygwin:<linkflags>-Wl,--enable-auto-import

        <library>/boost/filesystem//boost_filesystem
        <threading>single:<define>BOOST_LOG_NO_THREADS
        <threading>multi:<library>/boost/atomic//boost_atomic
        <threading>multi:<library>/boost/thread//boost_thread

        <target-os>windows:<define>BOOST_USE_WINDOWS_H
        <target-os>windows:<library>ws2_32
        <target-os>windows:<library>mswsock
        <target-os>windows:<library>advapi32

        <target-os>cygwin:<define>BOOST_USE_WINDOWS_H
        # Boost.Interprocess does not compile on Cygwin: https://github.com/boostorg/interprocess/issues/76
        <target-os>cygwin:<define>BOOST_LOG_WITHOUT_IPC
        <target-os>cygwin:<library>ws2_32
        <target-os>cygwin:<library>mswsock
        <target-os>cygwin:<library>advapi32

        <target-os>linux:<library>rt

        <target-os>solaris:<library>socket
        <target-os>solaris:<library>nsl

        <target-os>hpux:<library>ipv6

        <target-os>freebsd:<library>rt
        <target-os>qnxnto:<library>socket
        <toolset>pgi:<library>rt
    : usage-requirements
        <toolset>clang:<cxxflags>-Wno-bind-to-temporary-copy
        <toolset>clang:<cxxflags>-Wno-unused-function
    ;

local BOOST_LOG_COMMON_SRC =
    attribute_name.cpp
    attribute_set.cpp
    attribute_value_set.cpp
    code_conversion.cpp
    core.cpp
    record_ostream.cpp
    severity_level.cpp
    global_logger_storage.cpp
    named_scope.cpp
    process_name.cpp
    process_id.cpp
    thread_id.cpp
    timer.cpp
    exceptions.cpp
    default_attribute_names.cpp
    default_sink.cpp
    text_ostream_backend.cpp
    text_file_backend.cpp
    text_multifile_backend.cpp
    thread_specific.cpp
    once_block.cpp
    timestamp.cpp
    threadsafe_queue.cpp
    event.cpp
    trivial.cpp
    spirit_encoding.cpp
    format_parser.cpp
    date_time_format_parser.cpp
    named_scope_format_parser.cpp
    permissions.cpp
    dump.cpp
    ;

BOOST_LOG_COMMON_SSSE3_SRC =
    dump_ssse3
    ;

BOOST_LOG_COMMON_AVX2_SRC =
    dump_avx2
    ;

for local src in $(BOOST_LOG_COMMON_SSSE3_SRC)
{
    obj $(src)
        : ## sources ##
            $(src).cpp
        : ## requirements ##
            <conditional>@log-arch-config.ssse3-flags
            <link>shared:<define>BOOST_LOG_DLL
            <define>BOOST_LOG_BUILDING_THE_LIB=1
        : ## default-build ##
        : ## usage-requirements ##
            <define>BOOST_LOG_USE_SSSE3
        ;

    explicit $(src) ;
}

for local src in $(BOOST_LOG_COMMON_AVX2_SRC)
{
    obj $(src)
        : ## sources ##
            $(src).cpp
        : ## requirements ##
            <conditional>@log-arch-config.avx2-flags
            <link>shared:<define>BOOST_LOG_DLL
            <define>BOOST_LOG_BUILDING_THE_LIB=1
        : ## default-build ##
        : ## usage-requirements ##
            <define>BOOST_LOG_USE_AVX2
        ;

    explicit $(src) ;
}

rule select-arch-specific-sources ( properties * )
{
    local result ;

    if x86 in [ log-arch-config.deduce-architecture $(properties) ]
    {
        local has_ssse3 = [ configure.builds /boost/log/x86-extensions//ssse3 : $(properties) : "compiler supports SSSE3" ] ;
        if $(has_ssse3)
        {
            result += <define>BOOST_LOG_USE_SSSE3 ;
            result += <source>$(BOOST_LOG_COMMON_SSSE3_SRC) ;
        }

        local has_avx2 = [ configure.builds /boost/log/x86-extensions//avx2 : $(properties) : "compiler supports AVX2" ] ;
        if $(has_avx2)
        {
            result += <define>BOOST_LOG_USE_AVX2 ;
            result += <source>$(BOOST_LOG_COMMON_AVX2_SRC) ;
        }
    }

#    ECHO Arch sources: $(result) ;

    return $(result) ;
}

rule select-platform-specific-sources ( properties * )
{
    local result ;

    if <target-os>windows in $(properties)
    {
        result += <source>windows/light_rw_mutex.cpp ;
        result += <source>windows/is_debugger_present.cpp ;

        if ! [ has-config-flag BOOST_LOG_WITHOUT_IPC : $(properties) ]
        {
            result += <source>windows/object_name.cpp ;
            result += <source>windows/mapped_shared_memory.cpp ;
            result += <source>windows/ipc_sync_wrappers.cpp ;
            result += <source>windows/ipc_reliable_message_queue.cpp ;
            result += <library>secur32 ;
        }

        if ! [ has-config-flag BOOST_LOG_WITHOUT_DEBUG_OUTPUT : $(properties) ]
        {
            result += <source>windows/debug_output_backend.cpp ;
        }

        if ! [ has-config-flag BOOST_LOG_WITHOUT_EVENT_LOG : $(properties) ]
        {
            result += <source>windows/simple_event_log.mc ;
            result += <source>windows/event_log_backend.cpp ;
            result += <library>psapi ;

            DEPENDS windows/event_log_backend.cpp : windows/simple_event_log.mc ;
        }
    }
    else
    {
        result += <define>BOOST_LOG_WITHOUT_EVENT_LOG ;
        result += <define>BOOST_LOG_WITHOUT_DEBUG_OUTPUT ;

        if ! [ has-config-flag BOOST_LOG_WITHOUT_IPC : $(properties) ]
        {
            result += <source>posix/object_name.cpp ;
            result += <source>posix/ipc_reliable_message_queue.cpp ;
        }
    }

    if ! [ has-config-flag BOOST_LOG_WITHOUT_SYSLOG : $(properties) ]
    {
        result += <source>syslog_backend.cpp ;
    }

#    ECHO Platform sources: $(result) ;

    return $(result) ;
}

lib boost_log
    : ## sources ##
        $(BOOST_LOG_COMMON_SRC)
    : ## requirements ##
        <conditional>@select-arch-specific-sources
        <conditional>@select-platform-specific-sources
        <link>shared:<define>BOOST_LOG_DLL
        <define>BOOST_LOG_BUILDING_THE_LIB=1
    : ## default-build ##
    : ## usage-requirements ##
        <link>shared:<define>BOOST_LOG_DYN_LINK=1
        <threading>single:<define>BOOST_LOG_NO_THREADS
    ;


local BOOST_LOG_SETUP_COMMON_SRC =
    parser_utils.cpp
    init_from_stream.cpp
    init_from_settings.cpp
    settings_parser.cpp
    filter_parser.cpp
    formatter_parser.cpp
    default_filter_factory.cpp
    matches_relation_factory.cpp
    default_formatter_factory.cpp
    ;

lib boost_log_setup
    : ## sources ##
        setup/$(BOOST_LOG_SETUP_COMMON_SRC)
    : ## requirements ##
        <link>shared:<define>BOOST_LOG_DYN_LINK=1
        <link>shared:<define>BOOST_LOG_SETUP_DLL
        <define>BOOST_LOG_SETUP_BUILDING_THE_LIB=1
        <library>boost_log
    : ## default-build ##
    : ## usage-requirements ##
        <link>shared:<define>BOOST_LOG_SETUP_DYN_LINK=1
        <threading>single:<define>BOOST_LOG_NO_THREADS
    ;

boost-install boost_log boost_log_setup ;