2021-07-21 19:01:23 -05:00
|
|
|
#
|
2021-11-04 05:28:42 -05:00
|
|
|
# simulator.py
|
2021-07-21 19:01:23 -05:00
|
|
|
# PlatformIO pre: script for simulator builds
|
|
|
|
#
|
2022-08-06 01:17:46 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
import pioutil
|
|
|
|
if pioutil.is_pio_build():
|
2022-08-19 11:00:52 -05:00
|
|
|
# Get the environment thus far for the build
|
|
|
|
Import("env")
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
#print(env.Dump())
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
#
|
|
|
|
# Give the binary a distinctive name
|
|
|
|
#
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
env['PROGNAME'] = "MarlinSimulator"
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
#
|
|
|
|
# If Xcode is installed add the path to its Frameworks folder,
|
|
|
|
# or if Mesa is installed try to use its GL/gl.h.
|
|
|
|
#
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
import sys
|
|
|
|
if sys.platform == 'darwin':
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
#
|
|
|
|
# Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS')
|
|
|
|
#
|
|
|
|
env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ]
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
# Default paths for Xcode and a lucky GL/gl.h dropped by Mesa
|
|
|
|
xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
|
|
|
|
mesa_path = "/opt/local/include/GL/gl.h"
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
import os.path
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
if os.path.exists(xcode_path):
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
env['BUILD_FLAGS'] += [ "-F" + xcode_path ]
|
|
|
|
print("Using OpenGL framework headers from Xcode.app")
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
elif os.path.exists(mesa_path):
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
env['BUILD_FLAGS'] += [ '-D__MESA__' ]
|
|
|
|
print("Using OpenGL header from", mesa_path)
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
else:
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
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")
|
2021-07-21 19:01:23 -05:00
|
|
|
|
2022-08-19 11:00:52 -05:00
|
|
|
# Break out of the PIO build immediately
|
|
|
|
sys.exit(1)
|