Extra dependency script logging

This commit is contained in:
Scott Lahteine 2021-04-20 05:11:43 -05:00 committed by Scott Lahteine
parent 81ab756759
commit 2316fb2d05

View File

@ -40,9 +40,9 @@ try:
except: except:
verbose = 0 verbose = 0
def blab(str): def blab(str,level=1):
if verbose: if verbose >= level:
print(str) print("[deps] %s" % str)
FEATURE_CONFIG = {} FEATURE_CONFIG = {}
@ -65,13 +65,16 @@ def add_to_feat_cnf(feature, flines):
name = parts.pop(0) name = parts.pop(0)
if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
feat[name] = '='.join(parts) feat[name] = '='.join(parts)
blab("[%s] %s=%s" % (feature, name, feat[name]), 3)
else: else:
for dep in line.split(','): for dep in re.split(r",\s*", line):
lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0)
lib_re = re.compile('(?!^' + lib_name + '\\b)') lib_re = re.compile('(?!^' + lib_name + '\\b)')
feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
blab("[%s] lib_deps = %s" % (feature, dep), 3)
def load_config(): def load_config():
blab("========== Gather [features] entries...")
items = ProjectConfig().items('features') items = ProjectConfig().items('features')
for key in items: for key in items:
feature = key[0].upper() feature = key[0].upper()
@ -80,16 +83,20 @@ def load_config():
add_to_feat_cnf(feature, key[1]) add_to_feat_cnf(feature, key[1])
# Add options matching custom_marlin.MY_OPTION to the pile # Add options matching custom_marlin.MY_OPTION to the pile
blab("========== Gather custom_marlin entries...")
all_opts = env.GetProjectOptions() all_opts = env.GetProjectOptions()
for n in all_opts: for n in all_opts:
mat = re.match(r'custom_marlin\.(.+)', n[0]) key = n[0]
mat = re.match(r'custom_marlin\.(.+)', key)
if mat: if mat:
try: try:
val = env.GetProjectOption(n[0]) val = env.GetProjectOption(key)
except: except:
val = None val = None
if val: if val:
add_to_feat_cnf(mat.group(1).upper(), 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(): def get_all_known_libs():
known_libs = [] known_libs = []
@ -124,6 +131,7 @@ def force_ignore_unused_libs():
def apply_features_config(): def apply_features_config():
load_config() load_config()
blab("========== Apply enabled features...")
for feature in FEATURE_CONFIG: for feature in FEATURE_CONFIG:
if not env.MarlinFeatureIsEnabled(feature): if not env.MarlinFeatureIsEnabled(feature):
continue continue
@ -131,12 +139,13 @@ def apply_features_config():
feat = FEATURE_CONFIG[feature] feat = FEATURE_CONFIG[feature]
if 'lib_deps' in feat and len(feat['lib_deps']): if 'lib_deps' in feat and len(feat['lib_deps']):
blab("Adding lib_deps for %s... " % feature) blab("========== Adding lib_deps for %s... " % feature, 2)
# feat to add # feat to add
deps_to_add = {} deps_to_add = {}
for dep in feat['lib_deps']: for dep in feat['lib_deps']:
deps_to_add[PackageSpec(dep).name] = dep deps_to_add[PackageSpec(dep).name] = dep
blab("==================== %s... " % dep, 2)
# Does the env already have the dependency? # Does the env already have the dependency?
deps = env.GetProjectOption('lib_deps') deps = env.GetProjectOption('lib_deps')
@ -159,16 +168,16 @@ def apply_features_config():
if 'build_flags' in feat: if 'build_flags' in feat:
f = feat['build_flags'] f = feat['build_flags']
blab("Adding build_flags for %s: %s" % (feature, f)) blab("========== Adding build_flags for %s: %s" % (feature, f), 2)
new_flags = env.GetProjectOption('build_flags') + [ f ] new_flags = env.GetProjectOption('build_flags') + [ f ]
env.Replace(BUILD_FLAGS=new_flags) env.Replace(BUILD_FLAGS=new_flags)
if 'extra_scripts' in feat: if 'extra_scripts' in feat:
blab("Running extra_scripts for %s... " % feature) blab("Running extra_scripts for %s... " % feature, 2)
env.SConscript(feat['extra_scripts'], exports="env") env.SConscript(feat['extra_scripts'], exports="env")
if 'src_filter' in feat: if 'src_filter' in feat:
blab("Adding src_filter for %s... " % feature) blab("========== Adding src_filter for %s... " % feature, 2)
src_filter = ' '.join(env.GetProjectOption('src_filter')) src_filter = ' '.join(env.GetProjectOption('src_filter'))
# first we need to remove the references to the same folder # first we need to remove the references to the same folder
my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter'])
@ -182,7 +191,7 @@ def apply_features_config():
env.Replace(SRC_FILTER=src_filter) env.Replace(SRC_FILTER=src_filter)
if 'lib_ignore' in feat: if 'lib_ignore' in feat:
blab("Adding lib_ignore for %s... " % feature) blab("========== Adding lib_ignore for %s... " % feature, 2)
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
set_env_field('lib_ignore', lib_ignore) set_env_field('lib_ignore', lib_ignore)
@ -200,7 +209,6 @@ def search_compiler():
pass pass
if os.path.exists(GCC_PATH_CACHE): if os.path.exists(GCC_PATH_CACHE):
blab("Getting g++ path from cache")
with open(GCC_PATH_CACHE, 'r') as f: with open(GCC_PATH_CACHE, 'r') as f:
return f.read() return f.read()
@ -227,7 +235,6 @@ def search_compiler():
filepath = os.path.sep.join([pathdir, filepath]) filepath = os.path.sep.join([pathdir, filepath])
# Cache the g++ path to no search always # Cache the g++ path to no search always
if os.path.exists(ENV_BUILD_PATH): if os.path.exists(ENV_BUILD_PATH):
blab("Caching g++ for current env")
with open(GCC_PATH_CACHE, 'w+') as f: with open(GCC_PATH_CACHE, 'w+') as f:
f.write(filepath) f.write(filepath)
@ -262,7 +269,7 @@ def load_marlin_features():
cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h']
cmd = ' '.join(cmd) cmd = ' '.join(cmd)
blab(cmd) blab(cmd, 4)
define_list = subprocess.check_output(cmd, shell=True).splitlines() define_list = subprocess.check_output(cmd, shell=True).splitlines()
marlin_features = {} marlin_features = {}
for define in define_list: for define in define_list: