Merge branch 'release/v2.5.0'

This commit is contained in:
Ivan Kravets
2015-12-08 19:28:22 +02:00
33 changed files with 362 additions and 170 deletions

View File

@ -4,6 +4,19 @@ Release History
PlatformIO 2.0 PlatformIO 2.0
-------------- --------------
2.5.0 (2015-12-08)
~~~~~~~~~~~~~~~~~~
* Improved code builder for parallel builds (up to 4 times faster than before)
* Generate `.travis.yml <http://docs.platformio.org/en/latest/ci/travis.html>`__
CI and `.gitignore` files for embedded projects by default
(`issue #354 <https://github.com/platformio/platformio/issues/354>`_)
* Removed prompt with "auto-uploading" from `platformio init <http://docs.platformio.org/en/latest/userguide/cmd_init.html>`__
command and added ``--enable-auto-uploading`` option
(`issue #352 <https://github.com/platformio/platformio/issues/352>`_)
* Fixed incorrect behaviour of `platformio serialports monitor <http://docs.platformio.org/en/latest/userguide/cmd_serialports.html#platformio-serialports-monitor>`__
in pair with PySerial 3.0
2.4.1 (2015-12-01) 2.4.1 (2015-12-01)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
@ -219,7 +232,7 @@ PlatformIO 2.0
* Automatically detect upload port using VID:PID board settings * Automatically detect upload port using VID:PID board settings
(`issue #231 <https://github.com/platformio/platformio/issues/231>`_) (`issue #231 <https://github.com/platformio/platformio/issues/231>`_)
* Improved detection of build changes * Improved detection of build changes
* Avoided ``LibInstallDependencyError`` when more then 1 library is found * Avoided ``LibInstallDependencyError`` when more than 1 library is found
(`issue #229 <https://github.com/platformio/platformio/issues/229>`_) (`issue #229 <https://github.com/platformio/platformio/issues/229>`_)
2.1.0 (2015-06-03) 2.1.0 (2015-06-03)

BIN
docs/_static/ci-travis-logo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -23,12 +23,15 @@ Here are recent articles about PlatformIO:
2015 2015
^^^^ ^^^^
* Dec 01, 2015 - **Tateno Yuichi** - `ESP8266 を CUI で開発する (Develop a ESP8266 in CUI, Japanese) <http://jaywiggins.com/platformio/arduino/avr/es8266/2015/09/30/platformio-investigation/>`_
* Nov 29, 2015 - **Keith Hughes** - `Using PlatformIO for Embedded Projects <http://smartspacestuff.blogspot.com/2015/11/using-platformio-for-embedded-projects.html>`_ * Nov 29, 2015 - **Keith Hughes** - `Using PlatformIO for Embedded Projects <http://smartspacestuff.blogspot.com/2015/11/using-platformio-for-embedded-projects.html>`_
* Nov 22, 2015 - **Michał Seroczyński** - `Using PlatformIO to get started with Arduino in CLion IDE <http://www.ches.pl/using-platformio-get-started-arduino-clion-ide/>`_ * Nov 22, 2015 - **Michał Seroczyński** - `Using PlatformIO to get started with Arduino in CLion IDE <http://www.ches.pl/using-platformio-get-started-arduino-clion-ide/>`_
* Nov 09, 2015 - **ÁLvaro García Gómez** - `Programar con Arduino "The good way" (Programming with Arduino "The good way", Spanish) <http://congdegnu.es/2015/11/09/programar-con-arduino-the-good-way/>`_ * Nov 09, 2015 - **ÁLvaro García Gómez** - `Programar con Arduino "The good way" (Programming with Arduino "The good way", Spanish) <http://congdegnu.es/2015/11/09/programar-con-arduino-the-good-way/>`_
* Nov 06, 2015 - **nocd5** - `PlatformIOでmbedをオフラインビルドしSTM32 Nucleoボードでmrubyを使う (Use mruby in the offline build for STM32 Nucleo board with mbed and PlatformIO, Japanese) <http://qiita.com/nocd5/items/d5fda776240f7e7c17eb>`_ * Nov 06, 2015 - **nocd5** - `PlatformIOでmbedをオフラインビルドしSTM32 Nucleoボードでmrubyを使う (Use mruby in the offline build for STM32 Nucleo board with mbed and PlatformIO, Japanese) <http://qiita.com/nocd5/items/d5fda776240f7e7c17eb>`_
* Oct 21, 2015 - **Vittorio Zaccaria** - `Using a cheap STM32 Nucleo to teach remote sensor monitoring <http://www.vittoriozaccaria.net/blog/2015/10/21/using-a-cheap-stm32-nucleo-to-teach-remote-sensor-monitoring.html>`_
* Oct 18, 2015 - **Nico Coetzee** - `First Arduino I2C Experience with PlatformIO <https://electronicventurer.wordpress.com/2015/10/18/first-arduino-i2c-experience/>`_ * Oct 18, 2015 - **Nico Coetzee** - `First Arduino I2C Experience with PlatformIO <https://electronicventurer.wordpress.com/2015/10/18/first-arduino-i2c-experience/>`_
* Oct 01, 2015 - **Mistan** - `Compile and Upload Arduino Sketch with PlatformIO for Raspberry Pi Running Arch Linux <http://tech.memoryimprintstudio.com/code-building-for-arduino-with-platformio-for-raspberry-pi-with-arch-linux/>`_ * Oct 01, 2015 - **Mistan** - `Compile and Upload Arduino Sketch with PlatformIO for Raspberry Pi Running Arch Linux <http://tech.memoryimprintstudio.com/code-building-for-arduino-with-platformio-for-raspberry-pi-with-arch-linux/>`_
* Sep 30, 2015 - **Jay Wiggins** - `PlatformIO Investigation <http://jaywiggins.com/platformio/arduino/avr/es8266/2015/09/30/platformio-investigation/>`_
* Sep 01, 2015 - **Thomas P. Weldon, Ph.D.** - `Improvised MBED FRDM-K64F Eclipse/PlatformIO Setup and Software Installation <http://thomasweldon.com/tpw/courses/embeddsp/p00pcFrdmK64_eclipsePlatformioSetup.html>`_ * Sep 01, 2015 - **Thomas P. Weldon, Ph.D.** - `Improvised MBED FRDM-K64F Eclipse/PlatformIO Setup and Software Installation <http://thomasweldon.com/tpw/courses/embeddsp/p00pcFrdmK64_eclipsePlatformioSetup.html>`_
* Aug 08, 2015 - **Josh Glendenning** - `Armstrap Eagle and PlatformIO <http://isobit.io/2015/08/08/armstrap.html>`_ * Aug 08, 2015 - **Josh Glendenning** - `Armstrap Eagle and PlatformIO <http://isobit.io/2015/08/08/armstrap.html>`_
* Aug 01, 2015 - **Russell Davis** - `PlatformIO on the Raspberry Pi <http://www.russelldavis.org/2015/08/01/platformio-on-the-raspberry-pi/>`_ * Aug 01, 2015 - **Russell Davis** - `PlatformIO on the Raspberry Pi <http://www.russelldavis.org/2015/08/01/platformio-on-the-raspberry-pi/>`_

View File

@ -14,6 +14,13 @@
Travis CI Travis CI
========= =========
.. image:: ../_static/ci-travis-logo.png
:target: https://docs.travis-ci.com/user/integration/platformio/
**Travis CI** `officially supports <https://docs.travis-ci.com/user/integration/platformio/>`_
**PlatformIO for Embedded Builds.**
`Travis CI <http://en.wikipedia.org/wiki/Travis_CI>`_ is an open-source hosted, `Travis CI <http://en.wikipedia.org/wiki/Travis_CI>`_ is an open-source hosted,
distributed continuous integration service used to build and test projects distributed continuous integration service used to build and test projects
hosted at `GitHub <http://en.wikipedia.org/wiki/GitHub>`_. hosted at `GitHub <http://en.wikipedia.org/wiki/GitHub>`_.

View File

@ -28,12 +28,21 @@ This software can be used with:
Refer to the `Arduino Getting Started <http://arduino.cc/en/Guide/HomePage>`_ Refer to the `Arduino Getting Started <http://arduino.cc/en/Guide/HomePage>`_
page for Installation instructions. page for Installation instructions.
.. contents::
Integration Integration
----------- -----------
More detailed information is located in PlatformIO blog: More detailed information is located in PlatformIO blog:
`Integration of PlatformIO library manager to Arduino IDE <http://www.ikravets.com/computer-life/platformio/2014/10/07/integration-of-platformio-library-manager-to-arduino-and-energia-ides>`_. `Integration of PlatformIO library manager to Arduino IDE <http://www.ikravets.com/computer-life/platformio/2014/10/07/integration-of-platformio-library-manager-to-arduino-and-energia-ides>`_.
Articles / Manuals
------------------
* `Integration of PlatformIO library manager to Arduino and Energia IDEs <http://www.ikravets.com/computer-life/platformio/2014/10/07/integration-of-platformio-library-manager-to-arduino-and-energia-ides>`_
See the full list with :ref:`articles`.
Screenshot Screenshot
---------- ----------

View File

@ -34,6 +34,13 @@ Integration
Using `Atom Packages <https://atom.io/docs/v1.0.2/using-atom-atom-packages>`_ Using `Atom Packages <https://atom.io/docs/v1.0.2/using-atom-atom-packages>`_
please install `platomformio <https://atom.io/packages/platomformio>`_ package. please install `platomformio <https://atom.io/packages/platomformio>`_ package.
Articles / Manuals
------------------
* `Arduino Development in Atom Editor <http://viget.com/extend/arduino-development-in-atom-editor>`_
See a full list with :ref:`articles`.
Screenshot Screenshot
---------- ----------

View File

@ -57,6 +57,11 @@ There are 3 predefined targets for building:
* ``PLATFORMIO_UPLOAD`` - build and upload (if no errors) * ``PLATFORMIO_UPLOAD`` - build and upload (if no errors)
* ``PLATFORMIO_CLEAN`` - clean compiled objects and etc. * ``PLATFORMIO_CLEAN`` - clean compiled objects and etc.
.. warning::
The libraries which are added, installed or used in the project
after generating process wont be reflected in IDE. To fix it you
need to reinitialize project using :ref:`cmd_init` (repeat it).
.. warning:: .. warning::
PlatformIO generates empty project by default and **code auto-completion PlatformIO generates empty project by default and **code auto-completion
will not work!** To enable auto-completion please choose one of: will not work!** To enable auto-completion please choose one of:
@ -73,6 +78,14 @@ There are 3 predefined targets for building:
Active discussion is located in Active discussion is located in
`PlatformIO issue #132 <https://github.com/platformio/platformio/issues/132>`_. `PlatformIO issue #132 <https://github.com/platformio/platformio/issues/132>`_.
Articles / Manuals
------------------
* `Using PlatformIO to get started with Arduino in CLion IDE <http://www.ches.pl/using-platformio-get-started-arduino-clion-ide/>`_
* `Programar con Arduino "The good way" (Programming with Arduino "The good way", Spanish) <http://congdegnu.es/2015/11/09/programar-con-arduino-the-good-way/>`_
See a full list with :ref:`articles`.
Screenshot Screenshot
---------- ----------

View File

@ -37,9 +37,6 @@ page for more detailed information.
Integration Integration
----------- -----------
Project Generator
^^^^^^^^^^^^^^^^^
Since PlatformIO 2.0 you can generate Eclipse compatible project using Since PlatformIO 2.0 you can generate Eclipse compatible project using
:option:`platformio init --ide` command. Please choose board type using :option:`platformio init --ide` command. Please choose board type using
:ref:`cmd_boards` command and run: :ref:`cmd_boards` command and run:
@ -56,12 +53,19 @@ Then:
2. Open source file from ``src`` directory (``*.c, *.cpp, *.ino, etc.``) 2. Open source file from ``src`` directory (``*.c, *.cpp, *.ino, etc.``)
3. Build project: ``Menu: Project > Build Project``. 3. Build project: ``Menu: Project > Build Project``.
.. warning::
The libraries which are added, installed or used in the project
after generating process wont be reflected in IDE. To fix it you
need to reinitialize project using :ref:`cmd_init` (repeat it).
Manual Integration Articles / Manuals
^^^^^^^^^^^^^^^^^^ ------------------
* `Building and debugging Atmel AVR (Arduino-based) project using Eclipse IDE+PlatformIO <http://www.ikravets.com/computer-life/programming/2014/06/20/building-and-debugging-atmel-avr-arduino-based-project-using-eclipse-ideplatformio>`_ * `Building and debugging Atmel AVR (Arduino-based) project using Eclipse IDE+PlatformIO <http://www.ikravets.com/computer-life/programming/2014/06/20/building-and-debugging-atmel-avr-arduino-based-project-using-eclipse-ideplatformio>`_
* `Improvised MBED FRDM-K64F Eclipse/PlatformIO Setup and Software Installation <http://thomasweldon.com/tpw/courses/embeddsp/p00pcFrdmK64_eclipsePlatformioSetup.html>`_ * `Improvised MBED FRDM-K64F Eclipse/PlatformIO Setup and Software Installation <http://thomasweldon.com/tpw/courses/embeddsp/p00pcFrdmK64_eclipsePlatformioSetup.html>`_
* `Learning Arduino GitHub Repository <http://www.trojanc.co.za/2015/07/11/learning-arduino-github-repository/>`_
See a full list with :ref:`articles`.
Screenshot Screenshot
---------- ----------

View File

@ -28,12 +28,21 @@ This software can be used with:
Refer to the `Energia Getting Started <http://energia.nu/guide/>`_ Refer to the `Energia Getting Started <http://energia.nu/guide/>`_
page for Installation instructions. page for Installation instructions.
.. contents::
Integration Integration
----------- -----------
More detailed information is located in PlatformIO blog: More detailed information is located in PlatformIO blog:
`Integration of PlatformIO library manager to Energia IDE <http://www.ikravets.com/computer-life/platformio/2014/10/07/integration-of-platformio-library-manager-to-arduino-and-energia-ides>`_. `Integration of PlatformIO library manager to Energia IDE <http://www.ikravets.com/computer-life/platformio/2014/10/07/integration-of-platformio-library-manager-to-arduino-and-energia-ides>`_.
Articles / Manuals
------------------
* `Integration of PlatformIO library manager to Arduino and Energia IDEs <http://www.ikravets.com/computer-life/platformio/2014/10/07/integration-of-platformio-library-manager-to-arduino-and-energia-ides>`_
See the full list with :ref:`articles`.
Screenshot Screenshot
----------- -----------

View File

@ -85,6 +85,11 @@ Then:
.. image:: ../_static/ide-platformio-qtcreator-3.png .. image:: ../_static/ide-platformio-qtcreator-3.png
:target: http://docs.platformio.org/en/latest/_static/ide-platformio-qtcreator-3.png :target: http://docs.platformio.org/en/latest/_static/ide-platformio-qtcreator-3.png
.. warning::
The libraries which are added, installed or used in the project
after generating process wont be reflected in IDE. To fix it you
need to reinitialize project using :ref:`cmd_init` (repeat it).
Manual Integration Manual Integration
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^

View File

@ -23,6 +23,8 @@ This software can be used with:
* all available :ref:`platforms` * all available :ref:`platforms`
* all available :ref:`frameworks` * all available :ref:`frameworks`
.. contents::
Integration Integration
----------- -----------
@ -60,6 +62,13 @@ make firmware and upload it.
If hotkey doesn't work for you, try to add this line If hotkey doesn't work for you, try to add this line
``nnoremap <C-b> :make<CR>`` to ``~/.vimrc`` ``nnoremap <C-b> :make<CR>`` to ``~/.vimrc``
Articles / Manuals
------------------
* `コマンドラインでArduino開発 : vim + platformio (Arduino development at the command line: VIM + PlatformIO, Japanese) <http://qiita.com/caad1229/items/7b5fb47f034ae6e0baf2>`_
See a full list with :ref:`articles`.
Screenshot Screenshot
---------- ----------

View File

@ -52,6 +52,11 @@ Then:
2. Open source file from ``src`` directory (``*.c, *.cpp, *.ino, etc.``) 2. Open source file from ``src`` directory (``*.c, *.cpp, *.ino, etc.``)
3. Build project: ``Menu: Build > Build Solution``. 3. Build project: ``Menu: Build > Build Solution``.
.. warning::
The libraries which are added, installed or used in the project
after generating process wont be reflected in IDE. To fix it you
need to reinitialize project using :ref:`cmd_init` (repeat it).
Manual Integration Manual Integration
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^

View File

@ -99,11 +99,19 @@ Contents
Platforms & Boards <platforms/index> Platforms & Boards <platforms/index>
frameworks/index frameworks/index
.. toctree::
:caption: Library Manager
:maxdepth: 2
Quickstart <librarymanager/index>
User Guide <userguide/lib/index.rst>
librarymanager/config
librarymanager/creating
.. toctree:: .. toctree::
:caption: Integration :caption: Integration
:maxdepth: 2 :maxdepth: 2
librarymanager/index
ci/index ci/index
ide ide

View File

@ -336,6 +336,6 @@ A list of example patterns. This field is predefined with default value:
.. code-block:: javascript .. code-block:: javascript
"examples": [ "examples": [
"[Ee]xamples/*/*.ini", "[Ee]xamples/*/*.ino",
"[Ee]xamples/*/*.pde" "[Ee]xamples/*/*.pde"
] ]

View File

@ -14,10 +14,6 @@
Library Manager Library Manager
=============== ===============
..
*"The missing library manager for development platforms"* [#]_
*PlatformIO Library Manager* allows you to organize external embedded libraries. *PlatformIO Library Manager* allows you to organize external embedded libraries.
You can search for new libraries via You can search for new libraries via
@ -27,12 +23,4 @@ You can search for new libraries via
You don't need to bother for finding the latest version of library. Due to 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. :ref:`cmd_lib_update` command you will have up-to-date external libraries.
.. toctree:: .. image:: ../_static/platformio-demo-lib.gif
:maxdepth: 2
config
creating
User Guide <../userguide/lib/index.rst>
.. [#] Inspired by `npm <https://www.npmjs.com/>`_ and `bower
<http://bower.io>`_ package managers for web.

View File

@ -440,13 +440,17 @@ Example, specify own upload command for :ref:`platform_atmelavr`:
# uncomment line below to see environment variables # uncomment line below to see environment variables
# print env.Dump() # print env.Dump()
See built-in examples of `PlatformIO build scripts <https://github.com/platformio/platformio/tree/develop/platformio/builder/scripts>`_.
* see built-in examples of `PlatformIO build scripts <https://github.com/platformio/platformio/tree/develop/platformio/builder/scripts>`_.
* take a look on related users questions: `#351 <https://github.com/platformio/platformio/issues/351#issuecomment-161789165>`_,
`#236 <https://github.com/platformio/platformio/issues/236#issuecomment-112038284>`_,
`#247 <https://github.com/platformio/platformio/issues/247#issuecomment-118169728>`_
``targets`` ``targets``
^^^^^^^^^^^ ^^^^^^^^^^^
A list with targets which will be processed by :ref:`cmd_run` command by A list with targets which will be processed by :ref:`cmd_run` command by
default. You can enter more then one target separated with "space". Which default. You can enter more than one target separated with "space". Which
targets are supported is described in :option:`platformio run --target`. targets are supported is described in :option:`platformio run --target`.
**Tip!** You can use these targets like an option to **Tip!** You can use these targets like an option to

View File

@ -27,7 +27,7 @@ Usage
Description Description
----------- -----------
Initialize new PlatformIO based project. Initialize new PlatformIO based project or update existing with new data.
This command will create: This command will create:
@ -36,6 +36,8 @@ This command will create:
* ``src`` - a source directory. Put your source files here * ``src`` - a source directory. Put your source files here
* ``lib`` - a directory for the project specific (private) libraries. * ``lib`` - a directory for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file PlatformIO will compile them to static libraries and link to executable file
* ``.travis.yml`` configuration file (template) for Continuous Integration
with :ref:`ci_travis`
.. note:: .. note::
The source code of each library should be placed in separate directory. The source code of each library should be placed in separate directory.
@ -74,12 +76,11 @@ A list with supported IDE is available within ``platformio init --help`` command
Also, please look into :ref:`ide` page. Also, please look into :ref:`ide` page.
.. option:: .. option::
--disable-auto-uploading --enable-auto-uploading
If you initialise project with the specified If you initialise project with the specified
:option:`platformio init --board`, then *PlatformIO* :option:`platformio init --board`, then *PlatformIO*
will create environment with enabled firmware auto-uploading. This option will create environment with enabled firmware auto-uploading.
allows you to disable firmware auto-uploading by default.
.. option:: .. option::
--env-prefix --env-prefix
@ -138,9 +139,6 @@ Examples
$ platformio init --board uno $ platformio init --board uno
Would you like to enable firmware auto-uploading when project is successfully built using `platformio run` command?
Don't forget that you can upload firmware manually using `platformio run --target upload` command. [y/N]: y
The current working directory *** will be used for the new project. The current working directory *** will be used for the new project.
You can specify another project directory via You can specify another project directory via
`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command. `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.

View File

@ -59,7 +59,6 @@ Commands
cmd_boards cmd_boards
cmd_ci cmd_ci
cmd_init cmd_init
platformio lib <lib/index>
platformio platforms <platforms/index> platformio platforms <platforms/index>
cmd_run cmd_run
cmd_serialports cmd_serialports

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
VERSION = (2, 4, 1) VERSION = (2, 5, 0)
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -46,7 +46,7 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904
try: try:
return self._handle_obsolate_command(name) return self._handle_obsolate_command(name)
except AttributeError: except AttributeError:
raise exception.UnknownCLICommand(name) raise click.UsageError('No such command "%s"' % name, ctx)
return mod.cli return mod.cli
@staticmethod @staticmethod

View File

@ -41,8 +41,7 @@ from os import environ
from os.path import isfile, join from os.path import isfile, join
from time import time from time import time
from SCons.Script import (COMMAND_LINE_TARGETS, DefaultEnvironment, Exit, from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables
SConscript, SConscriptChdir, Variables)
from platformio.exception import UnknownBoard from platformio.exception import UnknownBoard
@ -141,10 +140,10 @@ if "BOARD" in env:
) )
if env['PLATFORM'] != env.get("BOARD_OPTIONS", {}).get("platform"): if env['PLATFORM'] != env.get("BOARD_OPTIONS", {}).get("platform"):
Exit("Error: '%s' platform doesn't support this board. " env.Exit(
"Use '%s' platform instead." % ( "Error: '%s' platform doesn't support this board. "
env['PLATFORM'], "Use '%s' platform instead." % (
env.get("BOARD_OPTIONS", {}).get("platform"))) env['PLATFORM'], env.get("BOARD_OPTIONS", {}).get("platform")))
for opt in ("LIB_IGNORE", "LIB_USE"): for opt in ("LIB_IGNORE", "LIB_USE"):
@ -158,16 +157,18 @@ if env.subst("$PIOPACKAGE_TOOLCHAIN"):
env.subst(join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN", "bin")) env.subst(join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN", "bin"))
) )
SConscriptChdir(0) env.SConscriptChdir(0)
SConscript(env.subst("$BUILD_SCRIPT")) env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite"))
env.SConscript("$BUILD_SCRIPT")
if environ.get("PLATFORMIO_EXTRA_SCRIPT", env.get("EXTRA_SCRIPT", None)): if environ.get("PLATFORMIO_EXTRA_SCRIPT", env.get("EXTRA_SCRIPT")):
SConscript(environ.get("PLATFORMIO_EXTRA_SCRIPT", env.get("EXTRA_SCRIPT"))) env.SConscript(
environ.get("PLATFORMIO_EXTRA_SCRIPT", env.get("EXTRA_SCRIPT")))
if "envdump" in COMMAND_LINE_TARGETS: if "envdump" in COMMAND_LINE_TARGETS:
print env.Dump() print env.Dump()
Exit() env.Exit()
if "idedata" in COMMAND_LINE_TARGETS: if "idedata" in COMMAND_LINE_TARGETS:
print json.dumps(env.DumpIDEData()) print json.dumps(env.DumpIDEData())
Exit() env.Exit()

View File

@ -26,13 +26,16 @@ the mbed Developer Community.
http://mbed.org/ http://mbed.org/
""" """
from __future__ import print_function
import re import re
import sys
import xml.etree.ElementTree as ElementTree import xml.etree.ElementTree as ElementTree
from binascii import crc32 from binascii import crc32
from os import getenv, walk from os import getenv, walk
from os.path import basename, isfile, join, normpath from os.path import basename, isfile, join, normpath
from SCons.Script import DefaultEnvironment, Exit from SCons.Script import DefaultEnvironment
env = DefaultEnvironment() env = DefaultEnvironment()
@ -119,8 +122,10 @@ def add_mbedlib(libname, libar):
lib_dir = join(env.subst("$PLATFORMFW_DIR"), "libs", libname) lib_dir = join(env.subst("$PLATFORMFW_DIR"), "libs", libname)
if not isfile(join(lib_dir, "TARGET_%s" % variant, if not isfile(join(lib_dir, "TARGET_%s" % variant,
"TOOLCHAIN_GCC_ARM", "lib%s.a" % libar)): "TOOLCHAIN_GCC_ARM", "lib%s.a" % libar)):
Exit("Error: %s board doesn't support %s library!" % print (
(env.get("BOARD"), libname)) "Warning: %s board doesn't have native support for '%s' library!" %
(env.get("BOARD"), libname), file=sys.stderr)
return
env.Append( env.Append(
LIBPATH=[ LIBPATH=[

View File

@ -99,8 +99,7 @@ def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913
_exclude_contents(build_dir, exclude) _exclude_contents(build_dir, exclude)
# initialise project # initialise project
ctx.invoke(cmd_init, project_dir=build_dir, board=board, ctx.invoke(cmd_init, project_dir=build_dir, board=board)
disable_auto_uploading=True)
# process project # process project
ctx.invoke(cmd_run, project_dir=build_dir, verbose=verbose) ctx.invoke(cmd_run, project_dir=build_dir, verbose=verbose)

View File

@ -45,21 +45,11 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613
callback=validate_boards) callback=validate_boards)
@click.option("--ide", @click.option("--ide",
type=click.Choice(ProjectGenerator.get_supported_ides())) type=click.Choice(ProjectGenerator.get_supported_ides()))
@click.option("--disable-auto-uploading", is_flag=True) @click.option("--enable-auto-uploading", is_flag=True)
@click.option("--env-prefix", default="") @click.option("--env-prefix", default="")
@click.pass_context @click.pass_context
def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 def cli(ctx, project_dir, board, ide, # pylint: disable=R0913
disable_auto_uploading, env_prefix): enable_auto_uploading, env_prefix):
# ask about auto-uploading
if board and app.get_setting("enable_prompts"):
disable_auto_uploading = not click.confirm(
"Would you like to enable firmware auto-uploading when project "
"is successfully built using `platformio run` command? \n"
"Don't forget that you can upload firmware manually using "
"`platformio run --target upload` command."
)
click.echo("")
if project_dir == getcwd(): if project_dir == getcwd():
click.secho("\nThe current working directory", fg="yellow", nl=False) click.secho("\nThe current working directory", fg="yellow", nl=False)
@ -93,9 +83,108 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913
if not isdir(d): if not isdir(d):
makedirs(d) makedirs(d)
if not isfile(join(lib_dir, "readme.txt")): init_lib_readme(lib_dir)
with open(join(lib_dir, "readme.txt"), "w") as f: init_ci_conf(project_dir)
f.write(""" init_cvs_ignore(project_dir)
if not isfile(project_file):
copyfile(join(get_source_dir(), "projectconftpl.ini"),
project_file)
if board:
fill_project_envs(
ctx, project_file, board, enable_auto_uploading, env_prefix,
ide is not None
)
if ide:
if not board:
raise exception.BoardNotDefined()
if len(board) > 1:
click.secho(
"Warning! You have initialised project with more than 1 board"
" for the specified IDE.\n"
"However, the IDE features (code autocompletion, syntax lint)"
" have been configured for the first board '%s' from your list"
" '%s'." % (board[0], ", ".join(board)),
fg="yellow"
)
pg = ProjectGenerator(
project_dir, ide, board[0])
pg.generate()
click.secho(
"\nProject has been successfully initialized!\nUseful commands:\n"
"`platformio run` - process/build project from the current "
"directory\n"
"`platformio run --target upload` or `platformio run -t upload` "
"- upload firmware to embedded board\n"
"`platformio run --target clean` - clean project (remove compiled "
"files)\n"
"`platformio run --help` - additional information",
fg="green"
)
def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
ctx, project_file, board_types, enable_auto_uploading,
env_prefix, force_download):
builtin_boards = get_boards()
content = []
used_envs = []
used_platforms = []
with open(project_file) as f:
used_envs = [l.strip() for l in f.read().splitlines() if
l.strip().startswith("[env:")]
for type_ in board_types:
data = builtin_boards[type_]
used_platforms.append(data['platform'])
env_name = "[env:%s%s]" % (env_prefix, type_)
if env_name in used_envs:
continue
content.append("")
content.append(env_name)
content.append("platform = %s" % data['platform'])
# find default framework for board
frameworks = data.get("frameworks")
if frameworks:
content.append("framework = %s" % frameworks[0])
content.append("board = %s" % type_)
if enable_auto_uploading:
content.append("targets = upload")
if force_download and used_platforms:
_install_dependent_platforms(ctx, used_platforms)
if not content:
return
with open(project_file, "a") as f:
content.append("")
f.write("\n".join(content))
def _install_dependent_platforms(ctx, platforms):
installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
if set(platforms) <= set(installed_platforms):
return
ctx.invoke(
cli_platforms_install,
platforms=list(set(platforms) - set(installed_platforms))
)
def init_lib_readme(lib_dir):
if isfile(join(lib_dir, "readme.txt")):
return
with open(join(lib_dir, "readme.txt"), "w") as f:
f.write("""
This directory is intended for the project specific (private) libraries. This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file. PlatformIO will compile them to static libraries and link to executable file.
@ -135,77 +224,81 @@ http://docs.platformio.org/en/latest/projectconf.html#lib-install
""") """)
if not isfile(project_file):
copyfile(join(get_source_dir(), "projectconftpl.ini"),
project_file)
if board: def init_ci_conf(project_dir):
fill_project_envs( if isfile(join(project_dir, ".travis.yml")):
ctx, project_file, board, disable_auto_uploading, env_prefix)
if ide:
pg = ProjectGenerator(project_dir, ide, board[0] if board else None)
pg.generate()
click.secho(
"\nProject has been successfully initialized!\nUseful commands:\n"
"`platformio run` - process/build project from the current "
"directory\n"
"`platformio run --target upload` or `platformio run -t upload` "
"- upload firmware to embedded board\n"
"`platformio run --target clean` - clean project (remove compiled "
"files)",
fg="green"
)
def fill_project_envs(ctx, project_file, board_types, disable_auto_uploading,
env_prefix):
builtin_boards = get_boards()
content = []
used_envs = []
used_platforms = []
with open(project_file) as f:
used_envs = [l.strip() for l in f.read().splitlines() if
l.strip().startswith("[env:")]
for type_ in board_types:
data = builtin_boards[type_]
used_platforms.append(data['platform'])
env_name = "[env:%s%s]" % (env_prefix, type_)
if env_name in used_envs:
continue
content.append("")
content.append(env_name)
content.append("platform = %s" % data['platform'])
# find default framework for board
frameworks = data.get("frameworks")
if frameworks:
content.append("framework = %s" % frameworks[0])
content.append("board = %s" % type_)
content.append("%stargets = upload" % ("# " if disable_auto_uploading
else ""))
_install_dependent_platforms(ctx, used_platforms)
if not content:
return return
with open(join(project_dir, ".travis.yml"), "w") as f:
with open(project_file, "a") as f: f.write("""# Continuous Integration (CI) is the practice, in software
content.append("") # engineering, of merging all developer working copies with a shared mainline
f.write("\n".join(content)) # several times a day < http://docs.platformio.org/en/latest/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < http://docs.platformio.org/en/latest/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html >
#
#
# Please choice one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#
def _install_dependent_platforms(ctx, platforms): #
installed_platforms = PlatformFactory.get_platforms(installed=True).keys() # Template #1: General project. Test it using existing `platformio.ini`.
if set(platforms) <= set(installed_platforms): #
# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
#
# script:
# - platformio run
#
# Template #2: The project is intended to by used as a library with examples
#
# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
#
# script:
# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N
""")
def init_cvs_ignore(project_dir):
if isfile(join(project_dir, ".gitignore")):
return return
ctx.invoke( with open(join(project_dir, ".gitignore"), "w") as f:
cli_platforms_install, f.write(".pioevs")
platforms=list(set(platforms) - set(installed_platforms))
)

View File

@ -159,7 +159,7 @@ def lib_install_dependency(ctx, data):
ctx.invoke(lib_install, libid=[result['items'][0]['id']]) ctx.invoke(lib_install, libid=[result['items'][0]['id']])
else: else:
click.secho( click.secho(
"Conflict: More then one dependent libraries have been found " "Conflict: More than one dependent libraries have been found "
"by request %s:" % json.dumps(data), fg="red") "by request %s:" % json.dumps(data), fg="red")
echo_liblist_header() echo_liblist_header()

View File

@ -57,10 +57,10 @@ if int(PYSERIAL_VERSION[0]) == 3:
help="Enable RTS/CTS flow control, default=Off") help="Enable RTS/CTS flow control, default=Off")
@click.option("--xonxoff", is_flag=True, @click.option("--xonxoff", is_flag=True,
help="Enable software flow control, default=Off") help="Enable software flow control, default=Off")
@click.option("--rts", default="0", type=click.Choice(["0", "1"]), @click.option("--rts", default=None, type=click.Choice(["0", "1"]),
help="Set initial RTS line state, default=0") help="Set initial RTS line state")
@click.option("--dtr", default="0", type=click.Choice(["0", "1"]), @click.option("--dtr", default=None, type=click.Choice(["0", "1"]),
help="Set initial DTR line state, default=0") help="Set initial DTR line state")
@click.option("--encoding", default="UTF-8", @click.option("--encoding", default="UTF-8",
help="Set the encoding for the serial port (e.g. hexlify, " help="Set the encoding for the serial port (e.g. hexlify, "
"Latin1, UTF-8), default: UTF-8") "Latin1, UTF-8), default: UTF-8")

