<s> """<STR_LIT>""" <EOL> import sys <EOL> import copy <EOL> from yaku . conftests . fconftests_imp import is_output_verbose , parse_flink <EOL> FC_VERBOSE_FLAG = "<STR_LIT>" <EOL> FC_RUNTIME_LDFLAGS = "<STR_LIT>" <EOL> FC_DUMMY_MAIN = "<STR_LIT>" <EOL> def check_fcompiler ( conf , msg = None ) : <EOL> code = """<STR_LIT>""" <EOL> if msg is None : <EOL> conf . start_message ( "<STR_LIT>" ) <EOL> else : <EOL> conf . start_message ( msg ) <EOL> ret = conf . builders [ "<STR_LIT>" ] . try_program ( "<STR_LIT>" , code ) <EOL> if ret : <EOL> conf . end_message ( "<STR_LIT:yes>" ) <EOL> else : <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> conf . fail_configuration ( "<STR_LIT>" ) <EOL> return ret <EOL> def check_fortran_verbose_flag ( conf ) : <EOL> code = """<STR_LIT>""" <EOL> conf . start_message ( "<STR_LIT>" ) <EOL> if not conf . builders [ "<STR_LIT>" ] . configured : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if sys . platform == "<STR_LIT:win32>" : <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> conf . env [ FC_VERBOSE_FLAG ] = [ ] <EOL> return True <EOL> for flag in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> old = copy . deepcopy ( conf . env [ "<STR_LIT>" ] ) <EOL> try : <EOL> conf . env [ "<STR_LIT>" ] . append ( flag ) <EOL> ret = conf . builders [ "<STR_LIT>" ] . try_program ( "<STR_LIT>" , code ) <EOL> if not ret : <EOL> continue <EOL> stdout = conf . get_stdout ( conf . last_task ) <EOL> if ret and is_output_verbose ( stdout ) : <EOL> conf . end_message ( flag ) <EOL> conf . env [ FC_VERBOSE_FLAG ] = flag <EOL> return True <EOL> finally : <EOL> conf . env [ "<STR_LIT>" ] = old <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> conf . fail_configuration ( "<STR_LIT>" ) <EOL> return False <EOL> def check_fortran_runtime_flags ( conf ) : <EOL> if not conf . builders [ "<STR_LIT>" ] . configured : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if sys . platform == "<STR_LIT:win32>" : <EOL> return _check_fortran_runtime_flags_win32 ( conf ) <EOL> else : <EOL> return _check_fortran_runtime_flags ( conf ) <EOL> def _check_fortran_runtime_flags_win32 ( conf ) : <EOL> if conf . env [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> conf . start_message ( "<STR_LIT>" ) <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> conf . env [ FC_RUNTIME_LDFLAGS ] = [ ] <EOL> else : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def _check_fortran_runtime_flags ( conf ) : <EOL> if not FC_VERBOSE_FLAG in conf . env : <EOL> raise ValueError ( """<STR_LIT>""" % FC_VERBOSE_FLAG ) <EOL> code = """<STR_LIT>""" <EOL> conf . start_message ( "<STR_LIT>" ) <EOL> old = copy . deepcopy ( conf . env [ "<STR_LIT>" ] ) <EOL> try : <EOL> conf . env [ "<STR_LIT>" ] . append ( conf . env [ "<STR_LIT>" ] ) <EOL> ret = conf . builders [ "<STR_LIT>" ] . try_program ( "<STR_LIT>" , code ) <EOL> if ret : <EOL> stdout = conf . get_stdout ( conf . last_task ) <EOL> flags = parse_flink ( stdout ) <EOL> conf . end_message ( "<STR_LIT>" % "<STR_LIT:U+0020>" . join ( flags ) ) <EOL> conf . env [ FC_RUNTIME_LDFLAGS ] = flags <EOL> return True <EOL> else : <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> return False <EOL> finally : <EOL> conf . env [ "<STR_LIT>" ] = old <EOL> return False <EOL> def check_fortran_dummy_main ( conf ) : <EOL> code_tpl = """<STR_LIT>""" <EOL> conf . start_message ( "<STR_LIT>" ) <EOL> old = copy . deepcopy ( conf . env [ "<STR_LIT>" ] ) <EOL> try : <EOL> conf . env [ "<STR_LIT>" ] . extend ( conf . env [ FC_RUNTIME_LDFLAGS ] ) <EOL> ret = conf . builders [ "<STR_LIT>" ] . try_program ( "<STR_LIT>" , <EOL> code_tpl % { "<STR_LIT>" : "<STR_LIT>" } ) <EOL> if ret : <EOL> conf . end_message ( "<STR_LIT:none>" ) <EOL> conf . env [ FC_DUMMY_MAIN ] = None <EOL> return True <EOL> else : <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> return False <EOL> finally : <EOL> conf . env [ "<STR_LIT>" ] = old <EOL> def check_fortran_mangling ( conf ) : <EOL> subr = """<STR_LIT>""" <EOL> main_tmpl = """<STR_LIT>""" <EOL> prog_tmpl = """<STR_LIT>""" <EOL> conf . start_message ( "<STR_LIT>" ) <EOL> old = { } <EOL> for k in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> old [ k ] = copy . deepcopy ( conf . env [ k ] ) <EOL> try : <EOL> mangling_lib = "<STR_LIT>" <EOL> ret = conf . builders [ "<STR_LIT>" ] . try_static_library ( mangling_lib , subr ) <EOL> if ret : <EOL> if conf . env [ FC_DUMMY_MAIN ] is not None : <EOL> main = main_tmpl % conf . env [ "<STR_LIT>" ] <EOL> else : <EOL> main = "<STR_LIT>" <EOL> conf . env [ "<STR_LIT>" ] . insert ( <NUM_LIT:0> , mangling_lib ) <EOL> libdir = conf . last_task . outputs [ - <NUM_LIT:1> ] . parent . abspath ( ) <EOL> conf . env [ "<STR_LIT>" ] . insert ( <NUM_LIT:0> , libdir ) <EOL> for u , du , case in mangling_generator ( ) : <EOL> names = { "<STR_LIT>" : mangle_func ( "<STR_LIT>" , u , du , case ) , <EOL> "<STR_LIT>" : mangle_func ( "<STR_LIT>" , u , du , case ) } <EOL> prog = prog_tmpl % names <EOL> name = "<STR_LIT>" <EOL> def _name ( u ) : <EOL> if u == "<STR_LIT:_>" : <EOL> return "<STR_LIT:u>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> name += "<STR_LIT>" % ( _name ( u ) , _name ( du ) , case ) <EOL> ret = conf . builders [ "<STR_LIT>" ] . try_program ( name , main + prog ) <EOL> if ret : <EOL> conf . env [ "<STR_LIT>" ] = ( u , du , case ) <EOL> conf . end_message ( "<STR_LIT>" % ( u , du , case ) ) <EOL> return <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> conf . fail_configuration ( None ) <EOL> else : <EOL> conf . end_message ( "<STR_LIT>" ) <EOL> conf . fail_configuration ( None ) <EOL> finally : <EOL> for k in old : <EOL> conf . env [ k ] = old [ k ] <EOL> def mangling_generator ( ) : <EOL> for under in [ '<STR_LIT:_>' , '<STR_LIT>' ] : <EOL> for double_under in [ '<STR_LIT>' , '<STR_LIT:_>' ] : <EOL> for case in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> yield under , double_under , case <EOL> def mangle_func ( name , under , double_under , case ) : <EOL> return getattr ( name , case ) ( ) + under + ( name . find ( "<STR_LIT:_>" ) != - <NUM_LIT:1> and double_under or '<STR_LIT>' ) </s>
