diff --git a/config_gen.py b/config_gen.py index 6089b20..c44bf1c 100755 --- a/config_gen.py +++ b/config_gen.py @@ -420,7 +420,7 @@ def parse_flags(build_log): # -warnings (-Werror), but no assembler, etc. flags (-Wa,-option) # -language (-std=gnu99) and standard library (-nostdlib) # -word size (-m64) - flags_whitelist = ["-[iIDF].*", "-W[^,]*", "-std=[a-z0-9+]+", "-(no)?std(lib|inc)", "-m[0-9]+"] + flags_whitelist = ["-[iIDF].*", "-W[^,]*", "-std=[a-z0-9+]+", "-(no)?std(lib|inc)", "-m[0-9]+", "-target"] flags_whitelist = re.compile("|".join(map("^{}$".format, flags_whitelist))) flags = set() line_count = 0 @@ -430,7 +430,7 @@ def parse_flags(build_log): define_regex = re.compile("-D([a-zA-Z0-9_]+)=(.*)") # Used to only bundle filenames with applicable arguments - filename_flags = ["-o", "-I", "-isystem", "-iquote", "-include", "-imacros", "-isysroot"] + filename_flags = ["-o", "-I", "-isystem", "-iquote", "-include", "-imacros", "-isysroot", "-target"] # Process build log for line in build_log: diff --git a/fake-toolchain/Unix/arm-none-eabi-g++ b/fake-toolchain/Unix/arm-none-eabi-g++ deleted file mode 120000 index 34836c6..0000000 --- a/fake-toolchain/Unix/arm-none-eabi-g++ +++ /dev/null @@ -1 +0,0 @@ -cxx \ No newline at end of file diff --git a/fake-toolchain/Unix/arm-none-eabi-g++ b/fake-toolchain/Unix/arm-none-eabi-g++ new file mode 100755 index 0000000..f3be24e --- /dev/null +++ b/fake-toolchain/Unix/arm-none-eabi-g++ @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then + # Cmake determines compiler properties by compiling a test file, so call clang for this case + $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@ + +elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then + # Needed to enable clang-specific options for certain build systems (e.g. linux) + $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@ + +else + echo "$@" >> $YCM_CONFIG_GEN_CXX_LOG -target arm-none-eabi +fi + diff --git a/fake-toolchain/Unix/arm-none-eabi-gcc b/fake-toolchain/Unix/arm-none-eabi-gcc deleted file mode 120000 index 2652f5f..0000000 --- a/fake-toolchain/Unix/arm-none-eabi-gcc +++ /dev/null @@ -1 +0,0 @@ -cc \ No newline at end of file diff --git a/fake-toolchain/Unix/arm-none-eabi-gcc b/fake-toolchain/Unix/arm-none-eabi-gcc new file mode 100755 index 0000000..7749714 --- /dev/null +++ b/fake-toolchain/Unix/arm-none-eabi-gcc @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then + # Cmake determines compiler properties by compiling a test file, so call clang for this case + $YCM_CONFIG_GEN_CC_PASSTHROUGH $@ + +elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then + # Needed to enable clang-specific options for certain build systems (e.g. linux) + $YCM_CONFIG_GEN_CC_PASSTHROUGH $@ + +else + echo "$@" >> $YCM_CONFIG_GEN_CC_LOG -target arm-none-eabi +fi + diff --git a/fake-toolchain/Unix/avr-g++ b/fake-toolchain/Unix/avr-g++ deleted file mode 120000 index 34836c6..0000000 --- a/fake-toolchain/Unix/avr-g++ +++ /dev/null @@ -1 +0,0 @@ -cxx \ No newline at end of file diff --git a/fake-toolchain/Unix/avr-g++ b/fake-toolchain/Unix/avr-g++ new file mode 100755 index 0000000..03b56b9 --- /dev/null +++ b/fake-toolchain/Unix/avr-g++ @@ -0,0 +1,16 @@ +#!/bin/sh + +AVR_LIB=$(cat /tmp/avr_gcc_include) + +if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then + # Cmake determines compiler properties by compiling a test file, so call clang for this case + $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@ + +elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then + # Needed to enable clang-specific options for certain build systems (e.g. linux) + $YCM_CONFIG_GEN_CXX_PASSTHROUGH $@ + +else + echo "$@" >> $YCM_CONFIG_GEN_CXX_LOG -isystem $AVR_LIB -D__flash= --target=avr +fi + diff --git a/fake-toolchain/Unix/avr-gcc b/fake-toolchain/Unix/avr-gcc deleted file mode 120000 index 2652f5f..0000000 --- a/fake-toolchain/Unix/avr-gcc +++ /dev/null @@ -1 +0,0 @@ -cc \ No newline at end of file diff --git a/fake-toolchain/Unix/avr-gcc b/fake-toolchain/Unix/avr-gcc new file mode 100755 index 0000000..ce7b1cf --- /dev/null +++ b/fake-toolchain/Unix/avr-gcc @@ -0,0 +1,16 @@ +#!/bin/sh + +AVR_LIB=$(cat /tmp/avr_gcc_include) + +if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then + # Cmake determines compiler properties by compiling a test file, so call clang for this case + $YCM_CONFIG_GEN_CC_PASSTHROUGH $@ + +elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then + # Needed to enable clang-specific options for certain build systems (e.g. linux) + $YCM_CONFIG_GEN_CC_PASSTHROUGH $@ + +else + echo "$@" >> $YCM_CONFIG_GEN_CC_LOG -isystem $AVR_LIB -D__flash= --target=avr +fi + diff --git a/template.py b/template.py index 7f52bb4..8c33760 100644 --- a/template.py +++ b/template.py @@ -36,11 +36,22 @@ import re import subprocess +import os.path as p +import sys + +DIR_OF_THIS = p.abspath(p.dirname(__file__)) +sys.path.append(DIR_OF_THIS) + +try: + from ycm_extra_manual_config import extra_flags +except ImportError: + extra_flags = [] flags = [ # INSERT FLAGS HERE ] +flags += extra_flags def LoadSystemIncludes(): regex = re.compile(r'(?:\#include \<...\> search starts here\:)(?P.*?)(?:End of search list)', re.DOTALL)