Merge branch 'release/v.2.0.1'

This commit is contained in:
Ivan Kravets
2015-05-27 17:02:08 +03:00
30 changed files with 308 additions and 160 deletions

View File

@ -1,10 +1,35 @@
Release History Release History
=============== ===============
2.0.1 (2015-??-??)
------------------
* Handle new environment variables
`PLATFORMIO_BUILD_FLAGS <http://docs.platformio.org/en/latest/envvars.html#platformio-build-flags>`_
and `PLATFORMIO_LDF_CYCLIC <http://docs.platformio.org/en/latest/envvars.html#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
(`issue #210 <https://github.com/platformio/platformio/issues/210>`_)
* Added support for new WildFire boards from
`Wicked Device <http://wickeddevice.com>`_ to
`atmelavr <http://docs.platformio.org/en/latest/platforms/atmelavr.html#boards>`__
platform
* Updated `Arduino Framework <http://docs.platformio.org/en/latest/frameworks/arduino.html>`__ to
1.6.4 version (`issue #212 <https://github.com/platformio/platformio/issues/212>`_)
* Handle Atmel AVR Symbols when initialising project for IDE
(`issue #216 <https://github.com/platformio/platformio/issues/216>`_)
* Fixed bug with converting ``*.ino`` to ``*.cpp``
* Fixed failing with ``platformio init --ide eclipse`` without boards
(`issue #217 <https://github.com/platformio/platformio/issues/217>`_)
2.0.0 (2015-05-22) 2.0.0 (2015-05-22)
------------------ ------------------
* PlatformIO as :ref:`ci` (CI) tool for embedded projects *Made in* `Paradise <https://twitter.com/ikravets/status/592356377185619969>`_
* PlatformIO as `Continuous Integration <http://docs.platformio.org/en/latest/ci/index.html>`_
(CI) tool for embedded projects
(`issue #108 <https://github.com/platformio/platformio/issues/108>`_) (`issue #108 <https://github.com/platformio/platformio/issues/108>`_)
* Initialise PlatformIO project for the specified IDE * Initialise PlatformIO project for the specified IDE
(`issue #151 <https://github.com/platformio/platformio/issues/151>`_) (`issue #151 <https://github.com/platformio/platformio/issues/151>`_)
@ -80,7 +105,7 @@ Release History
`teensy <http://docs.platformio.org/en/latest/platforms/teensy.html>`__ `teensy <http://docs.platformio.org/en/latest/platforms/teensy.html>`__
platform platform
* Added support for new Arduino based boards by *SparkFun, BQ, LightUp, * Added support for new Arduino based boards by *SparkFun, BQ, LightUp,
LowPowerLab, Quirkbot, RedBearLab, TinyCircuits, WickedDevice* to LowPowerLab, Quirkbot, RedBearLab, TinyCircuits* to
`atmelavr <http://docs.platformio.org/en/latest/platforms/atmelavr.html#boards>`__ `atmelavr <http://docs.platformio.org/en/latest/platforms/atmelavr.html#boards>`__
platform platform
* Upgraded `Arduino Framework <http://docs.platformio.org/en/latest/frameworks/arduino.html>`__ to * Upgraded `Arduino Framework <http://docs.platformio.org/en/latest/frameworks/arduino.html>`__ to

View File

