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

📄 boost-base.jam

📁 C++的一个好库。。。现在很流行
💻 JAM
📖 第 1 页 / 共 5 页
字号:
        [ get-properties
            [ difference $(sv-overrides:G) : $(override-conflicts:G) ] : $(dependent-simple-properties) ]
        ;
    subvariant = [ expand-target-subvariants $(sv-target) : $(sv-variant) : $(sv-toolset) ] ;
    split-target-subvariant sv-target sv-properties sv-toolset sv-variant : $(subvariant) ;

    return $(sv-properties) ;
}


# For each target specified in libs, generate build instructions
# for a subvariant that can be linked with a dependent target with
# dependent-properties, returning a list of all generated targets.
rule link-libraries ( libs * : toolset variant : dependent-simple-properties * )
{
    local lib-path result ;
    
    for lib-path in $(libs)
    {
        local lib-path = [ target-path-of $(lib-path) ] ;
        local lib-target = [ target-id-of $(lib-path) ] ;

        # Enter the dependee subproject
        local [ protect-subproject ] ;
        enter-subproject [ directory-of $(lib-path) ] ;

        local lib-subvariant = [ 
          find-compatible-subvariant $(lib-target)
            : $(toolset) $(variant)
              : $(dependent-simple-properties) ] ;

        # Generate build instructions for the library target
        result += [ subvariant-target $(lib-target) : $(lib-subvariant) : $(toolset) $(variant) ] ;
    }
    return $(result) ;
}

# Which configuration(s) to build if nothing is explicitly specified
DEFAULT_BUILD ?= debug ;

# get-BUILD [target-default-build]
#
# pick the first of ($(BUILD), $(>), $(DEFAULT_BUILD)) which is set. If it
# contains no variants, add variants from $(DEFAULT_BUILD).
rule get-BUILD
{
  local build = $(BUILD) ;
  build ?= $(<) ;
  build ?= $(DEFAULT_BUILD) ;
  local variants = [ select-ungristed $(build) ] ;
  if ! $(variants)
  {
    build += [ select-ungristed $(DEFAULT_BUILD) ] ;
  }
  return $(build) ;
}

# declare-fake-targets abstract-target : target-file
#
# 
rule declare-fake-targets
{
    # make a fake target so that it can be built without knowing the suffix
    # Since executables under *NIX have no suffix, we'd better check
    if $(>) != $(<)
    {
        DEPENDS $(<) : $(>) ;
        NOTFILE $(<) ;
    }
    
    # The following checks that we're in the subdirectory of Jam's invocation
    # so that we can arrange for ungristed target names to be built from the
    # command-line.
    if $(<:G) && [ in-invocation-subdir ]
    {
        DEPENDS $(<:G=) : $(<) ; # allows $(<:G=) to be used to build all variants
        NOTFILE $(<:G=) ;
    }
}

# declare-target-type TYPE : [[<compiler>]<variant>]<feature>value...
rule declare-target-type
{
    gTARGET_TYPE_REQUIREMENTS($(<)) = $(>) ;
}

declare-target-type DLL : <shared-linkable>true ;

if $(NT)
{
  gIMPORT_SUFFIX(DLL) = .lib ;
  gIMPORT_SUFFIX(LIB) = .lib ;
  gEXPORT_SUFFIX(DLL) = .lib ;
}
else
{
  gIMPORT_SUFFIX(DLL) = .so ;
  gIMPORT_SUFFIX(LIB) = .a ;
}

#
# prepare path constants
#
{
    # The names of path variables that are set on targets
    .run-path-vars = LD_LIBRARY_PATH PATH PYTHONPATH ;

    for local v in $(.run-path-vars)
    {
        .shell-var($(v)) = $(v) ;
    }
    
    # Dynamic libraries are actually found on PATH
    if $(NT) || ( $(UNIX) = CYGWIN )
    {
        .shell-var(LD_LIBRARY_PATH) = PATH ;
    }

    # Dynamic libraries search path var is loader, and hence system, dependant.
    else
    {
        .shell-var(LD_LIBRARY_PATH) = $(gSHELL_LIBPATH) ;
    }

    # The names of path variables in the shell
    .run-path-shell-vars = [ unique $(.shell-var($(.run-path-vars))) ] ;
    
    # Record the original value of each shell variable
    for local v in $(.run-path-shell-vars)
    {
        .run-path-shell-var-value($(v)) = $($(v)) ;
    }
    
    if $(NT)
    {
        .env-prefix = % ; 
        .env-suffix = % ;
    }
    else
    {
        .env-prefix = "$" ;
        .env-suffix = "" ;
    }
}



# Helper
rule depend-on-libs ( targets + : libs * )
{
    LIBPATH on $(<) += [ unique $(gLOCATE($(>))) ] ;
    DEPENDS $(<) : $(>) ;
    library-dependencies on $(<) += $(>) ;
    
    # To run these targets, we need everything needed to run the libraries
    for local v in $(.run-path-vars)
    {
        gRUN_$(v)($(<)) = [ unique $(gRUN_$(v)($(<))) $(gRUN_$(v)($(>))) ] ;
    }
}

rule depend-on-static ( targets + : static-libs * )
{
    local NEEDLIBS = [ unique $(NEEDLIBS) $(>) ] ;
    NEEDLIBS on $(<) = [ on $(<) return [ unique $(NEEDLIBS) $(>) ] ] ;
    depend-on-libs $(targets) : $(static-libs) ;
}

rule depend-on-shared ( targets + : dlls-and-import-libs * )
{
    local linkable ;
    
    # collect the linkable elements of the source libs into the appropriate variables
    for local f in $(dlls-and-import-libs)
    {
        local v = $(gLINK_VARIABLE($(f:S))) ;
        $(v) += $(f) ;
        $(v) on $(targets) += $(f) ;
        if $(v)
        {
            linkable += $(f) ;
        }
    }

    FINDLIBS on $(<) += [ unique $(gTARGET_BASENAME($(gTARGET_SUBVARIANT($(>))))) ] ;
    
    depend-on-libs $(targets) : $(dlls-and-import-libs) ;
}

# Given build properties, returns the normalised version of the <tag> features for
# use by rename-targets.
rule get-tag-features ( variant : build-properties * )
{
    local result = ;
    local tags = [ get-properties <tag> : $(build-properties) ] ;
    for local tag in $(tags)
    {
        tag = $(tag:G=) ;
        if $(tag:G)
        {
            result += <tag>$(tag) ;
        }
        else
        {
            result += <tag><$(variant)>$(tag) ;
        }
    }
    return $(result) ;
}

rule generate-dependencies ( main-target : subvariant-targets + )
{
    local dependencies = $(gTARGET_DEPS($(main-target))) ;
    {
        # Protect target variables against modification while lib dependencies
        # are built. They will be made empty here, and restored when this scope exits
        local $(gTARGET_VARIABLES) ;

        # extract the simple properties from dependent-properties
        local p = $(gBUILD_PROPERTIES) ;
        segregate-free-properties p ;

        # generate library build instructions
        local BUILD = $(BUILD) ;
        BUILD ?= $(gTARGET_DEFAULT_BUILD($(main-target))) ;
        
        for t in static shared
        {
            local lib-main-targets = [ get-values <$($(t:U)_TYPES)> : $(dependencies) ] ;
            
            local lib-targets
              = [ link-libraries $(lib-main-targets)
                  : $(gCURRENT_TOOLSET) $(variant) : $(p)
                ] ;
            depend-on-$(t) $(subvariant-targets) : $(lib-targets) ;
        }
    }
}

