<s> import glob <EOL> import os <EOL> import sys <EOL> TARGET_PLATFORM = { <EOL> '<STR_LIT>' : '<STR_LIT:win32>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:win32>' : '<STR_LIT:win32>' , <EOL> } [ sys . platform ] <EOL> SHARED_LIBRARY_SUFFIX = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:win32>' : '<STR_LIT>' , <EOL> } [ TARGET_PLATFORM ] <EOL> STATIC_LIBRARY_SUFFIX = { <EOL> '<STR_LIT>' : '<STR_LIT:a>' , <EOL> '<STR_LIT>' : '<STR_LIT:a>' , <EOL> '<STR_LIT:win32>' : '<STR_LIT>' , <EOL> } [ TARGET_PLATFORM ] <EOL> EXCLUDE_SHARED_LIBRARIES = { <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> '<STR_LIT:win32>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> } [ TARGET_PLATFORM ] <EOL> EXCLUDE_STATIC_LIBRARIES = { <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> '<STR_LIT:win32>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> } [ TARGET_PLATFORM ] <EOL> GYPI_TEMPLATE = """<STR_LIT>""" <EOL> def main ( target_file , code_dir , shared_dir , static_dir ) : <EOL> ( shared_libraries , shared_v8_libraries ) = searh_files ( <EOL> shared_dir , SHARED_LIBRARY_SUFFIX , EXCLUDE_SHARED_LIBRARIES ) <EOL> ( static_libraries , static_v8_libraries ) = searh_files ( <EOL> static_dir , STATIC_LIBRARY_SUFFIX , EXCLUDE_STATIC_LIBRARIES ) <EOL> content = GYPI_TEMPLATE % { <EOL> '<STR_LIT:src>' : repr ( os . path . abspath ( code_dir ) ) , <EOL> '<STR_LIT>' : repr ( os . path . abspath ( shared_dir ) ) , <EOL> '<STR_LIT>' : repr ( os . path . abspath ( static_dir ) ) , <EOL> '<STR_LIT>' : shared_libraries , <EOL> '<STR_LIT>' : shared_v8_libraries , <EOL> '<STR_LIT>' : static_libraries , <EOL> '<STR_LIT>' : static_v8_libraries , <EOL> } <EOL> with open ( target_file , '<STR_LIT>' ) as f : <EOL> f . write ( content ) <EOL> def searh_files ( src , suffix , exclude ) : <EOL> files = glob . glob ( os . path . join ( src , '<STR_LIT>' + suffix ) ) <EOL> files = [ f for f in files if os . path . basename ( f ) not in exclude ] <EOL> return ( [ os . path . abspath ( f ) for f in files if not is_v8_library ( f ) ] , <EOL> [ os . path . abspath ( f ) for f in files if is_v8_library ( f ) ] ) <EOL> def is_v8_library ( p ) : <EOL> return ( os . path . basename ( p ) . startswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) or <EOL> os . path . basename ( p ) . startswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( main ( sys . argv [ <NUM_LIT:1> ] , sys . argv [ <NUM_LIT:2> ] , sys . argv [ <NUM_LIT:3> ] , sys . argv [ <NUM_LIT:4> ] ) ) </s>
