My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

preflight-checks.py 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. # Require PlatformIO 6.1.1 or later
  48. vers = pioutil.get_pio_version()
  49. if vers < [6, 1, 1]:
  50. raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.")
  51. if 'MARLIN_FEATURES' not in env:
  52. raise SystemExit("Error: this script should be used after common Marlin scripts")
  53. if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
  54. raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
  55. build_env = env['PIOENV']
  56. motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
  57. board_envs = get_envs_for_board(motherboard)
  58. config = env.GetProjectConfig()
  59. result = check_envs("env:"+build_env, board_envs, config)
  60. if not result:
  61. err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \
  62. ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
  63. raise SystemExit(err)
  64. #
  65. # Check for Config files in two common incorrect places
  66. #
  67. for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
  68. for f in [ "Configuration.h", "Configuration_adv.h" ]:
  69. if os.path.isfile(os.path.join(p, f)):
  70. err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
  71. raise SystemExit(err)
  72. #
  73. # Give warnings on every build
  74. #
  75. build_dir = os.path.join(env['PROJECT_BUILD_DIR'], build_env);
  76. for outdir in [ build_dir, os.path.join(build_dir, "debug") ]:
  77. for wext in [ ".cpp", "" ]:
  78. warnfile = os.path.join(outdir, "src", "src", "inc", "Warnings" + wext + ".o")
  79. if os.path.exists(warnfile):
  80. os.remove(warnfile)
  81. #
  82. # Rebuild 'settings.cpp' for EEPROM_INIT_NOW
  83. #
  84. if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']:
  85. setfile = os.path.join(srcpath, "module", "settings.cpp.o")
  86. if os.path.exists(setfile):
  87. os.remove(setfile)
  88. #
  89. # Check for old files indicating an entangled Marlin (mixing old and new code)
  90. #
  91. mixedin = []
  92. p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "lcd", "dogm")
  93. for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
  94. if os.path.isfile(os.path.join(p, f)):
  95. mixedin += [ f ]
  96. p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "feature", "bedlevel", "abl")
  97. for f in [ "abl.cpp", "abl.h" ]:
  98. if os.path.isfile(os.path.join(p, f)):
  99. mixedin += [ f ]
  100. if mixedin:
  101. err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
  102. raise SystemExit(err)
  103. sanity_check_target()