|
@@ -3,6 +3,7 @@
|
3
|
3
|
#
|
4
|
4
|
import subprocess,os,re
|
5
|
5
|
|
|
6
|
+nocache = 1
|
6
|
7
|
verbose = 0
|
7
|
8
|
|
8
|
9
|
def blab(str):
|
|
@@ -50,7 +51,7 @@ def run_preprocessor(env, fn=None):
|
50
|
51
|
#
|
51
|
52
|
def search_compiler(env):
|
52
|
53
|
|
53
|
|
- ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV'])
|
|
54
|
+ ENV_BUILD_PATH = os.path.join(env['PROJECT_BUILD_DIR'], env['PIOENV'])
|
54
|
55
|
GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path")
|
55
|
56
|
|
56
|
57
|
try:
|
|
@@ -60,14 +61,17 @@ def search_compiler(env):
|
60
|
61
|
except:
|
61
|
62
|
pass
|
62
|
63
|
|
63
|
|
- if os.path.exists(GCC_PATH_CACHE):
|
|
64
|
+ # Warning: The cached .gcc_path will obscure a newly-installed toolkit
|
|
65
|
+ if not nocache and os.path.exists(GCC_PATH_CACHE):
|
64
|
66
|
blab("Getting g++ path from cache")
|
65
|
67
|
with open(GCC_PATH_CACHE, 'r') as f:
|
66
|
68
|
return f.read()
|
67
|
69
|
|
68
|
|
- # Find the current platform compiler by searching the $PATH
|
69
|
|
- # which will be in a platformio toolchain bin folder
|
70
|
|
- path_regex = re.escape(env['PROJECT_PACKAGES_DIR'])
|
|
70
|
+ # Find a platform compiler by searching $PATH items
|
|
71
|
+ # A native target will search all PATH bin folders.
|
|
72
|
+ # Others look only within $HOME/.platformio.
|
|
73
|
+ path_regex = "" if env.GetProjectOption('platform') == 'native' else re.escape(env['PROJECT_PACKAGES_DIR'])
|
|
74
|
+
|
71
|
75
|
gcc = "g++"
|
72
|
76
|
if env['PLATFORM'] == 'win32':
|
73
|
77
|
path_separator = ';'
|
|
@@ -87,7 +91,7 @@ def search_compiler(env):
|
87
|
91
|
# Use entire path to not rely on env PATH
|
88
|
92
|
filepath = os.path.sep.join([pathdir, filepath])
|
89
|
93
|
# Cache the g++ path to no search always
|
90
|
|
- if os.path.exists(ENV_BUILD_PATH):
|
|
94
|
+ if not nocache and os.path.exists(ENV_BUILD_PATH):
|
91
|
95
|
blab("Caching g++ for current env")
|
92
|
96
|
with open(GCC_PATH_CACHE, 'w+') as f:
|
93
|
97
|
f.write(filepath)
|