From 87dffa36b8b56122fbe9c74a3b59bd3169a03264 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 26 May 2022 22:29:51 +0300 Subject: [PATCH] Improved support for user inputs --- docs | 2 +- platformio/builder/main.py | 2 +- platformio/builder/tools/piointegration.py | 22 +++++++++++++++------- platformio/builder/tools/platformio.py | 5 +++-- platformio/project/helpers.py | 6 +++--- platformio/test/exception.py | 4 ++-- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/docs b/docs index 17a3f640..26527c1f 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 17a3f640ac409056db131f2093dd7319fca9157c +Subproject commit 26527c1f6ab013b5cf11174ef087355efc580b04 diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 616f4a0a..6aeee4f4 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -225,7 +225,7 @@ if "envdump" in COMMAND_LINE_TARGETS: click.echo(env.Dump()) env.Exit(0) -if set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS): +if env.IsIntegrationDump(): projenv = None try: Import("projenv") diff --git a/platformio/builder/tools/piointegration.py b/platformio/builder/tools/piointegration.py index 36989f06..f776bccf 100644 --- a/platformio/builder/tools/piointegration.py +++ b/platformio/builder/tools/piointegration.py @@ -19,10 +19,15 @@ import os import SCons.Defaults # 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 +def IsIntegrationDump(_): + return set(["_idedata", "idedata"]) & set(COMMAND_LINE_TARGETS) + + def DumpIntegrationIncludes(env): result = dict(build=[], compatlib=[], toolchain=[]) @@ -60,7 +65,7 @@ def DumpIntegrationIncludes(env): return result -def _get_gcc_defines(env): +def get_gcc_defines(env): items = [] try: sysenv = os.environ.copy() @@ -83,7 +88,7 @@ def _get_gcc_defines(env): return items -def _dump_defines(env): +def dump_defines(env): defines = [] # global symbols for item in SCons.Defaults.processDefines(env.get("CPPDEFINES", [])): @@ -108,12 +113,12 @@ def _dump_defines(env): # built-in GCC marcos # if env.GetCompilerType() == "gcc": - # defines.extend(_get_gcc_defines(env)) + # defines.extend(get_gcc_defines(env)) return defines -def _get_svd_path(env): +def dump_svd_path(env): svd_path = env.GetProjectOption("debug_svd_path") if svd_path: return os.path.abspath(svd_path) @@ -146,13 +151,13 @@ def DumpIntegrationData(env, globalenv): data = { "env_name": env["PIOENV"], "libsource_dirs": [env.subst(item) for item in env.GetLibSourceDirs()], - "defines": _dump_defines(env), + "defines": dump_defines(env), "includes": env.DumpIntegrationIncludes(), "cc_path": where_is_program(env.subst("$CC"), 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']}")), "prog_path": env.subst("$PROG_PATH"), - "svd_path": _get_svd_path(env), + "svd_path": dump_svd_path(env), "compiler_type": env.GetCompilerType(), "targets": globalenv.DumpTargets(), "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() # https://github.com/platformio/platformio-atom-ide/issues/34 @@ -191,6 +198,7 @@ def exists(_): def generate(env): + env.AddMethod(IsIntegrationDump) env.AddMethod(DumpIntegrationIncludes) env.AddMethod(DumpIntegrationData) return env diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 9476f685..60309b55 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -171,12 +171,13 @@ def ProcessProjectDeps(env): "Error: Nothing to build. Please put your source code files " "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( "Error: Nothing to build. Please put your test suites " "to the '%s' folder\n" % env.subst("$PROJECT_TEST_DIR") ) - env.Exit(1) + env.Exit(1) Export("projenv") diff --git a/platformio/project/helpers.py b/platformio/project/helpers.py index bc8d324a..c7b786c8 100644 --- a/platformio/project/helpers.py +++ b/platformio/project/helpers.py @@ -126,7 +126,7 @@ def load_build_metadata(project_dir, env_or_envs, cache=False): env_names = [env_names] 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()) if 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 if '"includes":' not in 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( os.path.join(project_dir, "platformio.ini") ).get("platformio", "build_dir") diff --git a/platformio/test/exception.py b/platformio/test/exception.py index 2d8c790c..048e7399 100644 --- a/platformio/test/exception.py +++ b/platformio/test/exception.py @@ -25,8 +25,8 @@ class TestDirNotExistsError(UnitTestError, UserSideException): "A test folder '{0}' does not exist.\nPlease create 'test' " "directory in the project root and put a test set.\n" "More details about Unit " - "Testing: https://docs.platformio.org/page/plus/" - "unit-testing.html" + "Testing: https://docs.platformio.org/en/latest/advanced/" + "unit-testing/index.html" )