📄 common.jam
字号:
RM = rm -f ; CP = cp ; LN = ln ;}rule rm-command ( ){ return $(RM) ;}rule copy-command ( ){ return $(CP) ;}# Returns the command needed to set an environment variable on the current# platform. The variable setting persists through all following commands and is# visible in the environment seen by subsequently executed commands. In other# words, on Unix systems, the variable is exported, which is consistent with the# only possible behavior on Windows systems.#rule variable-setting-command ( variable : value ){ local nl = "" ; if [ os.name ] = NT { return "set $(variable)=$(value)$(nl)" ; } else { # (todo) # The following does not work on CYGWIN and needs to be fixed. On # CYGWIN the $(nl) variable holds a Windows new-line \r\n sequence that # messes up the executed export command which then reports that the # passed variable name is incorrect. This is most likely due to the # extra \r character getting interpreted as a part of the variable name. # # Several ideas pop to mind on how to fix this: # * One way would be to separate the commands using the ; shell # command separator. This seems like the quickest possible # solution but I do not know whether this would break code on any # platforms I I have no access to. # * Another would be to not use the terminating $(nl) but that would # require updating all the using code so it does not simply # prepend this variable to its own commands. # * I guess the cleanest solution would be to update Boost Jam to # allow explicitly specifying \n & \r characters in its scripts # instead of always relying only on the 'current OS native newline # sequence'. # # Some code found to depend on this behaviour: # * This Boost Build module. # * __test__ rule. # * path-variable-setting-command rule. # * python.jam toolset. # * xsltproc.jam toolset. # * fop.jam toolset. # (todo) (07.07.2008.) (Jurko) return "$(variable)=$(value)$(nl)export $(variable)$(nl)" ; }}# Returns a command to sets a named shell path variable to the given NATIVE# paths on the current platform.#rule path-variable-setting-command ( variable : paths * ){ local sep = [ os.path-separator ] ; return [ variable-setting-command $(variable) : $(paths:J=$(sep)) ] ;}# Returns a command that prepends the given paths to the named path variable on# the current platform.#rule prepend-path-variable-command ( variable : paths * ){ return [ path-variable-setting-command $(variable) : $(paths) [ os.expand-variable $(variable) ] ] ;}# Return a command which can create a file. If 'r' is result of invocation, then# 'r foobar' will create foobar with unspecified content. What happens if file# already exists is unspecified.#rule file-creation-command ( ){ if [ os.name ] = NT { return "echo. > " ; } else { return "touch " ; }}# Returns a command that may be used for 'touching' files. It is not a real# 'touch' command on NT because it adds an empty line at the end of file but it# works with source files.#rule file-touch-command ( ){ if [ os.name ] = NT { return "echo. >> " ; } else { return "touch " ; }}rule MkDir{ # If dir exists, do not update it. Do this even for $(DOT). NOUPDATE $(<) ; if $(<) != $(DOT) && ! $($(<)-mkdir) { # Cheesy gate to prevent multiple invocations on same dir. $(<)-mkdir = true ; # Schedule the mkdir build action. if [ os.name ] = NT { MkDir1-quick-fix-for-windows $(<) ; } else { MkDir1-quick-fix-for-unix $(<) ; } # Prepare a Jam 'dirs' target that can be used to make the build only # construct all the target directories. DEPENDS dirs : $(<) ; # Recursively create parent directories. $(<:P) = $(<)'s parent & we # recurse until root. local s = $(<:P) ; if [ os.name ] = NT { switch $(s) { case *: : s = ; case *:\\ : s = ; } } if $(s) { if $(s) != $(<) { DEPENDS $(<) : $(s) ; MkDir $(s) ; } else { NOTFILE $(s) ; } } }}actions MkDir1{ mkdir "$(<)"}# (todo)# The following quick-fix actions should be replaced using the original MkDir1# action once Boost Jam gets updated to correctly detect different paths leading# up to the same filesystem target and triggers their build action only once.# (todo) (04.07.2008.) (Jurko)actions MkDir1-quick-fix-for-unix{ mkdir -p "$(<)"}actions MkDir1-quick-fix-for-windows{ if not exist "$(<)\\" mkdir "$(<)"}actions piecemeal together existing Clean{ $(RM) "$(>)"}rule copy{}actions copy{ $(CP) "$(>)" "$(<)"}rule RmTemps{}actions quietly updated piecemeal together RmTemps{ $(RM) "$(>)" $(IGNORE)}actions hard-link{ $(RM) "$(<)" 2$(NULL_OUT) $(NULL_OUT) $(LN) "$(>)" "$(<)" $(NULL_OUT)}# Given a target, as given to a custom tag rule, returns a string formatted# according to the passed format. Format is a list of properties that is# represented in the result. For each element of format the corresponding target# information is obtained and added to the result string. For all, but the# literal, the format value is taken as the as string to prepend to the output# to join the item to the rest of the result. If not given "-" is used as a# joiner.## The format options can be:## <base>[joiner]# :: The basename of the target name.# <toolset>[joiner]# :: The abbreviated toolset tag being used to build the target.# <threading>[joiner]# :: Indication of a multi-threaded build.# <runtime>[joiner]# :: Collective tag of the build runtime.# <version:/version-feature | X.Y[.Z]/>[joiner]# :: Short version tag taken from the given "version-feature" in the# build properties. Or if not present, the literal value as the# version number.# <property:/property-name/>[joiner]# :: Direct lookup of the given property-name value in the build# properties. /property-name/ is a regular expression. E.g.# <property:toolset-.*:flavor> will match every toolset.# /otherwise/# :: The literal value of the format argument.## For example this format:## boost_ <base> <toolset> <threading> <runtime> <version:boost-version>## Might return:## boost_thread-vc80-mt-gd-1_33.dll, or# boost_regex-vc80-gd-1_33.dll## The returned name also has the target type specific prefix and suffix which# puts it in a ready form to use as the value from a custom tag rule.#rule format-name ( format * : name : type ? : property-set ){ if [ type.is-derived $(type) LIB ] { local result = "" ; for local f in $(format) { switch $(f:G) { case <base> : result += $(name:B) ; case <toolset> : result += [ join-tag $(f:G=) : [ toolset-tag $(name) : $(type) : $(property-set) ] ] ; case <threading> : result += [ join-tag $(f:G=) : [ threading-tag $(name) : $(type) : $(property-set) ] ] ; case <runtime> : result += [ join-tag $(f:G=) : [ runtime-tag $(name) : $(type) : $(property-set) ] ] ; case <version:*> : local key = [ MATCH <version:(.*)> : $(f:G) ] ; local version = [ $(property-set).get <$(key)> ] ; version ?= $(key) ; version = [ MATCH "^([^.]+)[.]([^.]+)[.]?([^.]*)" : $(version) ] ; result += [ join-tag $(f:G=) : $(version[1])_$(version[2]) ] ; case <property:*> : local key = [ MATCH <property:(.*)> : $(f:G) ] ; local p0 = [ MATCH <($(key))> : [ $(property-set).raw ] ] ; if $(p0) { local p = [ $(property-set).get <$(p0)> ] ; if $(p) { result += [ join-tag $(f:G=) : $(p) ] ; } } case * : result += $(f:G=) ; } } result = [ virtual-target.add-prefix-and-suffix $(result:J=) : $(type) : $(property-set) ] ; return $(result) ; }}local rule join-tag ( joiner ? : tag ? ){ if ! $(joiner) { joiner = - ; } return $(joiner)$(tag) ;}local rule toolset-tag ( name : type ? : property-set ){ local tag = ; local properties = [ $(property-set).raw ] ; switch [ $(property-set).get <toolset> ] { case borland* : tag += bcb ; case como* : tag += como ; case cw : tag += cw ; case darwin* : tag += xgcc ; case edg* : tag += edg ; case gcc* : { switch [ $(property-set).get <toolset-gcc:flavor> ] { case *mingw* : tag += mgw ; case * : tag += gcc ; } } case intel : if [ $(property-set).get <toolset-intel:platform> ] = win { tag += iw ; } else { tag += il ; } case kcc* : tag += kcc ; case kylix* : tag += bck ; #case metrowerks* : tag += cw ; #case mingw* : tag += mgw ; case mipspro* : tag += mp ; case msvc* : tag += vc ; case sun* : tag += sw ; case tru64cxx* : tag += tru ; case vacpp* : tag += xlc ; } local version = [ MATCH "<toolset.*version>([0123456789]+)[.]([0123456789]*)" : $(properties) ] ; # For historical reasons, vc6.0 and vc7.0 use different naming. if $(tag) = vc { if $(version[1]) = 6 { # Cancel minor version. version = 6 ; } else if $(version[1]) = 7 && $(version[2]) = 0 { version = 7 ; } } # On intel, version is not added, because it does not matter and it is the # version of vc used as backend that matters. Ideally, we should encode the # backend version but that would break compatibility with V1. if $(tag) = iw { version = ; } # On borland, version is not added for compatibility with V1. if $(tag) = bcb { version = ; } tag += $(version) ; return $(tag:J=) ;}local rule threading-tag ( name : type ? : property-set ){ local tag = ; local properties = [ $(property-set).raw ] ; if <threading>multi in $(properties) { tag = mt ; } return $(tag:J=) ;}local rule runtime-tag ( name : type ? : property-set ){ local tag = ; local properties = [ $(property-set).raw ] ; if <runtime-link>static in $(properties) { tag += s ; } # This is an ugly thing. In V1, there is code to automatically detect which # properties affect a target. So, if <runtime-debugging> does not affect gcc # toolset, the tag rules will not even see <runtime-debugging>. Similar # functionality in V2 is not implemented yet, so we just check for toolsets # known to care about runtime debugging. if ( <toolset>msvc in $(properties) ) || ( <stdlib>stlport in $(properties) ) || ( <toolset-intel:platform>win in $(properties) ) { if <runtime-debugging>on in $(properties) { tag += g ; } } if <python-debugging>on in $(properties) { tag += y ; } if <variant>debug in $(properties) { tag += d ; } if <stdlib>stlport in $(properties) { tag += p ; } if <stdlib-stlport:iostream>hostios in $(properties) { tag += n ; } return $(tag:J=) ;}rule __test__ ( ){ import assert ; local nl = "" ; local save-os = [ modules.peek os : .name ] ; modules.poke os : .name : LINUX ; assert.result "PATH=foo:bar:baz$(nl)export PATH$(nl)" : path-variable-setting-command PATH : foo bar baz ; assert.result "PATH=foo:bar:$PATH$(nl)export PATH$(nl)" : prepend-path-variable-command PATH : foo bar ; modules.poke os : .name : NT ; assert.result "set PATH=foo;bar;baz$(nl)" : path-variable-setting-command PATH : foo bar baz ; assert.result "set PATH=foo;bar;%PATH%$(nl)" : prepend-path-variable-command PATH : foo bar ; modules.poke os : .name : $(save-os) ;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -