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

📄 project.jam

📁 boost库提供标准的C++ API 配合dev c++使用,功能更加强大
💻 JAM
📖 第 1 页 / 共 2 页
字号:
        inherit-attributes $(module-name) : $(project-root-module) : $(parent-module) ;
    }    
}

# Make 'project-module' inherit attributes of project root and parent module.
rule inherit-attributes ( project-module : project-root-module : parent-module ? )
{
    # Register with the project root. This will inject project-root
    # constants and do some other initialization.
    $(project-root-module).project-root register-project $(project-module) ;

    if $(parent-module)
    {
        local attributes = $($(project-module).attributes) ;        
        local pattributes = [ attributes $(parent-module) ] ;
        $(attributes).set parent : [ path.parent 
            [ path.make [ modules.binding $(parent-module) ] ] ] ;
        $(attributes).set default-build 
            : [ $(pattributes).get default-build ] ;
        $(attributes).set requirements
            : [ $(pattributes).get requirements ] : exact ;
        $(attributes).set usage-requirements
            : [ $(pattributes).get usage-requirements ] : exact ;
        local parent-build-dir = [ $(pattributes).get build-dir ] ;
        if $(parent-build-dir)
        {            
            # Have to compute relative path from parent dir to our dir
            # Convert both paths to absolute, since we cannot
            # find relative path from ".." to "."
            
            local location = [ attribute $(project-module) location ] ;
            local parent-location = [ attribute $(parent-module) location ] ;
            
            local pwd = [ path.pwd ] ;
            local parent-dir = [ path.root $(parent-location) $(pwd) ] ;
            local our-dir = [ path.root $(location) $(pwd) ] ;
            $(attributes).set build-dir : [ path.join $(parent-build-dir) 
                  [ path.relative $(our-dir) $(parent-dir) ] ] : exact ;
        }        
    }            
}


# Associate the given id with the given project module
rule register-id ( id : module )
{
    $(id).jamfile-module = $(module) ;
}

# Class keeping all the attributes of a project.
#
# The standard attributes are "id", "location", "project-root", "parent"
# "requirements", "default-build", "source-location" and "projects-to-build".
class project-attributes 
{
    import property ;
    import property-set ;
    import errors ;
    import path ;
    import print ;
    import sequence ;
        
    rule __init__ ( location )
    {       
        self.location = $(location) ;
    }
            
    # Set the named attribute from the specification given by the user.
    # The value actually set may be different.
    rule set ( attribute : specification * 
        : exact ? # Sets value from 'specification' without any processing
        ) 
    {
        if $(exact)
        {
            self.$(attribute) = $(specification) ;
        }
        else if $(attribute) = "requirements" 
        {
            specification = [ property.translate-paths $(specification)
                              : $(self.location) ] ;
            specification = [ property.make $(specification) ] ;            
            result = [ property-set.create $(specification) ] ;            
            
            # If we have inherited properties, need to refine them with the
            # specified.
            local current = $(self.requirements) ;                                    
            if $(current)
            {
                result = [ $(current).refine $(result) ] ;
            }

            if $(result[1]) = "@error"
            {
                errors.error
                    "Requirements for project at '$(self.location)'"
                    "conflict with parent's." :
                    "Explanation: " $(result[2-]) ;
            }
            else
            {
                self.requirements = $(result) ;
            }
        }
        else if $(attribute) = "usage-requirements"
        {
            local unconditional ;
            for local p in $(specification)
            {
                local split = [ property.split-conditional $(p) ] ;
                split ?= nothing $(p) ;
                unconditional += $(split[2]) ;
            }
            
            local non-free = [ property.remove free : $(unconditional) ] ;
            if $(non-free)
            {
                errors.error "usage-requirements" $(specification) "have non-free properties" $(non-free) ;
            }            
            local t = [ property.translate-paths $(specification)
                                      : $(self.location) ] ;
            if $(self.usage-requirements)
            {
                self.usage-requirements = [ property-set.create 
                    [ $(self.usage-requirements).raw ] $(t) ] ;
            }
            else 
            {
                self.usage-requirements = [ property-set.create $(t) ] ;
            }                        
        }        
        else if $(attribute) = "default-build"
        {
            self.default-build = [ property.make $(specification) ] ;
        }        
        else if $(attribute) = "source-location"
        { 
            self.source-location = [ path.root $(specification) $(self.location) ] ;
        }            
        else if $(attribute) = "build-dir"
        {
            self.build-dir = [ path.root $(specification) $(self.location) ] ;
        }        
        else if ! $(attribute) in "id" "default-build" "location" "source-location"
          "parent" "projects-to-build"
        {
            errors.error "Invalid project attribute '$(attribute)' specified "
                               "for project at '$(self.location)'" ;
        }
        else
        {
            self.$(attribute) = $(specification) ;
        }
    }

    # Returns the value of the given attribute.
    rule get ( attribute )
    {
        return $(self.$(attribute)) ;
    }

    # Prints the project attributes.
    rule print ( )
    {
        local id = $(self.id) ; id ?= (none) ;
        local parent = $(self.parent) ; parent ?= (none) ;
        print.section "'"$(id)"'" ;
        print.list-start ;
        print.list-item "Parent project:" $(parent) ;
        print.list-item "Requirements:" [ $(self.requirements).raw ] ;
        print.list-item "Default build:" $(self.default-build) ;
        print.list-item "Source location:" $(self.source-location) ;
        print.list-item "Projects to build:" 
                            [ sequence.insertion-sort $(self.projects-to-build) ] ;
        print.list-end ;
    }
    
}

# 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)) ;    
}

# If 'path' is absolute, returns it.
# Oherwise, returns the location of 'project', joined
# with 'path'
rule path-relative-to-project-location ( path project )
{
    local project-location = [ attribute $(project) location ] ;
    return [ path.root $(path) $(project-location) ] ;
}


# Use/load a project.
rule use ( id : location )
{
    local project-module = [ project.load $(location) ] ;
    local declared-id = [ project.attribute $(project-module) id ] ;

    if ! $(declared-id)
    {
        error "project loaded by 'use-project' has no project-id." ;
    }
    if $(declared-id) != $(id)
    {
        error project \"$(declared-id)\" at \"$(location)\" redeclared with id \"$(id)\". ;
    }
}

# This module defines rules common to all projects
module project-rules
{
    rule project ( id ? : options * : * )
    {
        import project ;
        import path ;
                
        local attributes = [ project.attributes $(__name__) ] ;
        if $(id) 
        {
           id = [ path.root $(id) / ] ;
           project.register-id $(id) : $(__name__) ;
           $(attributes).set id : $(id) ;
        }

        for n in 2 3 4 5 6 7 8 9
        {
            local option = $($(n)) ;
            if $(option) 
            {
                $(attributes).set $(option[1]) : $(option[2-]) ;
            }
        }
    }

    rule use-project ( id : where )
    {
        import project ;
        import path ;
        local attributes = [ project.attributes $(__name__) ] ;
        project.use $(id) : [ path.root 
            [ path.make $(where) ] [ $(attributes).get location ] ] ;
    }

    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 ;
        local t = [ project.target $(__name__) ] ;
        for local n in $(target-names)
        {            
            $(t).mark-target-as-explicit $(n) ;
        }        
    }    
    
    rule glob ( wildcards + )
    {
        import path ;
        import project ;
        
        local location = [ project.attribute $(__name__) location ] ;
        local all-paths = [ path.glob $(location) : $(wildcards) ] ;
        return $(all-paths:D="") ;
    }        
}


local rule __test__ ( )
{
    import assert ;
    assert.result foo/bar : remove-trailing-slash foo/bar/ ;
    assert.result foo/bar : remove-trailing-slash foo/bar ;
    assert.result foo : remove-trailing-slash foo/ ;
    assert.result foo : remove-trailing-slash foo ;
}

⌨️ 快捷键说明

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