mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Implement "envLibdepsDirs" per project for PIO Home
This commit is contained in:
@ -29,6 +29,7 @@ from platformio.compat import get_filesystem_encoding
|
|||||||
from platformio.ide.projectgenerator import ProjectGenerator
|
from platformio.ide.projectgenerator import ProjectGenerator
|
||||||
from platformio.managers.platform import PlatformManager
|
from platformio.managers.platform import PlatformManager
|
||||||
from platformio.project.config import ProjectConfig
|
from platformio.project.config import ProjectConfig
|
||||||
|
from platformio.project.helpers import get_project_libdeps_dir
|
||||||
|
|
||||||
|
|
||||||
class ProjectRPC(object):
|
class ProjectRPC(object):
|
||||||
@ -37,9 +38,10 @@ class ProjectRPC(object):
|
|||||||
def _get_projects(project_dirs=None):
|
def _get_projects(project_dirs=None):
|
||||||
|
|
||||||
def _get_project_data(project_dir):
|
def _get_project_data(project_dir):
|
||||||
data = {"boards": [], "libExtraDirs": []}
|
data = {"boards": [], "envLibdepsDirs": [], "libExtraDirs": []}
|
||||||
config = ProjectConfig(join(project_dir, "platformio.ini"))
|
config = ProjectConfig(join(project_dir, "platformio.ini"))
|
||||||
config.validate(validate_options=False)
|
config.validate(validate_options=False)
|
||||||
|
libdeps_dir = get_project_libdeps_dir()
|
||||||
|
|
||||||
if config.has_section("platformio") and \
|
if config.has_section("platformio") and \
|
||||||
config.has_option("platformio", "lib_extra_dirs"):
|
config.has_option("platformio", "lib_extra_dirs"):
|
||||||
@ -50,6 +52,7 @@ class ProjectRPC(object):
|
|||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
if not section.startswith("env:"):
|
if not section.startswith("env:"):
|
||||||
continue
|
continue
|
||||||
|
data['envLibdepsDirs'].append(join(libdeps_dir, section[4:]))
|
||||||
if config.has_option(section, "board"):
|
if config.has_option(section, "board"):
|
||||||
data['boards'].append(config.get(section, "board"))
|
data['boards'].append(config.get(section, "board"))
|
||||||
if config.has_option(section, "lib_extra_dirs"):
|
if config.has_option(section, "lib_extra_dirs"):
|
||||||
@ -57,18 +60,13 @@ class ProjectRPC(object):
|
|||||||
util.parse_conf_multi_values(
|
util.parse_conf_multi_values(
|
||||||
config.get(section, "lib_extra_dirs")))
|
config.get(section, "lib_extra_dirs")))
|
||||||
|
|
||||||
# resolve libExtraDirs paths
|
# skip non existing folders and resolve full path
|
||||||
with util.cd(project_dir):
|
for key in ("envLibdepsDirs", "libExtraDirs"):
|
||||||
data['libExtraDirs'] = [
|
data[key] = [
|
||||||
expanduser(d) if d.startswith("~") else realpath(d)
|
expanduser(d) if d.startswith("~") else realpath(d)
|
||||||
for d in data['libExtraDirs']
|
for d in data[key] if isdir(d)
|
||||||
]
|
]
|
||||||
|
|
||||||
# skip non existing folders
|
|
||||||
data['libExtraDirs'] = [
|
|
||||||
d for d in data['libExtraDirs'] if isdir(d)
|
|
||||||
]
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _path_to_name(path):
|
def _path_to_name(path):
|
||||||
@ -83,7 +81,8 @@ class ProjectRPC(object):
|
|||||||
data = {}
|
data = {}
|
||||||
boards = []
|
boards = []
|
||||||
try:
|
try:
|
||||||
data = _get_project_data(project_dir)
|
with util.cd(project_dir):
|
||||||
|
data = _get_project_data(project_dir)
|
||||||
except exception.PlatformIOProjectException:
|
except exception.PlatformIOProjectException:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -104,6 +103,10 @@ class ProjectRPC(object):
|
|||||||
int(getmtime(project_dir)),
|
int(getmtime(project_dir)),
|
||||||
"boards":
|
"boards":
|
||||||
boards,
|
boards,
|
||||||
|
"envLibStorages": [{
|
||||||
|
"name": basename(d),
|
||||||
|
"path": d
|
||||||
|
} for d in data.get("envLibdepsDirs", [])],
|
||||||
"extraLibStorages": [{
|
"extraLibStorages": [{
|
||||||
"name": _path_to_name(d),
|
"name": _path_to_name(d),
|
||||||
"path": d
|
"path": d
|
||||||
|
Reference in New Issue
Block a user