forked from platformio/platformio-core
Merge branch 'develop' into feature/platformio-30
* develop: (27 commits) Update boards list Add Arduino M0 as a separate board Update history Update microchippic32 platform and boards Fix PyLint warning Keep user changes for ".gitignore" file when re-generate/update project data Documented uploading of EEPROM data Push 2.11.1.dev1 Automatically install dependent upload tools // Issue #472 Split source files to HEADERS and SOURCES when generate project for Qt Creator IDE // Resolve #713 Improve project generator for CLion IDE Fix missing trailing ``\`` for the source files list when generate project for Qt Creator IDE // Resolve #711 * Fix missed ``--boot`` flag for the firmware uploader for ATSAM3X8E Cortex-M3 MCU based boards (Arduino Due, etc) // Resolve #710 Initial support for Arduino M0/Tian boards // Issue #472 Update project template for Qt Creator // Issue #711 Fix missed --boot flag for sam3x uploader // Issue # 710 Auto-remove project cache when PlatformIO is upgraded Version bump to 2.11.0 (issues #472, #520, #614, #620, #685, #698, #699) Update history Update espressif platform according to the new framework version
This commit is contained in:
commit
b043a2258f
18 files changed
+448
-85
No files matched your search
@@ -14,7 +14,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
VERSION = (3, 0, "0.dev3")
|
||||
VERSION = (3, 0, "0.dev4")
|
||||
__version__ = ".".join([str(s) for s in VERSION])
|
||||
|
||||
__title__ = "platformio"
|
||||
|
||||
@@ -21,7 +21,7 @@ from time import time
|
||||
|
||||
import click
|
||||
|
||||
from platformio import app, exception, telemetry, util
|
||||
from platformio import __version__, app, exception, telemetry, util
|
||||
from platformio.commands.lib import lib_install as cmd_lib_install
|
||||
from platformio.commands.platform import \
|
||||
platform_install as cmd_platform_install
|
||||
@@ -266,7 +266,7 @@ def check_project_envs(project_dir, environments):
|
||||
|
||||
|
||||
def calculate_project_hash():
|
||||
structure = []
|
||||
structure = [__version__]
|
||||
for d in (util.get_projectsrc_dir(), util.get_projectlib_dir()):
|
||||
if not isdir(d):
|
||||
continue
|
||||
|
||||
@@ -16,11 +16,10 @@ import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from os.path import (abspath, basename, expanduser, isdir, join, normpath,
|
||||
relpath)
|
||||
from os.path import (abspath, basename, expanduser, isdir, isfile, join,
|
||||
normpath, relpath)
|
||||
|
||||
import bottle
|
||||
import click # pylint: disable=wrong-import-order
|
||||
|
||||
from platformio import app, exception, util
|
||||
|
||||
@@ -114,16 +113,18 @@ class ProjectGenerator(object):
|
||||
return tpls
|
||||
|
||||
def generate(self):
|
||||
for _relpath, _path in self.get_tpls():
|
||||
tpl_dir = self.project_dir
|
||||
if _relpath:
|
||||
tpl_dir = join(self.project_dir, _relpath)
|
||||
if not isdir(tpl_dir):
|
||||
os.makedirs(tpl_dir)
|
||||
for tpl_relpath, tpl_path in self.get_tpls():
|
||||
dst_dir = self.project_dir
|
||||
if tpl_relpath:
|
||||
dst_dir = join(self.project_dir, tpl_relpath)
|
||||
if not isdir(dst_dir):
|
||||
os.makedirs(dst_dir)
|
||||
|
||||
file_name = basename(_path)[:-4]
|
||||
with open(join(tpl_dir, file_name), "w") as f:
|
||||
f.write(self._render_tpl(_path).encode("utf8"))
|
||||
file_name = basename(tpl_path)[:-4]
|
||||
self._merge_contents(
|
||||
join(dst_dir, file_name),
|
||||
self._render_tpl(tpl_path).encode("utf8")
|
||||
)
|
||||
|
||||
def _render_tpl(self, tpl_path):
|
||||
content = ""
|
||||
@@ -131,23 +132,29 @@ class ProjectGenerator(object):
|
||||
content = f.read()
|
||||
return bottle.template(content, **self._tplvars)
|
||||
|
||||
@staticmethod
|
||||
def _merge_contents(dst_path, contents):
|
||||
file_name = basename(dst_path)
|
||||
|
||||
# merge .gitignore
|
||||
if file_name == ".gitignore" and isfile(dst_path):
|
||||
contents = [l.strip() for l in contents.split("\n") if l.strip()]
|
||||
with open(dst_path) as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if line and line not in contents:
|
||||
contents.append(line)
|
||||
contents = "\n".join(contents)
|
||||
|
||||
with open(dst_path, "w") as f:
|
||||
f.write(contents)
|
||||
|
||||
def _gather_tplvars(self):
|
||||
src_files = self.get_src_files()
|
||||
|
||||
if (not any([f.endswith((".c", ".cpp")) for f in src_files]) and
|
||||
self.ide == "clion"):
|
||||
click.secho(
|
||||
"Warning! Can not find main source file (*.c, *.cpp). So, "
|
||||
"code auto-completion is disabled. Please add source files "
|
||||
"to `src` directory and re-initialize project or edit "
|
||||
"`CMakeLists.txt` file manually (`add_executable` command).",
|
||||
fg="yellow")
|
||||
|
||||
self._tplvars.update(self.get_project_env())
|
||||
self._tplvars.update(self.get_project_build_data())
|
||||
self._tplvars.update({
|
||||
"project_name": self.get_project_name(),
|
||||
"src_files": src_files,
|
||||
"src_files": self.get_src_files(),
|
||||
"user_home_dir": abspath(expanduser("~")),
|
||||
"project_dir": self.project_dir,
|
||||
"systype": util.get_systype(),
|
||||
|
||||
@@ -43,18 +43,5 @@ add_custom_target(
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
% if src_files and any([f.endswith((".c", ".cpp")) for f in src_files]):
|
||||
add_executable({{project_name}}
|
||||
% for f in src_files:
|
||||
% if f.endswith((".c", ".cpp")):
|
||||
{{f.replace("\\", "/")}}
|
||||
% end
|
||||
% end
|
||||
)
|
||||
% else:
|
||||
#
|
||||
# To enable code auto-completion, please specify path
|
||||
# to main source file (*.c, *.cpp) and uncomment line below
|
||||
#
|
||||
# add_executable({{project_name}} src/main_change_me.cpp)
|
||||
% end
|
||||
aux_source_directory(src SRC_LIST)
|
||||
add_executable(${PROJECT_NAME} ${SRC_LIST})
|
||||
@@ -17,10 +17,12 @@ INCLUDEPATH += "{{include}}"
|
||||
DEFINES += "{{define}}"
|
||||
% end
|
||||
|
||||
OTHER_FILES += \
|
||||
platformio.ini
|
||||
OTHER_FILES += platformio.ini
|
||||
|
||||
SOURCES += \
|
||||
% for file in src_files:
|
||||
{{file}}
|
||||
% end
|
||||
% for file in src_files:
|
||||
% if file.endswith((".h", ".hpp")):
|
||||
HEADERS += {{file}}
|
||||
% else:
|
||||
SOURCES += {{file}}
|
||||
% end
|
||||
% end
|
||||
Reference in new issue
Block a user