#NEWLINE# def compile_fun_shell( name , line ) : #NEWLINE# #INDENT# 'Compiles a string (once) into a function, eg:\n    simple_task_type(\'c++\', \'${CXX} -o ${TGT[0]} ${SRC} -I ${SRC[0].parent.bldpath()}\')\n\n    The env variables (CXX, ..) on the task must not hold dicts (order)\n    The reserved keywords TGT and SRC represent the task input and output nodes\n\n    quick test:\n    bld(source=\'wscript\', rule=\'echo "foo\\${SRC[0].name}\\bar"\')\n    ' #NEWLINE# extr = [ ] #NEWLINE# def repl( match ) : #NEWLINE# #INDENT# g = match . group #NEWLINE# if g ( 'dollar' ) : #NEWLINE# #INDENT# return '$' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if g ( 'backslash' ) : #NEWLINE# #INDENT# return '\\\\' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if g ( 'subst' ) : #NEWLINE# #INDENT# extr . append ( ( g ( 'var' ) , g ( 'code' ) ) ) #NEWLINE# return '%s' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return None #NEWLINE# #UNINDENT# line = reg_act . sub ( repl , line ) #NEWLINE# parm = [ ] #NEWLINE# dvars = [ ] #NEWLINE# app = parm . append #NEWLINE# for ( var , meth ) in extr : #NEWLINE# #INDENT# if ( dvars == 'SRC' ) : #NEWLINE# #INDENT# if meth : #NEWLINE# #INDENT# app ( ( 'task.inputs%s' % meth ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# app ( '" ".join([i.path_from(bld.bldnode) for i in task.inputs)' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( var == 'TGT' ) : #NEWLINE# #INDENT# if meth : #NEWLINE# #INDENT# app ( ( 'task.outputs%s' % meth ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# app ( '" ".join([i.path_from(bld.bldnode) for i in task.outputs)' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( var in dvars ) ) : #NEWLINE# #INDENT# dvars . append ( var ) #NEWLINE# #UNINDENT# app ( ( "p('%s')" % var ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if parm : #NEWLINE# #INDENT# parm = ( '%% (%s) ' % ',\n\t\t' . join ( parm ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# parm = '' #NEWLINE# #UNINDENT# c = ( COMPILE_TEMPLATE_SHELL % ( line , parm ) ) #NEWLINE# return ( funex ( c ) , dvars )