View File

@ -32,7 +32,6 @@ def cli():
fg="yellow") fg="yellow")
cmds = ( cmds = (
["pip", "install", "--upgrade", "pip", "setuptools"],
["pip", "install", "--upgrade", "platformio"], ["pip", "install", "--upgrade", "platformio"],
["platformio", "--version"] ["platformio", "--version"]
) )
@ -60,7 +59,11 @@ def cli():
if not r: if not r:
raise exception.UpgradeError( raise exception.UpgradeError(
"\n".join([str(cmd), str(e)])) "\n".join([str(cmd), str(e)]))
if ("Permission denied" in r['err'] and permission_errors = (
"permission denied",
"not permitted"
)
if (any([m in r['err'].lower() for m in permission_errors]) and
"windows" not in util.get_systype()): "windows" not in util.get_systype()):
click.secho(""" click.secho("""
----------------- -----------------
@ -68,7 +71,7 @@ Permission denied
----------------- -----------------
You need the `sudo` permission to install Python packages. Try You need the `sudo` permission to install Python packages. Try
> sudo platformio upgrade > sudo pip install -U platformio
WARNING! Don't use `sudo` for the rest PlatformIO commands. WARNING! Don't use `sudo` for the rest PlatformIO commands.
""", fg="yellow", err=True) """, fg="yellow", err=True)

View File

@ -48,10 +48,11 @@ class PlatformNotInstalledYet(PlatformioException):
"Use `platformio platforms install` command" "Use `platformio platforms install` command"
class UnknownCLICommand(PlatformioException): class BoardNotDefined(PlatformioException):
MESSAGE = "Unknown command '%s'. Please use `platformio --help`"\ MESSAGE = "You need to specify board type using `-b` or `--board` "\
" to see all available commands" "option. Supported boards list is available via "\
" `platformio boards` command"
class UnknownBoard(PlatformioException): class UnknownBoard(PlatformioException):
@ -201,6 +202,7 @@ class UpgradeError(PlatformioException):
MESSAGE = """%s MESSAGE = """%s
* Upgrade using `pip install -U platformio`
* Try different installation/upgrading steps: * Try different installation/upgrading steps:
http://docs.platformio.org/en/latest/installation.html http://docs.platformio.org/en/latest/installation.html
""" """

View File

@ -20,12 +20,12 @@ from os.path import abspath, basename, expanduser, isdir, join, relpath
import bottle import bottle
import click import click
from platformio import util from platformio import exception, util
class ProjectGenerator(object): class ProjectGenerator(object):
def __init__(self, project_dir, ide, board=None): def __init__(self, project_dir, ide, board):
self.project_dir = project_dir self.project_dir = project_dir
self.ide = ide self.ide = ide
self.board = board self.board = board
@ -50,7 +50,7 @@ class ProjectGenerator(object):
data = {"env_name": section[4:]} data = {"env_name": section[4:]}
for k, v in config.items(section): for k, v in config.items(section):
data[k] = v data[k] = v
if self.board and self.board == data.get("board"): if self.board == data.get("board"):
break break
return data return data
@ -68,16 +68,15 @@ class ProjectGenerator(object):
["platformio", "-f", "run", "-t", "idedata", ["platformio", "-f", "run", "-t", "idedata",
"-e", envdata['env_name'], "-d", self.project_dir] "-e", envdata['env_name'], "-d", self.project_dir]
) )
if result['returncode'] != 0 or '"includes":' not in result['out']: if result['returncode'] != 0 or '"includes":' not in result['out']:
return data raise exception.PlatformioException(
"\n".join([result['out'], result['err']]))
output = result['out'] output = result['out']
try: start_index = output.index('\n{"')
start_index = output.index('\n{"') stop_index = output.rindex('}')
stop_index = output.rindex('}') data = json.loads(output[start_index + 1:stop_index + 1])
data = json.loads(output[start_index + 1:stop_index + 1])
except ValueError:
pass
return data return data

