mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-29 23:07:42 +00:00
🔨 Skip bad compilers
This commit is contained in:
parent
80cfdb182c
commit
f2d585ac7f
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# preprocessor.py
|
# preprocessor.py
|
||||||
#
|
#
|
||||||
import subprocess
|
import subprocess, os
|
||||||
|
|
||||||
nocache = 1
|
nocache = 1
|
||||||
verbose = 0
|
verbose = 0
|
||||||
@ -53,12 +53,14 @@ def run_preprocessor(env, fn=None):
|
|||||||
# Find a compiler, considering the OS
|
# Find a compiler, considering the OS
|
||||||
#
|
#
|
||||||
def search_compiler(env):
|
def search_compiler(env):
|
||||||
|
global nocache
|
||||||
|
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
|
|
||||||
ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
|
ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
|
||||||
GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path"
|
GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path"
|
||||||
|
|
||||||
|
gccpath = None
|
||||||
try:
|
try:
|
||||||
gccpath = env.GetProjectOption('custom_gcc')
|
gccpath = env.GetProjectOption('custom_gcc')
|
||||||
blab("Getting compiler from env")
|
blab("Getting compiler from env")
|
||||||
@ -71,24 +73,42 @@ def search_compiler(env):
|
|||||||
blab("Getting g++ path from cache")
|
blab("Getting g++ path from cache")
|
||||||
return GCC_PATH_CACHE.read_text()
|
return GCC_PATH_CACHE.read_text()
|
||||||
|
|
||||||
# Use any item in $PATH corresponding to a platformio toolchain bin folder
|
|
||||||
path_separator = ':'
|
path_separator = ':'
|
||||||
gcc_exe = '*g++'
|
gcc_exe = '*g++'
|
||||||
if env['PLATFORM'] == 'win32':
|
|
||||||
|
sysname = os.uname().sysname
|
||||||
|
if sysname == 'Windows':
|
||||||
path_separator = ';'
|
path_separator = ';'
|
||||||
gcc_exe += ".exe"
|
gcc_exe += ".exe"
|
||||||
|
|
||||||
|
envpath = map(Path, env['ENV']['PATH'].split(path_separator))
|
||||||
|
|
||||||
# Search for the compiler in PATH
|
# Search for the compiler in PATH
|
||||||
for ppath in map(Path, env['ENV']['PATH'].split(path_separator)):
|
for ppath in envpath:
|
||||||
|
# Use any item in $PATH corresponding to a platformio toolchain bin folder
|
||||||
if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"):
|
if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"):
|
||||||
for gpath in ppath.glob(gcc_exe):
|
for gpath in ppath.glob(gcc_exe):
|
||||||
|
# Skip '*-elf-g++' (crosstool-NG)
|
||||||
|
if not gpath.stem.endswith('-elf-g++'):
|
||||||
gccpath = str(gpath.resolve())
|
gccpath = str(gpath.resolve())
|
||||||
# Cache the g++ path to no search always
|
break
|
||||||
if not nocache and ENV_BUILD_PATH.exists():
|
|
||||||
|
if not gccpath:
|
||||||
|
for ppath in envpath:
|
||||||
|
for gpath in ppath.glob(gcc_exe):
|
||||||
|
# Skip macOS Clang
|
||||||
|
if gpath != 'usr/bin/g++' or sysname != 'Darwin':
|
||||||
|
gccpath = str(gpath.resolve())
|
||||||
|
break
|
||||||
|
|
||||||
|
if not gccpath:
|
||||||
|
gccpath = env.get('CXX')
|
||||||
|
blab("Couldn't find a compiler! Fallback to '%s'" % gccpath)
|
||||||
|
nocache = 1
|
||||||
|
|
||||||
|
# Cache the g++ path to speed up the next build
|
||||||
|
if not nocache and gccpath and ENV_BUILD_PATH.exists():
|
||||||
blab("Caching g++ for current env")
|
blab("Caching g++ for current env")
|
||||||
GCC_PATH_CACHE.write_text(gccpath)
|
GCC_PATH_CACHE.write_text(gccpath)
|
||||||
return gccpath
|
|
||||||
|
|
||||||
gccpath = env.get('CXX')
|
|
||||||
blab("Couldn't find a compiler! Fallback to %s" % gccpath)
|
|
||||||
return gccpath
|
return gccpath
|
||||||
|
Loading…
Reference in New Issue
Block a user