Skip to content

Commit e3a1deb

Browse files
authored
Fix IDE include paths / Intellisense (#615)
1 parent 578d3d2 commit e3a1deb

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

tools/platformio-build.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@
2727
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinopico")
2828
assert os.path.isdir(FRAMEWORK_DIR)
2929

30+
# read includes from this file to add them into CPPPATH later
31+
includes_file = os.path.join(FRAMEWORK_DIR, "lib", "platform_inc.txt")
32+
file_lines = []
33+
includes = []
34+
with open(includes_file, "r") as fp:
35+
file_lines = fp.readlines()
36+
for l in file_lines:
37+
path = l.strip().replace("-iwithprefixbefore/", "").replace("/", os.sep)
38+
# emulate -iprefix <framework path>.
39+
path = os.path.join(FRAMEWORK_DIR, path)
40+
# prevent non-existent paths from being added
41+
# looking at you here, pico-extras/src/common/pico_audio and co.
42+
if os.path.isdir(path):
43+
includes.append(path)
44+
3045
# update progsize expression to also check for bootloader.
3146
env.Replace(
3247
SIZEPROGREGEXP=r"^(?:\.boot2|\.text|\.data|\.rodata|\.text.align|\.ARM.exidx)\s+(\d+).*"
@@ -42,8 +57,10 @@
4257
"-mthumb",
4358
"-ffunction-sections",
4459
"-fdata-sections",
45-
"-iprefix" + os.path.join(FRAMEWORK_DIR),
46-
"@%s" % os.path.join(FRAMEWORK_DIR, "lib", "platform_inc.txt")
60+
# use explicit include (-I) paths, otherwise it's
61+
# not visible in the IDE's intellisense.
62+
#"-iprefix" + os.path.join(FRAMEWORK_DIR),
63+
#"@%s" % os.path.join(FRAMEWORK_DIR, "lib", "platform_inc.txt")
4764
],
4865

4966
CFLAGS=[
@@ -98,7 +115,8 @@
98115
File(os.path.join(FRAMEWORK_DIR, "lib", "libpico.a")),
99116
"m", "c", "stdc++", "c"]
100117
)
101-
118+
# expand with read includes
119+
env.Append(CPPPATH=includes)
102120

103121
def configure_usb_flags(cpp_defines):
104122
global ram_size

0 commit comments

Comments
 (0)