mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Extend "load_project_ide_data" API to return IDE data for more than one environment
This commit is contained in:
@ -140,6 +140,8 @@ def DumpIDEData(env, projenv):
|
||||
LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS"
|
||||
|
||||
data = {
|
||||
"env_name":
|
||||
env['PIOENV'],
|
||||
"libsource_dirs": [env.subst(l) for l in env.GetLibSourceDirs()],
|
||||
"defines":
|
||||
_dump_defines(env),
|
||||
|
@ -194,20 +194,29 @@ def compute_project_checksum(config):
|
||||
return checksum.hexdigest()
|
||||
|
||||
|
||||
def load_project_ide_data(project_dir, env_name):
|
||||
def load_project_ide_data(project_dir, envs):
|
||||
from platformio.commands.run import cli as cmd_run
|
||||
result = CliRunner().invoke(cmd_run, [
|
||||
"--project-dir", project_dir, "--environment", env_name, "--target",
|
||||
"idedata"
|
||||
])
|
||||
assert envs
|
||||
if not isinstance(envs, (list, tuple)):
|
||||
envs = [envs]
|
||||
args = ["--project-dir", project_dir, "--target", "idedata"]
|
||||
for env in envs:
|
||||
args.extend(["-e", env])
|
||||
result = CliRunner().invoke(cmd_run, args)
|
||||
if result.exit_code != 0 and not isinstance(result.exception,
|
||||
exception.ReturnErrorCode):
|
||||
raise result.exception
|
||||
if '"includes":' not in result.output:
|
||||
raise exception.PlatformioException(result.output)
|
||||
|
||||
data = {}
|
||||
for line in result.output.split("\n"):
|
||||
line = line.strip()
|
||||
if line.startswith('{"') and line.endswith("}"):
|
||||
return json.loads(line)
|
||||
return None
|
||||
if (line.startswith('{"') and line.endswith("}")
|
||||
and "env_name" in line):
|
||||
_data = json.loads(line)
|
||||
if "env_name" in _data:
|
||||
data[_data['env_name']] = _data
|
||||
if len(envs) == 1 and envs[0] in data:
|
||||
return data[envs[0]]
|
||||
return data or None
|
||||
|
Reference in New Issue
Block a user