forked from platformio/platformio-core
Introduce "lib_compat_level" option for project configuration file
This commit is contained in:
1 parent
2892cb8c2f
commit
01c0b45ea2
6 files changed
+114
-31
No files matched your search
@@ -14,7 +14,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
VERSION = (3, 0, "0.dev9")
|
||||
VERSION = (3, 0, "0.dev10")
|
||||
__version__ = ".".join([str(s) for s in VERSION])
|
||||
|
||||
__title__ = "platformio"
|
||||
|
||||
@@ -45,6 +45,7 @@ commonvars.AddVariables(
|
||||
|
||||
# library options
|
||||
("LIB_DEEP_SEARCH",),
|
||||
("LIB_COMPAT_LEVEL",),
|
||||
("LIB_IGNORE",),
|
||||
("LIB_FORCE",),
|
||||
("LIB_EXTRA_DIRS",),
|
||||
@@ -121,6 +122,7 @@ for opt in ("LIB_IGNORE", "LIB_FORCE", "LIB_EXTRA_DIRS"):
|
||||
continue
|
||||
env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()]
|
||||
|
||||
env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", []))
|
||||
env.LoadDevPlatform(commonvars)
|
||||
|
||||
env.SConscriptChdir(0)
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
from os.path import basename, commonprefix, isdir, isfile, join, realpath
|
||||
from sys import modules
|
||||
|
||||
import SCons.Scanner
|
||||
|
||||
@@ -44,7 +44,7 @@ class LibBuilderFactory(object):
|
||||
elif used_frameworks:
|
||||
clsname = "%sLibBuilder" % used_frameworks[0].title()
|
||||
|
||||
obj = getattr(modules[__name__], clsname)(env, path)
|
||||
obj = getattr(sys.modules[__name__], clsname)(env, path)
|
||||
assert isinstance(obj, LibBuilderBase)
|
||||
return obj
|
||||
|
||||
@@ -327,27 +327,34 @@ def find_and_build_deps(env, lib_builders, scanner,
|
||||
|
||||
def GetLibBuilders(env):
|
||||
items = []
|
||||
libs_dirs = []
|
||||
env_frameworks = [
|
||||
f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",")]
|
||||
f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",")
|
||||
]
|
||||
compat_level = int(env.get("LIB_COMPAT_LEVEL", 1))
|
||||
|
||||
for key in ("LIB_EXTRA_DIRS", "LIBSOURCE_DIRS"):
|
||||
for d in env.get(key, []):
|
||||
d = env.subst(d)
|
||||
if isdir(d):
|
||||
libs_dirs.append(d)
|
||||
|
||||
for libs_dir in libs_dirs:
|
||||
for libs_dir in env['LIBSOURCE_DIRS']:
|
||||
libs_dir = env.subst(libs_dir)
|
||||
if not isdir(libs_dir):
|
||||
continue
|
||||
for item in sorted(os.listdir(libs_dir)):
|
||||
if item == "__cores__" or not isdir(join(libs_dir, item)):
|
||||
continue
|
||||
lb = LibBuilderFactory.new(env, join(libs_dir, item))
|
||||
if lb.name in env.get("LIB_IGNORE", []):
|
||||
if not env.GetOption("silent"):
|
||||
print "Ignored library " + lb.path
|
||||
continue
|
||||
if not lb.is_platform_compatible(env['PIOPLATFORM']):
|
||||
if compat_level > 1 and not lb.is_platform_compatible(env[
|
||||
'PIOPLATFORM']):
|
||||
if not env.GetOption("silent"):
|
||||
sys.stderr.write("Platform incompatible library %s\n" %
|
||||
lb.path)
|
||||
continue
|
||||
if not any([lb.is_framework_compatible(f)
|
||||
for f in env_frameworks]):
|
||||
if compat_level > 0 and not any([lb.is_framework_compatible(f)
|
||||
for f in env_frameworks]):
|
||||
if not env.GetOption("silent"):
|
||||
sys.stderr.write("Framework incompatible library %s\n" %
|
||||
lb.path)
|
||||
continue
|
||||
items.append(lb)
|
||||
return items
|
||||
@@ -358,8 +365,8 @@ def BuildDependentLibraries(env, src_dir):
|
||||
scanner = SCons.Scanner.C.CScanner()
|
||||
lib_builders = env.GetLibBuilders()
|
||||
|
||||
print "Looking for dependencies..."
|
||||
print "Collecting %d compatible libraries" % len(lib_builders)
|
||||
print "Looking for dependencies..."
|
||||
|
||||
built_lib_names = []
|
||||
for lib_name in env.get("LIB_FORCE", []):
|
||||
|
||||
Reference in new issue
Block a user