📄 stage.jam
字号:
local source-root = [ $(properties).get <install-source-root> ] ;
if $(source-root)
{
# Get the real path of the target. We probably need to strip
# relative path from the target name at construction...
local path = [ $(source).path ] ;
path = [ path.root $(name:D) $(path) ] ;
# Make the path absolute. Otherwise, it's hard to compute relative
# path. The 'source-root' is already absolute, see the
# 'adjust-properties' method above.
path = [ path.root $(path) [ path.pwd ] ] ;
relative = [ path.relative-to $(source-root) $(path) ] ;
targets = [ new file-target $(name:D=$(relative)) exact : [ $(source).type ]
: $(project) : $(new-a) ] ;
}
else
{
targets = [ new file-target $(name:D=) exact : [ $(source).type ]
: $(project) : $(new-a) ] ;
}
return $(targets) ;
}
rule symlink ( name : project : source : properties )
{
local a = [ new action $(source) : symlink.ln :
$(properties) ] ;
local targets = [
new file-target $(name) exact : [ $(source).type ] : $(project) : $(a) ] ;
return $(targets) ;
}
rule relink-file ( project : source : property-set )
{
local action = [ $(source).action ] ;
local cloned-action = [ virtual-target.clone-action $(action) : $(project) :
"" : $(property-set) ] ;
local result = [ $(cloned-action).targets ] ;
return $(result) ;
}
# Declare installed version of the EXE type. Generator for this type will
# cause relinking to the new location.
type.register INSTALLED_EXE : : EXE ;
class installed-exe-generator : generator
{
import type property-set modules stage ;
rule __init__ ( )
{
generator.__init__ install-exe : EXE : INSTALLED_EXE ;
}
rule run ( project name ? : property-set : source : multiple ? )
{
if [ $(property-set).get <os> ] in NT CYGWIN
{
# Relinking is never needed on NT
return [ stage.copy-file $(project)
: $(source) : $(property-set) ] ;
}
else
{
return [ stage.relink-file $(project)
: $(source) : $(property-set) ] ;
}
}
}
generators.register [ new installed-exe-generator ] ;
# Installing shared link on Unix might cause a creation of
# versioned symbolic links.
type.register INSTALLED_SHARED_LIB : : SHARED_LIB ;
class installed-shared-lib-generator : generator
{
import type property-set modules stage ;
rule __init__ ( )
{
generator.__init__ install-shared-lib : SHARED_LIB
: INSTALLED_SHARED_LIB ;
}
rule run ( project name ? : property-set : source : multiple ? )
{
local copied = [ stage.copy-file $(project)
: $(source) : $(property-set) ] ;
if [ $(property-set).get <os> ] = NT
{
return $(copied) ;
}
else
{
local result = $(copied) ;
# If the name is in the form NNN.XXX.YYY.ZZZ, where all
# 'X', 'Y' and 'Z' are numbers, we need to create
# NNN.XXX and NNN.XXX.YYY symbolic links.
local m = [ MATCH (.*)\\.([0123456789]+)\\.([0123456789]+)\\.([0123456789]+)$
: [ $(copied).name ] ] ;
if $(m)
{
result += [ stage.symlink $(m[1]).$(m[2]) : $(project)
: $(copied) : $(property-set) ] ;
result += [ stage.symlink $(m[1]).$(m[2]).$(m[3]) : $(project)
: $(copied) : $(property-set) ] ;
}
return $(result) ;
}
}
}
generators.register [ new installed-shared-lib-generator ] ;
# Main target rule for 'install'
rule install ( name : sources * : requirements * : default-build * )
{
local project = [ project.current ] ;
# Unless the user has explicitly asked us to hardcode dll paths, add
# <hardcode-dll-paths>false in requirements, to override default
# value.
if ! <hardcode-dll-paths>true in $(requirements)
{
requirements += <hardcode-dll-paths>false ;
}
if <name> in $(requirements:G)
{
errors.user-error
"The <name> property is not allowed for the 'install' rule" ;
}
if <tag> in $(requirements:G)
{
errors.user-error
"The <tag> property is not allowed for the 'install' rule" ;
}
targets.main-target-alternative
[ new install-target-class $(name) : $(project)
: [ targets.main-target-sources $(sources) : $(name) ]
: [ targets.main-target-requirements $(requirements) : $(project) ]
: [ targets.main-target-default-build $(default-build) : $(project) ]
] ;
}
IMPORT $(__name__) : install : : install ;
IMPORT $(__name__) : install : : stage ;
rule add-variant-and-compiler ( name : type ? : property-set )
{
return [ rename $(name) : $(type) : $(property-set) ] ;
}
rule add-variant ( name : type ? : property-set )
{
return [ rename $(name) : $(type) : $(property-set) : unversioned ] ;
}
rule rename ( name : type ? : property-set : unversioned ? )
{
if [ type.is-derived $(type) LIB ]
{
local properties = [ $(property-set).raw ] ;
local tags = ;
local thread-tag ;
if <threading>multi in $(properties) { thread-tag = mt ; }
local runtime-tag = ;
if <runtime-link>static in $(properties) { runtime-tag += s ; }
if <runtime-build>debug in $(properties) { runtime-tag += g ; }
if <variant>debug-python in $(properties) { runtime-tag += y ; }
if <variant>debug in $(properties) { runtime-tag += d ; }
if <stdlib>stlport in $(properties) { runtime-tag += p ; }
if <stdlib-stlport:iostream>hostios in $(properties) { runtime-tag += n ; }
local toolset-tag = ;
# 'unversioned' should be a parameter.
if ! $(unversioned)
{
switch [ $(property-set).get <toolset> ]
{
case borland* : toolset-tag += bcb ;
case como* : toolset-tag += como ;
case cw : toolset-tag += cw ;
case darwin* : toolset-tag += ;
case edg* : toolset-tag += edg ;
case gcc* : toolset-tag += gcc ;
case intel-linux* : toolset-tag += il ;
case intel-win* : toolset-tag += iw ;
case kcc* : toolset-tag += kcc ;
case kylix* : toolset-tag += bck ;
#case metrowerks* : toolset-tag += cw ;
#case mingw* : toolset-tag += mgw ;
case mipspro* : toolset-tag += mp ;
case msvc* : toolset-tag += vc ;
case sun* : toolset-tag += sw ;
case tru64cxx* : toolset-tag += tru ;
case vacpp* : toolset-tag += xlc ;
}
local version = [ MATCH "<toolset.*version>([0123456789]+)[.]([0123456789]*)" : $(properties) ] ;
toolset-tag += $(version) ;
}
# Note yet clear if this should be added on Linux (where we have
# version in soname) and how it should be done on Windows.
#local version-tag = ;
#if ! $(gUNVERSIONED_VARIANT_TAG)
#{
# local version-number = [ get-values <version> : $(properties) ] ;
# version-number ?= $(BOOST_VERSION) ;
# version-tag = [ MATCH "^([^.]+)[.]([^.]+)" : $(version-number[1]) ] ;
# version-tag = $(version-tag:J="_") ;
#}
tags += $(toolset-tag:J=) ;
tags += $(thread-tag:J=) ;
tags += $(runtime-tag:J=) ;
#tags += $(version-tag) ;
local result ;
if $(tags)
{
result = $(name)-$(tags:J=-) ;
}
else
{
result = $(name) ;
}
return [ virtual-target.add-prefix-and-suffix $(result) : $(type)
: $(property-set) ] ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -