My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generic_create_variant.py 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #
  2. # generic_create_variant.py
  3. #
  4. # Copy one of the variants from buildroot/platformio/variants into
  5. # the appropriate framework variants folder, so that its contents
  6. # will be picked up by PlatformIO just like any other variant.
  7. #
  8. import pioutil
  9. if pioutil.is_pio_build():
  10. import shutil,marlin
  11. from pathlib import Path
  12. #
  13. # Get the platform name from the 'platform_packages' option,
  14. # or look it up by the platform.class.name.
  15. #
  16. env = marlin.env
  17. platform = env.PioPlatform()
  18. from platformio.package.meta import PackageSpec
  19. platform_packages = env.GetProjectOption('platform_packages')
  20. # Remove all tool items from platform_packages
  21. platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")]
  22. if len(platform_packages) == 0:
  23. framewords = {
  24. "Ststm32Platform": "framework-arduinoststm32",
  25. "AtmelavrPlatform": "framework-arduino-avr"
  26. }
  27. platform_name = framewords[platform.__class__.__name__]
  28. else:
  29. platform_name = PackageSpec(platform_packages[0]).name
  30. if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]:
  31. platform_name = "framework-arduinoststm32"
  32. FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name))
  33. assert FRAMEWORK_DIR.is_dir()
  34. board = env.BoardConfig()
  35. #mcu_type = board.get("build.mcu")[:-2]
  36. variant = board.get("build.variant")
  37. #series = mcu_type[:7].upper() + "xx"
  38. # Prepare a new empty folder at the destination
  39. variant_dir = FRAMEWORK_DIR / "variants" / variant
  40. if variant_dir.is_dir():
  41. shutil.rmtree(variant_dir)
  42. if not variant_dir.is_dir():
  43. variant_dir.mkdir()
  44. # Source dir is a local variant sub-folder
  45. source_dir = Path("buildroot/share/PlatformIO/variants", variant)
  46. assert source_dir.is_dir()
  47. marlin.copytree(source_dir, variant_dir)