diff --git a/platformio/commands/debug/command.py b/platformio/commands/debug/command.py index 918aeb60..c604d8b9 100644 --- a/platformio/commands/debug/command.py +++ b/platformio/commands/debug/command.py @@ -39,12 +39,22 @@ from platformio.managers.core import inject_contrib_pysite dir_okay=True, writable=True, resolve_path=True)) +@click.option( + "-c", + "--project-conf", + type=click.Path( + exists=True, + file_okay=True, + dir_okay=False, + readable=True, + resolve_path=True)) @click.option("--environment", "-e", metavar="") @click.option("--verbose", "-v", is_flag=True) @click.option("--interface", type=click.Choice(["gdb"])) @click.argument("__unprocessed", nargs=-1, type=click.UNPROCESSED) @click.pass_context -def cli(ctx, project_dir, environment, verbose, interface, __unprocessed): +def cli(ctx, project_dir, project_conf, environment, verbose, interface, + __unprocessed): try: util.ensure_udev_rules() except NameError: @@ -59,8 +69,10 @@ def cli(ctx, project_dir, environment, verbose, interface, __unprocessed): project_dir = os.getenv("CWD") with util.cd(project_dir): - env_name = helpers.check_env_name(project_dir, environment) - env_options = helpers.get_env_options(project_dir, env_name) + env_name = helpers.check_env_name(project_conf or project_dir, + environment) + env_options = helpers.get_env_options(project_conf or project_dir, + env_name) if not set(env_options.keys()) >= set(["platform", "board"]): raise exception.ProjectEnvsNotAvailable() debug_options = helpers.validate_debug_options(ctx, env_options) diff --git a/platformio/commands/debug/helpers.py b/platformio/commands/debug/helpers.py index 42a4ef40..757d3ad9 100644 --- a/platformio/commands/debug/helpers.py +++ b/platformio/commands/debug/helpers.py @@ -46,8 +46,8 @@ def escape_path(path): return path.replace("\\", "/") -def check_env_name(project_dir, environment): - config = util.load_project_config(project_dir) +def check_env_name(project_conf, environment): + config = util.load_project_config(project_conf) envs = [] for section in config.sections(): if section.startswith("env:"): @@ -63,8 +63,8 @@ def check_env_name(project_dir, environment): return envs[0] -def get_env_options(project_dir, environment): - config = util.load_project_config(project_dir) +def get_env_options(project_conf, environment): + config = util.load_project_config(project_conf) options = {} for k, v in config.items("env:%s" % environment): options[k] = v diff --git a/platformio/commands/test/command.py b/platformio/commands/test/command.py index a4a3d627..47f8571f 100644 --- a/platformio/commands/test/command.py +++ b/platformio/commands/test/command.py @@ -53,6 +53,15 @@ from platformio.commands.test.native import NativeTestProcessor dir_okay=True, writable=True, resolve_path=True)) +@click.option( + "-c", + "--project-conf", + type=click.Path( + exists=True, + file_okay=True, + dir_okay=False, + readable=True, + resolve_path=True)) @click.option("--without-building", is_flag=True) @click.option("--without-uploading", is_flag=True) @click.option("--without-testing", is_flag=True) @@ -71,14 +80,14 @@ from platformio.commands.test.native import NativeTestProcessor @click.pass_context def cli( # pylint: disable=redefined-builtin ctx, environment, ignore, filter, upload_port, test_port, project_dir, - without_building, without_uploading, without_testing, no_reset, - monitor_rts, monitor_dtr, verbose): + project_conf, without_building, without_uploading, without_testing, + no_reset, monitor_rts, monitor_dtr, verbose): with util.cd(project_dir): test_dir = util.get_projecttest_dir() if not isdir(test_dir): raise exception.TestDirNotExists(test_dir) test_names = get_test_names(test_dir) - projectconf = util.load_project_config() + projectconf = util.load_project_config(project_conf) env_default = None if projectconf.has_option("platformio", "env_default"): env_default = util.parse_conf_multi_values(