<s> """<STR_LIT>""" <EOL> import copy <EOL> import os <EOL> TARGET_TYPE_EXT = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def _GetLargePdbShimCcPath ( ) : <EOL> """<STR_LIT>""" <EOL> this_dir = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> src_dir = os . path . abspath ( os . path . join ( this_dir , '<STR_LIT:..>' , '<STR_LIT:..>' ) ) <EOL> win_data_dir = os . path . join ( src_dir , '<STR_LIT:data>' , '<STR_LIT>' ) <EOL> large_pdb_shim_cc = os . path . join ( win_data_dir , '<STR_LIT>' ) <EOL> return large_pdb_shim_cc <EOL> def _DeepCopySomeKeys ( in_dict , keys ) : <EOL> """<STR_LIT>""" <EOL> d = { } <EOL> for key in keys : <EOL> if key not in in_dict : <EOL> continue <EOL> d [ key ] = copy . deepcopy ( in_dict [ key ] ) <EOL> return d <EOL> def _SuffixName ( name , suffix ) : <EOL> """<STR_LIT>""" <EOL> parts = name . rsplit ( '<STR_LIT:#>' , <NUM_LIT:1> ) <EOL> parts [ <NUM_LIT:0> ] = '<STR_LIT>' % ( parts [ <NUM_LIT:0> ] , suffix ) <EOL> return '<STR_LIT:#>' . join ( parts ) <EOL> def _ShardName ( name , number ) : <EOL> """<STR_LIT>""" <EOL> return _SuffixName ( name , str ( number ) ) <EOL> def ShardTargets ( target_list , target_dicts ) : <EOL> """<STR_LIT>""" <EOL> targets_to_shard = { } <EOL> for t in target_dicts : <EOL> shards = int ( target_dicts [ t ] . get ( '<STR_LIT>' , <NUM_LIT:0> ) ) <EOL> if shards : <EOL> targets_to_shard [ t ] = shards <EOL> new_target_list = [ ] <EOL> for t in target_list : <EOL> if t in targets_to_shard : <EOL> for i in range ( targets_to_shard [ t ] ) : <EOL> new_target_list . append ( _ShardName ( t , i ) ) <EOL> else : <EOL> new_target_list . append ( t ) <EOL> new_target_dicts = { } <EOL> for t in target_dicts : <EOL> if t in targets_to_shard : <EOL> for i in range ( targets_to_shard [ t ] ) : <EOL> name = _ShardName ( t , i ) <EOL> new_target_dicts [ name ] = copy . copy ( target_dicts [ t ] ) <EOL> new_target_dicts [ name ] [ '<STR_LIT>' ] = _ShardName ( <EOL> new_target_dicts [ name ] [ '<STR_LIT>' ] , i ) <EOL> sources = new_target_dicts [ name ] . get ( '<STR_LIT>' , [ ] ) <EOL> new_sources = [ ] <EOL> for pos in range ( i , len ( sources ) , targets_to_shard [ t ] ) : <EOL> new_sources . append ( sources [ pos ] ) <EOL> new_target_dicts [ name ] [ '<STR_LIT>' ] = new_sources <EOL> else : <EOL> new_target_dicts [ t ] = target_dicts [ t ] <EOL> for t in new_target_dicts : <EOL> for deptype in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> dependencies = copy . copy ( new_target_dicts [ t ] . get ( deptype , [ ] ) ) <EOL> new_dependencies = [ ] <EOL> for d in dependencies : <EOL> if d in targets_to_shard : <EOL> for i in range ( targets_to_shard [ d ] ) : <EOL> new_dependencies . append ( _ShardName ( d , i ) ) <EOL> else : <EOL> new_dependencies . append ( d ) <EOL> new_target_dicts [ t ] [ deptype ] = new_dependencies <EOL> return ( new_target_list , new_target_dicts ) <EOL> def _GetPdbPath ( target_dict , config_name , vars ) : <EOL> """<STR_LIT>""" <EOL> config = target_dict [ '<STR_LIT>' ] [ config_name ] <EOL> msvs = config . setdefault ( '<STR_LIT>' , { } ) <EOL> linker = msvs . get ( '<STR_LIT>' , { } ) <EOL> pdb_path = linker . get ( '<STR_LIT>' ) <EOL> if pdb_path : <EOL> return pdb_path <EOL> variables = target_dict . get ( '<STR_LIT>' , { } ) <EOL> pdb_path = variables . get ( '<STR_LIT>' , None ) <EOL> if pdb_path : <EOL> return pdb_path <EOL> pdb_base = target_dict . get ( '<STR_LIT>' , target_dict [ '<STR_LIT>' ] ) <EOL> pdb_base = '<STR_LIT>' % ( pdb_base , TARGET_TYPE_EXT [ target_dict [ '<STR_LIT:type>' ] ] ) <EOL> pdb_path = vars [ '<STR_LIT>' ] + '<STR_LIT:/>' + pdb_base <EOL> return pdb_path <EOL> def InsertLargePdbShims ( target_list , target_dicts , vars ) : <EOL> """<STR_LIT>""" <EOL> targets_to_shim = [ ] <EOL> for t in target_dicts : <EOL> target_dict = target_dicts [ t ] <EOL> if not int ( target_dict . get ( '<STR_LIT>' , <NUM_LIT:0> ) ) : <EOL> continue <EOL> targets_to_shim . append ( t ) <EOL> large_pdb_shim_cc = _GetLargePdbShimCcPath ( ) <EOL> for t in targets_to_shim : <EOL> target_dict = target_dicts [ t ] <EOL> target_name = target_dict . get ( '<STR_LIT>' ) <EOL> base_dict = _DeepCopySomeKeys ( target_dict , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> copy_suffix = '<STR_LIT>' <EOL> copy_target_name = target_name + '<STR_LIT:_>' + copy_suffix <EOL> full_copy_target_name = _SuffixName ( t , copy_suffix ) <EOL> shim_cc_basename = os . path . basename ( large_pdb_shim_cc ) <EOL> shim_cc_dir = vars [ '<STR_LIT>' ] + '<STR_LIT:/>' + copy_target_name <EOL> shim_cc_path = shim_cc_dir + '<STR_LIT:/>' + shim_cc_basename <EOL> copy_dict = copy . deepcopy ( base_dict ) <EOL> copy_dict [ '<STR_LIT>' ] = copy_target_name <EOL> copy_dict [ '<STR_LIT:type>' ] = '<STR_LIT:none>' <EOL> copy_dict [ '<STR_LIT>' ] = [ large_pdb_shim_cc ] <EOL> copy_dict [ '<STR_LIT>' ] = [ { <EOL> '<STR_LIT>' : shim_cc_dir , <EOL> '<STR_LIT>' : [ large_pdb_shim_cc ] <EOL> } ] <EOL> shim_suffix = '<STR_LIT>' <EOL> shim_target_name = target_name + '<STR_LIT:_>' + shim_suffix <EOL> full_shim_target_name = _SuffixName ( t , shim_suffix ) <EOL> shim_dict = copy . deepcopy ( base_dict ) <EOL> shim_dict [ '<STR_LIT>' ] = shim_target_name <EOL> shim_dict [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> shim_dict [ '<STR_LIT>' ] = [ shim_cc_path ] <EOL> shim_dict [ '<STR_LIT>' ] = [ full_copy_target_name ] <EOL> for config_name , config in shim_dict . get ( '<STR_LIT>' ) . iteritems ( ) : <EOL> pdb_path = _GetPdbPath ( target_dict , config_name , vars ) <EOL> for key in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:test>' ] : <EOL> config . pop ( key , None ) <EOL> msvs = config . setdefault ( '<STR_LIT>' , { } ) <EOL> compiler = msvs . setdefault ( '<STR_LIT>' , { } ) <EOL> compiler [ '<STR_LIT>' ] = '<STR_LIT:3>' <EOL> compiler [ '<STR_LIT>' ] = pdb_path <EOL> config = target_dict [ '<STR_LIT>' ] [ config_name ] <EOL> msvs = config . setdefault ( '<STR_LIT>' , { } ) <EOL> linker = msvs . setdefault ( '<STR_LIT>' , { } ) <EOL> linker [ '<STR_LIT>' ] = '<STR_LIT:true>' <EOL> linker [ '<STR_LIT>' ] = pdb_path <EOL> target_list . insert ( <NUM_LIT:0> , full_copy_target_name ) <EOL> target_list . insert ( <NUM_LIT:0> , full_shim_target_name ) <EOL> target_dicts [ full_copy_target_name ] = copy_dict <EOL> target_dicts [ full_shim_target_name ] = shim_dict <EOL> target_dict . setdefault ( '<STR_LIT>' , [ ] ) . append ( full_shim_target_name ) <EOL> return ( target_list , target_dicts ) </s>
