#NEWLINE# def compile_chipmunk( self ) : #NEWLINE# #INDENT# if self . release : #NEWLINE# #INDENT# print ( 'compiling chipmunk in Release mode (No debug output or asserts)' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'compiling chipmunk in Debug mode (Defualt, prints debug output and asserts)' ) #NEWLINE# #UNINDENT# compiler = cc . new_compiler ( compiler = self . compiler ) #NEWLINE# source_folders = [ 'chipmunk_src' , os . path . join ( 'chipmunk_src' , 'constraints' ) ] #NEWLINE# sources = [ ] #NEWLINE# for folder in source_folders : #NEWLINE# #INDENT# for fn in os . listdir ( folder ) : #NEWLINE# #INDENT# fn_path = os . path . join ( folder , fn ) #NEWLINE# if ( fn_path [ ( - 1 ) ] == 'c' ) : #NEWLINE# #INDENT# sources . append ( fn_path ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( fn_path [ ( - 1 ) ] == 'o' ) : #NEWLINE# #INDENT# os . remove ( fn_path ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# include_folders = [ os . path . join ( 'chipmunk_src' , 'include' , 'chipmunk' ) ] #NEWLINE# compiler_preargs = [ '-std=gnu99' , '-ffast-math' , '-DCHIPMUNK_FFI' , '-Wno-unknown-pragmas' , '-DCP_USE_CGPOINTS=0' ] #NEWLINE# if self . release : #NEWLINE# #INDENT# compiler_preargs . append ( '-DNDEBUG' ) #NEWLINE# #UNINDENT# arch = ( ctypes . sizeof ( ctypes . c_voidp ) * 8 ) #NEWLINE# if ( ( arch == 64 ) and ( platform . system ( ) == 'Linux' ) ) : #NEWLINE# #INDENT# compiler_preargs += [ '-m64' , '-O3' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( arch == 32 ) and ( platform . system ( ) == 'Linux' ) ) : #NEWLINE# #INDENT# compiler_preargs += [ '-m32' , '-O3' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( platform . system ( ) == 'Darwin' ) : #NEWLINE# #INDENT# compiler_preargs += [ '-arch' , 'i386' , '-arch' , 'x86_64' ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( platform . system ( ) in ( 'Windows' , 'Microsoft' ) ) : #NEWLINE# #INDENT# compiler_preargs += [ '-shared' ] #NEWLINE# #UNINDENT# if ( ( arch == 64 ) and ( platform . system ( ) in ( 'Windows' , 'Microsoft' ) ) ) : #NEWLINE# #INDENT# compiler_preargs += [ '-m64' ] #NEWLINE# #UNINDENT# if ( ( arch == 32 ) and ( platform . system ( ) in ( 'Windows' , 'Microsoft' ) ) ) : #NEWLINE# #INDENT# compiler_preargs += [ '-O2' , '-m32' ] #NEWLINE# #UNINDENT# for x in compiler . executables : #NEWLINE# #INDENT# args = getattr ( compiler , x ) #NEWLINE# try : #NEWLINE# #INDENT# args . remove ( '-mno-cygwin' ) #NEWLINE# args . remove ( '-mdll' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# objs = compiler . compile ( sources , include_dirs = include_folders , extra_preargs = compiler_preargs ) #NEWLINE# libname = 'chipmunk' #NEWLINE# if ( ( arch == 64 ) and ( platform . system ( ) != 'Darwin' ) ) : #NEWLINE# #INDENT# libname += '64' #NEWLINE# #UNINDENT# if ( platform . system ( ) == 'Darwin' ) : #NEWLINE# #INDENT# libname = compiler . library_filename ( libname , lib_type = 'dylib' ) #NEWLINE# compiler . set_executable ( 'linker_so' , [ 'cc' , '-dynamiclib' , '-arch' , 'i386' , '-arch' , 'x86_64' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# libname = compiler . library_filename ( libname , lib_type = 'shared' ) #NEWLINE# #UNINDENT# linker_preargs = [ ] #NEWLINE# if ( ( platform . system ( ) == 'Linux' ) and ( platform . machine ( ) == 'x86_64' ) ) : #NEWLINE# #INDENT# linker_preargs += [ '-fPIC' ] #NEWLINE# #UNINDENT# if ( platform . system ( ) in ( 'Windows' , 'Microsoft' ) ) : #NEWLINE# #INDENT# if ( arch == 32 ) : #NEWLINE# #INDENT# linker_preargs += [ '-m32' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# linker_preargs += [ '-m64' ] #NEWLINE# #UNINDENT# compiler . dll_libraries = [ lib for lib in compiler . dll_libraries if ( not lib . startswith ( 'msvcr' ) ) ] #NEWLINE# #UNINDENT# compiler . link ( cc . CCompiler . SHARED_LIBRARY , objs , libname , output_dir = 'pymunk' , extra_preargs = linker_preargs )