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 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 os,shutil,marlin
  11. from SCons.Script import DefaultEnvironment
  12. from platformio import util
  13. env = DefaultEnvironment()
  14. #
  15. # Get the platform name from the 'platform_packages' option,
  16. # or look it up by the platform.class.name.
  17. #
  18. platform = env.PioPlatform()
  19. from platformio.package.meta import PackageSpec
  20. platform_packages = env.GetProjectOption('platform_packages')
  21. # Remove all tool items from platform_packages
  22. platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")]
  23. if len(platform_packages) == 0:
  24. framewords = {
  25. "Ststm32Platform": "framework-arduinoststm32",
  26. "AtmelavrPlatform": "framework-arduino-avr"
  27. }
  28. platform_name = framewords[platform.__class__.__name__]
  29. else:
  30. platform_name = PackageSpec(platform_packages[0]).name
  31. 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" ]:
  32. platform_name = "framework-arduinoststm32"
  33. FRAMEWORK_DIR = platform.get_package_dir(platform_name)
  34. assert os.path.isdir(FRAMEWORK_DIR)
  35. board = env.BoardConfig()
  36. #mcu_type = board.get("build.mcu")[:-2]
  37. variant = board.get("build.variant")
  38. #series = mcu_type[:7].upper() + "xx"
  39. # Prepare a new empty folder at the destination
  40. variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
  41. if os.path.isdir(variant_dir):
  42. shutil.rmtree(variant_dir)
  43. if not os.path.isdir(variant_dir):
  44. os.mkdir(variant_dir)
  45. # Source dir is a local variant sub-folder
  46. source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
  47. assert os.path.isdir(source_dir)
  48. marlin.copytree(source_dir, variant_dir)