Quellcode durchsuchen

🔨 Use first g++ in path for 'native' targets

Scott Lahteine vor 2 Jahren
Ursprung
Commit
505ab1bb62
2 geänderte Dateien mit 16 neuen und 9 gelöschten Zeilen
  1. 10
    6
      buildroot/share/PlatformIO/scripts/preprocessor.py
  2. 6
    3
      ini/native.ini

+ 10
- 6
buildroot/share/PlatformIO/scripts/preprocessor.py Datei anzeigen

3
 #
3
 #
4
 import subprocess,os,re
4
 import subprocess,os,re
5
 
5
 
6
+nocache = 1
6
 verbose = 0
7
 verbose = 0
7
 
8
 
8
 def blab(str):
9
 def blab(str):
50
 #
51
 #
51
 def search_compiler(env):
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
 	GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path")
55
 	GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path")
55
 
56
 
56
 	try:
57
 	try:
60
 	except:
61
 	except:
61
 		pass
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
 		blab("Getting g++ path from cache")
66
 		blab("Getting g++ path from cache")
65
 		with open(GCC_PATH_CACHE, 'r') as f:
67
 		with open(GCC_PATH_CACHE, 'r') as f:
66
 			return f.read()
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
 	gcc = "g++"
75
 	gcc = "g++"
72
 	if env['PLATFORM'] == 'win32':
76
 	if env['PLATFORM'] == 'win32':
73
 		path_separator = ';'
77
 		path_separator = ';'
87
 			# Use entire path to not rely on env PATH
91
 			# Use entire path to not rely on env PATH
88
 			filepath = os.path.sep.join([pathdir, filepath])
92
 			filepath = os.path.sep.join([pathdir, filepath])
89
 			# Cache the g++ path to no search always
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
 				blab("Caching g++ for current env")
95
 				blab("Caching g++ for current env")
92
 				with open(GCC_PATH_CACHE, 'w+') as f:
96
 				with open(GCC_PATH_CACHE, 'w+') as f:
93
 					f.write(filepath)
97
 					f.write(filepath)

+ 6
- 3
ini/native.ini Datei anzeigen

63
 #
63
 #
64
 # Simulator for macOS (MacPorts)
64
 # Simulator for macOS (MacPorts)
65
 #
65
 #
66
-#  sudo port install gcc10 gdb glm libsdl2 libsdl2_net freetype
66
+#  sudo port install gcc11 gdb glm libsdl2 libsdl2_net freetype
67
 #  sudo port install ld64 @3_3 +ld64_xcode
67
 #  sudo port install ld64 @3_3 +ld64_xcode
68
 #
68
 #
69
 #  cd /opt/local/bin
69
 #  cd /opt/local/bin
70
 #  sudo rm -f gcc g++ cc
70
 #  sudo rm -f gcc g++ cc
71
-#  sudo ln -s gcc-mp-10 gcc ; sudo ln -s g++-mp-10 g++ ; sudo ln -s g++ cc
71
+#  sudo ln -s gcc-mp-11 gcc ; sudo ln -s g++-mp-11 g++ ; sudo ln -s g++ cc
72
 # This step may be obsolete:
72
 # This step may be obsolete:
73
 #  sudo port uninstall ld64 ld64-latest
73
 #  sudo port uninstall ld64 ld64-latest
74
 #
74
 #
79
 #
79
 #
80
 [simulator_macos]
80
 [simulator_macos]
81
 build_unflags     = -lGL
81
 build_unflags     = -lGL
82
-custom_verbose    = 0
83
 build_flags       =
82
 build_flags       =
84
   -I/opt/local/include
83
   -I/opt/local/include
85
   -I/opt/local/include/freetype2
84
   -I/opt/local/include/freetype2
93
 extends         = env:simulator_linux_debug
92
 extends         = env:simulator_linux_debug
94
 build_flags     = ${env:simulator_linux_debug.build_flags} ${simulator_macos.build_flags} -ggdb -Og -D_THREAD_SAFE
93
 build_flags     = ${env:simulator_linux_debug.build_flags} ${simulator_macos.build_flags} -ggdb -Og -D_THREAD_SAFE
95
 build_unflags   = ${simulator_macos.build_unflags}
94
 build_unflags   = ${simulator_macos.build_unflags}
95
+custom_verbose  = 0
96
+custom_gcc      = g++
96
 
97
 
97
 [env:simulator_macos_release]
98
 [env:simulator_macos_release]
98
 extends         = env:simulator_linux_release
99
 extends         = env:simulator_linux_release
99
 build_flags     = ${env:simulator_linux_release.build_flags} ${simulator_macos.build_flags}
100
 build_flags     = ${env:simulator_linux_release.build_flags} ${simulator_macos.build_flags}
100
 build_unflags   = ${simulator_macos.build_unflags}
101
 build_unflags   = ${simulator_macos.build_unflags}
102
+custom_verbose  = 0
103
+custom_gcc      = g++
101
 
104
 
102
 #
105
 #
103
 # Simulator for Windows 10
106
 # Simulator for Windows 10

Laden…
Abbrechen
Speichern