@ -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 - 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` For more details as for PlatformIO build process please look into :ref:`cmd_ci`
command. command.
@ -60,13 +62,22 @@ Examples
- "2.7" - "2.7"
env: env:
- PLATFORMIO_CI_SRC=examples/Bluetooth/PS3SPP/PS3SPP.ino - PLATFORMIO_CI_SRC=examples/acm/acm_terminal
- PLATFORMIO_CI_SRC=examples/pl2303/pl2303_gps/pl2303_gps.ino - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiIRCamera PLATFORMIO_BUILD_FLAGS="-DWIICAMERA"
- PLATFORMIO_CI_SRC=examples/ftdi/USBFTDILoopback
- PLATFORMIO_CI_SRC=examples/Xbox/XBOXUSB
# - ...
install: install:
- python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" - 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: script:
- platformio ci --lib="." --lib="/tmp/spi4teensy3-master" --board=uno --board=teensy31 --board=due - 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

View File

@ -36,44 +36,53 @@ In other words, ``CI=true`` automatically setup
PLATFORMIO_HOME_DIR PLATFORMIO_HOME_DIR
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_dir`.
:ref:`projectconf_pio_home_dir`.
.. _envvar_PLATFORMIO_LIB_DIR: .. _envvar_PLATFORMIO_LIB_DIR:
PLATFORMIO_LIB_DIR PLATFORMIO_LIB_DIR
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option Allows to override :ref:`projectconf` option :ref:`projectconf_pio_lib_dir`.
:ref:`projectconf_pio_lib_dir`.
.. _envvar_PLATFORMIO_SRC_DIR: .. _envvar_PLATFORMIO_SRC_DIR:
PLATFORMIO_SRC_DIR PLATFORMIO_SRC_DIR
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option Allows to override :ref:`projectconf` option :ref:`projectconf_pio_src_dir`.
:ref:`projectconf_pio_src_dir`.
.. _envvar_PLATFORMIO_ENVS_DIR: .. _envvar_PLATFORMIO_ENVS_DIR:
PLATFORMIO_ENVS_DIR PLATFORMIO_ENVS_DIR
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option Allows to override :ref:`projectconf` option :ref:`projectconf_pio_envs_dir`.
:ref:`projectconf_pio_envs_dir`.
Builder Builder
------- -------
.. _envvar_PLATFORMIO_BUILD_FLAGS:
PLATFORMIO_BUILD_FLAGS
~~~~~~~~~~~~~~~~~~~~~~
Allows to set :ref:`projectconf` option :ref:`projectconf_build_flags`.
.. _envvar_PLATFORMIO_SRCBUILD_FLAGS: .. _envvar_PLATFORMIO_SRCBUILD_FLAGS:
PLATFORMIO_SRCBUILD_FLAGS PLATFORMIO_SRCBUILD_FLAGS
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option Allows to set :ref:`projectconf` option :ref:`projectconf_srcbuild_flags`.
:ref:`projectconf_srcbuild_flags`.
.. _envvar_PLATFORMIO_LDF_CYCLIC:
PLATFORMIO_LDF_CYCLIC
~~~~~~~~~~~~~~~~~~~~~
Allows to set :ref:`projectconf` option :ref:`projectconf_ldf_cyclic`.
Settings Settings
-------- --------

View File

@ -923,8 +923,8 @@ TinyCircuits
- 32 Kb - 32 Kb
- 2 Kb - 2 Kb
WickedDevice Wicked Device
~~~~~~~~~~~~ ~~~~~~~~~~~~~
.. list-table:: .. list-table::
:header-rows: 1 :header-rows: 1
@ -937,14 +937,14 @@ WickedDevice
- RAM - RAM
* - ``wildfirev2`` * - ``wildfirev2``
- `WickedDevice WildFire v2 [stk500] <http://shop.wickeddevice.com/resources/wildfire/#arduinoidesetup>`_ - `Wicked Device WildFire V2 <http://shop.wickeddevice.com/resources/wildfire/>`_
- ATMEGA1284P - ATMEGA1284P
- 16 MHz - 16 MHz
- 128 Kb - 128 Kb
- 16 Kb - 16 Kb
* - ``wildfirev3`` * - ``wildfirev3``
- `WickedDevice WildFire v3 [optiboot] <http://shop.wickeddevice.com/resources/wildfire/>`_ - `Wicked Device WildFire V3 <http://shop.wickeddevice.com/resources/wildfire/>`_
- ATMEGA1284P - ATMEGA1284P
- 16 MHz - 16 MHz
- 128 Kb - 128 Kb

View File

@ -29,12 +29,13 @@ Integration
Project Generator Project Generator
^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
Since PlatformIO 2.0 you can generate Eclipse compatible project using SSince PlatformIO 2.0 you can generate Eclipse compatible project using
:option:`platformio init --ide` command: :option:`platformio init --ide` command. Please choose board type using
:ref:`cmd_boards` command and run:
.. code-block:: shell .. code-block:: shell
platformio init --ide eclipse platformio init --ide eclipse --board %TYPE%
Then import this project via ``File > Import... > General > Existing Projects Then import this project via ``File > Import... > General > Existing Projects
into Workspace > Next`` and specify root directory where is located into Workspace > Next`` and specify root directory where is located

View File

@ -21,12 +21,13 @@ Integration
Project Generator Project Generator
^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
Since PlatformIO 2.0 you can generate Eclipse compatible project using Since PlatformIO 2.0 you can generate Qt Creator compatible project using
:option:`platformio init --ide` command: :option:`platformio init --ide` command. Please choose board type using
:ref:`cmd_boards` command and run:
.. code-block:: shell .. 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`` Then import this project via ``File > New File or Project > Import Project``
and specify root directory where is located :ref:`projectconf`. and specify root directory where is located :ref:`projectconf`.

View File

@ -21,12 +21,13 @@ Integration
Project Generator Project Generator
^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
Since PlatformIO 2.0 you can generate Eclipse compatible project using Since PlatformIO 2.0 you can generate Sublime Text compatible project using
:option:`platformio init --ide` command: :option:`platformio init --ide` command. Please choose board type using
:ref:`cmd_boards` command and run:
.. code-block:: shell .. code-block:: shell
platformio init --ide sublimetext platformio init --ide sublimetext --board %TYPE%
Then import this project via ``Project > Open Project...`` and specify root Then import this project via ``Project > Open Project...`` and specify root
directory where is located :ref:`projectconf`. directory where is located :ref:`projectconf`.
@ -44,17 +45,17 @@ described below:
.. code-block:: bash .. code-block:: bash
{ {
"cmd": ["platformio", "run"], "cmd": ["platformio", "--force", "run"],
"working_dir": "${project_path:${folder}}", "working_dir": "${project_path:${folder}}",
"variants": "variants":
[ [
{ {
"name": "Clean", "name": "Clean",
"cmd": ["platformio", "run", "-t", "clean"] "cmd": ["platformio", "--force", "run", "--target", "clean"]
}, },
{ {
"name": "Upload", "name": "Upload",
"cmd": ["platformio", "run", "-t", "upload"] "cmd": ["platformio", "--force", "run", "--target", "upload"]
} }
] ]
} }

View File

@ -30,10 +30,10 @@ Put to the project directory ``Makefile`` wrapper with contents:
#PATH := /usr/local/bin:$(PATH) #PATH := /usr/local/bin:$(PATH)
all: all:
platformio run -t upload platformio --force run --target upload
clean: 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`` Now, in VIM ``cd /path/to/this/project`` and press ``Ctrl+B`` or ``Cmd+B``

View File

@ -21,15 +21,16 @@ Integration
Project Generator Project Generator
^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
Since PlatformIO 2.0 you can generate Eclipse compatible project using Since PlatformIO 2.0 you can generate Visual Studio compatible project using
:option:`platformio init --ide` command: :option:`platformio init --ide` command. Please choose board type using
:ref:`cmd_boards` command and run:
.. code-block:: shell .. code-block:: shell
platformio init --ide visualstudio platformio init --ide visualstudio --board %TYPE%
Then import this project via ``File > Import ...`` and specify root directory Then import this project via ``File->Open->Project/Solution`` and specify root
where is located :ref:`projectconf`. directory where is located :ref:`projectconf`.
Manual Integration Manual Integration
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^

View File

