ó âqLc@s»dZdZddlZddlZddlmZddlmZm Z ddl Zddl Zddl Zddl ZddlZddlZdefd„ƒYZeZgd„Zd ejjfd „ƒYZd ejjfd „ƒYZd ejjfd„ƒYZdejfd„ƒYZidd6dd6Zdejfd„ƒYZd„Zd„Zdefd„ƒYZ defd„ƒYZ!dejj"fd„ƒYZ#d„Z$dS( s± SCons.Builder Builder object subsystem. A Builder object is a callable that encapsulates information about how to execute actions to create a target Node (file) from source Nodes (files), and how to create those dependencies for tracking. The main entry point here is the Builder() factory method. This provides a procedural interface that creates the right underlying Builder object based on the keyword arguments supplied and the types of the arguments. The goal is for this external interface to be simple enough that the vast majority of users can create new Builders as necessary to support building new types of files in their configurations, without having to dive any deeper into this subsystem. The base class here is BuilderBase. This is a concrete base class which does, in fact, represent the Builder objects that we (or users) create. There is also a proxy that looks like a Builder: CompositeBuilder This proxies for a Builder with an action that is actually a dictionary that knows how to map file suffixes to a specific action. This is so that we can invoke different actions (compilers, compile options) for different flavors of source files. Builders and their proxies have the following public interface methods used by other modules: __call__() THE public interface. Calling a Builder object (with the use of internal helper methods) sets up the target and source dependencies, appropriate mapping to a specific action, and the environment manipulation necessary for overridden construction variable. This also takes care of warning about possible mistakes in keyword arguments. add_emitter() Adds an emitter for a specific file suffix, used by some Tool modules to specify that (for example) a yacc invocation on a .y can create a .h *and* a .c file. add_action() Adds an action for a specific file suffix, heavily used by Tool modules to add their specific action(s) for turning a source file into an object file to the global static and shared object file Builders. There are the following methods for internal use within this module: _execute() The internal method that handles the heavily lifting when a Builder is called. This is used so that the __call__() methods can set up warning about possible mistakes in keyword-argument overrides, and *then* execute all of the steps necessary so that the warnings only occur once. get_name() Returns the Builder's name within a specific Environment, primarily used to try to return helpful information in error messages. adjust_suffix() get_prefix() get_suffix() get_src_suffix() set_src_suffix() Miscellaneous stuff for handling the prefix and suffix manipulation we use in turning source file names into target file names. s:src/engine/SCons/Builder.py 5023 2010/06/14 22:05:46 sconsiÿÿÿÿN(tlogInstanceCreation(t InternalErrort UserErrort_NullcBseZRS((t__name__t __module__(((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRrscCsž|rŽg|D]#}|t|ƒ |kr |^q }|rŽtg|D]}t|ƒ|f^qFƒd}|t|ƒ |t|ƒ gSntjj|ƒS(Ni(tlentmaxtSConstUtiltsplitext(tpathtsuffixestStmatchsuft_ftsuf((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pytmatch_splitextws 0/#tDictCmdGeneratorcBs8eZdZddd„Zd„Zd„Zd„ZRS(sûThis is a callable class that can be used as a command generator function. It holds on to a dictionary mapping file suffixes to Actions. It uses that dictionary to return the proper action based on the file suffix of the source file.icCs#tjjj||ƒ||_dS(N(RR tSelectort__init__tsource_ext_match(tselftdictR((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR†scCst|jƒƒS(N(tlisttkeys(R((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyt src_suffixesŠscCs|||æs    (RRR.RR>(((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR8Ús cKsÛd }d|krTd|kr-tdƒ‚ntjj|diƒ|d<|d=n¦d|krú|jddƒ}d|krˆ|d=ntjj|dƒrÝt|d|ƒ}tjj|iƒ|d<|j ƒ|dd|jj|ƒ|j|ƒ|f}t|ƒ‚n|jƒjƒ|kr÷d|ttt|jƒjƒƒƒttt|ƒƒf}t|ƒ‚q÷qú|j|krúd|ttt|jƒƒttt|ƒƒf}t|ƒ‚qúqqW|jrSt|ƒdkrStdttt|ƒƒttt|ƒƒfƒ‚qSnd S( s›Validate that the lists of target and source nodes are legal for this builder and environment. Raise errors or issue warnings as appropriate. s=Multiple ways to build the same target were specified for: %sseTwo different environments were specified for target %s, but they appear to have the same action: %ssNTwo environments with different actions were specified for the same target: %ssITwo different builders (%s and %s) were specified for the same target: %ssMTwo different target lists have a target in common: %s (from %s and from %s)sTMultiple ways to build the same target were specified for: %s (from %s and from %s)isKMore than one source given for single-source builder: targets=%s sources=%sN(t side_effectRthas_explicit_builderR'RtbuilderRt get_contentst genstringRR=R>tDuplicateEnvironmentWarningtmultitget_namet get_executortget_all_targetsRRR R7t single_sourceR( RVR'ttlisttslistttRt t_contentstcontentsRB((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyt _node_errorss4     "  (=4 RKcBs)eZdZd„Zd„Zd„ZRS(sThis is a callable class that can act as a Builder emitter. It holds on to a string that is a key into an Environment dictionary, and will look there at actual build time to see if it holds a callable. If so, we will call that as the actual emitter.cCstjj|ƒ|_dS(N(RR t to_StringRQ(RRQ((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRHscCs§|j}x,tjj|ƒr7||kr7||}q Wt|ƒr_||||ƒ\}}n>tjj|ƒrx)|D]}||||ƒ\}}qxWn||fS(N(RQRR RIR0RL(RR%R&R'R3R-((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR"Ks !  cCst|j|jƒS(N(tcmpRQ(Rtother((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyt__cmp__\s(RRR.RR"Rh(((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRKAs  RMcBs–eZdZejjr'ejjZngZddddddddddddde dde d„Z d„Z d„Zd„Zdd„Ze d „Zddd „Ziid „Zdde d „Zd „Zgd„Zd„Zgd„Zd„Zd„Zd„Zd„Zd„Zid„Zd„Zej ejj!deƒƒd„Z"d„Z#ej ejj!de#ƒƒd„Z$d„Z%RS(sdBase class for Builders, objects that create output nodes (files) from input nodes (files). tiicKsÑt|dƒi|_||_| |_tjj|ƒrIt|ƒ}n||_tjj|ƒrst|ƒ}n| |_ | |_ d|krÉtj j tj j ddƒ|j|dƒ|d=nd|krøtj j tj j dƒ|d=n||_|j|ƒ|j|ƒ||_||_||_||_||_| |_| rc| |_ni|_|tk rˆ||jdt DeprecatedBuilderKeywordsWarningtupdateRjt set_suffixtset_src_suffixt ensure_suffixttarget_factorytsource_factoryttarget_scannertsource_scannerR3tnamet executor_kwt_nullt is_explicitRRLt src_builder(RRRnRRDRtRuRvRwR3RZR'R^RxRlR{R|RsRj((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRisR                           cCstdƒ‚dS(NsSDo not test for the Node.builder attribute directly; use Node.has_builder() instead(R(R((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyt __nonzero__­scCsˆy;t|djƒƒj|ƒ}t|djƒƒ|SWnFttttfk rƒy |jSWq„tk rt |j ƒSXnXdS(sBAttempts to get the name of the Builder. Look at the BUILDERS variable of env, expecting it to be a dictionary containing this Builder, and return the key of the dictionary. If there's no key, then return a directly-configured name (if there is one) or the name of the class (by default).tBUILDERSN( RtvaluestindexRtAttributeErrorR#t TypeErrort ValueErrorRxR t __class__(RR'R€((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR[°s  cCst|j|jƒS(N(Rft__dict__(RRg((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRhÁscCs=|s|j}n|r*|j|ƒ}ng}t||ƒS(N(R'RR(RR R'R ((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR Äs  cCs€|s gSg}tjj|ƒs.|g}nxK|D]C}tjj|ƒrktjj||||ƒ}n|j|ƒq5W|S(N(RR RLRIt adjustixestappend(RtfilestpreRRsRRtf((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyt _adjustixesÍs  cs0ˆjˆƒ}ˆjˆjƒ}ˆjˆjƒ}ˆj|d|ƒ}ˆj||ƒ}ˆjˆ|ƒ}ˆjˆ|ƒ} |dkry|dj } Wn;t k rÂt d|dƒ‚q<t k rØg} q<X‡‡fd†} | || | ƒg} n9ˆj||| ˆj ƒ}ˆj||d|d|ƒ} ˆjr&g} x7| D]/}|jƒsR|jˆƒ| j|ƒqRqRW| }|}ˆjd| d|dˆƒ\}}x-| D]%}|jˆkr¾|jdƒq¾q¾Wˆj||d|d|ƒ} ˆj||d|d|ƒ}n| |fS(s<Create and return lists of target and source nodes. is3Do not know how to create a target from source `%s'csˆj|ˆƒS(N(R (R (RR'(s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pytðsR%R&R'N(tget_src_suffixt get_factoryRtRuR‹Rt arg2nodest get_prefixt get_suffixttarget_from_sourceRRt IndexErrorRsR3t is_derivedt builder_setR‡RV(RR'R%R&tsrc_sufRtRuR`R‰Rtt_from_sR_R t new_targetsRat orig_tlistt orig_slist((R'Rs]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyt _create_nodesÚsF        $ c Cs|jr!|j|||ƒ}n|jrït|ƒdkrï|dkrïg}|dkrpdgt|ƒ}nxlt||ƒD][\}}|dk r¤|g}n|dk r¼|g}n|j|j||||ƒƒq€Wtj j |ƒS|j ƒ|j |||ƒ\} } t ||| | ƒd} d} |jr€y| djddƒ} Wnttfk roq€X| j| ƒn| dkr<|jsÕd} t| |j|p³|jƒttt| ƒƒfƒ‚n|jj|pê|j| | ƒ} | r<ytjj| ƒ} Wntk r%q9X| j| | ƒq<n| dkr‹tjj|j|g| | |ƒ} | r‹tjj| | ƒq‹nxd| D]\}|j j!ƒ|_"|j#|ƒ|j$|ƒ|j%| ƒ|j&| ƒ|j'|j(ƒq’Wtj j | ƒS(Niitcreates+Builder %s must have an action to build %s.()R|tsrc_builder_sourcesR^RRtziptextendt_executeRtNodetNodeListR>R›RdRZR\RR“t add_sourcesRRR[R'RRR t batch_keytExecutortGetBatchExecutorR#t add_batchtAddBatchExecutortfstgetcwdtcwdR•tenv_sett add_sourcet set_executort set_explicitR{(RR'R%R&toverwarnRyRRttgtR*R_R`texecutortkeytfmtRa((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR sb '   #    !       c Ksø|tkr|j}n|jjƒ}||d<|rÁd|kr|dd„}tjj|ƒsq|g}ntt||ƒƒ}|d=n|jr¸|jjƒ}|j |ƒqÊ|}n |j}|j |ƒ}|j |||t |ƒ|ƒS(NRltsrcdircSsMddl}tjj|ƒrI|jj|ƒ rI|jj||ƒ}n|S(Niÿÿÿÿ(tos.pathRR RIR tisabstjoin(RŠRµtos((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pytprependDirIfRelativegs %( RzRytcopyRR RLRRRjRptOverrideR R8( RR'R%R&RlROtekwRºtenv_kw((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR"\s$         cCs"|r|ddkrd|S|S(Nit.t_t$(R¿RÀRÁ((Rtsuff((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyt adjust_suffixzscCs4|j}t|ƒr'|||ƒ}n|j|ƒS(N(RnR0tsubst(RR'R7Rn((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRs  cCs+t|ƒs|j|ƒ}n||_dS(N(R0RÃR(RR((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRq…s cCs4|j}t|ƒr'|||ƒ}n|j|ƒS(N(RR0RÄ(RR'R7R((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR‘Šs  cCsh|sg}ntjj|ƒs-|g}ng|D]'}t|ƒrL|pX|j|ƒ^q4|_dS(N(RR RLR0RÃRD(RRDR((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyRrs   cCs!|j|ƒ}|sdS|dS(s5Get the first src_suffix in the list of src_suffixes.Rii(R(RR'R,((s]/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Builder.pyR—scCs||j|Ls:         2    * 'ÿí