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

📄 common.jam

📁 C++的一个好库。。。现在很流行
💻 JAM
📖 第 1 页 / 共 2 页
字号:
      [ feature.get-values <linkflags> : $(options) ] : unchecked ;        
}


# returns the location of the "program files" directory on a windows
# platform
rule get-program-files-dir ( )
{
    local ProgramFiles = [ modules.peek : ProgramFiles ] ;
    if $(ProgramFiles)
    {
        ProgramFiles = "$(ProgramFiles:J= )" ;
    }
    else
    {
        ProgramFiles = "c:\\Program Files" ;
    }
    return $(ProgramFiles) ;
}

if [ os.name ] = NT
{
    RM = del /f ;
    CP = copy ;
}
else
{
    RM = rm -f ;
    CP = cp ;
}

nl = "
" ;

rule rm-command ( ) 
{
     return $(RM) ;
}

# Returns the command needed to set the environment variable on the
# current platform.  The variable setting persists through all
# following commands and is visible in the environment seen by
# subsequently executed commands.  In other words, on Unix systems,
# the variable is exported, which is consistent with the only possible
# behavior on Windows systems.
rule variable-setting-command ( variable : value )
{    
    if [ os.name ] = NT
    {
        return "set $(variable)=$(value)$(nl)" ;
    }
    else
    {
        return "$(variable)=$(value)$(nl)export $(variable)$(nl)" ;
    }
}

# Returns a command that sets the named shell path variable to the
# given NATIVE paths to on the current platform.
rule path-variable-setting-command ( variable : paths * )
{   
    local sep = [ os.path-separator ] ;
    return [ variable-setting-command $(variable) : $(paths:J=$(sep)) ] ;
}

# Returns a command that prepends the given paths to the named path
# variable on the current platform.
rule prepend-path-variable-command ( variable : paths * )
{   
    return [ 
      path-variable-setting-command $(variable) 
        : $(paths) [ os.expand-variable $(variable) ]
    ] ;
}


# Return a command which can create a file. If 'r' is result of invocation,
# then 
#   r foobar
# will create foobar with unspecified content. What happens if file already 
# exists is unspecified.
rule file-creation-command ( )
{
    if [ modules.peek : NT ]
    {
        return "echo. > " ;
    }
    else
    {
        return "touch " ;
    }
}

        
rule MkDir
{
    # If dir exists, don't update it
    # Do this even for $(DOT).

    NOUPDATE $(<) ;

    if $(<) != $(DOT) && ! $($(<)-mkdir)
    {
        local s ;

        # Cheesy gate to prevent multiple invocations on same dir
        # MkDir1 has the actions
        # Arrange for jam dirs

        $(<)-mkdir = true ;
        MkDir1 $(<) ;
        Depends dirs : $(<) ;

        # Recursively make parent directories.
        # $(<:P) = $(<)'s parent, & we recurse until root

        s = $(<:P) ;

        if $(NT)
        {
            switch $(s)
            {
                case *:   : s = ;
                case *:\\ : s = ;
            }
        }
        
        if $(s) && $(s) != $(<)
        {
            Depends $(<) : $(s) ;
            MkDir $(s) ;
        }
        else if $(s)
        {
            NOTFILE $(s) ;
        }
    }
}

actions MkDir1
{
    mkdir "$(<)"
}

actions piecemeal together existing Clean
{
    $(RM) "$(>)"
}

rule copy 
{    
}


actions copy
{
    $(CP) "$(>)" "$(<)"
}

# Cause creation of response file, containing the sources in 'sources'
# All the targets in 'targets' will depend on response file, and response
# file will be created before the targets are built.
rule response-file ( targets + : sources * : the-response-file ? : properties * )
{
    # TODO: now 'the-response-file' is just ignored. Need to remove
    # the argument altother and adjust callers.
    
    # Create a target for response file. Note that we add 'rsp' to the target
    # name (without stripping suffix), so that response file names for c.exe
    # and c.obj are different.
    local rsp = $(targets[1]).rsp ;
    RSP on $(targets) = $(rsp) ;
    LOCATE on $(rsp) = [ on $(targets[1]) return $(LOCATE) ] ;
    DEPENDS $(targets) : $(rsp) ;
    # In theory, we don't need dependecy from response file on sources
    # because response file only needs the names of the sources.
    # In practice, bjam won't recreated TEMPORARY target without dependencies.
    DEPENDS $(rsp) : $(sources) ;
    # Make sure the directory is created before the response file. The target
    # itself depends on directory, but response file does not, yet.
    DEPENDS $(rsp) : [ on $(targets[1]) return $(LOCATE) ] ;
    
    TEMPORARY $(rsp) ;
            
    # Add libraries from <library> property to the list of sources.
    local libraries ;
    for local p in $(properties)
    {
        if $(p:G) = <library-file> && 
          ! [ type.is-derived [ $(p:G=).type ] SHARED_LIB ] 
        {
            libraries += $(p:G=) ;
        }          
    }
    # Get real jam targets
    local xlibraries ;
    for local l in $(libraries)
    {
        xlibraries += [ $(l).actualize ] ;
    }
    
    sources += $(xlibraries) ; 

    response-file-1 $(rsp) : $(sources[1]) ;
    if $(sources[2-])
    {
        response-file-2 $(rsp) : $(sources[2-]) ;
    }
    
    print.output $(rsp) ;
    print.text [ utility.apply-default-suffix .lib :
        [ on $(targets[1])
          return "$(LIBRARY_OPTION)$(FINDLIBS_ST)"
            "$(LIBRARY_OPTION)$(FINDLIBS_SA)"
        ] ] ;

    print.text
        [ on $(targets[1])
          return -D$(DEFINES) -I\"$(INCLUDES)\"
        ] ;
}

# response-file generation is broken up into two phases, the first of
# which overwrites any existing file and the second of which appends
# to the file, piecemeal, so that no command-line is too long.
actions quietly response-file-1
{
    echo "$(>)" > "$(<)"
}

actions quietly piecemeal response-file-2
{
    echo "$(>)" >> "$(<)"
}

rule __test__ ( ) {

    import assert ;
    
    local save-os = [ modules.peek os : name ] ;
    
    modules.poke os : .name : LINUX ;
    
    local nl = "
" ;
    
    assert.result "PATH=foo:bar:baz$(nl)export PATH$(nl)"
      : path-variable-setting-command PATH : foo bar baz ;
    
    assert.result "PATH=foo:bar:$PATH$(nl)export PATH$(nl)"
      : prepend-path-variable-command PATH : foo bar ;
    
    modules.poke os : .name : NT ;
    
    assert.result "set PATH=foo;bar;baz$(nl)"
      : path-variable-setting-command PATH : foo bar baz ;
    
    assert.result "set PATH=foo;bar;%PATH%$(nl)"
      : prepend-path-variable-command PATH : foo bar ;

    modules.poke os : .name : $(save-os) ;      
}    

⌨️ 快捷键说明

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