@ -8,8 +8,10 @@ Library Manager
*"The missing library manager for development platforms"* [#]_ *"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 :ref:`Command Line interface <cmd_lib_search>` You can search for new libraries via
or `Web 2.0 Library Search <http://platformio.org/#!/lib>`_.
* :ref:`Command Line interface <cmd_lib_search>`
* `Web 2.0 Library Search <http://platformio.org/#!/lib>`_
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.

View File

@ -816,8 +816,8 @@ TinyCircuits
- 32 Kb - 32 Kb
- 2 Kb - 2 Kb
WickedDevice Wicked Device
~~~~~~~~~~~~ ~~~~~~~~~~~~~
.. list-table:: .. list-table::
:header-rows: 1 :header-rows: 1
@ -830,14 +830,14 @@ WickedDevice
- RAM - RAM
* - ``wildfirev2`` * - ``wildfirev2``
- `WickedDevice WildFire v2 [stk500] <http://shop.wickeddevice.com/resources/wildfire/#arduinoidesetup>`_ - `Wicked Device WildFire V2 <http://shop.wickeddevice.com/resources/wildfire/>`_
- ATMEGA1284P - ATMEGA1284P
- 16 MHz - 16 MHz
- 128 Kb - 128 Kb
- 16 Kb - 16 Kb
* - ``wildfirev3`` * - ``wildfirev3``
- `WickedDevice WildFire v3 [optiboot] <http://shop.wickeddevice.com/resources/wildfire/>`_ - `Wicked Device WildFire V3 <http://shop.wickeddevice.com/resources/wildfire/>`_
- ATMEGA1284P - ATMEGA1284P
- 16 MHz - 16 MHz
- 128 Kb - 128 Kb

View File

@ -270,6 +270,9 @@ processes:
- Add the directory *dir* to the list of directories to be searched - Add the directory *dir* to the list of directories to be searched
for header files. for header files.
This option can be set by global environment variable
:ref:`envvar_PLATFORMIO_BUILD_FLAGS`.
Example: Example:
.. code-block:: ini .. 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 but will be applied only for the project source code from
:ref:`projectconf_pio_src_dir` directory. :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`. :ref:`envvar_PLATFORMIO_SRCBUILD_FLAGS`.
``install_libs`` ``install_libs``
@ -328,7 +331,7 @@ Example:
``use_libs`` ``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. the highest priority.
Example: Example:
@ -341,7 +344,7 @@ Example:
``ignore_libs`` ``ignore_libs``
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Specify libraries which should be ignored by ``Library Dependency Finder`` Specify libraries which should be ignored by ``Library Dependency Finder (LDF)``
Example: Example:
@ -350,6 +353,30 @@ Example:
[env:ignore_some_libs] [env:ignore_some_libs]
ignore_libs = SPI,EngduinoV3_ID123 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: .. _projectconf_examples:

View File

@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com> # Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details. # See LICENSE for details.
VERSION = (2, 0, 0) VERSION = (2, 0, 1)
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -250,50 +250,6 @@
"vendor": "TinyCircuits" "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": { "blend": {
"build": { "build": {
"core": "arduino", "core": "arduino",
@ -521,5 +477,49 @@
}, },
"url": "http://quirkbot.com", "url": "http://quirkbot.com",
"vendor": "Quirkbot" "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"
} }
} }

View File

@ -38,6 +38,7 @@ commonvars.AddVariables(
("SRCBUILD_FLAGS",), ("SRCBUILD_FLAGS",),
("IGNORE_LIBS",), ("IGNORE_LIBS",),
("USE_LIBS",), ("USE_LIBS",),
("LDF_CYCLIC",),
# board options # board options
("BOARD",), ("BOARD",),

View File

@ -53,6 +53,8 @@ env.Append(
"${BOARD_OPTIONS['build']['variant'].upper()}" "${BOARD_OPTIONS['build']['variant'].upper()}"
], ],
LIBS=["stdc++", "nosys"],
LINKFLAGS=[ LINKFLAGS=[
"-nostartfiles", "-nostartfiles",
"-nostdlib" "-nostdlib"

View File

@ -4,6 +4,7 @@
import atexit import atexit
import json import json
import re import re
from glob import glob
from os import getenv, listdir, remove, sep, walk from os import getenv, listdir, remove, sep, walk
from os.path import basename, dirname, isdir, isfile, join, normpath from os.path import basename, dirname, isdir, isfile, join, normpath
@ -47,10 +48,11 @@ def BuildFirmware(env):
_LIBFLAGS=" -Wl,--end-group" _LIBFLAGS=" -Wl,--end-group"
) )
_srcbuild_flags = getenv("PLATFORMIO_SRCBUILD_FLAGS", # Handle SRCBUILD_FLAGS
env.subst("$SRCBUILD_FLAGS")) if getenv("PLATFORMIO_SRCBUILD_FLAGS", None):
if _srcbuild_flags: firmenv.MergeFlags(getenv("PLATFORMIO_SRCBUILD_FLAGS"))
firmenv.MergeFlags(_srcbuild_flags) if "SRCBUILD_FLAGS" in env:
firmenv.MergeFlags(env['SRCBUILD_FLAGS'])
firmenv.Append( firmenv.Append(
CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format(
@ -62,18 +64,13 @@ def BuildFirmware(env):
Exit() Exit()
if "idedata" in COMMAND_LINE_TARGETS: if "idedata" in COMMAND_LINE_TARGETS:
_data = {"defines": [], "includes": []} print json.dumps(env.DumpIDEData())
for item in env.get("VARIANT_DIRS", []):
_data['includes'].append(env.subst(item[1]))
for item in env.get("CPPDEFINES", []):
_data['defines'].append(env.subst(item))
print json.dumps(_data)
Exit() Exit()
return firmenv.Program( return firmenv.Program(
join("$BUILD_DIR", "firmware"), join("$BUILD_DIR", "firmware"),
[firmenv.GlobCXXFiles(vdir) for vdir in vdirs], [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"], LIBPATH=env.get("LIBPATH", []) + ["$BUILD_DIR"],
PROGSUFFIX=".elf" PROGSUFFIX=".elf"
) )
@ -83,6 +80,9 @@ def ProcessFlags(env):
if "extra_flags" in env.get("BOARD_OPTIONS", {}).get("build", {}): if "extra_flags" in env.get("BOARD_OPTIONS", {}).get("build", {}):
env.MergeFlags(env.subst("${BOARD_OPTIONS['build']['extra_flags']}")) 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: if "BUILD_FLAGS" in env:
env.MergeFlags(env['BUILD_FLAGS']) env.MergeFlags(env['BUILD_FLAGS'])
@ -97,8 +97,8 @@ def ProcessFlags(env):
def GlobCXXFiles(env, path): def GlobCXXFiles(env, path):
files = [] files = []
for suff in ["*.c", "*.cpp", "*.S"]: for suff in ["c", "cpp", "S", "spp", "SPP", "sx", "s", "asm", "ASM"]:
_list = env.Glob(join(path, suff)) _list = env.Glob(join(path, "*.%s" % suff))
if _list: if _list:
files += _list files += _list
return files return files
@ -278,23 +278,24 @@ def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914
len(state['ordered']) + 1, finder.getLibName(), len(state['ordered']) + 1, finder.getLibName(),
_lib_dir)) _lib_dir))
state['libs'].add(_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 return state
# end internal prototypes # end internal prototypes
deplibs = _get_dep_libs(src_dir) deplibs = _get_dep_libs(src_dir)
env.Prepend( for l, ld in deplibs:
CPPPATH=[join("$BUILD_DIR", l) for (l, _) in deplibs] env.Append(
) CPPPATH=[join("$BUILD_DIR", l)]
)
# add automatically "utility" dir from the lib (Arduino issue) # add automatically "utility" dir from the lib (Arduino issue)
env.Prepend( if isdir(join(ld, "utility")):
CPPPATH=[ env.Append(
join("$BUILD_DIR", l, "utility") for (l, ld) in deplibs CPPPATH=[join("$BUILD_DIR", l, "utility")]
if isdir(join(ld, "utility")) )
]
)
libs = [] libs = []
for (libname, inc_dir) in deplibs: for (libname, inc_dir) in deplibs:
@ -309,8 +310,8 @@ class InoToCPPConverter(object):
PROTOTYPE_RE = re.compile( PROTOTYPE_RE = re.compile(
r"""^( r"""^(
(?:\s*[a-z_\d]+){1,2} # return type (\s*[a-z_\d]+){1,2} # return type
\s+[a-z_\d]+\s* # name of prototype (\s+[a-z_\d]+\s*) # name of prototype
\([a-z_,\.\*\&\[\]\s\d]*\) # arguments \([a-z_,\.\*\&\[\]\s\d]*\) # arguments
)\s*\{ # must end with { )\s*\{ # must end with {
""", """,
@ -319,7 +320,8 @@ class InoToCPPConverter(object):
DETECTMAIN_RE = re.compile(r"void\s+(setup|loop)\s*\(", re.M | re.I) 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): def __init__(self, nodes):
self.nodes = nodes self.nodes = nodes
@ -334,6 +336,15 @@ class InoToCPPConverter(object):
else: else:
return " " 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): def append_prototypes(self, fname, contents, prototypes):
contents = self.STRIPCOMMENTS_RE.sub(self._replace_comments_callback, contents = self.STRIPCOMMENTS_RE.sub(self._replace_comments_callback,
contents) contents)
@ -358,7 +369,7 @@ class InoToCPPConverter(object):
data = [] data = []
for node in self.nodes: for node in self.nodes:
ino_contents = node.get_text_contents() 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) item = (basename(node.get_path()), ino_contents)
if self.is_main_node(ino_contents): if self.is_main_node(ino_contents):
@ -404,6 +415,38 @@ def ConvertInoToCpp(env):
atexit.register(delete_tmpcpp_file, tmpcpp_file) 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(_): def exists(_):
return True return True
@ -418,4 +461,5 @@ def generate(env):
env.AddMethod(BuildLibrary) env.AddMethod(BuildLibrary)
env.AddMethod(BuildDependentLibraries) env.AddMethod(BuildDependentLibraries)
env.AddMethod(ConvertInoToCpp) env.AddMethod(ConvertInoToCpp)
env.AddMethod(DumpIDEData)
return env return env

View File

@ -3,7 +3,7 @@
import stat import stat
from glob import glob 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 os.path import abspath, basename, isdir, isfile, join
from shutil import copyfile, copytree, rmtree from shutil import copyfile, copytree, rmtree
from tempfile import mkdtemp 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): build_dir, keep_build_dir, project_conf, verbose):
if not src: if not src:
src = environ.get("PLATFORMIO_CI_SRC", "").split(":") src = getenv("PLATFORMIO_CI_SRC", "").split(":")
if not src: if not src:
raise click.BadParameter("Missing argument 'src'") raise click.BadParameter("Missing argument 'src'")

View File

@ -2,7 +2,7 @@
# See LICENSE for details. # See LICENSE for details.
from datetime import datetime from datetime import datetime
from os import chdir, getcwd from os import getcwd
from os.path import getmtime, isdir, join from os.path import getmtime, isdir, join
from shutil import rmtree from shutil import rmtree
from time import time from time import time
@ -28,9 +28,7 @@ from platformio.platforms.base import PlatformFactory
@click.pass_context @click.pass_context
def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
project_dir, verbose): project_dir, verbose):
initial_cwd = getcwd() with util.cd(project_dir):
chdir(project_dir)
try:
config = util.get_project_config() config = util.get_project_config()
if not config.sections(): if not config.sections():
@ -74,8 +72,6 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
if not all(results): if not all(results):
raise exception.ReturnErrorCode() raise exception.ReturnErrorCode()
finally:
chdir(initial_cwd)
class EnvironmentProcessor(object): class EnvironmentProcessor(object):

View File

@ -3,7 +3,6 @@
from email.utils import parsedate_tz from email.utils import parsedate_tz
from math import ceil from math import ceil
from os import environ
from os.path import getsize, join from os.path import getsize, join
from time import mktime from time import mktime
@ -50,7 +49,7 @@ class FileDownloader(object):
f = open(self._destination, "wb") f = open(self._destination, "wb")
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE))) chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
if environ.get("CI") == "true": if util.is_ci():
click.echo("Downloading...") click.echo("Downloading...")
for _ in range(0, chunks): for _ in range(0, chunks):
f.write(next(itercontent)) f.write(next(itercontent))

View File

@ -26,16 +26,16 @@ class ProjectGenerator(object):
return [d for d in listdir(tpls_dir) return [d for d in listdir(tpls_dir)
if isdir(join(tpls_dir, d))] if isdir(join(tpls_dir, d))]
@staticmethod def get_project_env(self):
def get_project_env(): data = {"env_name": "PlatformIO"}
data = {} with util.cd(self.project_dir):
config = util.get_project_config() config = util.get_project_config()
for section in config.sections(): for section in config.sections():
if not section.startswith("env:"): if not section.startswith("env:"):
continue continue
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
return data return data
@util.memoized @util.memoized
@ -44,7 +44,8 @@ class ProjectGenerator(object):
if "env_name" not in envdata: if "env_name" not in envdata:
return None return None
result = util.exec_command( 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']: if result['returncode'] != 0 or '{"includes":' not in result['out']:
return None return None

View File

@ -84,7 +84,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--force run -t clean</value> <value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--force run --target clean</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Command">platformio</value> <value type="QString" key="ProjectExplorer.ProcessStep.Command">platformio</value>
<value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}</value> <value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Process Step</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Process Step</value>
@ -125,7 +125,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--force run -t clean</value> <value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--force run --target clean</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Command">platformio</value> <value type="QString" key="ProjectExplorer.ProcessStep.Command">platformio</value>
<value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}</value> <value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Process Step</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Process Step</value>

View File

@ -5,6 +5,7 @@
"cmd": "cmd":
[ [
"platformio", "platformio",
"--force",
"run" "run"
], ],
"name": "PlatformIO", "name": "PlatformIO",

View File

@ -43,7 +43,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakeBuildCommandLine>platformio run</NMakeBuildCommandLine> <NMakeBuildCommandLine>platformio run</NMakeBuildCommandLine>
<NMakeCleanCommandLine>platformio run -t clean</NMakeCleanCommandLine> <NMakeCleanCommandLine>platformio run --target clean</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>{";".join(defines)}}</NMakePreprocessorDefinitions> <NMakePreprocessorDefinitions>{";".join(defines)}}</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>{{";".join(includes)}}</NMakeIncludeSearchPath> <NMakeIncludeSearchPath>{{";".join(includes)}}</NMakeIncludeSearchPath>
</PropertyGroup> </PropertyGroup>

View File

@ -3,6 +3,7 @@
import re import re
import struct import struct
import sys
from os import remove from os import remove
from os.path import isdir, isfile, join from os.path import isdir, isfile, join
from shutil import rmtree from shutil import rmtree
@ -25,6 +26,13 @@ from platformio.util import get_home_dir
def on_platformio_start(ctx, force): def on_platformio_start(ctx, force):
app.set_session_var("force_option", force) app.set_session_var("force_option", force)
telemetry.on_command(ctx) telemetry.on_command(ctx)
# skip any check operations when upgrade process
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) after_upgrade(ctx)
try: try:

View File

@ -4,9 +4,9 @@
import atexit import atexit
import platform import platform
import re import re
import sys
import threading import threading
import uuid import uuid
from sys import argv as sys_argv
from time import time from time import time
import click import click
@ -91,7 +91,8 @@ class MeasurementProtocol(TelemetryBase):
self['cd4'] = 1 if app.get_setting("enable_prompts") else 0 self['cd4'] = 1 if app.get_setting("enable_prompts") else 0
def _prefill_screen_name(self): 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: if not args:
return return
@ -101,7 +102,7 @@ class MeasurementProtocol(TelemetryBase):
cmd_path = args[:1] cmd_path = args[:1]
self['screen_name'] = " ".join([p.title() for p in cmd_path]) 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): def send(self, hittype):
if not app.get_setting("enable_telemetry"): if not app.get_setting("enable_telemetry"):

View File

@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com> # Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details. # See LICENSE for details.
from os import chmod, environ from os import chmod
from os.path import join, splitext from os.path import join, splitext
from tarfile import open as tarfile_open from tarfile import open as tarfile_open
from time import mktime from time import mktime
@ -9,8 +9,8 @@ from zipfile import ZipFile
import click import click
from platformio import util
from platformio.exception import UnsupportedArchiveType from platformio.exception import UnsupportedArchiveType
from platformio.util import change_filemtime
class ArchiveBase(object): class ArchiveBase(object):
@ -51,7 +51,7 @@ class ZIPArchive(ArchiveBase):
@staticmethod @staticmethod
def preserve_mtime(item, dest_dir): def preserve_mtime(item, dest_dir):
change_filemtime( util.change_filemtime(
join(dest_dir, item.filename), join(dest_dir, item.filename),
mktime(list(item.date_time) + [0]*3) mktime(list(item.date_time) + [0]*3)
) )
@ -81,7 +81,7 @@ class FileUnpacker(object):
raise UnsupportedArchiveType(archpath) raise UnsupportedArchiveType(archpath)
def start(self): def start(self):
if environ.get("CI") == "true": if util.is_ci():
click.echo("Unpacking...") click.echo("Unpacking...")
for item in self._unpacker.get_items(): for item in self._unpacker.get_items():
self._unpacker.extract_item(item, self._dest_dir) self._unpacker.extract_item(item, self._dest_dir)

View File

@ -55,6 +55,18 @@ class AsyncPipe(Thread):
self.join() self.join()
class cd(object):
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): class memoized(object):
''' '''
Decorator. Caches a function's return value each time it is called. Decorator. Caches a function's return value each time it is called.
@ -175,6 +187,10 @@ def change_filemtime(path, time):
os.utime(path, (time, time)) os.utime(path, (time, time))
def is_ci():
return os.getenv("CI", "").lower() == "true"
def exec_command(*args, **kwargs): def exec_command(*args, **kwargs):
result = { result = {
"out": None, "out": None,
@ -246,8 +262,11 @@ def get_logicaldisks():
def get_request_defheaders(): def get_request_defheaders():
return {"User-Agent": "PlatformIO/%s %s" % ( return {"User-Agent": "PlatformIO/%s CI/%d %s" % (
__version__, requests.utils.default_user_agent())} __version__,
1 if is_ci() else 0,
requests.utils.default_user_agent()
)}
def get_api_result(path, params=None, data=None): def get_api_result(path, params=None, data=None):

View File

@ -30,8 +30,7 @@ def test_run(platformio_setup, pioproject_dir):
rmtree(join(pioproject_dir, ".pioenvs")) rmtree(join(pioproject_dir, ".pioenvs"))
result = exec_command( result = exec_command(
["platformio", "run"], ["platformio", "--force", "run", "--project-dir", pioproject_dir]
cwd=pioproject_dir
) )
if result['returncode'] != 0: if result['returncode'] != 0:
pytest.fail(result) pytest.fail(result)

View File

@ -44,9 +44,8 @@ basepython =
py26: python2.6 py26: python2.6
py27: python2.7 py27: python2.7
usedevelop = True usedevelop = True
passenv = *
deps = pytest deps = pytest
setenv =
PLATFORMIO_SETTING_ENABLE_PROMPTS = False
commands = commands =
{envpython} --version {envpython} --version
pip install --egg http://sourceforge.net/projects/scons/files/latest/download pip install --egg http://sourceforge.net/projects/scons/files/latest/download