🔨 Fatal error for wrong GCC on macOS Native Sim

This commit is contained in:
Scott Lahteine 2024-06-20 12:42:26 -05:00
parent a93acbd35c
commit a7444021c6

View File

@ -17,13 +17,25 @@ if pioutil.is_pio_build():
env['PROGNAME'] = "MarlinSimulator" env['PROGNAME'] = "MarlinSimulator"
# #
# If Xcode is installed add the path to its Frameworks folder, # Check for a valid GCC and available OpenGL on macOS
# or if Mesa is installed try to use its GL/gl.h.
# #
emsg = ''
fatal = 0
import sys import sys
if sys.platform == 'darwin': if sys.platform == 'darwin':
import shutil
gcc = shutil.which('gcc')
if gcc == '' or gcc == '/usr/bin/gcc':
if gcc == '':
emsg = "\u001b[31mNo GCC found in your configured shell PATH."
elif gcc == '/usr/bin/gcc':
emsg = "\u001b[31mCan't build Marlin Native on macOS using the included version of GCC (clang)."
emsg += "\n\u001b[31mSee 'native.ini' for instructions to install GCC with MacPorts or Homebrew."
fatal = 1
else:
# #
# Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS')
# #
@ -38,16 +50,20 @@ if pioutil.is_pio_build():
if os.path.exists(xcode_path): if os.path.exists(xcode_path):
env['BUILD_FLAGS'] += [ "-F" + xcode_path ] env['BUILD_FLAGS'] += [ "-F" + xcode_path ]
print("Using OpenGL framework headers from Xcode.app") emsg = "\u001b[33mUsing OpenGL framework headers from Xcode.app"
elif os.path.exists(mesa_path): elif os.path.exists(mesa_path):
env['BUILD_FLAGS'] += [ '-D__MESA__' ] env['BUILD_FLAGS'] += [ '-D__MESA__' ]
print("Using OpenGL header from", mesa_path) emsg = f"\u001b[33mUsing OpenGL header from {mesa_path}"
else: else:
print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n") emsg = "\u001b[31mNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h."
fatal = 1
# Print error message, if any
if emsg: print(f"\n\n{emsg}\n\n")
# Break out of the PIO build immediately # Break out of the PIO build immediately
sys.exit(1) if fatal: sys.exit(1)