📄 stage.jam
字号:
{ result += [ $(i).all-referenced-targets ] ; } local result2 ; for local r in $(result) { if $(r:G) != <use> { result2 += $(r:G=) ; } } result = [ sequence.unique $(result2) ] ; } # Returns true iff 'type' is subtype of some element of 'types-to-include'. # local rule include-type ( type : types-to-include * ) { local found ; while $(types-to-include) && ! $(found) { if [ type.is-subtype $(type) $(types-to-include[1]) ] { found = true ; } types-to-include = $(types-to-include[2-]) ; } return $(found) ; }}# Creates a copy of target 'source'. The 'properties' object should have a# <location> property which specifies where the target must be placed.#rule copy-file ( project name ? : source : properties ){ name ?= [ $(source).name ] ; local relative ; local new-a = [ new non-scanning-action $(source) : common.copy : $(properties) ] ; 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 would be hard to compute the # 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) ] ; } # Note: Using $(name:D=$(relative)) might be faster here, but then we would # need to explicitly check that relative is not ".", otherwise we might get # paths like '<prefix>/boost/.', try to create it and mkdir would obviously # fail. name = [ path.join $(relative) $(name:D=) ] ; return [ new file-target $(name) exact : [ $(source).type ] : $(project) : $(new-a) ] ;}rule symlink ( name : project : source : properties ){ local a = [ new action $(source) : symlink.ln : $(properties) ] ; return [ new file-target $(name) exact : [ $(source).type ] : $(project) : $(a) ] ;}rule relink-file ( project : source : property-set ){ local action = [ $(source).action ] ; local cloned-action = [ virtual-target.clone-action $(action) : $(project) : "" : $(property-set) ] ; return [ $(cloned-action).targets ] ;}# 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 ; import property-set ; import modules ; import 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 || [ $(property-set).get <target-os> ] in windows 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 a 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 ; import property-set ; import modules ; import stage ; rule __init__ ( ) { generator.__init__ install-shared-lib : SHARED_LIB : INSTALLED_SHARED_LIB ; } rule run ( project name ? : property-set : source : multiple ? ) { if [ $(property-set).get <os> ] in NT CYGWIN || [ $(property-set).get <target-os> ] in windows cygwin { local copied = [ stage.copy-file $(project) : $(source) : $(property-set) ] ; return [ virtual-target.register $(copied) ] ; } else { local a = [ $(source).action ] ; local copied ; if ! $(a) { # Non-derived file, just copy. copied = [ stage.copy-file $(project) : $(source) : $(property-set) ] ; } else { local cp = [ $(a).properties ] ; local current-dll-path = [ $(cp).get <dll-path> ] ; local new-dll-path = [ $(property-set).get <dll-path> ] ; if $(current-dll-path) != $(new-dll-path) { # Rpath changed, need to relink. copied = [ stage.relink-file $(project) : $(source) : $(property-set) ] ; } else { copied = [ stage.copy-file $(project) : $(source) : $(property-set) ] ; } } copied = [ virtual-target.register $(copied) ] ; 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) { # Symlink without version at all is used to make # -lsome_library work. result += [ stage.symlink $(m[1]) : $(project) : $(copied) : $(property-set) ] ; # Symlinks of some libfoo.N and libfoo.N.M are used so that # library can found at runtime, if libfoo.N.M.X has soname of # libfoo.N. That happens when the library makes some binary # compatibility guarantees. If not, it is possible to skip those # symlinks. local suppress = [ $(property-set).get <install-no-version-symlinks> ] ; if $(suppress) != "on" { 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 <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 ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -