From ac1210fbeafa7de2193d2797b982024e8ab4faa2 Mon Sep 17 00:00:00 2001 From: Valerii Koval Date: Sun, 26 Apr 2020 00:35:22 +0300 Subject: [PATCH] Add -imacros files to forcedInclude field in VSCode template --- .../vscode/.vscode/c_cpp_properties.json.tpl | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl index 86667688..930854d3 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -52,15 +52,21 @@ % % def _find_forced_includes(flags, inc_paths): % result = [] +% include_args = ("-include", "-imacros") % for f in flags: -% inc = "" -% if f.startswith("-include") and f.split("-include")[1].strip(): -% inc = f.split("-include")[1].strip() -% elif not f.startswith("-"): -% inc = f +% if not f.startswith(include_args): +% continue % end -% if inc: -% result.append(_find_abs_path(inc, inc_paths)) +% for arg in include_args: +% inc = "" +% if f.startswith(arg) and f.split(arg)[1].strip(): +% inc = f.split(arg)[1].strip() +% elif not f.startswith("-"): +% inc = f +% end +% if inc: +% result.append(_find_abs_path(inc, inc_paths)) +% end % end % end % return result @@ -73,7 +79,7 @@ % cxx_stds = STD_RE.findall(cxx_flags) % cc_m_flags = split_args(cc_flags) % forced_includes = _find_forced_includes( -% filter_args(cc_m_flags, ["-include"]), cleaned_includes) +% filter_args(cc_m_flags, ["-include", "-imacros"]), cleaned_includes) % { "configurations": [ @@ -129,7 +135,7 @@ "compilerArgs": [ % for flag in [ % '"%s"' % _escape(f) if _escape_required(f) else f -% for f in filter_args(cc_m_flags, ["-m", "-i", "@"], ["-include"]) +% for f in filter_args(cc_m_flags, ["-m", "-i", "@"], ["-include", "-imacros"]) % ]: "{{ flag }}", % end