mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Add option to configure library Compatible Mode using library.json
This commit is contained in:
@ -14,6 +14,8 @@ PlatformIO 3.0
|
|||||||
* Improved handling of library dependencies defined as VCS or SemVer in
|
* Improved handling of library dependencies defined as VCS or SemVer in
|
||||||
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform>`__
|
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform>`__
|
||||||
(`issue #1155 <https://github.com/platformio/platformio-core/issues/1155>`_)
|
(`issue #1155 <https://github.com/platformio/platformio-core/issues/1155>`_)
|
||||||
|
* Added option to configure library `Compatible Mode <http://docs.platformio.org/en/latest/librarymanager/ldf.html#compatibility-mode>`__
|
||||||
|
using `library.json <http://docs.platformio.org/page/librarymanager/config.html>`__
|
||||||
* Fixed "Super-Quick (Mac / Linux)" installer script
|
* Fixed "Super-Quick (Mac / Linux)" installer script
|
||||||
(`issue #1017 <https://github.com/platformio/platformio-core/issues/1017>`_)
|
(`issue #1017 <https://github.com/platformio/platformio-core/issues/1017>`_)
|
||||||
* Fixed issue with "IOError" in VSCode when processing a project
|
* Fixed issue with "IOError" in VSCode when processing a project
|
||||||
|
2
docs
2
docs
Submodule docs updated: 19f487e4c4...d14eee3254
@ -83,6 +83,9 @@ class LibBuilderBase(object):
|
|||||||
LDF_MODES = ["off", "chain", "deep", "chain+", "deep+"]
|
LDF_MODES = ["off", "chain", "deep", "chain+", "deep+"]
|
||||||
LDF_MODE_DEFAULT = "chain"
|
LDF_MODE_DEFAULT = "chain"
|
||||||
|
|
||||||
|
COMPAT_MODES = [0, 1, 2]
|
||||||
|
COMPAT_MODE_DEFAULT = 1
|
||||||
|
|
||||||
CLASSIC_SCANNER = SCons.Scanner.C.CScanner()
|
CLASSIC_SCANNER = SCons.Scanner.C.CScanner()
|
||||||
ADVANCED_SCANNER = SCons.Scanner.C.CScanner(advanced=True)
|
ADVANCED_SCANNER = SCons.Scanner.C.CScanner(advanced=True)
|
||||||
INC_DIRS_CACHE = None
|
INC_DIRS_CACHE = None
|
||||||
@ -94,8 +97,6 @@ class LibBuilderBase(object):
|
|||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
|
||||||
self._manifest = manifest if manifest else self.load_manifest()
|
self._manifest = manifest if manifest else self.load_manifest()
|
||||||
self._ldf_mode = self.validate_ldf_mode(
|
|
||||||
self.env.get("LIB_LDF_MODE", self.LDF_MODE_DEFAULT))
|
|
||||||
self._is_dependent = False
|
self._is_dependent = False
|
||||||
self._is_built = False
|
self._is_built = False
|
||||||
self._depbuilders = list()
|
self._depbuilders = list()
|
||||||
@ -172,21 +173,15 @@ class LibBuilderBase(object):
|
|||||||
def lib_archive(self):
|
def lib_archive(self):
|
||||||
return self.env.get("LIB_ARCHIVE", "") != "false"
|
return self.env.get("LIB_ARCHIVE", "") != "false"
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def validate_ldf_mode(mode):
|
|
||||||
if isinstance(mode, basestring):
|
|
||||||
mode = mode.strip().lower()
|
|
||||||
if mode in LibBuilderBase.LDF_MODES:
|
|
||||||
return mode
|
|
||||||
try:
|
|
||||||
return LibBuilderBase.LDF_MODES[int(mode)]
|
|
||||||
except (IndexError, ValueError):
|
|
||||||
pass
|
|
||||||
return LibBuilderBase.LDF_MODE_DEFAULT
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lib_ldf_mode(self):
|
def lib_ldf_mode(self):
|
||||||
return self._ldf_mode
|
return self.validate_ldf_mode(
|
||||||
|
self.env.get("LIB_LDF_MODE", self.LDF_MODE_DEFAULT))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lib_compat_mode(self):
|
||||||
|
return self.validate_compat_mode(
|
||||||
|
self.env.get("LIB_COMPAT_MODE", self.COMPAT_MODE_DEFAULT))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def depbuilders(self):
|
def depbuilders(self):
|
||||||
@ -200,6 +195,27 @@ class LibBuilderBase(object):
|
|||||||
def is_built(self):
|
def is_built(self):
|
||||||
return self._is_built
|
return self._is_built
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def validate_ldf_mode(mode):
|
||||||
|
if isinstance(mode, basestring):
|
||||||
|
mode = mode.strip().lower()
|
||||||
|
if mode in LibBuilderBase.LDF_MODES:
|
||||||
|
return mode
|
||||||
|
try:
|
||||||
|
return LibBuilderBase.LDF_MODES[int(mode)]
|
||||||
|
except (IndexError, ValueError):
|
||||||
|
pass
|
||||||
|
return LibBuilderBase.LDF_MODE_DEFAULT
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def validate_compat_mode(mode):
|
||||||
|
try:
|
||||||
|
mode = int(mode)
|
||||||
|
assert mode in LibBuilderBase.COMPAT_MODES
|
||||||
|
return mode
|
||||||
|
except (AssertionError, ValueError):
|
||||||
|
return LibBuilderBase.COMPAT_MODE_DEFAULT
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def items_in_list(items, ilist):
|
def items_in_list(items, ilist):
|
||||||
|
|
||||||
@ -263,7 +279,7 @@ class LibBuilderBase(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
for lb in self.envorigin.GetLibBuilders():
|
for lb in self.env.GetLibBuilders():
|
||||||
if item['name'] != lb.name:
|
if item['name'] != lb.name:
|
||||||
continue
|
continue
|
||||||
elif "frameworks" in item and \
|
elif "frameworks" in item and \
|
||||||
@ -299,7 +315,7 @@ class LibBuilderBase(object):
|
|||||||
# all include directories
|
# all include directories
|
||||||
if not LibBuilderBase.INC_DIRS_CACHE:
|
if not LibBuilderBase.INC_DIRS_CACHE:
|
||||||
LibBuilderBase.INC_DIRS_CACHE = []
|
LibBuilderBase.INC_DIRS_CACHE = []
|
||||||
for lb in self.envorigin.GetLibBuilders():
|
for lb in self.env.GetLibBuilders():
|
||||||
LibBuilderBase.INC_DIRS_CACHE.extend(
|
LibBuilderBase.INC_DIRS_CACHE.extend(
|
||||||
[self.env.Dir(d) for d in lb.get_inc_dirs()])
|
[self.env.Dir(d) for d in lb.get_inc_dirs()])
|
||||||
|
|
||||||
@ -363,7 +379,7 @@ class LibBuilderBase(object):
|
|||||||
|
|
||||||
lib_inc_map = {}
|
lib_inc_map = {}
|
||||||
for inc in self._get_found_includes(search_paths):
|
for inc in self._get_found_includes(search_paths):
|
||||||
for lb in self.envorigin.GetLibBuilders():
|
for lb in self.env.GetLibBuilders():
|
||||||
if inc.get_abspath() in lb:
|
if inc.get_abspath() in lb:
|
||||||
if lb not in lib_inc_map:
|
if lb not in lib_inc_map:
|
||||||
lib_inc_map[lb] = []
|
lib_inc_map[lb] = []
|
||||||
@ -391,7 +407,7 @@ class LibBuilderBase(object):
|
|||||||
self.env.AppendUnique(CPPPATH=self.get_inc_dirs())
|
self.env.AppendUnique(CPPPATH=self.get_inc_dirs())
|
||||||
|
|
||||||
if self.lib_ldf_mode == "off":
|
if self.lib_ldf_mode == "off":
|
||||||
for lb in self.envorigin.GetLibBuilders():
|
for lb in self.env.GetLibBuilders():
|
||||||
if self == lb or not lb.is_built:
|
if self == lb or not lb.is_built:
|
||||||
continue
|
continue
|
||||||
for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"):
|
for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"):
|
||||||
@ -535,6 +551,13 @@ class PlatformIOLibBuilder(LibBuilderBase):
|
|||||||
self._manifest.get("build").get("libLDFMode"))
|
self._manifest.get("build").get("libLDFMode"))
|
||||||
return LibBuilderBase.lib_ldf_mode.fget(self)
|
return LibBuilderBase.lib_ldf_mode.fget(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lib_compat_mode(self):
|
||||||
|
if "libCompatMode" in self._manifest.get("build", {}):
|
||||||
|
return self.validate_compat_mode(
|
||||||
|
self._manifest.get("build").get("libCompatMode"))
|
||||||
|
return LibBuilderBase.lib_compat_mode.fget(self)
|
||||||
|
|
||||||
def is_platforms_compatible(self, platforms):
|
def is_platforms_compatible(self, platforms):
|
||||||
items = self._manifest.get("platforms")
|
items = self._manifest.get("platforms")
|
||||||
if not items:
|
if not items:
|
||||||
@ -602,7 +625,7 @@ class ProjectAsLibBuilder(LibBuilderBase):
|
|||||||
pkg_dir = lm.get_package_dir(*lm.parse_pkg_uri(uri))
|
pkg_dir = lm.get_package_dir(*lm.parse_pkg_uri(uri))
|
||||||
if not pkg_dir:
|
if not pkg_dir:
|
||||||
continue
|
continue
|
||||||
for lb in self.envorigin.GetLibBuilders():
|
for lb in self.env.GetLibBuilders():
|
||||||
if lb.path != pkg_dir:
|
if lb.path != pkg_dir:
|
||||||
continue
|
continue
|
||||||
if lb not in self.depbuilders:
|
if lb not in self.depbuilders:
|
||||||
@ -611,7 +634,7 @@ class ProjectAsLibBuilder(LibBuilderBase):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
for lb in self.envorigin.GetLibBuilders():
|
for lb in self.env.GetLibBuilders():
|
||||||
if lb.name != uri:
|
if lb.name != uri:
|
||||||
continue
|
continue
|
||||||
if lb not in self.depbuilders:
|
if lb not in self.depbuilders:
|
||||||
@ -632,11 +655,11 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches
|
|||||||
key=lambda lb: 0 if lb.dependent else 1)
|
key=lambda lb: 0 if lb.dependent else 1)
|
||||||
|
|
||||||
items = []
|
items = []
|
||||||
compat_mode = int(env.get("LIB_COMPAT_MODE", 1))
|
|
||||||
verbose = int(ARGUMENTS.get("PIOVERBOSE",
|
verbose = int(ARGUMENTS.get("PIOVERBOSE",
|
||||||
0)) and not env.GetOption('clean')
|
0)) and not env.GetOption('clean')
|
||||||
|
|
||||||
def _check_lib_builder(lb):
|
def _check_lib_builder(lb):
|
||||||
|
compat_mode = lb.lib_compat_mode
|
||||||
if lb.name in env.get("LIB_IGNORE", []):
|
if lb.name in env.get("LIB_IGNORE", []):
|
||||||
if verbose:
|
if verbose:
|
||||||
sys.stderr.write("Ignored library %s\n" % lb.path)
|
sys.stderr.write("Ignored library %s\n" % lb.path)
|
||||||
|
Reference in New Issue
Block a user