# Given main-target, a main target name gristed with $(SOURCE_GRIST), generate build
# instructions for a subvariant target using the given toolset, variant, etc.
#
# RETURNS: the a list of target names for the files built by the subvariant. If
# the main-target is a library, the first filename is the one that should be linked
# into a dependent target.
rule subvariant-target ( main-target : subvariant-id build-properties * : toolset variant )
{
  # SOURCE_GRIST identifies the subproject directory; TARGET_GRIST will identify
  # the target and subvariant, since unique versions of files will be built for
  # that combination.
  local property-tags = [ get-tag-features $(variant) : $(build-properties) ] ;
  local tags = [ get-properties <tag> : $(gIMPOSED_REQUIREMENTS($(main-target))) ] $(property-tags) ;
  local TARGET_GRIST = [ join-path $(SOURCE_GRIST) $(main-target:G=) $(subvariant-id) ] ;
  local subvariant = $(main-target:G=$(TARGET_GRIST)) ;

  # Keep track of the generated targets.
  if ! $(TARGET_GRIST) in $(gDECLARED_TARGETS)
  {
    gDECLARED_TARGETS += $(TARGET_GRIST) ;
  }

  # Make sure we know how to generate these types of targets.
  local target-type = $(gTARGET_TYPE($(main-target))) ;
  if ! $(target-type)
  {
      EXIT unknown target type for $(main-target) ;
  }
  
  gTARGET_TYPE($(subvariant)) = $(target-type) ;
  
  # LOCATE_TARGET affects where built targets are generated. We move it
  # relative to the default location based on the subvariant 
  local LOCATE_TARGET
    = [ join-path $(LOCATE_TARGET) $(main-target:G=) $(subvariant-id) ] ;

  # The renamed base name of the target. Only considers the tags defined directly
  # on the target.
  if $(gTARGET_NAME($(main-target)))
  {
    gTARGET_BASENAME($(main-target)) =
      [ rename-target $(gTARGET_NAME($(main-target))) : [ split-path [ ungrist $(subvariant:G) ] ] : $(property-tags) ] ;
  }

  # First order names have the suffix, if any according to the platform.
  local target-files = [ FAppendSuffix $(subvariant) : $(SUF$(target-type)) ] ;
  # Second order names have any tags as imposed from stage target contexts.
  target-files = [ rename-target $(target-files) : [ split-path [ ungrist $(subvariant:G) ] ] : $(tags) ] ;
  # Third order names are customized as determined by a rename rule on the target type.
  if $(gNAME_ADJUST($(target-type)))
  {
    target-files = [
      $(gNAME_ADJUST($(target-type))) $(target-files)
      : $(subvariant-id) $(build-properties)
      : $(toolset) $(variant) ] ;
    gTARGET_TYPE($(target-files[1])) = $(target-type) ;
  }

  # Do nothing if we already have the build instructions for the specific
  # target files of this subvariant target.
  if ! $(target-files) in $(gTARGET_FILES($(main-target)))
  {
    gTARGET_SUBVARIANT($(target-files)) = $(main-target) ;
    
    ###gTARGET_FILES($(subvariant)) = $(target-files) ;
    gTARGET_FILES($(main-target)) += $(target-files) ;

    # Remember the path from the build root to the subvariant directory
    gSUBVARIANT_PATH($(subvariant)) = $(subvariant-id) ;
    
    # Add target suppression if <suppress> was in the requirements
    local gSUPPRESS_FAKE_TARGETS = [ get-values <suppress> : $(gTARGET_REQUIREMENTS($(main-target))) ] $(gSUPPRESS_FAKE_TARGETS) ;

    declare-fake-targets $(main-target) : $(target-files) ;

    # set up gBUILD_PROPERTIES for include-tools (below)
    local gBUILD_PROPERTIES = $(build-properties) ;

    # Include the toolset specification. This will set up the global flags
    # variables in a way appropriate to this build. 
    
    include-tools $(toolset) ;

    # headers should be identified specific to the target, since search paths
    # may differ for different subvariants. The same header name or relative
    # path may refer to different files.
    local HDRGRIST = [ join $(SOURCE_GRIST) $(STDHDRS) $(SYSHDRS) $(HDRS) "" : "#" ] ;
    
    # transfer target variables to the target file.
    set-target-variables $(target-files) ;

    local dependencies
        = [ get-values <$(STATIC_TYPES)> <$(SHARED_TYPES)> 
          : $(gTARGET_DEPS($(main-target)))
        ] ;
      
    if $(dependencies)
    {
        # include each jamfile describing a dependee target.
        dependent-include $(dependencies) ;
        generate-dependencies $(main-target) : $(target-files) ;
    }
    
    local generator = $(gGENERATOR_FUNCTION($(target-type))) ;
    local sources = $(gTARGET_SOURCES($(main-target))) ;
    $(generator) $(target-files) : $(sources) ;
                        
    $(gTARGET_VARIABLES) = ; # Be sure that we don't mask bugs with lingering target variables
  }
  return $(target-files) ;
}

# Generate the expanded subvariants of a target.
#
rule expand-target-subvariants ( target : local-build * : tools + : )
{
    local BUILD = [ get-BUILD $(local-build) ] ;
    local variants = [ select-ungristed $(BUILD) ] ;
    local build-request = [ difference $(BUILD) : $(variants) ] ;

    local subvariants = ;
    for local toolset in $(tools)
    {
        for local variant in $(variants)
        {
            local rules = [ select-ungristed
                $(gTARGET_REQUIREMENTS($(target)))
                $(gIMPOSED_REQUIREMENTS($(target))) ] ;
            local requirements = [ select-gristed
                $(gTARGET_REQUIREMENTS($(target)))
                $(gIMPOSED_REQUIREMENTS($(target))) ] ;
            
            local expanded
                = [ expand-build-request $(toolset) $(variant) $(target)
                    : $(requirements) : $(build-request) ] ;
            
            local gNOWARN_INCOMPATIBLE_BUILDS = TRUE ;
            
            for local instance in $(expanded)
            {
                local properties = [ split-path-at-grist $(instance) ] ;
                for local r in $(rules)
                {
                    properties = [ $(r) $(toolset) $(variant) : $(properties) ] ;
                }
                
                if ! ( <build>no in $(properties) )
                {
                    # the rules may have modified the build request, reconstruct it
                    properties = [ expand-build-request $(toolset) $(variant) $(target)
                      : $(properties[2-]) : $(build-request) ] ;
                    
                    subvariants += $(target)|$(properties)|$(toolset)|$(variant) ;
                }
                else if --dump-unbuilt
                {
                    ECHO **** skipping build of $(target); toolset= $(toolset) variant= $(variant) **** ;
                }
            }
        }
    }
    return [ unique $(subvariants) ] ;
}

# Given an expanded subvariant of a terget, sets the various variables accordingly.
#
rule split-target-subvariant ( target-var properties-var toolset-var variant-var : subv

⌨️ 快捷键说明

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