From 2e8f06a2dc4de9764690432188487b696e2e1aae Mon Sep 17 00:00:00 2001 From: Ben Koller Date: Sun, 15 May 2016 22:11:03 -0400 Subject: [PATCH 1/2] Treat include paths as relative to CWD of CC command --- config_gen.py | 6 +++++- fake-toolchain/Unix/cc | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config_gen.py b/config_gen.py index c282026..89f568e 100755 --- a/config_gen.py +++ b/config_gen.py @@ -337,8 +337,12 @@ def parse_flags(build_log): line_count += 1 words = split_flags(line) + cmd_pwd = './' + for (i, word) in enumerate(words): if(word[0] != '-' or not flags_whitelist.match(word)): + if(word.find('YCM_CONFIG_GEN_PWD') == 0): + cmd_pwd = word[word.find("=") + 1:] continue # handle macro definitions @@ -353,7 +357,7 @@ def parse_flags(build_log): # 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, words[i + 1])) + flags.add((word, os.path.realpath(os.path.join(cmd_pwd, words[i + 1])))) else: flags.add(word) diff --git a/fake-toolchain/Unix/cc b/fake-toolchain/Unix/cc index 9a321b6..4c52fcd 100755 --- a/fake-toolchain/Unix/cc +++ b/fake-toolchain/Unix/cc @@ -9,6 +9,6 @@ elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then $YCM_CONFIG_GEN_CC_PASSTHROUGH $@ else - echo "$@" >> $YCM_CONFIG_GEN_CC_LOG + echo "YCM_CONFIG_GEN_PWD=$(pwd) $@" >> $YCM_CONFIG_GEN_CC_LOG fi From 8837813a6335cb21b8f6c29a129ba12d2490cb90 Mon Sep 17 00:00:00 2001 From: Ben Koller Date: Sun, 15 May 2016 22:13:36 -0400 Subject: [PATCH 2/2] Account for valueless #defines --- config_gen.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config_gen.py b/config_gen.py index 89f568e..ee10a6f 100755 --- a/config_gen.py +++ b/config_gen.py @@ -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"] @@ -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])))) @@ -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))