+def xor8(buf):
+ import functools
+
+ return functools.reduce(lambda x, y: (x & 0xff) ^ (y & 0xff), buf)
+
+def build_frm(target, source, env):
+ with open(str(source[0]), 'rb') as f_in:
+ buf = f_in.read()
+
+ with open(str(target[0]), 'wb') as f_out:
+ f_out.write(buf)
+ f_out.write(bytearray([xor8(buf)]))
+
+ return 0
+
+root_env.Append(BUILDERS = { 'Frm': Builder(
+ action=Action(build_frm, '$FRMCOMSTR'),
+ suffix='.frm',
+ src_suffix='.bin')})
+