⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jambase

📁 jam源码
💻
📖 第 1 页 / 共 3 页
字号:
	# N.B.	This rule is called during binding, potentially after	# the fate of many targets has been determined, and must be	# used with caution: don't add dependencies to unrelated	# targets, and don't set variables on $(<).	# Tell Jam that anything depending on $(<) also depends on $(>),	# set SEARCH so Jam can find the headers, but then say we don't	# care if we can't actually find the headers (they may have been	# within ifdefs),	local s = $(>:G=$(HDRGRIST:E)) ;	Includes $(<) : $(s) ;	SEARCH on $(s) = $(HDRSEARCH) ;	NoCare $(s) ;	# Propagate on $(<) to $(>)	HDRSEARCH on $(s) = $(HDRSEARCH) ;	HDRSCAN on $(s) = $(HDRSCAN) ;	HDRRULE on $(s) = $(HDRRULE) ;	HDRGRIST on $(s) = $(HDRGRIST) ;}rule InstallInto{	# InstallInto dir : sources ;	local i t ;	t = $(>:G=$(INSTALLGRIST)) ;	# Arrange for jam install	# Arrange for jam uninstall	# sources are in SEARCH_SOURCE	# targets are in dir	Depends install : $(t) ;	Clean uninstall : $(t) ;	SEARCH on $(>) = $(SEARCH_SOURCE) ;	MakeLocate $(t) : $(<) ;	# For each source, make gristed target name	# and Install, Chmod, Chown, and Chgrp	for i in $(>)	{	    local tt = $(i:G=$(INSTALLGRIST)) ;	    Depends $(tt) : $(i) ;	    Install $(tt) : $(i) ;	    Chmod $(tt) ;	    if $(OWNER) && $(CHOWN) 	    { 		Chown $(tt) ;		OWNER on $(tt) = $(OWNER) ;	    }	    if $(GROUP) && $(CHGRP) 	    { 		Chgrp $(tt) ;		GROUP on $(tt) = $(GROUP) ;	    }	}}rule InstallBin{	local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;	InstallInto $(<) : $(_t) ;	MODE on $(_t:G=$(INSTALLGRIST)) = $(EXEMODE) ;}rule InstallFile{	InstallInto $(<) : $(>) ;	MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;}rule InstallLib{	InstallInto $(<) : $(>) ;	MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;}rule InstallMan{	# Really this just strips the . from the suffix	local i s d ;	for i in $(>)	{	    switch $(i:S)	    {	    case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;	    case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;	    case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;	    case .n : s = n ; case .man : s = 1 ;	    }	    d = man$(s) ;	    InstallInto $(d:R=$(<)) : $(i) ;	}	MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;}rule InstallShell{	InstallInto $(<) : $(>) ;	MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;}rule Lex{	LexMv $(<) : $(>) ;	Depends $(<) : $(>) ;	MakeLocate $(<) : $(LOCATE_SOURCE) ;	Clean clean : $(<) ;}rule Library{	LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;	Objects $(>) ;}rule LibraryFromObjects{	local _i _l _s ;	# Add grist to file names	_s = [ FGristFiles $(>) ] ;	_l = $(<:S=$(SUFLIB)) ;	# library depends on its member objects	if $(KEEPOBJS)	{	    Depends obj : $(_s) ;	}	else	{	    Depends lib : $(_l) ;	}	# Set LOCATE for the library and its contents.  The bound	# value shows up as $(NEEDLIBS) on the Link actions.	# For compatibility, we only do this if the library doesn't	# already have a path.	if ! $(_l:D)	{	    MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ;	}	if $(NOARSCAN) 	{ 	    # If we can't scan the library to timestamp its contents,	    # we have to just make the library depend directly on the	    # on-disk object files.  	    Depends $(_l) : $(_s) ;	}	else	{	    # If we can scan the library, we make the library depend	    # on its members and each member depend on the on-disk	    # object file.	    Depends $(_l) : $(_l)($(_s:BS)) ;	    for _i in $(_s)	    {		Depends $(_l)($(_i:BS)) : $(_i) ;	    }	}	Clean clean : $(_l) ;	if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }	Archive $(_l) : $(_s) ;	if $(RANLIB) { Ranlib $(_l) ; }	# If we can't scan the library, we have to leave the .o's around.	if ! ( $(NOARSCAN) || $(NOARUPDATE) ) { RmTemps $(_l) : $(_s) ; }}rule Link{	MODE on $(<) = $(EXEMODE) ;	Chmod $(<) ;}rule LinkLibraries{	# make library dependencies of target	# set NEEDLIBS variable used by 'actions Main'	local _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;	Depends $(_t) : $(>:S=$(SUFLIB)) ;	NEEDLIBS on $(_t) += $(>:S=$(SUFLIB)) ;}rule Main{	MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;	Objects $(>) ;}rule MainFromObjects{	local _s _t ;	# Add grist to file names	# Add suffix to exe	_s = [ FGristFiles $(>) ] ;	_t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;	# so 'jam foo' works when it's really foo.exe	if $(_t) != $(<)	{	    Depends $(<) : $(_t) ;	    NotFile $(<) ;	}	# make compiled sources a dependency of target	Depends exe : $(_t) ;	Depends $(_t) : $(_s) ;	MakeLocate $(_t) : $(LOCATE_TARGET) ;	Clean clean : $(_t) ;	Link $(_t) : $(_s) ;}rule MakeLocate{	# MakeLocate targets : directory ;	# Sets special variable LOCATE on targets, and arranges	# with MkDir to create target directory.	# Note we grist the directory name with 'dir',	# so that directory path components and other	# targets don't conflict.	if $(>)	{	    LOCATE on $(<) = $(>) ;	    Depends $(<) : $(>[1]:G=dir) ;	    MkDir $(>[1]:G=dir) ;	}}rule MkDir{	# MkDir directory ;	# Make a directory and all its parent directories.	# Ignore timestamps on directories: we only care if they 	# exist.	NoUpdate $(<) ;	# Don't create . or any directory already created.	if $(<:G=) != $(DOT) && ! $($(<)-mkdir) 	{	    # Cheesy gate to prevent multiple invocations on same dir	    # Arrange for jam dirs	    # MkDir1 has the actions 	    $(<)-mkdir = true ;	    Depends dirs : $(<) ;	    MkDir1 $(<) ;	    # Recursively make parent directories.	    # $(<:P) = $(<)'s parent, & we recurse until root	    local s = $(<:P) ;	    # Don't try to create A: or A:\ on windows	    if $(NT)	    {	        switch $(s)		{		case *:   : s = ;		case *:\\ : s = ;		}	    }	    if $(s) = $(<)	    {		# The parent is the same as the dir.		# We're at the root, which some OS's can't stat, so we mark		# it as NotFile.	        NotFile $(s) ;	    }	    else if $(s:G=)	    {		# There's a parent; recurse.		Depends $(<) : $(s) ;		MkDir $(s) ;	    }	}}rule Object{	# locate object and search for source, if wanted	Clean clean : $(<) ;	MakeLocate $(<) : $(LOCATE_TARGET) ;	SEARCH on $(>) = $(SEARCH_SOURCE) ;	# Save HDRS for -I$(HDRS) on compile.	# We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers	# in the .c file's directory, but generated .c files (from	# yacc, lex, etc) are located in $(LOCATE_TARGET), possibly	# different from $(SEARCH_SOURCE).	HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ;	# handle #includes for source: Jam scans for headers with	# the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)	# with the scanned file as the target and the found headers	# as the sources.  HDRSEARCH is the value of SEARCH used for	# the found header files.  Finally, if jam must deal with 	# header files of the same name in different directories,	# they can be distinguished with HDRGRIST.	# $(SEARCH_SOURCE:E) is where cc first looks for #include 	# "foo.h" files.  If the source file is in a distant directory, 	# look there.  Else, look in "" (the current directory).	HDRRULE on $(>) = HdrRule ;	HDRSCAN on $(>) = $(HDRPATTERN) ;	HDRSEARCH on $(>) = 		$(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ;	HDRGRIST on $(>) = $(HDRGRIST) ;	# propagate target specific-defines	DEFINES on $(<) += $(DEFINES) ;	# if source is not .c, generate .c with specific rule	switch $(>:S)	{	    case .asm : As $(<) : $(>) ;	    case .c :	Cc $(<) : $(>) ;	    case .C :	C++ $(<) : $(>) ;	    case .cc :	C++ $(<) : $(>) ;	    case .cpp : C++ $(<) : $(>) ;	    case .f :	Fortran $(<) : $(>) ;	    case .l :	Cc $(<) : $(<:S=.c) ;			Lex $(<:S=.c) : $(>) ;	    case .s :	As $(<) : $(>) ;	    case .y :	Cc $(<) : $(<:S=$(YACCGEN)) ;			Yacc $(<:S=$(YACCGEN)) : $(>) ;	    case * :	UserObject $(<) : $(>) ;	}}rule ObjectCcFlags{	CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;}rule ObjectC++Flags{	C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;}rule ObjectDefines{	# must reformat CCDEFS according to current defines	local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;	DEFINES on $(s) += $(>) ;	CCDEFS on $(s) = [ on $(s) FDefines $(DEFINES) ] ;}rule ObjectHdrs{	# Add to HDRS for HdrScan's benefit.	# must reformat CCHDRS according to headers	local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;	HDRS on $(s) += $(>) ;	CCHDRS on $(s) = [ on $(s) FIncludes $(HDRS) ] ;}rule Objects{	local _i ;	for _i in [ FGristFiles $(<) ]	{		Object $(_i:S=$(SUFOBJ)) : $(_i) ;		Depends obj : $(_i:S=$(SUFOBJ)) ;	}}rule RmTemps{	Temporary $(>) ;}rule Setuid{	MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;}rule Shell{	Depends shell : $(<) ;	Depends $(<) : $(>) ;	SEARCH on $(>) = $(SEARCH_SOURCE) ;	MODE on $(<) = $(SHELLMODE) ;	Clean clean : $(<) ;	Chmod $(<) ;}rule SoftLink{	Depends files : $(<) ;	Depends $(<) : $(>) ;	SEARCH on $(>) = $(SEARCH_SOURCE) ;	Clean clean : $(<) ;}rule SubDir{	#	# SubDir TOP d1 d2 ... ;	#	# Support for a project tree spanning multiple directories.	#	# SubDir declares a Jamfile's location in a project tree, setting	# Jambase variables (SEARCH_SOURCE, LOCATE_TARGET) so that source	# files can be found.	#	# TOP is a user-select variable name for root of the tree, and	# d1 d2 ...  are the directory elements that lead from the root	# of the tree to the directory of the Jamfile.	#	# TOP can be set externally, but normally the first SubDir call	# computes TOP as the path up from the current directory; the	# path contains one ../ for each of d1 d2 ...	#	# SubDir reads once the project-specific rules file Jamrules 	# in the TOP directory, if present.  This can be overridden	# with the variable TOPRULES.	#	# SubDir supports multiple, overlaid project trees:  SubDir	# invocations with different TOPs can appear in the same Jamfile.	# The location established by the first SubDir call is used set	# the TOPs for the subsequent SubDir calls.	#	# SubDir's public variables:	#	#	$(TOP) = path from CWD to root.	#	$(SUBDIR) = path from CWD to the directory SubDir names.	#	$(SUBDIR_TOKENS) = path from $(TOP) to $(SUBDIR) as dir names	#	$(SEARCH_SOURCE) = $(SUBDIR)	#	$(LOCATE_SOURCE) = $(ALL_LOCATE_TARGET) $(SUBDIR)	#	$(LOCATE_TARGET) = $(ALL_LOCATE_TARGET) $(SUBDIR)	#	$(SOURCE_GRIST) = $(SUBDIR_TOKENS) with !'s 	#	local _top = $(<[1]) ;	local _tokens = $(<[2-]) ;	#	# First time through sets up relative root and includes Jamrules.	#	if ! $(_top)	{	    Exit SubDir syntax error ;	}	if ! $($(_top)-SET)	{	    $(_top)-SET = true ;	    # First time we've seen this TOP.	    # We'll initialize a number of internal variables:	    #	    #	$(TOP-UP) = directories from ROOT to a common point	    #	$(TOP-DOWN) = directories from common point to TOP	    #	$(TOP-ROOT) = root directory for UP/DOWN -- normally CWD	    #	$(SUBDIR_UP) = current value of $(TOP-UP)	    #	$(SUBDIR_DOWN) = current value of $(TOP-DOWN)	    #	$(SUBDIR_ROOT) = current value of $(TOP-ROOT)	    #	    if $($(_top))	    {		# TOP externally set.		# We'll ignore the relative (UP/DOWN) path that		# got us here, and instead remember the hard ROOT.		$(_top)-UP = ;		$(_top)-DOWN = ;		$(_top)-ROOT = $($(_top)) ;	    }	    else	    {		# TOP not preset.		# Establishing a new TOP.  In the simplest case,		# (SUBDIR_UP/SUBDIR_DOWN/SUBDIR_ROOT unset), it's		# merely a certain number of directories down from		# the current directory, and FSubDirPath will set		# TOP to a path consisting of ../ for each of the		# elements of _tokens, because that represents how 		# far below TOP the current directory sits.		#		# In the more complicated case, the starting directory		# isn't the directory of jam's invocation but an 		# location established by previous SubDir call.  The		# starting directory is SUBDIR_UP directories up from		# SUBDIR_ROOT, and then SUBDIR_DOWN directories down		# from that.   If SUBDIR_ROOT is not set, that means		# SUBDIR_DOWN and SUBDIR_UP represent the path from		# the directory of jam's invocation.		#		# In the most complicated case, the _tokens also 		# represents directories down, because TOP is being		# estalished in a directory other than TOP's root.		# Hopefully, _tokens and SUBDIR_DOWN represent the		# same final directory, relative to the new TOP and		# the previous SubDIr's TOP.  To find the new TOP,		# we have to chop off any common directories from		# then ends of _tokens and SUBDIR_DOWN.  To do so,		# we reverse each of them, call FStripCommon to		# remove the initial common elements, and then		# reverse them again.  After this process, if		# both _tokens and SUBDIR_DOWN have elements, it		# means the directory names estalished by the two		# SubDir calls don't match, and a warning is issued.		# All hell will likely break loose at this point,		# since the whole SubDir scheme relies on the SubDir		# calls accurately naming the current directory.		# Strip common trailing elements of _tokens and SUBDIR_DOWN.		_tokens = [ FReverse $(_tokens) ] ;		SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;		FStripCommon _tokens : SUBDIR_DOWN ;		SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;		_tokens = [ FReverse $(_tokens) ] ;		if $(SUBDIR_DOWN) && $(_tokens) 		{ 		    Echo Warning: SubDir $(<) misplaced! ; 		}		# We'll remember the relative (UP/DOWN) path that		# got us here, plus any hard ROOT starting point		# for the UP/DOWN.  If TOP is never set externally,		# ROOT will always be "" (directory of jam's invocation).		$(_top)-UP = $(SUBDIR_UP) $(_tokens) ;		$(_top)-DOWN = $(SUBDIR_DOWN) ;		$(_top)-ROOT = $(SUBDIR_ROOT:E="") ;		$(_top) = [ FSubDirPath $(_top) ] ;	    }	    # Set subdir vars for the inclusion of the Jamrules,	    # just in case they have SubDir rules of their own.	    # Note that SUBDIR_DOWN is empty: it's all the way	    # up where the Jamrules live.  These gets overrided	    # just after the inclusion.	    SUBDIR_UP = $($(_top)-UP) ;	    SUBDIR_DOWN = ;	    SUBDIR_ROOT = $($(_top)-ROOT) ;	    # Include $(TOPRULES) or $(TOP)/Jamrules.	    # Include $(TOPRULES) if set.	    # Otherwise include $(TOP)/Jamrules if present.	    if $($(_top)RULES) { 		include $($(_top)RULES) ;	    } else { 		NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ;		include $(JAMRULES:R=$($(_top)):G=$(_top)) ;	    }	}	# Get path from $(TOP) to named directory.	# Save dir tokens for other potential uses.	SUBDIR_UP = $($(_top)-UP) ;        SUBDIR_DOWN = $($(_top)-DOWN) $(_tokens) ;	SUBDIR_ROOT = $($(_top)-ROOT) ;        SUBDIR_TOKENS = $(SUBDIR_DOWN) ;	SUBDIR = [ FSubDirPath $(<) ] ;	# Now set up SEARCH_SOURCE, LOCATE_TARGET, SOURCE_GRIST	# These can be reset if needed.	 For example, if the source	# directory should not hold object files, LOCATE_TARGET can	# subsequently be redefined.	SEARCH_SOURCE = $(SUBDIR) ;	LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ;	LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ;	SOURCE_GRIST = [ FGrist $(SUBDIR_TOKENS) ] ;	# Reset per-directory ccflags, hdrs, etc,	# listed in SUBDIRRESET.	# Note use of variable expanded assignment var	SUBDIR$(SUBDIRRESET) = ;	# Invoke user-specific SubDir extensions,	# rule names listed in SUBDIRRULES.	# Note use of variable expanded rule invocation	$(SUBDIRRULES) $(<) ;}rule FSubDirPath{	# FSubDirPath TOP d1 ... ;	# Returns path to named directory.	# If jam is invoked in a subdirectory of the TOP, then we	# need to prepend a ../ for every level we must climb up	# (TOP-UP), and then append the directory names we must 	# climb down (TOP-DOWN), plus the named directories d1 ...	# If TOP was set externally, or computed from another TOP 	# that was, we'll have to reroot the whole thing at TOP-ROOT.	local _r = [ FRelPath $($(<[1])-UP) : $($(<[1])-DOWN) $(<[2-]) ] ;	return $(_r:R=$($(<[1])-ROOT)) ;}rule SubDirCcFlags{	SUBDIRCCFLAGS += $(<) ;}rule SubDirC++Flags{	SUBDIRC++FLAGS += $(<) ;}rule SubDirHdrs{	SUBDIRHDRS += [ FDirName $(<) ] ;}rule SubInclude{	# SubInclude TOP d1 ... ;	#	# Include a subdirectory's Jamfile.	# We use SubDir to get there, in case the included Jamfile	# either doesn't have its own SubDir (naughty) or is a subtree	# with its own TOP.	if ! $($(<[1]))	{	    Exit SubInclude $(<[1]) without prior SubDir $(<[1]) ;	}	SubDir $(<) ;	include $(JAMFILE:D=$(SUBDIR)) ;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -