forked from platformio/platformio-core
Allow overriding a default project "platformio.ini" configuration file
This commit is contained in:
@ -39,12 +39,22 @@ from platformio.managers.core import inject_contrib_pysite
|
|||||||
dir_okay=True,
|
dir_okay=True,
|
||||||
writable=True,
|
writable=True,
|
||||||
resolve_path=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="<environment>")
|
@click.option("--environment", "-e", metavar="<environment>")
|
||||||
@click.option("--verbose", "-v", is_flag=True)
|
@click.option("--verbose", "-v", is_flag=True)
|
||||||
@click.option("--interface", type=click.Choice(["gdb"]))
|
@click.option("--interface", type=click.Choice(["gdb"]))
|
||||||
@click.argument("__unprocessed", nargs=-1, type=click.UNPROCESSED)
|
@click.argument("__unprocessed", nargs=-1, type=click.UNPROCESSED)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, project_dir, environment, verbose, interface, __unprocessed):
|
def cli(ctx, project_dir, project_conf, environment, verbose, interface,
|
||||||
|
__unprocessed):
|
||||||
try:
|
try:
|
||||||
util.ensure_udev_rules()
|
util.ensure_udev_rules()
|
||||||
except NameError:
|
except NameError:
|
||||||
@ -59,8 +69,10 @@ def cli(ctx, project_dir, environment, verbose, interface, __unprocessed):
|
|||||||
project_dir = os.getenv("CWD")
|
project_dir = os.getenv("CWD")
|
||||||
|
|
||||||
with util.cd(project_dir):
|
with util.cd(project_dir):
|
||||||
env_name = helpers.check_env_name(project_dir, environment)
|
env_name = helpers.check_env_name(project_conf or project_dir,
|
||||||
env_options = helpers.get_env_options(project_dir, env_name)
|
environment)
|
||||||
|
env_options = helpers.get_env_options(project_conf or project_dir,
|
||||||
|
env_name)
|
||||||
if not set(env_options.keys()) >= set(["platform", "board"]):
|
if not set(env_options.keys()) >= set(["platform", "board"]):
|
||||||
raise exception.ProjectEnvsNotAvailable()
|
raise exception.ProjectEnvsNotAvailable()
|
||||||
debug_options = helpers.validate_debug_options(ctx, env_options)
|
debug_options = helpers.validate_debug_options(ctx, env_options)
|
||||||
|
@ -46,8 +46,8 @@ def escape_path(path):
|
|||||||
return path.replace("\\", "/")
|
return path.replace("\\", "/")
|
||||||
|
|
||||||
|
|
||||||
def check_env_name(project_dir, environment):
|
def check_env_name(project_conf, environment):
|
||||||
config = util.load_project_config(project_dir)
|
config = util.load_project_config(project_conf)
|
||||||
envs = []
|
envs = []
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
if section.startswith("env:"):
|
if section.startswith("env:"):
|
||||||
@ -63,8 +63,8 @@ def check_env_name(project_dir, environment):
|
|||||||
return envs[0]
|
return envs[0]
|
||||||
|
|
||||||
|
|
||||||
def get_env_options(project_dir, environment):
|
def get_env_options(project_conf, environment):
|
||||||
config = util.load_project_config(project_dir)
|
config = util.load_project_config(project_conf)
|
||||||
options = {}
|
options = {}
|
||||||
for k, v in config.items("env:%s" % environment):
|
for k, v in config.items("env:%s" % environment):
|
||||||
options[k] = v
|
options[k] = v
|
||||||
|
@ -53,6 +53,15 @@ from platformio.commands.test.native import NativeTestProcessor
|
|||||||
dir_okay=True,
|
dir_okay=True,
|
||||||
writable=True,
|
writable=True,
|
||||||
resolve_path=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-building", is_flag=True)
|
||||||
@click.option("--without-uploading", is_flag=True)
|
@click.option("--without-uploading", is_flag=True)
|
||||||
@click.option("--without-testing", is_flag=True)
|
@click.option("--without-testing", is_flag=True)
|
||||||
@ -71,14 +80,14 @@ from platformio.commands.test.native import NativeTestProcessor
|
|||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli( # pylint: disable=redefined-builtin
|
def cli( # pylint: disable=redefined-builtin
|
||||||
ctx, environment, ignore, filter, upload_port, test_port, project_dir,
|
ctx, environment, ignore, filter, upload_port, test_port, project_dir,
|
||||||
without_building, without_uploading, without_testing, no_reset,
|
project_conf, without_building, without_uploading, without_testing,
|
||||||
monitor_rts, monitor_dtr, verbose):
|
no_reset, monitor_rts, monitor_dtr, verbose):
|
||||||
with util.cd(project_dir):
|
with util.cd(project_dir):
|
||||||
test_dir = util.get_projecttest_dir()
|
test_dir = util.get_projecttest_dir()
|
||||||
if not isdir(test_dir):
|
if not isdir(test_dir):
|
||||||
raise exception.TestDirNotExists(test_dir)
|
raise exception.TestDirNotExists(test_dir)
|
||||||
test_names = get_test_names(test_dir)
|
test_names = get_test_names(test_dir)
|
||||||
projectconf = util.load_project_config()
|
projectconf = util.load_project_config(project_conf)
|
||||||
env_default = None
|
env_default = None
|
||||||
if projectconf.has_option("platformio", "env_default"):
|
if projectconf.has_option("platformio", "env_default"):
|
||||||
env_default = util.parse_conf_multi_values(
|
env_default = util.parse_conf_multi_values(
|
||||||
|
Reference in New Issue
Block a user