2021-02-14 03:51:26 +00:00
|
|
|
#
|
2021-04-27 09:49:21 +00:00
|
|
|
# generic_create_variant.py
|
2021-02-14 03:51:26 +00:00
|
|
|
#
|
2021-04-27 09:49:21 +00:00
|
|
|
# Copy one of the variants from buildroot/platformio/variants into
|
|
|
|
# the appropriate framework variants folder, so that its contents
|
|
|
|
# will be picked up by PlatformIO just like any other variant.
|
|
|
|
#
|
|
|
|
import os,shutil,marlin
|
2019-07-07 02:52:17 +00:00
|
|
|
from SCons.Script import DefaultEnvironment
|
|
|
|
from platformio import util
|
|
|
|
|
|
|
|
env = DefaultEnvironment()
|
2021-04-27 09:49:21 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Get the platform name from the 'platform_packages' option,
|
|
|
|
# or look it up by the platform.class.name.
|
|
|
|
#
|
2019-07-07 02:52:17 +00:00
|
|
|
platform = env.PioPlatform()
|
|
|
|
|
2021-04-27 09:49:21 +00:00
|
|
|
from platformio.package.meta import PackageSpec
|
|
|
|
platform_packages = env.GetProjectOption('platform_packages')
|
|
|
|
if len(platform_packages) == 0:
|
|
|
|
framewords = {
|
|
|
|
"Ststm32Platform": "framework-arduinoststm32",
|
|
|
|
"AtmelavrPlatform": "framework-arduino-avr"
|
|
|
|
}
|
|
|
|
platform_name = framewords[platform.__class__.__name__]
|
|
|
|
else:
|
|
|
|
platform_name = PackageSpec(platform_packages[0]).name
|
|
|
|
|
2021-06-03 21:52:25 +00:00
|
|
|
if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "tool-stm32duino" ]:
|
2021-04-27 09:49:21 +00:00
|
|
|
platform_name = "framework-arduinoststm32"
|
|
|
|
|
|
|
|
FRAMEWORK_DIR = platform.get_package_dir(platform_name)
|
2019-07-07 02:52:17 +00:00
|
|
|
assert os.path.isdir(FRAMEWORK_DIR)
|
|
|
|
|
2021-04-27 09:49:21 +00:00
|
|
|
board = env.BoardConfig()
|
|
|
|
|
|
|
|
#mcu_type = board.get("build.mcu")[:-2]
|
2019-07-07 02:52:17 +00:00
|
|
|
variant = board.get("build.variant")
|
2021-04-27 09:49:21 +00:00
|
|
|
#series = mcu_type[:7].upper() + "xx"
|
|
|
|
|
|
|
|
# Prepare a new empty folder at the destination
|
2019-07-07 02:52:17 +00:00
|
|
|
variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
|
2021-04-27 09:49:21 +00:00
|
|
|
if os.path.isdir(variant_dir):
|
|
|
|
shutil.rmtree(variant_dir)
|
|
|
|
if not os.path.isdir(variant_dir):
|
|
|
|
os.mkdir(variant_dir)
|
2019-07-07 02:52:17 +00:00
|
|
|
|
2021-04-27 09:49:21 +00:00
|
|
|
# Source dir is a local variant sub-folder
|
2019-07-07 02:52:17 +00:00
|
|
|
source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
|
|
|
|
assert os.path.isdir(source_dir)
|
|
|
|
|
2021-04-27 09:49:21 +00:00
|
|
|
marlin.copytree(source_dir, variant_dir)
|