From ce7d6f0507f0f62f59be6782e2cd60ad745bf420 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 May 2015 22:03:55 +0300 Subject: [PATCH 01/36] Add where PlatformIO 2.0 was made --- HISTORY.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2fbabd97..1a99b3f0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,7 +4,10 @@ Release History 2.0.0 (2015-05-22) ------------------ -* PlatformIO as :ref:`ci` (CI) tool for embedded projects +*Made in `Paradise `_* + +* PlatformIO as `Continuous Integration `_ + (CI) tool for embedded projects (`issue #108 `_) * Initialise PlatformIO project for the specified IDE (`issue #151 `_) From e22e4d23e4954322cbb751929b6bf4ba14a3fb09 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 May 2015 22:16:27 +0300 Subject: [PATCH 02/36] Fix broken link --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 1a99b3f0..f22ac94c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,7 +4,7 @@ Release History 2.0.0 (2015-05-22) ------------------ -*Made in `Paradise `_* +*Made in* `Paradise `_ * PlatformIO as `Continuous Integration `_ (CI) tool for embedded projects From f732d4088b880d0d53d525fa349c4da50becb6f7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 14:02:05 +0300 Subject: [PATCH 03/36] Fix bug with converting "*.ino" to "*.cpp" --- HISTORY.rst | 5 +++++ platformio/__init__.py | 2 +- platformio/builder/tools/platformio.py | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index f22ac94c..5d03f055 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,11 @@ Release History =============== +2.0.1 (2015-??-??) +------------------ + +* Fixed bug with converting ``*.ino`` to ``*.cpp`` + 2.0.0 (2015-05-22) ------------------ diff --git a/platformio/__init__.py b/platformio/__init__.py index 0864a676..a701575c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 0, 0) +VERSION = (2, 0, "1.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 656473b7..3c07e786 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -309,8 +309,8 @@ class InoToCPPConverter(object): PROTOTYPE_RE = re.compile( r"""^( - (?:\s*[a-z_\d]+){1,2} # return type - \s+[a-z_\d]+\s* # name of prototype + (\s*[a-z_\d]+){1,2} # return type + (\s+[a-z_\d]+\s*) # name of prototype \([a-z_,\.\*\&\[\]\s\d]*\) # arguments )\s*\{ # must end with { """, @@ -334,6 +334,15 @@ class InoToCPPConverter(object): else: return " " + def _parse_prototypes(self, contents): + prototypes = [] + reserved_keywords = set(["if", "else", "while"]) + for item in self.PROTOTYPE_RE.findall(contents): + if set([item[1].strip(), item[2].strip()]) & reserved_keywords: + continue + prototypes.append(item[0]) + return prototypes + def append_prototypes(self, fname, contents, prototypes): contents = self.STRIPCOMMENTS_RE.sub(self._replace_comments_callback, contents) @@ -358,7 +367,7 @@ class InoToCPPConverter(object): data = [] for node in self.nodes: ino_contents = node.get_text_contents() - prototypes += self.PROTOTYPE_RE.findall(ino_contents) + prototypes += self._parse_prototypes(ino_contents) item = (basename(node.get_path()), ino_contents) if self.is_main_node(ino_contents): From 28dd32070f7046c9cc70493219b17e5f87e0edfd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 14:23:55 +0300 Subject: [PATCH 04/36] Pass to API requests information about Continuous Integration system --- HISTORY.rst | 2 ++ platformio/util.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 5d03f055..0c0b5a3b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,8 @@ Release History 2.0.1 (2015-??-??) ------------------ +* Pass to API requests information about Continuous Integration system. This + information will be used by PlatformIO-API. * Fixed bug with converting ``*.ino`` to ``*.cpp`` 2.0.0 (2015-05-22) diff --git a/platformio/util.py b/platformio/util.py index 6dbad199..94f3f93f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -246,8 +246,11 @@ def get_logicaldisks(): def get_request_defheaders(): - return {"User-Agent": "PlatformIO/%s %s" % ( - __version__, requests.utils.default_user_agent())} + return {"User-Agent": "PlatformIO/%s CI/%d %s" % ( + __version__, + 1 if os.environ.get("CI", "").lower() == "true" else 0, + requests.utils.default_user_agent() + )} def get_api_result(path, params=None, data=None): From 363c65da5fcbc199a19afb72597be0a1fb5dae14 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 15:00:21 +0300 Subject: [PATCH 05/36] Fix stripping comments when converting from *.ino to *.cpp --- platformio/builder/tools/platformio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 3c07e786..ec88fae9 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -319,7 +319,8 @@ class InoToCPPConverter(object): DETECTMAIN_RE = re.compile(r"void\s+(setup|loop)\s*\(", re.M | re.I) - STRIPCOMMENTS_RE = re.compile(r"(/\*.*?\*/|//[^\r\n]*$)", re.M | re.S) + STRIPCOMMENTS_RE = re.compile(r"(/\*.*?\*/|(^|\s+)//[^\r\n]*$)", + re.M | re.S) def __init__(self, nodes): self.nodes = nodes From 1113e5d69c7e4d784c6e35f1630627e1b4f6fdd2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 17:42:22 +0300 Subject: [PATCH 06/36] Improve Travis CI docs --- docs/ci/travis.rst | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/docs/ci/travis.rst b/docs/ci/travis.rst index 4c5e9e34..5b74b089 100644 --- a/docs/ci/travis.rst +++ b/docs/ci/travis.rst @@ -44,6 +44,8 @@ Please put ``.travis.yml`` to the root directory of the GitHub repository. - platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N +Then see step 1, 2, and step 4 here: http://docs.travis-ci.com/user/getting-started/ + For more details as for PlatformIO build process please look into :ref:`cmd_ci` command. @@ -60,13 +62,35 @@ Examples - "2.7" env: - - PLATFORMIO_CI_SRC=examples/Bluetooth/PS3SPP/PS3SPP.ino - - PLATFORMIO_CI_SRC=examples/pl2303/pl2303_gps/pl2303_gps.ino + - PLATFORMIO_CI_SRC=examples/acm/acm_terminal + - PLATFORMIO_CI_SRC=examples/adk/term_time + - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiUProController + - PLATFORMIO_CI_SRC=examples/board_qc + - PLATFORMIO_CI_SRC=examples/cdc_XR21B1411/XR_terminal + - PLATFORMIO_CI_SRC=examples/ftdi/USBFTDILoopback + - PLATFORMIO_CI_SRC=examples/HID/le3dp + - PLATFORMIO_CI_SRC=examples/HID/USBHIDJoystick + - PLATFORMIO_CI_SRC=examples/hub_demo + - PLATFORMIO_CI_SRC=examples/max_LCD + - PLATFORMIO_CI_SRC=examples/pl2303/pl2303_xbee_terminal + - PLATFORMIO_CI_SRC=examples/PS3USB + - PLATFORMIO_CI_SRC=examples/PS4USB + - PLATFORMIO_CI_SRC=examples/PSBuzz + - PLATFORMIO_CI_SRC=examples/USB_desc + - PLATFORMIO_CI_SRC=examples/Xbox/XBOXUSB + # - ... install: - python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" - - wget https://github.com/xxxajk/spi4teensy3/archive/master.zip -O /tmp/spi4teensy3.zip - - unzip /tmp/spi4teensy3.zip -d /tmp + + # Libraries from PlatformIO Library Registry + # http://platformio.org/#!/lib/show/416/TinyGPS + # http://platformio.org/#!/lib/show/417/SPI4Teensy3 + - platformio lib install 416 417 script: - - platformio ci --lib="." --lib="/tmp/spi4teensy3-master" --board=uno --board=teensy31 --board=due + - if [[ $PLATFORMIO_CI_SRC == *"WiiIRCamera"* ]]; then sed -i -- 's/#define ENABLE_WII_IR_CAMERA 0/#define ENABLE_WII_IR_CAMERA 1/g' ./settings.h; fi + - platformio ci --board=uno --board=teensy31 --board=due --lib="." + +* Configuration file: https://github.com/felis/USB_Host_Shield_2.0/blob/master/.travis.yml +* Build History: https://travis-ci.org/felis/USB_Host_Shield_2.0 From 9560a665e59585b755394ed1b62935619491ca99 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 18:36:11 +0300 Subject: [PATCH 07/36] Better detecting of Continuous Integration system --- platformio/commands/ci.py | 4 ++-- platformio/downloader.py | 3 +-- platformio/unpacker.py | 8 ++++---- platformio/util.py | 6 +++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index e4b48e07..cf4f5010 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -3,7 +3,7 @@ import stat from glob import glob -from os import chmod, environ, makedirs, remove +from os import chmod, getenv, makedirs, remove from os.path import abspath, basename, isdir, isfile, join from shutil import copyfile, copytree, rmtree from tempfile import mkdtemp @@ -59,7 +59,7 @@ def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913 build_dir, keep_build_dir, project_conf, verbose): if not src: - src = environ.get("PLATFORMIO_CI_SRC", "").split(":") + src = getenv("PLATFORMIO_CI_SRC", "").split(":") if not src: raise click.BadParameter("Missing argument 'src'") diff --git a/platformio/downloader.py b/platformio/downloader.py index 7520446d..04227029 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -3,7 +3,6 @@ from email.utils import parsedate_tz from math import ceil -from os import environ from os.path import getsize, join from time import mktime @@ -50,7 +49,7 @@ class FileDownloader(object): f = open(self._destination, "wb") chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE))) - if environ.get("CI") == "true": + if util.is_ci(): click.echo("Downloading...") for _ in range(0, chunks): f.write(next(itercontent)) diff --git a/platformio/unpacker.py b/platformio/unpacker.py index 34cb3594..482aae96 100644 --- a/platformio/unpacker.py +++ b/platformio/unpacker.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -from os import chmod, environ +from os import chmod from os.path import join, splitext from tarfile import open as tarfile_open from time import mktime @@ -9,8 +9,8 @@ from zipfile import ZipFile import click +from platformio import util from platformio.exception import UnsupportedArchiveType -from platformio.util import change_filemtime class ArchiveBase(object): @@ -51,7 +51,7 @@ class ZIPArchive(ArchiveBase): @staticmethod def preserve_mtime(item, dest_dir): - change_filemtime( + util.change_filemtime( join(dest_dir, item.filename), mktime(list(item.date_time) + [0]*3) ) @@ -81,7 +81,7 @@ class FileUnpacker(object): raise UnsupportedArchiveType(archpath) def start(self): - if environ.get("CI") == "true": + if util.is_ci(): click.echo("Unpacking...") for item in self._unpacker.get_items(): self._unpacker.extract_item(item, self._dest_dir) diff --git a/platformio/util.py b/platformio/util.py index 94f3f93f..6477df7e 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -175,6 +175,10 @@ def change_filemtime(path, time): os.utime(path, (time, time)) +def is_ci(): + return os.getenv("CI", "").lower() == "true" + + def exec_command(*args, **kwargs): result = { "out": None, @@ -248,7 +252,7 @@ def get_logicaldisks(): def get_request_defheaders(): return {"User-Agent": "PlatformIO/%s CI/%d %s" % ( __version__, - 1 if os.environ.get("CI", "").lower() == "true" else 0, + 1 if is_ci() else 0, requests.utils.default_user_agent() )} From 4f10047ba30b33d62e1df077e474fd03a3837a7f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 19:17:07 +0300 Subject: [PATCH 08/36] Handle new environment variable PLATFORMIO_BUILD_FLAGS --- HISTORY.rst | 2 ++ docs/envvars.rst | 22 ++++++++++++---------- docs/projectconf.rst | 5 ++++- platformio/builder/tools/platformio.py | 12 ++++++++---- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 0c0b5a3b..c1b41581 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,8 @@ Release History 2.0.1 (2015-??-??) ------------------ +* Handle new environment variable + `PLATFORMIO_BUILD_FLAGS `_ * Pass to API requests information about Continuous Integration system. This information will be used by PlatformIO-API. * Fixed bug with converting ``*.ino`` to ``*.cpp`` diff --git a/docs/envvars.rst b/docs/envvars.rst index 765ec0a3..1b6aa2e4 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -36,44 +36,46 @@ In other words, ``CI=true`` automatically setup PLATFORMIO_HOME_DIR ~~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_home_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_dir`. .. _envvar_PLATFORMIO_LIB_DIR: PLATFORMIO_LIB_DIR ~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_lib_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_lib_dir`. .. _envvar_PLATFORMIO_SRC_DIR: PLATFORMIO_SRC_DIR ~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_src_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_src_dir`. .. _envvar_PLATFORMIO_ENVS_DIR: PLATFORMIO_ENVS_DIR ~~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_envs_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_envs_dir`. Builder ------- +.. _envvar_PLATFORMIO_BUILD_FLAGS: + +PLATFORMIO_BUILD_FLAGS +~~~~~~~~~~~~~~~~~~~~~~ + +Allows to set :ref:`projectconf` option :ref:`projectconf_build_flags`. + .. _envvar_PLATFORMIO_SRCBUILD_FLAGS: PLATFORMIO_SRCBUILD_FLAGS ~~~~~~~~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_srcbuild_flags`. +Allows to set :ref:`projectconf` option :ref:`projectconf_srcbuild_flags`. Settings -------- diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 698a8762..23f93c8b 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -270,6 +270,9 @@ processes: - Add the directory *dir* to the list of directories to be searched for header files. +This option can be set by global environment variable +:ref:`envvar_PLATFORMIO_BUILD_FLAGS`. + Example: .. code-block:: ini @@ -306,7 +309,7 @@ An option ``srcbuild_flags`` has the same behaviour like ``build_flags`` but will be applied only for the project source code from :ref:`projectconf_pio_src_dir` directory. -This option can be overridden by global environment variable +This option can be set by global environment variable :ref:`envvar_PLATFORMIO_SRCBUILD_FLAGS`. ``install_libs`` diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index ec88fae9..252f8aa6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -47,10 +47,11 @@ def BuildFirmware(env): _LIBFLAGS=" -Wl,--end-group" ) - _srcbuild_flags = getenv("PLATFORMIO_SRCBUILD_FLAGS", - env.subst("$SRCBUILD_FLAGS")) - if _srcbuild_flags: - firmenv.MergeFlags(_srcbuild_flags) + # Handle SRCBUILD_FLAGS + if getenv("PLATFORMIO_SRCBUILD_FLAGS", None): + firmenv.MergeFlags(getenv("PLATFORMIO_SRCBUILD_FLAGS")) + if "SRCBUILD_FLAGS" in env: + firmenv.MergeFlags(env['SRCBUILD_FLAGS']) firmenv.Append( CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( @@ -83,6 +84,9 @@ def ProcessFlags(env): if "extra_flags" in env.get("BOARD_OPTIONS", {}).get("build", {}): env.MergeFlags(env.subst("${BOARD_OPTIONS['build']['extra_flags']}")) + # Handle BUILD_FLAGS + if getenv("PLATFORMIO_BUILD_FLAGS", None): + env.MergeFlags(getenv("PLATFORMIO_BUILD_FLAGS")) if "BUILD_FLAGS" in env: env.MergeFlags(env['BUILD_FLAGS']) From 8f65492d96be45ca97f6dfca3310853ddec7d90f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 20:23:13 +0300 Subject: [PATCH 09/36] Extend ASM list of source files --- platformio/builder/tools/platformio.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 252f8aa6..6011a711 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -101,8 +101,8 @@ def ProcessFlags(env): def GlobCXXFiles(env, path): files = [] - for suff in ["*.c", "*.cpp", "*.S"]: - _list = env.Glob(join(path, suff)) + for suff in ["c", "cpp", "S", "spp", "SPP", "sx", "s", "asm", "ASM"]: + _list = env.Glob(join(path, "*.%s" % suff)) if _list: files += _list return files From 8739efaee4067f46dd5e62e9ecd1fa8f6f5a3813 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 May 2015 01:02:12 +0300 Subject: [PATCH 10/36] Simplify Travis example --- docs/ci/travis.rst | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/docs/ci/travis.rst b/docs/ci/travis.rst index 5b74b089..8eeff63d 100644 --- a/docs/ci/travis.rst +++ b/docs/ci/travis.rst @@ -63,20 +63,8 @@ Examples env: - PLATFORMIO_CI_SRC=examples/acm/acm_terminal - - PLATFORMIO_CI_SRC=examples/adk/term_time - - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiUProController - - PLATFORMIO_CI_SRC=examples/board_qc - - PLATFORMIO_CI_SRC=examples/cdc_XR21B1411/XR_terminal + - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiIRCamera PLATFORMIO_BUILD_FLAGS="-DWIICAMERA" - PLATFORMIO_CI_SRC=examples/ftdi/USBFTDILoopback - - PLATFORMIO_CI_SRC=examples/HID/le3dp - - PLATFORMIO_CI_SRC=examples/HID/USBHIDJoystick - - PLATFORMIO_CI_SRC=examples/hub_demo - - PLATFORMIO_CI_SRC=examples/max_LCD - - PLATFORMIO_CI_SRC=examples/pl2303/pl2303_xbee_terminal - - PLATFORMIO_CI_SRC=examples/PS3USB - - PLATFORMIO_CI_SRC=examples/PS4USB - - PLATFORMIO_CI_SRC=examples/PSBuzz - - PLATFORMIO_CI_SRC=examples/USB_desc - PLATFORMIO_CI_SRC=examples/Xbox/XBOXUSB # - ... @@ -89,7 +77,6 @@ Examples - platformio lib install 416 417 script: - - if [[ $PLATFORMIO_CI_SRC == *"WiiIRCamera"* ]]; then sed -i -- 's/#define ENABLE_WII_IR_CAMERA 0/#define ENABLE_WII_IR_CAMERA 1/g' ./settings.h; fi - platformio ci --board=uno --board=teensy31 --board=due --lib="." * Configuration file: https://github.com/felis/USB_Host_Shield_2.0/blob/master/.travis.yml From 77f2b17afd583b653352c292bf218d3ab5558a93 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 May 2015 18:48:45 +0300 Subject: [PATCH 11/36] Update package for Arduino framework to 1.6.4 // Resolve #212 --- HISTORY.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index c1b41581..42985cbd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,8 @@ Release History `PLATFORMIO_BUILD_FLAGS `_ * Pass to API requests information about Continuous Integration system. This information will be used by PlatformIO-API. +* Updated `Arduino Framework `__ to + 1.6.4 version (`issue #212 `_) * Fixed bug with converting ``*.ino`` to ``*.cpp`` 2.0.0 (2015-05-22) From 1948a730d9bc2d7be9d4cb7ec5009c1d5d6109a6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 09:50:37 +0300 Subject: [PATCH 12/36] Pass environment variables to subprocess --- platformio/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/util.py b/platformio/util.py index 6477df7e..e07538ba 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -189,7 +189,8 @@ def exec_command(*args, **kwargs): default = dict( stdout=subprocess.PIPE, stderr=subprocess.PIPE, - shell=system() == "Windows" + shell=system() == "Windows", + env=os.environ ) default.update(kwargs) kwargs = default From 5d9f81533dbdd4ff01455f40991dc4d456211759 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 10:11:28 +0300 Subject: [PATCH 13/36] Use os.environ to detect CI system --- platformio/util.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index e07538ba..d999380e 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -176,7 +176,7 @@ def change_filemtime(path, time): def is_ci(): - return os.getenv("CI", "").lower() == "true" + return os.environ.get("CI", "").lower() == "true" def exec_command(*args, **kwargs): @@ -189,8 +189,7 @@ def exec_command(*args, **kwargs): default = dict( stdout=subprocess.PIPE, stderr=subprocess.PIPE, - shell=system() == "Windows", - env=os.environ + shell=system() == "Windows" ) default.update(kwargs) kwargs = default From 65ba676f01c6feebf7d343843aa5bff15d6144ac Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 12:00:53 +0300 Subject: [PATCH 14/36] Correct path to import project in VisualStudio --- docs/ide/visualstudio.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ide/visualstudio.rst b/docs/ide/visualstudio.rst index f5275532..09c1929c 100644 --- a/docs/ide/visualstudio.rst +++ b/docs/ide/visualstudio.rst @@ -28,8 +28,8 @@ Since PlatformIO 2.0 you can generate Eclipse compatible project using platformio init --ide visualstudio -Then import this project via ``File > Import ...`` and specify root directory -where is located :ref:`projectconf`. +Then import this project via ``File->Open->Project/Solution`` and specify root +directory where is located :ref:`projectconf`. Manual Integration ^^^^^^^^^^^^^^^^^^ From 97de38d6a622e6f840ebe049fb9c36a808696181 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 25 May 2015 12:45:36 +0300 Subject: [PATCH 15/36] Add c++ support for ststm32 platform // Resolve #211 --- platformio/builder/scripts/ststm32.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platformio/builder/scripts/ststm32.py b/platformio/builder/scripts/ststm32.py index 0855457d..c1622028 100644 --- a/platformio/builder/scripts/ststm32.py +++ b/platformio/builder/scripts/ststm32.py @@ -53,6 +53,8 @@ env.Append( "${BOARD_OPTIONS['build']['variant'].upper()}" ], + LIBS=["stdc++", "nosys"], + LINKFLAGS=[ "-nostartfiles", "-nostdlib" From 146d430695c85823f11233ee7417e078caaf1f8c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 13:17:50 +0300 Subject: [PATCH 16/36] Revert CI detecting --- platformio/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/util.py b/platformio/util.py index d999380e..6477df7e 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -176,7 +176,7 @@ def change_filemtime(path, time): def is_ci(): - return os.environ.get("CI", "").lower() == "true" + return os.getenv("CI", "").lower() == "true" def exec_command(*args, **kwargs): From a1bb98fd5c4b898b6f6f426a1b9f43195e00abbd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 13:18:52 +0300 Subject: [PATCH 17/36] Reversed order for CPPATH --- platformio/builder/tools/platformio.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 6011a711..e01804b1 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -288,17 +288,15 @@ def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 # end internal prototypes deplibs = _get_dep_libs(src_dir) - env.Prepend( - CPPPATH=[join("$BUILD_DIR", l) for (l, _) in deplibs] - ) - - # add automatically "utility" dir from the lib (Arduino issue) - env.Prepend( - CPPPATH=[ - join("$BUILD_DIR", l, "utility") for (l, ld) in deplibs - if isdir(join(ld, "utility")) - ] - ) + for l, ld in deplibs: + env.Prepend( + CPPPATH=[join("$BUILD_DIR", l)] + ) + # add automatically "utility" dir from the lib (Arduino issue) + if isdir(join(ld, "utility")): + env.Prepend( + CPPPATH=[join("$BUILD_DIR", l, "utility")] + ) libs = [] for (libname, inc_dir) in deplibs: From 92313c0686f8698977a9d003d3694e90be6295d3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 13:35:26 +0300 Subject: [PATCH 18/36] Reversed order for CPPATH via Append --- platformio/builder/tools/platformio.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index e01804b1..e9bbb7c6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -289,12 +289,12 @@ def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 deplibs = _get_dep_libs(src_dir) for l, ld in deplibs: - env.Prepend( + env.Append( CPPPATH=[join("$BUILD_DIR", l)] ) # add automatically "utility" dir from the lib (Arduino issue) if isdir(join(ld, "utility")): - env.Prepend( + env.Append( CPPPATH=[join("$BUILD_DIR", l, "utility")] ) From 9ba3136a24a517347255cf226de79494af486c7a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 19:35:40 +0300 Subject: [PATCH 19/36] Fix library order --- platformio/builder/tools/platformio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index e9bbb7c6..522eb160 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -74,7 +74,7 @@ def BuildFirmware(env): return firmenv.Program( join("$BUILD_DIR", "firmware"), [firmenv.GlobCXXFiles(vdir) for vdir in vdirs], - LIBS=list(env.get("LIBS", []) + deplibs)[::-1], + LIBS=env.get("LIBS", []) + deplibs, LIBPATH=env.get("LIBPATH", []) + ["$BUILD_DIR"], PROGSUFFIX=".elf" ) From bcf0cc26aa5ea94bb981f79a054d0454ad292db9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 21:45:50 +0300 Subject: [PATCH 20/36] Add --force for run command --- docs/ide/sublimetext.rst | 4 ++-- docs/ide/vim.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/ide/sublimetext.rst b/docs/ide/sublimetext.rst index af39f328..df4a44a4 100644 --- a/docs/ide/sublimetext.rst +++ b/docs/ide/sublimetext.rst @@ -50,11 +50,11 @@ described below: [ { "name": "Clean", - "cmd": ["platformio", "run", "-t", "clean"] + "cmd": ["platformio", "--force", "run", "--target", "clean"] }, { "name": "Upload", - "cmd": ["platformio", "run", "-t", "upload"] + "cmd": ["platformio", "--force", "run", "--target", "upload"] } ] } diff --git a/docs/ide/vim.rst b/docs/ide/vim.rst index ae1116f6..a9ccc115 100644 --- a/docs/ide/vim.rst +++ b/docs/ide/vim.rst @@ -30,10 +30,10 @@ Put to the project directory ``Makefile`` wrapper with contents: #PATH := /usr/local/bin:$(PATH) all: - platformio run -t upload + platformio --force run --target upload clean: - platformio run -t clean + platformio --force run --target clean Now, in VIM ``cd /path/to/this/project`` and press ``Ctrl+B`` or ``Cmd+B`` From 76497694371f175de348956a1c1e936223f28ee4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 22:50:46 +0300 Subject: [PATCH 21/36] Disable packages/libs updating while "upgrade" operation // Resolve #214 --- platformio/__init__.py | 2 +- platformio/maintenance.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index a701575c..b6aa82ce 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 0, "1.dev0") +VERSION = (2, 0, "1.dev1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 89d7fbd3..350f4bf0 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -3,6 +3,7 @@ import re import struct +import sys from os import remove from os.path import isdir, isfile, join from shutil import rmtree @@ -25,6 +26,11 @@ from platformio.util import get_home_dir def on_platformio_start(ctx, force): app.set_session_var("force_option", force) telemetry.on_command(ctx) + + # skip any check operations when upgrade process + if len(sys.argv) > 1 and sys.argv[1] == "upgrade": + return + after_upgrade(ctx) try: From be700472331354c454fa2792eec30c1b5ade9939 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 23:26:35 +0300 Subject: [PATCH 22/36] Improve running project from other directory (not CWD) --- platformio/commands/run.py | 8 ++------ platformio/ide/projectgenerator.py | 18 +++++++++--------- platformio/util.py | 12 ++++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index b61544ba..5b27d1c6 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -2,7 +2,7 @@ # See LICENSE for details. from datetime import datetime -from os import chdir, getcwd +from os import getcwd from os.path import getmtime, isdir, join from shutil import rmtree from time import time @@ -28,9 +28,7 @@ from platformio.platforms.base import PlatformFactory @click.pass_context def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 project_dir, verbose): - initial_cwd = getcwd() - chdir(project_dir) - try: + with util.cd(project_dir): config = util.get_project_config() if not config.sections(): @@ -74,8 +72,6 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 if not all(results): raise exception.ReturnErrorCode() - finally: - chdir(initial_cwd) class EnvironmentProcessor(object): diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index fda18e9e..ef3d2c51 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -26,16 +26,16 @@ class ProjectGenerator(object): return [d for d in listdir(tpls_dir) if isdir(join(tpls_dir, d))] - @staticmethod - def get_project_env(): + def get_project_env(self): data = {} - config = util.get_project_config() - for section in config.sections(): - if not section.startswith("env:"): - continue - data['env_name'] = section[4:] - for k, v in config.items(section): - data[k] = v + with util.cd(self.project_dir): + config = util.get_project_config() + for section in config.sections(): + if not section.startswith("env:"): + continue + data['env_name'] = section[4:] + for k, v in config.items(section): + data[k] = v return data @util.memoized diff --git a/platformio/util.py b/platformio/util.py index 6477df7e..a5d36c66 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -55,6 +55,18 @@ class AsyncPipe(Thread): self.join() +class cd: + def __init__(self, new_path): + self.new_path = new_path + self.prev_path = os.getcwd() + + def __enter__(self): + os.chdir(self.new_path) + + def __exit__(self, etype, value, traceback): + os.chdir(self.prev_path) + + class memoized(object): ''' Decorator. Caches a function's return value each time it is called. From 7d949ecb160f63987c387c913e50248f93b6aaba Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 23:29:10 +0300 Subject: [PATCH 23/36] Fix old-style class defination --- platformio/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/util.py b/platformio/util.py index a5d36c66..b1e512bc 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -55,7 +55,7 @@ class AsyncPipe(Thread): self.join() -class cd: +class cd(object): def __init__(self, new_path): self.new_path = new_path self.prev_path = os.getcwd() From 58f0f8fab4854885a83f25edab7b10724e7ab011 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 25 May 2015 23:33:38 +0300 Subject: [PATCH 24/36] Use "include" directories from toolchain when exporting project for IDE // Resolve #210 --- HISTORY.rst | 2 ++ platformio/builder/tools/platformio.py | 5 +++++ platformio/ide/projectgenerator.py | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 42985cbd..c5e67a72 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,8 @@ Release History `PLATFORMIO_BUILD_FLAGS `_ * Pass to API requests information about Continuous Integration system. This information will be used by PlatformIO-API. +* Use ``include`` directories from toolchain when exporting project for IDE + (`issue #210 `_) * Updated `Arduino Framework `__ to 1.6.4 version (`issue #212 `_) * Fixed bug with converting ``*.ino`` to ``*.cpp`` diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 522eb160..e2ca23b2 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -4,6 +4,7 @@ import atexit import json import re +from glob import glob from os import getenv, listdir, remove, sep, walk from os.path import basename, dirname, isdir, isfile, join, normpath @@ -66,6 +67,10 @@ def BuildFirmware(env): _data = {"defines": [], "includes": []} for item in env.get("VARIANT_DIRS", []): _data['includes'].append(env.subst(item[1])) + for item in glob(env.subst( + join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN", + "*", "include"))): + _data['includes'].append(item) for item in env.get("CPPDEFINES", []): _data['defines'].append(env.subst(item)) print json.dumps(_data) diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index ef3d2c51..88d29652 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -44,7 +44,8 @@ class ProjectGenerator(object): if "env_name" not in envdata: return None result = util.exec_command( - ["platformio", "run", "-t", "idedata", "-e", envdata['env_name']] + ["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 From 4d36db1319f444ed47a803a7c5654d8eb5e22781 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 13:07:36 +0300 Subject: [PATCH 25/36] Improve handling of sys.args --- platformio/maintenance.py | 4 +++- platformio/telemetry.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 350f4bf0..e225aa4f 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -28,7 +28,9 @@ def on_platformio_start(ctx, force): telemetry.on_command(ctx) # skip any check operations when upgrade process - if len(sys.argv) > 1 and sys.argv[1] == "upgrade": + args = [str(s).lower() for s in sys.argv[1:] + if not str(s).startswith("-")] + if len(args) > 1 and args[1] == "upgrade": return after_upgrade(ctx) diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 3662b7f4..5017ace8 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -4,9 +4,9 @@ import atexit import platform import re +import sys import threading import uuid -from sys import argv as sys_argv from time import time import click @@ -91,7 +91,8 @@ class MeasurementProtocol(TelemetryBase): self['cd4'] = 1 if app.get_setting("enable_prompts") else 0 def _prefill_screen_name(self): - args = [str(s).lower() for s in sys_argv[1:]] + args = [str(s).lower() for s in sys.argv[1:] + if not str(s).startswith("-")] if not args: return From 1f373b1e4777091b40e9c2cff16e574cdfbe41a0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 13:59:33 +0300 Subject: [PATCH 26/36] Handle AVR Symbols when initialising project for IDE // Resolve #216 --- HISTORY.rst | 4 ++- platformio/__init__.py | 2 +- platformio/builder/tools/platformio.py | 44 ++++++++++++++++++++------ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c5e67a72..68e2b815 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,10 +8,12 @@ Release History `PLATFORMIO_BUILD_FLAGS `_ * Pass to API requests information about Continuous Integration system. This information will be used by PlatformIO-API. -* Use ``include`` directories from toolchain when exporting project for IDE +* Use ``include`` directories from toolchain when initialising project for IDE (`issue #210 `_) * Updated `Arduino Framework `__ to 1.6.4 version (`issue #212 `_) +* Handle Atmel AVR Symbols when initialising project for IDE + (`issue #216 `_) * Fixed bug with converting ``*.ino`` to ``*.cpp`` 2.0.0 (2015-05-22) diff --git a/platformio/__init__.py b/platformio/__init__.py index b6aa82ce..c5c298f0 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 0, "1.dev1") +VERSION = (2, 0, "1a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index e2ca23b2..7abd8b75 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -64,16 +64,7 @@ def BuildFirmware(env): Exit() if "idedata" in COMMAND_LINE_TARGETS: - _data = {"defines": [], "includes": []} - for item in env.get("VARIANT_DIRS", []): - _data['includes'].append(env.subst(item[1])) - for item in glob(env.subst( - join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN", - "*", "include"))): - _data['includes'].append(item) - for item in env.get("CPPDEFINES", []): - _data['defines'].append(env.subst(item)) - print json.dumps(_data) + print json.dumps(env.DumpIDEData()) Exit() return firmenv.Program( @@ -421,6 +412,38 @@ def ConvertInoToCpp(env): atexit.register(delete_tmpcpp_file, tmpcpp_file) +def DumpIDEData(env): + data = { + "defines": [], + "includes": [] + } + + # includes from framework and libs + for item in env.get("VARIANT_DIRS", []): + data['includes'].append(env.subst(item[1])) + + # includes from toolchain + for item in glob(env.subst( + join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN", + "*", "include"))): + data['includes'].append(item) + + # global symbols + for item in env.get("CPPDEFINES", []): + data['defines'].append(env.subst(item)) + + # special symbol for Atmel AVR MCU + board = env.get("BOARD_OPTIONS", {}) + if board and board['platform'] == "atmelavr": + data['defines'].append( + "__AVR_%s__" % board['build']['mcu'].upper() + .replace("ATMEGA", "ATmega") + .replace("ATTINY", "ATtiny") + ) + + return data + + def exists(_): return True @@ -435,4 +458,5 @@ def generate(env): env.AddMethod(BuildLibrary) env.AddMethod(BuildDependentLibraries) env.AddMethod(ConvertInoToCpp) + env.AddMethod(DumpIDEData) return env From 2e214f16e73ec9775881dddf4003b73c60cd3611 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 15:04:47 +0300 Subject: [PATCH 27/36] Return args + options for telemetry --- platformio/telemetry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 5017ace8..0dd676e1 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -102,7 +102,7 @@ class MeasurementProtocol(TelemetryBase): cmd_path = args[:1] self['screen_name'] = " ".join([p.title() for p in cmd_path]) - self['cd3'] = " ".join(args) + self['cd3'] = " ".join([str(s).lower() for s in sys.argv[1:]]) def send(self, hittype): if not app.get_setting("enable_telemetry"): From 6534fdaf04d6ba1959f9598afe6407b8aae22625 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 16:16:14 +0300 Subject: [PATCH 28/36] Pass all environment variables which shall be copied from the tox invocation environment --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index cafecaca..84770c5c 100644 --- a/tox.ini +++ b/tox.ini @@ -44,6 +44,7 @@ basepython = py26: python2.6 py27: python2.7 usedevelop = True +passenv = * deps = pytest setenv = PLATFORMIO_SETTING_ENABLE_PROMPTS = False From 78db2cda275a63052c6b32bd7dd5d84a20021781 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 16:41:45 +0300 Subject: [PATCH 29/36] Use forced run command and "--project-dir" option --- tests/test_examples.py | 3 +-- tox.ini | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 9ababba2..ab02d640 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -30,8 +30,7 @@ def test_run(platformio_setup, pioproject_dir): rmtree(join(pioproject_dir, ".pioenvs")) result = exec_command( - ["platformio", "run"], - cwd=pioproject_dir + ["platformio", "--force", "run", "--project-dir", pioproject_dir] ) if result['returncode'] != 0: pytest.fail(result) diff --git a/tox.ini b/tox.ini index 84770c5c..49706329 100644 --- a/tox.ini +++ b/tox.ini @@ -46,8 +46,6 @@ basepython = usedevelop = True passenv = * deps = pytest -setenv = - PLATFORMIO_SETTING_ENABLE_PROMPTS = False commands = {envpython} --version pip install --egg http://sourceforge.net/projects/scons/files/latest/download From 8fb0e1b75f20ebbe01f8b84966882237d340c012 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Tue, 26 May 2015 20:06:37 +0300 Subject: [PATCH 30/36] Add WildFire boards from Wicked Device. --- platformio/boards/misc.json | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json index b9f7dba6..c7fcbb03 100644 --- a/platformio/boards/misc.json +++ b/platformio/boards/misc.json @@ -521,5 +521,49 @@ }, "url": "http://quirkbot.com", "vendor": "Quirkbot" + }, + + "wildfirev2": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA", + "f_cpu": "16000000L", + "mcu": "atmega1284p", + "variant": "wildfirev2" + }, + "frameworks": ["arduino"], + "name": "Wicked Device WildFire V2", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 122878, + "protocol": "wiring", + "require_upload_port" : true, + "speed": 38400 + }, + "url": "http://shop.wickeddevice.com/resources/wildfire/", + "vendor": "Wicked Device" + }, + + "wildfirev3": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA", + "f_cpu": "16000000L", + "mcu": "atmega1284p", + "variant": "wildfirev3" + }, + "frameworks": ["arduino"], + "name": "Wicked Device WildFire V3", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 130048, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200 + }, + "url": "http://shop.wickeddevice.com/resources/wildfire/", + "vendor": "Wicked Device" } } From ac7479415b7b8f2814ecdfc180daf2abac7ee258 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 22:52:09 +0300 Subject: [PATCH 31/36] Add support for new WildFire boards from Wicked Device to atmelavr platform --- HISTORY.rst | 4 ++++ docs/frameworks/arduino.rst | 8 ++++---- docs/platforms/atmelavr.rst | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 68e2b815..4da08f4c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,10 @@ Release History information will be used by PlatformIO-API. * Use ``include`` directories from toolchain when initialising project for IDE (`issue #210 `_) +* Added support for new WildFire boards from + `Wicked Device `_ to + `atmelavr `__ + platform * Updated `Arduino Framework `__ to 1.6.4 version (`issue #212 `_) * Handle Atmel AVR Symbols when initialising project for IDE diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index 5804f7f7..b0b06738 100644 --- a/docs/frameworks/arduino.rst +++ b/docs/frameworks/arduino.rst @@ -923,8 +923,8 @@ TinyCircuits - 32 Kb - 2 Kb -WickedDevice -~~~~~~~~~~~~ +Wicked Device +~~~~~~~~~~~~~ .. list-table:: :header-rows: 1 @@ -937,14 +937,14 @@ WickedDevice - RAM * - ``wildfirev2`` - - `WickedDevice WildFire v2 [stk500] `_ + - `Wicked Device WildFire V2 `_ - ATMEGA1284P - 16 MHz - 128 Kb - 16 Kb * - ``wildfirev3`` - - `WickedDevice WildFire v3 [optiboot] `_ + - `Wicked Device WildFire V3 `_ - ATMEGA1284P - 16 MHz - 128 Kb diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index 5cc1c84e..048b7bef 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -816,8 +816,8 @@ TinyCircuits - 32 Kb - 2 Kb -WickedDevice -~~~~~~~~~~~~ +Wicked Device +~~~~~~~~~~~~~ .. list-table:: :header-rows: 1 @@ -830,14 +830,14 @@ WickedDevice - RAM * - ``wildfirev2`` - - `WickedDevice WildFire v2 [stk500] `_ + - `Wicked Device WildFire V2 `_ - ATMEGA1284P - 16 MHz - 128 Kb - 16 Kb * - ``wildfirev3`` - - `WickedDevice WildFire v3 [optiboot] `_ + - `Wicked Device WildFire V3 `_ - ATMEGA1284P - 16 MHz - 128 Kb From 65ad07af6b147e78bba491efe5273891b3388446 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 22:55:59 +0300 Subject: [PATCH 32/36] Fix failing with ``platformio init --ide eclipse`` without boards // Resolve #217 --- docs/ide/eclipse.rst | 7 ++++--- docs/ide/qtcreator.rst | 7 ++++--- docs/ide/sublimetext.rst | 9 +++++---- docs/ide/visualstudio.rst | 7 ++++--- platformio/ide/projectgenerator.py | 2 +- platformio/ide/tpls/qtcreator/platformio.pro.user.tpl | 4 ++-- .../ide/tpls/sublimetext/platformio.sublime-project.tpl | 1 + platformio/ide/tpls/visualstudio/platformio.vcxproj.tpl | 2 +- 8 files changed, 22 insertions(+), 17 deletions(-) diff --git a/docs/ide/eclipse.rst b/docs/ide/eclipse.rst index 2549c24d..ee89db47 100644 --- a/docs/ide/eclipse.rst +++ b/docs/ide/eclipse.rst @@ -29,12 +29,13 @@ Integration Project Generator ^^^^^^^^^^^^^^^^^ -Since PlatformIO 2.0 you can generate Eclipse compatible project using -:option:`platformio init --ide` command: +SSince PlatformIO 2.0 you can generate Eclipse compatible project using +:option:`platformio init --ide` command. Please choose board type using +:ref:`cmd_boards` command and run: .. code-block:: shell - platformio init --ide eclipse + platformio init --ide eclipse --board %TYPE% Then import this project via ``File > Import... > General > Existing Projects into Workspace > Next`` and specify root directory where is located diff --git a/docs/ide/qtcreator.rst b/docs/ide/qtcreator.rst index 31bc7cde..d5d97994 100644 --- a/docs/ide/qtcreator.rst +++ b/docs/ide/qtcreator.rst @@ -21,12 +21,13 @@ Integration Project Generator ^^^^^^^^^^^^^^^^^ -Since PlatformIO 2.0 you can generate Eclipse compatible project using -:option:`platformio init --ide` command: +Since PlatformIO 2.0 you can generate Qt Creator compatible project using +:option:`platformio init --ide` command. Please choose board type using +:ref:`cmd_boards` command and run: .. code-block:: shell - platformio init --ide qtcreator + platformio init --ide qtcreator --board %TYPE% Then import this project via ``File > New File or Project > Import Project`` and specify root directory where is located :ref:`projectconf`. diff --git a/docs/ide/sublimetext.rst b/docs/ide/sublimetext.rst index df4a44a4..9e6ab34e 100644 --- a/docs/ide/sublimetext.rst +++ b/docs/ide/sublimetext.rst @@ -21,12 +21,13 @@ Integration Project Generator ^^^^^^^^^^^^^^^^^ -Since PlatformIO 2.0 you can generate Eclipse compatible project using -:option:`platformio init --ide` command: +Since PlatformIO 2.0 you can generate Sublime Text compatible project using +:option:`platformio init --ide` command. Please choose board type using +:ref:`cmd_boards` command and run: .. code-block:: shell - platformio init --ide sublimetext + platformio init --ide sublimetext --board %TYPE% Then import this project via ``Project > Open Project...`` and specify root directory where is located :ref:`projectconf`. @@ -44,7 +45,7 @@ described below: .. code-block:: bash { - "cmd": ["platformio", "run"], + "cmd": ["platformio", "--force", "run"], "working_dir": "${project_path:${folder}}", "variants": [ diff --git a/docs/ide/visualstudio.rst b/docs/ide/visualstudio.rst index 09c1929c..4afb100d 100644 --- a/docs/ide/visualstudio.rst +++ b/docs/ide/visualstudio.rst @@ -21,12 +21,13 @@ Integration Project Generator ^^^^^^^^^^^^^^^^^ -Since PlatformIO 2.0 you can generate Eclipse compatible project using -:option:`platformio init --ide` command: +Since PlatformIO 2.0 you can generate Visual Studio compatible project using +:option:`platformio init --ide` command. Please choose board type using +:ref:`cmd_boards` command and run: .. code-block:: shell - platformio init --ide visualstudio + platformio init --ide visualstudio --board %TYPE% Then import this project via ``File->Open->Project/Solution`` and specify root directory where is located :ref:`projectconf`. diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 88d29652..e98282cb 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -27,7 +27,7 @@ class ProjectGenerator(object): if isdir(join(tpls_dir, d))] def get_project_env(self): - data = {} + data = {"env_name": "PlatformIO"} with util.cd(self.project_dir): config = util.get_project_config() for section in config.sections(): diff --git a/platformio/ide/tpls/qtcreator/platformio.pro.user.tpl b/platformio/ide/tpls/qtcreator/platformio.pro.user.tpl index 72ecb9ad..c6035cca 100644 --- a/platformio/ide/tpls/qtcreator/platformio.pro.user.tpl +++ b/platformio/ide/tpls/qtcreator/platformio.pro.user.tpl @@ -84,7 +84,7 @@ true - --force run -t clean + --force run --target clean platformio %{buildDir} Custom Process Step @@ -125,7 +125,7 @@ true - --force run -t clean + --force run --target clean platformio %{buildDir} Custom Process Step diff --git a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl index 4c4855a2..bd785662 100644 --- a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl +++ b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl @@ -5,6 +5,7 @@ "cmd": [ "platformio", + "--force", "run" ], "name": "PlatformIO", diff --git a/platformio/ide/tpls/visualstudio/platformio.vcxproj.tpl b/platformio/ide/tpls/visualstudio/platformio.vcxproj.tpl index 1a069d7e..2b3aa1f9 100644 --- a/platformio/ide/tpls/visualstudio/platformio.vcxproj.tpl +++ b/platformio/ide/tpls/visualstudio/platformio.vcxproj.tpl @@ -43,7 +43,7 @@ platformio run - platformio run -t clean + platformio run --target clean {";".join(defines)}} {{";".join(includes)}} From 25fde8db86c37d15d3865e215c0c770688429e52 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 23:00:40 +0300 Subject: [PATCH 33/36] Cleanup boards --- HISTORY.rst | 4 +++- platformio/boards/misc.json | 44 ------------------------------------- 2 files changed, 3 insertions(+), 45 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4da08f4c..3b63d7a5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,8 @@ Release History * Handle Atmel AVR Symbols when initialising project for IDE (`issue #216 `_) * Fixed bug with converting ``*.ino`` to ``*.cpp`` +* Fixed failing with ``platformio init --ide eclipse`` without boards + (`issue #217 `_) 2.0.0 (2015-05-22) ------------------ @@ -102,7 +104,7 @@ Release History `teensy `__ platform * Added support for new Arduino based boards by *SparkFun, BQ, LightUp, - LowPowerLab, Quirkbot, RedBearLab, TinyCircuits, WickedDevice* to + LowPowerLab, Quirkbot, RedBearLab, TinyCircuits* to `atmelavr `__ platform * Upgraded `Arduino Framework `__ to diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json index c7fcbb03..fbcbf031 100644 --- a/platformio/boards/misc.json +++ b/platformio/boards/misc.json @@ -250,50 +250,6 @@ "vendor": "TinyCircuits" }, - "wildfirev3": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR", - "f_cpu": "16000000L", - "mcu": "atmega1284p", - "variant": "wildfirev3" - }, - "frameworks": ["arduino"], - "name": "WickedDevice WildFire v3 [optiboot]", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 130048, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://shop.wickeddevice.com/resources/wildfire/", - "vendor": "WickedDevice" - }, - - "wildfirev2": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR", - "f_cpu": "16000000L", - "mcu": "atmega1284p", - "variant": "wildfirev2" - }, - "frameworks": ["arduino"], - "name": "WickedDevice WildFire v2 [stk500]", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 122878, - "protocol": "wiring", - "require_upload_port" : true, - "speed": 38400 - }, - "url": "http://shop.wickeddevice.com/resources/wildfire/#arduinoidesetup", - "vendor": "WickedDevice" - }, - "blend": { "build": { "core": "arduino", From 392758a84256683d9ac6506841218393d4041b32 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 26 May 2015 23:45:29 +0300 Subject: [PATCH 34/36] Allow to control cyclic behaviour of Library Dependency Finder --- HISTORY.rst | 3 ++- docs/envvars.rst | 7 +++++++ docs/projectconf.rst | 28 ++++++++++++++++++++++++-- platformio/builder/main.py | 1 + platformio/builder/tools/platformio.py | 5 ++++- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3b63d7a5..8d0e1d88 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,8 +4,9 @@ Release History 2.0.1 (2015-??-??) ------------------ -* Handle new environment variable +* Handle new environment variables `PLATFORMIO_BUILD_FLAGS `_ + and `PLATFORMIO_LDF_CYCLIC `_ * Pass to API requests information about Continuous Integration system. This information will be used by PlatformIO-API. * Use ``include`` directories from toolchain when initialising project for IDE diff --git a/docs/envvars.rst b/docs/envvars.rst index 1b6aa2e4..25414e27 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -77,6 +77,13 @@ PLATFORMIO_SRCBUILD_FLAGS Allows to set :ref:`projectconf` option :ref:`projectconf_srcbuild_flags`. +.. _envvar_PLATFORMIO_LDF_CYCLIC: + +PLATFORMIO_LDF_CYCLIC +~~~~~~~~~~~~~~~~~~~~~ + +Allows to set :ref:`projectconf` option :ref:`projectconf_ldf_cyclic`. + Settings -------- diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 23f93c8b..8aba9efe 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -331,7 +331,7 @@ Example: ``use_libs`` ^^^^^^^^^^^^ -Specify libraries which should be used by ``Library Dependency Finder`` with +Specify libraries which should be used by ``Library Dependency Finder (LDF)`` with the highest priority. Example: @@ -344,7 +344,7 @@ Example: ``ignore_libs`` ^^^^^^^^^^^^^^^ -Specify libraries which should be ignored by ``Library Dependency Finder`` +Specify libraries which should be ignored by ``Library Dependency Finder (LDF)`` Example: @@ -353,6 +353,30 @@ Example: [env:ignore_some_libs] ignore_libs = SPI,EngduinoV3_ID123 +.. _projectconf_ldf_cyclic: + +``ldf_cyclic`` +^^^^^^^^^^^^^^ + +Control cyclic (recursive) behaviour for ``Library Dependency Finder (LDF)``. +By default, this option is turned OFF (``ldf_cyclic=False``) and means, that +``LDF`` will find only libraries which are included in source files from the +project :ref:`projectconf_pio_src_dir`. + +If you want to enable cyclic (recursive, nested) search, please set this option +to ``True``. Founded library will be treated like a new source files and +``LDF`` will search dependencies for it. + +This option can be set by global environment variable +:ref:`envvar_PLATFORMIO_LDF_CYCLIC`. + +Example: + +.. code-block:: ini + + [env:libs_with_enabled_ldf_cyclic] + ldf_cyclic = True + .. _projectconf_examples: diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 45ec63d6..4b07953e 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -38,6 +38,7 @@ commonvars.AddVariables( ("SRCBUILD_FLAGS",), ("IGNORE_LIBS",), ("USE_LIBS",), + ("LDF_CYCLIC",), # board options ("BOARD",), diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 7abd8b75..7eae3b34 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -278,7 +278,10 @@ def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 len(state['ordered']) + 1, finder.getLibName(), _lib_dir)) state['libs'].add(_lib_dir) - state = _process_src_dir(state, _lib_dir) + + if getenv("PLATFORMIO_LDF_CYCLIC", + env.subst("$LDF_CYCLIC")).lower() == "true": + state = _process_src_dir(state, _lib_dir) return state # end internal prototypes From 27b7c2e201700993fafb4007bb4bd475d32d2d32 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 May 2015 16:23:39 +0300 Subject: [PATCH 35/36] Enhance docs for Library Manager --- docs/librarymanager/index.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/librarymanager/index.rst b/docs/librarymanager/index.rst index 994437fd..7f00a0bd 100644 --- a/docs/librarymanager/index.rst +++ b/docs/librarymanager/index.rst @@ -8,8 +8,10 @@ Library Manager *"The missing library manager for development platforms"* [#]_ *PlatformIO Library Manager* allows you to organize external embedded libraries. -You can search for new libraries via :ref:`Command Line interface ` -or `Web 2.0 Library Search `_. +You can search for new libraries via + +* :ref:`Command Line interface ` +* `Web 2.0 Library Search `_ You don't need to bother for finding the latest version of library. Due to :ref:`cmd_lib_update` command you will have up-to-date external libraries. From 9232c7abb1dc7cbba174c8dccfb57b9cdb23347a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 May 2015 17:01:59 +0300 Subject: [PATCH 36/36] Version bump to 2.0.1 (issues #210, #211, #212, #214, #216, #217) --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index c5c298f0..a38b7a47 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 0, "1a1") +VERSION = (2, 0, 1) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio"