Skip to content

Commit

Permalink
move up for easier compare
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 14, 2021
1 parent b6eea0f commit c1291b4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 122 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/gcode/host/M115.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void GcodeSuite::M115() {
cap_line(F("MEATPACK"), SERIAL_IMPL.has_feature(port, SerialFeature::MeatPack));

// CONFIG_EXPORT
cap_line(PSTR("CONFIG_EXPORT"), ENABLED(CONFIG_EMBED_AND_SAVE_TO_SD));
cap_line(F("CONFIG_EXPORT"), ENABLED(CONFIG_EMBED_AND_SAVE_TO_SD));

// Machine Geometry
#if ENABLED(M115_GEOMETRY_REPORT)
Expand Down
159 changes: 38 additions & 121 deletions buildroot/share/PlatformIO/scripts/common-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,38 @@
from platformio.package.meta import PackageSpec
from platformio.project.config import ProjectConfig

PIO_VERSION_MIN = (5, 0, 3)
try:
from platformio import VERSION as PIO_VERSION
weights = (1000, 100, 1)
version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)])
version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)])
if version_cur < version_min:
print()
print("**************************************************")
print("****** An update to PlatformIO is ******")
print("****** required to build Marlin Firmware. ******")
print("****** ******")
print("****** Minimum version: ", PIO_VERSION_MIN, " ******")
print("****** Current Version: ", PIO_VERSION, " ******")
print("****** ******")
print("****** Update PlatformIO and try again. ******")
print("**************************************************")
print()
exit(1)
except SystemExit:
exit(1)
except:
print("Can't detect PlatformIO Version")

#print(env.Dump())
verbose = 0
FEATURE_CONFIG = {}

try:
verbose = int(env.GetProjectOption('custom_verbose'))
except:
verbose = 0
def validate_pio():
PIO_VERSION_MIN = (5, 0, 3)
try:
from platformio import VERSION as PIO_VERSION
weights = (1000, 100, 1)
version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)])
version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)])
if version_cur < version_min:
print()
print("**************************************************")
print("****** An update to PlatformIO is ******")
print("****** required to build Marlin Firmware. ******")
print("****** ******")
print("****** Minimum version: ", PIO_VERSION_MIN, " ******")
print("****** Current Version: ", PIO_VERSION, " ******")
print("****** ******")
print("****** Update PlatformIO and try again. ******")
print("**************************************************")
print()
exit(1)
except SystemExit:
exit(1)
except:
print("Can't detect PlatformIO Version")

def blab(str,level=1):
if verbose >= level:
print("[deps] %s" % str)

FEATURE_CONFIG = {}

def add_to_feat_cnf(feature, flines):

try:
Expand Down Expand Up @@ -123,7 +118,6 @@ def set_env_field(field, value):

# All unused libs should be ignored so that if a library
# exists in .pio/lib_deps it will not break compilation.

def force_ignore_unused_libs():
env_libs = get_all_env_libs()
known_libs = get_all_known_libs()
Expand All @@ -139,96 +133,13 @@ def apply_features_config():
if not env.MarlinFeatureIsEnabled(feature):
continue

verbose = 0
FEATURE_CONFIG = {}

def validate_pio():
PIO_VERSION_MIN = (5, 0, 3)
try:
from platformio import VERSION as PIO_VERSION
weights = (1000, 100, 1)
version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)])
version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)])
if version_cur < version_min:
print()
print("**************************************************")
print("****** An update to PlatformIO is ******")
print("****** required to build Marlin Firmware. ******")
print("****** ******")
print("****** Minimum version: ", PIO_VERSION_MIN, " ******")
print("****** Current Version: ", PIO_VERSION, " ******")
print("****** ******")
print("****** Update PlatformIO and try again. ******")
print("**************************************************")
print()
exit(1)
except SystemExit:
exit(1)
except:
print("Can't detect PlatformIO Version")

def blab(str,level=1):
if verbose >= level:
print("[deps] %s" % str)

def add_to_feat_cnf(feature, flines):

try:
feat = FEATURE_CONFIG[feature]
except:
FEATURE_CONFIG[feature] = {}

# Get a reference to the FEATURE_CONFIG under construction
feat = FEATURE_CONFIG[feature]

# Split up passed lines on commas or newlines and iterate
# Add common options to the features config under construction
# For lib_deps replace a previous instance of the same library
atoms = re.sub(r',\\s*', '\n', flines).strip().split('\n')
for line in atoms:
parts = line.split('=')
name = parts.pop(0)
if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
feat[name] = '='.join(parts)
blab("[%s] %s=%s" % (feature, name, feat[name]), 3)
else:
for dep in re.split(r",\s*", line):
lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0)
lib_re = re.compile('(?!^' + lib_name + '\\b)')
feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
blab("[%s] lib_deps = %s" % (feature, dep), 3)

def load_config():
blab("========== Gather [features] entries...")
items = ProjectConfig().items('features')
for key in items:
feature = key[0].upper()
if not feature in FEATURE_CONFIG:
FEATURE_CONFIG[feature] = { 'lib_deps': [] }
add_to_feat_cnf(feature, key[1])

# Add options matching custom_marlin.MY_OPTION to the pile
blab("========== Gather custom_marlin entries...")
all_opts = env.GetProjectOptions()
for n in all_opts:
key = n[0]
mat = re.match(r'custom_marlin\.(.+)', key)
if mat:
try:
val = env.GetProjectOption(key)
except:
val = None
if val:
opt = mat.group(1).upper()
blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val ))
add_to_feat_cnf(opt, val)

def get_all_known_libs():
known_libs = []
for feature in FEATURE_CONFIG:
feat = FEATURE_CONFIG[feature]
if not 'lib_deps' in feat:
continue
if 'lib_deps' in feat and len(feat['lib_deps']):
blab("========== Adding lib_deps for %s... " % feature, 2)

# feat to add
deps_to_add = {}
for dep in feat['lib_deps']:
deps_to_add[PackageSpec(dep).name] = dep
blab("==================== %s... " % dep, 2)
Expand Down Expand Up @@ -291,7 +202,6 @@ def load_marlin_features():
# Process defines
from preprocessor import run_preprocessor
define_list = run_preprocessor(env)

marlin_features = {}
for define in define_list:
feature = define[8:].strip().decode().split(' ')
Expand Down Expand Up @@ -319,6 +229,13 @@ def MarlinFeatureIsEnabled(env, feature):

return some_on

validate_pio()

try:
verbose = int(env.GetProjectOption('custom_verbose'))
except:
pass

#
# Add a method for other PIO scripts to query enabled features
#
Expand Down

0 comments on commit c1291b4

Please sign in to comment.