diff --git a/HISTORY.rst b/HISTORY.rst index 38f22c94..0bcb7c4d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,14 +20,12 @@ PlatformIO 2.0 * Simplified `installation `__ process of PlatformIO (`issue #274 `_) -* Added support for Adafruit Gemma board to - `atmelavr `__ - platform - (`pull #256 `_) +* Significantly improved `Project Generator `__ which allows to integrate with `the most popular + IDE `__ * Added short ``-h`` help option for PlatformIO and sub-commands * Updated `mbed `__ framework -* Updated ``tool-teensy`` for `Teensy `__ +* Updated ``tool-teensy`` package for `Teensy `__ platform (`issue #268 `_) * Added FAQ answer when `Program "platformio" not found in PATH `_ @@ -36,6 +34,10 @@ PlatformIO 2.0 (`issue #273 `_) * Use toolchain's includes pattern ``include*`` for Project Generator (`issue #277 `_) +* Added support for Adafruit Gemma board to + `atmelavr `__ + platform + (`pull #256 `_) * Fixed includes list for Windows OS when generating project for `Eclipse IDE `__ (`issue #270 `_) * Fixed ``AttributeError: 'module' object has no attribute 'packages'`` diff --git a/docs/_static/ide-platformio-clion.png b/docs/_static/ide-platformio-clion.png index 11f0754f..96049b35 100644 Binary files a/docs/_static/ide-platformio-clion.png and b/docs/_static/ide-platformio-clion.png differ diff --git a/docs/ide/atom.rst b/docs/ide/atom.rst index 9b95c621..c4fa674c 100644 --- a/docs/ide/atom.rst +++ b/docs/ide/atom.rst @@ -20,11 +20,6 @@ page for more detailed information. Integration ----------- -.. note:: - Please verify that folder where is located ``platformio`` program is added - to `PATH (wiki) `_ environment - variable. See FAQ: :ref:`faq_troubleshooting_pionotfoundinpath`. - Using `Atom Packages `_ please install `platomformio `_ package. diff --git a/docs/ide/clion.rst b/docs/ide/clion.rst index 34eb1be7..2ec8d709 100644 --- a/docs/ide/clion.rst +++ b/docs/ide/clion.rst @@ -22,11 +22,6 @@ page for more detailed information. Integration ----------- -.. note:: - Please verify that folder where is located ``platformio`` program is added - to `PATH (wiki) `_ environment - variable. See FAQ: :ref:`faq_troubleshooting_pionotfoundinpath`. - Project Generator ^^^^^^^^^^^^^^^^^ @@ -41,6 +36,12 @@ Since PlatformIO 2.0 you can generate CLion compatible project using Then import this project from start menu or via ``File > Import Project>`` and specify root directory where is located :ref:`projectconf`. +There are 3 predefined targets for building: + +* ``PLATFORMIO_BUILD`` - build project without auto-uploading +* ``PLATFORMIO_UPLOAD`` - build and upload (if no errors) +* ``PLATFORMIO_CLEAN`` - clean compiled objects and etc. + .. warning:: CLion is still in the development stage, so some of the features (like, auto-complete) probably will not work with PlatformIO. See diff --git a/docs/ide/eclipse.rst b/docs/ide/eclipse.rst index 0cfc0cae..4a51b6af 100644 --- a/docs/ide/eclipse.rst +++ b/docs/ide/eclipse.rst @@ -26,17 +26,6 @@ page for more detailed information. Integration ----------- -.. note:: - Please verify that folder where is located ``platformio`` program is added - to `PATH (wiki) `_ environment - variable. See FAQ: :ref:`faq_troubleshooting_pionotfoundinpath`. - - What is more, you can update Eclipse ``$PATH`` variable. In Eclipse IDE make - right click on the created project ("Project Explorer"): - ``Properties > C/C++ Build > Environment > PATH > Edit`` - and set to ``/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin``. If ``PATH`` - variable doesn't exists, please ``Add`` it. - Project Generator ^^^^^^^^^^^^^^^^^ diff --git a/docs/ide/sublimetext.rst b/docs/ide/sublimetext.rst index c060c92a..4eab4fa6 100644 --- a/docs/ide/sublimetext.rst +++ b/docs/ide/sublimetext.rst @@ -18,11 +18,6 @@ page for more detailed information. Integration ----------- -.. note:: - Please verify that folder where is located ``platformio`` program is added - to `PATH (wiki) `_ environment - variable. See FAQ: :ref:`faq_troubleshooting_pionotfoundinpath`. - Project Generator ^^^^^^^^^^^^^^^^^ @@ -40,6 +35,11 @@ directory where is located :ref:`projectconf`. Manual Integration ^^^^^^^^^^^^^^^^^^ +.. note:: + Please verify that folder where is located ``platformio`` program is added + to `PATH (wiki) `_ environment + variable. See FAQ: :ref:`faq_troubleshooting_pionotfoundinpath`. + Initial configuration ~~~~~~~~~~~~~~~~~~~~~ @@ -50,17 +50,17 @@ described below: .. code-block:: bash { - "cmd": ["platformio", "--force", "run"], + "cmd": ["platformio", "-f", "-c", "sublimetext", "run"], "working_dir": "${project_path:${folder}}", "variants": [ { "name": "Clean", - "cmd": ["platformio", "--force", "run", "--target", "clean"] + "cmd": ["platformio", "-f", "-c", "sublimetext", "run", "--target", "clean"] }, { "name": "Upload", - "cmd": ["platformio", "--force", "run", "--target", "upload"] + "cmd": ["platformio", "-f", "-c", "sublimetext", "run", "--target", "upload"] } ] } diff --git a/docs/ide/vim.rst b/docs/ide/vim.rst index 76f87ced..cad03289 100644 --- a/docs/ide/vim.rst +++ b/docs/ide/vim.rst @@ -35,10 +35,10 @@ Put to the project directory ``Makefile`` wrapper with contents: #PATH := /usr/local/bin:$(PATH) all: - platformio --force run --target upload + platformio -f -c vim run --target upload clean: - platformio --force run --target clean + platformio -f -c vim run --target clean Now, in VIM ``cd /path/to/this/project`` and press ``Ctrl+B`` or ``Cmd+B`` diff --git a/platformio/__init__.py b/platformio/__init__.py index 553922c4..33f84f8d 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 3, "0b1") +VERSION = (2, 3, "0b2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index de64d606..f54c317e 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -7,7 +7,7 @@ from glob import glob from os import environ, remove from os.path import basename, join -from platformio.util import exec_command +from platformio.util import exec_command, where_is_program class InoToCPPConverter(object): @@ -122,7 +122,9 @@ def ConvertInoToCpp(env): def DumpIDEData(env): data = { "defines": [], - "includes": [] + "includes": [], + "cxx_path": where_is_program( + env.subst("$CXX"), env.subst("${ENV['PATH']}")) } # includes from framework and libs diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 668becfb..b694620d 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -2,7 +2,7 @@ # See LICENSE for details. import json -from os import listdir, makedirs, walk +import os from os.path import abspath, basename, expanduser, isdir, join, relpath import bottle @@ -23,7 +23,7 @@ class ProjectGenerator(object): @staticmethod def get_supported_ides(): tpls_dir = join(util.get_source_dir(), "ide", "tpls") - return sorted([d for d in listdir(tpls_dir) + return sorted([d for d in os.listdir(tpls_dir) if isdir(join(tpls_dir, d))]) @util.memoized @@ -43,25 +43,30 @@ class ProjectGenerator(object): @util.memoized def get_project_build_data(self): + data = { + "defines": [], + "includes": [], + "cxx_path": None + } envdata = self.get_project_env() if "env_name" not in envdata: - return None + return data result = util.exec_command( ["platformio", "run", "-t", "idedata", "-e", envdata['env_name'], "--project-dir", self.project_dir] ) - if result['returncode'] != 0 or '{"includes":' not in result['out']: - return None + if result['returncode'] != 0 or '"includes":' not in result['out']: + return data output = result['out'] try: - start_index = output.index('\n{"includes":') + start_index = output.index('\n{"') stop_index = output.rindex('}') - return json.loads(output[start_index + 1:stop_index + 1]) + data = json.loads(output[start_index + 1:stop_index + 1]) except ValueError: pass - return None + return data def get_project_name(self): return basename(self.project_dir) @@ -69,7 +74,7 @@ class ProjectGenerator(object): def get_srcfiles(self): result = [] with util.cd(self.project_dir): - for root, _, files in walk(util.get_projectsrc_dir()): + for root, _, files in os.walk(util.get_projectsrc_dir()): for f in files: result.append(relpath(join(root, f))) return result @@ -77,20 +82,23 @@ class ProjectGenerator(object): def get_tpls(self): tpls = [] tpls_dir = join(util.get_source_dir(), "ide", "tpls", self.ide) - for root, _, files in walk(tpls_dir): + for root, _, files in os.walk(tpls_dir): for f in files: - if f.endswith(".tpl"): - tpls.append(( - root.replace(tpls_dir, ""), join(root, f))) + if not f.endswith(".tpl"): + continue + _relpath = root.replace(tpls_dir, "") + if _relpath.startswith(os.sep): + _relpath = _relpath[len(os.sep):] + tpls.append((_relpath, join(root, f))) 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)[1:] + tpl_dir = join(self.project_dir, _relpath) if not isdir(tpl_dir): - makedirs(tpl_dir) + os.makedirs(tpl_dir) file_name = basename(_path)[:-4] with open(join(tpl_dir, file_name), "w") as f: @@ -104,17 +112,14 @@ class ProjectGenerator(object): def _gather_tplvars(self): self._tplvars.update(self.get_project_env()) - - build_data = self.get_project_build_data() - + self._tplvars.update(self.get_project_build_data()) self._tplvars.update({ "project_name": self.get_project_name(), - "includes": (build_data['includes'] - if build_data and "includes" in build_data else []), - "defines": (build_data['defines'] - if build_data and "defines" in build_data else []), "srcfiles": self.get_srcfiles(), "user_home_dir": abspath(expanduser("~")), "project_dir": self.project_dir, - "systype": util.get_systype() + "systype": util.get_systype(), + "platformio_path": util.where_is_program("platformio"), + "env_pathsep": os.pathsep, + "env_path": os.getenv("PATH") }) diff --git a/platformio/ide/tpls/clion/CMakeLists.txt.tpl b/platformio/ide/tpls/clion/CMakeLists.txt.tpl index 9707347f..fe6d5807 100644 --- a/platformio/ide/tpls/clion/CMakeLists.txt.tpl +++ b/platformio/ide/tpls/clion/CMakeLists.txt.tpl @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.2) project({{project_name}}) + +set(ENV{PATH} "{{env_path}}") +set(PLATFORMIO_CMD "{{platformio_path}}") + % for include in includes: % if include.startswith(user_home_dir): include_directories("$ENV{HOME}{{include.replace(user_home_dir, '').replace("\\", "/")}}") @@ -14,18 +18,18 @@ add_definitions(-D{{define}}) add_custom_target( PLATFORMIO_BUILD ALL - COMMAND platformio -f run + COMMAND ${PLATFORMIO_CMD} -f -c clion run WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) add_custom_target( PLATFORMIO_UPLOAD ALL - COMMAND platformio -f run --target upload + COMMAND ${PLATFORMIO_CMD} -f -c clion run --target upload WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) add_custom_target( PLATFORMIO_CLEAN ALL - COMMAND platformio -f run --target clean + COMMAND ${PLATFORMIO_CMD} -f -c clion run --target clean WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) \ No newline at end of file diff --git a/platformio/ide/tpls/eclipse/.cproject.tpl b/platformio/ide/tpls/eclipse/.cproject.tpl index 2d608394..08b8a369 100644 --- a/platformio/ide/tpls/eclipse/.cproject.tpl +++ b/platformio/ide/tpls/eclipse/.cproject.tpl @@ -19,7 +19,7 @@ - +