#NEWLINE# def _arm_compile( self , assembly ) : #NEWLINE# #INDENT# rc = 0 #NEWLINE# ctx = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# f_asm = tempfile . NamedTemporaryFile ( delete = False ) #NEWLINE# f_obj = tempfile . NamedTemporaryFile ( delete = False ) #NEWLINE# f_bin = tempfile . NamedTemporaryFile ( delete = False ) #NEWLINE# f_asm . write ( ( assembly + '\n' ) ) #NEWLINE# f_asm . close ( ) #NEWLINE# cmd_fmt = 'gcc -c -x assembler {asm} -o {obj} -mthumb -march=armv7-a; objcopy -O binary {obj} {bin};' #NEWLINE# cmd = cmd_fmt . format ( asm = f_asm . name , obj = f_obj . name , bin = f_bin . name ) #NEWLINE# return_code = subprocess . call ( cmd , shell = True ) #NEWLINE# if ( return_code == 0 ) : #NEWLINE# #INDENT# binary = '' #NEWLINE# byte = f_bin . read ( 1 ) #NEWLINE# while return_code : #NEWLINE# #INDENT# binary += byte #NEWLINE# byte = f_bin . read ( 1 ) #NEWLINE# #UNINDENT# f_bin . close ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'gcc error' ) #NEWLINE# #UNINDENT# os . remove ( f_asm . name ) #NEWLINE# os . remove ( f_obj . name ) #NEWLINE# os . remove ( f_bin . name ) #NEWLINE# return binary