Skip to content

Commit dc0a233

Browse files
Olli-Pekka PuolitaivalCruz Monrreal II
authored andcommitted
Fix building with python 3
1 parent 9cbc91f commit dc0a233

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tools/toolchains/__init__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,23 @@ def relative_object_path(self, build_path, base_dir, source):
812812
mkdir(obj_dir)
813813
return join(obj_dir, name + '.o')
814814

815-
# Generate response file for all includes.
816-
# ARM, GCC, IAR cross compatible
815+
def make_option_file(self, options, naming=".options_{}.txt"):
816+
""" Generate a via file for a pile of defines
817+
ARM, GCC, IAR cross compatible
818+
"""
819+
to_write = " ".join(options).encode('utf-8')
820+
new_md5 = md5(to_write).hexdigest()
821+
via_file = join(self.build_dir, naming.format(new_md5))
822+
try:
823+
with open(via_file, "r") as fd:
824+
old_md5 = md5(fd.read().encode('utf-8')).hexdigest()
825+
except IOError:
826+
old_md5 = None
827+
if old_md5 != new_md5:
828+
with open(via_file, "wb") as fd:
829+
fd.write(to_write)
830+
return via_file
831+
817832
def get_inc_file(self, includes):
818833
include_file = join(self.build_dir, ".includes_%s.txt" % self.inc_md5)
819834
if not exists(include_file):

0 commit comments

Comments
 (0)