📄 allyourbase.jam
字号:
h = $(SEARCH_SOURCE)$(SLASH)$(>:D) ;
}
else
{
h = $(>:D) ;
}
HDRRULE on $(>) = HdrRule ;
HDRSCAN on $(>) = $(HDRPATTERN) ;
HDRSEARCH on $(>) = $(HDRS) $(h) $(STDHDRS) $(SYSHDRS) ;
HDRGRIST on $(>) = $(HDRGRIST) ;
# if source is not .c, generate .c with specific rule
# make sure we don't generate the same object twice.
if ! $(gGENERATED_TARGET($(<)))
{
switch $(>:S)
{
case .asm : As $(<) : $(>) ;
case .c : Cc $(<) : $(>) ;
case .C : C++ $(<) : $(>) ;
case .cc : C++ $(<) : $(>) ;
case .cpp : C++ $(<) : $(>) ;
case .cxx : C++ $(<) : $(>) ;
case .f : Fortran $(<) : $(>) ;
case .s : As $(<) : $(>) ;
case * : UserObject $(<) : $(>) ;
}
gGENERATED_TARGET($(<)) = true ;
}
}
# dwa 6/4/01 - added for boost
# Return the corresponding object file target names given a list of source file
# target names.
rule object-name # sources...
{
return $(<:D=:S=$(SUFOBJ):G=$(TARGET_GRIST)) ;
}
# dwa 6/4/01 - added for boost
# Build a generated source file from input-target, and build whatever that file generates.
# Return a list of all object target names ultimately generated by recursively
# building the products of input-target.
rule gen-source # source => object-file-names
{
local suffix = .c ;
if $(<:S) in .lpp .ypp
{
suffix = .cpp ;
}
local immediate-target = $(<:D=:S=$(suffix):G=$(SOURCE_GRIST)) ;
# make sure we don't regenerate sources twice.
if ! $(gGENERATED_TARGET($(immediate-target)))
{
switch $(<:S)
{
case .l* : Lex $(immediate-target) : $(<) ; SEARCH on $(<) = $(SEARCH_SOURCE) ;
case .y* : Yacc $(immediate-target) : $(<) ; SEARCH on $(<) = $(SEARCH_SOURCE) ;
}
gGENERATED_TARGET($(immediate-target)) = true ;
}
return [ Objects $(immediate-target) ] ;
}
# dwa 6/4/01 - added for boost
# A list of all file extensions which generate source files when built.
SOURCE_GENERATING_EXTENSIONS ?= .lpp .ypp .l .y ;
# dwa 6/4/01 - modified for boost
# Build all object files generated by building $(<), and return a list of the
# names of those object file targets.
rule Objects
{
local _i _n _r ;
for _i in $(<)
{
if $(_i:S) in $(SOURCE_GENERATING_EXTENSIONS)
{
_n = [ gen-source $(_i) ] ;
}
else
{
_n = [ object-name $(_i) ] ;
Object $(_n) : $(_i) ;
}
_r += $(_n) ;
}
return $(_r) ;
}
rule RmTemps
{
TEMPORARY $(>) ;
}
rule Setuid
{
MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;
}
# dwa 6/4/01 - modified for boost
rule Shell
{
type-DEPENDS shell : $(<) ;
DEPENDS $(<) : $(>) ;
SEARCH on $(>) = $(SEARCH_SOURCE) ;
MODE on $(<) = $(SHELLMODE) ;
Clean clean : $(<) ;
Chmod $(<) ;
}
# dwa 6/7/01 - added for boost
# subproject path
#
# Invokes SubDir with a path description
rule subproject
{
SubDir TOP [ split-path $(<) ] ;
}
# dwa 6/18/01 - added for boost
# project-root
#
# Declares this directory to be the project root.
rule project-root ( )
{
local project-location ;
if $(gTOP)
{
project-location = [ root-paths $($(gTOP)) : [ PWD ] ] ;
}
else
{
project-location = [ PWD ] ;
}
local name ;
name = $(PROJECT($(project-location))) ;
name ?= $(project-location:B) ;
PROJECT = $(name) ;
gPROJECT($(name)) = $(project-location) ;
SubDir TOP ;
}
# grafik.
#
# Declare either your own project, or an external project.
#
rule project ( name : location ? )
{
if ! $(location)
{
gPROJECT($(name)) = $(gPROJECT($(PROJECT))) ;
PROJECT($(gPROJECT($(name)))) = $(name) ;
PROJECT = $(name) ;
}
else
{
gPROJECT($(name)) = [ root-paths $(location) : [ root-paths $($(gTOP)) : [ PWD ] ] ] ;
local [ protect-subproject ] ;
enter-subproject @$(name) ;
}
}
# grafik.
#
# Returns the set of vars to localize to prevent changes from
# affecting the current project. Also remembers the current values
# to use by enter-subproject to set the defaults for the new vars.
#
rule protect-subproject ( )
{
.TOP = $(TOP) ;
.TOP_TOKENS = $(TOP_TOKENS) ;
.gTOP = $(gTOP) ;
.PROJECT = $(PROJECT) ;
return TOP TOP_TOKENS gTOP PROJECT [ protect-subdir ] ;
}
# grafik.
#
# Sets up the environment as if the context is another project in
# preparation to include the external projects targets. This also
# works for refering to the current project.
#
rule enter-subproject ( project-path )
{
TOP = $(.TOP) ;
TOP_TOKENS = $(.TOP_TOKENS) ;
gTOP = $(.gTOP) ;
PROJECT = $(.PROJECT) ;
local project-name = [ MATCH "^@([^/\\]+)" : $(project-path) ] ;
project-name ?= $(PROJECT) ;
project-name ?= "" ;
local project-subdir = [ MATCH "^@[^/\\]+[/\\](.*)" : $(project-path) ] ;
local project-top ;
if $(project-name)
{
project-top = [ split-path $(gPROJECT($(project-name))) ] ;
if $(project-subdir)
{
project-top +=
[ split-path [ relative-path $(project-subdir) ] ]
[ split-path [ FSubDir [ split-path [ relative-path $(project-subdir) ] ] ] ] ;
}
TOP = [ join-path $(project-top) ] ;
TOP_TOKENS = $(project-top) ;
gTOP = TOP ;
PROJECT = $(project-name) ;
}
project-subdir ?= . ;
subproject $(project-subdir) ;
return $(project-name) $(project-subdir) ;
}
# dwa 6/7/01 - added for boost
# subinclude path...
#
# Invokes SubInclude for each path
rule subinclude
{
local d ;
for d in $(<)
{
SubInclude TOP [ split-path $(d) ] ;
}
}
# dwa 10/6/01 - added for boost
#
# path-global variable-name : path... ;
#
# if $(variable-name) is unset, sets variable-name to path...
# variable-name will be adjusted on a per-subproject basis to refer to the same path.
rule path-global
{
$(<) ?= $(>) ;
gPATH_GLOBAL_VALUE($(<)) = $($(<)) ;
if ! ( $(<) in $(gPATH_GLOBALS) )
{
gPATH_GLOBALS += $(<) ;
}
}
# dwa 6/4/01 - modified for boost
rule SubDir
{
local _r ;
#
# SubDir TOP d1 [ ... ]
#
# This introduces a Jamfile that is part of a project tree
# rooted at $(TOP). It (only once) includes the project-specific
# rules file $(TOP)/Jamrules and then sets search & locate stuff.
#
# If the variable $(TOPRULES) is set (where TOP is the first arg
# to SubDir), that file is included instead of $(TOP)/Jamrules.
#
# d1 ... are the directory elements that lead to this directory
# from $(TOP). We construct the system dependent path from these
# directory elements in order to set search&locate stuff.
#
if ! $($(<[1]))
{
if ! $(<[1])
{
EXIT SubDir syntax error ;
}
$(<[1]) = [ FSubDir $(<[2-]) ] ;
$(<[1])_TOKENS = [ split-path $($(<[1])) ] ;
gTOP = $(<[1]) ; # not sure why someone would want to use anything
# other than TOP, but just in case...
}
# Get path to current directory from root using SubDir.
# Save dir tokens for other potential uses.
local .SUBDIR_TOKENS = $(<[2-]) ;
# This allows us to determine whether we're in the directory where jam was
# invoked from so that we can make locally named targets
gINVOCATION_SUBDIR_TOKENS ?= $(.SUBDIR_TOKENS) ;
gINVOCATION_SUBDIR_TOKENS ?= $(DOT) ;
#
# If $(TOP)/Jamrules hasn't been included, do so.
#
local top = [ root-paths $($(gTOP)) : [ PWD ] ] ;
if ! $(gINCLUDED($(JAMRULES:R=$(top))))
{
# Gated entry.
gINCLUDED($(JAMRULES:R=$(top))) = TRUE ;
# Include it.
project-root ;
include $(JAMRULES:R=$(top)) ;
}
# Get path to current directory from root using SubDir.
# Save dir tokens for other potential uses.
SUBDIR_TOKENS = $(<[2-]) ;
# SUBDIR is the path from the invocation directory to the subproject
# directory.
SUBDIR = [ tokens-to-simple-path $($(gTOP)_TOKENS) $(SUBDIR_TOKENS) ] ;
SEARCH_SOURCE = $(SUBDIR) ;
# This will strip off any leading dot on SUBDIR_TOKENS
local nodot_subdir = [ simplify-path-tokens $(SUBDIR_TOKENS) ] ;
if $(ALL_LOCATE_TARGET) && ! $(first_ALL_LOCATE_TARGET)
{
normalized_ALL_LOCATE_TARGET = [ join-path $($(gTOP)) $(ALL_LOCATE_TARGET) ] ;
}
else
{
normalized_ALL_LOCATE_TARGET ?= [ join-path $($(gTOP)) $(ALL_LOCATE_TARGET) ] ;
}
first_ALL_LOCATE_TARGET ?= $(ALL_LOCATE_TARGET) ;
LOCATE_SOURCE = [ FDirName $(normalized_ALL_LOCATE_TARGET) $(BIN_DIRECTORY) $(PROJECT) $(nodot_subdir) ] ;
LOCATE_TARGET = $(LOCATE_SOURCE) ;
HCACHEFILE = [ FDirName $(normalized_ALL_LOCATE_TARGET) $(BIN_DIRECTORY) .jamdeps ] ;
SOURCE_GRIST = [ FGrist @$(PROJECT) $(SUBDIR_TOKENS) ] ;
# Reset per-directory ccflags, hdrs
SUBDIRCCFLAGS = ;
SUBDIRC++FLAGS = ;
# This variable holds the path from the directory of Jam's invocation to the
# directory of the current subproject.
RELATIVE_SUBDIR_TOKENS = [ simplify-path-tokens $($(gTOP)_TOKENS) $(SUBDIR_TOKENS) : $(DOT) ] ;
RELATIVE_SUBDIR = [ join-path $(RELATIVE_SUBDIR_TOKENS) ] ;
adjust-path-globals ;
}
rule in-invocation-subdir
{
local subdir-tokens = $(SUBDIR_TOKENS) ;
subdir-tokens ?= $(DOT) ;
if $(subdir-tokens) = $(gINVOCATION_SUBDIR_TOKENS)
{
return true ;
}
}
# These are the global variables that get set up by SubDir. If you need to
# invoke SubDir temporarily and then restore them, declare
# local $(gSUBDIR_GLOBALS) ;
gSUBDIR_GLOBALS = SUBDIR SUBDIR_TOKENS SEARCH_SOURCE LOCATE_SOURCE LOCATE_TARGET
SOURCE_GRIST RELATIVE_SUBDIR RELATIVE_SUBDIR_TOKENS ;
rule protect-subdir
{
return $(gSUBDIR_GLOBALS) $(gPATH_GLOBALS) ;
}
# prepends root to any unrooted elements of paths, and simplifies
rule root-paths ( paths * : root )
{
local path result ;
for path in $(paths)
{
local rooted = $(path:R=$(root)) ;
path = [ tokens-to-simple-path [ split-path $(rooted:G=) ] ] ;
path = $(path:G=$(rooted:G)) ;
result += $(path) ;
}
return $(result) ;
}
# Adjust all path globals so that they are relative to the current subproject.
rule adjust-path-globals
{
# compute path tokens from current subproject to root
local tokens-to-root = [ split-path [ FSubDir $(SUBDIR_TOKENS) ] ] ;
# compute path tokens from current subproject to invocation
# directory. $(DOT) is added just in case we're building from the project
# root
local tokens-to-invocation
= $(tokens-to-root) $(gINVOCATION_SUBDIR_TOKENS) ;
local variable ;
for variable in $(gPATH_GLOBALS)
{
local paths = $(gPATH_GLOBAL_VALUE($(variable))) ;
$(variable) = ;
local path ;
for path in $(paths)
{
# is path already rooted?
if $(path:R=x) = $(path)
{
$(variable) += $(path) ;
}
else
{
local tokens = $(tokens-to-invocation) [ split-path $(path) ] ;
$(variable) += [ tokens-to-simple-path $(tokens) ] ;
}
}
}
}
# dwa 6/4/01 - added for boost
# strip-grist value
#
# strip all leading gristed elements from value and return the result.
rule strip-grist
{
local x = $(<:G=) ;
if ! $(x:G)
{
return $(x) ;
}
else
{
return [ strip-grist $(x) ] ;
}
}
# dwa 6/4/01 - added for boost
# Breaks $(<) into path components
# This could certainly be improved now that we have David Turner's regular expression features.
#
# split-path <foo>bar/<bee>baz/mumble => <foo>bar <bee>baz mumble
rule split-path
{
local result = $(gSPLIT-PATH.$(<)) ;
if ! $(result)
{
local parent = $(<:P) ;
if $(NT)
{
switch $(<:G=)
{
# It turns out that to match a backslash, you need a /quadruple/ slash
# in the case clause!
case *\\\\*:* : # continue splitting
case *:\\\\*\\\\* : # continue splitting
case *:/*\\\\* : # continue splitting
case *:\\\\*/* : # continue splitting
case *:/*/* : # continue splitting
case *:/* : result = $(<) ;
case *:\\\\* : result = $(<) ;
case *: : result = $(<) ;
}
}
if ( ! $(<:B) ) && ( $(<) != $(DOT) ) # handle the case where $(<) is all grist.
{
result ?= $(<:G) ;
}
else if ( ! $(parent:G=) )
{
result ?= $(<) ;
}
else
{
local p = [ split-path $(parent) ] ;
local b = [ strip-grist $(<) ] ;
p += $(b:D=) ; # can't use :B here because it destroys . and ..
result ?= $(p) ;
}
gSPLIT-PATH.$(<) = $(result) ;
}
return $(result) ;
}
rule split ( string separator )
{
local result ;
local s = $(string) ;
while $(s)
{
local match = [ MATCH ^(.*)$(separator)(.*) : $(s) ] ;
local tail = $(match[2]) ;
tail ?= $(s) ;
result = $(tail) $(result) ;
s = $(match[1]) ;
}
return $(result) ;
}
rule split-path ( path )
{
if ! $(gSPLIT_PATH_CACHE($(path)))
{
gSPLIT_PATH_CACHE($(path)) =
[ MATCH "^([/$(SLASH)]+).*" : $(path) ] # rooting slash(es), if any
[ split $(path) "[/$(SLASH)]" ] # the rest.
;
}
return $(gSPLIT_PATH_CACHE($(path))) ;
}
# dwa 6/4/01 - added for boost
# reverse item1 item2...
#
# Returns ...item2 item1
rule reverse
{
local result ;
for x in $(<)
{
result = $(x) $(result) ;
}
return $(result) ;
}
# dwa 6/28/01 - added for boost
# strip-initial tokens... : input
#
# if input begins with tokens, remove the initial sequence of tokens and return
# the rest. Otherwise return input unchanged.
rule strip-initial
{
local result = $(>) ;
local t ;
local matched = true ;
for t in $(<)
{
if $(matched) && ( $(t) = $(result[1]) )
{
result = $(result[2-]) ;
}
else
{
matched = ;
result = $(>) ;
}
}
return $(result) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -