forked from platformio/platformio-core
Improved support for user inputs
This commit is contained in:
2
docs
2
docs
Submodule docs updated: 17a3f640ac...26527c1f6a
@ -225,7 +225,7 @@ if "envdump" in COMMAND_LINE_TARGETS:
|
|||||||
click.echo(env.Dump())
|
click.echo(env.Dump())
|
||||||
env.Exit(0)
|
env.Exit(0)
|
||||||
|
|
||||||
if set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS):
|
if env.IsIntegrationDump():
|
||||||
projenv = None
|
projenv = None
|
||||||
try:
|
try:
|
||||||
Import("projenv")
|
Import("projenv")
|
||||||
|
@ -19,10 +19,15 @@ import os
|
|||||||
|
|
||||||
import SCons.Defaults # pylint: disable=import-error
|
import SCons.Defaults # pylint: disable=import-error
|
||||||
import SCons.Subst # pylint: disable=import-error
|
import SCons.Subst # pylint: disable=import-error
|
||||||
|
from SCons.Script import COMMAND_LINE_TARGETS # pylint: disable=import-error
|
||||||
|
|
||||||
from platformio.proc import exec_command, where_is_program
|
from platformio.proc import exec_command, where_is_program
|
||||||
|
|
||||||
|
|
||||||
|
def IsIntegrationDump(_):
|
||||||
|
return set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS)
|
||||||
|
|
||||||
|
|
||||||
def DumpIntegrationIncludes(env):
|
def DumpIntegrationIncludes(env):
|
||||||
result = dict(build=[], compatlib=[], toolchain=[])
|
result = dict(build=[], compatlib=[], toolchain=[])
|
||||||
|
|
||||||
@ -60,7 +65,7 @@ def DumpIntegrationIncludes(env):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _get_gcc_defines(env):
|
def get_gcc_defines(env):
|
||||||
items = []
|
items = []
|
||||||
try:
|
try:
|
||||||
sysenv = os.environ.copy()
|
sysenv = os.environ.copy()
|
||||||
@ -83,7 +88,7 @@ def _get_gcc_defines(env):
|
|||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
def _dump_defines(env):
|
def dump_defines(env):
|
||||||
defines = []
|
defines = []
|
||||||
# global symbols
|
# global symbols
|
||||||
for item in SCons.Defaults.processDefines(env.get("CPPDEFINES", [])):
|
for item in SCons.Defaults.processDefines(env.get("CPPDEFINES", [])):
|
||||||
@ -108,12 +113,12 @@ def _dump_defines(env):
|
|||||||
|
|
||||||
# built-in GCC marcos
|
# built-in GCC marcos
|
||||||
# if env.GetCompilerType() == "gcc":
|
# if env.GetCompilerType() == "gcc":
|
||||||
# defines.extend(_get_gcc_defines(env))
|
# defines.extend(get_gcc_defines(env))
|
||||||
|
|
||||||
return defines
|
return defines
|
||||||
|
|
||||||
|
|
||||||
def _get_svd_path(env):
|
def dump_svd_path(env):
|
||||||
svd_path = env.GetProjectOption("debug_svd_path")
|
svd_path = env.GetProjectOption("debug_svd_path")
|
||||||
if svd_path:
|
if svd_path:
|
||||||
return os.path.abspath(svd_path)
|
return os.path.abspath(svd_path)
|
||||||
@ -146,13 +151,13 @@ def DumpIntegrationData(env, globalenv):
|
|||||||
data = {
|
data = {
|
||||||
"env_name": env["PIOENV"],
|
"env_name": env["PIOENV"],
|
||||||
"libsource_dirs": [env.subst(item) for item in env.GetLibSourceDirs()],
|
"libsource_dirs": [env.subst(item) for item in env.GetLibSourceDirs()],
|
||||||
"defines": _dump_defines(env),
|
"defines": dump_defines(env),
|
||||||
"includes": env.DumpIntegrationIncludes(),
|
"includes": env.DumpIntegrationIncludes(),
|
||||||
"cc_path": where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
|
"cc_path": where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
|
||||||
"cxx_path": where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
|
"cxx_path": where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
|
||||||
"gdb_path": where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
|
"gdb_path": where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
|
||||||
"prog_path": env.subst("$PROG_PATH"),
|
"prog_path": env.subst("$PROG_PATH"),
|
||||||
"svd_path": _get_svd_path(env),
|
"svd_path": dump_svd_path(env),
|
||||||
"compiler_type": env.GetCompilerType(),
|
"compiler_type": env.GetCompilerType(),
|
||||||
"targets": globalenv.DumpTargets(),
|
"targets": globalenv.DumpTargets(),
|
||||||
"extra": dict(
|
"extra": dict(
|
||||||
@ -162,7 +167,9 @@ def DumpIntegrationData(env, globalenv):
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
data["extra"].update(env.get("IDE_EXTRA_DATA", {}))
|
data["extra"].update(
|
||||||
|
env.get("INTEGRATION_EXTRA_DATA", env.get("IDE_EXTRA_DATA", {}))
|
||||||
|
)
|
||||||
|
|
||||||
env_ = env.Clone()
|
env_ = env.Clone()
|
||||||
# https://github.com/platformio/platformio-atom-ide/issues/34
|
# https://github.com/platformio/platformio-atom-ide/issues/34
|
||||||
@ -191,6 +198,7 @@ def exists(_):
|
|||||||
|
|
||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
|
env.AddMethod(IsIntegrationDump)
|
||||||
env.AddMethod(DumpIntegrationIncludes)
|
env.AddMethod(DumpIntegrationIncludes)
|
||||||
env.AddMethod(DumpIntegrationData)
|
env.AddMethod(DumpIntegrationData)
|
||||||
return env
|
return env
|
||||||
|
@ -171,12 +171,13 @@ def ProcessProjectDeps(env):
|
|||||||
"Error: Nothing to build. Please put your source code files "
|
"Error: Nothing to build. Please put your source code files "
|
||||||
"to the '%s' folder\n" % env.subst("$PROJECT_SRC_DIR")
|
"to the '%s' folder\n" % env.subst("$PROJECT_SRC_DIR")
|
||||||
)
|
)
|
||||||
elif "test" in env.GetBuildType():
|
env.Exit(1)
|
||||||
|
if "test" in env.GetBuildType():
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"Error: Nothing to build. Please put your test suites "
|
"Error: Nothing to build. Please put your test suites "
|
||||||
"to the '%s' folder\n" % env.subst("$PROJECT_TEST_DIR")
|
"to the '%s' folder\n" % env.subst("$PROJECT_TEST_DIR")
|
||||||
)
|
)
|
||||||
env.Exit(1)
|
env.Exit(1)
|
||||||
|
|
||||||
Export("projenv")
|
Export("projenv")
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ def load_build_metadata(project_dir, env_or_envs, cache=False):
|
|||||||
env_names = [env_names]
|
env_names = [env_names]
|
||||||
|
|
||||||
with fs.cd(project_dir):
|
with fs.cd(project_dir):
|
||||||
result = _load_cached_project_ide_data(project_dir, env_names) if cache else {}
|
result = _get_cached_build_metadata(project_dir, env_names) if cache else {}
|
||||||
missed_env_names = set(env_names) - set(result.keys())
|
missed_env_names = set(env_names) - set(result.keys())
|
||||||
if missed_env_names:
|
if missed_env_names:
|
||||||
result.update(_load_build_metadata(project_dir, missed_env_names))
|
result.update(_load_build_metadata(project_dir, missed_env_names))
|
||||||
@ -154,10 +154,10 @@ def _load_build_metadata(project_dir, env_names):
|
|||||||
raise result.exception
|
raise result.exception
|
||||||
if '"includes":' not in result.output:
|
if '"includes":' not in result.output:
|
||||||
raise exception.PlatformioException(result.output)
|
raise exception.PlatformioException(result.output)
|
||||||
return _load_cached_project_ide_data(project_dir, env_names)
|
return _get_cached_build_metadata(project_dir, env_names)
|
||||||
|
|
||||||
|
|
||||||
def _load_cached_project_ide_data(project_dir, env_names):
|
def _get_cached_build_metadata(project_dir, env_names):
|
||||||
build_dir = ProjectConfig.get_instance(
|
build_dir = ProjectConfig.get_instance(
|
||||||
os.path.join(project_dir, "platformio.ini")
|
os.path.join(project_dir, "platformio.ini")
|
||||||
).get("platformio", "build_dir")
|
).get("platformio", "build_dir")
|
||||||
|
@ -25,8 +25,8 @@ class TestDirNotExistsError(UnitTestError, UserSideException):
|
|||||||
"A test folder '{0}' does not exist.\nPlease create 'test' "
|
"A test folder '{0}' does not exist.\nPlease create 'test' "
|
||||||
"directory in the project root and put a test set.\n"
|
"directory in the project root and put a test set.\n"
|
||||||
"More details about Unit "
|
"More details about Unit "
|
||||||
"Testing: https://docs.platformio.org/page/plus/"
|
"Testing: https://docs.platformio.org/en/latest/advanced/"
|
||||||
"unit-testing.html"
|
"unit-testing/index.html"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user