From 797ceabec8e9100b8180a7deca7d34bdc3502485 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Fri, 7 Sep 2018 07:12:45 +0200 Subject: [PATCH 1/4] add '-target' to whitelist e.g. -target arm-none-eabi In your prefered build system you could add this build flag. for Makefile: ifeq($(YCMG), 1) CFLAGS += -target arm-none-eabi endif and start the generator in vim with: YCMGeneratConfig -M=YCMG=1 -f Probably this could be done automatically with the fake build system? --- config_gen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: From 20f1fe65c95c1298bbc4a46227b97d55f04bd6b5 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Wed, 13 Feb 2019 23:02:04 +0100 Subject: [PATCH 2/4] add -target arm-none-eabi for arm-none-eabi fake-toolchain --- fake-toolchain/Unix/arm-none-eabi-g++ | 15 ++++++++++++++- fake-toolchain/Unix/arm-none-eabi-gcc | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) mode change 120000 => 100755 fake-toolchain/Unix/arm-none-eabi-g++ mode change 120000 => 100755 fake-toolchain/Unix/arm-none-eabi-gcc 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 + From 64dad94d85c25667716fda7e9517412bdd0da6c3 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Thu, 11 Jul 2019 07:55:12 +0200 Subject: [PATCH 3/4] avr: create new avr fakes --- fake-toolchain/Unix/avr-g++ | 17 ++++++++++++++++- fake-toolchain/Unix/avr-gcc | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) mode change 120000 => 100755 fake-toolchain/Unix/avr-g++ mode change 120000 => 100755 fake-toolchain/Unix/avr-gcc 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 + From 0dc2923ad757b397e10e341798295425a02d9293 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Thu, 11 Jul 2019 08:36:47 +0200 Subject: [PATCH 4/4] it's now possible to create a ycm_extra_manual_config.py with a list of extra_flags so you would be able to import some extra stuff like test-frameworks ycm_extra_manual_config.py: extra_flags = ['-I./my_testframework/inc', '-I./some_other_includes'] --- template.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)