Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

Commit

Permalink
Account for valueless #defines
Browse files Browse the repository at this point in the history
  • Loading branch information
BKoller committed May 16, 2016
1 parent 2e8f06a commit 8837813
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions config_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ def parse_flags(build_log):

# macro definitions should be handled separately, so we can resolve duplicates
define_flags = dict()
define_regex = re.compile("-D([a-zA-Z0-9_]+)=(.*)")
define_regex = re.compile("-D\s*([a-zA-Z0-9_]+)(=.*)?")
define_flag = '-D'

# Used to only bundle filenames with applicable arguments
filename_flags = ["-o", "-I", "-isystem", "-include", "-imacros", "-isysroot"]
Expand Down Expand Up @@ -355,6 +356,10 @@ def parse_flags(build_log):

continue

if(word == define_flag):
flags.add(word + words[i+1])
continue

# include arguments for this option, if there are any, as a tuple
if(i != len(words) - 1 and word in filename_flags and words[i + 1][0] != '-'):
flags.add((word, os.path.realpath(os.path.join(cmd_pwd, words[i + 1]))))
Expand All @@ -378,7 +383,10 @@ def parse_flags(build_log):
print("WARNING: {} distinct definitions of macro {} found".format(len(values), name))
values.sort()

flags.add("-D{}={}".format(name, values[0]))
if values[0] != None:
flags.add("-D{}{}".format(name, values[0]))
else:
flags.add("-D{}".format(name))

return (line_count, skip_count, sorted(flags))

Expand Down

0 comments on commit 8837813

Please sign in to comment.