simulator.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #
  2. # simulator.py
  3. # PlatformIO pre: script for simulator builds
  4. #
  5. import pioutil
  6. if pioutil.is_pio_build():
  7. # Get the environment thus far for the build
  8. Import("env")
  9. #print(env.Dump())
  10. #
  11. # Give the binary a distinctive name
  12. #
  13. env['PROGNAME'] = "MarlinSimulator"
  14. #
  15. # If Xcode is installed add the path to its Frameworks folder,
  16. # or if Mesa is installed try to use its GL/gl.h.
  17. #
  18. import sys
  19. if sys.platform == 'darwin':
  20. #
  21. # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS')
  22. #
  23. env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ]
  24. # Default paths for Xcode and a lucky GL/gl.h dropped by Mesa
  25. xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
  26. mesa_path = "/opt/local/include/GL/gl.h"
  27. import os.path
  28. if os.path.exists(xcode_path):
  29. env['BUILD_FLAGS'] += [ "-F" + xcode_path ]
  30. print("Using OpenGL framework headers from Xcode.app")
  31. elif os.path.exists(mesa_path):
  32. env['BUILD_FLAGS'] += [ '-D__MESA__' ]
  33. print("Using OpenGL header from", mesa_path)
  34. else:
  35. 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")
  36. # Break out of the PIO build immediately
  37. sys.exit(1)