|
26 | 26 | from platformio import __version__, fs
|
27 | 27 | from platformio.compat import IS_MACOS, string_types
|
28 | 28 | from platformio.package.version import pepver_to_semver
|
| 29 | +from platformio.proc import where_is_program |
29 | 30 |
|
30 | 31 | SRC_HEADER_EXT = ["h", "hpp"]
|
31 | 32 | SRC_ASM_EXT = ["S", "spp", "SPP", "sx", "s", "asm", "ASM"]
|
@@ -125,12 +126,21 @@ def _append_pio_macros():
|
125 | 126 | # remove specified flags
|
126 | 127 | env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
|
127 | 128 |
|
128 |
| - if "compiledb" in COMMAND_LINE_TARGETS and env.get( |
129 |
| - "COMPILATIONDB_INCLUDE_TOOLCHAIN" |
130 |
| - ): |
131 |
| - for scope, includes in env.DumpIntegrationIncludes().items(): |
132 |
| - if scope in ("toolchain",): |
133 |
| - env.Append(CPPPATH=includes) |
| 129 | + if "compiledb" in COMMAND_LINE_TARGETS: |
| 130 | + # Resolve absolute path of toolchain |
| 131 | + for cmd in ("CC", "CXX", "AS"): |
| 132 | + if cmd not in env: |
| 133 | + continue |
| 134 | + if os.path.isabs(env[cmd]): |
| 135 | + continue |
| 136 | + env[cmd] = where_is_program( |
| 137 | + env.subst("$%s" % cmd), env.subst("${ENV['PATH']}") |
| 138 | + ) |
| 139 | + |
| 140 | + if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"): |
| 141 | + for scope, includes in env.DumpIntegrationIncludes().items(): |
| 142 | + if scope in ("toolchain",): |
| 143 | + env.Append(CPPPATH=includes) |
134 | 144 |
|
135 | 145 |
|
136 | 146 | def ProcessProjectDeps(env):
|
@@ -207,9 +217,7 @@ def ParseFlagsExtended(env, flags): # pylint: disable=too-many-branches
|
207 | 217 | # fix relative path for "-include"
|
208 | 218 | for i, f in enumerate(result.get("CCFLAGS", [])):
|
209 | 219 | if isinstance(f, tuple) and f[0] == "-include":
|
210 |
| - p = env.subst(f[1].get_path()) |
211 |
| - if os.path.exists(p): |
212 |
| - result["CCFLAGS"][i] = (f[0], os.path.abspath(p)) |
| 220 | + result["CCFLAGS"][i] = (f[0], env.subst(f[1].get_path())) |
213 | 221 |
|
214 | 222 | return result
|
215 | 223 |
|
|
0 commit comments