View File

@ -141,8 +141,8 @@ def after_upgrade(ctx):
(click.style("follow", fg="cyan"), (click.style("follow", fg="cyan"),
click.style("https://twitter.com/PlatformIO_Org", fg="cyan")) click.style("https://twitter.com/PlatformIO_Org", fg="cyan"))
) )
click.echo("- %s us a star on GitHub > %s" % ( click.echo("- %s it on GitHub! > %s" % (
click.style("give", fg="cyan"), click.style("star", fg="cyan"),
click.style("https://github.com/platformio/platformio", fg="cyan") click.style("https://github.com/platformio/platformio", fg="cyan")
)) ))
click.echo("*" * terminal_width) click.echo("*" * terminal_width)

View File

@ -15,6 +15,7 @@
import os import os
import re import re
from imp import load_source from imp import load_source
from multiprocessing import cpu_count
from os.path import isdir, isfile, join from os.path import isdir, isfile, join
import click import click
@ -389,6 +390,8 @@ class BasePlatform(object):
[ [
"scons", "scons",
"-Q", "-Q",
"-j %d" % self.get_job_nums(),
"--warn=no-no-parallel-support",
"-f", join(util.get_source_dir(), "builder", "main.py") "-f", join(util.get_source_dir(), "builder", "main.py")
] + variables + targets, ] + variables + targets,
stdout=util.AsyncPipe(self.on_run_out), stdout=util.AsyncPipe(self.on_run_out),
@ -432,3 +435,10 @@ class BasePlatform(object):
self._last_echo_line = line self._last_echo_line = line
click.secho(line, fg=fg, err=level < 3) click.secho(line, fg=fg, err=level < 3)
@staticmethod
def get_job_nums():
try:
return cpu_count()
except NotImplementedError:
return 1

View File

@ -71,10 +71,9 @@ setup(
"Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Compilers" "Topic :: Software Development :: Compilers"
], ],
keywords=( keywords=[
"iot builder library manager embedded development ide continuous " "iot", "build tool", "compiler", "builder", "library manager",
"integration atmel avr sam espressif esp freescale kinetis nordic " "embedded", "ci", "continuous integration", "arduino", "mbed",
"nrf51 nxp lpc silicon labs efm32 st stm32 ti msp430 tiva teensy " "framework", "ide", "ide integration", "library.json"
"arduino mbed libopencm3" ]
)
) )

View File

@ -16,7 +16,7 @@ from os import makedirs, getcwd
from os.path import getsize, isdir, isfile, join from os.path import getsize, isdir, isfile, join
from platformio.commands.init import cli from platformio.commands.init import cli
from platformio import exception, util from platformio import util
def validate_pioproject(pioproject_dir): def validate_pioproject(pioproject_dir):
@ -53,8 +53,7 @@ def test_init_special_board(platformio_setup, clirunner, validate_cliresult):
expected_result = [ expected_result = [
("platform", str(uno['platform'])), ("platform", str(uno['platform'])),
("framework", str(uno['frameworks'][0])), ("framework", str(uno['frameworks'][0])),
("board", "uno"), ("board", "uno")
("targets", "upload")
] ]
assert config.has_section("env:uno") assert config.has_section("env:uno")
@ -62,18 +61,19 @@ def test_init_special_board(platformio_setup, clirunner, validate_cliresult):
set(config.items("env:uno")))) == 0 set(config.items("env:uno")))) == 0
def test_init_disable_auto_uploading(platformio_setup, clirunner, def test_init_enable_auto_uploading(platformio_setup, clirunner,
validate_cliresult): validate_cliresult):
with clirunner.isolated_filesystem(): with clirunner.isolated_filesystem():
result = clirunner.invoke(cli, result = clirunner.invoke(cli,
["-b", "uno", "--disable-auto-uploading"]) ["-b", "uno", "--enable-auto-uploading"])
validate_cliresult(result) validate_cliresult(result)
validate_pioproject(getcwd()) validate_pioproject(getcwd())
config = util.get_project_config() config = util.get_project_config()
expected_result = [ expected_result = [
("platform", "atmelavr"), ("platform", "atmelavr"),
("framework", "arduino"), ("framework", "arduino"),
("board", "uno") ("board", "uno"),
("targets", "upload")
] ]
assert config.has_section("env:uno") assert config.has_section("env:uno")
assert len(set(expected_result).symmetric_difference( assert len(set(expected_result).symmetric_difference(