📄 stage.jam
字号:
# Copyright 2003 Dave Abrahams# Copyright 2005, 2006 Rene Rivera# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus# Distributed under the Boost Software License, Version 1.0.# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)# This module defines the 'install' rule, used to copy a set of targets to a# single location.import targets ;import "class" : new ;import errors ;import type ;import generators ;import feature ;import project ;import virtual-target ;import path ;import types/register ;feature.feature <install-dependencies> : off on : incidental ;feature.feature <install-type> : : free incidental ;feature.feature <install-source-root> : : free path ;feature.feature <so-version> : : free incidental ;# If 'on', version symlinks for shared libraries will not be created. Affects# Unix builds only.feature.feature <install-no-version-symlinks> : on : optional incidental ;class install-target-class : basic-target{ import feature ; import project ; import type ; import errors ; import generators ; import path ; import stage ; import "class" : new ; import property ; import property-set ; rule __init__ ( name-and-dir : project : sources * : requirements * : default-build * ) { basic-target.__init__ $(name-and-dir) : $(project) : $(sources) : $(requirements) : $(default-build) ; } # If <location> is not set, sets it based on the project data. # rule update-location ( property-set ) { local loc = [ $(property-set).get <location> ] ; if ! $(loc) { loc = [ path.root $(self.name) [ $(self.project).get location ] ] ; property-set = [ $(property-set).add-raw $(loc:G=<location>) ] ; } return $(property-set) ; } # Takes a target that is installed and a property set which is used when # installing. # rule adjust-properties ( target : build-property-set ) { local ps-raw ; local a = [ $(target).action ] ; if $(a) { local ps = [ $(a).properties ] ; ps-raw = [ $(ps).raw ] ; # Unless <hardcode-dll-paths>true is in properties, which can happen # only if the user has explicitly requested it, nuke all <dll-path> # properties. if [ $(property-set).get <hardcode-dll-paths> ] != true { ps-raw = [ property.change $(ps-raw) : <dll-path> ] ; } # If any <dll-path> properties were specified for installing, add # them. local l = [ $(build-property-set).get <dll-path> ] ; ps-raw += $(l:G=<dll-path>) ; # Also copy <linkflags> feature from current build set, to be used # for relinking. local l = [ $(build-property-set).get <linkflags> ] ; ps-raw += $(l:G=<linkflags>) ; # Remove the <tag> feature on original targets. ps-raw = [ property.change $(ps-raw) : <tag> ] ; # And <location>. If stage target has another stage target in # sources, then we shall get virtual targets with the <location> # property set. ps-raw = [ property.change $(ps-raw) : <location> ] ; } local d = [ $(build-property-set).get <dependency> ] ; ps-raw += $(d:G=<dependency>) ; local d = [ $(build-property-set).get <location> ] ; ps-raw += $(d:G=<location>) ; local ns = [ $(build-property-set).get <install-no-version-symlinks> ] ; ps-raw += $(ns:G=<install-no-version-symlinks>) ; local d = [ $(build-property-set).get <install-source-root> ] ; # Make the path absolute: we shall use it to compute relative paths and # making the path absolute will help. if $(d) { d = [ path.root $(d) [ path.pwd ] ] ; ps-raw += $(d:G=<install-source-root>) ; } if $(ps-raw) { return [ property-set.create $(ps-raw) ] ; } else { return [ property-set.empty ] ; } } rule construct ( name : source-targets * : property-set ) { source-targets = [ targets-to-stage $(source-targets) : $(property-set) ] ; property-set = [ update-location $(property-set) ] ; local ename = [ $(property-set).get <name> ] ; if $(ename) && $(source-targets[2]) { errors.error "When <name> property is used in 'install', only one" "source is allowed" ; } local result ; for local i in $(source-targets) { local staged-targets ; local new-properties = [ adjust-properties $(i) : $(property-set) ] ; # See if something special should be done when staging this type. It # is indicated by the presence of a special "INSTALLED_" type. local t = [ $(i).type ] ; if $(t) && [ type.registered INSTALLED_$(t) ] { if $(ename) { errors.error "In 'install': <name> property specified with target that requires relinking." ; } else { local targets = [ generators.construct $(self.project) $(name) : INSTALLED_$(t) : $(new-properties) : $(i) ] ; staged-targets += $(targets[2-]) ; } } else { staged-targets = [ stage.copy-file $(self.project) $(ename) : $(i) : $(new-properties) ] ; } if ! $(staged-targets) { errors.error "Unable to generate staged version of " [ $(source).str ] ; } for t in $(staged-targets) { result += [ virtual-target.register $(t) ] ; } } return [ property-set.empty ] $(result) ; } # Given the list of source targets explicitly passed to 'stage', returns the # list of targets which must be staged. # rule targets-to-stage ( source-targets * : property-set ) { local result ; # Traverse the dependencies, if needed. if [ $(property-set).get <install-dependencies> ] = "on" { source-targets = [ collect-targets $(source-targets) ] ; } # Filter the target types, if needed. local included-types = [ $(property-set).get <install-type> ] ; for local r in $(source-targets) { local ty = [ $(r).type ] ; if $(ty) { # Do not stage searched libs. if $(ty) != SEARCHED_LIB { if $(included-types) { if [ include-type $(ty) : $(included-types) ] { result += $(r) ; } } else { result += $(r) ; } } } else if ! $(included-types) { # Don't install typeless target if there is an explicit list of # allowed types. result += $(r) ; } } return $(result) ; } # CONSIDER: figure out why we can not use virtual-target.traverse here. # rule collect-targets ( targets * ) { # Find subvariants local s ; for local t in $(targets) { s += [ $(t).creating-subvariant ] ; } s = [ sequence.unique $(s) ] ; local result = $(targets) ; for local i in $(s)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -