mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Switch to default values from project configuration options
This commit is contained in:
@ -34,6 +34,7 @@ from platformio.builder.tools import platformio as piotool
|
|||||||
from platformio.compat import WINDOWS, hashlib_encode_data, string_types
|
from platformio.compat import WINDOWS, hashlib_encode_data, string_types
|
||||||
from platformio.managers.lib import LibraryManager
|
from platformio.managers.lib import LibraryManager
|
||||||
from platformio.package.manifest.parser import ManifestParserFactory
|
from platformio.package.manifest.parser import ManifestParserFactory
|
||||||
|
from platformio.project.options import ProjectOptions
|
||||||
|
|
||||||
|
|
||||||
class LibBuilderFactory(object):
|
class LibBuilderFactory(object):
|
||||||
@ -90,12 +91,6 @@ class LibBuilderFactory(object):
|
|||||||
|
|
||||||
class LibBuilderBase(object):
|
class LibBuilderBase(object):
|
||||||
|
|
||||||
LDF_MODES = ["off", "chain", "deep", "chain+", "deep+"]
|
|
||||||
LDF_MODE_DEFAULT = "chain"
|
|
||||||
|
|
||||||
COMPAT_MODES = ["off", "soft", "strict"]
|
|
||||||
COMPAT_MODE_DEFAULT = "soft"
|
|
||||||
|
|
||||||
CLASSIC_SCANNER = SCons.Scanner.C.CScanner()
|
CLASSIC_SCANNER = SCons.Scanner.C.CScanner()
|
||||||
CCONDITIONAL_SCANNER = SCons.Scanner.C.CConditionalScanner()
|
CCONDITIONAL_SCANNER = SCons.Scanner.C.CConditionalScanner()
|
||||||
# Max depth of nested includes:
|
# Max depth of nested includes:
|
||||||
@ -215,35 +210,37 @@ class LibBuilderBase(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def lib_ldf_mode(self):
|
def lib_ldf_mode(self):
|
||||||
return self.env.GetProjectOption("lib_ldf_mode", self.LDF_MODE_DEFAULT)
|
return self.env.GetProjectOption("lib_ldf_mode")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validate_ldf_mode(mode):
|
def validate_ldf_mode(mode):
|
||||||
|
ldf_modes = ProjectOptions["env.lib_ldf_mode"].type.choices
|
||||||
if isinstance(mode, string_types):
|
if isinstance(mode, string_types):
|
||||||
mode = mode.strip().lower()
|
mode = mode.strip().lower()
|
||||||
if mode in LibBuilderBase.LDF_MODES:
|
if mode in ldf_modes:
|
||||||
return mode
|
return mode
|
||||||
try:
|
try:
|
||||||
return LibBuilderBase.LDF_MODES[int(mode)]
|
return ldf_modes[int(mode)]
|
||||||
except (IndexError, ValueError):
|
except (IndexError, ValueError):
|
||||||
pass
|
pass
|
||||||
return LibBuilderBase.LDF_MODE_DEFAULT
|
return ProjectOptions["env.lib_ldf_mode"].default
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lib_compat_mode(self):
|
def lib_compat_mode(self):
|
||||||
return self.env.GetProjectOption("lib_compat_mode", self.COMPAT_MODE_DEFAULT)
|
return self.env.GetProjectOption("lib_compat_mode")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validate_compat_mode(mode):
|
def validate_compat_mode(mode):
|
||||||
|
compat_modes = ProjectOptions["env.lib_compat_mode"].type.choices
|
||||||
if isinstance(mode, string_types):
|
if isinstance(mode, string_types):
|
||||||
mode = mode.strip().lower()
|
mode = mode.strip().lower()
|
||||||
if mode in LibBuilderBase.COMPAT_MODES:
|
if mode in compat_modes:
|
||||||
return mode
|
return mode
|
||||||
try:
|
try:
|
||||||
return LibBuilderBase.COMPAT_MODES[int(mode)]
|
return compat_modes[int(mode)]
|
||||||
except (IndexError, ValueError):
|
except (IndexError, ValueError):
|
||||||
pass
|
pass
|
||||||
return LibBuilderBase.COMPAT_MODE_DEFAULT
|
return ProjectOptions["env.lib_compat_mode"].default
|
||||||
|
|
||||||
def is_platforms_compatible(self, platforms):
|
def is_platforms_compatible(self, platforms):
|
||||||
return True
|
return True
|
||||||
|
@ -117,10 +117,10 @@ def cli(
|
|||||||
flags=flags or env_options.get("check_flags"),
|
flags=flags or env_options.get("check_flags"),
|
||||||
severity=[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]]
|
severity=[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]]
|
||||||
if silent
|
if silent
|
||||||
else (severity or env_options.get("check_severity")),
|
else severity or config.get("env:" + envname, "check_severity"),
|
||||||
)
|
)
|
||||||
|
|
||||||
for tool in env_options.get("check_tool", ["cppcheck"]):
|
for tool in config.get("env:" + envname, "check_tool"):
|
||||||
if skipenv:
|
if skipenv:
|
||||||
results.append({"env": envname, "tool": tool})
|
results.append({"env": envname, "tool": tool})
|
||||||
continue
|
continue
|
||||||
|
@ -139,15 +139,11 @@ def validate_debug_options(cmd_ctx, env_options):
|
|||||||
load_cmds=_cleanup_cmds(
|
load_cmds=_cleanup_cmds(
|
||||||
env_options.get(
|
env_options.get(
|
||||||
"debug_load_cmds",
|
"debug_load_cmds",
|
||||||
tool_settings.get("load_cmds", tool_settings.get("load_cmd", "load")),
|
tool_settings.get("load_cmds", tool_settings.get("load_cmd")),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
load_mode=env_options.get(
|
load_mode=env_options.get("debug_load_mode", tool_settings.get("load_mode")),
|
||||||
"debug_load_mode", tool_settings.get("load_mode", "always")
|
init_break=env_options.get("debug_init_break", tool_settings.get("init_break")),
|
||||||
),
|
|
||||||
init_break=env_options.get(
|
|
||||||
"debug_init_break", tool_settings.get("init_break", "tbreak main")
|
|
||||||
),
|
|
||||||
init_cmds=_cleanup_cmds(
|
init_cmds=_cleanup_cmds(
|
||||||
env_options.get("debug_init_cmds", tool_settings.get("init_cmds"))
|
env_options.get("debug_init_cmds", tool_settings.get("init_cmds"))
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user