📄 boost-base.jam
字号:
: $(RELATIVE_SUBDIR)
]
: $(override-sets)
] ;
}
}
# split-path-at-grist path
#
# Breaks path at each $(SLASH) that is followed by grist. This can be used to
# break apart property sets, particularly where the <include> feature is used,
# since its value is typically a path.
rule split-path-at-grist
{
local full-split = [ split-path $(<) ] ;
local last ;
local result x ;
for x in $(full-split)
{
if $(x:G)
{
result += $(last) ;
last = $(x) ;
}
else
{
last = $(last)$(SLASH)$(x) ;
last ?= $(x) ;
}
}
return $(result) $(last) ;
}
#
# GIVEN:
#
# A set of dependency sources with grist to indicate the types
# (<dll>*, <lib>*, etc)
#
# RESULT:
#
# Will use the type, basename, and SUF*/PRE* to expand the name
# of the sources to their fully specific target name.
#
# EXAMPLE:
#
# [ expand-source-names <lib>test <dll>test <exe>test README.txt <pyd>test ]
#
# RETURNS:
#
# <lib>libtest.a <dll>libtest.so <exe>test.app README.TXT <pyd>test.so
#
rule expand-source-names ( sources * )
{
local x-sources = ;
for local source in $(sources)
{
local grist = [ ungrist $(source:G) ] ;
local type = $(gTARGET_TYPE_ID($(grist))) ;
if $(type)
{
local p = "" ; if $(source:B=:S=:G=) { p = "/" ; }
local prefix = "" ;
local suffix = "" ;
if $(PRE$(type)[1]) { prefix = $(PRE$(type)[1]) ; }
if $(SUF$(type)[1]) { suffix = $(SUF$(type)[1]) ; }
x-sources += $(source:B=:S=)$(p)$(prefix)$(source:B:S=)$(suffix) ;
}
else
{
x-sources += $(source) ;
}
}
return $(x-sources) ;
}
#
# GIVEN:
#
# A set of targets and a single target type for all the targets
# (DLL, LIB, etc.)
#
# RESULT:
#
# Will use the type, basename, and SUF*/PRE* to expand the name
# of the targets to their fully specific target name.
#
# EXAMPLE:
#
# [ expand-targets-names foo bar : DLL ]
#
# RETURNS:
#
# libfoo.a libbar.so
#
rule expand-target-names ( targets + : target-type )
{
local x-targets = ;
for local target in $(targets)
{
local prefix = "" ;
local suffix = "" ;
if $(PRE$(target-type)[1]) { prefix = $(PRE$(target-type)[1]) ; }
if $(SUF$(target-type)[1]) { suffix = $(SUF$(target-type)[1]) ; }
x-targets += $(prefix)$(target)$(suffix) ;
}
return $(x-targets) ;
}
# declare-local-target name : sources : requirements : local-BUILD : target-type
#
# declares a subproject-local target of the given name and target-type. This is
# all top-level rules which declare targets should eventually go through here.
#
# RETURNS: the a list of target names for the files built by the target.
rule declare-local-target ( target : sources * : requirements * : default-build * : target-type )
{
# We expand out the name of the target
local x-target = [ expand-target-names $(target) : $(target-type) ] ;
# We add SOURCE_GRIST the base target name here because we're referring the
# abstract target which generates all of the actual builds. We need a way to
# distinguish targets of the same name from different subprojects.
local target-id = [ FGristFiles $(x-target) ] ;
if ! $(target-type)
{
EXIT No target type given for "$(x-target)" ;
}
# Define the specifications of the target.
gTARGET_NAME($(target-id)) = $(target) ;
# Declare the basic target.
declare-basic-target $(target-id) : $(sources) : $(requirements) : $(default-build) : $(target-type) ;
# Generate build instructions, but only if the target has a generator.
#
if $(gGENERATOR_FUNCTION($(gTARGET_TYPE($(target-id)))))
{
# Supress the regular build of this target
local suppress = [ get-values <suppress> : $(default-build) ] ;
local gSUPPRESS_FAKE_TARGETS = $(suppress[1]) ;
declare-fake-targets $(target) : $(target-id) ;
# Just gather information if we are including a library's Jamfile for a
# dependent target. Don't generate build instructions here.
if ! $(gIN_LIB_INCLUDE)
{
main-target $(target-id) : $(gTARGET_DEFAULT_BUILD($(target-id))) ;
}
}
return $(gTARGET_FILES($(target-id))) ;
}
# declare-basic-target target-id : sources : requirements : local-BUILD : target-type
#
# Declares a basic target for the given target-id and target-type.
# All target generation should go through here to ensure all vars are set
# for the targets.
#
# WARNING: This only declares, no build instructions are generated here.
rule declare-basic-target ( target-id : sources * : requirements * : default-build * : target-type )
{
# We expand out the name of the sources
local x-sources = [ expand-source-names $(sources) ] ;
# Define the specifications of the target, but only if we haven't already.
#
if ! $(gTARGET_TYPE($(target-id)))
{
# Save basic information about the target.
#
gTARGET_TYPE($(target-id)) = $(target-type) ;
# Add the specified requirements to any requirements given by the target
# type, and the corresponding <target-type> property.
#
gTARGET_REQUIREMENTS($(target-id))
= toolset::requirements $(requirements) $(gTARGET_TYPE_REQUIREMENTS($(target-type))) ;
if ! $(gNO_TARGET_TYPE_REQUIREMENT($(target-type)))
{
gTARGET_REQUIREMENTS($(target-id)) += <target-type>$(target-type) ;
}
# Collect the recognized dependencies to other targets.
#
local dependencies ;
for local source in [ select-gristed $(x-sources) ]
{
local dependency-type = [ ungrist $(source:G:L) ] ;
local dependency-type-id = $(gTARGET_TYPE_ID($(dependency-type))) ;
if $(gIS_DEPENDENCY($(dependency-type-id)))
{
gTARGET_DEPS($(target-id)) += $(source:G=$(dependency-type-id)) ;
}
}
# Sources that aren't recognized as targets, are considered raw sources.
#
gTARGET_SOURCES($(target-id))
= [ FGristFiles
[ difference $(x-sources:G=) : $(gTARGET_DEPS($(target-id)):G=) ] ] ;
# Save the default builds.
#
gTARGET_DEFAULT_BUILD($(target-id)) = $(default-build) ;
# Apply any modifiers to the target specs.
#
for local mod in $(gTARGET_DEPS($(target-id)))
{
local dependency-type-id = [ ungrist $(mod:G) ] ;
local modifier-function = $(gMODIFIER_FUNCTION($(dependency-type-id))) ;
if $(modifier-function)
{
# Remove and apply the modifier.
gTARGET_DEPS($(target-id)) = [ difference $(gTARGET_DEPS($(target-id))) : $(mod) ] ;
local ignored = [ $(modifier-function) $(target-id) : $(mod) ] ;
}
}
}
# Trying to define the same specific target with a different type.
#
else if $(gTARGET_TYPE($(target-id))) != $(target-type)
{
EXIT conflicting target types for "$(x-target)":
"$(gTARGET_TYPE($(target-id)))" "$(target-type)" ;
}
}
# directory-of files...
#
# Returns a list of the directories containing each element of files
rule directory-of
{
local result d ;
for d in $(<:D)
{
if $(d) = ""
{
result += $(DOT) ;
}
else
{
result += $(d) ;
}
}
return $(result) ;
}
# top-relative-tokens path
#
# Returns a list of path elements which form the relative path from TOP to path,
# which is expected to be given relative to the current subproject.
rule top-relative-tokens
{
return [ simplify-path-tokens $(SUBDIR_TOKENS) [ split-path $(<) ] ] ;
}
.project-root-tokens = [ split-path $(.boost-build-file:D) ] ;
# try to make a potentially absolute path relative to the project
# root. Only works for paths below the project root right now; others
# will remain absolute.
rule relative-path ( path )
{
local path-tokens = [ split-path $(path) ] ;
# try to strip the project root
local r = $(.project-root-tokens) ;
local p = $(path-tokens) ;
while $(r) && ( $(r[1]) = $(p[1]) )
{
p = $(p[2-]) ;
r = $(r[2-]) ;
}
# if successful, use the stripped project root
if ! $(r)
{
path-tokens = $(p) ;
}
return [ tokens-to-simple-path $(path-tokens) ] ;
}
# dependent-include target-path...
#
# For each target-path, ensure that the appropriate Jamfile has been
# included. Used when a target declares its dependency on another target.
rule dependent-include
{
local target ;
for target in $(<)
{
{
local .project-path = [ target-path-of $(target) ] ;
.project-path = $(.project-path:D) ;
# load the file as a dependent.
local gIN_LIB_INCLUDE = TRUE ;
#
local [ protect-subproject ] ;
local .project-name-and-subdir = [ enter-subproject $(.project-path) ] ;
local .project-name = $(.project-name-and-subdir[1]) ;
local .project-subdir = $(.project-name-and-subdir[2]) ;
local .jamfile-path = [ root-paths $(JAMFILE) : [ root-paths $(.project-subdir) : $(TOP) ] ] ;
load-jamfiles $(.jamfile-path) ;
}
}
}
# segregate-free-properties variable1 variable2...
#
# returns the and removes the unique list of free properties from
# $(variable1) $(variable2)...
rule segregate-free-properties
{
local free-properties = [ unique [ get-properties $(gFREE_FEATURES) : $($(<)) ] ] ;
local v ;
for v in $(<)
{
$(v) = [ difference $($(v)) : $(free-properties) ] ;
}
return $(free-properties) ;
}
# is-link-compatible feature : value1 : value2
#
# return non-empty iff a library built with <feature>value1 can be linked into a
# target with <feature>value2, empty otherwise
rule is-link-compatible ( feature : value1 : value2 )
{
return [ intersection
$(feature) $(value1:G=$(feature))
$(value1:G=$(feature))$(SLASH)$(value12:G=$(feature))
$(value2:G=$(feature))
: $(gLINK_COMPATIBLE) ] ;
}
# find-compatible-subvariant main-target : toolset variant : dependent-simple-properties
rule find-compatible-subvariant ( main-target : toolset variant : dependent-simple-properties * )
{
# calculate the subvariant only of what is requested
# the subvariant requested...
local sv-request =
[ multiply-property-sets
[ get-properties $(BUILD:G) : $(dependent-simple-properties) ] ] ;
# the available build requests...
local build-requests =
[ multiply-property-sets [ select-gristed $(BUILD) ] ] ;
# the build requst we want to build...
local sv-build =
[ intersection $(sv-request) : $(build-requests) ] ;
sv-build ?= "" ;
local BUILD = $(variant) [ split-path $(sv-build) ] ;
local gTARGET_DEFAULT_BUILD($(main-target)) = ;
# the full subvariant to build...
local subvariant = [ expand-target-subvariants $(main-target) : $(variant) : $(toolset) ] ;
local sv-target = ; local sv-properties = ; local sv-toolset = ; local sv-variant = ;
split-target-subvariant sv-target sv-properties sv-toolset sv-variant : $(subvariant) ;
local sv-overrides =
[ difference $(dependent-simple-properties) : [ select-gristed $(sv-properties) ] ] ;
sv-overrides +=
[ get-properties
[ difference $(dependent-simple-properties:G) : $(sv-overrides:G) ] : $(sv-properties) ] ;
if ! $(gTARGET_TYPE($(main-target)))
{
EXIT unknown dependent target $(main-target) ;
}
# check to make sure we can link against the subvariant
local target-requirements
= [ select-gristed $(gTARGET_REQUIREMENTS($(main-target))) ] ;
local override-conflicts
= [ get-properties $(target-requirements:G) $(gALWAYS_RELEVANT) : $(sv-overrides) ] ;
for local sv-override in $(override-conflicts)
{
local sv-required = [ get-values $(sv-override:G) : $(sv-properties) ] ;
if $(sv-override:G=) != $(sv-required) &&
! [ is-link-compatible $(sv-override:G) : $(sv-override:G=) : $(sv-required) ]
{
EXIT $(main-target): required property $(sv-override:G)$(sv-required)
incompatible with $(sv-override) ;
}
}
# now that we have a mostly (or completely) compatible subvariant do the overrides
local gTARGET_REQUIREMENTS($(main-target)) =
# property rules...
[ select-ungristed $(gTARGET_REQUIREMENTS($(main-target))) ]
# always relevant properties to target...
[ difference
$(target-requirements) :
[ get-properties [ difference $(sv-overrides:G) : $(gALWAYS_RELEVANT) ] : $(target-requirements) ] ]
# link compatible properties, on the target...
[ get-properties
[ difference $(sv-overrides:G) : $(gALWAYS_RELEVANT) ] : $(target-requirements) ]
# overrides from dependent...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -