My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

preflight-checks.py 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #
  2. # preflight-checks.py
  3. # Check for common issues prior to compiling
  4. #
  5. import pioutil
  6. if pioutil.is_pio_build():
  7. import os,re,sys
  8. Import("env")
  9. def get_envs_for_board(board):
  10. with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file:
  11. if sys.platform == 'win32':
  12. envregex = r"(?:env|win):"
  13. elif sys.platform == 'darwin':
  14. envregex = r"(?:env|mac|uni):"
  15. elif sys.platform == 'linux':
  16. envregex = r"(?:env|lin|uni):"
  17. else:
  18. envregex = r"(?:env):"
  19. r = re.compile(r"if\s+MB\((.+)\)")
  20. if board.startswith("BOARD_"):
  21. board = board[6:]
  22. for line in file:
  23. mbs = r.findall(line)
  24. if mbs and board in re.split(r",\s*", mbs[0]):
  25. line = file.readline()
  26. found_envs = re.match(r"\s*#include .+" + envregex, line)
  27. if found_envs:
  28. envlist = re.findall(envregex + r"(\w+)", line)
  29. return [ "env:"+s for s in envlist ]
  30. return []
  31. def check_envs(build_env, board_envs, config):
  32. if build_env in board_envs:
  33. return True
  34. ext = config.get(build_env, 'extends', default=None)
  35. if ext:
  36. if isinstance(ext, str):
  37. return check_envs(ext, board_envs, config)
  38. elif isinstance(ext, list):
  39. for ext_env in ext:
  40. if check_envs(ext_env, board_envs, config):
  41. return True
  42. return False
  43. def sanity_check_target():
  44. # Sanity checks:
  45. if 'PIOENV' not in env:
  46. raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO")
  47. if 'MARLIN_FEATURES' not in env:
  48. raise SystemExit("Error: this script should be used after common Marlin scripts")
  49. if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
  50. raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
  51. build_env = env['PIOENV']
  52. motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
  53. board_envs = get_envs_for_board(motherboard)
  54. config = env.GetProjectConfig()
  55. result = check_envs("env:"+build_env, board_envs, config)
  56. if not result:
  57. err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \
  58. ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
  59. raise SystemExit(err)
  60. #
  61. # Check for Config files in two common incorrect places
  62. #
  63. for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
  64. for f in [ "Configuration.h", "Configuration_adv.h" ]:
  65. if os.path.isfile(os.path.join(p, f)):
  66. err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
  67. raise SystemExit(err)
  68. #
  69. # Give warnings on every build
  70. #
  71. srcpath = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src")
  72. warnfile = os.path.join(srcpath, "inc", "Warnings.cpp.o")
  73. if os.path.exists(warnfile):
  74. os.remove(warnfile)
  75. #
  76. # Rebuild 'settings.cpp' for EEPROM_INIT_NOW
  77. #
  78. if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']:
  79. setfile = os.path.join(srcpath, "module", "settings.cpp.o")
  80. if os.path.exists(setfile):
  81. os.remove(setfile)
  82. #
  83. # Check for old files indicating an entangled Marlin (mixing old and new code)
  84. #
  85. mixedin = []
  86. p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "lcd", "dogm")
  87. for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
  88. if os.path.isfile(os.path.join(p, f)):
  89. mixedin += [ f ]
  90. p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "feature", "bedlevel", "abl")
  91. for f in [ "abl.cpp", "abl.h" ]:
  92. if os.path.isfile(os.path.join(p, f)):
  93. mixedin += [ f ]
  94. if mixedin:
  95. err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
  96. raise SystemExit(err)
  97. sanity_check_target()