mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Better handling of used boards when init/update project
This commit is contained in:
@ -120,10 +120,9 @@ def init_base_project(project_dir):
|
|||||||
|
|
||||||
lib_dir = join(project_dir, "lib")
|
lib_dir = join(project_dir, "lib")
|
||||||
src_dir = join(project_dir, "src")
|
src_dir = join(project_dir, "src")
|
||||||
with util.cd(project_dir):
|
config = util.get_project_config(platformio_ini)
|
||||||
config = util.get_project_config()
|
if config.has_option("platformio", "src_dir"):
|
||||||
if config.has_option("platformio", "src_dir"):
|
src_dir = join(project_dir, config.get("platformio", "src_dir"))
|
||||||
src_dir = join(project_dir, config.get("platformio", "src_dir"))
|
|
||||||
|
|
||||||
for d in (src_dir, lib_dir):
|
for d in (src_dir, lib_dir):
|
||||||
if not isdir(d):
|
if not isdir(d):
|
||||||
@ -263,23 +262,25 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
|||||||
env_prefix, force_download):
|
env_prefix, force_download):
|
||||||
builtin_boards = get_boards()
|
builtin_boards = get_boards()
|
||||||
content = []
|
content = []
|
||||||
used_envs = []
|
used_boards = []
|
||||||
used_platforms = []
|
used_platforms = []
|
||||||
|
|
||||||
with open(platformio_ini) as f:
|
config = util.get_project_config(platformio_ini)
|
||||||
used_envs = [l.strip() for l in f.read().splitlines() if
|
for section in config.sections():
|
||||||
l.strip().startswith("[env:")]
|
if not all([section.startswith("env:"),
|
||||||
|
config.has_option(section, "board")]):
|
||||||
|
continue
|
||||||
|
used_boards.append(config.get(section, "board"))
|
||||||
|
|
||||||
for type_ in board_types:
|
for type_ in board_types:
|
||||||
data = builtin_boards[type_]
|
data = builtin_boards[type_]
|
||||||
used_platforms.append(data['platform'])
|
used_platforms.append(data['platform'])
|
||||||
env_name = "[env:%s%s]" % (env_prefix, type_)
|
|
||||||
|
|
||||||
if env_name in used_envs:
|
if type_ in used_boards:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
content.append("")
|
content.append("")
|
||||||
content.append(env_name)
|
content.append("[env:%s%s]" % (env_prefix, type_))
|
||||||
content.append("platform = %s" % data['platform'])
|
content.append("platform = %s" % data['platform'])
|
||||||
|
|
||||||
# find default framework for board
|
# find default framework for board
|
||||||
|
@ -213,12 +213,13 @@ def get_projectdata_dir():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_project_config():
|
def get_project_config(ini_path=None):
|
||||||
path = join(get_project_dir(), "platformio.ini")
|
if not ini_path:
|
||||||
if not isfile(path):
|
ini_path = join(get_project_dir(), "platformio.ini")
|
||||||
|
if not isfile(ini_path):
|
||||||
raise exception.NotPlatformProject(get_project_dir())
|
raise exception.NotPlatformProject(get_project_dir())
|
||||||
cp = ConfigParser()
|
cp = ConfigParser()
|
||||||
cp.read(path)
|
cp.read(ini_path)
|
||||||
return cp
|
return cp
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user