⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 project.jam

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 JAM
📖 第 1 页 / 共 3 页
字号:
{    .current-project = $(.saved-current-project[-1]) ;    .saved-current-project = $(.saved-current-project[1--2]) ;}# Returns the project-attribute instance for the specified Jamfile module.#rule attributes ( project ){    return $($(project).attributes) ;}# Returns the value of the specified attribute in the specified Jamfile module.#rule attribute ( project attribute ){    return [ $($(project).attributes).get $(attribute) ] ;}# Returns the project target corresponding to the 'project-module'.#rule target ( project-module ){    if ! $(.target.$(project-module))    {        .target.$(project-module) = [ new project-target $(project-module)            : $(project-module)            : [ attribute $(project-module) requirements ] ] ;    }    return $(.target.$(project-module)) ;}# Use/load a project.#rule use ( id : location ){    local saved-project = $(.current-project) ;    local project-module = [ project.load $(location) ] ;    local declared-id = [ project.attribute $(project-module) id ] ;    if ! $(declared-id) || $(declared-id) != $(id)    {        # The project at 'location' either has no id or that id is not equal to        # the 'id' parameter.        if $($(id).jamfile-module) && ( $($(id).jamfile-module) !=            $(project-module) )        {            errors.user-error Attempt to redeclare already existing project id                '$(id)' ;        }        $(id).jamfile-module = $(project-module) ;    }    .current-project = $(saved-project) ;}# Defines a Boost.Build extension project. Such extensions usually contain# library targets and features that can be used by many people. Even though# extensions are really projects, they can be initialized as a module would be# with the "using" (project.project-rules.using) mechanism.#rule extension ( id : options * : * ){    # The caller is a standalone module for the extension.    local mod = [ CALLER_MODULE ] ;    # We need to do the rest within the extension module.    module $(mod)    {        import path ;        # Find the root project.        local root-project = [ project.current ] ;        root-project = [ $(root-project).project-module ] ;        while            [ project.attribute $(root-project) parent-module ] &&            [ project.attribute $(root-project) parent-module ] != user-config        {            root-project = [ project.attribute $(root-project) parent-module ] ;        }        # Create the project data, and bring in the project rules into the        # module.        project.initialize $(__name__) : [ path.join [ project.attribute            $(root-project) location ] ext $(1:L) ] ;        # Create the project itself, i.e. the attributes. All extensions are        # created in the "/ext" project space.        project /ext/$(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) :            $(9) ;        local attributes = [ project.attributes $(__name__) ] ;        # Inherit from the root project of whomever is defining us.        project.inherit-attributes $(__name__) : $(root-project) ;        $(attributes).set parent-module : $(root-project) : exact ;    }}rule glob-internal ( project : wildcards + : excludes * : rule-name ){    local location = [ $(project).get source-location ] ;    local result ;    local paths = [ path.$(rule-name) $(location) :        [ sequence.transform path.make : $(wildcards) ] :        [ sequence.transform path.make : $(excludes) ] ] ;    if $(wildcards:D) || $(rule-name) != glob    {        # The paths we have found are relative to the current directory, but the        # names specified in the sources list are assumed to be relative to the        # source directory of the corresponding project. So, just make the names        # absolute.        for local p in $(paths)        {            result += [ path.root $(p) [ path.pwd ] ] ;        }    }    else    {        # There were no wildcards in the directory path, so the files are all in        # the source directory of the project. Just drop the directory, instead        # of making paths absolute.        result = $(paths:D="") ;    }    return $(result) ;}# This module defines rules common to all projects.#module project-rules{    rule using ( toolset-module : * )    {        import toolset ;        import modules ;        import project ;        # Temporarily change the search path so the module referred to by        # 'using' can be placed in the same directory as Jamfile. User will        # expect the module to be found even though the directory is not in        # BOOST_BUILD_PATH.        local x = [ modules.peek : BOOST_BUILD_PATH ] ;        local caller = [ modules.binding $(__name__) ] ;        modules.poke : BOOST_BUILD_PATH : $(caller:D) $(x) ;        toolset.using $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;        modules.poke : BOOST_BUILD_PATH : $(x) ;        # The above might have clobbered .current-project. Restore the correct        # value.        modules.poke project : .current-project            : [ project.target $(__name__) ] ;    }    import modules ;    rule import ( * : * : * )    {        modules.import project ;        local caller = [ CALLER_MODULE ] ;        local saved = [ modules.peek project : .current-project ] ;        module $(caller)        {            modules.import $(1) : $(2) : $(3) ;        }        modules.poke project : .current-project : $(saved) ;    }    rule project ( id ? : options * : * )    {        import errors ;        import path ;        import project ;        local attributes = [ project.attributes $(__name__) ] ;        if $(id)        {           $(attributes).set id : $(id) ;        }        local explicit-build-dir ;        for n in 2 3 4 5 6 7 8 9        {            local option = $($(n)) ;            if $(option)            {                $(attributes).set $(option[1]) : $(option[2-]) ;            }            if $(option[1]) = "build-dir"            {                explicit-build-dir = [ path.make $(option[2-]) ] ;            }        }        # If '--build-dir' is specified, change the build dir for the project.        local global-build-dir =            [ modules.peek project : .global-build-dir ] ;        if $(global-build-dir)        {            local location = [ $(attributes).get location ] ;            # Project with an empty location is a 'standalone' project such as            # user-config or qt. It has no build dir. If we try to set build dir            # for user-config, we shall then try to inherit it, with either            # weird or wrong consequences.            if $(location) && $(location) = [ $(attributes).get project-root ]            {                # Re-read the project id, since it might have been changed in                # the project's attributes.                id = [ $(attributes).get id ] ;                # This is Jamroot.                if $(id)                {                    if $(explicit-build-dir) &&                        [ path.is-rooted $(explicit-build-dir) ]                    {                        errors.user-error Absolute directory specified via                            'build-dir' project attribute : Do not know how to                            combine that with the --build-dir option. ;                    }                    # Strip the leading slash from id.                    local rid = [ MATCH /(.*) : $(id) ] ;                    local p = [ path.join                        $(global-build-dir) $(rid) $(explicit-build-dir) ] ;                    $(attributes).set build-dir : $(p) : exact ;                }            }            else            {                # Not Jamroot.                if $(explicit-build-dir)                {                    errors.user-error When --build-dir is specified, the                        'build-dir' project : attribute is allowed only for                        top-level 'project' invocations ;                }            }        }    }    # Declare and set a project global constant. Project global constants are    # normal variables but should not be changed. They are applied to every    # child Jamfile.    #    rule constant (        name  # Variable name of the constant.        : value +  # Value of the constant.    )    {        import project ;        local p = [ project.target $(__name__) ] ;        $(p).add-constant $(name) : $(value) ;    }    # Declare and set a project global constant, whose value is a path. The path    # is adjusted to be relative to the invocation directory. The given value    # path is taken to be either absolute, or relative to this project root.    #    rule path-constant (        name  # Variable name of the constant.        : value +  # Value of the constant.        )    {        import project ;        local p = [ project.target $(__name__) ] ;        $(p).add-constant $(name) : $(value) : path ;    }    rule use-project ( id : where )    {        # See comment in 'load' for explanation.        .used-projects += $(id) $(where) ;    }    rule build-project ( dir )    {        import project ;        local attributes = [ project.attributes $(__name__) ] ;        local now = [ $(attributes).get projects-to-build ] ;        $(attributes).set projects-to-build : $(now) $(dir) ;    }    rule explicit ( target-names * )    {        import project ;        # If 'explicit' is used in a helper rule defined in Jamroot and        # inherited by children, then most of the time we want 'explicit' to        # operate on the Jamfile where the helper rule is invoked.        local t = [ project.current ] ;        for local n in $(target-names)        {            $(t).mark-target-as-explicit $(n) ;        }    }    rule glob ( wildcards + : excludes * )    {        import project ;        return [ project.glob-internal [ project.current ] : $(wildcards) :            $(excludes) : glob ] ;    }    rule glob-tree ( wildcards + : excludes * )    {        import project ;        if $(wildcards:D) || $(excludes:D)        {            errors.user-error The patterns to 'glob-tree' may not include                directory ;        }        return [ project.glob-internal [ project.current ] : $(wildcards) :            $(excludes) : glob-tree ] ;    }    # Calculates conditional requirements for multiple requirements at once.    # This is a shorthand to reduce duplication and to keep an inline    # declarative syntax. For example:    #    #   lib x : x.cpp : [ conditional <toolset>gcc <variant>debug :    #       <define>DEBUG_EXCEPTION <define>DEBUG_TRACE ] ;    #    rule conditional ( condition + : requirements * )    {        local condition = $(condition:J=,) ;        if [ MATCH (:) : $(condition) ]        {            return $(condition)$(requirements) ;        }        else        {            return $(condition):$(requirements) ;        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -