diff --git a/platformio/platforms/__init__.py b/.coveragerc similarity index 65% rename from platformio/platforms/__init__.py rename to .coveragerc index 0c05c3b0..32d9f345 100644 --- a/platformio/platforms/__init__.py +++ b/.coveragerc @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,3 +11,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +[run] +omit = + platformio/builder/* +source = platformio + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + pragma: no cover + def __repr__ + raise AssertionError + raise NotImplementedError diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 3e4857dd..71b72011 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,14 +4,17 @@ What kind of issue is this? something, or to understand why something isn't working the way you expect it to, use our Community Forums https://community.platformio.org +- [ ] PlatformIO IDE. All issues related to PlatformIO IDE should be reported to appropriate repository + https://github.com/platformio/platformio-atom-ide/issues + +- [ ] Development Platform. All issues related to Development Platform should be reported to appropriate repository. Search it using link below + https://github.com/platformio?query=platform- + - [ ] Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small. -- [ ] PlatformIO IDE. All issues related to PlatformIO IDE should be reported to appropriate repository - https://github.com/platformio/platformio-atom-ide/issues - -- [ ] Bug report. If you’ve found a bug, please provide information below. +- [ ] PlatformIO Core. If you’ve found a bug, please provide an information below. *You can erase any parts of this template not applicable to your Issue.* diff --git a/.gitignore b/.gitignore index 89257136..0a54e681 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ docs/_build dist build .cache +coverage.xml +.coverage +htmlcov diff --git a/.isort.cfg b/.isort.cfg index 907a398d..9ac98225 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,3 +1,3 @@ [settings] line_length=79 -known_third_party=bottle,click,lockfile,pytest,requests,serial,SCons +known_third_party=bottle,click,lockfile,pytest,requests,semantic_version,serial,SCons diff --git a/.pylintrc b/.pylintrc index bdf25c27..66581ace 100644 --- a/.pylintrc +++ b/.pylintrc @@ -20,4 +20,4 @@ confidence= # --disable=W" # disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating -disable=locally-disabled,missing-docstring,invalid-name,too-few-public-methods,redefined-variable-type,import-error,similarities,unsupported-membership-test,unsubscriptable-object,ungrouped-imports +disable=locally-disabled,missing-docstring,invalid-name,too-few-public-methods,redefined-variable-type,import-error,similarities,unsupported-membership-test,unsubscriptable-object,ungrouped-imports,cyclic-import diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 00000000..7bc85964 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,3 @@ +[style] +blank_line_before_nested_class_or_def = true +allow_multiline_lambdas = true diff --git a/.travis.yml b/.travis.yml index 0a418de9..cd1df106 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,42 @@ language: python -python: - - "2.7" -env: - - TOX_ENV=docs - - TOX_ENV=lint - - TOX_ENV=py26 - - TOX_ENV=py27 +matrix: + include: + - os: linux + sudo: false + python: 2.7 + env: TOX_ENV=docs + - os: linux + sudo: false + python: 2.7 + env: TOX_ENV=lint + - os: linux + sudo: required + python: 2.7 + env: TOX_ENV=py27 + - os: osx + language: generic + env: TOX_ENV=py27 install: - git submodule update --init --recursive - - pip install -U pip setuptools tox - - sudo apt-get install -qq lib32z1 lib32ncurses5 lib32bz2-1.0 # temporarily + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip install -U tox; else pip install -U tox; fi + + # temporary hook to fix issue with gcc-pic32 + - if [[ "$TOX_ENV" == "py27" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -qq lib32z1 lib32ncurses5 lib32bz2-1.0; fi script: - tox -e $TOX_ENV +after_success: + - if [[ "$TOX_ENV" == "py27" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tox -e coverage; fi + - if [[ "$TOX_ENV" == "py27" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash <(curl -s https://codecov.io/bash); fi + notifications: + email: false + slack: - secure: ksQmXOP5NVsf8IgoDuxD68Q/YNwDpZuwq0V29h2dxYCr38oYdAkq/Os4LSCs0X6P0cQFf6nC1hM/d+cAvU+SmzcHGxEceHNEGCg3/TAj+68KIwooPU93Lfq1zwdfteZWxANjKlCQy4+wZliHLhL8fvCYgfJww/6qKmqSYleBNM= + rooms: + secure: JD6VGfN4+SLU2CwDdiIOr1VgwD+zbYUCE/srwyGuHavnjIkPItkl6T6Bn8Y4VrU6ysbuKotfdV2TAJJ82ivFbY8BvZBc7FBcYp/AGQ4FaCCV5ySv8RDAcQgdE12oaGzMdODiLqsB85f65zOlAFa+htaXyEiRTcotn6Y2hupatrI= on_failure: always on_success: change diff --git a/HISTORY.rst b/HISTORY.rst index 2cf5ea27..f96d0962 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,115 @@ Release Notes ============= +PlatformIO 3.0 +-------------- + +3.0.0 (2016-09-07) +~~~~~~~~~~~~~~~~~~ + +* `PlatformIO Plus `__ + + + Local and Embedded `Unit Testing `__ + (`issue #408 `_, + `issue #519 `_) + +* Decentralized Development Platforms + + + Development platform manifest "platform.json" and + `open source development platforms `__ + + `Semantic Versioning `__ for platform commands, + development platforms and dependent packages + + Custom package repositories + + External embedded board configuration files, isolated build scripts + (`issue #479 `_) + + Embedded Board compatibility with more than one development platform + (`issue #456 `_) + +* Library Manager 3.0 + + + Project dependencies per build environment using `lib_deps `__ option + (`issue #413 `_) + + `Semantic Versioning `__ for library commands and + dependencies + (`issue #410 `_) + + Multiple library storages: Project's Local, PlatformIO's Global or Custom + (`issue #475 `_) + + Install library by name + (`issue #414 `_) + + Depend on a library using VCS URL (GitHub, Git, ARM mbed code registry, Hg, SVN) + (`issue #498 `_) + + Strict search for library dependencies + (`issue #588 `_) + + Allowed ``library.json`` to specify sources other than PlatformIO's Repository + (`issue #461 `_) + + Search libraries by headers/includes with ``platformio lib search --header`` option + +* New Intelligent Library Build System + + + `Library Dependency Finder `__ + that interprets C/C++ Preprocessor conditional macros with deep search behavior + + Check library compatibility with project environment before building + (`issue #415 `_) + + Control Library Dependency Finder for compatibility using + `lib_compat_mode `__ + option + + Custom library storages/directories with + `lib_extra_dirs `__ option + (`issue #537 `_) + + Handle extra build flags, source filters and build script from + `library.json `__ + (`issue #289 `_) + + Allowed to disable library archiving (``*.ar``) + (`issue #719 `_) + + Show detailed build information about dependent libraries + (`issue #617 `_) + + Support for the 3rd party manifests (Arduino IDE "library.properties" + and ARM mbed "module.json") + +* Removed ``enable_prompts`` setting. Now, all PlatformIO CLI is non-blocking! +* Switched to SSL PlatformIO API +* Renamed ``platformio serialports`` command to ``platformio device`` +* Build System: Attach custom Before/Pre and After/Post actions for targets + (`issue #542 `_) +* Allowed passing custom project configuration options to ``platformio ci`` + and ``platformio init`` commands using ``-O, --project-option``. +* Print human-readable information when processing environments without + ``-v, --verbose`` option + (`issue #721 `_) +* Improved INO to CPP converter + (`issue #659 `_, + `issue #765 `_) +* Added ``license`` field to `library.json `__ + (`issue #522 `_) +* Warn about unknown options in project configuration file ``platformio.ini`` + (`issue #740 `_) +* Fixed wrong line number for INO file when ``#warning`` directive is used + (`issue #742 `_) +* Stopped supporting Python 2.6 + +------ + +* Development platform `Atmel SAM `__ + + + Fixed missing analog ports for Adafruit Feather M0 Bluefruit + (`issue #2 `__) + +* Development platform `Nordic nRF51 `__ + + + Added support for BBC micro:bit board + (`issue #709 `_) + +* Development platform `ST STM32 `__ + + + Added support for BluePill F103C8 board + (`pull #2 `__) + +* Development platform `Teensy `__ + + + Updated Arduino Framework to v1.29 + (`issue #2 `__) + + PlatformIO 2.0 -------------- @@ -1029,8 +1138,7 @@ PlatformIO 0.0 ~~~~~~~~~~~~~~~~~~ * Replaced "dark blue" by "cyan" colour for the texts (`issue #33 `_) -* Added new setting `enable_prompts `_ - and allowed to disable all *PlatformIO* prompts (useful for cloud compilers) +* Added new setting ``enable_prompts`` and allowed to disable all *PlatformIO* prompts (useful for cloud compilers) (`issue #34 `_) * Fixed compilation bug on *Windows* with installed *MSVC* (`issue #18 `_) diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..51b3d166 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ + +lint: + pylint --rcfile=./.pylintrc ./platformio + +isort: + isort -rc ./platformio + isort -rc ./tests + +yapf: + yapf --recursive --in-place platformio/ + +before-commit: isort yapf lint + +clean-docs: + rm -rf docs/_build + +clean: clean-docs + find . -name \*.pyc -delete + find . -name __pycache__ -delete + rm -rf .cache + rm -rf build + rm -rf htmlcov + rm -f .coverage \ No newline at end of file diff --git a/README.rst b/README.rst index a3854318..0505c762 100644 --- a/README.rst +++ b/README.rst @@ -7,6 +7,8 @@ PlatformIO .. image:: https://ci.appveyor.com/api/projects/status/dku0h2rutfj0ctls/branch/develop?svg=true :target: https://ci.appveyor.com/project/ivankravets/platformio :alt: AppVeyor.CI Build Status +.. image:: https://codecov.io/gh/platformio/platformio/branch/develop/graph/badge.svg + :target: https://codecov.io/gh/platformio/platformio .. image:: https://requires.io/github/platformio/platformio/requirements.svg?branch=develop :target: https://requires.io/github/platformio/platformio/requirements/?branch=develop :alt: Requirements Status @@ -19,29 +21,30 @@ PlatformIO .. image:: https://img.shields.io/community/PlatformIO.png :alt: Community Forums :target: https://community.platformio.org -.. image:: https://img.shields.io/donate/PlatformIO.png?color=yellow - :alt: Donate for PlatformIO.Org - :target: http://platformio.org/donate +.. image:: https://img.shields.io/PlatformIO/Plus.png?color=orange + :alt: PlatformIO Plus: Professional solutions for an awesome open source PlatformIO ecosystem + :target: https://pioplus.com - -`Home `_ | -`IDE `_ | +**Quick Links:** `Home Page `_ | +`PlatformIO Plus `_ | +`PlatformIO IDE `_ | `Project Examples `_ | `Docs `_ | -`Twitter `_ | +`Donate `_ | +`Contact Us `_ + +**Social:** `Twitter `_ | `Facebook `_ | `Hackaday `_ | `Bintray `_ | `Community `_ | -`Donate `_ | -`Contact Us `_ .. image:: https://raw.githubusercontent.com/platformio/platformio/develop/docs/_static/platformio-logo.png :target: http://platformio.org `PlatformIO `_ is an open source ecosystem for IoT development. Cross-platform build system and library manager. Continuous and -IDE integration. Arduino and MBED compatible. Ready for Cloud compiling. +IDE integration. Arduino, ESP8266 and ARM mbed compatible * **PlatformIO IDE** - The next-generation integrated development environment for IoT. C/C++ Intelligent Code Completion and Smart Code Linter for the super-fast coding. @@ -66,19 +69,20 @@ TI MSP430 & Tiva, Teensy, Arduino, mbed, libOpenCM3, etc.* .. image:: https://raw.githubusercontent.com/platformio/platformio/develop/docs/_static/platformio-demo-wiring.gif :target: http://platformio.org +* `PlatformIO Plus and professional solutions `_ * `PlatformIO IDE `_ * `Get Started `_ -* `Web 2.0 Library Search `_ +* `Library Search and Registry `_ * `Development Platforms `_ * `Frameworks `_ * `Embedded Boards Explorer `_ -* `Library Manager `_ -* `User Guide `_ -* `Continuous Integration `_ -* `IDE Integration `_ -* `Articles about us `_ -* `FAQ `_ -* `Release Notes `_ +* `Library Manager `_ +* `User Guide `_ +* `Continuous Integration `_ +* `IDE Integration `_ +* `Articles about us `_ +* `FAQ `_ +* `Release Notes `_ Use whenever. *Run everywhere.* ------------------------------- @@ -95,12 +99,12 @@ Embedded Development. *Easier Than Ever.* settings for most popular `Embedded Boards `_. * Colourful `command-line output `_ -* `IDE Integration `_ with +* `IDE Integration `_ with *Arduino, Atom, Eclipse, Emacs, Energia, Qt Creator, Sublime Text, Vim, Visual Studio* -* Cloud compiling and `Continuous Integration `_ +* Cloud compiling and `Continuous Integration `_ with *AppVeyor, Circle CI, Drone, Shippable, Travis CI* -* Built-in `Serial Port Monitor `_ and configurable - `build -flags/-options `_ +* Built-in `Serial Port Monitor `_ and configurable + `build -flags/-options `_ * Automatic **firmware uploading** * Pre-built tool chains, frameworks for the popular `Hardware Platforms `_ @@ -113,10 +117,10 @@ The Missing Library Manager. *It's here!* *PlatformIO Library Manager* is the missing library manager for development platforms which allows you to organize and have up-to-date external libraries. -* Friendly `Command-Line Interface `_ +* Friendly `Command-Line Interface `_ * Modern `Web 2.0 Library Search `_ * Open Source `Library Registry API `_ -* Library Crawler based on `library.json `_ +* Library Crawler based on `library.json `_ specification * Library **dependency management** * Automatic library updating @@ -135,7 +139,7 @@ cross-platform substitute for the classic *Make* utility. * Reliable detection of *build changes* * Improved support for *parallel builds* * Ability to share *built files in a cache* -* Lookup for external libraries which are installed via `Library Manager `_ +* Lookup for external libraries which are installed via `Library Manager `_ .. image:: https://raw.githubusercontent.com/platformio/platformio-web/develop/app/images/platformio-scons-builder.png :target: http://platformio.org @@ -145,9 +149,9 @@ Single source code. *Multiple platforms.* ----------------------------------------- *PlatformIO* allows the developer to compile the same code with different development platforms using only *One Command* -`platformio run `_. +`platformio run `_. This happens due to -`Project Configuration File (platformio.ini) `_ +`Project Configuration File (platformio.ini) `_ where you can setup different environments with specific options (platform type, firmware uploading settings, pre-built framework, build flags and many more). @@ -180,7 +184,7 @@ Frameworks: * `SPL `_ * `WiringPi `_ -For further details, please refer to `What is PlatformIO? `_ +For further details, please refer to `What is PlatformIO? `_ Contributing ------------ @@ -190,7 +194,7 @@ See `contributing guidelines +Copyright 2014-present PlatformIO The PlatformIO is licensed under the permissive Apache 2.0 license, so you can use it in both commercial and personal projects with confidence. diff --git a/appveyor.yml b/appveyor.yml index 845307f6..fe1b1e8f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,3 +11,11 @@ install: test_script: - cmd: tox + +notifications: + - provider: Slack + incoming_webhook: + secure: E9H0SU0Ju7WLDvgxsV8cs3J62T3nTTX7QkEjsczN0Sto/c9hWkVfhc5gGWUkxhlD975cokHByKGJIdwYwCewqOI+7BrcT8U+nlga4Uau7J8= + on_build_success: false + on_build_failure: true + on_build_status_changed: true diff --git a/docs/_static/extra.css b/docs/_static/extra.css index 1d7f3b0b..83ae2147 100644 --- a/docs/_static/extra.css +++ b/docs/_static/extra.css @@ -1,5 +1,5 @@ /** - * Copyright 2014-2016 Ivan Kravets + * Copyright 2014-present PlatformIO * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -262,6 +262,12 @@ nav { visibility: none; } +@media (min-width: 768px) { + .wy-side-scroll { + padding-bottom: 50px; + } +} + .navbar-header .navbar-brand { color: #e0e0e0; background: url("../_static/platformio-logo-xs.png") no-repeat; @@ -292,6 +298,16 @@ nav { } } +.navbar-inverse .navbar-nav > li.nav-pioplus > a, +.navbar-inverse .navbar-nav > li.nav-pioplus > a:visited +{ + color: #ff6600; +} + +.navbar-inverse .navbar-nav > li.nav-pioplus > a:hover { + color: #ff9900; +} + .top-banner { display: block; padding: 10px 20px; diff --git a/docs/_static/pioplus-unit-testing-demo.png b/docs/_static/pioplus-unit-testing-demo.png new file mode 100644 index 00000000..d34dad14 Binary files /dev/null and b/docs/_static/pioplus-unit-testing-demo.png differ diff --git a/docs/_templates/footer.html b/docs/_templates/footer.html index 6c39a60e..6ac869f3 100644 --- a/docs/_templates/footer.html +++ b/docs/_templates/footer.html @@ -27,7 +27,7 @@ diff --git a/docs/articles.rst b/docs/articles.rst index 3ceb7fce..294922c7 100644 --- a/docs/articles.rst +++ b/docs/articles.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -18,11 +18,17 @@ Articles about us If you've written article about PlatformIO and would like it listed on this page, `please edit this page `_. -Here are recent articles about PlatformIO: +Here are recent articles/reviews about PlatformIO: 2016 ^^^^ +* Sep 2, 2016 - **Tinkerman** `ESP8266: Optimizing files for SPIFFS with Gulp `_ +* Aug 28, 2016 - **Tom Parker** `Using the BBC micro:bit with PlatformIO `_ +* Aug 24, 2016 - **Primal Cortex** `Cloud based continuous integration and delivery for IOT using PlatformIO `_ +* Aug 18, 2016 - **Primal Cortex** - `Installing PlatformIO on Arch Linux `_ +* Jul 26, 2016 - **Embedded Systems Laboratory** - `แนะนำการใช้งาน PlatformIO IDE สำหรับบอร์ด Arduino และ ESP8266 (Get started with PlatformIO IDE for Arduino board and ESP8266, Thai) `_ +* Jul 15, 2016 - **Jaime** - `ESP8266 Mobile Rick Roll Captive Portal `_ * Jul 5, 2016 - **Ivan Kravets, Ph.D.** - `Explore the new development instruments for Arduino with PlatformIO ecosystem `_ * Jul 5, 2016 - **Belinda** - `Monte Bianco Arduino Developer Summit `_ * Jul 1, 2016 - **Tam Hanna** - `Mikrocontroller-Gipfel in den Alpen: Arduino Developer Summit, Tag eins (Microcontroller peaks in the Alps: Arduino Developer Summit, Day One, German) `_ @@ -38,18 +44,18 @@ Here are recent articles about PlatformIO: * May 16, 2016 - **Pedro Minatel** - `Controle remoto WiFi com ESP8266 (WiFi remote control using ESP8266, Portuguese) `_ * May 11, 2016 - **Jo Vandeginste** - `Using PlatformIO to compile for Jeelabs' Jeenode Micro `_ * May 08, 2016 - **Radoslaw Bob** - `Touch controlled buzzer (Nodemcu ESP8266) `_ -* May 06, 2016 - **Jean Roux** - `The IoT building blocks I use for my home-automation projects `_ +* May 06, 2016 - **Jean Roux** - `The IoT building blocks I use for my home-automation projects `_ * May 05, 2016 - **Ivan Kravets, Ph.D. / Eclipse Virtual IoT Meetup** - `PlatformIO: a cross-platform IoT solution to build them all! `_ * May 01, 2016 - **Pedro Minatel** - `PlatformIO – Uma alternativa ao Arduino IDE (PlatformIO - An alternative to the Arduino IDE, Portuguese) `_ * Apr 23, 2016 - **Al Williams** - `Hackaday: Atomic Arduino (and Other) Development `_ * Apr 16, 2016 - **Sathittham Sangthong** - `[PlatformIO] มาลองเล่น PlatformIO แทน Arduino IDE กัน (Let's play together with PlatformIO IDE [alternative to Arduino IDE], Thai) `_ -* Apr 15, 2016 - **Daniel Eichhorn** - `ESP8266: Offline Debugging with the Platformio Environment `_ +* Apr 15, 2016 - **Daniel Eichhorn** - `ESP8266: Offline Debugging with the Platformio Environment `_ * Apr 11, 2016 - **Matjaz Trcek** - `Top 5 Arduino integrated development environments `_ * Apr 06, 2016 - **Aleks** - `PlatformIO ausprobiert (Tried PlatformIO, German) `_ * Apr 02, 2016 - **Diego Pinto** - `Você tem coragem de abandonar a IDE do Arduino? PlatformIO + Atom (Do you dare to leave the Arduino IDE? PlatformIO + Atom, Portuguese) `_ * Mar 30, 2016 - **Brandon Cannaday** - `Getting Started with PlatformIO and ESP8266 NodeMcu `_ * Mar 29, 2016 - **Pablo Peñalve** - `PlatformIO + Geany + Raspberry PI, Spanish `_ -* Mar 24, 2016 - **NAzT** - `PlatformIO และการปรับแต่ง เพื่อใช้สำหรับพัฒนา Arduino Library (PlatformIO and advanced development for Arduino Library, Thai) `_ +* Mar 24, 2016 - **NAzT** - `PlatformIO และการปรับแต่ง เพื่อใช้สำหรับพัฒนา Arduino Library (PlatformIO and advanced development for Arduino Library, Thai) `_ * Mar 16, 2016 - **Jakub Skořepa** - `Instalace PlatformIO (PlatformIO IDE Installation, Czech) `_ * Mar 12, 2016 - **Peter Marks** - `PlatformIO, the Arduino IDE for programmers `_ * Mar 12, 2016 - **Richard Arthurs** - `Getting Started With PlatformIO `_ diff --git a/docs/ci/appveyor.rst b/docs/ci/appveyor.rst index 2fc919dd..5a018b29 100644 --- a/docs/ci/appveyor.rst +++ b/docs/ci/appveyor.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -56,7 +56,7 @@ Put ``appveyor.yml`` to the root directory of the GitHub repository. - cmd: pip install -U platformio test_script: - - cmd: platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - cmd: platformio ci --board= --board= --board= For more details as for PlatformIO build process please look into :ref:`cmd_ci` diff --git a/docs/ci/circleci.rst b/docs/ci/circleci.rst index ba6d6932..da331230 100644 --- a/docs/ci/circleci.rst +++ b/docs/ci/circleci.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -49,9 +49,9 @@ guide first. test: override: - - platformio ci path/to/test/file.c --board=TYPE_1 --board=TYPE_2 --board=TYPE_N - - platformio ci examples/file.ino --board=TYPE_1 --board=TYPE_2 --board=TYPE_N - - platformio ci path/to/test/directory --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci path/to/test/file.c --board= --board= --board= + - platformio ci examples/file.ino --board= --board= --board= + - platformio ci path/to/test/directory --board= --board= --board= For more details as for PlatformIO build process please look into :ref:`cmd_ci`. @@ -65,7 +65,7 @@ it), please use ``--lib="."`` option for :ref:`cmd_ci` command .. code-block:: yaml script: - - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci --lib="." --board= --board= --board= Library dependecies ~~~~~~~~~~~~~~~~~~~ @@ -83,11 +83,11 @@ Install dependent library using :ref:`librarymanager` - sudo pip install -U platformio # OneWire Library with ID=1 http://platformio.org/lib/show/1/OneWire - - platformio lib install 1 + - platformio lib -g install 1 test: override: - - platformio ci path/to/test/file.c --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci path/to/test/file.c --board= --board= --board= Manually download dependent library and include in build process via ``--lib`` option ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ Manually download dependent library and include in build process via ``--lib`` o test: override: - - platformio ci path/to/test/file.c --lib="/tmp/OneWire-master" --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci path/to/test/file.c --lib="/tmp/OneWire-master" --board= --board= --board= Custom Build Flags ~~~~~~~~~~~~~~~~~~ @@ -152,14 +152,14 @@ Examples - sudo pip install -U platformio # pre-install PlatformIO development platforms, they will be cached - - platformio platforms install atmelavr atmelsam teensy + - platformio platform install atmelavr atmelsam teensy # # Libraries from PlatformIO Library Registry: # # http://platformio.org/lib/show/416/TinyGPS # http://platformio.org/lib/show/417/SPI4Teensy3 - - platformio lib install 416 417 + - platformio lib -g install 416 417 test: override: diff --git a/docs/ci/drone.rst b/docs/ci/drone.rst index 37d0ac0b..c0537d8e 100644 --- a/docs/ci/drone.rst +++ b/docs/ci/drone.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -51,7 +51,7 @@ Please fill all fields for your project in the Drone control panel: .. code-block:: bash pip install -U platformio - platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + platformio ci --board= --board= --board= .. image:: ../_static/droneci-platformio-integration-1.png diff --git a/docs/ci/index.rst b/docs/ci/index.rst index 93b1b2a6..931f5147 100644 --- a/docs/ci/index.rst +++ b/docs/ci/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/ci/shippable.rst b/docs/ci/shippable.rst index c64e96e9..63daa960 100644 --- a/docs/ci/shippable.rst +++ b/docs/ci/shippable.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -58,7 +58,7 @@ GitHub repository. - pip install -U platformio script: - - platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci --board= --board= --board= For more details as for PlatformIO build process please look into :ref:`cmd_ci` diff --git a/docs/ci/travis.rst b/docs/ci/travis.rst index cb27dd33..a690e5a0 100644 --- a/docs/ci/travis.rst +++ b/docs/ci/travis.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -72,7 +72,7 @@ PlatformIO is written in Python and is recommended to be run within - pip install -U platformio script: - - platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci --board= --board= --board= Then perform steps 1, 2 and 4 from http://docs.travis-ci.com/user/getting-started/ @@ -87,10 +87,10 @@ it), please use ``--lib="."`` option for :ref:`cmd_ci` command .. code-block:: yaml script: - - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci --lib="." --board= --board= --board= -Library dependecies -~~~~~~~~~~~~~~~~~~~ +Library dependencies +~~~~~~~~~~~~~~~~~~~~ There 2 options to test source code with dependent libraries: @@ -106,7 +106,7 @@ Install dependent library using :ref:`librarymanager` # Libraries from PlatformIO Library Registry: # # http://platformio.org/lib/show/1/OneWire - - platformio lib install 1 + - platformio lib -g install 1 Manually download dependent library and include in build process via ``--lib`` option ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ Manually download dependent library and include in build process via ``--lib`` o - unzip /tmp/onewire_source.zip -d /tmp/ script: - - platformio ci --lib="/tmp/OneWire-master" --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + - platformio ci --lib="/tmp/OneWire-master" --board= --board= --board= Custom Build Flags ~~~~~~~~~~~~~~~~~~ @@ -189,7 +189,7 @@ Examples # # http://platformio.org/lib/show/416/TinyGPS # http://platformio.org/lib/show/417/SPI4Teensy3 - - platformio lib install 416 417 + - platformio lib -g install 416 417 script: - platformio ci --board=uno --board=teensy31 --board=due --lib="." @@ -260,7 +260,7 @@ Examples # Libraries from PlatformIO Library Registry: # # http://platformio.org/lib/show/416/TinyGPS - - platformio lib install 416 421 422 + - platformio lib -g install 416 421 422 script: - platformio ci --lib="." --board=uno --board=teensy20pp $PLATFORMIO_CI_EXTRA_ARGS diff --git a/docs/conf.py b/docs/conf.py index 2a3116cf..5f9474e6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,7 +45,7 @@ master_doc = 'index' # General information about the project. project = u'PlatformIO' -copyright = u'2014-2016, Ivan Kravets' +copyright = u'2014-present, PlatformIO' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -199,7 +199,7 @@ latex_elements = { # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'PlatformIO.tex', u'PlatformIO Documentation', - u'Ivan Kravets', 'manual'), + u'PlatformIO', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -229,7 +229,7 @@ latex_documents = [ # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'platformio', u'PlatformIO Documentation', - [u'Ivan Kravets'], 1) + [u'PlatformIO'], 1) ] # If true, show URL addresses after external links. @@ -243,7 +243,7 @@ man_pages = [ # dir menu entry, description, category) texinfo_documents = [ ('index', 'PlatformIO', u'PlatformIO Documentation', - u'Ivan Kravets', 'PlatformIO', 'One line description of project.', + u'PlatformIO', 'PlatformIO', 'One line description of project.', 'Miscellaneous'), ] diff --git a/docs/demo.rst b/docs/demo.rst index 28dcc084..b44a2c69 100644 --- a/docs/demo.rst +++ b/docs/demo.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -41,11 +41,11 @@ Platform Manager Used in demo ~~~~~~~~~~~~ -1. :ref:`userguide_platforms` -2. :ref:`cmd_platforms_list` command -3. :ref:`platformio platforms search avr ` command -4. :ref:`platformio platforms show teensy ` command -5. :ref:`cmd_platforms_update` command. +1. :ref:`userguide_platform` +2. :ref:`cmd_platform_list` command +3. :ref:`platformio platform search avr ` command +4. :ref:`platformio platform show teensy ` command +5. :ref:`cmd_platform_update` command. Library Manager --------------- diff --git a/docs/envvars.rst b/docs/envvars.rst index e9316c64..7749e9ce 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -35,8 +35,8 @@ PlatformIO handles ``CI`` variable which is setup by `Continuous Integration `_ (Travis, Circle and etc.) systems. PlatformIO uses it to disable prompts and progress bars. In other words, -``CI=true`` automatically setup :envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS` to -``false`` and :envvar:`PLATFORMIO_DISABLE_PROGRESSBAR` to ``true``. +``CI=true`` automatically setup :envvar:`PLATFORMIO_DISABLE_PROGRESSBAR` to +``true``. .. envvar:: PLATFORMIO_FORCE_COLOR @@ -57,6 +57,10 @@ Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_dir`. Allows to override :ref:`projectconf` option :ref:`projectconf_pio_lib_dir`. +.. envvar:: PLATFORMIO_LIBDEPS_DIR + +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_libdeps_dir`. + .. envvar:: PLATFORMIO_SRC_DIR Allows to override :ref:`projectconf` option :ref:`projectconf_pio_src_dir`. @@ -69,6 +73,10 @@ Allows to override :ref:`projectconf` option :ref:`projectconf_pio_envs_dir`. Allows to override :ref:`projectconf` option :ref:`projectconf_pio_data_dir`. +.. envvar:: PLATFORMIO_TEST_DIR + +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_test_dir`. + Building -------- @@ -103,6 +111,10 @@ Allows to set :ref:`projectconf` option :ref:`projectconf_src_filter`. Allows to set :ref:`projectconf` option :ref:`projectconf_extra_script`. +.. envvar:: PLATFORMIO_LIB_EXTRA_DIRS + +Allows to set :ref:`projectconf` option :ref:`projectconf_lib_extra_dirs`. + Uploading --------- @@ -142,10 +154,15 @@ Allows to override setting :ref:`setting_check_platformio_interval`. Allows to override setting :ref:`setting_check_platforms_interval`. -.. envvar:: PLATFORMIO_SETTING_ENABLE_PROMPTS - -Allows to override setting :ref:`setting_enable_prompts`. - .. envvar:: PLATFORMIO_SETTING_ENABLE_TELEMETRY Allows to override setting :ref:`setting_enable_telemetry`. + +.. envvar:: PLATFORMIO_SETTING_FORCE_VERBOSE + +Allows to override setting :ref:`setting_force_verbose`. + + +.. envvar:: PLATFORMIO_SETTING_DISABLE_SSL + +Allows to override setting :ref:`setting_disable_ssl`. diff --git a/docs/faq.rst b/docs/faq.rst index 663c108f..8e054883 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -68,6 +68,13 @@ PlatformIO IDE Please refer to :ref:`PlatformIO IDE Frequently Asked Questions `. +Before/Pre and After/Post build actions +--------------------------------------- + +PlatformIO Build System has rich API that allows to attach different pre-/post +actions (hooks). See features of :ref:`projectconf_extra_script` option for +:ref:`projectconf`. + .. _faq_troubleshooting: Troubleshooting @@ -132,21 +139,6 @@ Please upgrade *SetupTools* package: Miscellaneous ~~~~~~~~~~~~~ -.. _faq_troubleshooting_pioblocksprompt: - -PlatformIO blocks command execution using user prompt -''''''''''''''''''''''''''''''''''''''''''''''''''''' - -If you are going to run *PlatformIO* from **subprocess**, you **MUST -DISABLE** all prompts. It will allow you to avoid blocking. -There are a few options: - -- using :option:`platformio --force` option before each command -- using environment variable :envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS=No ` -- disable global setting ``enable_prompts`` via :ref:`cmd_settings` command -- masking under Continuous Integration system via environment variable - :envvar:`CI=true `. - Serial does not work with panStampAVR board ''''''''''''''''''''''''''''''''''''''''''' @@ -155,12 +147,6 @@ Answered in `issue #144 `_ -* `#331: Unable to use MySensors library `_ - ARM toolchain: cc1plus: error while loading shared libraries '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index b16c12d6..d53926b3 100644 --- a/docs/frameworks/arduino.rst +++ b/docs/frameworks/arduino.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -33,7 +33,7 @@ Platforms * - :ref:`platform_atmelsam` - Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB to 2MB of Flash including a rich peripheral and feature mix. - * - :ref:`platform_espressif` + * - :ref:`platform_espressif8266` - Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications. * - :ref:`platform_intel_arc32` @@ -151,7 +151,7 @@ Adafruit * - ``protrinket3ftdi`` - `Adafruit Pro Trinket 3V/12MHz (FTDI) `_ - ATMEGA328P - - 16 MHz + - 12 MHz - 32 Kb - 2 Kb diff --git a/docs/frameworks/cmsis.rst b/docs/frameworks/cmsis.rst index 7520cd94..394c652e 100644 --- a/docs/frameworks/cmsis.rst +++ b/docs/frameworks/cmsis.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/cmsis_extra.rst b/docs/frameworks/cmsis_extra.rst index d57aff1a..fb8711ce 100644 --- a/docs/frameworks/cmsis_extra.rst +++ b/docs/frameworks/cmsis_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/energia.rst b/docs/frameworks/energia.rst index 4f9a2594..5235ee76 100644 --- a/docs/frameworks/energia.rst +++ b/docs/frameworks/energia.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/index.rst b/docs/frameworks/index.rst index 56a5f532..dc925667 100644 --- a/docs/frameworks/index.rst +++ b/docs/frameworks/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/libopencm3.rst b/docs/frameworks/libopencm3.rst index 9822bc97..ea45d299 100644 --- a/docs/frameworks/libopencm3.rst +++ b/docs/frameworks/libopencm3.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/libopencm3_extra.rst b/docs/frameworks/libopencm3_extra.rst index f0bc221a..54f9050b 100644 --- a/docs/frameworks/libopencm3_extra.rst +++ b/docs/frameworks/libopencm3_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/mbed.rst b/docs/frameworks/mbed.rst index df5d4c00..fb45d9a6 100644 --- a/docs/frameworks/mbed.rst +++ b/docs/frameworks/mbed.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -266,6 +266,26 @@ Freescale - 256 Kb - 32 Kb +Generic +~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``bluepill_f103c8`` + - `BluePill F103C8 `_ + - STM32F103C8T6 + - 72 MHz + - 64 Kb + - 20 Kb + JKSoft ~~~~~~ diff --git a/docs/frameworks/mbed_extra.rst b/docs/frameworks/mbed_extra.rst index b073db35..4da14956 100644 --- a/docs/frameworks/mbed_extra.rst +++ b/docs/frameworks/mbed_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/simba.rst b/docs/frameworks/simba.rst index 699e38be..99c80e16 100644 --- a/docs/frameworks/simba.rst +++ b/docs/frameworks/simba.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -33,7 +33,7 @@ Platforms * - :ref:`platform_atmelsam` - Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB to 2MB of Flash including a rich peripheral and feature mix. - * - :ref:`platform_espressif` + * - :ref:`platform_espressif8266` - Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications. Boards diff --git a/docs/frameworks/simba_extra.rst b/docs/frameworks/simba_extra.rst index 40b700ee..aa4c7298 100755 --- a/docs/frameworks/simba_extra.rst +++ b/docs/frameworks/simba_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/spl.rst b/docs/frameworks/spl.rst index 54fbe5e5..d9203e8b 100644 --- a/docs/frameworks/spl.rst +++ b/docs/frameworks/spl.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/spl_extra.rst b/docs/frameworks/spl_extra.rst index 15b14696..f84cff83 100644 --- a/docs/frameworks/spl_extra.rst +++ b/docs/frameworks/spl_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/wiringpi.rst b/docs/frameworks/wiringpi.rst index c973dbd8..93febf97 100644 --- a/docs/frameworks/wiringpi.rst +++ b/docs/frameworks/wiringpi.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/frameworks/wiringpi_extra.rst b/docs/frameworks/wiringpi_extra.rst index e82a29bc..a0a33ec8 100644 --- a/docs/frameworks/wiringpi_extra.rst +++ b/docs/frameworks/wiringpi_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/history.rst b/docs/history.rst index 08e44848..9c0c0f45 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/ide.rst b/docs/ide.rst index 63c3469f..f41e3643 100644 --- a/docs/ide.rst +++ b/docs/ide.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/ide/_platformio_ide_extra.rst b/docs/ide/_platformio_ide_extra.rst index c762c1b1..cf446adf 100644 --- a/docs/ide/_platformio_ide_extra.rst +++ b/docs/ide/_platformio_ide_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/ide/atom.rst b/docs/ide/atom.rst index 09c6692c..dc907b24 100644 --- a/docs/ide/atom.rst +++ b/docs/ide/atom.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -49,7 +49,7 @@ It's built on top of `GitHub's Atom "hackable" text editor `_. If you have already Atom installed, please install `PlatformIO IDE for Atom package `_. .. note:: - You don't need to install PlatformIO CLI seprately to system. + You don't need to install PlatformIO CLI separately to system. PlatformIO CLI is built into PlatformIO IDE and you will be able to use it within PlatformIO IDE Terminal. @@ -95,9 +95,9 @@ then install it and restart Atom: - **Other Systems**: Download the latest `Clang for the other systems `_. .. warning:: - The libraries which are added/installed after initializing process will - not be reflected in code linter. You need ``Menu: PlatformIO > - Rebuild C/C++ Project Index (Autocomplete, Linter)``. + If some libraries are not visible in :ref:`ide_atom` and Code Completion or + Code Linting does not work properly, please perform ``Menu: PlatformIO > + Rebuild C/C++ Project Index (Autocomplete, Linter)`` 3. IDE Installation ~~~~~~~~~~~~~~~~~~~ @@ -337,9 +337,9 @@ automatically created and preconfigured when you initialize project using ``Menu: PlatformIO > Initialize new PlatformIO Project or update existing...``. .. warning:: - The libraries which are added/installed after initializing process will - not be reflected in code linter. You need ``Menu: PlatformIO > - Rebuild C/C++ Project Index (Autocomplete, Linter)``. + If some libraries are not visible in :ref:`ide_atom` and Code Completion or + Code Linting does not work properly, please perform ``Menu: PlatformIO > + Rebuild C/C++ Project Index (Autocomplete, Linter)`` .. error:: @@ -381,11 +381,11 @@ For example, we have the next ``Demo.ino`` file: .. code-block:: cpp - void function setup () { + void setup () { someFunction(13); } - void function loop() { + void loop() { delay(1000); } @@ -406,11 +406,11 @@ The final ``Demo.cpp``: void someFunction(int num); - void function setup () { + void setup () { someFunction(13); } - void function loop() { + void loop() { delay(1000); } @@ -439,6 +439,11 @@ To force Smart Code Linter to use Arduino files as C++ please 2. Perform all steps from :ref:`ide_atom_knownissues_sclarduino_manually` (without renaming to ``.cpp``). +Arch Linux: PlatformIO IDE Terminal issue +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Please read this article `Installing PlatformIO on Arch Linux `_. + .. _ide_atom_faq: Frequently Asked Questions @@ -478,6 +483,8 @@ package and `C/C++ Uncrustify Code Beautifier `_ +* Jul 26, 2016 - **Embedded Systems Laboratory** - `แนะนำการใช้งาน PlatformIO IDE สำหรับบอร์ด Arduino และ ESP8266 (Get started with PlatformIO IDE for Arduino board and ESP8266, Thai) `_ * May 30, 2016 - **Ron Moerman** - `IoT Development with PlatformIO `_ * May 01, 2016 - **Pedro Minatel** - `PlatformIO – Uma alternativa ao Arduino IDE (PlatformIO - An alternative to the Arduino IDE, Portuguese) `_ * Apr 23, 2016 - **Al Williams** - `Hackaday: Atomic Arduino (and Other) Development `_ diff --git a/docs/ide/clion.rst b/docs/ide/clion.rst index 387dad92..185f503e 100644 --- a/docs/ide/clion.rst +++ b/docs/ide/clion.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,12 +31,12 @@ page for more detailed information. Integration ----------- -Choose board ``type`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide clion --board %TYPE% + platformio init --ide clion --board # For example, generate project for Arduino UNO platformio init --ide clion --board uno diff --git a/docs/ide/codeblocks.rst b/docs/ide/codeblocks.rst index 04819998..23df9db1 100644 --- a/docs/ide/codeblocks.rst +++ b/docs/ide/codeblocks.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -30,12 +30,12 @@ CodeBlocks IDE can be downloaded from `here `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide codeblocks --board %TYPE% + platformio init --ide codeblocks --board # For example, generate project for Arduino UNO platformio init --ide codeblocks --board uno diff --git a/docs/ide/eclipse.rst b/docs/ide/eclipse.rst index 6f889b6b..3d21ea09 100644 --- a/docs/ide/eclipse.rst +++ b/docs/ide/eclipse.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -35,12 +35,12 @@ page for more detailed information. Integration ----------- -Choose board ``type`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide eclipse --board %TYPE% + platformio init --ide eclipse --board # For example, generate project for Arduino UNO platformio init --ide eclipse --board uno diff --git a/docs/ide/emacs.rst b/docs/ide/emacs.rst index ef402dfb..fbbc108d 100644 --- a/docs/ide/emacs.rst +++ b/docs/ide/emacs.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -45,12 +45,12 @@ Code completion can optionally be provided by installing `irony-mode `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide emacs --board %TYPE% + platformio init --ide emacs --board There are 6 predefined targets for building. diff --git a/docs/ide/netbeans.rst b/docs/ide/netbeans.rst index 432ddb26..a44a3311 100644 --- a/docs/ide/netbeans.rst +++ b/docs/ide/netbeans.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -33,12 +33,12 @@ install the C/C++ development plugins). Integration ----------- -Choose board ``type`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide netbeans --board %TYPE% + platformio init --ide netbeans --board # For example, generate project for Arduino UNO platformio init --ide netbeans --board uno diff --git a/docs/ide/qtcreator.rst b/docs/ide/qtcreator.rst index a84c8875..42df4feb 100644 --- a/docs/ide/qtcreator.rst +++ b/docs/ide/qtcreator.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -35,12 +35,12 @@ Integration Project Generator ^^^^^^^^^^^^^^^^^ -Choose board ``type`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide qtcreator --board %TYPE% + platformio init --ide qtcreator --board # For example, generate project for Arduino UNO platformio init --ide qtcreator --board uno @@ -165,14 +165,16 @@ Copy the source code which is described below to file ``main.c``. Edit the content to match the code described below. -.. code-block:: none +.. code-block:: ini - # - # PlatformIO Project Configuration File - # - # Please make sure to read documentation with examples first - # http://docs.platformio.org/en/stable/projectconf.html - # + ; PlatformIO Project Configuration File + ; + ; Build options: build flags, source filter, extra scripting + ; Upload options: custom port, speed and extra flags + ; Library options: dependencies, extra library storages + ; + ; Please visit documentation for the other options and examples + ; http://docs.platformio.org/en/stable/projectconf.html [env:arduino_uno] platform = atmelavr diff --git a/docs/ide/sublimetext.rst b/docs/ide/sublimetext.rst index feaa5f3a..3589287d 100644 --- a/docs/ide/sublimetext.rst +++ b/docs/ide/sublimetext.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -42,12 +42,12 @@ steps and documentation. Project Generator ^^^^^^^^^^^^^^^^^ -Choose board ``type`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide sublimetext --board %TYPE% + platformio init --ide sublimetext --board # For example, generate project for Arduino UNO platformio init --ide sublimetext --board uno @@ -164,14 +164,16 @@ Let's create new file named ``main.c`` using ``Menu: File > New File`` or shortc 2. Project Configuration File named ``platformio.ini`` must be located in the project root directory. Copy the source code which is described below to it. -.. code-block:: none +.. code-block:: ini - # - # PlatformIO Project Configuration File - # - # Please make sure to read documentation with examples first - # http://docs.platformio.org/en/stable/projectconf.html - # + ; PlatformIO Project Configuration File + ; + ; Build options: build flags, source filter, extra scripting + ; Upload options: custom port, speed and extra flags + ; Library options: dependencies, extra library storages + ; + ; Please visit documentation for the other options and examples + ; http://docs.platformio.org/en/stable/projectconf.html [env:arduino_uno] platform = atmelavr diff --git a/docs/ide/vim.rst b/docs/ide/vim.rst index 02a09733..c6fc368f 100644 --- a/docs/ide/vim.rst +++ b/docs/ide/vim.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/ide/visualstudio.rst b/docs/ide/visualstudio.rst index e7008e92..7848e6cf 100644 --- a/docs/ide/visualstudio.rst +++ b/docs/ide/visualstudio.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -35,12 +35,12 @@ Integration Project Generator ^^^^^^^^^^^^^^^^^ -Choose board ``type`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ +Choose board ``ID`` using :ref:`cmd_boards` or `Embedded Boards Explorer `_ command and generate project via :option:`platformio init --ide` command: .. code-block:: shell - platformio init --ide sublimetext --board %TYPE% + platformio init --ide sublimetext --board # For example, generate project for Arduino UNO platformio init --ide visualstudio --board uno @@ -124,14 +124,16 @@ Copy the source code which is described below to file ``main.cpp``. Copy the source code which is described below to it. -.. code-block:: none +.. code-block:: ini - # - # PlatformIO Project Configuration File - # - # Please make sure to read documentation with examples first - # http://docs.platformio.org/en/stable/projectconf.html - # + ; PlatformIO Project Configuration File + ; + ; Build options: build flags, source filter, extra scripting + ; Upload options: custom port, speed and extra flags + ; Library options: dependencies, extra library storages + ; + ; Please visit documentation for the other options and examples + ; http://docs.platformio.org/en/stable/projectconf.html [env:arduino_uno] platform = atmelavr diff --git a/docs/index.rst b/docs/index.rst index ce0d088c..3b006919 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -13,7 +13,7 @@ PlatformIO is an open source ecosystem for IoT development ========================================================== **Cross-platform build system and library manager. Continuous and IDE -integration. Arduino and MBED compatible. Ready for Cloud compiling.** +integration. Arduino, ESP8266 and ARM mbed compatible.** * **PlatformIO IDE** - The next-generation integrated development environment for IoT. C/C++ Intelligent Code Completion and Smart Code Linter for the super-fast coding. @@ -35,9 +35,10 @@ integration. Arduino and MBED compatible. Ready for Cloud compiling.** Silicon Labs EFM32, ST STM32, TI MSP430 & Tiva, Teensy, Arduino, mbed, libOpenCM3, etc.* -* `Website `_ +* `Home Page `_ +* `PlatformIO Plus and professional solutions `_ * :ref:`ide_atom` -* `Web 2.0 Library Search `_ | +* `Library Search and Registry `_ | `Embedded Boards Explorer `_ * `Project Examples `_ * `Source Code `_ | @@ -55,7 +56,7 @@ Embedded Development. *Easier Than Ever.* * :ref:`IDE Integration ` with *Arduino, Atom, CLion, Eclipse, Emacs, Energia, Qt Creator, Sublime Text, Vim, Visual Studio* * Cloud compiling and :ref:`ci` with *AppVeyor, Circle CI, Drone, Shippable, Travis CI* -* Built-in :ref:`Serial Port Monitor ` and +* Built-in :ref:`Serial Port Monitor ` and configurable build :ref:`-flags/-options ` * Pre-built toolchains, :ref:`frameworks` for the :ref:`platforms` @@ -112,12 +113,19 @@ Contents frameworks/index platforms/custom_platform_and_board +.. toctree:: + :caption: PlatformIO Plus + :maxdepth: 3 + + plus/unit-testing + .. toctree:: :caption: Library Manager :maxdepth: 2 Quickstart User Guide + librarymanager/ldf librarymanager/config librarymanager/creating @@ -135,3 +143,5 @@ Contents articles FAQ history + migration + diff --git a/docs/installation.rst b/docs/installation.rst index a74cca4e..81af129a 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -200,11 +200,6 @@ To revert to the latest stable version Troubleshooting --------------- -.. warning:: - If you are going to run *PlatformIO* from **subprocess**, you - :ref:`MUST DISABLE ` all prompts. - It will allow you to avoid blocking. - .. note:: **Linux OS**: Don't forget to install "udev" rules file `99-platformio-udev.rules `_ (an instruction is located in the file). diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index c56d74ed..67a5e6bb 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -22,10 +22,11 @@ to keep project in own structure and define: * examples list * compatible frameworks and platforms * library dependencies +* advanced build settings PlatformIO Library Crawler uses ``library.json`` manifest to extract -source code from developer's location and keeps cleaned library in own -Library Storage. +source code from developer's location and keeps a cleaned library in own +Library Registry. A data in ``library.json`` should be represented in `JSON-style `_ via @@ -138,7 +139,7 @@ Examples: *Required* if :ref:`libjson_downloadurl` field is not defined | Type: ``Object`` -The repository in which the source code can be found. The field consists for the +The repository in which the source code can be found. The field consists of the next items: * ``type`` the only "git", "hg" or "svn" are supported @@ -221,6 +222,21 @@ Example: }, "version": "1.0.0" + +``license`` +----------- + +*Optional* | Type: ``String`` + +A license of the library. You can check +`the full list of SPDX license IDs `_. Ideally you +should pick one that is `OSI `_ +approved. + +.. code-block:: javascript + + "license": "Apache-2.0" + .. _libjson_downloadurl: ``downloadUrl`` @@ -246,27 +262,40 @@ Example with fixed release/tag on GitHub: See more ``library.json`` :ref:`library_creating_examples`. -.. _libjson_url: - -``url`` -------- +``homepage`` +------------ *Optional* | Type: ``String`` | Max. Length: 255 Home page of library (if is different from :ref:`libjson_repository` url). -.. _libjson_include: +.. _libjson_export: + +``export`` +---------- + +*Optional* | Type: ``Object`` + +Explain PlatformIO Library Crawler which content from the repository/archive +should be exported as "source code" of the library. This option is useful if +need to exclude extra data (test code, docs, images, PDFs, etc). It allows to +reduce size of the final archive. + +Possible options: + +.. contents:: + :local: ``include`` ------------ +~~~~~~~~~~~ *Optional* | Type: ``String`` or ``Array`` | `Glob Pattern `_ -If :ref:`libjson_include` field is a type of ``String``, then -|PIOAPICR| will recognize it like a "relative path inside -repository/archive to library source code". See example below where the only +If ``include`` field is a type of ``String``, then |PIOAPICR| will recognize +it like a "relative path inside repository/archive to library source code". +See example below where the only source code from the relative directory ``LibrarySourceCodeHere`` will be included. @@ -274,21 +303,23 @@ included. "include": "some/child/dir/LibrarySourceCodeHere" -If :ref:`libjson_include` field is a type of ``Array``, then -|PIOAPICR| firstly will apply :ref:`libjson_exclude` filter and -then include only directories/files which match with :ref:`libjson_include` -patterns. +If ``include`` field is a type of ``Array``, then |PIOAPICR| firstly will +apply ``exclude`` filter and then include only directories/files +which match with ``include`` patterns. Example: .. code-block:: javascript - "include": - [ - "dir/*.[ch]pp", - "dir/examples/*", - "*/*/*.h" - ] + "export": { + "include": + [ + "dir/*.[ch]pp", + "dir/examples/*", + "*/*/*.h" + ] + } + Pattern Meaning @@ -308,16 +339,14 @@ Pattern Meaning See more ``library.json`` :ref:`library_creating_examples`. -.. _libjson_exclude: ``exclude`` ------------ +~~~~~~~~~~~ *Optional* | Type: ``String`` or ``Array`` | `Glob Pattern `_ -Exclude the directories and files which match with :ref:`libjson_exclude` -patterns. +Exclude the directories and files which match with ``exclude`` patterns. .. _libjson_frameworks: @@ -367,10 +396,26 @@ A list of dependent libraries. They will be installed automatically with Allowed requirements for dependent library: * ``name`` | Type: ``String`` +* ``version`` | Type: ``String`` * ``authors`` | Type: ``String`` or ``Array`` * ``frameworks`` | Type: ``String`` or ``Array`` * ``platforms`` | Type: ``String`` or ``Array`` +The ``version`` supports `Semantic Versioning `_ ( +``..``) and can take any of the following forms: + +* ``0.1.2`` - an exact version number. Use only this exact version +* ``^0.1.2`` - any compatible version (exact version for ``0.x.x`` versions +* ``~0.1.2`` - any version with the same major and minor versions, and an + equal or greater patch version +* ``>0.1.2`` - any version greater than ``0.1.2``. ``>=``, ``<``, and ``<=`` + are also possible +* ``>0.1.0,!=0.2.0,<0.3.0`` - any version greater than ``0.1.0``, not equal to + ``0.2.0`` and less than ``0.3.0`` + +The rest possible values including VCS repository URLs are documented in +:ref:`cmd_lib_install` command. + Example: .. code-block:: javascript @@ -387,17 +432,30 @@ Example: }, { "name": "Library-Bar", - "frameworks": "FrameworkFoo, FrameworkBar" + "version": "~1.2.3" + }, + { + "name": "lib-from-repo", + "version": "https://github.com/user/package.git#1.2.3" } ] +A short definition of dependencies is allowed: + +.. code-block:: javascript + + "dependencies": { + "mylib": "1.2.3", + "lib-from-repo": "githubuser/package" + } + See more ``library.json`` :ref:`library_creating_examples`. .. _libjson_examples: ``examples`` ----------------- +------------ *Optional* | Type: ``String`` or ``Array`` | `Glob Pattern `_ @@ -407,9 +465,141 @@ A list of example patterns. This field is predefined with default value: .. code-block:: javascript "examples": [ + "[Ee]xamples/*.c", + "[Ee]xamples/*.cpp", + "[Ee]xamples/*.ino", + "[Ee]xamples/*.pde", "[Ee]xamples/*/*.c", "[Ee]xamples/*/*.cpp", - "[Ee]xamples/*/*.h", "[Ee]xamples/*/*.ino", - "[Ee]xamples/*/*.pde" + "[Ee]xamples/*/*.pde", + "[Ee]xamples/*/*/*.c", + "[Ee]xamples/*/*/*.cpp", + "[Ee]xamples/*/*/*.ino", + "[Ee]xamples/*/*/*.pde" ] + + +.. _libjson_build: + +``build`` +--------- + +*Optional* | Type: ``Object`` + +Specify advanced settings, options and flags for the build system. Possible +options: + +.. contents:: + :local: + +``flags`` +~~~~~~~~~ + +*Optional* | Type: ``String`` or ``Array`` + +Extra flags to control preprocessing, compilation, assembly and linking +processes. More details :ref:`projectconf_build_flags`. + +``unflags`` +~~~~~~~~~~~ + +*Optional* | Type: ``String`` or ``Array`` + +Remove base/initial flags which were set by development platform. More +details :ref:`projectconf_build_unflags`. + +``srcFilter`` +~~~~~~~~~~~~~ + +*Optional* | Type: ``String`` or ``Array`` + +Specify which source files should be included/excluded from build process. +More details :ref:`projectconf_src_filter`. + +``extraScript`` +~~~~~~~~~~~~~~~ + +*Optional* | Type: ``String`` + +Launch extra script before build process. +More details :ref:`projectconf_extra_script`. + +``libArchive`` +~~~~~~~~~~~~~~ + +*Optional* | Type: ``Boolean`` + +Archive object files to Static Library. This is default behavior of PlatformIO +Build System (``"libArchive": true``). + +``libLDFMode`` +~~~~~~~~~~~~~~ + +*Optional* | Type: ``Integer`` + +Specify Library Dependency Finder Mode. See :ref:`ldf_mode` for details. + +**Examples** + +1. Custom macros/defines + +.. code-block:: javascript + + "build": { + "flags": "-D MYLIB_REV=0.1.2 -DRELEASE" + } + +2. Extra includes for C preprocessor + +.. code-block:: javascript + + "build": { + "flags": [ + "-I inc", + "-I inc/target_x13" + ] + } + +3. Force to use ``C99`` standard instead of ``C11`` + +.. code-block:: javascript + + "build": { + "unflags": "-std=gnu++11", + "flags": "-std=c99" + } + +4. Build source files (``c, cpp, h``) at the top level of the library + +.. code-block:: javascript + + "build": { + "srcFilter": [ + "+<*.c>", + "+<*.cpp>", + "+<*.h>" + ] + } + + +5. Extend PlatformIO Build System with own extra script + +.. code-block:: javascript + + "build": { + "extraScript": "generate_headers.py" + } + +``generate_headers.py`` + +.. code-block:: python + + Import('env') + # print env.Dump() + env.Append( + CPPDEFINES=["HELLO=WORLD", "TAG=1.2.3", "DEBUG"], + CPPPATH=["inc", "inc/devices"] + ) + + # some python code that generates header files "on-the-fly" diff --git a/docs/librarymanager/creating.rst b/docs/librarymanager/creating.rst index 2fe3dbbd..8bdbf5b9 100644 --- a/docs/librarymanager/creating.rst +++ b/docs/librarymanager/creating.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -32,9 +32,8 @@ There are a several ways how to share your library with the whole world (see `examples `_). You can hold a lot of libraries (split into separated folders) inside one of -the repository/archive. In this case please use :ref:`libjson_include` -field to specify the relative path to your library's source code. - +the repository/archive. In this case, you need to specify ``include`` option of +:ref:`libjson_export` field to relative path to your library's source code. At GitHub ^^^^^^^^^ @@ -132,7 +131,9 @@ of **required** fields in the :ref:`library_config` will look like: }, "version": "2.2", "downloadUrl": "http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip", - "include": "OneWire", + "export": { + "include": "OneWire" + }, "frameworks": "arduino", "platforms": "atmelavr" } diff --git a/docs/librarymanager/index.rst b/docs/librarymanager/index.rst index 8a935663..52d8ec87 100644 --- a/docs/librarymanager/index.rst +++ b/docs/librarymanager/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -14,13 +14,50 @@ Library Manager =============== -*PlatformIO Library Manager* allows you to organize external embedded libraries. -You can search for new libraries via +*PlatformIO Library Manager* is a tool for managing libraries of +`PlatformIO Registry `__ and VCS repositories (Git, +Hg, SVN). It makes it exceedingly simple to find, install and keep libraries +up-to-date. PlatformIO Library Manager supports +`Semantic Versioning `_ and its rules. -* :ref:`Command Line interface ` -* `Web 2.0 Library Search `_ +There 2 options how to find library: -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:`Command Line Interface ` +* `Web-based Library Search `__ + +*PlatformIO Library Manager* allows to manage different library storages using +:option:`platformio lib --global` or :option:`platformio lib --storage-dir` +options. + +Project dependencies +-------------------- + +*PlatformIO Library Manager* allows to specify project dependencies +(:ref:`projectconf_lib_deps`) that will be installed automatically per project +before environment processing. You do not need to install libraries manually. +The only one simple step is to define dependencies in :ref:`projectconf`. +You can use library ID, Name or even repository URL. For example, + +.. code-block:: ini + + [env:myenv] + platform = ... + framework = ... + board = ... + lib_deps = + 13 + PubSubClient + Json@~5.6,!=5.4 + https://github.com/gioblu/PJON.git@v2.0 + https://github.com/me-no-dev/ESPAsyncTCP.git + https://github.com/adafruit/DHT-sensor-library/archive/master.zip + +Please follow to :ref:`cmd_lib_install` for detailed documentation about +possible values. + +.. warning:: + If some libraries are not visible in :ref:`ide_atom` and Code Completion or + Code Linting does not work properly, please perform ``Menu: PlatformIO > + Rebuild C/C++ Project Index (Autocomplete, Linter)`` .. image:: ../_static/platformio-demo-lib.gif diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst new file mode 100644 index 00000000..ed56dc39 --- /dev/null +++ b/docs/librarymanager/ldf.rst @@ -0,0 +1,167 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.. _ldf: + +Library Dependency Finder (LDF) +=============================== + +.. versionadded:: 3.0 + +Library Dependency Finder is a core part of PlatformIO Build System that +operates with the C/C++ source files and looks for ``#include ...`` +directives. + +In spite of the fact that Library Dependency Finder is written in pure Python, +it interprets (emulates) :ref:`ldf_c_cond_syntax` (``#ifdef``, ``if``, ``defined``, +``else``, and ``elif``) without calling ``gcc -E``. This approach allows +significantly reduce total compilation time. + +Library Dependency Finder has controls that can be set up in :ref:`projectconf`: + +.. hlist:: + :columns: 3 + + * :ref:`projectconf_lib_deps` + * :ref:`projectconf_lib_extra_dirs` + * :ref:`projectconf_lib_force` + * :ref:`projectconf_lib_ignore` + * :ref:`projectconf_lib_compat_mode` + * :ref:`projectconf_lib_ldf_mode` + +----------- + +.. contents:: + +.. _ldf_storage: + +Storage +------- + +There are different storages where Library Dependency Finder looks for +libraries. These storages (folders) have priority and LDF operates in the next +order: + +1. :ref:`projectconf_lib_extra_dirs` - extra storages per build environment +2. :ref:`projectconf_pio_lib_dir` - own/private library storage per project +3. :ref:`projectconf_pio_libdeps_dir` - project dependencies storage used by + :ref:`librarymanager` +4. ":ref:`projectconf_pio_home_dir`/lib" - global storage per all projects. + +.. _ldf_mode: + +Dependency Finder Mode +---------------------- + +Library Dependency Finder starts work from analyzing source files of the +project (:ref:`projectconf_pio_src_dir`) and can work in the next modes: + +* ``0`` - "manual mode", does not process source files of a project and + dependencies. Builds only the libraries that are specified in + manifests (:ref:`library_config`, ``module.json``) or in the :ref:`projectconf`. +* ``1`` - **default** - parses ALL C/C++ source code of the project and follows + only by nested includes (``#include ...``, chain...) from the libraries. +* ``2`` - parses ALL C/C++ source code of the project and parses + ALL C/C++ source code of the each found dependency (recursively). + +This mode can be changed using :ref:`projectconf_lib_ldf_mode` option in +:ref:`projectconf`. + +A difference between ``1`` and ``2`` modes. For example, there are 2 libraries: + +* Library "Foo" with files: + + - ``Foo/foo.h`` + - ``Foo/foo.cpp`` + +* Library "Bar" with files: + + - ``Bar/bar.h`` + - ``Bar/bar.cpp`` + +:Case 1: + + * ``lib_ldf_mode = 1`` + * ``Foo/foo.h`` depends on "Bar" library (contains ``#include ``) + * ``#include `` is located in one of the project source files + + Here are nested includes (``project file > foo.h > bar.h``) and ``LDF`` + will find both libraries "Foo" and "Bar". + +:Case 2: + + * ``lib_ldf_mode = 1`` + * ``Foo/foo.cpp`` depends on "Bar" library (contains ``#include ``) + * ``#include `` is located in one of the project source files + + In this case, ``LDF`` will not find "Bar" library because it doesn't know + about CPP file (``Foo/foo.cpp``). + +:Case 3: + + * ``lib_ldf_mode = 2`` + * ``Foo/foo.cpp`` depends on "Bar" library (contains ``#include ``) + * ``#include `` is located in one of the project source files + + Firstly, ``LDF`` finds "Foo" library, then it parses all sources from "Foo" + library and finds ``Foo/foo.cpp`` that depends on ``#include ``. + Secondly, it will parse all sources from "Bar" library and this operation + continues until all dependencies will not be parsed. + +.. _ldf_compat_mode: + +Compatibility Mode +------------------ + +Compatibility mode allows to control strictness of Library Dependency Finder. +If library contains one of manifest file (:ref:`library_config`, +``library.properties``, ``module.json``), then LDF check compatibility of this +library with real build environment. Available compatibility modes: + +* ``0`` - does not check for compatibility (is not recommended) +* ``1`` - **default** - checks for the compatibility with + :ref:`projectconf_env_framework` from build environment +* ``2`` - checks for the compatibility with :ref:`projectconf_env_framework` + and :ref:`projectconf_env_platform` from build environment. + +This mode can be changed using :ref:`projectconf_lib_compat_mode` option in +:ref:`projectconf`. + +.. _ldf_c_cond_syntax: + +C/C++ Preprocessor conditional syntax +------------------------------------- + +In spite of the fact that Library Dependency Finder is written in pure Python, +it interprets (emulates) `C/C++ Preprocessor conditional syntax `_ +(``#ifdef``, ``if``, ``defined``, ``else``, and ``elif``) without calling +``gcc -E``. For example, + +``platformio.ini`` + +.. code-block:: ini + + [env:myenv] + build_flags = -D MY_PROJECT_VERSION=13 + +``mylib.h`` + +.. code-block:: c + + #ifdef PROJECT_VERSION + // include common file for the project + #include "my_common.h" + #endif + + #if PROJECT_VERSION < 10 + // this include will be ignored because does not satisfy condition above + #include "my_old.h" + #endif diff --git a/docs/migration.rst b/docs/migration.rst new file mode 100644 index 00000000..9c28647a --- /dev/null +++ b/docs/migration.rst @@ -0,0 +1,213 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.. _migration: + +Migrating from 2.x to 3.0 +========================= + +Guidance on how to upgrade from PlatformIO v2.x to v3.x with emphasis on major +changes, what is new, and what is been removed. + +PlatformIO 3 is not backwards compatible with v2.x. Use this section as a +general guide to upgrading from v2.x to v3.0. For a broader overview, see +`what is new `_ in the v3.0 +release announcement. + +.. contents:: + +Major PlatformIO CLI changes +---------------------------- + +.. note:: + PlatformIO 3.x is 100% non-blocking! You do not need to use ``--force`` + option or setup special ``PLATOFMRIO_SETTING_ENABLE_PROMPTS`` environment. + Use PlatformIO 3.0 with sub-processing without any risk! + +This table shows the CLI changes between v2.x and v3.0. + +.. list-table:: + :header-rows: 1 + + * - PlatformIO 2.x + - PlatformIO 3.x + * - platformio platforms + - :ref:`platformio platform ` + * - platformio serialports + - :ref:`cmd_device` + * - platformio settings set enable_prompts false + - Removed! Now, all PlatformIO 3.0 CLI is 100% non-blocking! + + +PlatformIO 2.x commands will be converted to PlatformIO 3.x automatically. +Nevertheless, we recommend to use PlatformIO 3.x commands for the new projects. + +What is new +----------- + +Development Platforms +~~~~~~~~~~~~~~~~~~~~~ + +We have introduced :ref:`platform_creating_manifest_file` and ported +PlatformIO 2.x development platforms according PlatformIO 3.0 decentralized +architecture. Now, platform related things (build scrips, LD scripts, board +configs, package requirements) are located in own repository. Here is the full +list with `PlatformIO 3.0 open source development platforms `__. You can fork it, modify or create custom. +See :ref:`platform_creating` guide for details. + +* :ref:`platform_creating_manifest_file` +* ``espressif`` development platform has been renamed to :ref:`platform_espressif8266` +* PlatformIO 3.0 :ref:`userguide_platform` +* Custom package repositories +* External embedded board configuration files, isolated build scripts +* Embedded Board compatibility with more than one development platform + +Library Manager and Intelligent Build System +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* Powerful and super-fast :ref:`ldf` that interprets C/C++ Preprocessor + conditional macros with deep search behavior +* Project dependencies per build environment using `projectconf_lib_deps` option +* Depend on a library using VCS URL (GitHub, Git, ARM mbed code registry, Hg, SVN) +* Install library by name +* Strict search for library dependencies +* Multiple library storages: Project's Local, PlatformIO's Global or Custom +* Allowed :ref:`library_config` to specify sources other than PlatformIO's Repository +* Check library compatibility with project environment before building +* Control Library Dependency Finder for compatibility using :ref:`projectconf_lib_compat_mode` option +* Custom library storages/directories with :ref:`projectconf_lib_extra_dirs` option +* Handle extra build flags, source filters and build script from :ref:`library_config` +* Allowed to disable library archiving (``*.ar``) +* Show detailed build information about dependent libraries (Library Dependency Graph) +* Support for the 3rd party manifests (Arduino IDE "library.properties" and + ARM mbed "module.json") +* Build System: Attach custom Before/Pre and After/Post actions for targets using :ref:`projectconf_extra_script` + +Command Line Interface +~~~~~~~~~~~~~~~~~~~~~~ + +We have added new commands and changed some existing ones. Here are the new or +updated commands and options. + +.. list-table:: + :header-rows: 1 + + * - Command + - Description + * - :ref:`cmd_boards` + - Returns all supported boards by PlatformIO + * - :option:`platformio boards --installed` + - Returns currently installed boards + * - :option:`platformio ci --project-option` + - Pass custom option from :ref:`projectconf` + * - :option:`platformio ci --verbose` + - Print detailed information about build process + * - :option:`platformio init --project-option` + - Pass custom option from :ref:`projectconf` + * - :option:`platformio lib --global` + - Manage PlatformIO :ref:`Global Library Storage ` + * - :option:`platformio lib --storage-dir` + - Manage :ref:`Custom Library Storage ` + * - :ref:`cmd_lib_install` + - New PlatformIO 3.0 Library Manager! Semantic Versioning, VCS support and external URL support + * - :option:`platformio lib install --silent` + - Suppress progress reporting when install library + * - :option:`platformio lib install --interactive` + - Allow to make a choice for all prompts when install library + * - :option:`platformio lib search --header` + - Search library by specific header file name (include) + * - :option:`platformio lib update --only-check` + - Do not update, only check for new version + * - :ref:`platformio platform ` + - New PlatformIO 3.0 Platform Manager! Semantic Versioning, VCS support and external URL support. + * - :option:`platformio platform update --only-packages` + - Update only platform packages + * - :option:`platformio platform update --only-check` + - Do not update, only check for new version + * - :ref:`cmd_run` + - By default, prints only human-readable information when processing environments + * - :option:`platformio run --verbose` + - Print detailed processing information + * - :ref:`platformio settings set force_verbose true ` + - Force verbose output when processing environments (globally) + * - :ref:`cmd_test` + - PlatformIO Plus Unit Testing + * - :option:`platformio update --only-check` + - Do not update, only check for new version + +:ref:`projectconf` +~~~~~~~~~~~~~~~~~~ + +We have added new options and changed some existing ones. Here are the new or +updated options. + +.. list-table:: + :header-rows: 1 + + * - Section + - Option + - Description + * - platformio + - :ref:`projectconf_pio_libdeps_dir` + - Internal storage where :ref:`librarymanager` will install project dependencies + * - platformio + - :ref:`projectconf_pio_test_dir` + - Directory where :ref:`unit_testing` engine will look for the tests + * - env + - :ref:`projectconf_lib_deps` + - Specify project dependencies that should be installed automatically to :ref:`projectconf_pio_libdeps_dir` before environment processing. + * - env + - :ref:`projectconf_env_platform` + - PlatformIO 3.0 allows to use specific version of platform using `Semantic Versioning `_ (X.Y.Z=MAJOR.MINOR.PATCH). + * - env + - :ref:`projectconf_lib_extra_dirs` + - A list with extra directories/storages where :ref:`ldf` will look for dependencies + * - env + - :ref:`projectconf_lib_ldf_mode` + - This option specifies how does :ref:`ldf` should analyze dependencies (``#include`` directives) + * - env + - :ref:`projectconf_lib_compat_mode` + - Library compatibility mode allows to control strictness of :ref:`ldf` + * - env + - :ref:`projectconf_test_ignore` + - Ignore tests where the name matches specified patterns + +What is removed +--------------- + +Command Line Interface +~~~~~~~~~~~~~~~~~~~~~~ + +The following commands have been dropped or changed in v3.0. + +.. list-table:: + :header-rows: 1 + + * - Command + - Description + * - platformio init --enable-auto-uploading + - Use :option:`platformio init --project-option` instead of it with ``targets = upload`` value + +:ref:`projectconf` +~~~~~~~~~~~~~~~~~~ + +The following options have been dropped or changed in v3.0. + +.. list-table:: + :header-rows: 1 + + * - Section + - Option + - Description + * - platformio + - :ref:`projectconf_pio_lib_dir` + - Changed: Project's own/private libraries, where in PlatformIO 2.x it was global library storage + diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index 52bcb584..88d545f0 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,21 +28,34 @@ Packages * - Name - Contents - * - ``toolchain-atmelavr`` - - `avr-gcc `_, `GDB `_, `AVaRICE `_, `SimulAVR `_ - - * - ``tool-avrdude`` - - `AVRDUDE `_ + * - ``framework-arduinoavr`` + - `Arduino Wiring-based Framework (AVR Core, 1.6) `_ * - ``framework-simba`` - `Simba Framework `_ - * - ``framework-arduinoavr`` - - `Arduino Wiring-based Framework (AVR Core, 1.6) `_ + * - ``tool-avrdude`` + - `AVRDUDE `_ * - ``tool-micronucleus`` - `Micronucleus `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + + * - ``toolchain-atmelavr`` + - `avr-gcc `_, `GDB `_, `AVaRICE `_, `SimulAVR `_ + +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). + + + **Windows Users:** Please check that you have correctly installed USB + driver from board manufacturer + + + Frameworks ---------- .. list-table:: @@ -124,7 +137,7 @@ Adafruit * - ``protrinket3ftdi`` - `Adafruit Pro Trinket 3V/12MHz (FTDI) `_ - ATMEGA328P - - 16 MHz + - 12 MHz - 32 Kb - 2 Kb diff --git a/docs/platforms/atmelavr_extra.rst b/docs/platforms/atmelavr_extra.rst index 754de6e0..ac6691bd 100644 --- a/docs/platforms/atmelavr_extra.rst +++ b/docs/platforms/atmelavr_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -30,7 +30,7 @@ Configuration for the programmers: upload_protocol = stk500v1 upload_flags = -P$UPLOAD_PORT - # edit this line with valid upload port + ; edit this line with valid upload port upload_port = SERIAL_PORT_HERE * AVRISP mkII @@ -91,7 +91,7 @@ Configuration for the programmers: upload_protocol = stk500v1 upload_flags = -P$UPLOAD_PORT -b$UPLOAD_SPEED - # edit these lines + ; edit these lines upload_port = SERIAL_PORT_HERE upload_speed = 19200 diff --git a/docs/platforms/atmelsam.rst b/docs/platforms/atmelsam.rst index 12cbc41a..a73ab057 100644 --- a/docs/platforms/atmelsam.rst +++ b/docs/platforms/atmelsam.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,30 +28,30 @@ Packages * - Name - Contents - * - ``framework-mbed`` - - `mbed Framework `_ - - * - ``toolchain-gccarmnoneeabi`` - - `gcc-arm-embedded `_, `GDB `_ - * - ``framework-arduinosam`` - `Arduino Wiring-based Framework (SAM Core, 1.6) `_ - * - ``ldscripts`` - - `Linker Scripts `_ + * - ``framework-mbed`` + - `mbed Framework `_ * - ``framework-simba`` - `Simba Framework `_ - * - ``tool-openocd`` - - `OpenOCD `_ - * - ``tool-avrdude`` - `AVRDUDE `_ * - ``tool-bossac`` - `BOSSA CLI `_ + * - ``tool-openocd`` + - `OpenOCD `_ + + * - ``tool-scons`` + - `SCons software construction tool `_ + + * - ``toolchain-gccarmnoneeabi`` + - `gcc-arm-embedded `_, `GDB `_ + .. warning:: **Linux Users:** Don't forget to install "udev" rules file `99-platformio-udev.rules `_ (an instruction is located in the file). @@ -73,12 +73,12 @@ Frameworks * - :ref:`framework_arduino` - Arduino Wiring-based Framework allows writing cross-platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding, interactive objects, spaces or physical experiences. - * - :ref:`framework_mbed` - - The mbed framework The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community. - * - :ref:`framework_simba` - Simba is an RTOS and build framework. It aims to make embedded programming easy and portable. + * - :ref:`framework_mbed` + - The mbed framework The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community. + Boards ------ diff --git a/docs/platforms/creating_board.rst b/docs/platforms/creating_board.rst index 55be0dbd..02c8b0ea 100644 --- a/docs/platforms/creating_board.rst +++ b/docs/platforms/creating_board.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -35,29 +35,44 @@ The key fields: * ``build`` data will be used by :ref:`platforms` and :ref:`frameworks` builders * ``frameworks`` is the list with supported :ref:`frameworks` -* ``platform`` main type of :ref:`platforms` +* ``platform`` name of :ref:`platforms` * ``upload`` upload settings which depend on the ``platform`` .. code-block:: json { - "myboard": { - "build": {}, - "frameworks": ["%LIST_WITH_SUPPORTED_FRAMEWORKS%"], - "name": "My test board", - "platform": "%PLATFORM_TYPE_HERE%", - "upload": {}, - "url": "http://example.com", - "vendor": "My Company Ltd." - } + "build": { + "extra_flags": "-DHELLO_PLATFORMIO", + "f_cpu": "16000000L", + "hwids": [ + [ + "0x1234", + "0x0013" + ], + [ + "0x4567", + "0x0013" + ] + ], + "mcu": "%MCU_TYPE_HERE%" + }, + "frameworks": ["%LIST_WITH_SUPPORTED_FRAMEWORKS%"], + "name": "My Test Board", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32256 + }, + "url": "http://example.com", + "vendor": "MyCompany" } + Installation ------------ 1. Create ``boards`` directory in :ref:`projectconf_pio_home_dir` if it doesn't exist. -2. Create ``my_own_boards.json`` file and put to ``boards`` directory. +2. Create ``myboard.json`` file and put to ``boards`` directory. 3. Search available boards via :ref:`cmd_boards` command. You should see ``myboard`` board. @@ -68,5 +83,6 @@ Now, you can use ``myboard`` for the :ref:`projectconf_env_board` option in Examples -------- -For the examples, please look into built-in ``*.json`` files with boards -settings: https://github.com/platformio/platformio/tree/develop/platformio/boards. +Please take a look at the source code of +`PlatformIO Development Platforms `_ +and navigate to ``boards`` folder of the repository. diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index 09e11695..44fe48f0 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -14,7 +14,7 @@ Custom Development Platform =========================== -*PlatformIO* was developed like a tool which would build the same source code +*PlatformIO* was developed like a tool that may build the same source code for the different development platforms via single command :ref:`cmd_run` without any dependent software or requirements. @@ -32,7 +32,7 @@ different/own build scripts, uploader and etc. **Step-by-Step Manual** -1. Chose :ref:`platform_creating_packages` for platform +1. Choose :ref:`platform_creating_packages` for platform 2. Create :ref:`platform_creating_manifest_file` 3. Create :ref:`platform_creating_build_script` 4. Finish with the :ref:`platform_creating_installation`. @@ -56,7 +56,7 @@ Packages * - ``framework-arduinoavr`` - `Arduino Wiring-based Framework (AVR Core, 1.6) `_ - * - ``framework-arduinoespressif`` + * - ``framework-arduinoespressif8266`` - `Arduino Wiring-based Framework (ESP8266 Core) `_ * - ``framework-arduinointel`` @@ -187,89 +187,79 @@ Packages .. _platform_creating_manifest_file: -Manifest File -------------- +Manifest File ``platform.json`` +------------------------------- -A platform manifest file is a `Python `_ script with the -next requirements: +.. code-block:: json -1. The file should have ``.py`` extension -2. The **name of the file** is the **platform name** (lowercase) -3. The source code of this file should contain a ``class`` which describes your - own platform. The name of the ``class`` should start with your - **platform name** (the first letter should be capitalized) + ``Platform`` - ending. This ``class`` should be derived from *PlatformIO* ``BasePlatform`` - class. - -.. warning:: - If you are new to *Python* language, please read: - - * `Style Guide for Python Code `_. - * A hash sign (#) that is not inside a string literal begins a comment. - All characters after the # and up to the physical line end are part - of the comment and the *Python* interpreter ignores them. - -Example of the **test** platform (``test.py``): - -.. code-block:: python - - import os - - from platformio.platforms.base import BasePlatform - - class TestPlatform(BasePlatform): - # This is a description of your platform. - # Platformio uses it for the `platformio search / list` commands - """ - My Test platform - test.py - """ - - PACKAGES = { - - "toolchain-foo": { - - # alias is used for quick access to package. - # For example, - # `> platformio install test --without-package=toolchain` - "alias": "toolchain", - - # Flag which allows PlatformIO to install this package by - # default via `> platformio install test` command - "default": True - }, - - "tool-bar": { - "alias": "uploader", - "default": True - }, - - "framework-baz": { - "default": True + { + "name": "myplatform", + "title": "My Platform", + "description": "My custom development platform", + "url": "http://example.com", + "homepage": "http://platformio.org/platforms/myplatform", + "license": "Apache-2.0", + "engines": { + "platformio": "~3.0.0", + "scons": ">=2.3.0,<2.6.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/platformio/platform-myplatform.git" + }, + "version": "0.0.0", + "packageRepositories": [ + "https://dl.bintray.com/platformio/dl-packages/manifest.json", + "https://sourceforge.net/projects/platformio-storage/files/packages/manifest.json/download", + "http://dl.platformio.org/packages/manifest.json", + { + "framework-%FRAMEWORK_NAME_1%": [ + { + "url": "http://dl.example.com/packages/framework-%FRAMEWORK_NAME_1%-1.10607.0.tar.gz", + "sha1": "adce2cd30a830d71cb6572575bf08461b7b73c07", + "version": "1.10607.0", + "system": "*" } + ] } - - def get_build_script(self): - """ Returns a path to build script """ - - # You can return static path - #return "/path/to/test-builder.py" - - # or detect dynamically if `test-builder.py` is located in the same - # folder with `test.py` - return os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "test-builder.py" - ) + ], + "frameworks": { + "%FRAMEWORK_NAME_1%": { + "package": "framework-%FRAMEWORK_NAME_1%", + "script": "builder/frameworks/%FRAMEWORK_NAME_1%.py" + }, + "%FRAMEWORK_NAME_N%": { + "package": "framework-%FRAMEWORK_NAME_N%", + "script": "builder/frameworks/%FRAMEWORK_NAME_N%.py" + } + }, + "packages": { + "toolchain-gccarmnoneeabi": { + "type": "toolchain", + "version": ">=1.40803.0,<1.40805.0" + }, + "framework-%FRAMEWORK_NAME_1%": { + "type": "framework", + "optional": true, + "version": "~1.10607.0" + }, + "framework-%FRAMEWORK_NAME_N%": { + "type": "framework", + "optional": true, + "version": "~1.117.0" + } + } + } .. _platform_creating_build_script: -Build Script ------------- +Build Script ``main.py`` +------------------------ Platform's build script is based on a next-generation build tool named `SCons `_. PlatformIO has own built-in firmware builder -``env.BuildProgram`` with the nested libraries search. Please look into a -base template of ``test-builder.py``. +``env.BuildProgram`` with the deep libraries search. Please look into a +base template of ``main.py``. .. code-block:: python @@ -347,15 +337,6 @@ base template of ``test-builder.py``. Default(target_bin) -Please look into the examples with built-in scripts for the popular -platforms: - -* `baseavr.py `_ -* `basearm.py `_ -* `atmelavr.py `_ -* `timsp430.py `_ -* `ststm32.py `_ - .. _platform_creating_installation: Installation @@ -363,126 +344,17 @@ Installation 1. Create ``platforms`` directory in :ref:`projectconf_pio_home_dir` if it doesn't exist. -2. Copy ``test.py`` and ``test-builder.py`` files to ``platforms`` directory. -3. Search available platforms via :ref:`cmd_platforms_search` command. You should see - ``test`` platform. -4. Install ``test`` platform via :ref:`cmd_platforms_install` command. +2. Create ``myplatform`` directory in ``platforms`` +3. Copy ``platform.json`` and ``builder/main.py`` files to ``myplatform`` directory. +4. Search available platforms via :ref:`cmd_platform_search` command. You + should see ``myplatform`` platform. +5. Install ``myplatform`` platform via :ref:`cmd_platform_install` command. -Now, you can use ``test`` for the :ref:`projectconf_env_platform` option in -:ref:`projectconf`. +Now, you can use ``myplatform`` for the :ref:`projectconf_env_platform` +option in :ref:`projectconf`. -Example -------- - -Let's use the real example which was requested by our user in `issue 175 `_. Need to add support for uploading firmware using GDB to -:ref:`platform_ststm32`. - -First of all, need to create new folder ``platforms`` in :ref:`projectconf_pio_home_dir` -and copy there two files: - -1. Platform manifest file ``ststm32gdb.py`` with the next content: - -.. code-block:: python - - import os - - from platformio.platforms.ststm32 import Ststm32Platform - - - class Ststm32gdbPlatform(Ststm32Platform): - - """ - ST STM32 using GDB as uploader - - http://www.st.com/web/en/catalog/mmc/FM141/SC1169?sc=stm32 - """ - - def get_build_script(self): - - return os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "ststm32gdb-builder.py" - ) - -2. Build script file ``ststm32gdb-builder.py`` with the next content: - -.. code-block:: python - - """ - Builder for ST STM32 Series ARM microcontrollers with GDB upload. - """ - - from os.path import join - - from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - - - env = DefaultEnvironment() - - SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - - env.Replace( - UPLOADER=join( - "$PIOPACKAGES_DIR", "toolchain-gccarmnoneeabi", - "bin", "arm-none-eabi-gdb" - ), - UPLOADERFLAGS=[ - join("$BUILD_DIR", "firmware.elf"), - "-batch", - "-x", join("$PROJECT_DIR", "upload.gdb") - ], - - UPLOADCMD="$UPLOADER $UPLOADERFLAGS" - ) - - env.Append( - CPPDEFINES=[ - "${BOARD_OPTIONS['build']['variant'].upper()}" - ], - - LINKFLAGS=[ - "-nostartfiles", - "-nostdlib" - ] - ) - - # - # Target: Build executable and linkable firmware - # - - target_elf = env.BuildProgram() - - # - # Target: Build the .bin file - # - - if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") - else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - - # - # Target: Print binary size - # - - target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") - AlwaysBuild(target_size) - - # - # Target: Upload by default .bin file - # - - upload = env.Alias( - ["upload", "uploadlazy"], target_firm, "$UPLOADCMD") - AlwaysBuild(upload) - - # - # Target: Define targets - # - - Default([target_firm, target_size]) - -Now, we should see ``ststm32gdb`` platform using :ref:`cmd_platforms_search` command output -and can install it via :ref:`platformio platforms install ststm32gdb ` command. +Examples +-------- +Please take a look at the source code of +`PlatformIO Development Platforms `_. diff --git a/docs/platforms/custom_platform_and_board.rst b/docs/platforms/custom_platform_and_board.rst index 7db1381c..36614a24 100644 --- a/docs/platforms/custom_platform_and_board.rst +++ b/docs/platforms/custom_platform_and_board.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/platforms/embedded_boards.rst b/docs/platforms/embedded_boards.rst index 91df1475..8353ed67 100644 --- a/docs/platforms/embedded_boards.rst +++ b/docs/platforms/embedded_boards.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -137,7 +137,7 @@ Adafruit * - ``protrinket3ftdi`` - `Adafruit Pro Trinket 3V/12MHz (FTDI) `_ - ATMEGA328P - - 16 MHz + - 12 MHz - 32 Kb - 2 Kb @@ -1123,6 +1123,26 @@ Fubarino - 512 Kb - 128 Kb +Generic +~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``bluepill_f103c8`` + - `BluePill F103C8 `_ + - STM32F103C8T6 + - 72 MHz + - 64 Kb + - 20 Kb + Generic ATTiny ~~~~~~~~~~~~~~ diff --git a/docs/platforms/espressif.rst b/docs/platforms/espressif8266.rst similarity index 96% rename from docs/platforms/espressif.rst rename to docs/platforms/espressif8266.rst index 56ffbc43..8530ea18 100644 --- a/docs/platforms/espressif.rst +++ b/docs/platforms/espressif8266.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,10 +9,10 @@ See the License for the specific language governing permissions and limitations under the License. -.. _platform_espressif: +.. _platform_espressif8266: -Platform ``espressif`` -====================== +Platform ``espressif8266`` +========================== Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications. For more detailed information please visit `vendor site `_. @@ -28,26 +28,26 @@ Packages * - Name - Contents - * - ``toolchain-xtensa`` - - `xtensa-gcc `_, `GDB `_ + * - ``framework-arduinoespressif8266`` + - `Arduino Wiring-based Framework (ESP8266 Core) `_ * - ``framework-simba`` - `Simba Framework `_ + * - ``sdk-esp8266`` + - `ESP8266 SDK `_ + * - ``tool-esptool`` - `esptool-ck `_ * - ``tool-mkspiffs`` - `Tool to build and unpack SPIFFS images `_ - * - ``framework-arduinoespressif`` - - `Arduino Wiring-based Framework (ESP8266 Core) `_ + * - ``tool-scons`` + - `SCons software construction tool `_ - * - ``ldscripts`` - - `Linker Scripts `_ - - * - ``sdk-esp8266`` - - `ESP8266 SDK `_ + * - ``toolchain-xtensa`` + - `xtensa-gcc `_, `GDB `_ .. warning:: **Linux Users:** Don't forget to install "udev" rules file @@ -386,4 +386,4 @@ WeMos - 4096 Kb - 80 Kb -.. include:: espressif_extra.rst +.. include:: espressif8266_extra.rst diff --git a/docs/platforms/espressif_extra.rst b/docs/platforms/espressif8266_extra.rst similarity index 91% rename from docs/platforms/espressif_extra.rst rename to docs/platforms/espressif8266_extra.rst index 65d7356a..02db956f 100644 --- a/docs/platforms/espressif_extra.rst +++ b/docs/platforms/espressif8266_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -17,7 +17,7 @@ See :ref:`projectconf_board_f_cpu` option from :ref:`projectconf` .. code-block:: ini [env:myenv] - # set frequency to 160MHz + ; set frequency to 160MHz board_f_cpu = 160000000L Custom FLASH Frequency @@ -34,7 +34,7 @@ values: .. code-block:: ini [env:myenv] - # set frequency to 80MHz + ; set frequency to 80MHz board_f_flash = 80000000L Custom FLASH Mode @@ -181,7 +181,7 @@ For the full list with available options please run .. code-block:: bash - ~/.platformio/packages/framework-arduinoespressif/tools/espota.py -h + ~/.platformio/packages/framework-arduinoespressif8266/tools/espota.py -h Usage: espota.py [options] @@ -221,9 +221,20 @@ Using Arduino Framework with Staging version -------------------------------------------- 1. Clone/Copy `main repository `_ to - :ref:`projectconf_pio_home_dir` + ``packages/framework-arduinoespressif`` - and create new file ``packages/framework-arduinoespressif/version.txt`` - with the new version (for example, ``2.2.0``). + :ref:`projectconf_pio_home_dir` + ``packages/framework-arduinoespressif8266`` + and create new file ``packages/framework-arduinoespressif8266/package.json`` + with the next contents (you can specify own version if you want) + + .. code-block:: json + + { + "description":"Arduino Wiring-based Framework (ESP8266 Core)", + "name":"framework-arduinoespressif8266", + "system":"all", + "url":"https://github.com/esp8266/Arduino", + "version":"1.20300.0" + } + 2. Try to build project 3. If you see build errors, then try to build this project using the same ``stage`` on Arduino IDE @@ -240,6 +251,8 @@ Using Arduino Framework with Staging version Articles -------- +* Sep 2, 2016 - **Tinkerman** `Optimizing files for SPIFFS with Gulp `_ +* Jul 15, 2016 - **Jaime** - `ESP8266 Mobile Rick Roll Captive Portal `_ * Jun 13, 2016 - **Daniel Eichhorn** - `New Weather Station Demo on Github `_ * Jun 3, 2016 - **Daniel Eichhorn** - `ESP8266: Continuous Delivery Pipeline – Push To Production `_ * May 29, 2016 - **Chris Synan** - `Reverse Engineer RF Remote Controller for IoT! `_ diff --git a/docs/platforms/freescalekinetis.rst b/docs/platforms/freescalekinetis.rst index 13e60daf..29323287 100644 --- a/docs/platforms/freescalekinetis.rst +++ b/docs/platforms/freescalekinetis.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,6 +31,9 @@ Packages * - ``framework-mbed`` - `mbed Framework `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-gccarmnoneeabi`` - `gcc-arm-embedded `_, `GDB `_ diff --git a/docs/platforms/index.rst b/docs/platforms/index.rst index f7f68146..99261396 100644 --- a/docs/platforms/index.rst +++ b/docs/platforms/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -30,7 +30,7 @@ Embedded atmelavr atmelsam - espressif + espressif8266 freescalekinetis intel_arc32 lattice_ice40 diff --git a/docs/platforms/intel_arc32.rst b/docs/platforms/intel_arc32.rst index c4863e5c..dbfe8f16 100644 --- a/docs/platforms/intel_arc32.rst +++ b/docs/platforms/intel_arc32.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -34,6 +34,9 @@ Packages * - ``tool-arduino101load`` - `Genuino101 uploader `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-intelarc32`` - `GCC for Intel ARC `_ diff --git a/docs/platforms/lattice_ice40.rst b/docs/platforms/lattice_ice40.rst index 4a836ed3..d4e60376 100644 --- a/docs/platforms/lattice_ice40.rst +++ b/docs/platforms/lattice_ice40.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,6 +28,9 @@ Packages * - Name - Contents + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-icestorm`` - `GCC for FPGA IceStorm `_ diff --git a/docs/platforms/linux_arm.rst b/docs/platforms/linux_arm.rst index 56783765..1e01001d 100644 --- a/docs/platforms/linux_arm.rst +++ b/docs/platforms/linux_arm.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,6 +31,9 @@ Packages * - ``framework-wiringpi`` - `GPIO Interface library for the Raspberry Pi `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-gccarmlinuxgnueabi`` - `GCC for Linux ARM GNU EABI `_, `GDB `_ diff --git a/docs/platforms/linux_i686.rst b/docs/platforms/linux_i686.rst index 583ad151..386c8dd5 100644 --- a/docs/platforms/linux_i686.rst +++ b/docs/platforms/linux_i686.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,5 +28,8 @@ Packages * - Name - Contents + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-gcclinux32`` - `GCC for Linux i686 `_ \ No newline at end of file diff --git a/docs/platforms/linux_x86_64.rst b/docs/platforms/linux_x86_64.rst index d770b2e8..91068819 100644 --- a/docs/platforms/linux_x86_64.rst +++ b/docs/platforms/linux_x86_64.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -15,7 +15,7 @@ Platform ``linux_x86_64`` ========================= Linux x86_64 (64-bit) is a Unix-like and mostly POSIX-compliant computer operating system (OS) assembled under the model of free and open-source software development and distribution. Using host OS (Mac OS X or Linux 64-bit) you can build native application for Linux x86_64 platform. -For more detailed information please visit `vendor site `_. +For more detailed information please visit `vendor site `_. .. contents:: @@ -28,5 +28,8 @@ Packages * - Name - Contents + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-gcclinux64`` - `GCC for Linux x86_64 `_ \ No newline at end of file diff --git a/docs/platforms/microchippic32.rst b/docs/platforms/microchippic32.rst index 51c92e8e..91269d85 100644 --- a/docs/platforms/microchippic32.rst +++ b/docs/platforms/microchippic32.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,12 +31,15 @@ Packages * - ``framework-arduinomicrochippic32`` - `Arduino Wiring-based Framework (PIC32 Core) `_ - * - ``toolchain-microchippic32`` - - `GCC for Microchip PIC32 `_ - * - ``tool-pic32prog`` - `pic32prog `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + + * - ``toolchain-microchippic32`` + - `GCC for Microchip PIC32 `_ + .. warning:: **Linux Users:** Don't forget to install "udev" rules file `99-platformio-udev.rules `_ (an instruction is located in the file). diff --git a/docs/platforms/native.rst b/docs/platforms/native.rst index 68fd805b..a6794951 100644 --- a/docs/platforms/native.rst +++ b/docs/platforms/native.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -17,4 +17,16 @@ Native development platform is intended to be used for desktop OS. This platform For more detailed information please visit `vendor site `_. -.. contents:: \ No newline at end of file +.. contents:: + +Packages +-------- + +.. list-table:: + :header-rows: 1 + + * - Name + - Contents + + * - ``tool-scons`` + - `SCons software construction tool `_ \ No newline at end of file diff --git a/docs/platforms/nordicnrf51.rst b/docs/platforms/nordicnrf51.rst index fff500b3..b7f8c8d9 100644 --- a/docs/platforms/nordicnrf51.rst +++ b/docs/platforms/nordicnrf51.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,20 +28,23 @@ Packages * - Name - Contents + * - ``framework-arduinonordicnrf51`` + - `Arduino Wiring-based Framework (RFduino Core) `_ + * - ``framework-mbed`` - `mbed Framework `_ * - ``tool-rfdloader`` - `rfdloader `_ - * - ``toolchain-gccarmnoneeabi`` - - `gcc-arm-embedded `_, `GDB `_ + * - ``tool-scons`` + - `SCons software construction tool `_ * - ``tool-sreccat`` - `Merging tool `_ - * - ``framework-arduinonordicnrf51`` - - `Arduino Wiring-based Framework (RFduino Core) `_ + * - ``toolchain-gccarmnoneeabi`` + - `gcc-arm-embedded `_, `GDB `_ .. warning:: **Linux Users:** Don't forget to install "udev" rules file diff --git a/docs/platforms/nordicnrf51_extra.rst b/docs/platforms/nordicnrf51_extra.rst index beab99ce..79140038 100644 --- a/docs/platforms/nordicnrf51_extra.rst +++ b/docs/platforms/nordicnrf51_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,6 +9,11 @@ See the License for the specific language governing permissions and limitations under the License. +Articles +-------- + +* Aug 28, 2016 - **Tom Parker** `Using the BBC micro:bit with PlatformIO `_ + Examples -------- diff --git a/docs/platforms/nxplpc.rst b/docs/platforms/nxplpc.rst index 2c94410f..3b76506c 100644 --- a/docs/platforms/nxplpc.rst +++ b/docs/platforms/nxplpc.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,6 +31,9 @@ Packages * - ``framework-mbed`` - `mbed Framework `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-gccarmnoneeabi`` - `gcc-arm-embedded `_, `GDB `_ diff --git a/docs/platforms/siliconlabsefm32.rst b/docs/platforms/siliconlabsefm32.rst index c4829f08..ac92c554 100644 --- a/docs/platforms/siliconlabsefm32.rst +++ b/docs/platforms/siliconlabsefm32.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,6 +31,9 @@ Packages * - ``framework-mbed`` - `mbed Framework `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-gccarmnoneeabi`` - `gcc-arm-embedded `_, `GDB `_ diff --git a/docs/platforms/ststm32.rst b/docs/platforms/ststm32.rst index fb1acfa4..d66e1f71 100644 --- a/docs/platforms/ststm32.rst +++ b/docs/platforms/ststm32.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,26 +28,26 @@ Packages * - Name - Contents - * - ``framework-libopencm3`` - - `libOpenCM3 Framework `_ - - * - ``toolchain-gccarmnoneeabi`` - - `gcc-arm-embedded `_, `GDB `_ - - * - ``tool-stlink`` - - `ST-Link `_ - - * - ``framework-spl`` - - `Standard Peripheral Library for STM32 MCUs `_ - * - ``framework-cmsis`` - `Vendor-independent hardware abstraction layer for the Cortex-M processor series `_ + * - ``framework-libopencm3`` + - `libOpenCM3 Framework `_ + * - ``framework-mbed`` - `mbed Framework `_ - * - ``ldscripts`` - - `Linker Scripts `_ + * - ``framework-spl`` + - `Standard Peripheral Library for STM32 MCUs `_ + + * - ``tool-scons`` + - `SCons software construction tool `_ + + * - ``tool-stlink`` + - `ST-Link `_ + + * - ``toolchain-gccarmnoneeabi`` + - `gcc-arm-embedded `_, `GDB `_ .. warning:: **Linux Users:** Don't forget to install "udev" rules file @@ -73,12 +73,12 @@ Frameworks * - :ref:`framework_libopencm3` - The libOpenCM3 framework aims to create a free/libre/open-source firmware library for various ARM Cortex-M0(+)/M3/M4 microcontrollers, including ST STM32, Ti Tiva and Stellaris, NXP LPC 11xx, 13xx, 15xx, 17xx parts, Atmel SAM3, Energy Micro EFM32 and others. - * - :ref:`framework_mbed` - - The mbed framework The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community. - * - :ref:`framework_spl` - The ST Standard Peripheral Library provides a set of functions for handling the peripherals on the STM32 Cortex-M3 family. The idea is to save the user (the new user, in particular) having to deal directly with the registers. + * - :ref:`framework_mbed` + - The mbed framework The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community. + Boards ------ @@ -142,6 +142,26 @@ Armstrap - 512 Kb - 192 Kb +Generic +~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``bluepill_f103c8`` + - `BluePill F103C8 `_ + - STM32F103C8T6 + - 72 MHz + - 64 Kb + - 20 Kb + MultiTech ~~~~~~~~~ diff --git a/docs/platforms/ststm32_extra.rst b/docs/platforms/ststm32_extra.rst index 6a98012b..077a5517 100644 --- a/docs/platforms/ststm32_extra.rst +++ b/docs/platforms/ststm32_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/platforms/teensy.rst b/docs/platforms/teensy.rst index 0edcbcd2..ef95fc5b 100644 --- a/docs/platforms/teensy.rst +++ b/docs/platforms/teensy.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,20 +31,20 @@ Packages * - ``framework-arduinoteensy`` - `Arduino Wiring-based Framework `_ - * - ``tool-teensy`` - - `Teensy Loader `_ - - * - ``toolchain-gccarmnoneeabi`` - - `gcc-arm-embedded `_, `GDB `_ - * - ``framework-mbed`` - `mbed Framework `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + + * - ``tool-teensy`` + - `Teensy Loader `_ + * - ``toolchain-atmelavr`` - `avr-gcc `_, `GDB `_, `AVaRICE `_, `SimulAVR `_ - * - ``ldscripts`` - - `Linker Scripts `_ + * - ``toolchain-gccarmnoneeabi`` + - `gcc-arm-embedded `_, `GDB `_ .. warning:: **Linux Users:** Don't forget to install "udev" rules file diff --git a/docs/platforms/teensy_extra.rst b/docs/platforms/teensy_extra.rst index 360ea86c..77438896 100644 --- a/docs/platforms/teensy_extra.rst +++ b/docs/platforms/teensy_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/platforms/timsp430.rst b/docs/platforms/timsp430.rst index 28b25393..2218f8c8 100644 --- a/docs/platforms/timsp430.rst +++ b/docs/platforms/timsp430.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,17 +28,20 @@ Packages * - Name - Contents - * - ``toolchain-timsp430`` - - `msp-gcc `_, `GDB `_ - - * - ``tool-mspdebug`` - - `MSPDebug `_ + * - ``framework-arduinomsp430`` + - `Arduino Wiring-based Framework (MSP430 Core) `_ * - ``framework-energiamsp430`` - `Energia Wiring-based Framework (MSP430 Core) `_ - * - ``framework-arduinomsp430`` - - `Arduino Wiring-based Framework (MSP430 Core) `_ + * - ``tool-mspdebug`` + - `MSPDebug `_ + + * - ``tool-scons`` + - `SCons software construction tool `_ + + * - ``toolchain-timsp430`` + - `msp-gcc `_, `GDB `_ .. warning:: **Linux Users:** Don't forget to install "udev" rules file diff --git a/docs/platforms/timsp430_extra.rst b/docs/platforms/timsp430_extra.rst index 40e21277..e30f5e3b 100644 --- a/docs/platforms/timsp430_extra.rst +++ b/docs/platforms/timsp430_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/platforms/titiva.rst b/docs/platforms/titiva.rst index bf4d6288..2dae6a51 100644 --- a/docs/platforms/titiva.rst +++ b/docs/platforms/titiva.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,20 +28,20 @@ Packages * - Name - Contents - * - ``ldscripts`` - - `Linker Scripts `_ + * - ``framework-energiativa`` + - `Energia Wiring-based Framework (LM4F Core) `_ * - ``framework-libopencm3`` - `libOpenCM3 Framework `_ - * - ``toolchain-gccarmnoneeabi`` - - `gcc-arm-embedded `_, `GDB `_ - * - ``tool-lm4flash`` - `Flash Programmer `_ - * - ``framework-energiativa`` - - `Energia Wiring-based Framework (LM4F Core) `_ + * - ``tool-scons`` + - `SCons software construction tool `_ + + * - ``toolchain-gccarmnoneeabi`` + - `gcc-arm-embedded `_, `GDB `_ .. warning:: **Linux Users:** Don't forget to install "udev" rules file @@ -61,12 +61,12 @@ Frameworks * - Name - Description - * - :ref:`framework_energia` - - Energia Wiring-based framework enables pretty much anyone to start easily creating microcontroller-based projects and applications. Its easy-to-use libraries and functions provide developers of all experience levels to start blinking LEDs, buzzing buzzers and sensing sensors more quickly than ever before. - * - :ref:`framework_libopencm3` - The libOpenCM3 framework aims to create a free/libre/open-source firmware library for various ARM Cortex-M0(+)/M3/M4 microcontrollers, including ST STM32, Ti Tiva and Stellaris, NXP LPC 11xx, 13xx, 15xx, 17xx parts, Atmel SAM3, Energy Micro EFM32 and others. + * - :ref:`framework_energia` + - Energia Wiring-based framework enables pretty much anyone to start easily creating microcontroller-based projects and applications. Its easy-to-use libraries and functions provide developers of all experience levels to start blinking LEDs, buzzing buzzers and sensing sensors more quickly than ever before. + Boards ------ diff --git a/docs/platforms/titiva_extra.rst b/docs/platforms/titiva_extra.rst index bdc91b0c..5830ab70 100644 --- a/docs/platforms/titiva_extra.rst +++ b/docs/platforms/titiva_extra.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/docs/platforms/windows_x86.rst b/docs/platforms/windows_x86.rst index 6f904a0b..a35f48d6 100644 --- a/docs/platforms/windows_x86.rst +++ b/docs/platforms/windows_x86.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,5 +28,8 @@ Packages * - Name - Contents + * - ``tool-scons`` + - `SCons software construction tool `_ + * - ``toolchain-gccmingw32`` - `MinGW `_ \ No newline at end of file diff --git a/docs/plus/unit-testing.rst b/docs/plus/unit-testing.rst new file mode 100644 index 00000000..e8c08219 --- /dev/null +++ b/docs/plus/unit-testing.rst @@ -0,0 +1,480 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.. _unit_testing: + +Unit Testing +============ + +.. versionadded:: 3.0 (`PlatformIO Plus `_) + +`Unit Testing (wiki) `_ +is a software testing method by which individual units of source code, sets +of one or more MCU program modules together with associated control data, +usage procedures, and operating procedures, are tested to determine whether +they are fit for use. Unit testing finds problems early in the development cycle. + +PlatformIO Testing Engine supports 2 different test types: + +1. **Local Test** - *[host, native]*, process test on the host machine + using :ref:`platform_native`. +2. **Embedded Test** - *[remote, hardware]*, prepare special firmware for the + target device and upload it. Run test on the embedded device and collect + results. Process test results on the host machine. + + You will be able to run the same test on the different target devices + (:ref:`embedded_boards`). + +PlatformIO Testing Engine consists of: + +* Project builder +* Test builder +* Firmware uploader (is used only for embedded test) +* Test processor + +There is special command :ref:`cmd_test` to run tests from PlatformIO Project. +It allows to process specific environments or to ignore some tests using +"Glob patterns". + +Also, is possible to ignore some tests for specific environment using +:ref:`projectconf_test_ignore` option from :ref:`projectconf`. + +.. contents:: + +Demo +---- + +Demo of `Local & Embedded: Calculator `_. + +.. image:: ../_static/pioplus-unit-testing-demo.png + :target: https://youtu.be/bo3VVRZVKhA + +.. _unit_testing_design: + +Design +------ + +PlatformIO Testing Engine design is based on a few isolated components: + +1. **Main program**. Contains the independent modules, procedures, + functions or methods that will be the target candidates (TC) for testing. +2. **Unit test**. This a small independent program that is intended to + re-use TC from the main program and apply tests for them. +3. **Test processor**. The set of approaches and tools that will be used + to apply test for the environments from :ref:`projectconf`. + +Workflow +-------- + +1. Create PlatformIO project using :ref:`cmd_init` command. For Local Unit + Testing (on the host machine), need to use :ref:`platform_native`. + + .. code-block:: ini + + ; PlatformIO Project Configuration File + ; + ; Build options: build flags, source filter, extra scripting + ; Upload options: custom port, speed and extra flags + ; Library options: dependencies, extra library storages + ; + ; Please visit documentation for the other options and examples + ; http://docs.platformio.org/en/stable/projectconf.html + + ; + ; Embedded platforms + ; + + [env:uno] + platform = atmelavr + framework = arduino + board = uno + + [env:nodemcu] + platform = espressif8266 + framework = arduino + board = nodemcuv2 + + ; + ; Local (PC, native) platforms + ; + + [env:local] + platform = native + +2. Place source code of main program to ``src`` directory. +3. Wrap ``main()`` or ``setup()/loop()`` methods of main program in ``UNIT_TEST`` + guard: + + .. code-block:: c + + /** + * Arduino Wiring-based Framework + */ + #ifndef UNIT_TEST + #include + void setup () { + // some code... + } + + void loop () { + // some code... + } + #endif + + + .. code-block:: c + + /** + * Generic C/C++ + */ + #ifndef UNIT_TEST + int main(int argc, char **argv) { + // setup code... + + while (1) { + // loop code... + } + return 0 + } + #endif + +4. Create ``test`` directory in the root of project. See :ref:`projectconf_pio_test_dir`. +5. Write test using :ref:`unit_testing_api`. The each test is a small + independent program with own ``main()`` or ``setup()/loop()`` methods. Also, + test should start from ``UNITY_BEGIN()`` and finish with ``UNITY_END()``. +6. Place test to ``test`` directory. If you have more than one test, split them + into sub-folders. For example, ``test/test_1/*.[c,cpp,h]``, + ``test_N/*.[c,cpp,h]``, etc. If no such directory in ``test`` folder, then + PlatformIO Testing Engine will treat the source code of ``test`` folder + as SINGLE test. +7. Run tests using :ref:`cmd_test` command. + +.. _unit_testing_api: + +Test API +-------- + +The summary of `Unity Test API `_: + +* `Running Tests `_ + + - ``RUN_TEST(func, linenum)`` + +* `Ignoring Tests `_ + + - ``TEST_IGNORE()`` + - ``TEST_IGNORE_MESSAGE (message)`` + +* `Aborting Tests `_ + + - ``TEST_PROTECT()`` + - ``TEST_ABORT()`` + +* `Basic Validity Tests `_ + + - ``TEST_ASSERT_TRUE(condition)`` + - ``TEST_ASSERT_FALSE(condition)`` + - ``TEST_ASSERT(condition)`` + - ``TEST_ASSERT_UNLESS(condition)`` + - ``TEST_FAIL()`` + - ``TEST_FAIL_MESSAGE(message)`` + +* `Numerical Assertions: Integers `_ + + - ``TEST_ASSERT_EQUAL_INT(expected, actual)`` + - ``TEST_ASSERT_EQUAL_INT8(expected, actual)`` + - ``TEST_ASSERT_EQUAL_INT16(expected, actual)`` + - ``TEST_ASSERT_EQUAL_INT32(expected, actual)`` + - ``TEST_ASSERT_EQUAL_INT64(expected, actual)`` + + - ``TEST_ASSERT_EQUAL_UINT(expected, actual)`` + - ``TEST_ASSERT_EQUAL_UINT8(expected, actual)`` + - ``TEST_ASSERT_EQUAL_UINT16(expected, actual)`` + - ``TEST_ASSERT_EQUAL_UINT32(expected, actual)`` + - ``TEST_ASSERT_EQUAL_UINT64(expected, actual)`` + + - ``TEST_ASSERT_EQUAL_HEX(expected, actual)`` + - ``TEST_ASSERT_EQUAL_HEX8(expected, actual)`` + - ``TEST_ASSERT_EQUAL_HEX16(expected, actual)`` + - ``TEST_ASSERT_EQUAL_HEX32(expected, actual)`` + - ``TEST_ASSERT_EQUAL_HEX64(expected, actual)`` + - ``TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)`` + + - ``TEST_ASSERT_EQUAL(expected, actual)`` + - ``TEST_ASSERT_INT_WITHIN(delta, expected, actual)`` + +* `Numerical Assertions: Bitwise `_ + + - ``TEST_ASSERT_BITS(mask, expected, actual)`` + - ``TEST_ASSERT_BITS_HIGH(mask, actual)`` + - ``TEST_ASSERT_BITS_LOW(mask, actual)`` + - ``TEST_ASSERT_BIT_HIGH(mask, actual)`` + - ``TEST_ASSERT_BIT_LOW(mask, actual)`` + +* `Numerical Assertions: Floats `_ + + - ``TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)`` + - ``TEST_ASSERT_EQUAL_FLOAT(expected, actual)`` + - ``TEST_ASSERT_EQUAL_DOUBLE(expected, actual)`` + +* `String Assertions `_ + + - ``TEST_ASSERT_EQUAL_STRING(expected, actual)`` + - ``TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len)`` + - ``TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)`` + - ``TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message)`` + +* `Pointer Assertions `_ + + - ``TEST_ASSERT_NULL(pointer)`` + - ``TEST_ASSERT_NOT_NULL(pointer)`` + +* `Memory Assertions `_ + + - ``TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)`` + +Test "Blink" Project +-------------------- + +1. Please follow to :ref:`quickstart` and create "Blink Project". According + to the Unit Testing :ref:`unit_testing_design` it is the **Main program**. +2. Create ``test`` directory in that project (on the same level as ``src``) + and place ``test_main.cpp`` file to it (the source code is located below). +3. Wrap ``setup()`` and ``loop()`` methods of main program in ``UNIT_TEST`` + guard. +4. Run tests using :ref:`cmd_test` command. + +Project structure +~~~~~~~~~~~~~~~~~ + +.. code-block:: bash + + project_dir + ├── lib + │   └── readme.txt + ├── platformio.ini + ├── src + │   └── main.cpp + └── test + └── test_main.cpp + +Source files +~~~~~~~~~~~~ + +* ``platformio.ini`` + + .. code-block:: ini + + ; PlatformIO Project Configuration File + ; + ; Build options: build flags, source filter, extra scripting + ; Upload options: custom port, speed and extra flags + ; Library options: dependencies, extra library storages + ; + ; Please visit documentation for the other options and examples + ; http://docs.platformio.org/en/stable/projectconf.html + + + [env:uno] + platform = atmelavr + framework = arduino + board = uno + + [env:nodemcu] + platform = espressif8266 + framework = arduino + board = nodemcu + + [env:teensy31] + platform = teensy + framework = arduino + board = teensy31 + +* ``src/main.cpp`` + + .. code-block:: cpp + + /* + * Blink + * Turns on an LED on for one second, + * then off for one second, repeatedly. + */ + + #include "Arduino.h" + + #ifndef UNIT_TEST // IMPORTANT LINE! + + void setup() + { + // initialize LED digital pin as an output. + pinMode(LED_BUILTIN, OUTPUT); + } + + void loop() + { + // turn the LED on (HIGH is the voltage level) + digitalWrite(LED_BUILTIN, HIGH); + // wait for a second + delay(1000); + // turn the LED off by making the voltage LOW + digitalWrite(LED_BUILTIN, LOW); + // wait for a second + delay(1000); + } + + #endif // IMPORTANT LINE! + +* ``test/test_main.cpp`` + + .. code-block:: cpp + + #include + #include + + #ifdef UNIT_TEST + + // void setUp(void) { + // // set stuff up here + // } + + // void tearDown(void) { + // // clean stuff up here + // } + + void test_led_builtin_pin_number(void) { + TEST_ASSERT_EQUAL(LED_BUILTIN, 13); + } + + void test_led_state_high(void) { + digitalWrite(LED_BUILTIN, HIGH); + TEST_ASSERT_EQUAL(digitalRead(LED_BUILTIN), HIGH); + } + + void test_led_state_low(void) { + digitalWrite(LED_BUILTIN, LOW); + TEST_ASSERT_EQUAL(digitalRead(LED_BUILTIN), LOW); + } + + void setup() { + UNITY_BEGIN(); // IMPORTANT LINE! + RUN_TEST(test_led_builtin_pin_number); + + pinMode(LED_BUILTIN, OUTPUT); + } + + uint8_t i = 0; + uint8_t max_blinks = 5; + + void loop() { + if (i < max_blinks) + { + RUN_TEST(test_led_state_high); + delay(500); + RUN_TEST(test_led_state_low); + delay(500); + i++; + } + else if (i == max_blinks) { + UNITY_END(); // stop unit testing + } + } + + #endif + +Test results +~~~~~~~~~~~~ + +.. code:: + + > platformio test -e nodemcu --verbose + + PlatformIO Plus (https://pioplus.com) v0.1.0 + Verbose mode can be enabled via `-v, --verbose` option + Collected 1 items + + ============================== [test::*] Building... (1/3) ============================== + [Wed Sep 7 15:16:55 2016] Processing nodemcu (platform: espressif8266, board: nodemcu, framework: arduino) + ---------------------------------------------------------------------------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 34 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/nodemcu/src/main.o + Compiling .pioenvs/nodemcu/test/output_export.o + Compiling .pioenvs/nodemcu/test/test_main.o + Compiling .pioenvs/nodemcu/UnityTestLib/unity.o + Archiving .pioenvs/nodemcu/libFrameworkArduinoVariant.a + Indexing .pioenvs/nodemcu/libFrameworkArduinoVariant.a + Compiling .pioenvs/nodemcu/FrameworkArduino/Esp.o + Compiling .pioenvs/nodemcu/FrameworkArduino/FS.o + Compiling .pioenvs/nodemcu/FrameworkArduino/HardwareSerial.o + Compiling .pioenvs/nodemcu/FrameworkArduino/IPAddress.o + Archiving .pioenvs/nodemcu/libUnityTestLib.a + Indexing .pioenvs/nodemcu/libUnityTestLib.a + Compiling .pioenvs/nodemcu/FrameworkArduino/MD5Builder.o + ... + Compiling .pioenvs/nodemcu/FrameworkArduino/umm_malloc/umm_malloc.o + Archiving .pioenvs/nodemcu/libFrameworkArduino.a + Indexing .pioenvs/nodemcu/libFrameworkArduino.a + Linking .pioenvs/nodemcu/firmware.elf + Calculating size .pioenvs/nodemcu/firmware.elf + text data bss dec hex filename + 223500 2408 29536 255444 3e5d4 .pioenvs/nodemcu/firmware.elf + Building .pioenvs/nodemcu/firmware.bin + + ============================== [test::*] Uploading... (2/3) ============================== + [Wed Sep 7 15:17:01 2016] Processing nodemcu (platform: espressif8266, board: nodemcu, framework: arduino) + ---------------------------------------------------------------------------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 34 compatible libraries + Looking for dependencies... + Project does not have dependencies + Linking .pioenvs/nodemcu/firmware.elf + Checking program size .pioenvs/nodemcu/firmware.elf + text data bss dec hex filename + 223500 2408 29536 255444 3e5d4 .pioenvs/nodemcu/firmware.elf + Calculating size .pioenvs/nodemcu/firmware.elf + text data bss dec hex filename + 223500 2408 29536 255444 3e5d4 .pioenvs/nodemcu/firmware.elf + Looking for upload port... + Auto-detected: /dev/cu.SLAB_USBtoUART + Uploading .pioenvs/nodemcu/firmware.bin + Uploading 230064 bytes from .pioenvs/nodemcu/firmware.bin to flash at 0x00000000 + ................................................................................ [ 35% ] + ................................................................................ [ 71% ] + ................................................................. [ 100% ] + + =============================== [test::*] Testing... (3/3) =============================== + If you don't see any output for the first 10 secs, please reset board (press reset button) + + test/test_main.cpp:41:test_led_state_high [PASSED] + test/test_main.cpp:43:test_led_state_low [PASSED] + test/test_main.cpp:41:test_led_state_high [PASSED] + test/test_main.cpp:43:test_led_state_low [PASSED] + test/test_main.cpp:41:test_led_state_high [PASSED] + test/test_main.cpp:43:test_led_state_low [PASSED] + test/test_main.cpp:41:test_led_state_high [PASSED] + test/test_main.cpp:43:test_led_state_low [PASSED] + ----------------------- + 11 Tests 1 Failures 0 Ignored + + ===================================== [TEST SUMMARY] ===================================== + test:*/env:nodemcu [PASSED] + ================================ [PASSED] Took 38.15 seconds ================================ + +Examples +-------- + +* `Embedded: Wiring Blink `_ +* `Local & Embedded: Calculator `_ + +For the other examples and source code please follow to +`PlatformIO Unit Testing Examples `_ repository. diff --git a/docs/projectconf.rst b/docs/projectconf.rst index f6835544..832c2571 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -18,7 +18,7 @@ The Project configuration file is named ``platformio.ini``. This is a `INI-style `_ file. ``platformio.ini`` has sections (each denoted by a ``[header]``) and -key / value pairs within the sections. Lines beginning with ``#`` or ``;`` +key / value pairs within the sections. Lines beginning with ``;`` are ignored and may be used to provide comments. The sections and their allowable values are described below. @@ -44,8 +44,8 @@ Options ``home_dir`` ^^^^^^^^^^^^ -Is used to store platform toolchains, frameworks, external libraries, -service data and etc. +Is used to store platform toolchains, frameworks, global libraries for +:ref: `ldf`, service data and etc. A default value is User's home directory: @@ -60,18 +60,59 @@ This option can be overridden by global environment variable ``lib_dir`` ^^^^^^^^^^^ -This directory is used to store external libraries downloaded by -:ref:`librarymanager`. +You can put here your own/private libraries. The source code of each library +should be placed in separate directory, like +``lib/private_lib/[here are source files]``. This directory has the highest +priority for :ref:`ldf`. -A default value is ``%home_dir%/lib``. +A default value is ``lib`` that means that folder is located in the root of +project. This option can be overridden by global environment variable :envvar:`PLATFORMIO_LIB_DIR`. -.. note:: - You can put here your own/private libraries. The source code of each - library should be placed in separate directory. For example, - ``%lib_dir%/private_lib/[here are source files]``. +For example, see how can be organized ``Foo`` and ``Bar`` libraries: + +.. code:: + + |--lib + | |--Bar + | | |--docs + | | |--examples + | | |--src + | | |- Bar.c + | | |- Bar.h + | |--Foo + | | |- Foo.c + | | |- Foo.h + |- platformio.ini + |--src + |- main.c + + +Then in ``src/main.c`` you should use: + +.. code-block:: c + + #include + #include + + // rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +.. _projectconf_pio_libdeps_dir: + +``libdeps_dir`` +^^^^^^^^^^^^^^^ + +Internal storage where :ref:`librarymanager` will install project dependencies +(:ref:`projectconf_lib_deps`). A default value is ``.piolibdeps`` that means +that folder is located in the root of project. + +This option can be overridden by global environment variable +:envvar:`PLATFORMIO_LIBDEPS_DIR`. .. _projectconf_pio_src_dir: @@ -79,10 +120,8 @@ This option can be overridden by global environment variable ^^^^^^^^^^^ A path to project's source directory. PlatformIO uses it for :ref:`cmd_run` -command. - -A default value is ``src`` which means that folder is located in the root of -project. +command. A default value is ``src`` that means that folder is located in the +root of project. This option can be overridden by global environment variable :envvar:`PLATFORMIO_SRC_DIR`. @@ -110,14 +149,14 @@ fast! then PlatformIO will remove this folder automatically. It will be created on the next build operation. -A default value is ``.pioenvs`` which means that folder is located in the root of +A default value is ``.pioenvs`` that means that folder is located in the root of project. This option can be overridden by global environment variable :envvar:`PLATFORMIO_ENVS_DIR`. .. note:: - If you have any problems with building your Project environmets which + If you have any problems with building your Project environments which are defined in :ref:`projectconf`, then **TRY TO DELETE** this folder. In this situation you will remove all cached files without any risk. @@ -127,13 +166,24 @@ This option can be overridden by global environment variable ^^^^^^^^^^^^ Data directory to store contents and :ref:`platform_espressif_uploadfs`. - -A default value is ``data`` which means that folder is located in the root of +A default value is ``data`` that means that folder is located in the root of project. This option can be overridden by global environment variable :envvar:`PLATFORMIO_DATA_DIR`. +.. _projectconf_pio_test_dir: + +``test_dir`` +^^^^^^^^^^^^ + +Directory where :ref:`unit_testing` engine will look for the tests. +A default value is ``test`` that means that folder is located in the root of +project. + +This option can be overridden by global environment variable +:envvar:`PLATFORMIO_TEST_DIR`. + .. _projectconf_pio_env_default: ``env_default`` @@ -144,8 +194,8 @@ if :option:`platformio run --environment` option is not specified. :ref:`projectconf_pio_env_default` allows to define environments which should be processed by default. -Multiple environments are allowed if they are separated with ``,`` (comma). -For example. +Multiple environments are allowed if they are separated with ", " +(comma+space). For example. .. code-block:: ini @@ -158,7 +208,7 @@ For example. board = uno [env:nodemcu] - platform = espressif + platform = espressif8266 framework = arduino board = nodemcu @@ -193,22 +243,50 @@ For example, ``[env:hello_world]``. General options ~~~~~~~~~~~~~~~ +.. contents:: + :local: + .. _projectconf_env_platform: ``platform`` ^^^^^^^^^^^^ -:ref:`platforms` type. +:ref:`platforms` name. +PlatformIO allows to use specific version of platform using +`Semantic Versioning `_ (X.Y.Z=MAJOR.MINOR.PATCH). +Version specifications can take any of the following forms: + +* ``0.1.2``: an exact version number. Use only this exact version +* ``^0.1.2``: any compatible version (exact version for ``0.x.x`` versions +* ``~0.1.2``: any version with the same major and minor versions, and an + equal or greater patch version +* ``>0.1.2``: any version greater than ``0.1.2``. ``>=``, ``<``, and ``<=`` + are also possible +* ``>0.1.0,!=0.2.0,<0.3.0``: any version greater than ``0.1.0``, not equal to + ``0.2.0`` and less than ``0.3.0`` + +Examples: + +.. code-block:: ini + + [env:the_latest_version] + platform = atmelavr + + [env:specific_major_version] + platform = atmelavr@^0.1.2 + + [env:specific_major_and_minor_version] + platform = atmelavr@~0.1.2 .. _projectconf_env_framework: ``framework`` ^^^^^^^^^^^^^ -:ref:`Framework ` type. +:ref:`frameworks` name. -The multiple frameworks are allowed, split them with comma ``,`` separator. +The multiple frameworks are allowed, split them with comma+space ", ". .. _projectconf_env_board: @@ -227,6 +305,9 @@ using `PlatformIO Embedded Boards Explorer `_. Board options ~~~~~~~~~~~~~ +.. contents:: + :local: + ``board_mcu`` ^^^^^^^^^^^^^ @@ -261,7 +342,7 @@ format of this option is ``C-like long integer`` value with ``L`` suffix. The 1 Hertz is equal to ``1L``, then 40 Mhz (Mega Hertz) is equal to ``40000000L``. This option isn't available for the all development platforms. The only -:ref:`platform_espressif` supports it. +:ref:`platform_espressif8266` supports it. .. _projectconf_board_flash_mode: @@ -269,10 +350,13 @@ This option isn't available for the all development platforms. The only ^^^^^^^^^^^^^^^^^^^^ Flash chip interface mode. This option isn't available for the all development -platforms. The only :ref:`platform_espressif` supports it. +platforms. The only :ref:`platform_espressif8266` supports it. -Building options -~~~~~~~~~~~~~~~~ +Build options +~~~~~~~~~~~~~ + +.. contents:: + :local: .. _projectconf_build_flags: @@ -356,7 +440,7 @@ Example: build_flags = -Wl,-T/path/to/ld_script.ld [env:exec_command] - # get VCS revision "on-the-fly" + ; get VCS revision "on-the-fly" build_flags = !echo "-DPIO_SRC_REV="$(git rev-parse HEAD) @@ -388,6 +472,8 @@ but will be applied only for the project source code from This option can be set by global environment variable :envvar:`PLATFORMIO_SRC_BUILD_FLAGS`. +.. _projectconf_build_unflags: + ``build_unflags`` ^^^^^^^^^^^^^^^^^ @@ -416,7 +502,7 @@ be applied in theirs order. By default, ``src_filter`` is predefined to ``+<*> -<.git/> - - - - -``, -which means "includes ALL files, then +that means "includes ALL files, then exclude ``.git`` and ``svn`` repository folders, ``example`` ... folder. This option can be set by global environment variable @@ -427,6 +513,9 @@ This option can be set by global environment variable ``extra_script`` ^^^^^^^^^^^^^^^^ +.. contents:: + :local: + Allows to launch extra script using `SCons `_ software construction tool. For more details please follow to "Construction Environments" section of @@ -435,13 +524,23 @@ section of This option can be set by global environment variable :envvar:`PLATFORMIO_EXTRA_SCRIPT`. +Take a look at the multiple snippets/answers for the user questions: + + - `#462 Split C/C++ build flags `_ + - `#365 Extra configuration for ESP8266 uploader `_ + - `#351 Specific reset method for ESP8266 `_ + - `#247 Specific options for avrdude `_. + +Custom Uploader +''''''''''''''' + Example, specify own upload command for :ref:`platform_atmelavr`: ``platformio.ini``: .. code-block:: ini - [env:env_with_specific_extra_script] + [env:env_custom_uploader] platform = atmelavr extra_script = /path/to/extra_script.py custom_option = hello @@ -450,9 +549,7 @@ Example, specify own upload command for :ref:`platform_atmelavr`: .. code-block:: python - from SCons.Script import DefaultEnvironment - - env = DefaultEnvironment() + Import('env') env.Replace(UPLOADHEXCMD='"$UPLOADER" ${ARGUMENTS.get("custom_option")} --uploader --flags') @@ -460,14 +557,52 @@ Example, specify own upload command for :ref:`platform_atmelavr`: # print env.Dump() # print ARGUMENTS +Before/Pre and After/Post actions +''''''''''''''''''''''''''''''''' -* see built-in examples of `PlatformIO build scripts `_. -* take a look at the multiple snippets/answers for the user questions: +PlatformIO Build System has rich API that allows to attach different pre-/post +actions (hooks) using ``env.AddPreAction(target, callback)`` function. A first +argument ``target`` can be a name of target that is passed using +:option:`platformio run --target` command or path to file which PlatformIO +processes (ELF, HEX, BIN, etc.). For example, to call function before HEX file +will be created, need to use as a ``$BUILD_DIR/firmware.hex`` target value. - - `#462 Split C/C++ build flags `_ - - `#365 Extra configuration for ESP8266 uploader `_ - - `#351 Specific reset method for ESP8266 `_ - - `#247 Specific options for avrdude `_. +The example below demonstrates how to call different functions +when :option:`platformio run --target` is called with ``upload`` value. +`extra_script.py` file is located on the same level as ``platformio.ini``. + +``platformio.ini``: + +.. code-block:: ini + + [env:pre_and_post_hooks] + extra_script = extra_script.py + +``extra_script.py``: + +.. code-block:: python + + Import("env") + + def before_upload(source, target, env): + print "before_upload" + # do some actions + + + def after_upload(source, target, env): + print "after_upload" + # do some actions + + print "Current build targets", map(str, BUILD_TARGETS) + + # env.AddPreAction("$BUILD_DIR/firmware.elf", callback...) + # env.AddPostAction("$BUILD_DIR/firmware.hex", callback...) + + env.AddPreAction("upload", before_upload) + env.AddPostAction("upload", after_upload) + + +.. _projectconf_targets: ``targets`` ^^^^^^^^^^^ @@ -485,14 +620,17 @@ The list with available targets is located in :option:`platformio run --target`. # clean project platformio run -t clean - # dump curent build environment + # dump current build environment platformio run --target envdump When no targets are defined, *PlatformIO* will build only sources by default. -Uploading options -~~~~~~~~~~~~~~~~~ +Upload options +~~~~~~~~~~~~~~ + +.. contents:: + :local: .. _projectconf_upload_port: @@ -509,7 +647,7 @@ This option is used by "uploader" tool when sending firmware to board via If ``upload_port`` isn't specified, then *PlatformIO* will try to detect it automatically. -To print all available serial ports use :ref:`cmd_serialports` command. +To print all available serial ports use :ref:`cmd_device` command. This option can be set by global environment variable :envvar:`PLATFORMIO_UPLOAD_PORT`. @@ -544,70 +682,201 @@ This option can be set by global environment variable ^^^^^^^^^^^^^^^^^^^^^^ Specify reset method for "uploader" tool. This option isn't available for all -development platforms. The only :ref:`platform_espressif` supports it. +development platforms. The only :ref:`platform_espressif8266` supports it. Library options ~~~~~~~~~~~~~~~ -``lib_install`` -^^^^^^^^^^^^^^^ +.. contents:: + :local: -Specify dependent libraries which should be installed before environment -process. The only library IDs are allowed. Multiple libraries can be passed -using comma ``,`` sign. +.. _projectconf_lib_deps: -You can obtain library IDs using :ref:`cmd_lib_search` command. +``lib_deps`` +^^^^^^^^^^^^ + +.. versionadded:: 3.0 +.. seealso:: + Please make sure to read :ref:`ldf` guide first. + +Specify project dependencies that should be installed automatically to +:ref:`projectconf_pio_libdeps_dir` before environment processing. +Multiple dependencies are allowed (multi-lines or separated with comma+space ", "). + +**Valid forms** + +.. code-block:: ini + + [env:myenv] + lib_deps = LIBRARY_1, LIBRARY_2, LIBRARY_N + + [env:myenv2] + lib_deps = + LIBRARY_1 + LIBRARY_2 + LIBRARY_N + +The each line with ``LIBRARY_1... LIBRARY_N`` will be passed automatically to +:ref:`cmd_lib_install` command. Please follow to :ref:`cmd_lib_install` for +detailed documentation about possible values. Example: .. code-block:: ini - [env:depends_on_some_libs] - lib_install = 1,13,19 + [env:depends_on_some_libs] + lib_deps = + 13 + PubSubClient + Json@~5.6,!=5.4 + https://github.com/gioblu/PJON.git@v2.0 + https://github.com/me-no-dev/ESPAsyncTCP.git -``lib_use`` -^^^^^^^^^^^ +.. _projectconf_lib_force: -Specify libraries which should be used by ``Library Dependency Finder (LDF)`` with -the highest priority. +``lib_force`` +^^^^^^^^^^^^^ + +.. seealso:: + Please make sure to read :ref:`ldf` guide first. + +Force Library Dependency Finder to depend on the specified library if it even +is not included in the project source code. Also, this library will be +processed in the first order. + +The correct value for this option is library name (not folder name). In the +most cases, library name is pre-defined in manifest file +(:ref:`library_config`, ``library.properties``, ``module.json``). The multiple +library names are allowed, split them with comma+space ", ". Example: .. code-block:: ini - [env:libs_with_highest_priority] - lib_use = OneWire_ID1,SPI + [env:myenv] + lib_force = OneWire, SPI + +.. _projectconf_lib_ignore: ``lib_ignore`` ^^^^^^^^^^^^^^ -Specify libraries which should be ignored by ``Library Dependency Finder (LDF)`` +.. seealso:: + Please make sure to read :ref:`ldf` guide first. + +Specify libraries which should be ignored by Library Dependency Finder. + +The correct value for this option is library name (not +folder name). In the most cases, library name is pre-defined in manifest file +(:ref:`library_config`, ``library.properties``, ``module.json``). The multiple +library names are allowed, split them with comma+space ", ". Example: .. code-block:: ini [env:ignore_some_libs] - lib_ignore = SPI,EngduinoV3_ID123 + lib_ignore = SPI, Ethernet -``lib_dfcyclic`` -^^^^^^^^^^^^^^^^ +.. _projectconf_lib_extra_dirs: -Control cyclic (recursive) behavior for ``Library Dependency Finder (LDF)``. -By default, this option is turned OFF (``lib_dfcyclic=False``) and means that -``LDF`` will find only libraries which are included in source files from the -project :ref:`projectconf_pio_src_dir`. +``lib_extra_dirs`` +^^^^^^^^^^^^^^^^^^ -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. +.. versionadded:: 3.0 +.. seealso:: + Please make sure to read :ref:`ldf` guide first. + +A list with extra directories/storages where :ref:`ldf` will +look for dependencies. Multiple paths are allowed. Please separate them +using comma+space ", ". + +This option can be set by global environment variable +:envvar:`PLATFORMIO_LIB_EXTRA_DIRS`. + +.. warning:: + This is a not direct path to library with source code. It should be the path + to storage that contains libraries grouped by folders. For example, + ``/extra/lib/storage/`` but not ``/extra/lib/storage/MyLibrary``. Example: .. code-block:: ini - [env:libs_with_enabled_ldf_cyclic] - lib_dfcyclic = True + [env:custom_lib_dirs] + lib_extra_dirs = /path/to/private/dir1,/path/to/private/dir2 + +.. _projectconf_lib_ldf_mode: + +``lib_ldf_mode`` +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.0 +.. seealso:: + Please make sure to read :ref:`ldf` guide first. + +This option specifies how does Library Dependency Finder should analyze +dependencies (``#include`` directives). See :ref:`ldf_mode` for details. + +.. _projectconf_lib_compat_mode: + +``lib_compat_mode`` +^^^^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.0 +.. seealso:: + Please make sure to read :ref:`ldf` guide first. + +Library compatibility mode allows to control strictness of Library Dependency +Finder. More details :ref:`ldf_compat_mode`. + +By default, this value is set to ``lib_compat_mode = 1`` and means that LDF +will check only for framework compatibility. + + +Test options +~~~~~~~~~~~~ + +.. contents:: + :local: + +.. _projectconf_test_ignore: + +``test_ignore`` +^^^^^^^^^^^^^^^ + +.. versionadded:: 3.0 +.. seealso:: + Please make sure to read :ref:`unit_testing` guide first. + +Ignore tests where the name matches specified patterns. Multiple names are +allowed. Please separate them using comma+space ", ". Also, you can +ignore some tests using :option:`platformio test --ignore` command. + +.. list-table:: + :header-rows: 1 + + * - Pattern + - Meaning + + * - ``*`` + - matches everything + + * - ``?`` + - matches any single character + + * - ``[seq]`` + - matches any character in seq + + * - ``[!seq]`` + - matches any character not in seq + +**Example** + +.. code-block:: ini + + [env:myenv] + test_ignore = footest, bartest_*, test[13] ----------- @@ -631,7 +900,7 @@ Examples framework = arduino board = uno - # enable auto-uploading + ; enable auto-uploading targets = upload @@ -646,12 +915,12 @@ Examples board_f_cpu = 16000000L upload_port = /dev/ttyUSB0 - # for Windows OS - # upload_port = COM3 + ; for Windows OS + ; upload_port = COM3 upload_protocol = arduino upload_speed = 19200 - # enable auto-uploading + ; enable auto-uploading targets = upload diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 57146752..83442cb9 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -82,11 +82,10 @@ According to the table above the ID/TYPE for Teensy 3.1 is ``teensy31``. Also, the ID for Arduino UNO is ``uno`` and for NodeMCU 1.0 (ESP-12E Module) is ``nodemcuv2``. - Initialize Project ------------------ -PlatformIO ecosystem contains huge database with pre-configured settings for the +PlatformIO ecosystem contains big database with pre-configured settings for the most popular embedded boards. It helps you to forget about installing toolchains, writing build scripts or configuring uploading process. Just tell PlatformIO the Board ID and you will receive full working project with @@ -146,12 +145,14 @@ The result of just generated ``platformio.ini``: .. code-block:: ini - # - # PlatformIO Project Configuration File - # - # Please make sure to read documentation with examples first - # http://docs.platformio.org/en/stable/projectconf.html - # + ; PlatformIO Project Configuration File + ; + ; Build options: build flags, source filter, extra scripting + ; Upload options: custom port, speed and extra flags + ; Library options: dependencies, extra library storages + ; + ; Please visit documentation for the other options and examples + ; http://docs.platformio.org/en/stable/projectconf.html [env:uno] platform = atmelavr @@ -159,7 +160,7 @@ The result of just generated ``platformio.ini``: board = uno [env:nodemcuv2] - platform = espressif + platform = espressif8266 framework = arduino board = nodemcuv2 diff --git a/docs/userguide/cmd_boards.rst b/docs/userguide/cmd_boards.rst index 83b7f86f..a4b0eae9 100644 --- a/docs/userguide/cmd_boards.rst +++ b/docs/userguide/cmd_boards.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -33,6 +33,11 @@ Options .. program:: platformio boards +.. option:: + --installed + +List boards only from the installed platforms + .. option:: --json-output diff --git a/docs/userguide/cmd_ci.rst b/docs/userguide/cmd_ci.rst index d97d3b96..87c3735b 100644 --- a/docs/userguide/cmd_ci.rst +++ b/docs/userguide/cmd_ci.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -35,19 +35,25 @@ with the build environments (using :option:`platformio ci --board` or :option:`platformio ci --project-conf`) and processes them via :ref:`cmd_run` command. +:ref:`cmd_ci` command accepts **multiple** ``SRC`` arguments, +:option:`platformio ci --lib` and :option:`platformio ci --exclude` options +which can be a path to directory, file or +`Glob Pattern `_. +Also, you can omit ``SRC`` argument and set path (multiple paths are allowed +denoting with ``:``) to +``PLATFORMIO_CI_SRC`` `Environment variable `_ + For more details as for integration with the popular Continuous Integration Systems please follow to :ref:`ci` page. .. note:: - :ref:`cmd_ci` command accepts **multiple** ``SRC`` arguments, - :option:`platformio ci --lib` and :option:`platformio ci --exclude` options - which can be a path to directory, file or - `Glob Pattern `_. - -.. note:: - You can omit ``SRC`` argument and set path (multiple paths are allowed - denoting with ``:``) to - ``PLATFORMIO_CI_SRC`` `Environment variable `_ + :ref:`cmd_ci` command is useful for library developers. It allows to build + different examples without creating own project per them. Also, is possible + to upload firmware to the target device. In this case, you need to pass + additional option ``--project-option="targets=upload"``. What is more, + you can specify custom upload port using + ``--project-option="upload_port="`` option. + See :option:`platformio ci --project-option` for details. Options ------- @@ -57,10 +63,10 @@ Options .. option:: -l, --lib -Source code which will be copied to ``%build_dir%/lib`` directly. +Source code which will be copied to ``/lib`` directly. If :option:`platformio ci --lib` is a path to file (not to directory), then -PlatformIO will create temporary directory within ``%build_dir%/lib`` and copy +PlatformIO will create temporary directory within ``/lib`` and copy the rest files into it. @@ -105,17 +111,28 @@ temporary directory within your operation system. Don't remove :option:`platformio ci --build-dir` after build process. .. option:: - --project-conf + -P, --project-conf Buid project using pre-configured :ref:`projectconf`. +.. option:: + -O, --project-option + +Pass additional options from :ref:`projectconf` to +:option:`platformio init --project-option` command. For example, +automatically install dependent libraries +``platformio ci --project-option="lib_deps=ArduinoJSON"`` or ignore specific +library ``platformio ci --project-option="lib_ignore=SomeLib"``. + .. option:: -v, --verbose -Shows details about the results of processing environments. More details -:option:`platformio run --verbose` +Shows detailed information when processing environments. + +This option can be set globally using :ref:`setting_force_verbose` setting +or by environment variable :envvar:`PLATFORMIO_SETTING_FORCE_VERBOSE`. Examples -------- -For the examples please follow to :ref:`ci` page. +For the others examples please follow to :ref:`ci` page. diff --git a/docs/userguide/cmd_serialports.rst b/docs/userguide/cmd_device.rst similarity index 91% rename from docs/userguide/cmd_serialports.rst rename to docs/userguide/cmd_device.rst index 963046b1..91d2fcd2 100644 --- a/docs/userguide/cmd_serialports.rst +++ b/docs/userguide/cmd_device.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,14 +9,14 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_serialports: +.. _cmd_device: -platformio serialports +platformio device ====================== .. contents:: -platformio serialports list +platformio device list --------------------------- Usage @@ -24,7 +24,7 @@ Usage .. code-block:: bash - platformio serialports list [OPTIONS] + platformio device list [OPTIONS] Description @@ -35,7 +35,7 @@ List available `Serial Ports `_ Options ~~~~~~~ -.. program:: platformio serialports list +.. program:: platformio device list .. option:: --json-output @@ -50,7 +50,7 @@ Examples .. code-block:: bash - $ platformio serialports list + $ platformio device list /dev/cu.SLAB_USBtoUART ---------- Hardware ID: USB VID:PID=10c4:ea60 SNR=0001 @@ -66,7 +66,7 @@ Examples .. code-block:: bash - $ platformio serialports list + $ platformio device list COM4 ---------- Hardware ID: USB VID:PID=0451:F432 @@ -78,9 +78,9 @@ Examples Description: Silicon Labs CP210x USB to UART Bridge (COM3) -.. _cmd_serialports_monitor: +.. _cmd_device_monitor: -platformio serialports monitor +platformio device monitor ------------------------------ Usage @@ -88,7 +88,7 @@ Usage .. code-block:: bash - platformio serialports monitor [OPTIONS] + platformio device monitor [OPTIONS] Description @@ -112,7 +112,7 @@ To control *monitor* please use these "hot keys": Options ~~~~~~~ -.. program:: platformio serialports monitor +.. program:: platformio device monitor .. option:: -p, --port @@ -194,7 +194,7 @@ ASCII code of special character that is used to exit the application, default ``29`` (DEC). For example, to use ``Ctrl+Q`` run -``platformio serialports monitor --exit-char 17``. +``platformio device monitor --exit-char 17``. .. option:: --menu-char @@ -238,8 +238,8 @@ multiple times: 3. hex dump everything **REMOVED**: Is not available in Miniterm/PySerial 3.0. -See :option:`platformio serialports monitor --encoding` and -:option:`platformio serialports monitor --filter` options. +See :option:`platformio device monitor --encoding` and +:option:`platformio device monitor --filter` options. Examples ~~~~~~~~ @@ -248,8 +248,8 @@ Examples .. code-block:: bash - $ platformio serialports monitor --help - Usage: platformio serialports monitor [OPTIONS] + $ platformio device monitor --help + Usage: platformio device monitor [OPTIONS] Options: -p, --port TEXT Port, a number or a device name @@ -276,7 +276,7 @@ Examples .. code-block:: bash - $ platformio serialports monitor + $ platformio device monitor --- Available ports: --- /dev/cu.Bluetooth-Incoming-Port n/a diff --git a/docs/userguide/cmd_init.rst b/docs/userguide/cmd_init.rst index 716ed155..a9dcb194 100644 --- a/docs/userguide/cmd_init.rst +++ b/docs/userguide/cmd_init.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -52,7 +52,7 @@ A path to the directory where *PlatformIO* will initialize new project. .. option:: -b, --board -If you specify board ``type`` (you can pass multiple ``--board`` options), then +If you specify board ``ID`` (you can pass multiple ``--board`` options), then *PlatformIO* will automatically generate environment for :ref:`projectconf` and pre-fill these data: @@ -65,18 +65,17 @@ The full list with pre-configured boards is available here :ref:`platforms`. .. option:: --ide -Initialise PlatformIO project for the specified IDE which can be imported later +Initialize PlatformIO project for the specified IDE which can be imported later via "Import Project" functionality. A list with supported IDE is available within ``platformio init --help`` command. Also, please take a look at :ref:`ide` page. .. option:: - --enable-auto-uploading + -O, --project-option -If you initialise project with the specified -:option:`platformio init --board`, then *PlatformIO* -will create environment with enabled firmware auto-uploading. +Initialize project with additional options from :ref:`projectconf`. For example, +``platformio init --project-option="lib_deps=ArduinoJSON"``. .. option:: --env-prefix @@ -104,7 +103,6 @@ Examples platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| src - Put your source files here lib - Put here project specific (private) libraries - Do you want to continue? [y/N]: y Project has been successfully initialized! Useful commands: `platformio run` - process/build project from the current directory @@ -122,14 +120,13 @@ Examples platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| src - Put your source files here lib - Put here project specific (private) libraries - Do you want to continue? [y/N]: y Project has been successfully initialized! Useful commands: `platformio run` - process/build project from the current directory `platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board `platformio run --target clean` - clean project (remove compiled files) -3. Initialise project for Arduino Uno +3. Initialize project for Arduino Uno .. code-block:: bash @@ -143,7 +140,6 @@ Examples platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| src - Put your source files here lib - Put here project specific (private) libraries - Do you want to continue? [y/N]: y Project has been successfully initialized! Useful commands: `platformio run` - process/build project from the current directory diff --git a/docs/userguide/cmd_run.rst b/docs/userguide/cmd_run.rst index 6034cb04..020c112a 100644 --- a/docs/userguide/cmd_run.rst +++ b/docs/userguide/cmd_run.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -64,7 +64,9 @@ Pre-built targets: --upload-port Upload port of embedded board. To print all available ports use -:ref:`cmd_serialports` command +:ref:`cmd_device` command. + +If upload port is not specified, PlatformIO will try to detect it automatically. .. option:: -d, --project-dir @@ -75,17 +77,10 @@ to current working directory (``CWD``). .. option:: -v, --verbose -Shows details about the results of processing environments. Each instance of -``--verbose`` on the command line increases the verbosity level by one, so if -you need more details on the output, specify it twice. +Shows detailed information when processing environments. -There 3 levels of verbosity: - -1. ``-v`` - output errors only -2. ``-vv`` - output errors and warnings -3. ``-vvv`` - output errors, warnings and additional information - -By default, verbosity level is set to 3 (maximum information). +This option can be set globally using :ref:`setting_force_verbose` setting +or by environment variable :envvar:`PLATFORMIO_SETTING_FORCE_VERBOSE`. .. option:: --disable-auto-clean @@ -98,87 +93,285 @@ Examples 1. Process `Wiring Blink Example `_ -.. code-block:: bash +.. code:: - $ platformio run - Processing arduino_pro5v environment: - scons: `.pioenvs/arduino_pro5v/firmware.elf' is up to date. - scons: `.pioenvs/arduino_pro5v/firmware.hex' is up to date. + > platformio run - Processing launchpad_msp430g2 environment: - scons: `.pioenvs/launchpad_msp430g2/firmware.elf' is up to date. - scons: `.pioenvs/launchpad_msp430g2/firmware.hex' is up to date. + [Wed Sep 7 15:48:58 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino) + ----------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 36 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/uno/src/main.o + Archiving .pioenvs/uno/libFrameworkArduinoVariant.a + Indexing .pioenvs/uno/libFrameworkArduinoVariant.a + Compiling .pioenvs/uno/FrameworkArduino/CDC.o + ... + Compiling .pioenvs/uno/FrameworkArduino/wiring_shift.o + Archiving .pioenvs/uno/libFrameworkArduino.a + Indexing .pioenvs/uno/libFrameworkArduino.a + Linking .pioenvs/uno/firmware.elf + Building .pioenvs/uno/firmware.hex + Calculating size .pioenvs/uno/firmware.elf + AVR Memory Usage + ---------------- + Device: atmega328p - Processing launchpad_lm4f120 environment: - scons: `.pioenvs/launchpad_lm4f120/firmware.elf' is up to date. - scons: `.pioenvs/launchpad_lm4f120/firmware.hex' is up to date + Program: 1034 bytes (3.2% Full) + (.text + .data + .bootloader) + Data: 9 bytes (0.4% Full) + (.data + .bss + .noinit) + + + =========================== [SUCCESS] Took 2.47 seconds =========================== + + [Wed Sep 7 15:49:01 2016] Processing nodemcu (platform: espressif8266, board: nodemcu, framework: arduino) + ----------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 34 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/nodemcu/src/main.o + Archiving .pioenvs/nodemcu/libFrameworkArduinoVariant.a + Indexing .pioenvs/nodemcu/libFrameworkArduinoVariant.a + Compiling .pioenvs/nodemcu/FrameworkArduino/Esp.o + Compiling .pioenvs/nodemcu/FrameworkArduino/FS.o + Compiling .pioenvs/nodemcu/FrameworkArduino/HardwareSerial.o + ... + Archiving .pioenvs/nodemcu/libFrameworkArduino.a + Indexing .pioenvs/nodemcu/libFrameworkArduino.a + Linking .pioenvs/nodemcu/firmware.elf + Calculating size .pioenvs/nodemcu/firmware.elf + text data bss dec hex filename + 221240 888 29400 251528 3d688 .pioenvs/nodemcu/firmware.elf + Building .pioenvs/nodemcu/firmware.bin + =========================== [SUCCESS] Took 6.43 seconds =========================== + + [Wed Sep 7 15:49:07 2016] Processing teensy31 (platform: teensy, board: teensy31, framework: arduino) + ----------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 96 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/teensy31/src/main.o + Compiling .pioenvs/teensy31/FrameworkArduino/AudioStream.o + Compiling .pioenvs/teensy31/FrameworkArduino/DMAChannel.o + ... + Compiling .pioenvs/teensy31/FrameworkArduino/yield.o + Archiving .pioenvs/teensy31/libFrameworkArduino.a + Indexing .pioenvs/teensy31/libFrameworkArduino.a + Linking .pioenvs/teensy31/firmware.elf + Calculating size .pioenvs/teensy31/firmware.elf + text data bss dec hex filename + 11288 168 2288 13744 35b0 .pioenvs/teensy31/firmware.elf + Building .pioenvs/teensy31/firmware.hex + =========================== [SUCCESS] Took 5.36 seconds =========================== + + [Wed Sep 7 15:49:12 2016] Processing lpmsp430g2553 (platform: timsp430, build_flags: -D LED_BUILTIN=RED_LED, board: lpmsp430g2553, framework: energia) + ----------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 29 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/lpmsp430g2553/src/main.o + Compiling .pioenvs/lpmsp430g2553/FrameworkEnergia/HardwareSerial.o + Compiling .pioenvs/lpmsp430g2553/FrameworkEnergia/IPAddress.o + ... + Compiling .pioenvs/lpmsp430g2553/FrameworkEnergia/wiring_digital.o + Compiling .pioenvs/lpmsp430g2553/FrameworkEnergia/wiring_pulse.o + Compiling .pioenvs/lpmsp430g2553/FrameworkEnergia/wiring_shift.o + Archiving .pioenvs/lpmsp430g2553/libFrameworkEnergia.a + Indexing .pioenvs/lpmsp430g2553/libFrameworkEnergia.a + Linking .pioenvs/lpmsp430g2553/firmware.elf + Calculating size .pioenvs/lpmsp430g2553/firmware.elf + text data bss dec hex filename + 820 0 20 840 348 .pioenvs/lpmsp430g2553/firmware.elf + Building .pioenvs/lpmsp430g2553/firmware.hex + =========================== [SUCCESS] Took 2.34 seconds =========================== 2. Process specific environment -.. code-block:: bash +.. code:: - $ platformio run -e arduino_pro5v -e launchpad_lm4f120 - Processing arduino_pro5v environment: - scons: `.pioenvs/arduino_pro5v/firmware.elf' is up to date. - scons: `.pioenvs/arduino_pro5v/firmware.hex' is up to date. + > platformio run -e nodemcu -e teensy31 - Processing launchpad_lm4f120 environment: - scons: `.pioenvs/launchpad_lm4f120/firmware.elf' is up to date. - scons: `.pioenvs/launchpad_lm4f120/firmware.hex' is up to date. - - -3. Process specific target - -.. code-block:: bash - - $ platformio run -t clean - Processing arduino_pro5v environment: - Removed .pioenvs/arduino_pro5v/src/main.o + [Wed Sep 7 15:49:01 2016] Processing nodemcu (platform: espressif8266, board: nodemcu, framework: arduino) + ----------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 34 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/nodemcu/src/main.o + Archiving .pioenvs/nodemcu/libFrameworkArduinoVariant.a + Indexing .pioenvs/nodemcu/libFrameworkArduinoVariant.a + Compiling .pioenvs/nodemcu/FrameworkArduino/Esp.o + Compiling .pioenvs/nodemcu/FrameworkArduino/FS.o + Compiling .pioenvs/nodemcu/FrameworkArduino/HardwareSerial.o ... - Removed .pioenvs/arduino_pro5v/firmware.hex + Archiving .pioenvs/nodemcu/libFrameworkArduino.a + Indexing .pioenvs/nodemcu/libFrameworkArduino.a + Linking .pioenvs/nodemcu/firmware.elf + Calculating size .pioenvs/nodemcu/firmware.elf + text data bss dec hex filename + 221240 888 29400 251528 3d688 .pioenvs/nodemcu/firmware.elf + Building .pioenvs/nodemcu/firmware.bin + =========================== [SUCCESS] Took 6.43 seconds =========================== - Processing launchpad_msp430g2 environment: - Removed .pioenvs/launchpad_msp430g2/src/main.o + [Wed Sep 7 15:49:07 2016] Processing teensy31 (platform: teensy, board: teensy31, framework: arduino) + ----------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 96 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/teensy31/src/main.o + Compiling .pioenvs/teensy31/FrameworkArduino/AudioStream.o + Compiling .pioenvs/teensy31/FrameworkArduino/DMAChannel.o ... - Removed .pioenvs/launchpad_msp430g2/firmware.hex + Compiling .pioenvs/teensy31/FrameworkArduino/yield.o + Archiving .pioenvs/teensy31/libFrameworkArduino.a + Indexing .pioenvs/teensy31/libFrameworkArduino.a + Linking .pioenvs/teensy31/firmware.elf + Calculating size .pioenvs/teensy31/firmware.elf + text data bss dec hex filename + 11288 168 2288 13744 35b0 .pioenvs/teensy31/firmware.elf + Building .pioenvs/teensy31/firmware.hex + =========================== [SUCCESS] Took 5.36 seconds =========================== - Processing launchpad_lm4f120 environment: - Removed .pioenvs/launchpad_lm4f120/src/main.o + +3. Process specific target (clean project) + +.. code:: bash + + > platformio run -t clean + [Wed Sep 7 15:53:26 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino) + ----------------------------------------------------------------------------------------------------- + Removed .pioenvs/uno/firmware.elf + Removed .pioenvs/uno/firmware.hex + Removed .pioenvs/uno/libFrameworkArduino.a + Removed .pioenvs/uno/libFrameworkArduinoVariant.a + Removed .pioenvs/uno/FrameworkArduino/_wiring_pulse.o + Removed .pioenvs/uno/FrameworkArduino/abi.o + Removed .pioenvs/uno/FrameworkArduino/CDC.o + Removed .pioenvs/uno/FrameworkArduino/HardwareSerial.o + Removed .pioenvs/uno/FrameworkArduino/HardwareSerial0.o + Removed .pioenvs/uno/FrameworkArduino/HardwareSerial1.o + Removed .pioenvs/uno/FrameworkArduino/HardwareSerial2.o + Removed .pioenvs/uno/FrameworkArduino/HardwareSerial3.o + Removed .pioenvs/uno/FrameworkArduino/hooks.o + Removed .pioenvs/uno/FrameworkArduino/IPAddress.o + Removed .pioenvs/uno/FrameworkArduino/main.o + Removed .pioenvs/uno/FrameworkArduino/new.o + Removed .pioenvs/uno/FrameworkArduino/PluggableUSB.o + Removed .pioenvs/uno/FrameworkArduino/Print.o + Removed .pioenvs/uno/FrameworkArduino/Stream.o + Removed .pioenvs/uno/FrameworkArduino/Tone.o + Removed .pioenvs/uno/FrameworkArduino/USBCore.o + Removed .pioenvs/uno/FrameworkArduino/WInterrupts.o + Removed .pioenvs/uno/FrameworkArduino/wiring.o + Removed .pioenvs/uno/FrameworkArduino/wiring_analog.o + Removed .pioenvs/uno/FrameworkArduino/wiring_digital.o + Removed .pioenvs/uno/FrameworkArduino/wiring_pulse.o + Removed .pioenvs/uno/FrameworkArduino/wiring_shift.o + Removed .pioenvs/uno/FrameworkArduino/WMath.o + Removed .pioenvs/uno/FrameworkArduino/WString.o + Removed .pioenvs/uno/src/main.o + Done cleaning + ======================= [SUCCESS] Took 0.49 seconds ======================= + + [Wed Sep 7 15:53:27 2016] Processing nodemcu (platform: espressif8266, board: nodemcu, framework: arduino) + ----------------------------------------------------------------------------------------------------- + Removed .pioenvs/nodemcu/firmware.bin + Removed .pioenvs/nodemcu/firmware.elf + Removed .pioenvs/nodemcu/libFrameworkArduino.a + Removed .pioenvs/nodemcu/libFrameworkArduinoVariant.a ... - Removed .pioenvs/launchpad_lm4f120/firmware.hex + Removed .pioenvs/nodemcu/FrameworkArduino/spiffs/spiffs_nucleus.o + Removed .pioenvs/nodemcu/FrameworkArduino/umm_malloc/umm_malloc.o + Removed .pioenvs/nodemcu/src/main.o + Done cleaning + ======================= [SUCCESS] Took 0.50 seconds ======================= + + [Wed Sep 7 15:53:27 2016] Processing teensy31 (platform: teensy, board: teensy31, framework: arduino) + ----------------------------------------------------------------------------------------------------- + Removed .pioenvs/teensy31/firmware.elf + Removed .pioenvs/teensy31/firmware.hex + Removed .pioenvs/teensy31/libFrameworkArduino.a + Removed .pioenvs/teensy31/FrameworkArduino/analog.o + Removed .pioenvs/teensy31/FrameworkArduino/AudioStream.o + ... + Removed .pioenvs/teensy31/FrameworkArduino/WString.o + Removed .pioenvs/teensy31/FrameworkArduino/yield.o + Removed .pioenvs/teensy31/src/main.o + Done cleaning + ======================= [SUCCESS] Took 0.50 seconds ======================= + + [Wed Sep 7 15:53:28 2016] Processing lpmsp430g2553 (platform: timsp430, build_flags: -D LED_BUILTIN=RED_LED, board: lpmsp430g2553, framework: energia) + ----------------------------------------------------------------------------------------------------- + Removed .pioenvs/lpmsp430g2553/firmware.elf + Removed .pioenvs/lpmsp430g2553/firmware.hex + Removed .pioenvs/lpmsp430g2553/libFrameworkEnergia.a + Removed .pioenvs/lpmsp430g2553/FrameworkEnergia/atof.o + ... + Removed .pioenvs/lpmsp430g2553/FrameworkEnergia/avr/dtostrf.o + Removed .pioenvs/lpmsp430g2553/src/main.o + Done cleaning + ======================= [SUCCESS] Took 0.49 seconds ======================= 4. Mix environments and targets -.. code-block:: bash +.. code:: - $ platformio run -e launchpad_msp430g2 -t upload - Processing launchpad_msp430g2 environment: - /Users/ikravets/.platformio/timsp430/tools/mspdebug/mspdebug rf2500 --force-reset "prog .pioenvs/launchpad_msp430g2/firmware.hex" - MSPDebug version 0.20 - debugging tool for MSP430 MCUs - Copyright (C) 2009-2012 Daniel Beer - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + > platformio run -e uno -t upload - Trying to open interface 1 on 009 - Initializing FET... - FET protocol version is 30394216 - Configured for Spy-Bi-Wire - Sending reset... - Set Vcc: 3000 mV - Device ID: 0x2553 - Code start address: 0xc000 - Code size : 16384 byte = 16 kb - RAM start address: 0x200 - RAM end address: 0x3ff - RAM size : 512 byte = 0 kb - Device: MSP430G2553/G2403 - Code memory starts at 0xc000 - Number of breakpoints: 2 - Chip ID data: 25 53 - Erasing... - Programming... - Writing 646 bytes at c000... - Writing 32 bytes at ffe0... - Done, 678 bytes total + [Wed Sep 7 15:55:11 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino) + -------------------------------------------------------------------------------------------------- + Verbose mode can be enabled via `-v, --verbose` option + Collected 36 compatible libraries + Looking for dependencies... + Project does not have dependencies + Compiling .pioenvs/uno/src/main.o + Archiving .pioenvs/uno/libFrameworkArduinoVariant.a + Indexing .pioenvs/uno/libFrameworkArduinoVariant.a + Compiling .pioenvs/uno/FrameworkArduino/CDC.o + ... + Compiling .pioenvs/uno/FrameworkArduino/wiring_shift.o + Archiving .pioenvs/uno/libFrameworkArduino.a + Indexing .pioenvs/uno/libFrameworkArduino.a + Linking .pioenvs/uno/firmware.elf + Checking program size .pioenvs/uno/firmware.elf + text data bss dec hex filename + 1034 0 9 1043 413 .pioenvs/uno/firmware.elf + Building .pioenvs/uno/firmware.hex + Looking for upload port... + Auto-detected: /dev/cu.usbmodemFA141 + Uploading .pioenvs/uno/firmware.hex + + avrdude: AVR device initialized and ready to accept instructions + + Reading | ################################################## | 100% 0.01s + + avrdude: Device signature = 0x1e950f + avrdude: reading input file ".pioenvs/uno/firmware.hex" + avrdude: writing flash (1034 bytes): + + Writing | ################################################## | 100% 0.18s + + avrdude: 1034 bytes of flash written + avrdude: verifying flash memory against .pioenvs/uno/firmware.hex: + avrdude: load data flash data from input file .pioenvs/uno/firmware.hex: + avrdude: input file .pioenvs/uno/firmware.hex contains 1034 bytes + avrdude: reading on-chip flash data: + + Reading | ################################################## | 100% 0.15s + + avrdude: verifying ... + avrdude: 1034 bytes of flash verified + + avrdude: safemode: Fuses OK (H:00, E:00, L:00) + + avrdude done. Thank you. + + ======================== [SUCCESS] Took 4.14 seconds ======================== diff --git a/docs/userguide/cmd_settings.rst b/docs/userguide/cmd_settings.rst index ff5640d0..2605ed74 100644 --- a/docs/userguide/cmd_settings.rst +++ b/docs/userguide/cmd_settings.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -87,23 +87,29 @@ Check for the new PlatformIO interval. Check for the platform updates interval. -.. _setting_enable_prompts: +.. _setting_disable_ssl: -``enable_prompts`` -^^^^^^^^^^^^^^^^^^ +``disable_ssl`` +^^^^^^^^^^^^^^^ -:Default: Yes +:Default: No :Values: Yes/No -Can PlatformIO communicate with you via prompts? +Disable SSL for PlatformIO API (NOT RECOMMENDED, INSECURE) -* propose to install platforms which aren't installed yet -* paginate over library search results -* and etc. +.. _setting_force_verbose: -.. warning:: - If you are going to run *PlatformIO* from **subprocess**, you **MUST - DISABLE** all prompts. It will allow you to avoid blocking. +``force_verbose`` +^^^^^^^^^^^^^^^^^ + +:Default: No +:Values: Yes/No + +Force verbose output when processing environments. This setting overrides + +* :option:`platformio run --verbose` +* :option:`platformio ci --verbose` +* :option:`platformio test --verbose` .. _setting_enable_telemetry: @@ -148,7 +154,6 @@ Examples check_libraries_interval 7 Check for the library updates interval (days) check_platformio_interval 3 Check for the new PlatformIO interval (days) check_platforms_interval 7 Check for the platform updates interval (days) - enable_prompts Yes Can PlatformIO communicate with you via prompts ... enable_telemetry Yes Telemetry service (Yes/No) diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst new file mode 100644 index 00000000..e34ea0c0 --- /dev/null +++ b/docs/userguide/cmd_test.rst @@ -0,0 +1,100 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.. _cmd_test: + +platformio test +=============== + +.. versionadded:: 3.0 + +.. contents:: + +Usage +----- + +.. code-block:: bash + + platformio test [OPTIONS] + +Description +----------- + +Run tests from PlatformIO based project. More details about PlatformIO +:ref:`unit_testing`. + +This command allows you to apply the tests for the environments specified +in :ref:`projectconf`. + +Options +------- + +.. program:: platformio test + +.. option:: + -e, --environment + +Process specified environments. More details :option:`platformio run --environment` + +.. option:: + -i, --ignore + +Ignore tests where the name matches specified patterns. More than one +pattern is allowed. If you need to ignore some tests for the specific +environment, please take a look at :ref:`projectconf_test_ignore` option from +:ref:`projectconf`. + +.. list-table:: + :header-rows: 1 + + * - Pattern + - Meaning + + * - ``*`` + - matches everything + + * - ``?`` + - matches any single character + + * - ``[seq]`` + - matches any character in seq + + * - ``[!seq]`` + - matches any character not in seq + +For example, ``platformio test --ignore "mytest*" -i "test[13]"`` + +.. option:: + --upload-port + +Upload port of embedded board. To print all available ports use +:ref:`cmd_device` command. + +If upload port is not specified, PlatformIO will try to detect it automatically. + +.. option:: + -d, --project-dir + +Specify the path to project directory. By default, ``--project-dir`` is equal +to current working directory (``CWD``). + +.. option:: + -v, --verbose + +Shows detailed information when processing environments. + +This option can be set globally using :ref:`setting_force_verbose` setting +or by environment variable :envvar:`PLATFORMIO_SETTING_FORCE_VERBOSE`. + +Examples +-------- + +For the examples please follow to :ref:`unit_testing` page. diff --git a/docs/userguide/cmd_update.rst b/docs/userguide/cmd_update.rst index d429bb0d..da5d9327 100644 --- a/docs/userguide/cmd_update.rst +++ b/docs/userguide/cmd_update.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,91 +21,215 @@ Usage .. code-block:: bash - platformio update + platformio update [OPTIONS] Description ----------- -Check or update installed :ref:`platforms` and -:ref:`Libraries ` +Check or update installed :ref:`platforms` and global +:ref:`Libraries `. This command is combination of 2 sub-commands: + +* :ref:`cmd_platform_update` +* :ref:`cmd_lib_update` + +Options +------- + +.. program:: platformio update + +.. option:: + -c, --only-check + +Do not update, only check for new version Examples -------- -.. code-block:: bash +.. code:: - $ platformio update + > platformio update + + Platform Manager + ================ + Platform timsp430 + -------- + Updating timsp430 @ 0.0.0: [Up-to-date] + Updating toolchain-timsp430 @ 1.40603.0: [Up-to-date] + Updating framework-energiamsp430 @ 1.17.0: [Up-to-date] + Updating framework-arduinomsp430 @ 1.10601.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform freescalekinetis + -------- + Updating freescalekinetis @ 0.0.0: [Up-to-date] + Updating framework-mbed @ 1.121.1: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform ststm32 + -------- + Updating ststm32 @ 0.0.0: [Up-to-date] + Updating framework-libopencm3 @ 1.1.0: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] + Updating tool-stlink @ 1.10200.0: [Up-to-date] + Updating framework-spl @ 1.10201.0: [Up-to-date] + Updating framework-cmsis @ 1.40300.0: [Up-to-date] + Updating framework-mbed @ 1.121.1: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform lattice_ice40 + -------- + Updating lattice_ice40 @ 0.0.0: [Up-to-date] + Updating toolchain-icestorm @ 1.7.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] Platform atmelavr -------- - Updating toolchain-atmelavr package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-avrdude package: - Versions: Current=2, Latest=2 [Up-to-date] - Updating framework-arduinoavr package: - Versions: Current=12, Latest=12 [Up-to-date] - Updating tool-micronucleus package: - Versions: Current=1, Latest=1 [Up-to-date] + Updating atmelavr @ 0.0.0: [Up-to-date] + Updating framework-arduinoavr @ 1.10608.1: [Up-to-date] + Updating tool-avrdude @ 1.60001.1: [Up-to-date] + Updating toolchain-atmelavr @ 1.40801.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] - Platform atmelsam + Platform espressif8266 -------- - Updating framework-arduinosam package: - Versions: Current=3, Latest=3 [Up-to-date] - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-bossac package: - Versions: Current=1, Latest=1 [Up-to-date] + Updating espressif8266 @ 0.0.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + Updating toolchain-xtensa @ 1.40802.0: [Up-to-date] + Updating tool-esptool @ 1.409.0: [Up-to-date] + Updating tool-mkspiffs @ 1.102.0: [Up-to-date] + Updating framework-arduinoespressif8266 @ 1.20300.0: [Up-to-date] + Updating sdk-esp8266 @ 1.10502.0: [Up-to-date] - Platform stm32 + Platform linux_x86_64 -------- - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-stlink package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-spl package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-cmsis package: - Versions: Current=2, Latest=2 [Up-to-date] - Updating framework-opencm3 package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] + Updating linux_x86_64 @ 0.0.0: [Up-to-date] + Updating toolchain-gcclinux64 @ 1.40801.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform windows_x86 + -------- + Updating windows_x86 @ 0.0.0: [Up-to-date] + Updating toolchain-gccmingw32 @ 1.40800.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] Platform teensy -------- - Updating toolchain-atmelavr package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-arduinoteensy package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-teensy package: - Versions: Current=1, Latest=1 [Up-to-date] + Updating teensy @ 0.0.0: [Up-to-date] + Updating framework-arduinoteensy @ 1.128.0: [Up-to-date] + Updating tool-teensy @ 1.1.0: [Up-to-date] + Updating framework-mbed @ 1.121.1: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + Updating toolchain-atmelavr @ 1.40801.0: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] - Platform timsp430 + Platform nordicnrf51 -------- - Updating toolchain-timsp430 package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-mspdebug package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-energiamsp430 package: - Versions: Current=2, Latest=2 [Up-to-date] + Updating nordicnrf51 @ 0.0.0: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] + Updating framework-arduinonordicnrf51 @ 1.20302.0: [Up-to-date] + Updating framework-mbed @ 1.121.1: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] Platform titiva -------- - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-lm4flash package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-opencm3 package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-energiativa package: - Versions: Current=4, Latest=4 [Up-to-date] + Updating titiva @ 0.0.0: [Up-to-date] + Updating framework-libopencm3 @ 1.1.0: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] + Updating framework-energiativa @ 1.17.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform atmelsam + -------- + Updating atmelsam @ 0.0.0: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] + Updating tool-openocd @ 1.900.0: [Up-to-date] + Updating framework-mbed @ 1.121.1: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + Updating tool-avrdude @ 1.60001.1: [Up-to-date] + Updating tool-bossac @ 1.10601.0: [Up-to-date] + + Platform siliconlabsefm32 + -------- + Updating siliconlabsefm32 @ 0.0.0: [Up-to-date] + Updating framework-mbed @ 1.121.1: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform microchippic32 + -------- + Updating microchippic32 @ 0.0.0: [Up-to-date] + Updating framework-arduinomicrochippic32 @ 1.10201.0: [Up-to-date] + Updating toolchain-microchippic32 @ 1.40803.0: [Up-to-date] + Updating tool-pic32prog @ 1.200200.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform linux_i686 + -------- + Updating linux_i686 @ 0.0.0: [Up-to-date] + Updating toolchain-gcclinux32 @ 1.40801.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform intel_arc32 + -------- + Updating intel_arc32 @ 0.0.0: [Up-to-date] + Updating framework-arduinointel @ 1.10006.0: [Up-to-date] + Updating tool-arduino101load @ 1.124.0: [Up-to-date] + Updating toolchain-intelarc32 @ 1.40805.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform nxplpc + -------- + Updating nxplpc @ 0.0.0: [Up-to-date] + Updating framework-mbed @ 1.121.1: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform linux_arm + -------- + Updating linux_arm @ 0.0.0: [Up-to-date] + Updating toolchain-gccarmlinuxgnueabi @ 1.40802.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + Platform native + -------- + Updating native @ 0.0.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + + + Library Manager + =============== + Updating Adafruit-GFX @ 334e815bc1: [Up-to-date] + Updating Adafruit-ST7735 @ d53d4bf03a: [Up-to-date] + Updating Adafruit-DHT @ 09344416d2: [Up-to-date] + Updating Adafruit-Unified-Sensor @ f2af6f4efc: [Up-to-date] + Updating ESP8266_SSD1306 @ 3.2.3: [Up-to-date] + Updating EngduinoMagnetometer @ 3.1.0: [Up-to-date] + Updating IRremote @ 2.2.1: [Up-to-date] + Updating Json @ 5.6.4: [Up-to-date] + Updating MODSERIAL @ d8422efe47: [Up-to-date] + Updating PJON @ 1fb26fd: [Checking] + git version 2.7.4 (Apple Git-66) + Already up-to-date. + Updating Servo @ 36b69a7ced07: [Checking] + Mercurial Distributed SCM (version 3.8.4) + (see https://mercurial-scm.org for more information) + + Copyright (C) 2005-2016 Matt Mackall and others + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + pulling from https://developer.mbed.org/users/simon/code/Servo/ + searching for changes + no changes found + Updating TextLCD @ 308d188a2d3a: [Checking] + Mercurial Distributed SCM (version 3.8.4) + (see https://mercurial-scm.org for more information) + + Copyright (C) 2005-2016 Matt Mackall and others + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + pulling from https://developer.mbed.org/users/simon/code/TextLCD/ + searching for changes + no changes found diff --git a/docs/userguide/cmd_upgrade.rst b/docs/userguide/cmd_upgrade.rst index d0b1ebce..887a8b32 100644 --- a/docs/userguide/cmd_upgrade.rst +++ b/docs/userguide/cmd_upgrade.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -33,11 +33,12 @@ Check or upgrade PlatformIO to the latest version Examples -------- -.. code-block:: bash +.. code:: + + > platformio upgrade - $ platformio upgrade You are up-to-date! PlatformIO x.x.x is currently the newest version available. # If you have problem with permissions try: - $ sudo platformio upgrade + > sudo platformio upgrade diff --git a/docs/userguide/index.rst b/docs/userguide/index.rst index d447a775..2a3b0f2a 100644 --- a/docs/userguide/index.rst +++ b/docs/userguide/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -34,8 +34,7 @@ Options .. option:: --force, -f -Force to accept any confirmation prompts. This option allows to avoid an issue -with :ref:`faq_troubleshooting_pioblocksprompt` +Force to accept any confirmation prompts and disable progress bars. .. option:: --version @@ -61,10 +60,11 @@ Commands cmd_boards cmd_ci + cmd_device cmd_init - platformio platforms + platformio platform cmd_run - cmd_serialports cmd_settings + cmd_test cmd_update cmd_upgrade diff --git a/docs/userguide/lib/cmd_install.rst b/docs/userguide/lib/cmd_install.rst index a28c24a6..d407d935 100644 --- a/docs/userguide/lib/cmd_install.rst +++ b/docs/userguide/lib/cmd_install.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,14 +21,73 @@ Usage .. code-block:: bash - platformio lib install [OPTIONS] [LIBRARY_ID] + platformio lib [STORAGE_OPTIONS] install [OPTIONS] [LIBRARY...] + # install project dependent library + # (run it from a project root where is located "platformio.ini") + platformio lib install [OPTIONS] [LIBRARY...] + + # install to global storage + platformio lib --global install [OPTIONS] [LIBRARY...] + platformio lib -g install [OPTIONS] [LIBRARY...] + + # install to custom storage + platformio lib --storage-dir /path/to/dir install [OPTIONS] [LIBRARY...] + platformio lib -d /path/to/dir install [OPTIONS] [LIBRARY...] + + # [LIBRARY...] forms + platformio lib [STORAGE_OPTIONS] install (with no args, project dependencies) + platformio lib [STORAGE_OPTIONS] install + platformio lib [STORAGE_OPTIONS] install id= + platformio lib [STORAGE_OPTIONS] install @ + platformio lib [STORAGE_OPTIONS] install @ + platformio lib [STORAGE_OPTIONS] install + platformio lib [STORAGE_OPTIONS] install @ + platformio lib [STORAGE_OPTIONS] install @ + platformio lib [STORAGE_OPTIONS] install + platformio lib [STORAGE_OPTIONS] install file:// + platformio lib [STORAGE_OPTIONS] install file:// + platformio lib [STORAGE_OPTIONS] install + platformio lib [STORAGE_OPTIONS] install = (name it should have locally) + platformio lib [STORAGE_OPTIONS] install ("tag" can be commit, branch or tag) + +.. warning:: + If some libraries are not visible in :ref:`ide_atom` and Code Completion or + Code Linting does not work properly, please perform ``Menu: PlatformIO > + Rebuild C/C++ Project Index (Autocomplete, Linter)`` Description ----------- -Install new library by specified -`PlatformIO Library Registry ID `_. +Install a library, and any libraries that it depends on using: + +1. Library ``id`` or ``name`` from `PlatformIO Library Registry `_ +2. Custom folder, repository or archive. + +The ``version`` supports `Semantic Versioning `_ ( +``..``) and can take any of the following forms: + +* ``0.1.2`` - an exact version number. Use only this exact version +* ``^0.1.2`` - any compatible version (exact version for ``0.x.x`` versions +* ``~0.1.2`` - any version with the same major and minor versions, and an + equal or greater patch version +* ``>0.1.2`` - any version greater than ``0.1.2``. ``>=``, ``<``, and ``<=`` + are also possible +* ``>0.1.0,!=0.2.0,<0.3.0`` - any version greater than ``0.1.0``, not equal to + ``0.2.0`` and less than ``0.3.0`` + +PlatformIO supports installing from local directory or archive. Need +to use ``file://`` prefix before local path. Also, directory or +archive should contain ``.library.json`` manifest (see :ref:`library_config`). + +* ``file:///local/path/to/the/platform/dir`` +* ``file:///local/path/to/the/platform.zip`` +* ``file:///local/path/to/the/platform.tar.gz`` + +Storage Options +--------------- + +See base options for :ref:`userguide_lib`. Options ------- @@ -36,50 +95,168 @@ Options .. program:: platformio lib install .. option:: - -v, --version + -s, --silent -Install specified version of library +Suppress progress reporting + +.. option:: + --interactive + +Allow to make a choice for all prompts + +Version control +--------------- + +PlatformIO supports installing from Git, Mercurial and Subversion, and detects +the type of VCS using url prefixes: "git+", "hg+", or "svn+". + +.. note:: + PlatformIO requires a working VCS command on your path: ``git``, ``hg`` + or ``svn``. + +Git +^^^ + +The supported schemes are: ``git``, ``git+https`` and ``git+ssh``. Here are +the supported forms: + +* user/library (short version for GitHub repository) +* https://github.com/user/library.git +* git+git://git.server.org/my-library +* git+https://git.server.org/my-library +* git+ssh://git.server.org/my-library + +Passing branch names, a commit hash or a tag name is possible like so: + +* https://github.com/user/library.git#master +* git+git://git.server.org/my-library#master +* git+https://git.server.org/my-library#v1.0 +* git+ssh://git.server.org/my-library#7846d8ad52f983f2f2887bdc0f073fe9755a806d + +Mercurial +^^^^^^^^^ + +The supported schemes are: ``hg+http``, ``hg+https`` and ``hg+ssh``. Here are +the supported forms: + +* https://developer.mbed.org/users/user/code/library/ (install ARM mbed library) +* hg+hg://hg.server.org/my-library +* hg+https://hg.server.org/my-library +* hg+ssh://hg.server.org/my-library + +Passing branch names, a commit hash or a tag name is possible like so: + +* hg+hg://hg.server.org/my-library#master +* hg+https://hg.server.org/my-library#v1.0 +* hg+ssh://hg.server.org/my-library#4cfe2fa00668 + +Subversion +^^^^^^^^^^ + +The supported schemes are: ``svn``, ``svn+svn``, ``svn+http``, ``svn+https`` +and ``svn+ssh``. Here are the supported forms: + +* svn+svn://svn.server.org/my-library +* svn+https://svn.server.org/my-library +* svn+ssh://svn.server.org/my-library + +You can also give specific revisions to an SVN URL, like so: + +* svn+svn://svn.server.org/my-library#13 Examples -------- -1. Install the latest version of library +1. Install the latest version of library to a global storage using ID or NAME -.. code-block:: bash +.. code:: - # IRremote: http://platformio.org/lib/show/4/IRremote - $ platformio lib install 4 - # Installing library [ 4 ]: - # Downloading [####################################] 100% - # Unpacking [####################################] 100% - # The library #4 'IRremote' has been successfully installed! + > platformio lib -g install 4 + + Library Storage: /storage/dir/... + LibraryManager: Installing id=4 + Downloading [####################################] 100% + Unpacking [####################################] 100% + IRremote @ 2.2.1 has been successfully installed! + + # repeat command with name + > platformio lib -g install IRRemote + + Library Storage: /storage/dir/... + Looking for IRRemote library in registry + Found: http://platformio.org/lib/show/4/IRremote + LibraryManager: Installing id=4 + IRremote @ 2.2.1 is already installed -2. Install specified version of library +2. Install specified version of a library to a global storage -.. code-block:: bash +.. code:: - # XBee: http://platformio.org/lib/show/6/XBee - $ platformio lib install 6 --version=0.5 - # Installing library [ 6 ]: - # Downloading [####################################] 100% - # Unpacking [####################################] 100% - # The library #6 'XBee' has been successfully installed! + > platformio lib -g install Json@5.4.0 + + Library Storage: /storage/dir/... + Looking for Json library in registry + Found: http://platformio.org/lib/show/64/Json + LibraryManager: Installing id=64 @ 5.4.0 + Downloading [####################################] 100% + Unpacking [####################################] 100% + Json @ 5.4.0 has been successfully installed! -3. Install library with dependencies +3. Install library with dependencies to custom storage -.. code-block:: bash +.. code:: - # Adafruit-ST7735: http://platformio.org/lib/show/12/Adafruit-ST7735 - $ platformio lib install 12 - # Installing library [ 12 ]: - # Downloading [####################################] 100% - # Unpacking [####################################] 100% - # The library #12 'Adafruit-ST7735' has been successfully installed! - # Installing dependencies: - # Installing library [ 13 ]: - # Downloading [####################################] 100% - # Unpacking [####################################] 100% - # The library #13 'Adafruit-GFX' has been successfully installed! + > platformio lib --storage-dir /my/storage/dir install DallasTemperature + + Library Storage: /my/storage/dir + Looking for DallasTemperature library in registry + Found: http://platformio.org/lib/show/54/DallasTemperature + LibraryManager: Installing id=54 + Downloading [####################################] 100% + Unpacking [####################################] 100% + DallasTemperature @ 3.7.7 has been successfully installed! + Installing dependencies + Looking for OneWire library in registry + Found: http://platformio.org/lib/show/1/OneWire + LibraryManager: Installing id=1 + Downloading [####################################] 100% + Unpacking [####################################] 100% + OneWire @ 8fd2ebfec7 has been successfully installed! + +4. Install ARM mbed library to the global storage + +.. code:: + + > platformio lib -g install https://developer.mbed.org/users/simon/code/TextLCD/ + + Library Storage: /storage/dir/... + LibraryManager: Installing TextLCD + Mercurial Distributed SCM (version 3.8.4) + (see https://mercurial-scm.org for more information) + + Copyright (C) 2005-2016 Matt Mackall and others + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + requesting all changes + adding changesets + adding manifests + adding file changes + added 9 changesets with 18 changes to 6 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + TextLCD @ 308d188a2d3a has been successfully installed! + +5. Install from archive using URL + +.. code:: + + > platformio lib -g install https://github.com/adafruit/DHT-sensor-library/archive/master.zip + + Library Storage: /storage/dir/... + LibraryManager: Installing master + Downloading [####################################] 100% + Unpacking [####################################] 100% + DHT sensor library @ 1.2.3 has been successfully installed! diff --git a/docs/userguide/lib/cmd_list.rst b/docs/userguide/lib/cmd_list.rst index deb19b9c..b0274fc7 100644 --- a/docs/userguide/lib/cmd_list.rst +++ b/docs/userguide/lib/cmd_list.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,14 +21,30 @@ Usage .. code-block:: bash + platformio lib [STORAGE_OPTIONS] list [OPTIONS] + + # list project dependent libraries + # (run it from a project root where is located "platformio.ini") platformio lib list [OPTIONS] + # list libraries from global storage + platformio lib --global list [OPTIONS] + platformio lib -g list [OPTIONS] + + # list libraries from custom storage + platformio lib --storage-dir /path/to/dir list [OPTIONS] + platformio lib -d /path/to/dir list [OPTIONS] Description ----------- List installed libraries +Storage Options +--------------- + +See base options for :ref:`userguide_lib`. + Options ~~~~~~~ @@ -42,18 +58,14 @@ Return the output in `JSON `_ format Examples -------- -.. code-block:: bash +.. code:: - $ platformio lib list - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope - # [ 12 ] Adafruit-ST7735 arduino, atmelavr "Adafruit Industries": A library for the Adafruit 1.8" SPI display - # [ 31 ] Adafruit-Unified-Sensor arduino, atmelavr "Adafruit Industries": Adafruit Unified Sensor Driver - # [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) - # [ 6 ] XBee arduino, atmelavr "Andrew Rapp": Arduino library for communicating with XBees in API mode - # [ 13 ] Adafruit-GFX arduino, atmelavr "Adafruit Industries": A core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.) - # [ 4 ] IRremote arduino, atmelavr "Ken Shirriff": Send and receive infrared signals with multiple protocols - # [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) - # ... + > platformio lib list + + pio lib -g list + Library Storage: /storage/dir/... + [ ID ] Name Compatibility "Authors": Description + ----------------------------------------------------------------------------------------------------------- + [ 4 ] IRremote arduino, atmelavr "Rafi Khan, Ken Shirriff": Send and receive infrared signals with multiple protocols | @2.2.1 + [ 64 ] Json arduino, atmelavr, atmelsam, timsp430, titiva, teensy, freescalekinetis, ststm32, nordicnrf51, nxplpc, espressif8266, siliconlabsefm32, linux_arm, native, intel_arc32 "Benoit Blanchon": An elegant and efficient JSON library for embedded systems | @5.4.0 + [ VCS ] TextLCD - "Unknown": hg+https://developer.mbed.org/users/simon/code/TextLCD/ | @308d188a2d3a diff --git a/docs/userguide/lib/cmd_register.rst b/docs/userguide/lib/cmd_register.rst index 60f00c21..d34b857c 100644 --- a/docs/userguide/lib/cmd_register.rst +++ b/docs/userguide/lib/cmd_register.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,17 +21,25 @@ Usage .. code-block:: bash - platformio lib register [HTTP_URL_TO_LIBRARY.JSON] + platformio lib register [MANIFEST_URL] Description ----------- -Register new library and allow others to install it. +Register new library in `PlatformIO Library Registry `_. + +PlatformIO Library Registry supports the next library manifests: + +* PlatformIO :ref:`library_config` +* Arduino `library.properties `_ +* ARM mbed yotta `module.json `_. Examples -------- -.. code-block:: bash +.. code:: - $ platformio lib register http://my.example.com/library.json + platformio lib register https://raw.githubusercontent.com/bblanchon/ArduinoJson/master/library.json + platformio lib register https://raw.githubusercontent.com/adafruit/DHT-sensor-library/master/library.properties + platformio lib register https://raw.githubusercontent.com/ARMmbed/ble/master/module.json diff --git a/docs/userguide/lib/cmd_search.rst b/docs/userguide/lib/cmd_search.rst index 4325fe7f..4ca0789c 100644 --- a/docs/userguide/lib/cmd_search.rst +++ b/docs/userguide/lib/cmd_search.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -74,6 +74,11 @@ Options .. program:: platformio lib search +.. option:: + -n, --name + +Filter libraries by specified name (strict search) + .. option:: -a, --author @@ -84,18 +89,23 @@ Filter libraries by specified author Filter libraries by specified keyword - .. option:: -f, --framework Filter libraries by specified framework - .. option:: -p, --platform Filter libraries by specified keyword +.. option:: + -i, --header + +Filter libraries by header file (include) + +For example, ``platformio lib search --header "OneWire.h"`` + .. option:: --json-output @@ -112,126 +122,134 @@ Examples 1. List all libraries -.. code-block:: bash +.. code:: - $ platformio lib search - # Found N libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) - # [ 13 ] Adafruit-GFX arduino, atmelavr "Adafruit Industries": A core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.) - # [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope - # [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) - # [ 12 ] Adafruit-ST7735 arduino, atmelavr "Adafruit Industries": A library for the Adafruit 1.8" SPI display - # [ 31 ] Adafruit-Unified-Sensor arduino, atmelavr "Adafruit Industries": Adafruit Unified Sensor Driver - # [ 4 ] IRremote arduino, atmelavr "Ken Shirriff": Send and receive infrared signals with multiple protocols - # [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) - # [ 6 ] XBee arduino, atmelavr "Andrew Rapp": Arduino library for communicating with XBees in API mode - # [ 15 ] Adafruit-ADXL345-Unified arduino, atmelavr "Adafruit Industries": Unified driver for the ADXL345 Accelerometer - # Show next libraries? [y/N]: - # ... + > platformio lib search + + Found N libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) + [ 13 ] Adafruit-GFX arduino, atmelavr "Adafruit Industries": A core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.) + [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope + [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) + [ 12 ] Adafruit-ST7735 arduino, atmelavr "Adafruit Industries": A library for the Adafruit 1.8" SPI display + [ 31 ] Adafruit-Unified-Sensor arduino, atmelavr "Adafruit Industries": Adafruit Unified Sensor Driver + [ 4 ] IRremote arduino, atmelavr "Ken Shirriff": Send and receive infrared signals with multiple protocols + [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) + [ 6 ] XBee arduino, atmelavr "Andrew Rapp": Arduino library for communicating with XBees in API mode + [ 15 ] Adafruit-ADXL345-Unified arduino, atmelavr "Adafruit Industries": Unified driver for the ADXL345 Accelerometer + Show next libraries? [y/N]: + ... 2. Search for `1-Wire libraries `_ -.. code-block:: bash +.. code:: - $ platformio lib search "1-wire" - # Found N libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) - # ... + > platformio lib search "1-wire" + + Found N libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) + ... 3. Search for `Arduino-based "I2C" libraries `_ -.. code-block:: bash +.. code:: - $ platformio lib search "i2c" --framework="arduino" - # Found N libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 11 ] I2Cdevlib-Core arduino, atmelavr "Jeff Rowberg": The I2C Device Library (I2Cdevlib) is a collection of uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices. - # [ 24 ] Adafruit-L3GD20 arduino, atmelavr "Adafruit Industries": Driver for Adafruit's L3GD20 I2C Gyroscope Breakout - # [ 10 ] I2Cdevlib-AK8975 arduino, atmelavr "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology - # [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) - # ... + > platformio lib search "i2c" --framework="arduino" + + Found N libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 11 ] I2Cdevlib-Core arduino, atmelavr "Jeff Rowberg": The I2C Device Library (I2Cdevlib) is a collection of uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices. + [ 24 ] Adafruit-L3GD20 arduino, atmelavr "Adafruit Industries": Driver for Adafruit's L3GD20 I2C Gyroscope Breakout + [ 10 ] I2Cdevlib-AK8975 arduino, atmelavr "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology + [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) + ... 4. Search for `libraries by "web" and "http" keywords `_. -.. code-block:: bash +.. code:: - $ platformio lib search --keyword="web" --keyword="http" - # Found N libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 5 ] Webduino arduino, atmelavr "Ben Combee": An extensible web server library (for use with the Arduino WizNet Ethernet Shield) - # [ 17 ] Adafruit-CC3000 arduino, atmelavr "Adafruit Industries": Library code for Adafruit's CC3000 Wi-Fi/WiFi breakouts - # ... + > platformio lib search --keyword="web" --keyword="http" + + Found N libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 5 ] Webduino arduino, atmelavr "Ben Combee": An extensible web server library (for use with the Arduino WizNet Ethernet Shield) + [ 17 ] Adafruit-CC3000 arduino, atmelavr "Adafruit Industries": Library code for Adafruit's CC3000 Wi-Fi/WiFi breakouts + ... 5. Search for `libraries by "Adafruit Industries" author `_ -.. code-block:: bash +.. code:: - $ platformio lib search --author="Adafruit Industries" - # Found N libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) - # [ 13 ] Adafruit-GFX arduino, atmelavr "Adafruit Industries": A core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.) - # [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope - # [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) - # ... + > platformio lib search --author="Adafruit Industries" + + Found N libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) + [ 13 ] Adafruit-GFX arduino, atmelavr "Adafruit Industries": A core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.) + [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope + [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) + ... 6. Search for `libraries which are compatible with Dallas temperature sensors `_ like DS18B20, DS18S20 and etc. -.. code-block:: bash +.. code:: - $ platformio lib search "DS*" - # Found N libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) - # ... + > platformio lib search "DS*" + + Found N libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) + ... 7. Search for `Energia-based *nRF24* or *HttpClient* libraries `_. The search query that is described below can be interpreted like ``energia nRF24 OR energia HttpClient`` -.. code-block:: bash +.. code:: - $ platformio lib search "+(nRF24 HttpClient)" --framework="energia" - # Found 2 libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 46 ] HttpClient energia, timsp430, titiva "Zack Lalanne": HttpClient is a library to make it easier to interact with web servers - # [ 43 ] nRF24 energia, timsp430 "Eric": The nRF24L01 is a low-cost 2.4GHz ISM transceiver module. It supports a number of channel frequencies in the 2.4GHz band and a range of data rates. + > platformio lib search "+(nRF24 HttpClient)" --framework="energia" + + Found 2 libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 46 ] HttpClient energia, timsp430, titiva "Zack Lalanne": HttpClient is a library to make it easier to interact with web servers + [ 43 ] nRF24 energia, timsp430 "Eric": The nRF24L01 is a low-cost 2.4GHz ISM transceiver module. It supports a number of channel frequencies in the 2.4GHz band and a range of data rates. 8. Search for the `all sensor libraries excluding temperature `_. -.. code-block:: bash +.. code:: - $ platformio lib search "sensor -temperature" - # Found N libraries: - # - # [ ID ] Name Compatibility "Authors": Description - # ------------------------------------------------------------------------------------- - # [ 31 ] Adafruit-Unified-Sensor arduino, atmelavr "Adafruit Industries": Adafruit Unified Sensor Driver - # [ 10 ] I2Cdevlib-AK8975 arduino, atmelavr "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology - # [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) - # [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope - # [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) - # [ 33 ] Adafruit-TMP006 arduino, atmelavr "Adafruit Industries": A library for the Adafruit TMP006 Infrared Thermopile Sensor - # [ 34 ] Adafruit-TSL2561-Unified arduino, atmelavr "Adafruit Industries": Unified light sensor driver for Adafruit's TSL2561 breakouts - # [ 97 ] I2Cdevlib-BMA150 arduino, atmelavr "Jeff Rowberg": The BMA150 is a triaxial, low-g acceleration sensor IC with digital output for consumer market applications - # [ 106 ] I2Cdevlib-MPR121 arduino, atmelavr "Jeff Rowberg": The MPR121 is a 12-bit proximity capacitive touch sensor - # [ 111 ] I2Cdevlib-AK8975 energia, timsp430 "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology - # Show next libraries? [y/N]: + > platformio lib search "sensor -temperature" + + Found N libraries: + + [ ID ] Name Compatibility "Authors": Description + ------------------------------------------------------------------------------------- + [ 31 ] Adafruit-Unified-Sensor arduino, atmelavr "Adafruit Industries": Adafruit Unified Sensor Driver + [ 10 ] I2Cdevlib-AK8975 arduino, atmelavr "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology + [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) + [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope + [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) + [ 33 ] Adafruit-TMP006 arduino, atmelavr "Adafruit Industries": A library for the Adafruit TMP006 Infrared Thermopile Sensor + [ 34 ] Adafruit-TSL2561-Unified arduino, atmelavr "Adafruit Industries": Unified light sensor driver for Adafruit's TSL2561 breakouts + [ 97 ] I2Cdevlib-BMA150 arduino, atmelavr "Jeff Rowberg": The BMA150 is a triaxial, low-g acceleration sensor IC with digital output for consumer market applications + [ 106 ] I2Cdevlib-MPR121 arduino, atmelavr "Jeff Rowberg": The MPR121 is a 12-bit proximity capacitive touch sensor + [ 111 ] I2Cdevlib-AK8975 energia, timsp430 "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology + Show next libraries? [y/N]: diff --git a/docs/userguide/lib/cmd_show.rst b/docs/userguide/lib/cmd_show.rst index 745685d1..b0befe1d 100644 --- a/docs/userguide/lib/cmd_show.rst +++ b/docs/userguide/lib/cmd_show.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,28 +21,65 @@ Usage .. code-block:: bash - platformio lib show ID + platformio lib [STORAGE_OPTIONS] show [LIBRARY] + # show info about project dependent library + # (run it from a project root where is located "platformio.ini") + platformio lib show [LIBRARY] + + # show info about library from global storage + platformio lib --global show [LIBRARY] + platformio lib -g show [LIBRARY] + + # show info about library from custom storage + platformio lib --storage-dir /path/to/dir show [LIBRARY] + platformio lib -d /path/to/dir show [LIBRARY] + + # [LIBRARY] forms + platformio lib [STORAGE_OPTIONS] show + platformio lib [STORAGE_OPTIONS] show + platformio lib [STORAGE_OPTIONS] show @ + platformio lib [STORAGE_OPTIONS] show @ + platformio lib [STORAGE_OPTIONS] show + platformio lib [STORAGE_OPTIONS] show @ + platformio lib [STORAGE_OPTIONS] show @ Description ----------- -Show details about the installed library +Show details about the installed library. +The ``version`` supports `Semantic Versioning `_ ( +``..``) and can take any of the following forms: + +* ``0.1.2`` - an exact version number. Use only this exact version +* ``^0.1.2`` - any compatible version (exact version for ``0.x.x`` versions +* ``~0.1.2`` - any version with the same major and minor versions, and an + equal or greater patch version +* ``>0.1.2`` - any version greater than ``0.1.2``. ``>=``, ``<``, and ``<=`` + are also possible +* ``>0.1.0,!=0.2.0,<0.3.0`` - any version greater than ``0.1.0``, not equal to + ``0.2.0`` and less than ``0.3.0`` + +Storage Options +--------------- + +See base options for :ref:`userguide_lib`. Examples -------- -.. code-block:: bash +.. code:: - # OneWire: http://platformio.org/lib/show/1/OneWire - $ platformio lib show 1 - # OneWire - # ------- - # Authors: Paul Stoffregen http://www.pjrc.com/teensy/td_libs_OneWire.html (maintainer), Jim Studt, Jason Dangel , Derek Yerger, Tom Pollard , Robin James - # Keywords: onewire, 1-wire, bus, sensor, temperature, ibutton - # Frameworks: arduino - # Platforms: atmelavr - # Version: 2.2 - # - # Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) + platformio lib -g show Json + + Library Storage: /storage/dir/... + Json + ==== + An elegant and efficient JSON library for embedded systems + + Authors: Benoit Blanchon http://blog.benoitblanchon.fr + Keywords: json, rest, http, web + Frameworks: arduino + Platforms: atmelavr, atmelsam, timsp430, titiva, teensy, freescalekinetis, ststm32, nordicnrf51, nxplpc, espressif8266, siliconlabsefm32, linux_arm, native, intel_arc32 + Version: 5.4.0 diff --git a/docs/userguide/lib/cmd_uninstall.rst b/docs/userguide/lib/cmd_uninstall.rst index df99372b..a465ad17 100644 --- a/docs/userguide/lib/cmd_uninstall.rst +++ b/docs/userguide/lib/cmd_uninstall.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,20 +21,56 @@ Usage .. code-block:: bash - platformio lib uninstall ID + platformio lib [STORAGE_OPTIONS] uninstall [LIBRARY...] + # uninstall project dependent library + # (run it from a project root where is located "platformio.ini") + platformio lib uninstall [LIBRARY...] + + # uninstall library from global storage + platformio lib --global uninstall [LIBRARY...] + platformio lib -g uninstall [LIBRARY...] + + # uninstall library from custom storage + platformio lib --storage-dir /path/to/dir uninstall [LIBRARY...] + platformio lib -d /path/to/dir uninstall [LIBRARY...] + + # [LIBRARY...] forms + platformio lib [STORAGE_OPTIONS] uninstall + platformio lib [STORAGE_OPTIONS] uninstall @ + platformio lib [STORAGE_OPTIONS] uninstall @ + platformio lib [STORAGE_OPTIONS] uninstall + platformio lib [STORAGE_OPTIONS] uninstall @ + platformio lib [STORAGE_OPTIONS] uninstall @ Description ----------- Uninstall specified library +The ``version`` supports `Semantic Versioning `_ ( +``..``) and can take any of the following forms: + +* ``0.1.2`` - an exact version number. Use only this exact version +* ``^0.1.2`` - any compatible version (exact version for ``0.x.x`` versions +* ``~0.1.2`` - any version with the same major and minor versions, and an + equal or greater patch version +* ``>0.1.2`` - any version greater than ``0.1.2``. ``>=``, ``<``, and ``<=`` + are also possible +* ``>0.1.0,!=0.2.0,<0.3.0`` - any version greater than ``0.1.0``, not equal to + ``0.2.0`` and less than ``0.3.0`` + +Storage Options +--------------- + +See base options for :ref:`userguide_lib`. Examples -------- -.. code-block:: bash +.. code:: - # XBee: http://platformio.org/lib/show/6/XBee - $ platformio lib uninstall 6 - # The library #6 'XBee' has been successfully uninstalled! + > platformio lib -g uninstall AsyncMqttClient + + Library Storage: /storage/dir/... + Uninstalling AsyncMqttClient @ 0.2.0: [OK] diff --git a/docs/userguide/lib/cmd_update.rst b/docs/userguide/lib/cmd_update.rst index 6b24f699..aea28cf0 100644 --- a/docs/userguide/lib/cmd_update.rst +++ b/docs/userguide/lib/cmd_update.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,51 +21,102 @@ Usage .. code-block:: bash - platformio lib update [LIBRARY_ID] + platformio lib [STORAGE_OPTIONS] update [OPTIONS] + + # update all project libraries + # (run it from a project root where is located "platformio.ini") + platformio lib update [OPTIONS] + + # update project dependent library + platformio lib [STORAGE_OPTIONS] update [OPTIONS] [LIBRARY...] + + # update library in global storage + platformio lib --global update [OPTIONS] [LIBRARY...] + platformio lib -g update [OPTIONS] [LIBRARY...] + + # update library in custom storage + platformio lib --storage-dir /path/to/dir update [OPTIONS] [LIBRARY...] + platformio lib -d /path/to/dir update [OPTIONS] [LIBRARY...] + + # [LIBRARY...] forms + platformio lib [STORAGE_OPTIONS] update + platformio lib [STORAGE_OPTIONS] update @ + platformio lib [STORAGE_OPTIONS] update @ + platformio lib [STORAGE_OPTIONS] update + platformio lib [STORAGE_OPTIONS] update @ + platformio lib [STORAGE_OPTIONS] update @ Description ----------- -Check or update installed libraries +Check or update installed libraries. +The ``version`` supports `Semantic Versioning `_ ( +``..``) and can take any of the following forms: + +* ``0.1.2`` - an exact version number. Use only this exact version +* ``^0.1.2`` - any compatible version (exact version for ``0.x.x`` versions +* ``~0.1.2`` - any version with the same major and minor versions, and an + equal or greater patch version +* ``>0.1.2`` - any version greater than ``0.1.2``. ``>=``, ``<``, and ``<=`` + are also possible +* ``>0.1.0,!=0.2.0,<0.3.0`` - any version greater than ``0.1.0``, not equal to + ``0.2.0`` and less than ``0.3.0`` + +Storage Options +--------------- + +See base options for :ref:`userguide_lib`. + +Options +------- + +.. program:: platformio lib update + +.. option:: + -c, --only-check + +Do not update, only check for new version Examples -------- -1. Update all installed libraries +1. Update all installed libraries in global storage -.. code-block:: bash +.. code:: - $ platformio lib update - # Updating [ 23 ] Adafruit-L3GD20-Unified library: - # Versions: Current=63de2eb9ea, Latest=63de2eb9ea [Up-to-date] - # Updating [ 12 ] Adafruit-ST7735 library: - # Versions: Current=e880eb1687, Latest=e880eb1687 [Up-to-date] - # Updating [ 31 ] Adafruit-Unified-Sensor library: - # Versions: Current=88ae805bce, Latest=88ae805bce [Up-to-date] - # Updating [ 26 ] Adafruit-LSM303DLHC-Unified library: - # Versions: Current=59767208a8, Latest=59767208a8 [Up-to-date] - # Updating [ 13 ] Adafruit-GFX library: - # Versions: Current=a9e5bc4707, Latest=a9e5bc4707 [Up-to-date] - # Updating [ 1 ] OneWire library: - # Versions: Current=2.2, Latest=2.2 [Up-to-date] - # Updating [ 4 ] IRremote library: - # Versions: Current=f2dafe5030, Latest=f2dafe5030 [Up-to-date] - # Updating [ 14 ] Adafruit-9DOF-Unified library: - # Versions: Current=b2f07242ac, Latest=b2f07242ac [Up-to-date] + > platformio lib -g update -2. Update specified libraries + Library Storage: /storage/dir/... + Updating ESP8266_SSD1306 @ 3.2.3: [Up-to-date] + Updating EngduinoMagnetometer @ 3.1.0: [Up-to-date] + Updating IRremote @ 2.2.1: [Up-to-date] + Updating Json @ 5.4.0: [Out-of-date] + LibraryManager: Installing id=64 @ 5.6.4 + Downloading [####################################] 100% + Unpacking [####################################] 100% + Json @ 5.6.4 has been successfully installed! + Updating PJON @ 1fb26fd: [Checking] + git version 2.7.4 (Apple Git-66) + Already up-to-date. + Updating TextLCD @ 308d188a2d3a: [Checking] + Mercurial Distributed SCM (version 3.8.4) + (see https://mercurial-scm.org for more information) -.. code-block:: bash + Copyright (C) 2005-2016 Matt Mackall and others + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + pulling from https://developer.mbed.org/users/simon/code/TextLCD/ + searching for changes + no changes found - $ platformio lib update 1 59 - # Updating [ 1 ] OneWire library: - # Versions: Current=2.2, Latest=2.2 [Up-to-date] - # Updating [ 59 ] USB-Host-Shield-20 library: - # Versions: Current=fcab83dcb3, Latest=c61f9ce1c2 [Out-of-date] - # The library #59 'USB-Host-Shield-20' has been successfully uninstalled! - # Installing library [ 59 ]: - # Downloading [####################################] 100% - # Unpacking [####################################] 100% - # The library #59 'USB-Host-Shield-20' has been successfully installed! +2. Update specified libraries in global storage + +.. code:: + + > platformio lib -g update Json 4 + + Library Storage: /storage/dir/... + Updating Json @ 5.6.4: [Up-to-date] + Updating IRremote @ 2.2.1: [Up-to-date] diff --git a/docs/userguide/lib/index.rst b/docs/userguide/lib/index.rst index 55626bfb..d0722ab7 100644 --- a/docs/userguide/lib/index.rst +++ b/docs/userguide/lib/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -14,15 +14,48 @@ Library Manager =============== -To print all available commands and options use: +Usage +----- .. code-block:: bash - $ platformio lib --help - $ platformio lib COMMAND --help + platformio lib [OPTIONS] COMMAND + + # To print all available commands and options use + platformio lib --help + platformio lib COMMAND --help + +Options +------- + +.. program:: platformio lib + +.. option:: + -g, --global + +.. versionadded:: 3.0 + + +Manage global PlatformIO's library storage ( +":ref:`projectconf_pio_home_dir`/lib") where :ref:`ldf` will look for +dependencies by default. + +.. option:: + -d, --storage-dir + +.. versionadded:: 3.0 + +Manage custom library storage. It can be used later for the +:ref:`projectconf_extra_script` option from :ref:`projectconf`. + +Demo +---- .. image:: ../../_static/platformio-demo-lib.gif +Commands +-------- + .. toctree:: :maxdepth: 2 diff --git a/docs/userguide/platforms/cmd_install.rst b/docs/userguide/platforms/cmd_install.rst index 03008881..4dd8145a 100644 --- a/docs/userguide/platforms/cmd_install.rst +++ b/docs/userguide/platforms/cmd_install.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,10 +9,10 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_platforms_install: +.. _cmd_platform_install: -platformio platforms install -============================ +platformio platform install +=========================== .. contents:: @@ -21,23 +21,49 @@ Usage .. code-block:: bash - platformio platforms install [OPTIONS] [PLATFORMS] + platformio platform install [OPTIONS] [PLATFORM...] + + # [PLATFORM...] forms + platformio platform install + platformio platform install @ + platformio platform install @ + platformio platform install + platformio platform install file:// + platformio platform install file:// + platformio platform install + platformio platform install (name it should have locally) + platformio platform install ("tag" can be commit, branch or tag) Description ----------- -Install pre-built development :ref:`platforms` with related packages. +Install :ref:`platforms` and dependent packages. -There are several predefined aliases for packages, such as: +The ``version`` supports `Semantic Versioning `_ ( +``..``) and can take any of the following forms: -* ``toolchain`` -* ``uploader`` +* ``0.1.2`` - an exact version number. Use only this exact version +* ``^0.1.2`` - any compatible version (exact version for ``0.x.x`` versions +* ``~0.1.2`` - any version with the same major and minor versions, and an + equal or greater patch version +* ``>0.1.2`` - any version greater than ``0.1.2``. ``>=``, ``<``, and ``<=`` + are also possible +* ``>0.1.0,!=0.2.0,<0.3.0`` - any version greater than ``0.1.0``, not equal to + ``0.2.0`` and less than ``0.3.0`` + +Also, PlatformIO supports installing from local directory or archive. Need to +use ``file://`` prefix before local path. Also, directory or archive should +contain ``platform.json`` manifest. + +* ``file:///local/path/to/the/platform/dir`` +* ``file:///local/path/to/the/platform.zip`` +* ``file:///local/path/to/the/platform.tar.gz`` Options ------- -.. program:: platformio platforms install +.. program:: platformio platform install .. option:: --with-package @@ -55,33 +81,141 @@ Do not install specified package (or alias) Skip default packages +Version control +--------------- + +PlatformIO supports installing from Git, Mercurial and Subversion, and detects +the type of VCS using url prefixes: "git+", "hg+", or "svn+". + +.. note:: + PlatformIO requires a working VCS command on your path: ``git``, ``hg`` + or ``svn``. + +Git +^^^ + +The supported schemes are: ``git``, ``git+https`` and ``git+ssh``. Here are +the supported forms: + +* platformio/platform-NAME (short version for GitHub repository) +* https://github.com/platformio/platform-NAME.git +* git+git://git.server.org/my-platform +* git+https://git.server.org/my-platform +* git+ssh://git.server.org/my-platform + +Passing branch names, a commit hash or a tag name is possible like so: + +* https://github.com/platformio/platform-name.git#master +* git+git://git.server.org/my-platform#master +* git+https://git.server.org/my-platform#v1.0 +* git+ssh://git.server.org/my-platform#7846d8ad52f983f2f2887bdc0f073fe9755a806d + +Mercurial +^^^^^^^^^ + +The supported schemes are: ``hg+http``, ``hg+https`` and ``hg+ssh``. Here are +the supported forms: + +* hg+hg://hg.server.org/my-platform +* hg+https://hg.server.org/my-platform +* hg+ssh://hg.server.org/my-platform + +Passing branch names, a commit hash or a tag name is possible like so: + +* hg+hg://hg.server.org/my-platform#master +* hg+https://hg.server.org/my-platform#v1.0 +* hg+ssh://hg.server.org/my-platform#4cfe2fa00668 + +Subversion +^^^^^^^^^^ + +The supported schemes are: ``svn``, ``svn+svn``, ``svn+http``, ``svn+https`` +and ``svn+ssh``. Here are the supported forms: + +* svn+svn://svn.server.org/my-platform +* svn+https://svn.server.org/my-platform +* svn+ssh://svn.server.org/my-platform + +You can also give specific revisions to an SVN URL, like so: + +* svn+svn://svn.server.org/my-platform#13 + Examples -------- -1. Install :ref:`platform_timsp430` with default packages +1. Install :ref:`platform_atmelavr` with default packages -.. code-block:: bash +.. code:: - $ platformio platforms install timsp430 - Installing toolchain-timsp430 package: + > platformio platform install atmelavr + + PlatformManager: Installing atmelavr + Downloading... + Unpacking [####################################] 100% + atmelavr @ 0.0.0 has been successfully installed! + PackageManager: Installing tool-scons @ >=2.3.0,<2.6.0 Downloading [####################################] 100% Unpacking [####################################] 100% - Installing tool-mspdebug package: + tool-scons @ 2.4.1 has been successfully installed! + PackageManager: Installing toolchain-atmelavr @ ~1.40801.0 Downloading [####################################] 100% Unpacking [####################################] 100% - Installing framework-energiamsp430 package: - Downloading [####################################] 100% - Unpacking [####################################] 100% - The platform 'timsp430' has been successfully installed! + toolchain-atmelavr @ 1.40801.0 has been successfully installed! + The platform 'atmelavr' has been successfully installed! + The rest of packages will be installed automatically depending on your build environment. - -2. Install :ref:`platform_timsp430` with ``uploader`` utility only and skip +2. Install :ref:`platform_atmelavr` with ``uploader`` utility only and skip default packages -.. code-block:: bash +.. code:: - $ platformio platforms install timsp430 --skip-default-package --with-package=uploader - Installing tool-mspdebug package: + > platformio platform install atmelavr --skip-default-package --with-package=uploader + + PlatformManager: Installing atmelavr Downloading [####################################] 100% Unpacking [####################################] 100% - The platform 'timsp430' has been successfully installed! + atmelavr @ 0.0.0 has been successfully installed! + PackageManager: Installing tool-micronucleus @ ~1.200.0 + Downloading [####################################] 100% + Unpacking [####################################] 100% + tool-micronucleus @ 1.200.0 has been successfully installed! + PackageManager: Installing tool-avrdude @ ~1.60001.0 + Downloading [####################################] 100% + Unpacking [####################################] 100% + tool-avrdude @ 1.60001.1 has been successfully installed! + The platform 'atmelavr' has been successfully installed! + The rest of packages will be installed automatically depending on your build environment. + +3. Install the latest development :ref:`platform_atmelavr` from Git repository + +.. code:: + + > platformio platform install https://github.com/platformio/platform-atmelavr.git + + PlatformManager: Installing platform-atmelavr + git version 2.7.4 (Apple Git-66) + Cloning into '/Volumes/MEDIA/tmp/pio3_test_projects/arduino-digihead-master/home_dir/platforms/installing-U3ucN0-package'... + remote: Counting objects: 176, done. + remote: Compressing objects: 100% (55/55), done. + remote: Total 176 (delta 114), reused 164 (delta 109), pack-reused 0 + Receiving objects: 100% (176/176), 38.86 KiB | 0 bytes/s, done. + Resolving deltas: 100% (114/114), done. + Checking connectivity... done. + Submodule 'examples/arduino-external-libs/lib/OneWire' (https://github.com/PaulStoffregen/OneWire.git) registered for path 'examples/arduino-external-libs/lib/OneWire' + Cloning into 'examples/arduino-external-libs/lib/OneWire'... + remote: Counting objects: 91, done. + remote: Total 91 (delta 0), reused 0 (delta 0), pack-reused 91 + Unpacking objects: 100% (91/91), done. + Checking connectivity... done. + Submodule path 'examples/arduino-external-libs/lib/OneWire': checked out '57c18c6de80c13429275f70875c7c341f1719201' + atmelavr @ 0.0.0 has been successfully installed! + PackageManager: Installing tool-scons @ >=2.3.0,<2.6.0 + Downloading [####################################] 100% + Unpacking [####################################] 100% + tool-scons @ 2.4.1 has been successfully installed! + PackageManager: Installing toolchain-atmelavr @ ~1.40801.0 + Downloading [####################################] 100% + Unpacking [####################################] 100% + toolchain-atmelavr @ 1.40801.0 has been successfully installed! + The platform 'https://github.com/platformio/platform-atmelavr.git' has been successfully installed! + The rest of packages will be installed automatically depending on your build environment. diff --git a/docs/userguide/platforms/cmd_list.rst b/docs/userguide/platforms/cmd_list.rst index ebc72141..2ae465c8 100644 --- a/docs/userguide/platforms/cmd_list.rst +++ b/docs/userguide/platforms/cmd_list.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,10 +9,10 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_platforms_list: +.. _cmd_platform_list: -platformio platforms list -========================= +platformio platform list +======================== .. contents:: @@ -21,7 +21,7 @@ Usage .. code-block:: bash - platformio platforms list [OPTIONS] + platformio platform list [OPTIONS] Description @@ -32,7 +32,7 @@ List installed :ref:`platforms` Options ~~~~~~~ -.. program:: platformio platforms list +.. program:: platformio platform list .. option:: --json-output @@ -42,15 +42,31 @@ Return the output in `JSON `_ format Examples -------- -.. code-block:: bash +.. code:: - $ platformio platforms list - atmelavr with packages: toolchain-atmelavr, tool-avrdude, framework-arduinoavr, tool-micronucleus - atmelsam with packages: framework-arduinosam, ldscripts, toolchain-gccarmnoneeabi, tool-bossac - freescalekinetis with packages: framework-mbed, toolchain-gccarmnoneeabi - nordicnrf51 with packages: framework-mbed, toolchain-gccarmnoneeabi - nxplpc with packages: framework-mbed, toolchain-gccarmnoneeabi - ststm32 with packages: framework-libopencm3, toolchain-gccarmnoneeabi, tool-stlink, framework-spl, framework-cmsis, framework-mbed, ldscripts - teensy with packages: toolchain-atmelavr, ldscripts, framework-arduinoteensy, toolchain-gccarmnoneeabi, tool-teensy - timsp430 with packages: toolchain-timsp430, tool-mspdebug, framework-energiamsp430, framework-arduinomsp430 - titiva with packages: ldscripts, framework-libopencm3, toolchain-gccarmnoneeabi, tool-lm4flash, framework-energiativa + > platformio platform list + + atmelavr ~ Atmel AVR + ==================== + Atmel AVR 8- and 32-bit MCUs deliver a unique combination of performance, power efficiency and design flexibility. Optimized to speed time to market-and easily adapt to new ones-they are based on the industrys most code-efficient architecture for C and assembly programming. + + Home: http://platformio.org/platforms/atmelavr + Packages: toolchain-atmelavr, framework-simba + Version: 0.0.0 + + atmelsam ~ Atmel SAM + ==================== + Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB to 2MB of Flash including a rich peripheral and feature mix. + + Home: http://platformio.org/platforms/atmelsam + Packages: framework-arduinosam, framework-mbed, framework-simba, toolchain-gccarmnoneeabi, tool-bossac + Version: 0.0.0 + + espressif8266 ~ Espressif 8266 + ============================== + Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications. + + Home: http://platformio.org/platforms/espressif8266 + Packages: framework-simba, tool-esptool, framework-arduinoespressif8266, sdk-esp8266, toolchain-xtensa + Version: 0.0.0 + ... diff --git a/docs/userguide/platforms/cmd_search.rst b/docs/userguide/platforms/cmd_search.rst index 1bb7104d..9f0dc648 100644 --- a/docs/userguide/platforms/cmd_search.rst +++ b/docs/userguide/platforms/cmd_search.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,10 +9,10 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_platforms_search: +.. _cmd_platform_search: -platformio platforms search -=========================== +platformio platform search +========================== .. contents:: @@ -21,7 +21,7 @@ Usage .. code-block:: bash - platformio platforms search QUERY [OPTIONS] + platformio platform search QUERY [OPTIONS] Description @@ -32,7 +32,7 @@ Search for development :ref:`platforms` Options ~~~~~~~ -.. program:: platformio platforms search +.. program:: platformio platform search .. option:: --json-output @@ -45,75 +45,105 @@ Examples 1. Print all available development platforms -.. code-block:: bash +.. code:: - $ platformio platforms search - atmelavr (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - -------- - Atmel AVR 8- and 32-bit MCUs deliver a unique combination of performance... + > platformio platform search - atmelsam (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - -------- - Atmel | SMART offers Flash- based ARM products based on the ... + atmelavr ~ Atmel AVR + ==================== + Atmel AVR 8- and 32-bit MCUs deliver a unique combination of performance, power efficiency and design flexibility. Optimized to speed time to market-and easily adapt to new ones-they are based on the industrys most code-efficient architecture for C and assembly programming. - freescalekinetis (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ---------------- - Freescale Kinetis Microcontrollers is family of multiple hardware- and ... + Home: http://platformio.org/platforms/atmelavr + Packages: toolchain-atmelavr, framework-simba + Version: 0.0.0 - nordicnrf51 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ----------- - The Nordic nRF51 Series is a family of highly flexible, multi-protocol ... + atmelsam ~ Atmel SAM + ==================== + Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB to 2MB of Flash including a rich peripheral and feature mix. - nxplpc (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------ - The NXP LPC is a family of 32-bit microcontroller integrated circuits ... + Home: http://platformio.org/platforms/atmelsam + Packages: framework-arduinosam, framework-mbed, framework-simba, toolchain-gccarmnoneeabi, tool-bossac + Version: 0.0.0 - ststm32 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------- - The STM32 family of 32-bit Flash MCUs based on the ARM Cortex-M ... + espressif8266 ~ Espressif 8266 + ============================== + Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications. - teensy (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------ - Teensy is a complete USB-based microcontroller development syste ... - - timsp430 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - -------- - MSP430 microcontrollers (MCUs) from Texas Instruments (TI) are ... - - titiva (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------ - Texas Instruments TM4C12x MCUs offer the industrys most popular ... + Home: http://platformio.org/platforms/espressif + Packages: framework-simba, tool-esptool, framework-arduinoespressif8266, sdk-esp8266, toolchain-xtensa + Version: 0.0.0 + ... 2. Search for TI development platforms -.. code-block:: bash +.. code:: - $ platformio platforms search ti - timsp430 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - -------- - MSP430 microcontrollers (MCUs) from Texas Instruments (TI) are ... + > platformio platform search texas - titiva (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------ - Texas Instruments TM4C12x MCUs offer the industrys most popular ... + timsp430 ~ TI MSP430 + ==================== + MSP430 microcontrollers (MCUs) from Texas Instruments (TI) are 16-bit, RISC-based, mixed-signal processors designed for ultra-low power. These MCUs offer the lowest power consumption and the perfect mix of integrated peripherals for thousands of applications. -3. Search for development platforms which support "mbed Framework" + Home: http://platformio.org/platforms/timsp430 + Packages: toolchain-timsp430, tool-mspdebug, framework-energiamsp430, framework-arduinomsp430 -.. code-block:: bash + titiva ~ TI TIVA + ================ + Texas Instruments TM4C12x MCUs offer the industrys most popular ARM Cortex-M4 core with scalable memory and package options, unparalleled connectivity peripherals, advanced application functions, industry-leading analog integration, and extensive software solutions. - $ platformio platforms search mbed - freescalekinetis (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ---------------- - Freescale Kinetis Microcontrollers is family of multiple hardware- and ... + Home: http://platformio.org/platforms/titiva + Packages: ldscripts, framework-libopencm3, toolchain-gccarmnoneeabi, tool-lm4flash, framework-energiativa - nordicnrf51 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ----------- - The Nordic nRF51 Series is a family of highly flexible, multi-protocol ... +.. code:: - nxplpc (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------ - The NXP LPC is a family of 32-bit microcontroller integrated circuits ... + > platformio platform search framework-mbed - ststm32 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------- - The STM32 family of 32-bit Flash MCUs based on the ARM Cortex-M ... + atmelsam ~ Atmel SAM + ==================== + Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB to 2MB of Flash including a rich peripheral and feature mix. + + Home: http://platformio.org/platforms/atmelsam + Packages: toolchain-gccarmnoneeabi, framework-arduinosam, framework-simba, tool-openocd, framework-mbed, ldscripts, tool-bossac + + freescalekinetis ~ Freescale Kinetis + ==================================== + Freescale Kinetis Microcontrollers is family of multiple hardware- and software-compatible ARM Cortex-M0+, Cortex-M4 and Cortex-M7-based MCU series. Kinetis MCUs offer exceptional low-power performance, scalability and feature integration. + + Home: http://platformio.org/platforms/freescalekinetis + Packages: framework-mbed, toolchain-gccarmnoneeabi + + nordicnrf51 ~ Nordic nRF51 + ========================== + The Nordic nRF51 Series is a family of highly flexible, multi-protocol, system-on-chip (SoC) devices for ultra-low power wireless applications. nRF51 Series devices support a range of protocol stacks including Bluetooth Smart (previously called Bluetooth low energy), ANT and proprietary 2.4GHz protocols such as Gazell. + + Home: http://platformio.org/platforms/nordicnrf51 + Packages: framework-mbed, tool-rfdloader, toolchain-gccarmnoneeabi, framework-arduinonordicnrf51 + + nxplpc ~ NXP LPC + ================ + The NXP LPC is a family of 32-bit microcontroller integrated circuits by NXP Semiconductors. The LPC chips are grouped into related series that are based around the same 32-bit ARM processor core, such as the Cortex-M4F, Cortex-M3, Cortex-M0+, or Cortex-M0. Internally, each microcontroller consists of the processor core, static RAM memory, flash memory, debugging interface, and various peripherals. + + Home: http://platformio.org/platforms/nxplpc + Packages: framework-mbed, toolchain-gccarmnoneeabi + + siliconlabsefm32 ~ Silicon Labs EFM32 + ===================================== + Silicon Labs EFM32 Gecko 32-bit microcontroller (MCU) family includes devices that offer flash memory configurations up to 256 kB, 32 kB of RAM and CPU speeds up to 48 MHz. Based on the powerful ARM Cortex-M core, the Gecko family features innovative low energy techniques, short wake-up time from energy saving modes and a wide selection of peripherals, making it ideal for battery operated applications and other systems requiring high performance and low-energy consumption. + + Home: http://platformio.org/platforms/siliconlabsefm32 + Packages: framework-mbed, toolchain-gccarmnoneeabi + + ststm32 ~ ST STM32 + ================== + The STM32 family of 32-bit Flash MCUs based on the ARM Cortex-M processor is designed to offer new degrees of freedom to MCU users. It offers a 32-bit product range that combines very high performance, real-time capabilities, digital signal processing, and low-power, low-voltage operation, while maintaining full integration and ease of development. + + Home: http://platformio.org/platforms/ststm32 + Packages: framework-libopencm3, toolchain-gccarmnoneeabi, tool-stlink, framework-spl, framework-cmsis, framework-mbed, ldscripts + + teensy ~ Teensy + =============== + Teensy is a complete USB-based microcontroller development system, in a very small footprint, capable of implementing many types of projects. All programming is done via the USB port. No special programmer is needed, only a standard USB cable and a PC or Macintosh with a USB port. + + Home: http://platformio.org/platforms/teensy + Packages: framework-arduinoteensy, tool-teensy, toolchain-gccarmnoneeabi, framework-mbed, toolchain-atmelavr, ldscripts + ... diff --git a/docs/userguide/platforms/cmd_show.rst b/docs/userguide/platforms/cmd_show.rst index 3f66d3d3..35ec16c3 100644 --- a/docs/userguide/platforms/cmd_show.rst +++ b/docs/userguide/platforms/cmd_show.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,10 +9,10 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_platforms_show: +.. _cmd_platform_show: -platformio platforms show -========================= +platformio platform show +======================== .. contents:: @@ -21,7 +21,7 @@ Usage .. code-block:: bash - platformio platforms show PLATFORM + platformio platform show PLATFORM Description @@ -33,24 +33,56 @@ Show details about the installed :ref:`platforms` Examples -------- -.. code-block:: bash +.. code:: - $ platformio platforms show atmelavr - atmelavr - An embedded platform for Atmel AVR microcontrollers (with Arduino Framework) - ---------- - Package: toolchain-atmelavr - Alias: toolchain - Version: 1 - Installed: 2014-12-13 23:58:48 - ---------- - Package: tool-avrdude - Version: 2 - Installed: 2015-02-13 22:23:17 - ---------- - Package: framework-arduinoavr - Version: 12 - Installed: 2015-02-23 20:57:40 - ---------- - Package: tool-micronucleus - Version: 1 - Installed: 2015-02-23 21:20:14 + > platformio platform show atmelavr + + atmelavr ~ Atmel AVR + ==================== + Atmel AVR 8- and 32-bit MCUs deliver a unique combination of performance, power efficiency and design flexibility. Optimized to speed time to market-and easily adapt to new ones-they are based on the industrys most code-efficient architecture for C and assembly programming. + + Version: 0.0.0 + Home: http://platformio.org/platforms/atmelavr + License: Apache-2.0 + Frameworks: simba, arduino + + Package toolchain-atmelavr + -------------------------- + Type: toolchain + Optional: No + Requirements: ~1.40801.0 + Installed: Yes + Description: avr-gcc + Url: https://gcc.gnu.org/wiki/avr-gcc + Version: 1.40801.0 + + Package framework-arduinoavr + ---------------------------- + Type: framework + Optional: Yes + Requirements: ~1.10608.0 + Installed: No (optional) + + Package framework-simba + ----------------------- + Type: framework + Optional: Yes + Requirements: ~1.50.0 + Installed: Yes + Description: framework-simba + Url: https://github.com/eerimoq/simba + Version: 1.50.0 + + Package tool-avrdude + -------------------- + Type: uploader + Optional: Yes + Requirements: >=1.60001.0,<=1.60100.0 + Installed: No (optional) + + Package tool-micronucleus + ------------------------- + Type: uploader + Optional: Yes + Requirements: ~1.200.0 + Installed: No (optional) diff --git a/docs/userguide/platforms/cmd_uninstall.rst b/docs/userguide/platforms/cmd_uninstall.rst index 0a4545a9..d26c4c23 100644 --- a/docs/userguide/platforms/cmd_uninstall.rst +++ b/docs/userguide/platforms/cmd_uninstall.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,10 +9,10 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_platforms_uninstall: +.. _cmd_platform_uninstall: -platformio platforms uninstall -============================== +platformio platform uninstall +============================= .. contents:: @@ -21,7 +21,10 @@ Usage .. code-block:: bash - platformio platforms uninstall PLATFORM + platformio platform uninstall [PLATFORM...] + + # uninstall specific platform version using Semantic Versioning + platformio platform uninstall PLATFORM@X.Y.Z Description @@ -33,10 +36,10 @@ Uninstall specified :ref:`platforms` Examples -------- -.. code-block:: bash +.. code:: - $ platformio platforms uninstall timsp430 - Uninstalling toolchain-timsp430 package: [OK] - Uninstalling tool-mspdebug package: [OK] - Uninstalling framework-energiamsp430 package: [OK] - The platform 'timsp430' has been successfully uninstalled! + > platformio platform uninstall atmelavr + Uninstalling platform atmelavr @ 0.0.0: [OK] + Uninstalling package tool-scons @ 2.4.1: [OK] + Uninstalling package toolchain-atmelavr @ 1.40801.0: [OK] + The platform 'atmelavr' has been successfully uninstalled! diff --git a/docs/userguide/platforms/cmd_update.rst b/docs/userguide/platforms/cmd_update.rst index 96e52d68..79612b0d 100644 --- a/docs/userguide/platforms/cmd_update.rst +++ b/docs/userguide/platforms/cmd_update.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-present Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,10 +9,10 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_platforms_update: +.. _cmd_platform_update: -platformio platforms update -=========================== +platformio platform update +========================== .. contents:: @@ -21,7 +21,10 @@ Usage .. code-block:: bash - platformio platforms update + platformio platform update [OPTIONS] [PLATFORM...] + + # update specific platform version using Semantic Versioning + platformio platform update PLATFORM@X.Y.Z Description @@ -29,82 +32,55 @@ Description Check or update installed :ref:`platforms` +Options +------- + +.. program:: platformio platform update + +.. option:: + -p, --only-packages + +Update only platform related packages. Do not update development platform +build scripts, board configs and etc. + +.. option:: + -c, --only-check + +Do not update, only check for new version Examples -------- -.. code-block:: bash +.. code:: - $ platformio platforms update + > platformio platform update Platform atmelavr -------- - Updating toolchain-atmelavr package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-avrdude package: - Versions: Current=2, Latest=2 [Up-to-date] - Updating framework-arduinoavr package: - Versions: Current=12, Latest=12 [Up-to-date] - Updating tool-micronucleus package: - Versions: Current=1, Latest=1 [Up-to-date] + Updating atmelavr @ 0.0.0: [Up-to-date] + Updating framework-arduinoavr @ 1.10608.1: [Up-to-date] + Updating tool-avrdude @ 1.60001.1: [Up-to-date] + Updating toolchain-atmelavr @ 1.40801.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] - Platform atmelsam + Platform espressif8266 -------- - Updating framework-arduinosam package: - Versions: Current=3, Latest=3 [Up-to-date] - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-bossac package: - Versions: Current=1, Latest=1 [Up-to-date] - - Platform stm32 - -------- - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-stlink package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-spl package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-cmsis package: - Versions: Current=2, Latest=2 [Up-to-date] - Updating framework-opencm3 package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] + Updating espressif @ 0.0.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + Updating toolchain-xtensa @ 1.40802.0: [Up-to-date] + Updating tool-esptool @ 1.409.0: [Up-to-date] + Updating tool-mkspiffs @ 1.102.0: [Up-to-date] + Updating framework-arduinoespressif8266 @ 1.20300.0: [Up-to-date] + Updating sdk-esp8266 @ 1.10502.0: [Up-to-date] Platform teensy -------- - Updating toolchain-atmelavr package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-arduinoteensy package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-teensy package: - Versions: Current=1, Latest=1 [Up-to-date] + Updating teensy @ 0.0.0: [Up-to-date] + Updating framework-arduinoteensy @ 1.128.0: [Up-to-date] + Updating tool-teensy @ 1.1.0: [Up-to-date] + Updating framework-mbed @ 1.121.0: [Up-to-date] + Updating tool-scons @ 2.4.1: [Up-to-date] + Updating toolchain-atmelavr @ 1.40801.0: [Up-to-date] + Updating toolchain-gccarmnoneeabi @ 1.40804.0: [Up-to-date] - Platform timsp430 - -------- - Updating toolchain-timsp430 package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-mspdebug package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-energiamsp430 package: - Versions: Current=2, Latest=2 [Up-to-date] - - Platform titiva - -------- - Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating tool-lm4flash package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-opencm3 package: - Versions: Current=1, Latest=1 [Up-to-date] - Updating framework-energiativa package: - Versions: Current=4, Latest=4 [Up-to-date] + ... diff --git a/docs/userguide/platforms/index.rst b/docs/userguide/platforms/index.rst index 1d084ccd..b9402f61 100644 --- a/docs/userguide/platforms/index.rst +++ b/docs/userguide/platforms/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -9,7 +9,7 @@ See the License for the specific language governing permissions and limitations under the License. -.. _userguide_platforms: +.. _userguide_platform: Platform Manager ================ @@ -18,8 +18,8 @@ To print all available commands and options use: .. code-block:: bash - $ platformio platforms --help - $ platformio platforms COMMAND --help + platformio platform --help + platformio platform COMMAND --help .. image:: ../../_static/platformio-demo-platforms.gif diff --git a/docs/what-is-platformio.rst b/docs/what-is-platformio.rst index 0eb61dd5..13fd7a2b 100644 --- a/docs/what-is-platformio.rst +++ b/docs/what-is-platformio.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -76,7 +76,7 @@ Alright, so PlatformIO can run on different operating systems. But more importantly, from development perspective at least, is a list of supported boards and MCUs. To keep things short: PlatformIO supports approximately 200 `Embedded Boards `_ and all major -:ref:`Development Platforms `. +:ref:`platforms`. User SHOULD have a choice ------------------------- diff --git a/examples b/examples index a657ca42..72b3153a 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit a657ca4225f55af7239b89486350c9f02bb3ee93 +Subproject commit 72b3153af021232552eafccb247186e5563ed533 diff --git a/platformio/__init__.py b/platformio/__init__.py index 1282de0a..d01eed7d 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,29 +14,25 @@ import sys -VERSION = (2, 11, 2) +VERSION = (3, 0, 0) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" -__description__ = ( - "An open source ecosystem for IoT development. " - "Cross-platform build system and library manager. " - "Continuous and IDE integration. " - "Arduino and MBED compatible. Ready for Cloud compiling." -) +__description__ = ("An open source ecosystem for IoT development. " + "Cross-platform build system and library manager. " + "Continuous and IDE integration. " + "Arduino, ESP8266 and ARM mbed compatible") __url__ = "http://platformio.org" __author__ = "Ivan Kravets" __email__ = "me@ikravets.com" __license__ = "Apache Software License" -__copyright__ = "Copyright 2014-2016 Ivan Kravets" +__copyright__ = "Copyright 2014-present PlatformIO" -__apiurl__ = "http://api.platformio.org" -__apiip__ = "198.7.57.247" +__apiurl__ = "https://api.platformio.org" - -if sys.version_info >= (3, 0, 0): +if sys.version_info < (2, 7, 0) or sys.version_info >= (3, 0, 0): msg = ("PlatformIO version %s does not run under Python version %s.\n" "Python 3 is not yet supported.\n") sys.stderr.write(msg % (__version__, sys.version.split()[0])) diff --git a/platformio/__main__.py b/platformio/__main__.py index d6ade4d6..05486bf0 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -40,8 +40,8 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904 def get_command(self, ctx, name): mod = None try: - mod = __import__("platformio.commands." + name, - None, None, ["cli"]) + mod = __import__("platformio.commands." + name, None, None, + ["cli"]) except ImportError: try: return self._handle_obsolate_command(name) @@ -51,28 +51,27 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904 @staticmethod def _handle_obsolate_command(name): - if name in ("install", "list", "search", "show", "uninstall"): - click.secho( - "Warning! `platformio %s` command is deprecated and will be " - "removed in the next release! Please use " - "`platformio platforms %s` instead." % (name, name), - fg="yellow" - ) - from platformio.commands import platforms - return getattr(platforms, "platforms_" + name) + if name == "platforms": + from platformio.commands import platform + return platform.cli + elif name == "serialports": + from platformio.commands import device + return device.cli raise AttributeError() -@click.command(cls=PlatformioCLI, - context_settings=dict(help_option_names=["-h", "--help"])) +@click.command( + cls=PlatformioCLI, + context_settings=dict(help_option_names=["-h", "--help"])) @click.version_option(__version__, prog_name="PlatformIO") -@click.option("--force", "-f", is_flag=True, - help="Force to accept any confirmation prompts.") +@click.option( + "--force", + "-f", + is_flag=True, + help="Force to accept any confirmation prompts.") @click.option("--caller", "-c", help="Caller ID (service).") @click.pass_context def cli(ctx, force, caller): - if not caller and getenv("PLATFORMIO_CALLER"): - caller = getenv("PLATFORMIO_CALLER") maintenance.on_platformio_start(ctx, force, caller) diff --git a/platformio/app.py b/platformio/app.py index 20f2f55e..25ec8ce7 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import hashlib import json +import uuid from copy import deepcopy from os import environ, getenv from os.path import getmtime, isfile, join @@ -44,29 +46,24 @@ DEFAULT_SETTINGS = { "description": "Automatically update libraries (Yes/No)", "value": False }, - "enable_telemetry": { - "description": ( - "Telemetry service (Yes/No)"), - "value": True + "force_verbose": { + "description": "Force verbose output when processing environments", + "value": False }, - "enable_prompts": { - "description": ( - "Can PlatformIO communicate with you via prompts: " - "propose to install platforms which aren't installed yet, " - "paginate over library search results and etc.)? ATTENTION!!! " - "If you call PlatformIO like subprocess, " - "please disable prompts to avoid blocking (Yes/No)"), + "disable_ssl": { + "description": ("Disable SSL for PlatformIO API " + "(NOT RECOMMENDED, INSECURE)"), + "value": False + }, + "enable_telemetry": { + "description": + ("Telemetry service (Yes/No)"), "value": True } } - -SESSION_VARS = { - "command_ctx": None, - "force_option": False, - "caller_id": None -} +SESSION_VARS = {"command_ctx": None, "force_option": False, "caller_id": None} class State(object): @@ -104,8 +101,8 @@ class State(object): return self._lockfile = LockFile(self.path) - if (self._lockfile.is_locked() and - (time() - getmtime(self._lockfile.lock_file)) > 10): + if self._lockfile.is_locked() and \ + (time() - getmtime(self._lockfile.lock_file)) > 10: self._lockfile.break_lock() self._lockfile.acquire() @@ -144,12 +141,6 @@ def set_state_item(name, value): def get_setting(name): - if name == "enable_prompts": - # disable prompts for Continuous Integration systems - # and when global "--force" option is set - if any([util.is_ci(), get_session_var("force_option")]): - return False - _env_name = "PLATFORMIO_SETTING_%s" % name.upper() if _env_name in environ: return sanitize_setting(name, getenv(_env_name)) @@ -184,5 +175,16 @@ def set_session_var(name, value): def is_disabled_progressbar(): - return (not get_setting("enable_prompts") or - getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true") + return any([get_session_var("force_option"), util.is_ci(), + getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true"]) + + +def get_cid(): + cid = get_state_item("cid") + if not cid: + cid = str( + uuid.UUID(bytes=hashlib.md5( + str(getenv("C9_UID") + if getenv("C9_UID") else uuid.getnode())).digest())) + set_state_item("cid", cid) + return cid diff --git a/platformio/boards/adafruit.json b/platformio/boards/adafruit.json deleted file mode 100644 index fc5ef21c..00000000 --- a/platformio/boards/adafruit.json +++ /dev/null @@ -1,282 +0,0 @@ -{ - "flora8": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_FLORA8", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "Adafruit Flora", - "variant": "flora", - "hwids": [ - ["0x239A", "0x8004"] - ] - }, - "frameworks": ["arduino"], - "name": "Adafruit Flora", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.adafruit.com/product/659", - "vendor": "Adafruit" - }, - - "bluefruitmicro": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_BLUEFRUITMICRO", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "Bluefruit Micro", - "variant": "bluefruitmicro", - "hwids": [ - ["0x239A", "0x800A"] - ] - }, - "frameworks": ["arduino"], - "name": "Adafruit Bluefruit Micro", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.adafruit.com/products/2661", - "vendor": "Adafruit" - }, - - "gemma": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_GEMMA", - "f_cpu": "8000000L", - "mcu": "attiny85", - "variant": "tiny8" - }, - "frameworks": ["arduino"], - "name": "Adafruit Gemma", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 8192, - "protocol": "usbtiny" - }, - "url": "http://www.adafruit.com/products/1222", - "vendor": "Adafruit" - }, - - "feather32u4": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_FEATHER32U4", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "Feather 32u4", - "variant": "feather32u4", - "hwids": [ - ["0x239A", "0x800C"] - ] - }, - "frameworks": ["arduino"], - "name": "Adafruit Feather", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/", - "vendor": "Adafruit" - }, - - "trinket3": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_TRINKET3", - "f_cpu": "8000000L", - "mcu": "attiny85", - "variant": "tiny8" - }, - "frameworks": ["arduino"], - "name": "Adafruit Trinket 3V/8MHz", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 8192, - "protocol": "usbtiny" - }, - "url": "http://www.adafruit.com/products/1500", - "vendor": "Adafruit" - }, - - "trinket5": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_TRINKET5", - "f_cpu": "16000000L", - "mcu": "attiny85", - "variant": "tiny8" - }, - "frameworks": ["arduino"], - "name": "Adafruit Trinket 5V/16MHz", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 8192, - "protocol": "usbtiny" - }, - "url": "http://www.adafruit.com/products/1501", - "vendor": "Adafruit" - }, - - "metro": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_METRO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Adafruit Metro", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.adafruit.com/products/2466", - "vendor": "Adafruit" - }, - - "protrinket3": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PROTRINKET3", - "f_cpu": "12000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Adafruit Pro Trinket 3V/12MHz (USB)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 28672, - "protocol": "usbtiny" - }, - "url": "http://www.adafruit.com/products/2010", - "vendor": "Adafruit" - }, - - "protrinket5": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PROTRINKET5", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Adafruit Pro Trinket 5V/16MHz (USB)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 28672, - "protocol": "usbtiny" - }, - "url": "http://www.adafruit.com/products/2000", - "vendor": "Adafruit" - }, - "protrinket3ftdi": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PROTRINKET3FTDI", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Adafruit Pro Trinket 3V/12MHz (FTDI)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 28672, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.adafruit.com/products/2010", - "vendor": "Adafruit" - }, - "protrinket5ftdi": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PROTRINKET5FTDI", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Adafruit Pro Trinket 5V/16MHz (USB)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 28672, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.adafruit.com/products/2000", - "vendor": "Adafruit" - }, - "adafruit_feather_m0_usb": { - "build": { - "core": "arduino_zero", - "extra_flags": "-DARDUINO_SAMD_FEATHER_M0 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Adafruit Feather M0", - "variant": "arduino_zero", - "ldscript": "flash_with_bootloader.ld", - "hwids": [ - ["0x239A", "0x800B"], - ["0x239A", "0x000B"] - ] - }, - "frameworks": ["arduino"], - "name": "Adafruit Feather M0", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.adafruit.com/product/2772", - "vendor": "Adafruit" - } -} diff --git a/platformio/boards/arduino.json b/platformio/boards/arduino.json deleted file mode 100644 index 99ab8a54..00000000 --- a/platformio/boards/arduino.json +++ /dev/null @@ -1,1093 +0,0 @@ -{ - "LilyPadUSB": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LILYPAD_USB", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "LilyPad USB", - "variant": "leonardo", - "hwids": [ - ["0x1B4F", "0x9207"], - ["0x1B4F", "0x9208"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino LilyPad USB", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardLilyPadUSB", - "vendor": "Arduino" - }, - "atmegangatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_NG", - "f_cpu": "16000000L", - "mcu": "atmega168", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Arduino NG or older ATmega168", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/main/boards", - "vendor": "Arduino" - }, - "atmegangatmega8": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_NG", - "f_cpu": "16000000L", - "mcu": "atmega8", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Arduino NG or older ATmega8", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 7168, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/main/boards", - "vendor": "Arduino" - }, - "btatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_BT", - "f_cpu": "16000000L", - "mcu": "atmega168", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino BT ATmega168", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/main/boards", - "vendor": "Arduino" - }, - "btatmega328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_BT", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino BT ATmega328", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2048, - "maximum_size": 28672, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/main/boards", - "vendor": "Arduino" - }, - "diecimilaatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_DUEMILANOVE", - "f_cpu": "16000000L", - "mcu": "atmega168", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Arduino Duemilanove or Diecimila ATmega168", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardDiecimila", - "vendor": "Arduino" - }, - "diecimilaatmega328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_DUEMILANOVE", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Arduino Duemilanove or Diecimila ATmega328", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardDiecimila", - "vendor": "Arduino" - }, - "esplora": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ESPLORA", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduino Esplora", - "variant": "leonardo", - "hwids": [ - ["0x2341", "0x003C"], - ["0x2341", "0x803C"], - ["0x2A03", "0x003C"], - ["0x2A03", "0x803C"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Esplora", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-esplora", - "vendor": "Arduino" - }, - "ethernet": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ETHERNET", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "ethernet" - }, - "frameworks": ["arduino"], - "name": "Arduino Ethernet", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-ethernet", - "vendor": "Arduino" - }, - "fio": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_FIO", - "f_cpu": "8000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Fio", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardFio", - "vendor": "Arduino" - }, - "leonardo": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LEONARDO", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduino Leonardo", - "variant": "leonardo", - "hwids": [ - ["0x2341", "0x0036"], - ["0x2341", "0x8036"], - ["0x2A03", "0x0036"], - ["0x2A03", "0x8036"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Leonardo", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-leonardo", - "vendor": "Arduino" - }, - "leonardoeth": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LEONARDO", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduino Leonardo ETH", - "variant": "leonardo", - "hwids": [ - ["0x2A03", "0x8040"], - ["0x2A03", "0x0040"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Leonardo ETH", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-leonardo-eth", - "vendor": "Arduino" - }, - "lilypadatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LILYPAD", - "f_cpu": "8000000L", - "mcu": "atmega168", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Arduino LilyPad ATmega168", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardLilyPad", - "vendor": "Arduino" - }, - "lilypadatmega328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LILYPAD", - "f_cpu": "8000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Arduino LilyPad ATmega328", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardLilyPad", - "vendor": "Arduino" - }, - "megaADK": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ADK", - "f_cpu": "16000000L", - "mcu": "atmega2560", - "variant": "mega" - }, - "frameworks": ["arduino"], - "name": "Arduino Mega ADK", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 253952, - "protocol": "wiring", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-mega-adk", - "vendor": "Arduino" - }, - "megaatmega1280": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA", - "f_cpu": "16000000L", - "mcu": "atmega1280", - "variant": "mega" - }, - "frameworks": ["arduino"], - "name": "Arduino Mega or Mega 2560 ATmega1280", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 126976, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-mega-2560", - "vendor": "Arduino" - }, - "megaatmega2560": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560", - "f_cpu": "16000000L", - "mcu": "atmega2560", - "variant": "mega" - }, - "frameworks": ["arduino", "simba"], - "name": "Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 253952, - "protocol": "wiring", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-mega-2560", - "vendor": "Arduino" - }, - "micro": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MICRO", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduino Micro", - "variant": "micro", - "hwids": [ - ["0x2341", "0x0037"], - ["0x2341", "0x8037"], - ["0x2A03", "0x0037"], - ["0x2A03", "0x8037"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Micro", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-micro", - "vendor": "Arduino" - }, - "miniatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MINI", - "f_cpu": "16000000L", - "mcu": "atmega168", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Mini ATmega168", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardMini", - "vendor": "Arduino" - }, - "miniatmega328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MINI", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Mini ATmega328", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 28672, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardMini", - "vendor": "Arduino" - }, - "nanoatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_NANO", - "f_cpu": "16000000L", - "mcu": "atmega168", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Nano ATmega168", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-nano", - "vendor": "Arduino" - }, - "nanoatmega328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_NANO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino", "simba"], - "name": "Arduino Nano ATmega328", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-nano", - "vendor": "Arduino" - }, - "pro16MHzatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PRO", - "f_cpu": "16000000L", - "mcu": "atmega168", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Pro or Pro Mini ATmega168 (5V, 16 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardProMini", - "vendor": "Arduino" - }, - "pro16MHzatmega328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PRO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Pro or Pro Mini ATmega328 (5V, 16 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardProMini", - "vendor": "Arduino" - }, - "pro8MHzatmega168": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PRO", - "f_cpu": "8000000L", - "mcu": "atmega168", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Pro or Pro Mini ATmega168 (3.3V, 8 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 14336, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardProMini", - "vendor": "Arduino" - }, - "pro8MHzatmega328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PRO", - "f_cpu": "8000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://arduino.cc/en/Main/ArduinoBoardProMini", - "vendor": "Arduino" - }, - "robotControl": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ROBOT_CONTROL", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Robot Control", - "variant": "robot_control", - "hwids": [ - ["0x2341", "0x0038"], - ["0x2341", "0x8038"], - ["0x2A03", "0x0038"], - ["0x2A03", "0x8038"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Robot Control", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-robot", - "vendor": "Arduino" - }, - "robotMotor": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ROBOT_MOTOR", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Robot Motor", - "variant": "robot_motor", - "hwids": [ - ["0x2341", "0x0039"], - ["0x2341", "0x8039"], - ["0x2A03", "0x0039"], - ["0x2A03", "0x8039"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Robot Motor", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-robot", - "vendor": "Arduino" - }, - "uno": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard", - "hwids": [ - ["0x2341", "0x0043"], - ["0x2341", "0x0001"], - ["0x2A03", "0x0043"] - ] - }, - "frameworks": ["arduino", "simba"], - "name": "Arduino Uno", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-uno", - "vendor": "Arduino" - }, - "yun": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduino Yun", - "variant": "yun", - "hwids": [ - ["0x2341", "0x0041"], - ["0x2341", "0x8041"], - ["0x2A03", "0x0041"], - ["0x2A03", "0x8041"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Yun", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "via_ssh": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-yun", - "vendor": "Arduino" - }, - "yunmini": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduino Yun Mini", - "variant": "yun", - "hwids": [ - ["0x2A03", "0x8050"], - ["0x2A03", "0x0050"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Yun Mini", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "via_ssh": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-yun-mini", - "vendor": "Arduino" - }, - "chiwawa": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduino Industrial 101", - "variant": "yun", - "hwids": [ - ["0x2A03", "0x8056"], - ["0x2A03", "0x0056"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Industrial 101", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "via_ssh": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-industrial-101", - "vendor": "Arduino" - }, - "one": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Linino One", - "variant": "yun", - "hwids": [ - ["0x2A03", "0x8001"], - ["0x2A03", "0x0001"] - ] - }, - "frameworks": ["arduino"], - "name": "Linino One", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "via_ssh": true, - "wait_for_upload_port": true - }, - "url": "http://www.linino.org/portfolio/linino-one/", - "vendor": "Linino" - }, - "due": { - "build": { - "core": "arduino", - "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM", - "f_cpu": "84000000L", - "mcu": "sam3x8e", - "cpu": "cortex-m3", - "usb_product": "Arduino Due", - "variant": "arduino_due_x", - "ldscript": "sam3x8e.ld", - "hwids": [ - ["0x2341", "0x003D"], - ["0x2A03", "0x003D"] - ] - }, - "frameworks": ["arduino", "simba"], - "name": "Arduino Due (Programming Port)", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 524288, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": false - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-due", - "vendor": "Arduino" - }, - "dueUSB": { - "build": { - "core": "arduino", - "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM", - "f_cpu": "84000000L", - "mcu": "sam3x8e", - "cpu": "cortex-m3", - "usb_product": "Arduino Due", - "variant": "arduino_due_x", - "ldscript": "sam3x8e.ld", - "hwids": [ - ["0x2341", "0x003E"], - ["0x2A03", "0x003E"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Due (USB Native Port)", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 524288, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.arduino.org/products/boards/4-arduino-boards/arduino-due", - "vendor": "Arduino" - }, - "zero": { - "build": { - "core": "arduino_zero", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Arduino Zero", - "variant": "arduino_zero", - "ldscript": "flash_with_bootloader.ld", - "hwids": [ - ["0x2341", "0x804D"], - ["0x03EB", "0x2157"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Zero (Programming Port)", - "platform": "atmelsam", - "debug": { - "openocdcfg": "arduino_zero.cfg" - }, - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "openocd", - "require_upload_port" : false, - "use_1200bps_touch": false, - "wait_for_upload_port": false, - "section_start": "0x2000" - }, - "url": "https://www.arduino.cc/en/Main/ArduinoBoardZero", - "vendor": "Arduino" - }, - "zeroUSB": { - "build": { - "core": "arduino_zero", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Arduino Zero", - "variant": "arduino_zero", - "ldscript": "flash_with_bootloader.ld", - "hwids": [ - ["0x2341", "0x804D"], - ["0x2341", "0x004D"], - ["0x2341", "0x824D"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Zero (USB Native Port)", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.arduino.cc/en/Main/ArduinoBoardZero", - "vendor": "Arduino" - }, - "mkr1000USB": { - "build": { - "core": "arduino_zero", - "extra_flags": "-DARDUINO_SAMD_MKR1000 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Arduino MKR1000", - "variant": "mkr1000", - "ldscript": "flash_with_bootloader.ld", - "hwids": [ - ["0x2341", "0x804E"], - ["0x2341", "0x004E"], - ["0x2341", "0x824E"], - ["0x2341", "0x024E"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino MKR1000", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.arduino.cc/en/Main/ArduinoMKR1000", - "vendor": "Arduino" - }, - "mzeropro": { - "build": { - "core": "arduino_zero_org", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Arduino M0 Pro", - "variant": "arduino_zero_org", - "ldscript": "samd21g18a_bootloader_org.ld", - "hwids": [ - ["0x2A03", "0x804F"], - ["0x03EB", "0x2111"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino M0 Pro (Programming Port)", - "platform": "atmelsam", - "debug": { - "openocdcfg": "arduino_zero_org.cfg" - }, - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "openocd", - "require_upload_port" : false, - "use_1200bps_touch": false, - "wait_for_upload_port": false, - "section_start": "0x4000" - }, - "url": "http://www.arduino.org/products/boards/arduino-m0-pro", - "vendor": "Arduino" - }, - "mzeroproUSB": { - "build": { - "core": "arduino_zero_org", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Arduino M0 Pro", - "variant": "arduino_zero_org", - "ldscript": "samd21g18a_bootloader_org.ld", - "hwids": [ - ["0x2A03", "0x804F"], - ["0x2A03", "0x004F"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino M0 Pro (Native USB Port)", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true, - "section_start": "0x4000" - }, - "url": "http://www.arduino.org/products/boards/arduino-m0-pro", - "vendor": "Arduino" - }, - "mzeroUSB": { - "build": { - "core": "arduino_zero_org", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Arduino M0", - "variant": "arduino_zero_org", - "ldscript": "samd21g18a_bootloader_org.ld", - "hwids": [ - ["0x2A03", "0x804E"], - ["0x2A03", "0x004E"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino M0", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true, - "section_start": "0x4000" - }, - "url": "http://www.arduino.org/products/boards/arduino-m0", - "vendor": "Arduino" - }, - "tian": { - "build": { - "core": "arduino_zero_org", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "Arduino Tian", - "variant": "arduino_zero_org", - "ldscript": "samd21g18a_bootloader_org.ld", - "hwids": [ - ["0x2A03", "0x8052"], - ["0x10C4", "0xEA70"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Tian", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true, - "section_start": "0x4000" - }, - "url": "http://www.arduino.org/products/boards/arduino-tian", - "vendor": "Arduino" - } -} diff --git a/platformio/boards/atmelsam.json b/platformio/boards/atmelsam.json deleted file mode 100644 index fc956996..00000000 --- a/platformio/boards/atmelsam.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "samr21_xpro": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0plus", - "mcu": "atsamr21g18a" - }, - "frameworks": ["mbed"], - "name": "Atmel ATSAMR21-XPRO", - "platform": "atmelsam", - "debug": { - "openocdcfg": "atmel_samr21_xplained_pro.cfg" - }, - "upload": { - "protocol": "openocd", - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/SAMR21-XPRO/", - "vendor": "Atmel" - }, - "saml21_xpro_b": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0plus", - "mcu": "atsaml21j18b" - }, - "frameworks": ["mbed"], - "name": "Atmel SAML21-XPRO-B", - "platform": "atmelsam", - "debug": { - "openocdcfg": "atmel_saml21_xplained_pro.cfg" - }, - "upload": { - "protocol": "openocd", - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/SAML21-XPRO/", - "vendor": "Atmel" - }, - "samd21_xpro": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0plus", - "mcu": "atsamd21j18a" - }, - "frameworks": ["mbed"], - "name": "Atmel SAMD21-XPRO", - "platform": "atmelsam", - "debug": { - "openocdcfg": "atmel_samd21_xplained_pro.cfg" - }, - "upload": { - "protocol": "openocd", - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/SAMD21-XPRO/", - "vendor": "Atmel" - } -} diff --git a/platformio/boards/digistump.json b/platformio/boards/digistump.json deleted file mode 100644 index 87e4b4b5..00000000 --- a/platformio/boards/digistump.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "digispark-tiny": { - "build": { - "core": "digispark_tiny", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_DIGISPARK", - "f_cpu": "16000000L", - "mcu": "attiny85", - "variant": "digispark_tiny" - }, - "frameworks": ["arduino"], - "name": "Digistump Digispark (Default - 16 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 6012, - "protocol": "digispark" - }, - "url": "http://digistump.com/products/1", - "vendor": "Digistump" - }, - "digispark-pro": { - "build": { - "core": "digispark_pro", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_DIGISPARKPRO", - "f_cpu": "16000000L", - "mcu": "attiny167", - "variant": "digispark_pro" - }, - "frameworks": ["arduino"], - "name": "Digistump Digispark Pro (Default 16 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 14844, - "protocol": "digispark" - }, - "url": "http://digistump.com/products/109", - "vendor": "Digistump" - }, - "digispark-pro32": { - "build": { - "core": "digispark_pro", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_DIGISPARKPRO", - "f_cpu": "16000000L", - "mcu": "attiny167", - "variant": "digispark_pro32" - }, - "frameworks": ["arduino"], - "name": "Digistump Digispark Pro (16 MHz) (32 byte buffer)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 14844, - "protocol": "digispark" - }, - "url": "http://digistump.com/products/109", - "vendor": "Digistump" - }, - "digispark-pro64": { - "build": { - "core": "digispark_pro", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_DIGISPARKPRO", - "f_cpu": "16000000L", - "mcu": "attiny167", - "variant": "digispark_pro64" - }, - "frameworks": ["arduino"], - "name": "Digistump Digispark Pro (16 MHz) (64 byte buffer)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 14844, - "protocol": "digispark" - }, - "url": "http://digistump.com/products/109", - "vendor": "Digistump" - }, - "digix": { - "build": { - "core": "digispark_digix", - "extra_flags": "-w -D__SAM3X8E__ -DARDUINO_SAM_DIGIX -DARDUINO_ARCH_SAM", - "f_cpu": "84000000L", - "mcu": "at91sam3x8e", - "cpu": "cortex-m3", - "ldscript": "sam3x8e.ld", - "usb_product": "Digistump DigiX", - "variant": "digispark_digix", - "hwids": [ - ["0x16D0", "0x078A"] - ] - }, - "frameworks": ["arduino"], - "name": "Digistump DigiX", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 28672, - "maximum_size": 524288, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://digistump.com/products/50", - "vendor": "Digistump" - } -} \ No newline at end of file diff --git a/platformio/boards/engduino.json b/platformio/boards/engduino.json deleted file mode 100644 index 9d76376e..00000000 --- a/platformio/boards/engduino.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "engduinov1": { - "build": { - "board": "AVR_ENGDUINOV1", - "core": "arduino", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "EngduinoV1", - "variant": "engduinov1", - "hwids": [ - ["0x1B4F", "0x9208"] - ] - }, - "frameworks": ["arduino"], - "name": "Engduino 1", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.engduino.org", - "vendor": "Engduino" - }, - "engduinov2": { - "build": { - "board": "AVR_ENGDUINOV2", - "core": "arduino", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "EngduinoV2", - "variant": "engduinov2", - "hwids": [ - ["0x1B4F", "0x9208"] - ] - }, - "frameworks": ["arduino"], - "name": "Engduino 2", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.engduino.org", - "vendor": "Engduino" - }, - "engduinov3": { - "build": { - "board": "AVR_ENGDUINOV3", - "core": "arduino", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "EngduinoV3", - "variant": "engduinov3", - "hwids": [ - ["0x1B4F", "0x9208"] - ] - }, - "frameworks": ["arduino"], - "name": "Engduino 3", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.engduino.org", - "vendor": "Engduino" - } -} \ No newline at end of file diff --git a/platformio/boards/espressif.json b/platformio/boards/espressif.json deleted file mode 100644 index 3c9d21be..00000000 --- a/platformio/boards/espressif.json +++ /dev/null @@ -1,582 +0,0 @@ -{ - "esp01": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.512k64.ld", - "mcu": "esp8266", - "variant": "generic" - }, - "frameworks": ["arduino", "simba"], - "name": "Espressif Generic ESP8266 ESP-01 512k", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 524288, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - }, - - "esp01_1m": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.1m256.ld", - "mcu": "esp8266", - "variant": "generic" - }, - "frameworks": ["arduino", "simba"], - "name": "Espressif Generic ESP8266 ESP-01 1M", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 1048576, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - }, - - "esp07": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP07", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "nodemcu" - }, - "frameworks": ["arduino"], - "name": "Espressif Generic ESP8266 ESP-07", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family#esp-07", - "vendor": "Espressif" - }, - - "esp12e": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "nodemcu" - }, - "frameworks": ["arduino", "simba"], - "name": "Espressif ESP8266 ESP-12E", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - }, - - "espduino": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP13", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "ESPDuino" - }, - "frameworks": ["arduino"], - "name": "ESPDuino (ESP-13 Module)", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/doit/espduinowifi-uno-r3/", - "vendor": "Doit" - }, - - "nodemcu": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_NODEMCU", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "nodemcu", - "hwids": [ - ["0x10C4", "0xEA60"] - ] - }, - "frameworks": ["arduino", "simba"], - "name": "NodeMCU 0.9 (ESP-12 Module)", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.nodemcu.com/", - "vendor": "NodeMCU" - }, - - "nodemcuv2": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_NODEMCU", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "nodemcu", - "hwids": [ - ["0x10C4", "0xEA60"] - ] - }, - "frameworks": ["arduino", "simba"], - "name": "NodeMCU 1.0 (ESP-12E Module)", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.nodemcu.com/", - "vendor": "NodeMCU" - }, - - "huzzah": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "adafruit" - }, - "frameworks": ["arduino", "simba"], - "name": "Adafruit HUZZAH ESP8266", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.adafruit.com/products/2471", - "vendor": "Adafruit" - }, - - "espresso_lite_v1": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESPRESSO_LITE_V1", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "espresso_lite_v1" - }, - "frameworks": ["arduino"], - "name": "ESPresso Lite 1.0", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.espert.co", - "vendor": "ESPert" - }, - - "espresso_lite_v2": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESPRESSO_LITE_V2", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "espresso_lite_v2" - }, - "frameworks": ["arduino"], - "name": "ESPresso Lite 2.0", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.espert.co", - "vendor": "ESPert" - }, - - "modwifi": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_MOD_WIFI_ESP8266", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.2m.ld", - "mcu": "esp8266", - "variant": "generic" - }, - "frameworks": ["arduino"], - "name": "Olimex MOD-WIFI-ESP8266(-DEV)", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 2097152, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/open-source-hardware", - "vendor": "Olimex" - }, - - "thing": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_THING", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.512k64.ld", - "mcu": "esp8266", - "variant": "thing" - }, - "frameworks": ["arduino"], - "name": "SparkFun ESP8266 Thing", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 524288, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.sparkfun.com/products/13231", - "vendor": "SparkFun" - }, - - "thingdev": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_THING", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.512k64.ld", - "mcu": "esp8266", - "variant": "thing" - }, - "frameworks": ["arduino"], - "name": "SparkFun ESP8266 Thing Dev", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 524288, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.sparkfun.com/products/13231", - "vendor": "SparkFun" - }, - - "esp210": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP210", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "generic" - }, - "frameworks": ["arduino"], - "name": "SweetPea ESP-210", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://wiki.sweetpeas.se/index.php?title=ESP-210", - "vendor": "SweetPea" - }, - - "d1": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DESP8266_WEMOS_D1MINI", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "d1" - }, - "frameworks": ["arduino"], - "name": "WeMos D1(Retired)", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.wemos.cc/wiki/doku.php?id=en:d1", - "vendor": "WeMos" - }, - - "d1_mini": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DESP8266_WEMOS_D1MINI", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "d1_mini" - }, - "frameworks": ["arduino"], - "name": "WeMos D1 R2 & mini", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.wemos.cc/wiki/doku.php?id=en:d1_mini", - "vendor": "WeMos" - }, - - "espino": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "espino" - }, - "frameworks": ["arduino"], - "name": "ESPino", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.espino.io", - "vendor": "ESPino" - }, - - "espinotee": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP13", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "espinotee" - }, - "frameworks": ["arduino"], - "name": "ThaiEasyElec ESPino", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.thaieasyelec.com/products/wireless-modules/wifi-modules/espino-wifi-development-board-detail.html", - "vendor": "ThaiEasyElec" - }, - - "esp_wroom_02": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP_WROOM_02", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "nodemcu" - }, - "frameworks": ["arduino"], - "name": "ESP-WROOM-02", - "platform": "espressif", - "upload": { - "maximum_ram_size": 51200, - "maximum_size": 4194304, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - }, - - "esp8285": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DESP8266_ESP01", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dout", - "ldscript": "esp8266.flash.1m256.ld", - "mcu": "esp8266", - "variant": "generic" - }, - "frameworks": ["arduino"], - "name": "Generic ESP8285 Module", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 434160, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - }, - - "phoenix_v1": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DESP8266_PHOENIX_V1", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "phoenix_v1" - }, - "frameworks": ["arduino"], - "name": "Phoenix 1.0", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 1044464, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - }, - - "phoenix_v2": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DESP8266_PHOENIX_V2", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "dio", - "ldscript": "esp8266.flash.4m1m.ld", - "mcu": "esp8266", - "variant": "phoenix_v2" - }, - "frameworks": ["arduino"], - "name": "Phoenix 2.0", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 1044464, - "resetmethod": "ck", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - }, - - "wifinfo": { - "build": { - "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DWIFINFO", - "f_cpu": "80000000L", - "f_flash": "40000000L", - "flash_mode": "qio", - "ldscript": "esp8266.flash.1m256.ld", - "mcu": "esp8266", - "variant": "wifinfo" - }, - "frameworks": ["arduino"], - "name": "WifInfo", - "platform": "espressif", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 434160, - "resetmethod": "nodemcu", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", - "vendor": "Espressif" - } -} diff --git a/platformio/boards/freescalekinetis.json b/platformio/boards/freescalekinetis.json deleted file mode 100644 index 869a977a..00000000 --- a/platformio/boards/freescalekinetis.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "frdm_kl25z": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0plus", - "mcu": "mkl25z128vlk4" - }, - "frameworks": ["mbed"], - "name": "Freescale Kinetis FRDM-KL25Z", - "platform": "freescalekinetis", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - }, - "url": "https://developer.mbed.org/platforms/KL25Z/", - "vendor": "Freescale" - }, - "frdm_kl46z": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0plus", - "mcu": "mkl46z256vll4" - }, - "frameworks": ["mbed"], - "name": "Freescale Kinetis FRDM-KL46Z", - "platform": "freescalekinetis", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/FRDM-KL46Z/", - "vendor": "Freescale" - }, - "frdm_k64f": { - "build": { - "f_cpu": "120000000L", - "cpu": "cortex-m4", - "mcu": "mk64fn1m0vll12" - }, - "frameworks": ["mbed"], - "name": "Freescale Kinetis FRDM-K64F", - "platform": "freescalekinetis", - "upload": { - "maximum_ram_size": 262144, - "maximum_size": 1048576 - }, - "url": "https://developer.mbed.org/platforms/FRDM-K64F/", - "vendor": "Freescale" - }, - "frdm_kl05z": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0plus", - "mcu": "mkl05z32vfm4" - }, - "frameworks": ["mbed"], - "name": "Freescale Kinetis FRDM-KL05Z", - "platform": "freescalekinetis", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/FRDM-KL05Z/", - "vendor": "Freescale" - }, - "frdm_k20d50m": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m4", - "mcu": "mk20dx128vlh5" - }, - "frameworks": ["mbed"], - "name": "Freescale Kinetis FRDM-K20D50M", - "platform": "freescalekinetis", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - }, - "url": "https://developer.mbed.org/platforms/FRDM-K20D50M/", - "vendor": "Freescale" - }, - "frdm_k22f": { - "build": { - "f_cpu": "120000000L", - "cpu": "cortex-m4", - "mcu": "mk22fn512vlh12" - }, - "frameworks": ["mbed"], - "name": "Freescale Kinetis FRDM-K22F", - "platform": "freescalekinetis", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/FRDM-K22F/", - "vendor": "Freescale" - }, - "IBMEthernetKit": { - "build": { - "f_cpu": "120000000L", - "cpu": "cortex-m4", - "mcu": "mk64fn1m0vll12" - }, - "frameworks": ["mbed"], - "name": "Ethernet IoT Starter Kit", - "platform": "freescalekinetis", - "upload": { - "maximum_ram_size": 262144, - "maximum_size": 1048576 - }, - "url": "http://developer.mbed.org/platforms/IBMEthernetKit/", - "vendor": "Freescale" - } -} \ No newline at end of file diff --git a/platformio/boards/intel.json b/platformio/boards/intel.json deleted file mode 100644 index 34950dc8..00000000 --- a/platformio/boards/intel.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "genuino101": { - "build": { - "core": "arc32", - "extra_flags": "-DARDUINO_ARCH_ARC32 -D__ARDUINO_ARC__", - "f_cpu": "32000000L", - "ldscript": "flash.ld", - "mcu": "ARCv2EM", - "cpu": "quarkse_em", - "usb_product": "Genuino 101", - "variant": "arduino_101", - "hwids": [ - ["0x8087", "0x0AB6"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino/Genuino 101", - "platform": "intel_arc32", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 155648, - "protocol": "script", - "require_upload_port" : true, - "use_1200bps_touch": true - }, - "url": "https://www.arduino.cc/en/Main/ArduinoBoard101", - "vendor": "Intel" - } -} - diff --git a/platformio/boards/lattice.json b/platformio/boards/lattice.json deleted file mode 100755 index 02e699f9..00000000 --- a/platformio/boards/lattice.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "icestick": { - "build": { - "core": "icestick", - "f_cpu": "12000000L", - "cpu": "fpga", - "mcu": "ice40hx1k", - "variant": "1k", - "hwids": [ - ["0x0403", "0x6010"] - ] - }, - "frameworks": ["icestorm"], - "name": "Lattice iCEstick FPGA Evaluation Kit", - "platform": "lattice_ice40", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 32768 - }, - "url": "http://www.latticesemi.com/icestick", - "vendor": "Lattice" - }, - - "icezum": { - "build": { - "core": "icezum", - "f_cpu": "12000000L", - "cpu": "fpga", - "mcu": "ice40hx1k", - "variant": "1k", - "hwids": [ - ["0x0403", "0x6010"] - ] - }, - "frameworks": ["icestorm"], - "name": "BQ IceZUM Alhambra FPGA", - "platform": "lattice_ice40", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 32768 - }, - "url": "https://github.com/bqlabs/icezum/wiki", - "vendor": "BQ" - } -} diff --git a/platformio/boards/microchippic32.json b/platformio/boards/microchippic32.json deleted file mode 100644 index 0b569c03..00000000 --- a/platformio/boards/microchippic32.json +++ /dev/null @@ -1,576 +0,0 @@ -{ - "cerebot32mx4": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CEREBOT_32MX4_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX460F512.ld", - "mcu": "32MX460F512L", - "variant": "Cerebot_32MX4" - }, - "frameworks": ["arduino"], - "name": "Digilent Cerebot 32MX4", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/cerebot-32mx4-limited-time-see-chipkit-pro-mx4/", - "vendor": "Digilent" - }, - - "cerebot32mx7": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CEREBOT_32MX7_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512L", - "variant": "Cerebot_32MX7" - }, - "frameworks": ["arduino"], - "name": "Digilent Cerebot 32MX7", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=TDGL004", - "vendor": "Digilent" - }, - - "chipkit_mx3": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CEREBOT_MX3CK_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX320F128.ld", - "mcu": "32MX320F128H", - "variant": "Cerebot_MX3cK" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT MX3", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 126976, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-mx3-microcontroller-board-with-pmod-headers/", - "vendor": "Digilent" - }, - - "chipkit_pro_mx4": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CEREBOT_MX4CK_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX460F512.ld", - "mcu": "32MX460F512L", - "variant": "Cerebot_MX4cK" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT Pro MX4", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-pro-mx4-embedded-systems-trainer-board/", - "vendor": "Digilent" - }, - - "chipkit_pro_mx7": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CEREBOT_MX7CK_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512L", - "variant": "Cerebot_MX7cK" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT Pro MX7", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-pro-mx7-advanced-peripherals-embedded-systems-trainer-board/", - "vendor": "Digilent" - }, - - "chipkit_pi": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CHIPKIT_PI_", - "f_cpu": "40000000L", - "ldscript": "chipKIT-application-32MX250F128.ld", - "mcu": "32MX250F128B", - "variant": "ChipKIT_Pi" - }, - "frameworks": ["arduino"], - "name": "Element14 chipKIT Pi", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 122880, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.element14.com/community/community/knode/dev_platforms_kits/element14_dev_kits/microchip-chipkit/chipkit_pi", - "vendor": "element14" - }, - - "chipkit_cmod": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CMOD_", - "f_cpu": "40000000L", - "ldscript": "chipKIT-application-32MX150F128.ld", - "mcu": "32MX150F128D", - "variant": "Cmod" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT Cmod", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 126976, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-cmod-breadboardable-mz-microcontroller-board/", - "vendor": "Digilent" - }, - - "cui32stem": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_CUI32_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512H", - "variant": "CUI32stem" - }, - "frameworks": ["arduino"], - "name": "SeeedStudio CUI32stem", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.seeedstudio.com/wiki/CUI32Stem", - "vendor": "SeeedStudio" - }, - - "ubw32_mx460": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_UBW32_MX460_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX460F512.ld", - "mcu": "32MX460F512L", - "variant": "Default_100" - }, - "frameworks": ["arduino"], - "name": "UBW32 MX460", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.schmalzhaus.com/UBW32/", - "vendor": "UBW32" - }, - - "ubw32_mx795": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_UBW32_MX795_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512L", - "variant": "Default_100" - }, - "frameworks": ["arduino"], - "name": "UBW32 MX795", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.schmalzhaus.com/UBW32/", - "vendor": "UBW32" - }, - - "usbono_pic32": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_PONTECH_UAV100_ -D_USE_USB_FOR_SERIAL_ -Danything=1", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX440F512.ld", - "mcu": "32MX440F512H", - "variant": "PONTECH_UAV100" - }, - "frameworks": ["arduino"], - "name": "PONTECH UAV100", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.pontech.com/productdisplay/uav100", - "vendor": "PONTECH" - }, - - "chipkit_dp32": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_DP32_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "40000000L", - "ldscript": "chipKIT-application-32MX250F128.ld", - "mcu": "32MX250F128B", - "variant": "DP32" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT DP32", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 122880, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-dp32-dip-package-prototyping-microcontroller-board/", - "vendor": "Digilent" - }, - - "fubarino_mini": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_FUBARINO_MINI_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "48000000L", - "ldscript": "chipKIT-application-32MX250F128.ld", - "mcu": "32MX250F128D", - "variant": "Fubarino_Mini" - }, - "frameworks": ["arduino"], - "name": "Fubarino Mini", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 122880, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://fubarino.org/mini/", - "vendor": "Fubarino" - }, - - "fubarino_sd": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_FUBARINO_SD_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512H", - "variant": "Fubarino_SD" - }, - "frameworks": ["arduino"], - "name": "Fubarino SD (1.5)", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://fubarino.org/sd/index.html", - "vendor": "Fubarino" - }, - - "mega_pic32": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_MEGA_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512L", - "variant": "Max32" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT MAX32", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-max32-microcontroller-board-with-mega-r3-headers/", - "vendor": "Digilent" - }, - - "pinguino32": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_OLIMEX_PIC32_PINGUINO_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX440F256.ld", - "mcu": "32MX440F256H", - "variant": "Olimex_PIC32_Pinguino" - }, - "frameworks": ["arduino"], - "name": "Olimex PIC32-PINGUINO", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 258048, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.olimex.com/Products/Duino/PIC32/PIC32-PINGUINO/open-source-hardware", - "vendor": "Olimex" - }, - - "picadillo_35t": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_PICADILLO_35T_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512L", - "variant": "picadillo_35t" - }, - "frameworks": ["arduino"], - "name": "4DSystems PICadillo 35T", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://www.4dsystems.com.au/product/Picadillo_35T/", - "vendor": "4DSystems" - }, - - "quick240_usb": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_PONTECH_QUICK240_USB_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX795F512.ld", - "mcu": "32MX795F512L", - "variant": "quicK240" - }, - "frameworks": ["arduino"], - "name": "PONTECH quicK240", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://quick240.com/quicki/", - "vendor": "PONTECH" - }, - - "chipkit_uc32": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_UC32_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX340F512.ld", - "mcu": "32MX340F512H", - "variant": "uC32" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT uC32", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-uc32-basic-microcontroller-board-with-uno-r3-headers/", - "vendor": "Digilent" - }, - - "uno_pic32": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_UNO_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX320F128.ld", - "mcu": "32MX320F128H", - "variant": "Uno32" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT UNO32", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 126976, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-uno32-basic-microcontroller-board-retired-see-chipkit-uc32/", - "vendor": "Digilent" - }, - - "chipkit_wf32": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_WF32_", - "f_cpu": "80000000L", - "ldscript": "chipKIT-application-32MX695F512.ld", - "mcu": "32MX695F512L", - "variant": "WF32" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT WF32", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-wf32-wifi-enabled-microntroller-board-with-uno-r3-headers/", - "vendor": "Digilent" - }, - - "chipkit_wifire": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_WIFIRE_", - "f_cpu": "200000000L", - "ldscript": "MZ-application-32MZ2048ECX.ld", - "mcu": "32MZ2048ECG100", - "variant": "WiFire" - }, - "frameworks": ["arduino"], - "name": "Digilent chipKIT WiFire", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 524288, - "maximum_size": 2080768, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/chipkit-wi-fire-wifi-enabled-mz-microcontroller-board/", - "vendor": "Digilent" - }, - - "openscope": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_OPENSCOPE_", - "f_cpu": "200000000L", - "ldscript": "OpenScope.ld", - "mcu": "32MZ2048EFG124", - "variant": "OpenScope" - }, - "frameworks": ["arduino"], - "name": "Digilent OpenScope", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 524288, - "maximum_size": 2080768, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://store.digilentinc.com/", - "vendor": "Digilent" - }, - - "openbci": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_DP32_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "40000000L", - "ldscript": "chipKIT-application-32MX250F128.ld", - "mcu": "32MX250F128B", - "variant": "OpenBCI" - }, - "frameworks": ["arduino"], - "name": "OpenBCI 32bit", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 122880, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://shop.openbci.com/", - "vendor": "OpenBCI" - }, - - "lenny": { - "build": { - "core": "pic32", - "extra_flags": "-D_BOARD_LENNY_ -D_USE_USB_FOR_SERIAL_", - "f_cpu": "40000000L", - "ldscript": "chipKIT-application-32MX270F256.ld", - "mcu": "32MX270F256D", - "variant": "Lenny" - }, - "frameworks": ["arduino"], - "name": "chipKIT Lenny", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 122880, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://chipkit.net/tag/lenny/", - "vendor": "chipKIT" - } -} diff --git a/platformio/boards/microduino.json b/platformio/boards/microduino.json deleted file mode 100644 index 1a0aa341..00000000 --- a/platformio/boards/microduino.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "1284p16m": { - "build": { - "board": "AVR_MICRODUINO_CORE_PLUS", - "core": "arduino", - "f_cpu": "16000000L", - "mcu": "atmega1284p", - "variant": "plus" - }, - "frameworks": ["arduino"], - "name": "Microduino Core+ (ATmega1284P@16M,5V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 130048, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core%2B", - "vendor": "Microduino" - }, - "1284p8m": { - "build": { - "board": "AVR_MICRODUINO_CORE_PLUS", - "core": "arduino", - "f_cpu": "8000000L", - "mcu": "atmega1284p", - "variant": "plus" - }, - "frameworks": ["arduino"], - "name": "Microduino Core+ (ATmega1284P@8M,3.3V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 130048, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core%2B", - "vendor": "Microduino" - }, - "168pa16m": { - "build": { - "board": "AVR_MICRODUINO_CORE", - "core": "arduino", - "f_cpu": "16000000L", - "mcu": "atmega168p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Microduino Core (Atmega168PA@16M,5V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 15872, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core", - "vendor": "Microduino" - }, - "168pa8m": { - "build": { - "board": "AVR_MICRODUINO_CORE", - "core": "arduino", - "f_cpu": "8000000L", - "mcu": "atmega168p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Microduino Core (Atmega168PA@8M,3.3V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 15872, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core", - "vendor": "Microduino" - }, - "328p16m": { - "build": { - "board": "AVR_MICRODUINO_CORE", - "core": "arduino", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Microduino Core (Atmega328P@16M,5V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core", - "vendor": "Microduino" - }, - "328p8m": { - "build": { - "board": "AVR_MICRODUINO_CORE", - "core": "arduino", - "f_cpu": "8000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "Microduino Core (Atmega328P@8M,3.3V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "require_upload_port" : true, - "protocol": "arduino", - "speed": 57600 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core", - "vendor": "Microduino" - }, - "32u416m": { - "build": { - "board": "AVR_MICRODUINO_CORE_USB", - "core": "arduino", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "variant": "32u4", - "hwids": [ - ["0x2341", "0x8036"] - ] - }, - "frameworks": ["arduino"], - "name": "Microduino Core USB (ATmega32U4@16M,5V)", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-CoreUSB", - "vendor": "Microduino" - }, - "644pa16m": { - "build": { - "board": "AVR_MICRODUINO_CORE_PLUS", - "core": "arduino", - "f_cpu": "16000000L", - "mcu": "atmega644p", - "variant": "plus" - }, - "frameworks": ["arduino"], - "name": "Microduino Core+ (Atmega644PA@16M,5V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 64512, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core%2B", - "vendor": "Microduino" - }, - "644pa8m": { - "build": { - "board": "AVR_MICRODUINO_CORE_PLUS", - "core": "arduino", - "f_cpu": "8000000L", - "mcu": "atmega644p", - "variant": "plus" - }, - "frameworks": ["arduino"], - "name": "Microduino Core+ (Atmega644PA@8M,3.3V)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 64512, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://www.microduino.cc/wiki/index.php?title=Microduino-Core%2B", - "vendor": "Microduino" - } -} \ No newline at end of file diff --git a/platformio/boards/mightycore.json b/platformio/boards/mightycore.json deleted file mode 100644 index 7ee7913f..00000000 --- a/platformio/boards/mightycore.json +++ /dev/null @@ -1,155 +0,0 @@ -{ - "mightycore1284": { - "build": { - "core": "MightyCore", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega1284", - "f_cpu": "16000000L", - "mcu": "atmega1284p", - "variant": "mightycore" - }, - "frameworks": ["arduino"], - "name": "MightyCore ATmega1284", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 130048, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board", - "vendor": "Mcudude" - }, - - "mightycore644": { - "build": { - "core": "MightyCore", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega644", - "f_cpu": "16000000L", - "mcu": "atmega644p", - "variant": "mightycore" - }, - "frameworks": ["arduino"], - "name": "MightyCore ATmega644", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 64512, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board", - "vendor": "Mcudude" - }, - - "mightycore324": { - "build": { - "core": "MightyCore", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega324", - "f_cpu": "16000000L", - "mcu": "atmega324p", - "variant": "mightycore" - }, - "frameworks": ["arduino"], - "name": "MightyCore ATmega324", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board", - "vendor": "Mcudude" - }, - - "mightycore164": { - "build": { - "core": "MightyCore", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega164", - "f_cpu": "16000000L", - "mcu": "atmega164p", - "variant": "mightycore" - }, - "frameworks": ["arduino"], - "name": "MightyCore ATmega164", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 15872, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board", - "vendor": "Mcudude" - }, - - "mightycore32": { - "build": { - "core": "MightyCore", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega32", - "f_cpu": "16000000L", - "mcu": "atmega32", - "variant": "mightycore" - }, - "frameworks": ["arduino"], - "name": "MightyCore ATmega32", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board", - "vendor": "Mcudude" - }, - - "mightycore16": { - "build": { - "core": "MightyCore", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega16", - "f_cpu": "16000000L", - "mcu": "atmega16", - "variant": "mightycore" - }, - "frameworks": ["arduino"], - "name": "MightyCore ATmega16", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 15872, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board", - "vendor": "Mcudude" - }, - - "mightycore8535": { - "build": { - "core": "MightyCore", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATmega8535", - "f_cpu": "16000000L", - "mcu": "atmega16", - "variant": "mightycore" - }, - "frameworks": ["arduino"], - "name": "MightyCore ATmega8535", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 7680, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.tindie.com/products/MCUdude/dip-40-arduino-compatible-development-board", - "vendor": "Mcudude" - } -} diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json deleted file mode 100644 index 0a9be48e..00000000 --- a/platformio/boards/misc.json +++ /dev/null @@ -1,846 +0,0 @@ -{ - "ardhat": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_ARDHAT", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "ubIQio Ardhat", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://ardhat.com", - "vendor": "ubIQio" - }, - - "raspduino": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_RASPDUINO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "BitWizard Raspduino", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://www.bitwizard.nl/wiki/index.php/Raspduino", - "vendor": "BitWizard" - }, - - "emonpi": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_EMONPI", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "OpenEnergyMonitor emonPi", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://github.com/openenergymonitor/emonpi", - "vendor": "OpenEnergyMonitor" - }, - - "sainSmartDue": { - "build": { - "core": "arduino", - "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM", - "f_cpu": "84000000L", - "mcu": "at91sam3x8e", - "cpu": "cortex-m3", - "usb_product": "Arduino Due", - "variant": "arduino_due_x", - "ldscript": "sam3x8e.ld", - "hwids": [ - ["0x2341", "0x003E"] - ] - }, - "frameworks": ["arduino"], - "name": "SainSmart Due (Programming Port)", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 524288, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": false - }, - "url": "http://www.sainsmart.com/arduino/control-boards/sainsmart-due-atmel-sam3x8e-arm-cortex-m3-board-black.html", - "vendor": "SainSmart" - }, - "sainSmartDueUSB": { - "build": { - "core": "arduino", - "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM", - "f_cpu": "84000000L", - "mcu": "at91sam3x8e", - "cpu": "cortex-m3", - "usb_product": "Arduino Due", - "variant": "arduino_due_x", - "ldscript": "sam3x8e.ld", - "hwids": [ - ["0x2341", "0x003E"] - ] - }, - "frameworks": ["arduino"], - "name": "SainSmart Due (USB Native Port)", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 524288, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://www.sainsmart.com/arduino/control-boards/sainsmart-due-atmel-sam3x8e-arm-cortex-m3-board-black.html", - "vendor": "SainSmart" - }, - - "panStampAVR": { - "build": { - "core": "panstamp", - "extra_flags": "-DPANSTAMP_AVR", - "f_cpu": "8000000L", - "mcu": "atmega328p", - "variant": "panstamp" - }, - "frameworks": ["arduino"], - "name": "PanStamp AVR", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "http://www.panstamp.com/product/panstamp-avr/", - "vendor": "PanStamp" - }, - - "panStampNRG": { - "build": { - "core": "panstamp", - "f_cpu": "12000000L", - "mcu": "cc430f5137", - "variant": "panstamp_nrg_1.1" - }, - "frameworks": ["arduino"], - "name": "PanStamp NRG 1.1", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 32640, - "protocol": "flash-bsl" - }, - "url": "http://www.panstamp.com/product/197/", - "vendor": "PanStamp" - }, - "reprap_rambo": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_RAMBO", - "f_cpu": "16000000L", - "mcu": "atmega2560", - "variant": "rambo" - }, - "frameworks": ["arduino"], - "name": "RepRap RAMBo", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 258048, - "protocol": "wiring", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://reprap.org/wiki/Rambo", - "vendor": "RepRap" - }, - - "sanguino_atmega1284p": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_SANGUINO", - "f_cpu": "16000000L", - "mcu": "atmega1284p", - "variant": "sanguino" - }, - "frameworks": ["arduino"], - "name": "Sanguino ATmega1284p (16MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 130048, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://code.google.com/p/sanguino/", - "vendor": "Sanguino" - }, - - "sanguino_atmega1284_8m": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_SANGUINO", - "f_cpu": "8000000L", - "mcu": "atmega1284p", - "variant": "sanguino" - }, - "frameworks": ["arduino"], - "name": "Sanguino ATmega1284p (8MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 130048, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://code.google.com/p/sanguino/", - "vendor": "Sanguino" - }, - - "sanguino_atmega644": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_SANGUINO", - "f_cpu": "16000000L", - "mcu": "atmega644", - "variant": "sanguino" - }, - "frameworks": ["arduino"], - "name": "Sanguino ATmega644 or ATmega644A (16 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 64512, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://code.google.com/p/sanguino/", - "vendor": "Sanguino" - }, - - "sanguino_atmega644_8m": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_SANGUINO", - "f_cpu": "8000000L", - "mcu": "atmega644", - "variant": "sanguino" - }, - "frameworks": ["arduino"], - "name": "Sanguino ATmega644 or ATmega644A (8 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 64512, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://code.google.com/p/sanguino/", - "vendor": "Sanguino" - }, - - "sanguino_atmega644p": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_SANGUINO", - "f_cpu": "16000000L", - "mcu": "atmega644p", - "variant": "sanguino" - }, - "frameworks": ["arduino"], - "name": "Sanguino ATmega644P or ATmega644PA (16 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 64512, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://code.google.com/p/sanguino/", - "vendor": "Sanguino" - }, - - "sanguino_atmega644p_8m": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_SANGUINO", - "f_cpu": "8000000L", - "mcu": "atmega644p", - "variant": "sanguino" - }, - "frameworks": ["arduino"], - "name": "Sanguino ATmega644P or ATmega644PA (8 MHz)", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 64512, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://code.google.com/p/sanguino/", - "vendor": "Sanguino" - }, - - "tinyduino": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LILYPAD", - "f_cpu": "8000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "TinyCircuits TinyDuino Processor Board", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://tiny-circuits.com/tinyduino-processor-board.html", - "vendor": "TinyCircuits" - }, - - "blend": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "RedBearLab Blend", - "variant": "leonardo", - "hwids": [ - ["0x2341", "0x8036"] - ] - }, - "frameworks": ["arduino"], - "name": "RedBearLab Blend", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://redbearlab.com/blend/", - "vendor": "RedBearLab" - }, - - "blendmicro8": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "RedBearLab Blend", - "variant": "micro", - "hwids": [ - ["0x03EB", "0x2404"] - ] - }, - "frameworks": ["arduino"], - "name": "RedBearLab Blend Micro 3.3V/8MHz", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://redbearlab.com/blendmicro/", - "vendor": "RedBearLab" - }, - - "blendmicro16": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "RedBearLab Blend", - "variant": "micro", - "hwids": [ - ["0x03EB", "0x2404"] - ] - }, - "frameworks": ["arduino"], - "name": "RedBearLab Blend Micro 3.3V/16MHz (overclock)", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "http://redbearlab.com/blendmicro/", - "vendor": "RedBearLab" - }, - - "tinylily": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LILYPAD", - "f_cpu": "8000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "TinyCircuits TinyLily Mini Processor", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 30720, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 57600 - }, - "url": "https://tiny-circuits.com/tiny-lily-mini-processor.html", - "vendor": "TinyCircuits" - }, - - "lightup": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_LEONARDO", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "LightUp", - "variant": "leonardo", - "hwids": [ - ["0x1d50", "0x6096"] - ] - }, - "frameworks": ["arduino"], - "name": "LightUp", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.lightup.io/", - "vendor": "LightUp" - }, - - "moteino": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_MOTEINO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "LowPowerLab Moteino", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 31744, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://lowpowerlab.com/shop/moteino-r4", - "vendor": "LowPowerLab" - }, - - "moteinomega": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_MOTEINOMEGA", - "f_cpu": "16000000L", - "mcu": "atmega1284p", - "variant": "moteinomega" - }, - "frameworks": ["arduino"], - "name": "LowPowerLab MoteinoMEGA", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 130048, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "http://lowpowerlab.com/blog/2014/08/09/moteinomega-available-now/", - "vendor": "LowPowerLab" - }, - - "zumbt328": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_BT", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "eightanaloginputs" - }, - "frameworks": ["arduino"], - "name": "BQ ZUM BT-328", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2048, - "maximum_size": 28672, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://www.bq.com/gb/products/zum.html", - "vendor": "BQ" - }, - - "quirkbot": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DQUIRKBOT", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "variant" : "quirkbot", - "usb_product": "Quirkbot", - "hwids": [ - ["0x2886", "0xf004"], - ["0x2886", "0xf005"], - ["0x2886", "0xf006"], - ["0x2886", "0xf007"] - ] - }, - "frameworks": ["arduino"], - "name": "Quirkbot", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "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" - }, - - "attiny13": { - "build": { - "core": "core13", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATTINY13", - "f_cpu": "9600000L", - "mcu": "attiny13" - }, - "frameworks": ["arduino"], - "name": "Generic ATTiny13", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 64, - "maximum_size": 1024, - "protocol": "arduinoisp", - "require_upload_port" : true, - "speed": 19200 - }, - "url": "http://www.atmel.com/devices/ATTINY13.aspx", - "vendor": "Generic ATTiny" - }, - - "attiny24": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATTINY24", - "f_cpu": "8000000L", - "mcu": "attiny24", - "variant": "tiny14" - }, - "frameworks": ["arduino"], - "name": "Generic ATTiny24", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 128, - "maximum_size": 2048, - "protocol": "usbtiny" - }, - "url": "http://www.atmel.com/devices/ATTINY24.aspx", - "vendor": "Generic ATTiny" - }, - - "attiny25": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATTINY25", - "f_cpu": "8000000L", - "mcu": "attiny25", - "variant": "tiny8" - }, - "frameworks": ["arduino"], - "name": "Generic ATTiny25", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 128, - "maximum_size": 2048, - "protocol": "usbtiny" - }, - "url": "http://www.atmel.com/devices/ATTINY25.aspx", - "vendor": "Generic ATTiny" - }, - - "attiny44": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATTINY44", - "f_cpu": "8000000L", - "mcu": "attiny44", - "variant": "tiny14" - }, - "frameworks": ["arduino"], - "name": "Generic ATTiny44", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 256, - "maximum_size": 4096, - "protocol": "usbtiny" - }, - "url": "http://www.atmel.com/devices/ATTINY44.aspx", - "vendor": "Generic ATTiny" - }, - - "attiny45": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATTINY45", - "f_cpu": "8000000L", - "mcu": "attiny45", - "variant": "tiny8" - }, - "frameworks": ["arduino"], - "name": "Generic ATTiny45", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 256, - "maximum_size": 4096, - "protocol": "usbtiny" - }, - "url": "http://www.atmel.com/devices/ATTINY45.aspx", - "vendor": "Generic ATTiny" - }, - - "attiny84": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATTINY84", - "f_cpu": "8000000L", - "mcu": "attiny84", - "variant": "tiny14" - }, - "frameworks": ["arduino"], - "name": "Generic ATTiny84", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 8192, - "protocol": "usbtiny" - }, - "url": "http://www.atmel.com/devices/ATTINY84.aspx", - "vendor": "Generic ATTiny" - }, - - "attiny85": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ATTINY85", - "f_cpu": "8000000L", - "mcu": "attiny85", - "variant": "tiny8" - }, - "frameworks": ["arduino"], - "name": "Generic ATTiny85", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 8192, - "protocol": "usbtiny" - }, - "url": "http://www.atmel.com/devices/ATTINY85.aspx", - "vendor": "Generic ATTiny" - }, - - "arduboy": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ARDUBOY -DARDUBOY_10", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduboy", - "variant": "leonardo", - "hwids": [ - ["0x2341", "0x0036"], - ["0x2341", "0x8036"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduboy", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.arduboy.com", - "vendor": "Arduboy" - }, - - "arduboy_devkit": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ARDUBOY_DEVKIT -DAB_DEVKIT", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "Arduboy DevKit", - "variant": "leonardo", - "hwids": [ - ["0x2341", "0x0036"], - ["0x2341", "0x8036"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduboy DevKit", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.arduboy.com", - "vendor": "Arduboy" - }, - - "pinoccio": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_PINOCCIO -D__PROG_TYPES_COMPAT__", - "f_cpu": "16000000L", - "mcu": "atmega256rfr2", - "variant": "pinoccio" - }, - "frameworks": ["arduino"], - "name": "Pinoccio Scout", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 253952, - "protocol": "wiring", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.crowdsupply.com/pinoccio/mesh-sensor-network", - "vendor": "Pinoccio" - } -} diff --git a/platformio/boards/nordicnrf51.json b/platformio/boards/nordicnrf51.json deleted file mode 100644 index 1a80b2fd..00000000 --- a/platformio/boards/nordicnrf51.json +++ /dev/null @@ -1,182 +0,0 @@ -{ - "nrf51_mkit": { - "build": { - "f_cpu": "16000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "Nordic nRF51822-mKIT", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - }, - "url": "http://developer.mbed.org/platforms/Nordic-nRF51822/", - "vendor": "Nordic" - }, - "hrm1017": { - "build": { - "f_cpu": "16000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "Switch Science mbed HRM1017", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/mbed-HRM1017/", - "vendor": "Switch Science" - }, - "redBearLab": { - "build": { - "f_cpu": "16000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "RedBearLab nRF51822", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/RedBearLab-nRF51822/", - "vendor": "RedBearLab" - }, - "nrf51_dk": { - "build": { - "f_cpu": "32000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "Nordic nRF51-DK", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/Nordic-nRF51-DK/", - "vendor": "Nordic" - }, - "redBearLabBLENano": { - "build": { - "f_cpu": "16000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "RedBearLab BLE Nano", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/RedBearLab-BLE-Nano/", - "vendor": "RedBearLab" - }, - "nrf51_dongle": { - "build": { - "f_cpu": "32000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "Nordic nRF51-Dongle", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/Nordic-nRF51-Dongle/", - "vendor": "Nordic" - }, - "wallBotBLE": { - "build": { - "f_cpu": "16000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "JKSoft Wallbot BLE", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - }, - "url": "https://developer.mbed.org/platforms/JKSoft-Wallbot-BLE/", - "vendor": "JKSoft" - }, - "seeedTinyBLE": { - "build": { - "f_cpu": "16000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "SeeedStudio Seeed Tiny BLE", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 262144 - }, - "url": "http://developer.mbed.org/platforms/Seeed-Tiny-BLE/", - "vendor": "SeeedStudio" - }, - "dfcm_nnn40": { - "build": { - "f_cpu": "32000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "Delta DFCM-NNN40", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/Delta-DFCM-NNN40/", - "vendor": "Delta" - }, - "rfduino": { - "build": { - "core": "arduino", - "extra_flags": "-D__RFduino__", - "f_cpu": "16000000L", - "ldscript": "RFduino.ld", - "cpu": "cortex-m0", - "mcu": "nrf51822", - "variant": "RFduino" - }, - "frameworks": ["arduino"], - "name": "RFduino", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 131072 - }, - "url": "http://www.rfduino.com/product/rfd22102-rfduino-dip/index.html", - "vendor": "RFduino" - }, - "bbcmicrobit": { - "build": { - "f_cpu": "16000000L", - "cpu": "cortex-m0", - "mcu": "nrf51822" - }, - "frameworks": ["mbed"], - "name": "BBC micro:bit", - "platform": "nordicnrf51", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/Microbit/", - "vendor": "BBC" - } -} diff --git a/platformio/boards/nxplpc.json b/platformio/boards/nxplpc.json deleted file mode 100644 index de29b022..00000000 --- a/platformio/boards/nxplpc.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "lpc1768": { - "build": { - "f_cpu": "96000000L", - "cpu": "cortex-m3", - "mcu": "lpc1768" - }, - "frameworks": ["mbed"], - "name": "NXP mbed LPC1768", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 65536, - "maximum_size": 524288 - }, - "url": "http://developer.mbed.org/platforms/mbed-LPC1768/", - "vendor": "NXP" - }, - "lpc11u24": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "lpc11u24" - }, - "frameworks": ["mbed"], - "name": "NXP mbed LPC11U24", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/mbed-LPC11U24/", - "vendor": "NXP" - }, - "lpc4088": { - "build": { - "f_cpu": "120000000L", - "cpu": "cortex-m4", - "mcu": "lpc4088" - }, - "frameworks": ["mbed"], - "name": "Embedded Artists LPC4088 QuickStart Board", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 98304, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/EA-LPC4088/", - "vendor": "Embedded Artists" - }, - "dipcortexm0": { - "build": { - "f_cpu": "50000000L", - "cpu": "cortex-m0", - "mcu": "lpc11u24" - }, - "frameworks": ["mbed"], - "name": "Solder Splash Labs DipCortex M0", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/DipCortex-M0/", - "vendor": "Solder Splash Labs" - }, - "blueboard_lpc11u24": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "lpc11u24" - }, - "frameworks": ["mbed"], - "name": "NGX Technologies BlueBoard-LPC11U24", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/BlueBoard-LPC11U24/", - "vendor": "NGX Technologies" - }, - "seeeduinoArchPro": { - "build": { - "f_cpu": "96000000L", - "cpu": "cortex-m3", - "mcu": "lpc1768" - }, - "frameworks": ["mbed"], - "name": "SeeedStudio Seeeduino-Arch-Pro", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 65536, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/Seeeduino-Arch-Pro/", - "vendor": "SeeedStudio" - }, - "ubloxc027": { - "build": { - "f_cpu": "96000000L", - "cpu": "cortex-m3", - "mcu": "lpc1768" - }, - "frameworks": ["mbed"], - "name": "u-blox C027", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 65536, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/u-blox-C027/", - "vendor": "u-blox" - }, - "lpc1114fn28": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "lpc1114fn28" - }, - "frameworks": ["mbed"], - "name": "Switch Science mbed LPC1114FN28", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/LPC1114FN28/", - "vendor": "Switch Science" - }, - "lpc11u35": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "lpc11u35" - }, - "frameworks": ["mbed"], - "name": "Embedded Artists LPC11U35 QuickStart Board", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 10240, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/EA-LPC11U35/", - "vendor": "Embedded Artists" - }, - "lpc11u35_501": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "lpc11u35" - }, - "frameworks": ["mbed"], - "name": "CQ Publishing TG-LPC11U35-501", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 10240, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/TG-LPC11U35-501/", - "vendor": "CQ Publishing" - }, - "lpc1549": { - "build": { - "f_cpu": "72000000L", - "cpu": "cortex-m3", - "mcu": "lpc1549" - }, - "frameworks": ["mbed"], - "name": "NXP LPCXpresso1549", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 36864, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/LPCXpresso1549/", - "vendor": "NXP" - }, - "mbuino": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "lpc11u24" - }, - "frameworks": ["mbed"], - "name": "Outrageous Circuits mBuino", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/Outrageous-Circuits-mBuino/", - "vendor": "Outrageous Circuits" - }, - "lpc4088_dm": { - "build": { - "f_cpu": "120000000L", - "cpu": "cortex-m4", - "mcu": "lpc4088" - }, - "frameworks": ["mbed"], - "name": "Embedded Artists LPC4088 Display Module", - "platform": "nxplpc", - "upload": { - "maximum_ram_size": 98304, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/EA-LPC4088-Display-Module/", - "vendor": "Embedded Artists" - } -} \ No newline at end of file diff --git a/platformio/boards/punchthrough.json b/platformio/boards/punchthrough.json deleted file mode 100644 index 6e7d41ed..00000000 --- a/platformio/boards/punchthrough.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "lightblue-bean": { - "name": "LightBlue Bean", - "vendor": "Punch Through", - "url": "https://punchthrough.com/bean", - - "platform": "atmelavr", - "frameworks": ["arduino"], - - "build": { - "core": "bean", - "variant": "bean", - "extra_flags": "-DARDUINO_ARCH_AVR", - "mcu": "atmega328p", - "f_cpu": "8000000L" - }, - "upload": { - "maximum_size": 32256, - "maximum_ram_size": 2048 - } - } -} diff --git a/platformio/boards/raspberrypi.json b/platformio/boards/raspberrypi.json deleted file mode 100644 index 25c3485a..00000000 --- a/platformio/boards/raspberrypi.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "raspberrypi_1b": { - "build": { - "extra_flags": "-DRASPBERRYPI -DRASPBERRYPI1", - "f_cpu": "700000000L", - "mcu": "bcm2835" - }, - "frameworks": ["wiringpi"], - "name": "Raspberry Pi 1 Model B", - "platform": "linux_arm", - "upload": { - "maximum_ram_size": 536870912, - "maximum_size": 536870912 - }, - "url": "https://www.raspberrypi.org", - "vendor": "Raspberry Pi" - }, - - "raspberrypi_2b": { - "build": { - "extra_flags": "-DRASPBERRYPI -DRASPBERRYPI2", - "f_cpu": "900000000L", - "mcu": "bcm2836" - }, - "frameworks": ["wiringpi"], - "name": "Raspberry Pi 2 Model B", - "platform": "linux_arm", - "upload": { - "maximum_ram_size": 1073741824, - "maximum_size": 1073741824 - }, - "url": "https://www.raspberrypi.org", - "vendor": "Raspberry Pi" - }, - - "raspberrypi_zero": { - "build": { - "extra_flags": "-DRASPBERRYPI -DRASPBERRYPIZERO", - "f_cpu": "1000000000L", - "mcu": "bcm2835" - }, - "frameworks": ["wiringpi"], - "name": "Raspberry Pi Zero", - "platform": "linux_arm", - "upload": { - "maximum_ram_size": 536870912, - "maximum_size": 536870912 - }, - "url": "https://www.raspberrypi.org", - "vendor": "Raspberry Pi" - } -} diff --git a/platformio/boards/siliconlabsefm32.json b/platformio/boards/siliconlabsefm32.json deleted file mode 100644 index e4d55f18..00000000 --- a/platformio/boards/siliconlabsefm32.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "efm32wg_stk3800": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m4", - "mcu": "efm32wg990f256" - }, - "frameworks": ["mbed"], - "name": "Silicon Labs EFM32WG-STK3800 (Wonder Gecko)", - "platform": "siliconlabsefm32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/EFM32-Wonder-Gecko/", - "vendor": "Silicon Labs" - }, - - "efm32gg_stk3700": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m3", - "mcu": "efm32gg990f1024" - }, - "frameworks": ["mbed"], - "name": "Silicon Labs EFM32GG-STK3700 (Giant Gecko)", - "platform": "siliconlabsefm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 1048576 - }, - "url": "https://developer.mbed.org/platforms/EFM32-Giant-Gecko/", - "vendor": "Silicon Labs" - }, - - "efm32lg_stk3600": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m3", - "mcu": "efm32lg990f256" - }, - "frameworks": ["mbed"], - "name": "Silicon Labs EFM32LG-STK3600 (Leopard Gecko)", - "platform": "siliconlabsefm32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/EFM32-Leopard-Gecko/", - "vendor": "Silicon Labs" - }, - - "efm32zg_stk3200": { - "build": { - "f_cpu": "24000000L", - "cpu": "cortex-m0plus", - "mcu": "efm2zg222f32" - }, - "frameworks": ["mbed"], - "name": "Silicon Labs EFM32ZG-STK3200 (Zero Gecko)", - "platform": "siliconlabsefm32", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/EFM32-Zero-Gecko/", - "vendor": "Silicon Labs" - }, - - "efm32hg_stk3400": { - "build": { - "f_cpu": "24000000L", - "cpu": "cortex-m3", - "mcu": "efm32hg322f64" - }, - "frameworks": ["mbed"], - "name": "Silicon Labs SLSTK3400A USB-enabled (Happy Gecko)", - "platform": "siliconlabsefm32", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/EFM32-Happy-Gecko/", - "vendor": "Silicon Labs" - }, - - "efm32pg_stk3401": { - "build": { - "f_cpu": "40000000L", - "cpu": "cortex-m4", - "mcu": "efm32pg1b200f256" - }, - "frameworks": ["mbed"], - "name": "Silicon Labs SLSTK3401A (Pearl Gecko)", - "platform": "siliconlabsefm32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/EFM32-Pearl-Gecko/", - "vendor": "Silicon Labs" - } -} diff --git a/platformio/boards/sparkfun.json b/platformio/boards/sparkfun.json deleted file mode 100644 index b14a9ab9..00000000 --- a/platformio/boards/sparkfun.json +++ /dev/null @@ -1,304 +0,0 @@ - { - "sparkfun_redboard": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "SparkFun RedBoard", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.sparkfun.com/products/12757", - "vendor": "SparkFun" - }, - "sparkfun_promicro16": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_PROMICRO16", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "SparkFun Pro Micro", - "variant": "sparkfun_promicro", - "hwids": [ - ["0x1B4F", "0x9205"], - ["0x1B4F", "0x9206"] - ] - }, - "frameworks": ["arduino"], - "name": "SparkFun Pro Micro 5V/16MHz", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.sparkfun.com/products/12640", - "vendor": "SparkFun" - }, - "sparkfun_promicro8": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_PROMICRO8", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "SparkFun Pro Micro", - "variant": "sparkfun_promicro", - "hwids": [ - ["0x1B4F", "0x9203"], - ["0x1B4F", "0x9204"] - ] - }, - "frameworks": ["arduino"], - "name": "SparkFun Pro Micro 3.3V/8MHz", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.sparkfun.com/products/12587", - "vendor": "SparkFun" - }, - "sparkfun_fiov3": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_FIOV3", - "f_cpu": "8000000L", - "mcu": "atmega32u4", - "usb_product": "SparkFun Fio v3", - "variant": "sparkfun_promicro", - "hwids": [ - ["0x1B4F", "0xF100"], - ["0x1B4F", "0xF101"] - ] - }, - "frameworks": ["arduino"], - "name": "SparkFun Fio V3 3.3V/8MHz", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.sparkfun.com/products/11520", - "vendor": "SparkFun" - }, - "sparkfun_makeymakey": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_MAKEYMAKEY", - "f_cpu": "16000000L", - "mcu": "atmega32u4", - "usb_product": "SparkFun MaKey", - "variant": "sparkfun_promicro", - "hwids": [ - ["0x1B4F", "0x2B74"], - ["0x1B4F", "0x2B75"] - ] - }, - "frameworks": ["arduino"], - "name": "SparkFun Makey Makey", - "platform": "atmelavr", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 2560, - "maximum_size": 28672, - "protocol": "avr109", - "require_upload_port" : true, - "speed": 57600, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.sparkfun.com/products/11511", - "vendor": "SparkFun" - }, - "sparkfun_megapro16MHz": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560", - "f_cpu": "16000000L", - "mcu": "atmega2560", - "variant": "mega" - }, - "frameworks": ["arduino"], - "name": "SparkFun Mega Pro 5V/16MHz", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 258048, - "protocol": "stk500v2", - "speed": 57600 - }, - "url": "https://www.sparkfun.com/products/11007", - "vendor": "SparkFun" - }, - "sparkfun_megapro8MHz": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560", - "f_cpu": "8000000L", - "mcu": "atmega2560", - "variant": "mega" - }, - "frameworks": ["arduino"], - "name": "SparkFun Mega Pro 3.3V/8MHz", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 258048, - "protocol": "stk500v2", - "speed": 57600 - }, - "url": "https://www.sparkfun.com/products/10744", - "vendor": "SparkFun" - }, - "sparkfun_megamini": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560", - "f_cpu": "8000000L", - "mcu": "atmega2560", - "variant": "mega" - }, - "frameworks": ["arduino"], - "name": "SparkFun Mega Pro Mini 3.3V", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 258048, - "protocol": "stk500v2", - "speed": 57600 - }, - "url": "https://www.sparkfun.com/products/10743", - "vendor": "SparkFun" - }, - "sparkfun_digitalsandbox": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "SparkFun Digital Sandbox", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.sparkfun.com/products/12651", - "vendor": "SparkFun" - }, - - "uview": { - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO", - "f_cpu": "16000000L", - "mcu": "atmega328p", - "variant": "standard" - }, - "frameworks": ["arduino"], - "name": "SparkFun MicroView", - "platform": "atmelavr", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 32256, - "protocol": "arduino", - "require_upload_port" : true, - "speed": 115200 - }, - "url": "https://www.sparkfun.com/products/12923", - "vendor": "SparkFun" - }, - - "sparkfun_samd21_dev_usb": { - "build": { - "core": "arduino_zero", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "SparkFun SAMD21", - "variant": "arduino_zero", - "ldscript": "flash_with_bootloader.ld", - "hwids": [ - ["0x1B4F", "0x8D21"], - ["0x1B4F", "0x0D21"] - ] - }, - "frameworks": ["arduino"], - "name": "SparkFun SAMD21 Dev Breakout", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.sparkfun.com/products/13672", - "vendor": "SparkFun" - }, - - "sparkfun_samd21_mini_usb": { - "build": { - "core": "arduino_zero", - "extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", - "f_cpu": "48000000L", - "mcu": "samd21g18a", - "cpu": "cortex-m0plus", - "usb_product": "SparkFun SAMD21", - "variant": "SparkFun_SAMD_Mini", - "ldscript": "flash_with_bootloader.ld", - "hwids": [ - ["0x1B4F", "0x8D21"], - ["0x1B4F", "0x0D21"] - ] - }, - "frameworks": ["arduino"], - "name": "SparkFun SAMD21 Mini Breakout", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "sam-ba", - "require_upload_port" : true, - "use_1200bps_touch": true, - "wait_for_upload_port": true - }, - "url": "https://www.sparkfun.com/products/13664", - "vendor": "SparkFun" - } -} diff --git a/platformio/boards/ststm32.json b/platformio/boards/ststm32.json deleted file mode 100644 index 1366a4e4..00000000 --- a/platformio/boards/ststm32.json +++ /dev/null @@ -1,653 +0,0 @@ -{ - "disco_f407vg": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F4 -DSTM32F407xx -DSTM32F40_41xxx", - "f_cpu": "168000000L", - "ldscript": "stm32f405x6.ld", - "cpu": "cortex-m4", - "mcu": "stm32f407vgt6", - "variant": "stm32f407xx" - }, - "frameworks": ["mbed", "cmsis", "spl", "libopencm3"], - "name": "ST STM32F4DISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 1048576, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF252419", - "vendor": "ST" - }, - "disco_l152rb": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32L1 -DSTM32L152xB -DSTM32L1XX_MD", - "f_cpu": "32000000L", - "ldscript": "stm32l15xx6.ld", - "cpu": "cortex-m3", - "mcu": "stm32l152rbt6", - "variant": "stm32l152xb" - }, - "frameworks": ["cmsis", "spl", "libopencm3"], - "name": "ST STM32LDISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF258515", - "vendor": "ST" - }, - "disco_f303vc": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F3 -DSTM32F303xC", - "f_cpu": "72000000L", - "ldscript": "stm32f30xx.ld", - "cpu": "cortex-m4", - "mcu": "stm32f303vct6", - "variant": "stm32f303xc" - }, - "frameworks": ["mbed", "cmsis", "spl", "libopencm3"], - "name": "ST STM32F3DISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 49152, - "maximum_size": 262144, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF254044", - "vendor": "ST" - }, - "disco_f100rb": { - "build": { - "f_cpu": "24000000L", - "cpu": "cortex-m3", - "mcu": "stm32f100rbt6" - }, - "frameworks": ["mbed"], - "name": "ST STM32VLDISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 131072, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF250863", - "vendor": "ST" - }, - "disco_f051r8": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32f051r8t6" - }, - "frameworks": ["mbed"], - "name": "ST STM32F0DISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 65536, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF253215", - "vendor": "ST" - }, - "disco_f334c8": { - "build": { - "f_cpu": "72000000L", - "cpu": "cortex-m4", - "mcu": "stm32f334c8t6" - }, - "frameworks": ["mbed"], - "name": "ST 32F3348DISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 65536, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF260318", - "vendor": "ST" - }, - "disco_f401vc": { - "build": { - "f_cpu": "84000000L", - "cpu": "cortex-m4", - "mcu": "stm32f401vct6" - }, - "frameworks": ["mbed"], - "name": "ST 32F401CDISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 65536, - "maximum_size": 262144, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF259098", - "vendor": "ST" - }, - "disco_f429zi": { - "build": { - "f_cpu": "180000000L", - "cpu": "cortex-m4", - "mcu": "stm32f429zit6" - }, - "frameworks": ["mbed"], - "name": "ST 32F429IDISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 262144, - "maximum_size": 2097152, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1848/PF259090", - "vendor": "ST" - }, - "nucleo_f030r8": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32f030r8t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F030R8", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F030R8/", - "vendor": "ST" - }, - "nucleo_f070rb": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32f070rbt6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F070RB", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F070RB/", - "vendor": "ST" - }, - "nucleo_f072rb": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32f072rbt6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F072RB", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F072RB/", - "vendor": "ST" - }, - "nucleo_f091rc": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32f091rct6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F091RC", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F091RC/", - "vendor": "ST" - }, - "nucleo_f103rb": { - "build": { - "core": "stm32", - "f_cpu": "72000000L", - "ldscript": "stm32f103xb.ld", - "cpu": "cortex-m3", - "mcu": "stm32f103rbt6", - "variant": "stm32f1" - }, - "frameworks": ["mbed","libopencm3"], - "name": "ST Nucleo F103RB", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 20480, - "maximum_size": 131072 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F103RB/", - "vendor": "ST" - }, - "nucleo_f302r8": { - "build": { - "f_cpu": "72000000L", - "cpu": "cortex-m4", - "mcu": "stm32f302r8t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F302R8", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F302R8/", - "vendor": "ST" - }, - "nucleo_f303re": { - "build": { - "f_cpu": "72000000L", - "cpu": "cortex-m4", - "mcu": "stm32f303ret6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F303RE", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 65536, - "maximum_size": 524288 - }, - "url": "http://developer.mbed.org/platforms/ST-Nucleo-F303RE/", - "vendor": "ST" - }, - "nucleo_f334r8": { - "build": { - "f_cpu": "72000000L", - "cpu": "cortex-m4", - "mcu": "stm32f334r8t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F334R8", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F334R8/", - "vendor": "ST" - }, - "nucleo_f401re": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx", - "f_cpu": "84000000L", - "ldscript": "stm32f401xe.ld", - "cpu": "cortex-m4", - "mcu": "stm32f401ret6", - "variant": "stm32f401xe" - }, - "frameworks": ["mbed", "cmsis", "spl"], - "name": "ST Nucleo F401RE", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 98304, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F401RE/", - "vendor": "ST" - }, - "nucleo_f411re": { - "build": { - "f_cpu": "100000000L", - "cpu": "cortex-m4", - "mcu": "stm32f411ret6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F411RE", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F411RE/", - "vendor": "ST" - }, - "nucleo_f446re": { - "build": { - "f_cpu": "180000000L", - "cpu": "cortex-m4", - "mcu": "stm32f446ret6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F446RE", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F446RE/", - "vendor": "ST" - }, - "nucleo_l053r8": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32l053r8t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo L053R8", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-L053R8/", - "vendor": "ST" - }, - "nucleo_l152re": { - "build": { - "f_cpu": "32000000L", - "cpu": "cortex-m3", - "mcu": "stm32l152ret6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo L152RE", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-L152RE/", - "vendor": "ST" - }, - "armstrap_eagle512": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F40_41xxx", - "f_cpu": "168000000L", - "ldscript": "armstrap_eagle_512.ld", - "cpu": "cortex-m4", - "mcu": "stm32f407vet6", - "variant": "stm32f4" - }, - "frameworks": ["cmsis", "spl"], - "name": "Armstrap Eagle 512", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 196608, - "maximum_size": 524288 - }, - "url": "http://docs.armstrap.org/en/latest/hardware-overview.html", - "vendor": "Armstrap" - }, - "armstrap_eagle1024": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F40_41xxx", - "f_cpu": "168000000L", - "ldscript": "armstrap_eagle_1024.ld", - "cpu": "cortex-m4", - "mcu": "stm32f417vgt6", - "variant": "stm32f4" - }, - "frameworks": ["cmsis", "spl"], - "name": "Armstrap Eagle 1024", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 196608, - "maximum_size": 1048576 - }, - "url": "http://docs.armstrap.org/en/latest/hardware-overview.html", - "vendor": "Armstrap" - }, - "armstrap_eagle2048": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F427_437xx", - "f_cpu": "168000000L", - "ldscript": "armstrap_eagle_2048.ld", - "cpu": "cortex-m4", - "mcu": "stm32f427vit6", - "variant": "stm32f4" - }, - "frameworks": ["cmsis", "spl"], - "name": "Armstrap Eagle 2048", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 262144, - "maximum_size": 2091752 - }, - "url": "http://docs.armstrap.org/en/latest/hardware-overview.html", - "vendor": "Armstrap" - }, - "disco_l053c8": { - "build": { - "f_cpu": "32000000L", - "cpu": "cortex-m0plus", - "mcu": "stm32l053c8t6" - }, - "frameworks": ["mbed"], - "name": "ST 32L0538DISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 65536, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/en/catalog/tools/PF260319", - "vendor": "ST" - }, - "disco_f334c8": { - "build": { - "f_cpu": "72000000L", - "cpu": "cortex-m4", - "mcu": "stm32f334c8t6" - }, - "frameworks": ["mbed"], - "name": "ST 32F3348DISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 12288, - "maximum_size": 65536, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/en/catalog/tools/PF260318", - "vendor": "ST" - }, - "disco_f469ni": { - "build": { - "f_cpu": "180000000L", - "cpu": "cortex-m4", - "mcu": "stm32f469nih6" - }, - "frameworks": ["mbed"], - "name": "ST 32F469IDISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 393216, - "maximum_size": 1048576, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/CL1620/SC959/SS1532/LN1848/PF262395", - "vendor": "ST" - }, - "disco_l476vg": { - "build": { - "f_cpu": "80000000L", - "cpu": "cortex-m4", - "mcu": "stm32l476vgt6" - }, - "frameworks": ["mbed"], - "name": "ST 32L476GDISCOVERY", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 1048576, - "protocol": "stlink" - }, - "url": "http://www.st.com/web/catalog/tools/FM116/CL1620/SC959/SS1532/LN1848/PF261635", - "vendor": "ST" - }, - "nucleo_f031k6": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32f031k6t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F031K6", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F031K6/", - "vendor": "ST" - }, - "nucleo_f042k6": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0", - "mcu": "stm32f042k6t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F042K6", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 6144, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F042K6/", - "vendor": "ST" - }, - "nucleo_f303k8": { - "build": { - "f_cpu": "72000000L", - "cpu": "cortex-m4", - "mcu": "stm32f303k8t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F303K8", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 65536 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F303K8/", - "vendor": "ST" - }, - "nucleo_l476rg": { - "build": { - "f_cpu": "80000000L", - "cpu": "cortex-m4", - "mcu": "stm32l476rgt6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo L476RG", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 1048576 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-L476RG/", - "vendor": "ST" - }, - "nucleo_f410rb": { - "build": { - "f_cpu": "100000000L", - "cpu": "cortex-m4", - "mcu": "stm32f410rbt6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo F410RB", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 131072 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-F410RB/", - "vendor": "ST" - }, - "nucleo_l073rz": { - "build": { - "f_cpu": "32000000L", - "cpu": "cortex-m0plus", - "mcu": "stm32l073rz" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo L073RZ", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 20480, - "maximum_size": 196608 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-L073RZ/", - "vendor": "ST" - }, - "nucleo_l031k6": { - "build": { - "f_cpu": "32000000L", - "cpu": "cortex-m0plus", - "mcu": "stm32l031k6t6" - }, - "frameworks": ["mbed"], - "name": "ST Nucleo L031K6", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 32768 - }, - "url": "https://developer.mbed.org/platforms/ST-Nucleo-L031K6/", - "vendor": "ST" - }, - "seeedArchMax": { - "build": { - "f_cpu": "168000000L", - "cpu": "cortex-m4", - "mcu": "stm32f407vet6" - }, - "frameworks": ["mbed"], - "name": "SeeedStudio Arch Max", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 196608, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/Seeed-Arch-Max/", - "vendor": "SeeedStudio" - }, - "b96b_f446ve": { - "build": { - "f_cpu": "168000000L", - "cpu": "cortex-m4", - "mcu": "stm32f446vet6" - }, - "frameworks": ["mbed"], - "name": "96Boards B96B-F446VE", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/ST-B96B-F446VE/", - "vendor": "96Boards" - }, - "mts_mdot_f411re": { - "build": { - "f_cpu": "100000000L", - "cpu": "cortex-m4", - "mcu": "stm32f411ret6" - }, - "frameworks": ["mbed"], - "name": "MultiTech mDot F411", - "platform": "ststm32", - "upload": { - "maximum_ram_size": 131072, - "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/MTS-mDot-F411/", - "vendor": "MultiTech" - } -} diff --git a/platformio/boards/teensy.json b/platformio/boards/teensy.json deleted file mode 100644 index dd4816ae..00000000 --- a/platformio/boards/teensy.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "teensy20": { - "build": { - "core": "teensy", - "f_cpu": "16000000L", - "mcu": "atmega32u4" - }, - "frameworks": ["arduino"], - "name": "Teensy 2.0", - "platform": "teensy", - "upload": { - "maximum_ram_size": 2560, - "maximum_size": 32256 - }, - "url": "https://www.pjrc.com/store/teensy.html", - "vendor": "Teensy" - }, - - "teensy20pp": { - "build": { - "core": "teensy", - "f_cpu": "16000000L", - "mcu": "at90usb1286" - }, - "frameworks": ["arduino"], - "name": "Teensy++ 2.0", - "platform": "teensy", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 130048 - }, - "url": "https://www.pjrc.com/store/teensypp.html", - "vendor": "Teensy" - }, - - "teensy30": { - "build": { - "core": "teensy3", - "extra_flags": "-D__MK20DX128__", - "f_cpu": "48000000L", - "ldscript": "mk20dx128.ld", - "mcu": "mk20dx128", - "cpu": "cortex-m4" - }, - "frameworks": ["arduino"], - "name": "Teensy 3.0", - "platform": "teensy", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - }, - "url": "https://www.pjrc.com/store/teensy3.html", - "vendor": "Teensy" - }, - - "teensy31": { - "build": { - "core": "teensy3", - "extra_flags": "-D__MK20DX256__", - "f_cpu": "72000000L", - "ldscript": "mk20dx256.ld", - "mcu": "mk20dx256", - "cpu": "cortex-m4" - }, - "frameworks": ["arduino", "mbed"], - "name": "Teensy 3.1 / 3.2", - "platform": "teensy", - "upload": { - "maximum_ram_size": 65536, - "maximum_size": 262144 - }, - "url": "https://www.pjrc.com/store/teensy31.html", - "vendor": "Teensy" - }, - - "teensylc": { - "build": { - "core": "teensy3", - "extra_flags": "-D__MKL26Z64__", - "f_cpu": "48000000L", - "ldscript": "mkl26z64.ld", - "mcu": "mkl26z64", - "cpu": "cortex-m0plus" - }, - "frameworks": ["arduino"], - "name": "Teensy LC", - "platform": "teensy", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 63488 - }, - "url": "http://www.pjrc.com/teensy/teensyLC.html", - "vendor": "Teensy" - } -} diff --git a/platformio/boards/timsp430.json b/platformio/boards/timsp430.json deleted file mode 100644 index 5b8544a6..00000000 --- a/platformio/boards/timsp430.json +++ /dev/null @@ -1,164 +0,0 @@ -{ - "lpmsp430f5529": { - "build": { - "core": "msp430", - "f_cpu": "16000000L", - "mcu": "msp430f5529", - "variant": "launchpad_f5529" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430f5529 (16MHz)", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 131072, - "protocol": "tilib" - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-msp430-msp-exp430f5529lp.html", - "vendor": "TI" - }, - "lpmsp430f5529_25": { - "build": { - "core": "msp430", - "f_cpu": "25000000L", - "mcu": "msp430f5529", - "variant": "launchpad_f5529" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430f5529 (25MHz)", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 131072, - "protocol": "tilib" - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-msp430-msp-exp430f5529lp.html", - "vendor": "TI" - }, - "lpmsp430fr5739": { - "build": { - "core": "msp430", - "f_cpu": "16000000L", - "mcu": "msp430fr5739", - "variant": "fraunchpad" - }, - "frameworks": ["energia"], - "name": "TI FraunchPad w/ msp430fr5739", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 15872, - "protocol": "rf2500" - }, - "url": "http://www.ti.com/tool/msp-exp430fr5739", - "vendor": "TI" - }, - "lpmsp430fr5969": { - "build": { - "core": "msp430", - "f_cpu": "8000000L", - "mcu": "msp430fr5969", - "variant": "launchpad_fr5969" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430fr5969", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 1024, - "maximum_size": 65536, - "protocol": "tilib" - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-msp430-msp-exp430fr5969.html", - "vendor": "TI" - }, - "lpmsp430g2231": { - "build": { - "core": "msp430", - "f_cpu": "1000000L", - "mcu": "msp430g2231", - "variant": "launchpad" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430g2231 (1 MHz)", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 128, - "maximum_size": 2048, - "protocol": "rf2500" - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-msp430-msp-exp430g2.html", - "vendor": "TI" - }, - "lpmsp430g2452": { - "build": { - "core": "msp430", - "f_cpu": "16000000L", - "mcu": "msp430g2452", - "variant": "launchpad" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430g2452 (16MHz)", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 256, - "maximum_size": 8192, - "protocol": "rf2500" - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-msp430-msp-exp430g2.html", - "vendor": "TI" - }, - "lpmsp430g2553": { - "build": { - "core": "msp430", - "f_cpu": "16000000L", - "mcu": "msp430g2553", - "variant": "launchpad" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430g2553 (16MHz)", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 512, - "maximum_size": 16384, - "protocol": "rf2500" - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-msp430-msp-exp430g2.html", - "vendor": "TI" - }, - "lpmsp430fr4133": { - "build": { - "core": "msp430", - "f_cpu": "16000000L", - "mcu": "msp430fr4133", - "variant": "launchpad_fr4133" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430fr4133", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 15360, - "protocol": "tilib" - }, - "url": "http://www.ti.com/tool/msp-exp430fr4133", - "vendor": "TI" - }, - "lpmsp430fr6989": { - "build": { - "core": "msp430", - "f_cpu": "16000000L", - "mcu": "msp430fr6989", - "variant": "launchpad_fr6989" - }, - "frameworks": ["energia"], - "name": "TI LaunchPad w/ msp430fr6989", - "platform": "timsp430", - "upload": { - "maximum_ram_size": 2048, - "maximum_size": 130048, - "protocol": "tilib" - }, - "url": "http://www.ti.com/tool/msp-exp430fr6989", - "vendor": "TI" - } -} diff --git a/platformio/boards/titiva.json b/platformio/boards/titiva.json deleted file mode 100644 index 29b7944f..00000000 --- a/platformio/boards/titiva.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "lplm4f120h5qr": { - "build": { - "core": "lm4f", - "f_cpu": "80000000L", - "ldscript": "lm4fcpp_blizzard.ld", - "cpu": "cortex-m4", - "mcu": "lplm4f120h5qr", - "variant": "stellarpad" - }, - "frameworks": ["energia", "libopencm3"], - "name": "TI LaunchPad (Stellaris) w/ lm4f120 (80MHz)", - "platform": "titiva", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "http://www.ti.com/tool/ek-lm4f120xl", - "vendor": "TI" - }, - "lptm4c1230c3pm": { - "build": { - "core": "lm4f", - "f_cpu": "80000000L", - "ldscript": "lm4fcpp_blizzard.ld", - "cpu": "cortex-m4", - "mcu": "lptm4c1230c3pm", - "variant": "stellarpad" - }, - "frameworks": ["energia", "libopencm3"], - "name": "TI LaunchPad (Tiva C) w/ tm4c123 (80MHz)", - "platform": "titiva", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 262144 - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-connected-ek-tm4c123gxl.html", - "vendor": "TI" - }, - "lptm4c1294ncpdt": { - "build": { - "core": "lm4f", - "f_cpu": "120000000L", - "ldscript": "lm4fcpp_snowflake.ld", - "cpu": "cortex-m4", - "mcu": "lptm4c1294ncpdt", - "variant": "launchpad_129" - }, - "frameworks": ["energia", "libopencm3"], - "name": "TI LaunchPad (Tiva C) w/ tm4c129 (120MHz)", - "platform": "titiva", - "upload": { - "maximum_ram_size": 262144, - "maximum_size": 1048576 - }, - "url": "http://www.ti.com/ww/en/launchpad/launchpads-connected-ek-tm4c1294xl.html", - "vendor": "TI" - } -} \ No newline at end of file diff --git a/platformio/builder/__init__.py b/platformio/builder/__init__.py index 0c05c3b0..95899c71 100644 --- a/platformio/builder/__init__.py +++ b/platformio/builder/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 8b01c7b2..2da97908 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,40 +14,41 @@ import base64 import json -import sys from os import environ -from os.path import join, normpath +from os.path import join from time import time -from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables +from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, DEFAULT_TARGETS, + AllowSubstExceptions, AlwaysBuild, + DefaultEnvironment, Variables) from platformio import util -from platformio.exception import UnknownBoard -# AllowSubstExceptions() +AllowSubstExceptions(NameError) # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( + ("PLATFORM_MANIFEST",), ("BUILD_SCRIPT",), ("EXTRA_SCRIPT",), ("PIOENV",), - ("PLATFORM",), + ("PIOTEST",), + ("PIOPLATFORM",), + ("PIOFRAMEWORK",), - # package aliases - ("PIOPACKAGE_TOOLCHAIN",), - ("PIOPACKAGE_FRAMEWORK",), - ("PIOPACKAGE_UPLOADER",), - - # options - ("FRAMEWORK",), + # build options ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",), ("BUILD_UNFLAGS",), ("SRC_FILTER",), - ("LIB_DFCYCLIC",), + + # library options + ("LIB_LDF_MODE",), + ("LIB_COMPAT_MODE",), ("LIB_IGNORE",), - ("LIB_USE",), + ("LIB_FORCE",), + ("LIB_EXTRA_DIRS",), # board options ("BOARD",), @@ -62,112 +63,88 @@ commonvars.AddVariables( ("UPLOAD_SPEED",), ("UPLOAD_FLAGS",), ("UPLOAD_RESETMETHOD",) -) +) # yapf: disable -DefaultEnvironment( +DEFAULT_ENV_OPTIONS = dict( tools=[ - "gcc", "g++", "as", "ar", "gnulink", - "platformio", "pioupload", "pioar", "piomisc" - ], - toolpath=[join("$PIOBUILDER_DIR", "tools")], + "ar", "as", "gcc", "g++", "gnulink", + "platformio", "pioplatform", "piowinhooks", + "piolib", "piotest", "pioupload", "piomisc" + ], # yapf: disable + toolpath=[join(util.get_source_dir(), "builder", "tools")], variables=commonvars, # Propagating External Environment ENV=environ, - UNIX_TIME=int(time()), PROGNAME="program", - PIOHOME_DIR=util.get_home_dir(), PROJECT_DIR=util.get_project_dir(), - PROJECTLIB_DIR=util.get_projectlib_dir(), PROJECTSRC_DIR=util.get_projectsrc_dir(), + PROJECTTEST_DIR=util.get_projecttest_dir(), PROJECTDATA_DIR=util.get_projectdata_dir(), - PIOENVS_DIR=util.get_pioenvs_dir(), - - PIOBUILDER_DIR=join(util.get_source_dir(), "builder"), - PIOPACKAGES_DIR=join("$PIOHOME_DIR", "packages"), - - BUILD_DIR=join("$PIOENVS_DIR", "$PIOENV"), + PROJECTPIOENVS_DIR=util.get_projectpioenvs_dir(), + BUILD_DIR=join("$PROJECTPIOENVS_DIR", "$PIOENV"), BUILDSRC_DIR=join("$BUILD_DIR", "src"), + BUILDTEST_DIR=join("$BUILD_DIR", "test"), LIBSOURCE_DIRS=[ - "$PROJECTLIB_DIR", - util.get_lib_dir(), - join("$PLATFORMFW_DIR", "libraries") + util.get_projectlib_dir(), util.get_projectlibdeps_dir(), + join("$PIOHOME_DIR", "lib") ], + PYTHONEXE=util.get_pythonexe_path()) - PYTHONEXE=normpath(sys.executable) -) +if not int(ARGUMENTS.get("PIOVERBOSE", 0)): + DEFAULT_ENV_OPTIONS['ARCOMSTR'] = "Archiving $TARGET" + DEFAULT_ENV_OPTIONS['LINKCOMSTR'] = "Linking $TARGET" + DEFAULT_ENV_OPTIONS['RANLIBCOMSTR'] = "Indexing $TARGET" + for k in ("ASCOMSTR", "ASPPCOMSTR", "CCCOMSTR", "CXXCOMSTR"): + DEFAULT_ENV_OPTIONS[k] = "Compiling $TARGET" -env = DefaultEnvironment() +env = DefaultEnvironment(**DEFAULT_ENV_OPTIONS) # decode common variables for k in commonvars.keys(): if k in env: env[k] = base64.b64decode(env[k]) -env.Prepend(LIBPATH=[join("$PIOPACKAGES_DIR", "ldscripts")]) +if env.GetOption('clean'): + env.PioClean(env.subst("$BUILD_DIR")) + env.Exit(0) +elif not int(ARGUMENTS.get("PIOVERBOSE", 0)): + print "Verbose mode can be enabled via `-v, --verbose` option" -if "BOARD" in env: - try: - env.Replace(BOARD_OPTIONS=util.get_boards(env.subst("$BOARD"))) - except UnknownBoard as e: - env.Exit("Error: %s" % str(e)) - - for k in commonvars.keys(): - if (k in env or - not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")])): - continue - _opt, _val = k.lower().split("_", 1) - if _opt == "board": - _opt = "build" - if _val in env['BOARD_OPTIONS'][_opt]: - env.Replace(**{k: "${BOARD_OPTIONS['%s']['%s']}" % (_opt, _val)}) - - if "ldscript" in env.get("BOARD_OPTIONS", {}).get("build", {}): - env.Replace( - LDSCRIPT_PATH="${BOARD_OPTIONS['build']['ldscript']}" - ) - - if env['PLATFORM'] != env.get("BOARD_OPTIONS", {}).get("platform"): - env.Exit( - "Error: '%s' platform doesn't support this board. " - "Use '%s' platform instead." % ( - env['PLATFORM'], env.get("BOARD_OPTIONS", {}).get("platform"))) - - -for opt in ("LIB_IGNORE", "LIB_USE"): - if opt not in env: - continue - env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] - -if env.subst("$PIOPACKAGE_TOOLCHAIN"): - env.PrependENVPath( - "PATH", - env.subst(join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN", "bin")) - ) - -# handle custom variable from system environment +# Handle custom variables from system environment for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT", - "UPLOAD_PORT", "UPLOAD_FLAGS"): + "UPLOAD_PORT", "UPLOAD_FLAGS", "LIB_EXTRA_DIRS"): k = "PLATFORMIO_%s" % var if environ.get(k): env[var] = environ.get(k) +# Parse comma separated items +for opt in ("LIB_IGNORE", "LIB_FORCE", "LIB_EXTRA_DIRS"): + if opt not in env: + continue + env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] + +env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) +env.LoadPioPlatform(commonvars) + env.SConscriptChdir(0) -env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite")) +env.SConsignFile(join("$PROJECTPIOENVS_DIR", ".sconsign.dblite")) env.SConscript("$BUILD_SCRIPT") +AlwaysBuild(env.Alias("test", DEFAULT_TARGETS + ["size"])) + if "UPLOAD_FLAGS" in env: env.Append(UPLOADERFLAGS=["$UPLOAD_FLAGS"]) if env.get("EXTRA_SCRIPT"): - env.SConscript(env.get("EXTRA_SCRIPT")) + env.SConscript(env.get("EXTRA_SCRIPT"), exports="env") if "envdump" in COMMAND_LINE_TARGETS: print env.Dump() - env.Exit() + env.Exit(0) if "idedata" in COMMAND_LINE_TARGETS: print json.dumps(env.DumpIDEData()) - env.Exit() + env.Exit(0) diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py deleted file mode 100644 index 2500084e..00000000 --- a/platformio/builder/scripts/atmelavr.py +++ /dev/null @@ -1,168 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Atmel AVR series of microcontrollers -""" - -from os.path import join -from time import sleep - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - -from platformio.util import get_serialports - - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - - if "program" in COMMAND_LINE_TARGETS: - return - - if "micronucleus" in env['UPLOADER']: - print "Please unplug/plug device ..." - - upload_options = env.get("BOARD_OPTIONS", {}).get("upload", {}) - - # Deprecated: compatibility with old projects. Use `program` instead - if "usb" in env.subst("$UPLOAD_PROTOCOL"): - upload_options['require_upload_port'] = False - env.Replace(UPLOAD_SPEED=None) - - if env.subst("$UPLOAD_SPEED"): - env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"]) - - if upload_options and not upload_options.get("require_upload_port", False): - return - - env.AutodetectUploadPort() - env.Append(UPLOADERFLAGS=["-P", '"$UPLOAD_PORT"']) - - if env.subst("$BOARD") in ("raspduino", "emonpi"): - - def _rpi_sysgpio(path, value): - with open(path, "w") as f: - f.write(str(value)) - - pin_num = 18 if env.subst("$BOARD") == "raspduino" else 4 - _rpi_sysgpio("/sys/class/gpio/export", pin_num) - _rpi_sysgpio("/sys/class/gpio/gpio%d/direction" % pin_num, "out") - _rpi_sysgpio("/sys/class/gpio/gpio%d/value" % pin_num, 1) - sleep(0.1) - _rpi_sysgpio("/sys/class/gpio/gpio%d/value" % pin_num, 0) - _rpi_sysgpio("/sys/class/gpio/unexport", pin_num) - else: - if not upload_options.get("disable_flushing", False): - env.FlushSerialBuffer("$UPLOAD_PORT") - - before_ports = get_serialports() - - if upload_options.get("use_1200bps_touch", False): - env.TouchSerialPort("$UPLOAD_PORT", 1200) - - if upload_options.get("wait_for_upload_port", False): - env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports)) - - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py"))) - -env.Append( - CFLAGS=[ - "-std=gnu11" - ], - - CXXFLAGS=[ - "-std=gnu++11" - ] -) - -if "digispark" in env.get( - "BOARD_OPTIONS", {}).get("build", {}).get("core", ""): - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-micronucleus", "micronucleus"), - UPLOADERFLAGS=[ - "-c", "$UPLOAD_PROTOCOL", - "--timeout", "60" - ], - UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES' - ) - -else: - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"), - UPLOADERFLAGS=[ - "-v", - "-p", "$BOARD_MCU", - "-C", - '"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"), - "-c", "$UPLOAD_PROTOCOL" - ], - UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -D -U flash:w:$SOURCES:i', - UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i', - PROGRAMHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i' - ) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .hex file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.hex") -else: - target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default .hex file -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, - [BeforeUpload, "$UPLOADHEXCMD"]) -AlwaysBuild(upload) - -# -# Target: Upload EEPROM data (from EEMEM directive) -# - -uploadeep = env.Alias("uploadeep", - env.ElfToEep(join("$BUILD_DIR", "firmware"), target_elf), - [BeforeUpload, "$UPLOADEEPCMD"]) -AlwaysBuild(uploadeep) - -# -# Target: Upload firmware using external programmer -# - -program = env.Alias("program", target_firm, [BeforeUpload, "$PROGRAMHEXCMD"]) -AlwaysBuild(program) - -# -# Setup default targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/atmelsam.py b/platformio/builder/scripts/atmelsam.py deleted file mode 100644 index d4b25a46..00000000 --- a/platformio/builder/scripts/atmelsam.py +++ /dev/null @@ -1,252 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Atmel SAM series of microcontrollers -""" - -from os.path import basename, join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, - DefaultEnvironment, SConscript) - -from platformio.util import get_serialports - - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - - upload_options = env.get("BOARD_OPTIONS", {}).get("upload", {}) - - if not upload_options.get("disable_flushing", False): - env.FlushSerialBuffer("$UPLOAD_PORT") - - before_ports = get_serialports() - - if upload_options.get("use_1200bps_touch", False): - env.TouchSerialPort("$UPLOAD_PORT", 1200) - - if upload_options.get("wait_for_upload_port", False): - env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports)) - - # use only port name for BOSSA - if ("/" in env.subst("$UPLOAD_PORT") and - env.subst("$UPLOAD_PROTOCOL") == "sam-ba"): - env.Replace(UPLOAD_PORT=basename(env.subst("$UPLOAD_PORT"))) - - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - -BOARD_OPTIONS = env.get("BOARD_OPTIONS", {}) - - -env.Append( - - CCFLAGS=[ - "--param", "max-inline-insns-single=500", - "-MMD" - ], - - CFLAGS=[ - "-std=gnu11" - ], - - CXXFLAGS=[ - "-std=gnu++11", - "-fno-threadsafe-statics" - ], - - CPPDEFINES=[ - "USBCON" - ], - - LINKFLAGS=[ - "-Wl,--check-sections", - "-Wl,--unresolved-symbols=report-all", - "-Wl,--warn-common", - "-Wl,--warn-section-align" - ] -) - -user_code_section = BOARD_OPTIONS.get("upload", {}).get("section_start", False) - -if user_code_section: - env.Append( - CPPDEFINES=[ - "printf=iprintf" - ], - - LINKFLAGS=[ - "-Wl,--entry=Reset_Handler", - "-Wl,--section-start=.text=%s" % user_code_section - ] - ) - -if "sam3x8e" in BOARD_OPTIONS.get("build", {}).get("mcu", ""): - env.Append( - CPPDEFINES=[ - "printf=iprintf" - ], - - LINKFLAGS=[ - "-Wl,--entry=Reset_Handler", - "-Wl,--start-group" - ] - - ) -elif "samd" in BOARD_OPTIONS.get("build", {}).get("mcu", ""): - env.Append( - LINKFLAGS=[ - "--specs=nosys.specs", - "--specs=nano.specs" - ] - ) - - -upload_protocol = BOARD_OPTIONS.get("upload", {}).get("protocol", None) - -if upload_protocol == "openocd": - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-openocd", "bin", "openocd"), - UPLOADERFLAGS=[ - "-d2", - "-f", join(BOARD_OPTIONS.get("debug", {}).get("openocdcfg", "")), - "-s", join("$PIOPACKAGES_DIR", "tool-openocd", - "share", "openocd", "scripts"), - "-s", join("$PIOPACKAGES_DIR", "tool-openocd", - "share", "openocd", "scripts", "board") - ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' - ) - - if "zero" in env.subst("$BOARD"): - env.Append( - UPLOADERFLAGS=[ - "-s", join("$PLATFORMFW_DIR", "variants", - "${BOARD_OPTIONS['build']['variant']}", - "openocd_scripts") - ] - ) - - env.Append( - UPLOADERFLAGS=[ - "-c", "\"telnet_port", "disabled;", - "program", "{{$SOURCES}}", - "verify", "reset", - "%s;" % user_code_section if user_code_section else "", - "shutdown\"" - ] - ) - -elif upload_protocol == "sam-ba": - - board_type = env.subst("$BOARD") - - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"), - UPLOADERFLAGS=[ - "--info", - "--port", '"$UPLOAD_PORT"', - "--erase", - "--write", - "--verify", - "--reset", - "--debug", - "-U", - "true" if ("usb" in board_type.lower( - ) or board_type == "digix") else "false" - ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES' - ) - - if "sam3x8e" in BOARD_OPTIONS.get("build", {}).get("mcu", ""): - env.Append(UPLOADERFLAGS=["--boot"]) - -elif upload_protocol == "stk500v2": - env.Append( - BUILDERS=dict( - ElfToHex=Builder( - action=" ".join([ - "$OBJCOPY", - "-O", - "ihex", - "-R", - ".eeprom", - "$SOURCES", - "$TARGET"]), - suffix=".hex" - ) - ) - ) - - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"), - UPLOADERFLAGS=[ - "-C", '"%s"' % join("$PIOPACKAGES_DIR", - "tool-avrdude", "avrdude.conf"), - "-v", - "-p", "atmega2560", # Arduino M0/Tian upload hook - "-c", "$UPLOAD_PROTOCOL", - "-P", '"$UPLOAD_PORT"', - "-b", "$UPLOAD_SPEED" - ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i' - ) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") -elif upload_protocol == "stk500v2": - target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) -else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default .bin file -# - -if upload_protocol == "openocd": - upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") -else: - upload = env.Alias( - ["upload", "uploadlazy"], target_firm, - [env.AutodetectUploadPort, BeforeUpload, "$UPLOADCMD"]) - -AlwaysBuild(upload) - -# -# Setup default targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/basearm.py b/platformio/builder/scripts/basearm.py deleted file mode 100644 index 20892b18..00000000 --- a/platformio/builder/scripts/basearm.py +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Base for ARM microcontrollers. -""" - -from SCons.Script import Builder, DefaultEnvironment - -env = DefaultEnvironment() - -env.Replace( - AR="arm-none-eabi-ar", - AS="arm-none-eabi-as", - CC="arm-none-eabi-gcc", - CXX="arm-none-eabi-g++", - OBJCOPY="arm-none-eabi-objcopy", - RANLIB="arm-none-eabi-ranlib", - SIZETOOL="arm-none-eabi-size", - - ARFLAGS=["rcs"], - - ASFLAGS=["-x", "assembler-with-cpp"], - - CCFLAGS=[ - "-g", # include debugging info (so errors include line numbers) - "-Os", # optimize for size - "-ffunction-sections", # place each function in its own section - "-fdata-sections", - "-Wall", - "-mthumb", - "-mcpu=${BOARD_OPTIONS['build']['cpu']}", - "-nostdlib" - ], - - CXXFLAGS=[ - "-fno-rtti", - "-fno-exceptions" - ], - - CPPDEFINES=[ - "F_CPU=$BOARD_F_CPU" - ], - - LINKFLAGS=[ - "-Os", - "-Wl,--gc-sections,--relax", - "-mthumb", - "-mcpu=${BOARD_OPTIONS['build']['cpu']}" - ], - - LIBS=["c", "gcc", "m"], - - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - - PROGNAME="firmware", - PROGSUFFIX=".elf" -) - - -env.Append( - ASFLAGS=env.get("CCFLAGS", [])[:], - - BUILDERS=dict( - ElfToBin=Builder( - action=" ".join([ - "$OBJCOPY", - "-O", - "binary", - "$SOURCES", - "$TARGET"]), - suffix=".bin" - ), - ElfToHex=Builder( - action=" ".join([ - "$OBJCOPY", - "-O", - "ihex", - "-R", - ".eeprom", - "$SOURCES", - "$TARGET"]), - suffix=".hex" - ) - ) -) diff --git a/platformio/builder/scripts/baseavr.py b/platformio/builder/scripts/baseavr.py deleted file mode 100644 index 055fb742..00000000 --- a/platformio/builder/scripts/baseavr.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Base for Atmel AVR series of microcontrollers -""" - -from SCons.Script import Builder, DefaultEnvironment - -env = DefaultEnvironment() - -env.Replace( - AR="avr-ar", - AS="avr-as", - CC="avr-gcc", - CXX="avr-g++", - OBJCOPY="avr-objcopy", - RANLIB="avr-ranlib", - SIZETOOL="avr-size", - - ARFLAGS=["rcs"], - - ASFLAGS=["-x", "assembler-with-cpp"], - - CCFLAGS=[ - "-g", # include debugging info (so errors include line numbers) - "-Os", # optimize for size - "-Wall", # show warnings - "-ffunction-sections", # place each function in its own section - "-fdata-sections", - "-mmcu=$BOARD_MCU" - ], - - CXXFLAGS=[ - "-fno-exceptions", - "-fno-threadsafe-statics" - ], - - CPPDEFINES=["F_CPU=$BOARD_F_CPU"], - - LINKFLAGS=[ - "-Os", - "-mmcu=$BOARD_MCU", - "-Wl,--gc-sections,--relax" - ], - - LIBS=["m"], - - SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES', - - PROGNAME="firmware", - PROGSUFFIX=".elf" -) - -env.Append( - ASFLAGS=env.get("CCFLAGS", [])[:], - - BUILDERS=dict( - ElfToEep=Builder( - action=" ".join([ - "$OBJCOPY", - "-O", - "ihex", - "-j", - ".eeprom", - '--set-section-flags=.eeprom="alloc,load"', - "--no-change-warnings", - "--change-section-lma", - ".eeprom=0", - "$SOURCES", - "$TARGET"]), - suffix=".eep" - ), - - ElfToHex=Builder( - action=" ".join([ - "$OBJCOPY", - "-O", - "ihex", - "-R", - ".eeprom", - "$SOURCES", - "$TARGET"]), - suffix=".hex" - ) - ) -) diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py deleted file mode 100644 index d9cef77b..00000000 --- a/platformio/builder/scripts/espressif.py +++ /dev/null @@ -1,356 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=redefined-outer-name - -""" - Builder for Espressif MCUs -""" - -import re -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, - DefaultEnvironment) - - -def _get_flash_size(env): - # use board's flash size by default - board_max_size = int( - env.get("BOARD_OPTIONS", {}).get("upload", {}).get("maximum_size", 0)) - - # check if user overrides LD Script - match = re.search(r"\.flash\.(\d+)(m|k).*\.ld", env.GetActualLDScript()) - if match: - if match.group(2) == "k": - board_max_size = int(match.group(1)) * 1024 - elif match.group(2) == "m": - board_max_size = int(match.group(1)) * 1024 * 1024 - - return ("%dK" % (board_max_size / 1024) if board_max_size < 1048576 - else "%dM" % (board_max_size / 1048576)) - - -def _get_board_f_flash(env): - frequency = env.subst("$BOARD_F_FLASH") - frequency = str(frequency).replace("L", "") - return int(int(frequency) / 1000000) - - -env = DefaultEnvironment() - -env.Replace( - __get_flash_size=_get_flash_size, - __get_board_f_flash=_get_board_f_flash, - - AR="xtensa-lx106-elf-ar", - AS="xtensa-lx106-elf-as", - CC="xtensa-lx106-elf-gcc", - CXX="xtensa-lx106-elf-g++", - OBJCOPY=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool"), - RANLIB="xtensa-lx106-elf-ranlib", - SIZETOOL="xtensa-lx106-elf-size", - - ARFLAGS=["rcs"], - - ASFLAGS=["-x", "assembler-with-cpp"], - - CFLAGS=[ - "-std=gnu99", - "-Wpointer-arith", - "-Wno-implicit-function-declaration", - "-Wl,-EL", - "-fno-inline-functions", - "-nostdlib" - ], - - CCFLAGS=[ - "-Os", # optimize for size - "-mlongcalls", - "-mtext-section-literals", - "-falign-functions=4", - "-U__STRICT_ANSI__", - "-ffunction-sections", - "-fdata-sections" - ], - - CXXFLAGS=[ - "-fno-rtti", - "-fno-exceptions", - "-std=c++11" - ], - - CPPDEFINES=[ - "F_CPU=$BOARD_F_CPU", - "__ets__", - "ICACHE_FLASH" - ], - - LINKFLAGS=[ - "-Os", - "-nostdlib", - "-Wl,--no-check-sections", - "-u", "call_user_start", - "-Wl,-static", - "-Wl,--gc-sections" - ], - - # - # Upload - # - - UPLOADER=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool"), - UPLOADEROTA=join("$PLATFORMFW_DIR", "tools", "espota.py"), - - UPLOADERFLAGS=[ - "-vv", - "-cd", "$UPLOAD_RESETMETHOD", - "-cb", "$UPLOAD_SPEED", - "-cp", '"$UPLOAD_PORT"' - ], - UPLOADEROTAFLAGS=[ - "--debug", - "--progress", - "-i", "$UPLOAD_PORT", - "$UPLOAD_FLAGS" - ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -cf $SOURCE', - UPLOADOTACMD='"$PYTHONEXE" "$UPLOADEROTA" $UPLOADEROTAFLAGS -f $SOURCE', - - # - # Misc - # - - MKSPIFFSTOOL=join("$PIOPACKAGES_DIR", "tool-mkspiffs", "mkspiffs"), - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - - PROGNAME="firmware", - PROGSUFFIX=".elf" -) - -env.Append( - ASFLAGS=env.get("CCFLAGS", [])[:], - - BUILDERS=dict( - ElfToBin=Builder( - action=" ".join([ - '"$OBJCOPY"', - "-eo", - '"%s"' % join("$PLATFORMFW_DIR", "bootloaders", - "eboot", "eboot.elf"), - "-bo", "$TARGET", - "-bm", "$BOARD_FLASH_MODE", - "-bf", "${__get_board_f_flash(__env__)}", - "-bz", "${__get_flash_size(__env__)}", - "-bs", ".text", - "-bp", "4096", - "-ec", - "-eo", "$SOURCES", - "-bs", ".irom0.text", - "-bs", ".text", - "-bs", ".data", - "-bs", ".rodata", - "-bc", "-ec" - ]), - suffix=".bin" - ) - ) -) - - -# -# SPIFFS -# - -def _fetch_spiffs_size(target, source, env): - spiffs_re = re.compile( - r"PROVIDE\s*\(\s*_SPIFFS_(\w+)\s*=\s*(0x[\dA-F]+)\s*\)") - with open(env.GetActualLDScript()) as f: - for line in f.readlines(): - match = spiffs_re.search(line) - if not match: - continue - env["SPIFFS_%s" % match.group(1).upper()] = match.group(2) - - assert all([k in env for k in ["SPIFFS_START", "SPIFFS_END", "SPIFFS_PAGE", - "SPIFFS_BLOCK"]]) - - # esptool flash starts from 0 - for k in ("SPIFFS_START", "SPIFFS_END"): - _value = 0 - if int(env[k], 16) < 0x40300000: - _value = int(env[k], 16) & 0xFFFFF - else: - _value = int(env[k], 16) & 0xFFFFFF - _value -= 0x200000 # esptool offset - - env[k] = hex(_value) - - return (target, source) - - -env.Append( - BUILDERS=dict( - DataToBin=Builder( - action=" ".join([ - '"$MKSPIFFSTOOL"', - "-c", "$SOURCES", - "-p", "${int(SPIFFS_PAGE, 16)}", - "-b", "${int(SPIFFS_BLOCK, 16)}", - "-s", "${int(SPIFFS_END, 16) - int(SPIFFS_START, 16)}", - "$TARGET" - ]), - emitter=_fetch_spiffs_size, - source_factory=env.Dir, - suffix=".bin" - ) - ) -) - -if "uploadfs" in COMMAND_LINE_TARGETS: - env.Append( - UPLOADERFLAGS=["-ca", "$SPIFFS_START"], - UPLOADEROTAFLAGS=["-s"] - ) - -# -# Framework and SDK specific configuration -# - -if "FRAMEWORK" in env: - env.Append( - LINKFLAGS=[ - "-Wl,-wrap,system_restart_local", - "-Wl,-wrap,register_chipv6_phy" - ] - ) - - # Handle uploading via OTA - ota_port = None - if env.get("UPLOAD_PORT"): - ota_port = re.match( - r"\"?((([0-9]{1,3}\.){3}[0-9]{1,3})|.+\.local)\"?$", - env.get("UPLOAD_PORT")) - if ota_port: - env.Replace(UPLOADCMD="$UPLOADOTACMD") - -# Configure native SDK -else: - env.Append( - CPPPATH=[ - join("$PIOPACKAGES_DIR", "sdk-esp8266", "include"), - "$PROJECTSRC_DIR" - ], - - LIBPATH=[ - join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib"), - join("$PIOPACKAGES_DIR", "sdk-esp8266", "ld") - ], - - BUILDERS=dict( - ElfToBin=Builder( - action=" ".join([ - '"$OBJCOPY"', - "-eo", "$SOURCES", - "-bo", "${TARGETS[0]}", - "-bm", "$BOARD_FLASH_MODE", - "-bf", "${__get_board_f_flash(__env__)}", - "-bz", "${__get_flash_size(__env__)}", - "-bs", ".text", - "-bs", ".data", - "-bs", ".rodata", - "-bc", "-ec", - "-eo", "$SOURCES", - "-es", ".irom0.text", "${TARGETS[1]}", - "-ec", "-v" - ]), - suffix=".bin" - ) - ) - ) - env.Replace( - LIBS=[ - "c", "gcc", "phy", "pp", "net80211", "lwip", "wpa", "wpa2", - "main", "wps", "crypto", "json", "ssl", "pwm", "upgrade", - "smartconfig", "airkiss", "at" - ], - - UPLOADERFLAGS=[ - "-vv", - "-cd", "$UPLOAD_RESETMETHOD", - "-cb", "$UPLOAD_SPEED", - "-cp", '"$UPLOAD_PORT"', - "-ca", "0x00000", - "-cf", "${SOURCES[0]}", - "-ca", "0x40000", - "-cf", "${SOURCES[1]}" - ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS', - ) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .hex or SPIFFS image -# - -if set(["uploadfs", "uploadfsota"]) & set(COMMAND_LINE_TARGETS): - target_firm = env.DataToBin( - join("$BUILD_DIR", "spiffs"), "$PROJECTDATA_DIR") - AlwaysBuild(target_firm) - -elif "uploadlazy" in COMMAND_LINE_TARGETS: - if "FRAMEWORK" not in env: - target_firm = [ - join("$BUILD_DIR", "firmware_00000.bin"), - join("$BUILD_DIR", "firmware_40000.bin") - ] - else: - target_firm = join("$BUILD_DIR", "firmware.bin") -else: - if "FRAMEWORK" not in env: - target_firm = env.ElfToBin( - [join("$BUILD_DIR", "firmware_00000"), - join("$BUILD_DIR", "firmware_40000")], target_elf) - else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload firmware or SPIFFS image -# - -target_upload = env.Alias( - ["upload", "uploadlazy", "uploadfs"], target_firm, - [env.AutodetectUploadPort, "$UPLOADCMD"]) -env.AlwaysBuild(target_upload) - - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/frameworks/__init__.py b/platformio/builder/scripts/frameworks/__init__.py deleted file mode 100644 index 0c05c3b0..00000000 --- a/platformio/builder/scripts/frameworks/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py deleted file mode 100644 index 17300c75..00000000 --- a/platformio/builder/scripts/frameworks/arduino.py +++ /dev/null @@ -1,372 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -Arduino - -Arduino Wiring-based Framework allows writing cross-platform software to -control devices attached to a wide range of Arduino boards to create all -kinds of creative coding, interactive objects, spaces or physical experiences. - -http://arduino.cc/en/Reference/HomePage -""" - -from os import listdir, walk -from os.path import isdir, isfile, join - -from SCons.Script import DefaultEnvironment - -env = DefaultEnvironment() - -BOARD_OPTS = env.get("BOARD_OPTIONS", {}) -BOARD_BUILDOPTS = BOARD_OPTS.get("build", {}) -BOARD_CORELIBDIRNAME = BOARD_BUILDOPTS.get("core") - -# -# Determine framework directory -# based on development platform -# - -PLATFORMFW_DIR = join("$PIOPACKAGES_DIR", - "framework-arduino${PLATFORM.replace('atmel', '')}") - -if "digispark" in BOARD_BUILDOPTS.get("core"): - BOARD_CORELIBDIRNAME = "digispark" - PLATFORMFW_DIR = join( - "$PIOPACKAGES_DIR", - "framework-arduino%s" % ( - "sam" if BOARD_BUILDOPTS.get("cpu") == "cortex-m3" else "avr") - ) -elif env.get("PLATFORM") == "timsp430": - PLATFORMFW_DIR = join( - "$PIOPACKAGES_DIR", - "framework-arduinomsp430" - ) -elif env.get("PLATFORM") == "espressif": - env.Prepend( - CPPDEFINES=["LWIP_OPEN_SRC"], - CPPPATH=[ - join("$PLATFORMFW_DIR", "tools", "sdk", "include"), - join("$PLATFORMFW_DIR", "tools", "sdk", "lwip", "include") - ], - LIBPATH=[join("$PLATFORMFW_DIR", "tools", "sdk", "lib")], - LIBS=[ - "mesh", "wpa2", "smartconfig", "pp", "main", "wpa", "lwip_gcc", - "net80211", "wps", "crypto", "phy", "hal", "axtls", "gcc", - "m", "stdc++" - ] - ) - env.VariantDirWrap( - join("$BUILD_DIR", "generic"), - join("$PIOPACKAGES_DIR", "framework-arduinoespressif", - "variants", "generic") - ) - -elif env.get("PLATFORM") == "nordicnrf51": - PLATFORMFW_DIR = join( - "$PIOPACKAGES_DIR", - "framework-arduinonordicnrf51" - ) - env.Prepend( - CPPPATH=[ - join("$PLATFORMFW_DIR", "system", "CMSIS", "CMSIS", "Include"), - join("$PLATFORMFW_DIR", "system", "RFduino"), - join("$PLATFORMFW_DIR", "system", "RFduino", "include") - ], - LIBPATH=[ - join( - "$PLATFORMFW_DIR", - "variants", - "${BOARD_OPTIONS['build']['variant']}" - ), - join( - "$PLATFORMFW_DIR", - "variants", - "${BOARD_OPTIONS['build']['variant']}", - "linker_scripts", - "gcc" - ), - ], - LIBS=["RFduino", "RFduinoBLE", "RFduinoGZLL", "RFduinoSystem"] - ) - -elif env.get("PLATFORM") == "microchippic32": - PLATFORMFW_DIR = join( - "$PIOPACKAGES_DIR", - "framework-arduinomicrochippic32" - ) - env.Prepend( - LIBPATH=[ - join( - "$PLATFORMFW_DIR", "cores", - "${BOARD_OPTIONS['build']['core']}" - ), - join( - "$PLATFORMFW_DIR", "variants", - "${BOARD_OPTIONS['build']['variant']}" - ) - ], - - CPPDEFINES=["ARDUINO_ARCH_PIC32"] - - ) - -elif "intel" in env.get("PLATFORM"): - PLATFORMFW_DIR = join( - "$PIOPACKAGES_DIR", - "framework-arduinointel" - ) - - if BOARD_CORELIBDIRNAME == "arc32": - env.Prepend( - CPPPATH=[ - join("$PLATFORMFW_DIR", "system", - "libarc32_arduino101", "drivers"), - join("$PLATFORMFW_DIR", "system", - "libarc32_arduino101", "common"), - join("$PLATFORMFW_DIR", "system", - "libarc32_arduino101", "framework", "include"), - join("$PLATFORMFW_DIR", "system", - "libarc32_arduino101", "bootcode"), - join("$BUILD_DIR", "IntelDrivers") - ] - ) - - env.Prepend( - LIBPATH=[ - join( - "$PLATFORMFW_DIR", "variants", - "${BOARD_OPTIONS['build']['variant']}" - ), - join( - "$PLATFORMFW_DIR", "variants", - "${BOARD_OPTIONS['build']['variant']}", - "linker_scripts" - ) - ] - ) - -env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR) - -# -# Lookup for specific core's libraries -# - -if isdir(join(env.subst("$PLATFORMFW_DIR"), "libraries", "__cores__", - BOARD_CORELIBDIRNAME)): - lib_dirs = env.get("LIBSOURCE_DIRS") - lib_dirs.insert( - lib_dirs.index(join("$PLATFORMFW_DIR", "libraries")), - join(PLATFORMFW_DIR, "libraries", "__cores__", BOARD_CORELIBDIRNAME) - ) - env.Replace( - LIBSOURCE_DIRS=lib_dirs - ) - -# -# Base -# - -ARDUINO_VERSION = int( - open(join(env.subst("$PLATFORMFW_DIR"), - "version.txt")).read().replace(".", "").strip()) - -# usb flags -ARDUINO_USBDEFINES = [] -if "usb_product" in BOARD_BUILDOPTS: - ARDUINO_USBDEFINES = [ - "USB_VID=${BOARD_OPTIONS['build']['hwids'][0][0]}", - "USB_PID=${BOARD_OPTIONS['build']['hwids'][0][1]}", - 'USB_PRODUCT=\\"%s\\"' % (env.subst( - "${BOARD_OPTIONS['build']['usb_product']}").replace('"', "")), - 'USB_MANUFACTURER=\\"%s\\"' % (env.subst( - "${BOARD_OPTIONS['vendor']}").replace('"', "")) - ] - -if env.get("PLATFORM") == "teensy": - ARDUINO_USBDEFINES += [ - "ARDUINO=10600", - "TEENSYDUINO=%d" % ARDUINO_VERSION - ] - - USB_FLAGS = ( - "USB_HID", - "USB_SERIAL_HID", - "USB_DISK", - "USB_DISK_SDFLASH", - "USB_MIDI", - "USB_RAWHID", - "USB_FLIGHTSIM", - "USB_DISABLED" - ) - - if not any(f in env.get("BUILD_FLAGS", []) for f in USB_FLAGS): - env.Append(CPPDEFINES=["USB_SERIAL"]) -else: - ARDUINO_USBDEFINES += ["ARDUINO=%d" % ARDUINO_VERSION] - -env.Append( - CPPDEFINES=ARDUINO_USBDEFINES, - - CPPPATH=[ - join("$BUILD_DIR", "FrameworkArduino") - ] -) - -# -# Atmel SAM platform -# - -if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam": - env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkCMSISInc"), - join( - "$PLATFORMFW_DIR", "system", - "CMSIS%s" % ( - "_ORG" if BOARD_CORELIBDIRNAME.endswith("_org") else ""), - "CMSIS", "Include" - ) - ) - env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkDeviceInc"), - join( - "$PLATFORMFW_DIR", "system", - "CMSIS%s" % ( - "_ORG" if BOARD_CORELIBDIRNAME.endswith("_org") else ""), - "Device", "ATMEL" - ) - ) - env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkLibSam"), - join("$PLATFORMFW_DIR", "system", "libsam") - ) - - env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkArduinoInc"), - join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}") - ) - env.Append( - CPPPATH=[ - join("$BUILD_DIR", "FrameworkCMSISInc"), - join("$BUILD_DIR", "FrameworkLibSam"), - join("$BUILD_DIR", "FrameworkLibSam", "include"), - join("$BUILD_DIR", "FrameworkDeviceInc"), - join( - "$BUILD_DIR", - "FrameworkDeviceInc", - "${BOARD_OPTIONS['build']['mcu'][3:]}", - "include" - ) - ], - - LIBPATH=[ - join( - "$PLATFORMFW_DIR", - "variants", - "${BOARD_OPTIONS['build']['variant']}", - "linker_scripts", - "gcc" - ) - ] - ) - - # search relative includes in lib SAM directories - core_dir = join(env.subst("$PLATFORMFW_DIR"), "system", "libsam") - for root, _, files in walk(core_dir): - for lib_file in files: - file_path = join(root, lib_file) - if not isfile(file_path): - continue - content = None - content_changed = False - with open(file_path) as fp: - content = fp.read() - if '#include "../' in content: - content_changed = True - content = content.replace('#include "../', '#include "') - if not content_changed: - continue - with open(file_path, "w") as fp: - fp.write(content) - -# -# Teensy platform -# - -# Teensy 2.x Core -if BOARD_BUILDOPTS.get("core", None) == "teensy": - # search relative includes in teensy directories - core_dir = join(env.get("PIOHOME_DIR"), "packages", - "framework-arduinoteensy", "cores", "teensy") - for item in sorted(listdir(core_dir)): - file_path = join(core_dir, item) - if not isfile(file_path): - continue - content = None - content_changed = False - with open(file_path) as fp: - content = fp.read() - if '#include "../' in content: - content_changed = True - content = content.replace('#include "../', '#include "') - if not content_changed: - continue - with open(file_path, "w") as fp: - fp.write(content) - - env.Append(CPPPATH=[join("$PLATFORMFW_DIR", "cores")]) - -# -# Target: Build Core Library -# - -libs = [] - -if "variant" in BOARD_BUILDOPTS: - env.Append( - CPPPATH=[ - join("$BUILD_DIR", "FrameworkArduinoVariant") - ] - ) - libs.append(env.BuildLibrary( - join("$BUILD_DIR", "FrameworkArduinoVariant"), - join("$PLATFORMFW_DIR", "variants", - "${BOARD_OPTIONS['build']['variant']}") - )) - -envsafe = env.Clone() - -if BOARD_BUILDOPTS.get("core", None) == "teensy3": - libs.append("arm_cortex%sl_math" % ( - "M4" if BOARD_BUILDOPTS.get("cpu") == "cortex-m4" else "M0")) - -if env.subst("$BOARD") == "genuino101": - libs.append("libarc32drv_arduino101") - -libs.append(envsafe.BuildLibrary( - join("$BUILD_DIR", "FrameworkArduino"), - join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}") -)) - -if "sam3x8e" in BOARD_BUILDOPTS.get("mcu", ""): - env.Append( - LIBPATH=[ - join("$PLATFORMFW_DIR", "variants", - "${BOARD_OPTIONS['build']['variant']}") - ] - ) - - libs.append("sam_sam3x8e_gcc_rel") - -env.Prepend(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/cmsis.py b/platformio/builder/scripts/frameworks/cmsis.py deleted file mode 100644 index e0ea99d5..00000000 --- a/platformio/builder/scripts/frameworks/cmsis.py +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -CMSIS - -The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a -vendor-independent hardware abstraction layer for the Cortex-M processor -series and specifies debugger interfaces. The CMSIS enables consistent and -simple software interfaces to the processor for interface peripherals, -real-time operating systems, and middleware. It simplifies software -re-use, reducing the learning curve for new microcontroller developers -and cutting the time-to-market for devices. - -http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php -""" - -from os.path import isfile, join - -from SCons.Script import DefaultEnvironment - -env = DefaultEnvironment() - -env.Replace( - PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-cmsis") -) - -env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkCMSIS"), - join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}") -) - -env.Append( - CPPPATH=[ - join("$BUILD_DIR", "FrameworkCMSIS"), - join("$BUILD_DIR", "FrameworkCMSISCommon"), - join("$BUILD_DIR", "FrameworkCMSISVariant") - ] -) - -envsafe = env.Clone() - -# -# Target: Build Core Library -# - -# use mbed ldscript with bootloader section -ldscript = env.get("BOARD_OPTIONS", {}).get("build", {}).get("ldscript") -if not isfile(join(env.subst("$PIOPACKAGES_DIR"), "ldscripts", ldscript)): - if "mbed" in env.get("BOARD_OPTIONS", {}).get("frameworks", {}): - env.Append( - LINKFLAGS=[ - '-Wl,-T"%s"' % - join( - "$PIOPACKAGES_DIR", "framework-mbed", "variant", - env.subst("$BOARD").upper(), "mbed", - "TARGET_%s" % env.subst( - "$BOARD").upper(), "TOOLCHAIN_GCC_ARM", - "%s.ld" % ldscript.upper()[:-3] - ) - ] - ) - -libs = [] -libs.append(envsafe.BuildLibrary( - join("$BUILD_DIR", "FrameworkCMSISVariant"), - join( - "$PLATFORMFW_DIR", "variants", - env.subst("${BOARD_OPTIONS['build']['variant']}")[0:7], - "${BOARD_OPTIONS['build']['variant']}" - ) -)) - -libs.append(envsafe.BuildLibrary( - join("$BUILD_DIR", "FrameworkCMSISCommon"), - join( - "$PLATFORMFW_DIR", "variants", - env.subst("${BOARD_OPTIONS['build']['variant']}")[0:7], "common" - ) -)) - -env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/energia.py b/platformio/builder/scripts/frameworks/energia.py deleted file mode 100644 index 24bc9760..00000000 --- a/platformio/builder/scripts/frameworks/energia.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -Energia - -Energia Wiring-based framework enables pretty much anyone to start easily -creating microcontroller-based projects and applications. Its easy-to-use -libraries and functions provide developers of all experience levels to start -blinking LEDs, buzzing buzzers and sensing sensors more quickly than ever -before. - -http://energia.nu/reference/ -""" - -from os.path import join - -from SCons.Script import DefaultEnvironment - -env = DefaultEnvironment() - -env.Replace( - PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-energia${PLATFORM[2:]}") -) - -ENERGIA_VERSION = int( - open(join(env.subst("$PLATFORMFW_DIR"), - "version.txt")).read().replace(".", "").strip()) - -# include board variant -env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkEnergiaVariant"), - join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}") -) - -env.Append( - CPPDEFINES=[ - "ARDUINO=101", - "ENERGIA=%d" % ENERGIA_VERSION - ], - CPPPATH=[ - join("$BUILD_DIR", "FrameworkEnergia"), - join("$BUILD_DIR", "FrameworkEnergiaVariant") - ] -) - -if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "lm4f": - env.Append( - LINKFLAGS=["-Wl,--entry=ResetISR"] - ) - -# -# Target: Build Core Library -# - -libs = [] - -libs.append(env.BuildLibrary( - join("$BUILD_DIR", "FrameworkEnergia"), - join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}") -)) - -env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/libopencm3.py b/platformio/builder/scripts/frameworks/libopencm3.py deleted file mode 100644 index e48e61a3..00000000 --- a/platformio/builder/scripts/frameworks/libopencm3.py +++ /dev/null @@ -1,191 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -libOpenCM3 - -The libOpenCM3 framework aims to create a free/libre/open-source -firmware library for various ARM Cortex-M0(+)/M3/M4 microcontrollers, -including ST STM32, Ti Tiva and Stellaris, NXP LPC 11xx, 13xx, 15xx, -17xx parts, Atmel SAM3, Energy Micro EFM32 and others. - -http://www.libopencm3.org/wiki/Main_Page -""" - -from __future__ import absolute_import - -import re -from os import listdir, sep, walk -from os.path import isfile, join, normpath - -from SCons.Script import DefaultEnvironment - -from platformio.util import exec_command - -env = DefaultEnvironment() - -env.Replace( - PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-libopencm3") -) - -BOARD_BUILDOPTS = env.get("BOARD_OPTIONS", {}).get("build", {}) - - -def find_ldscript(src_dir): - ldscript = None - matches = [] - for item in sorted(listdir(src_dir)): - _path = join(src_dir, item) - if not isfile(_path) or not item.endswith(".ld"): - continue - matches.append(_path) - - if len(matches) == 1: - ldscript = matches[0] - elif isfile(join(src_dir, BOARD_BUILDOPTS['ldscript'])): - ldscript = join(src_dir, BOARD_BUILDOPTS['ldscript']) - - return ldscript - - -def generate_nvic_files(): - fw_dir = env.subst("$PLATFORMFW_DIR") - for root, _, files in walk(join(fw_dir, "include", "libopencm3")): - if "irq.json" not in files or isfile(join(root, "nvic.h")): - continue - - exec_command( - ["python", join("scripts", "irq2nvic_h"), - join("." + root.replace(fw_dir, ""), - "irq.json").replace("\\", "/")], - cwd=fw_dir - ) - - -def parse_makefile_data(makefile): - data = {"includes": [], "objs": [], "vpath": ["./"]} - - with open(makefile) as f: - content = f.read() - - # fetch "includes" - re_include = re.compile(r"^include\s+([^\r\n]+)", re.M) - for match in re_include.finditer(content): - data['includes'].append(match.group(1)) - - # fetch "vpath"s - re_vpath = re.compile(r"^VPATH\s+\+?=\s+([^\r\n]+)", re.M) - for match in re_vpath.finditer(content): - data['vpath'] += match.group(1).split(":") - - # fetch obj files - objs_match = re.search( - r"^OBJS\s+\+?=\s+([^\.]+\.o\s*(?:\s+\\s+)?)+", content, re.M) - assert objs_match - data['objs'] = re.sub( - r"(OBJS|[\+=\\\s]+)", "\n", objs_match.group(0)).split() - return data - - -def get_source_files(src_dir): - mkdata = parse_makefile_data(join(src_dir, "Makefile")) - - for include in mkdata['includes']: - _mkdata = parse_makefile_data(normpath(join(src_dir, include))) - for key, value in _mkdata.iteritems(): - for v in value: - if v not in mkdata[key]: - mkdata[key].append(v) - - sources = [] - lib_root = env.subst("$PLATFORMFW_DIR") - for obj_file in mkdata['objs']: - src_file = obj_file[:-1] + "c" - for search_path in mkdata['vpath']: - src_path = normpath(join(src_dir, search_path, src_file)) - if isfile(src_path): - sources.append(join("$BUILD_DIR", "FrameworkLibOpenCM3", - src_path.replace(lib_root + sep, ""))) - break - return sources - - -def merge_ld_scripts(main_ld_file): - - def _include_callback(match): - included_ld_file = match.group(1) - # search included ld file in lib directories - for root, _, files in walk(env.subst(join("$PLATFORMFW_DIR", "lib"))): - if included_ld_file not in files: - continue - with open(join(root, included_ld_file)) as fp: - return fp.read() - return match.group(0) - - content = "" - with open(main_ld_file) as f: - content = f.read() - - incre = re.compile(r"^INCLUDE\s+\"?([^\.]+\.ld)\"?", re.M) - with open(main_ld_file, "w") as f: - f.write(incre.sub(_include_callback, content)) - -# -# Processing ... -# - -if BOARD_BUILDOPTS.get("core") == "lm4f": - env.Append( - CPPDEFINES=["LM4F"] - ) - -env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkLibOpenCM3Variant"), - join("$PLATFORMFW_DIR", "include") -) - -env.Append( - CPPPATH=[ - join("$BUILD_DIR", "FrameworkLibOpenCM3"), - join("$BUILD_DIR", "FrameworkLibOpenCM3Variant") - ] -) - -root_dir = env.subst( - join("$PLATFORMFW_DIR", "lib", BOARD_BUILDOPTS.get("core"))) -if BOARD_BUILDOPTS.get("core") == "stm32": - root_dir = join(root_dir, BOARD_BUILDOPTS.get("variant")[5:7]) - -ldscript_path = find_ldscript(root_dir) -if ldscript_path: - merge_ld_scripts(ldscript_path) -generate_nvic_files() - -# override ldscript by libopencm3 -assert "LDSCRIPT_PATH" in env -env.Replace( - LDSCRIPT_PATH=ldscript_path -) - -libs = [] -env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkLibOpenCM3"), - "$PLATFORMFW_DIR" -) -libs.append(env.Library( - join("$BUILD_DIR", "FrameworkLibOpenCM3"), - get_source_files(root_dir) -)) - -env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/mbed.py b/platformio/builder/scripts/frameworks/mbed.py deleted file mode 100644 index 76aca7fa..00000000 --- a/platformio/builder/scripts/frameworks/mbed.py +++ /dev/null @@ -1,349 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -mbed - -The mbed framework The mbed SDK has been designed to provide enough -hardware abstraction to be intuitive and concise, yet powerful enough to -build complex projects. It is built on the low-level ARM CMSIS APIs, -allowing you to code down to the metal if needed. In addition to RTOS, -USB and Networking libraries, a cookbook of hundreds of reusable -peripheral and module libraries have been built on top of the SDK by -the mbed Developer Community. - -http://mbed.org/ -""" - -from __future__ import print_function - -import json -import re -import sys -import xml.etree.ElementTree as ElementTree -from binascii import crc32 -from os import walk -from os.path import basename, isfile, join, normpath - -from SCons.Script import DefaultEnvironment - -env = DefaultEnvironment() - -BOARD_OPTS = env.get("BOARD_OPTIONS", {}).get("build", {}) - -env.Replace( - PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-mbed") -) - -MBED_VARIANTS = { - "blueboard_lpc11u24": "LPC11U24", - "dipcortexm0": "LPC11U24", - "seeeduinoArchPro": "ARCH_PRO", - "seeedArchMax": "ARCH_MAX", - "ubloxc027": "UBLOX_C027", - "lpc1114fn28": "LPC1114", - "lpc11u35": "LPC11U35_401", - "mbuino": "LPC11U24", - "nrf51_mkit": "NRF51822", - "seeedTinyBLE": "SEEED_TINY_BLE", - "redBearLab": "RBLAB_NRF51822", - "nrf51-dt": "NRF51_DK", - "redBearLabBLENano": "RBLAB_BLENANO", - "wallBotBLE": "NRF51822", - "frdm_kl25z": "KL25Z", - "frdm_kl46z": "KL46Z", - "frdm_k64f": "K64F", - "frdm_kl05z": "KL05Z", - "frdm_k20d50m": "K20D50M", - "frdm_k22f": "K22F", - "teensy31": "TEENSY3_1", - "dfcm_nnn40": "DELTA_DFCM_NNN40", - "samr21_xpro": "SAMR21G18A", - "saml21_xpro_b": "SAML21J18A", - "samd21_xpro": "SAMD21J18A", - "bbcmicrobit": "NRF51_MICROBIT" -} - -MBED_LIBS_MAP = { - "dsp": {"ar": ["dsp", "cmsis_dsp"]}, - "eth": {"ar": ["eth"], "deps": ["rtos"]}, - "fat": {"ar": ["fat"]}, - "rtos": {"ar": ["rtos", "rtx"]}, - "usb": {"ar": ["USBDevice"]}, - "usb_host": {"ar": ["USBHost"]} -} - - -def get_mbedlib_includes(): - result = [] - for lib in MBED_LIBS_MAP: - includes = [] - lib_dir = join(env.subst("$PLATFORMFW_DIR"), "libs", lib) - for _, _, files in walk(lib_dir): - for libfile in files: - if libfile.endswith(".h"): - includes.append(libfile) - result.append((lib, set(includes))) - return result - - -def get_used_mbedlibs(): - re_includes = re.compile(r"^(#include\s+(?:\<|\")([^\r\n\"]+))", - re.M | re.I) - srcincs = [] - for root, _, files in walk(env.get("PROJECTSRC_DIR")): - for pfile in files: - if not any([pfile.endswith(ext) for ext in (".h", ".c", ".cpp")]): - continue - with open(join(root, pfile)) as fp: - srcincs.extend([i[1] for i in re_includes.findall(fp.read())]) - srcincs = set(srcincs) - - result = {} - for libname, libincs in get_mbedlib_includes(): - if libincs & srcincs and libname not in result: - result[libname] = MBED_LIBS_MAP[libname] - - return result - - -def add_mbedlib(libname, libar): - if libar in env.get("LIBS"): - return - - lib_dir = join(env.subst("$PLATFORMFW_DIR"), "libs", libname) - if not isfile(join(lib_dir, "TARGET_%s" % variant, - "TOOLCHAIN_GCC_ARM", "lib%s.a" % libar)): - print( - "Warning: %s board doesn't have native support for '%s' library!" % - (env.get("BOARD"), libname), file=sys.stderr) - return - - env.Append( - LIBPATH=[ - join(env.subst("$PLATFORMFW_DIR"), "libs", libname, - "TARGET_%s" % variant, "TOOLCHAIN_GCC_ARM") - ], - LIBS=[libar] - ) - - sysincdirs = ( - "eth", - "include", - "ipv4", - "lwip-eth", - "lwip-sys" - ) - - target_map = { - "nxplpc": "NXP", - "freescalekinetis": "Freescale", - "ststm32": "STM" - } - - target_includes = ( - "TARGET_%s" % target_map.get(env.subst("$PLATFORM"), ""), - "TARGET_%s" % variant, - "TARGET_CORTEX_M" - ) - - for root, _, files in walk(lib_dir): - if (not any(f.endswith(".h") for f in files) and - basename(root) not in sysincdirs): - continue - - if "TARGET_" in root: - if all([p not in root for p in target_includes]): - continue - - var_dir = join("$BUILD_DIR", "FrameworkMbed%sInc%d" % - (libname.upper(), crc32(root))) - if var_dir in env.get("CPPPATH"): - continue - env.VariantDirWrap(var_dir, root) - env.Append(CPPPATH=[var_dir]) - - -def parse_eix_file(filename): - result = {} - paths = ( - ("CFLAGS", "./Target/Source/CC/Switch"), - ("CXXFLAGS", "./Target/Source/CPPC/Switch"), - ("CPPDEFINES", "./Target/Source/Symbols/Symbol"), - ("FILES", "./Target/Files/File"), - ("LINKFLAGS", "./Target/Source/LD/Switch"), - ("OBJFILES", "./Target/Source/Addobjects/Addobject"), - ("LIBPATH", "./Target/Linker/Librarypaths/Librarypath"), - ("STDLIBS", "./Target/Source/Syslibs/Library"), - ("LDSCRIPT_PATH", "./Target/Source/Scriptfile"), - ("CPPPATH", "./Target/Compiler/Includepaths/Includepath") - ) - - tree = ElementTree.parse(filename) - - for (key, path) in paths: - if key not in result: - result[key] = [] - - for node in tree.findall(path): - _nkeys = node.keys() - result[key].append( - node.get(_nkeys[0]) if len(_nkeys) == 1 else node.attrib) - - if "LINKFLAGS" in result: - for i, flag in enumerate(result["LINKFLAGS"]): - if flag.startswith("-u "): - result["LINKFLAGS"][i] = result["LINKFLAGS"][i].split(" ") - - return result - - -def get_build_flags(data): - flags = {} - cflags = set(data.get("CFLAGS", [])) - cxxflags = set(data.get("CXXFLAGS", [])) - ccflags = set(cflags & cxxflags) - flags['CCFLAGS'] = list(ccflags) - flags['CXXFLAGS'] = list(cxxflags - ccflags) - flags['CFLAGS'] = list(cflags - ccflags) - return flags - - -def _mbed_whole_archive_hook(libs_): - if (not isinstance(libs_, list) or - env.subst("$PLATFORM") == "nordicnrf51"): - return libs_ - - _dynlibs = [] - _stlibs = [] - for l_ in libs_: - if isinstance(l_, basestring): - _stlibs.append(l_) - else: - _dynlibs.append(l_) - - libs_ = [] - if _dynlibs: - libs_.append("-Wl,-whole-archive") - libs_.extend(_dynlibs) - libs_.append("-Wl,-no-whole-archive") - libs_.extend(_stlibs) - - return libs_ - - -board_type = env.subst("$BOARD") -variant = MBED_VARIANTS[ - board_type] if board_type in MBED_VARIANTS else board_type.upper() -eixdata = parse_eix_file( - join(env.subst("$PLATFORMFW_DIR"), "variant", variant, "%s.eix" % variant)) - -build_flags = get_build_flags(eixdata) -variant_dir = join("$PLATFORMFW_DIR", "variant", variant) - - -def _find_soft_device_hex(): - - if not isfile(join(env.subst("$PLATFORMFW_DIR"), "targets.json")): - return None - - with open(join(env.subst("$PLATFORMFW_DIR"), "targets.json")) as fp: - data = json.load(fp) - - def _find_hex(target_name): - assert isinstance(data, dict) - if target_name not in data: - return None - target = data[target_name] - if "EXPECTED_SOFTDEVICES_WITH_OFFSETS" not in target: - try: - return _find_hex(target.get("inherits", [])[0]) - except IndexError: - return None - else: - return target['EXPECTED_SOFTDEVICES_WITH_OFFSETS'][0]['name'] - - softdevice_name = _find_hex(variant) - if softdevice_name: - for root, _, files in walk(env.subst(variant_dir)): - if softdevice_name in files: - return join(root, softdevice_name) - - env.Exit("Error: Cannot find SoftDevice binary file for your board!") - - -env.Replace( - _mbed_whole_archive_hook=_mbed_whole_archive_hook, - _LIBFLAGS="${_mbed_whole_archive_hook(%s)}" % env.get("_LIBFLAGS")[2:-1], - CCFLAGS=build_flags.get("CCFLAGS", []), - CFLAGS=build_flags.get("CFLAGS", []), - CXXFLAGS=build_flags.get("CXXFLAGS", []), - LINKFLAGS=eixdata.get("LINKFLAGS", []), - CPPDEFINES=[define for define in eixdata.get("CPPDEFINES", [])], - LDSCRIPT_PATH=normpath( - join(variant_dir, eixdata.get("LDSCRIPT_PATH")[0])) -) - - -if env.get("PLATFORM") == "nordicnrf51": - env.Append(SOFTDEVICEHEX=_find_soft_device_hex()) - -# restore external build flags -env.ProcessFlags( - env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags")) -# remove base flags -env.ProcessUnFlags(env.get("BUILD_UNFLAGS")) -# apply user flags -env.ProcessFlags(env.get("BUILD_FLAGS")) - -# Hook for K64F and K22F -if board_type in ("frdm_k22f", "frdm_k64f"): - env.Append( - LINKFLAGS=["-Wl,--start-group"] - ) - -for lib_path in eixdata.get("CPPPATH"): - _vdir = join("$BUILD_DIR", "FrameworkMbedInc%d" % crc32(lib_path)) - env.VariantDirWrap(_vdir, join(variant_dir, lib_path)) - env.Append(CPPPATH=[_vdir]) - -env.Append( - LIBPATH=[join(variant_dir, lib_path) - for lib_path in eixdata.get("LIBPATH", []) - if lib_path.startswith("mbed")] -) - -# -# Target: Build mbed Library -# - -libs = [l for l in eixdata.get("STDLIBS", []) if l not in env.get("LIBS", [])] -libs.extend(["mbed", "c", "gcc"]) - -libs.append(env.Library( - join("$BUILD_DIR", "FrameworkMbed"), - [join(variant_dir, f) - for f in eixdata.get("OBJFILES", [])] -)) - -env.Prepend(LIBS=libs) - -for _libname, _libdata in get_used_mbedlibs().iteritems(): - for _libar in _libdata['ar']: - add_mbedlib(_libname, _libar) - if "deps" not in _libdata: - continue - for libdep in _libdata['deps']: - for _libar in MBED_LIBS_MAP[libdep]['ar']: - add_mbedlib(libdep, _libar) diff --git a/platformio/builder/scripts/frameworks/spl.py b/platformio/builder/scripts/frameworks/spl.py deleted file mode 100644 index e521ae9f..00000000 --- a/platformio/builder/scripts/frameworks/spl.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -SPL - -The ST Standard Peripheral Library provides a set of functions for -handling the peripherals on the STM32 Cortex-M3 family. -The idea is to save the user (the new user, in particular) having to deal -directly with the registers. - -http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743?sc=stm32embeddedsoftware -""" - -from os.path import isfile, join - -from SCons.Script import DefaultEnvironment - -env = DefaultEnvironment() - -env.Replace( - PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-spl") -) - -env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkCMSIS"), - join("$PLATFORMFW_DIR", "${BOARD_OPTIONS['build']['core']}", - "cmsis", "cores", "${BOARD_OPTIONS['build']['core']}") -) - -env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkSPLInc"), - join( - "$PLATFORMFW_DIR", "${BOARD_OPTIONS['build']['core']}", "spl", - "variants", env.subst("${BOARD_OPTIONS['build']['variant']}")[0:7], - "inc" - ) -) - -env.Append( - CPPPATH=[ - join("$BUILD_DIR", "FrameworkCMSIS"), - join("$BUILD_DIR", "FrameworkCMSISVariant"), - join("$BUILD_DIR", "FrameworkSPLInc"), - join("$BUILD_DIR", "FrameworkSPL") - ] -) - -envsafe = env.Clone() - -envsafe.Append( - CPPPATH=["$BUILDSRC_DIR"], - CPPDEFINES=[ - "USE_STDPERIPH_DRIVER" - ] -) - -# -# Target: Build SPL Library -# - -# use mbed ldscript with bootloader section -ldscript = env.get("BOARD_OPTIONS", {}).get("build", {}).get("ldscript") -if not isfile(join(env.subst("$PIOPACKAGES_DIR"), "ldscripts", ldscript)): - if "mbed" in env.get("BOARD_OPTIONS", {}).get("frameworks", {}): - env.Append( - LINKFLAGS=[ - '-Wl,-T"%s"' % - join( - "$PIOPACKAGES_DIR", "framework-mbed", "variant", - env.subst("$BOARD").upper(), "mbed", - "TARGET_%s" % env.subst( - "$BOARD").upper(), "TOOLCHAIN_GCC_ARM", - "%s.ld" % ldscript.upper()[:-3] - ) - ] - ) - -extra_flags = env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags") -src_filter_patterns = ["+<*>"] -if "STM32F40_41xxx" in extra_flags: - src_filter_patterns += ["-"] -if "STM32F427_437xx" in extra_flags: - src_filter_patterns += ["-"] -elif "STM32F303xC" in extra_flags: - src_filter_patterns += ["-"] -elif "STM32L1XX_MD" in extra_flags: - src_filter_patterns += ["-"] - -libs = [] - -libs.append(envsafe.BuildLibrary( - join("$BUILD_DIR", "FrameworkCMSISVariant"), - join( - "$PLATFORMFW_DIR", "${BOARD_OPTIONS['build']['core']}", "cmsis", - "variants", env.subst("${BOARD_OPTIONS['build']['variant']}")[0:7] - ) -)) - -libs.append(envsafe.BuildLibrary( - join("$BUILD_DIR", "FrameworkSPL"), - join("$PLATFORMFW_DIR", "${BOARD_OPTIONS['build']['core']}", - "spl", "variants", - env.subst("${BOARD_OPTIONS['build']['variant']}")[0:7], "src"), - src_filter=" ".join(src_filter_patterns) -)) - -env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/wiringpi.py b/platformio/builder/scripts/frameworks/wiringpi.py deleted file mode 100644 index c17b4801..00000000 --- a/platformio/builder/scripts/frameworks/wiringpi.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -WiringPi - -WiringPi is a GPIO access library written in C for the BCM2835 used in the -Raspberry Pi. It's designed to be familiar to people who have used the Arduino -"wiring" system. - -http://wiringpi.com -""" - -from os.path import join - -from SCons.Script import DefaultEnvironment - -env = DefaultEnvironment() - -env.Replace( - CPPFLAGS=[ - "-O2", - "-Wformat=2", - "-Wall", - "-Winline", - "-pipe", - "-fPIC" - ], - - LIBS=["pthread"] -) - -env.Append( - CPPDEFINES=[ - "_GNU_SOURCE" - ], - - CPPPATH=[ - join("$BUILD_DIR", "FrameworkWiringPi") - ] -) - - -# -# Target: Build Core Library -# - -libs = [] -libs.append(env.BuildLibrary( - join("$BUILD_DIR", "FrameworkWiringPi"), - join("$PIOPACKAGES_DIR", "framework-wiringpi", "wiringPi") -)) - -env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/freescalekinetis.py b/platformio/builder/scripts/freescalekinetis.py deleted file mode 100644 index af832d00..00000000 --- a/platformio/builder/scripts/freescalekinetis.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Freescale Kinetis series ARM microcontrollers. -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") -else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default .bin file -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/intel_arc32.py b/platformio/builder/scripts/intel_arc32.py deleted file mode 100644 index f654234f..00000000 --- a/platformio/builder/scripts/intel_arc32.py +++ /dev/null @@ -1,196 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Intel ARC32 microcontrollers -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, - DefaultEnvironment) - -env = DefaultEnvironment() - - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - - if env.get("BOARD_OPTIONS", {}).get("upload", {}).get( - "use_1200bps_touch", False): - env.TouchSerialPort("$UPLOAD_PORT", 1200) - - -env.Replace( - AR="arc-elf32-ar", - AS="arc-elf32-as", - CC="arc-elf32-gcc", - CXX="arc-elf32-g++", - OBJCOPY="arc-elf32-objcopy", - RANLIB="arc-elf32-ranlib", - SIZETOOL="arc-elf32-size", - - ARFLAGS=["rcs"], - - ASFLAGS=["-x", "assembler-with-cpp"], - - CCFLAGS=[ - "-g", - "-Os", - "-ffunction-sections", - "-fdata-sections", - "-Wall", - "-mlittle-endian", - "-mcpu=${BOARD_OPTIONS['build']['cpu']}", - "-fno-reorder-functions", - "-fno-asynchronous-unwind-tables", - "-fno-omit-frame-pointer", - "-fno-defer-pop", - "-Wno-unused-but-set-variable", - "-Wno-main", - "-ffreestanding", - "-fno-stack-protector", - "-mno-sdata", - "-fsigned-char" - ], - - CXXFLAGS=[ - "-fno-rtti", - "-std=c++11", - "-fno-exceptions" - ], - - CPPDEFINES=[ - "F_CPU=$BOARD_F_CPU", - "ARDUINO_ARC32_TOOLS", - "__CPU_ARC__", - "CLOCK_SPEED=%d" % ( - int(env.subst("${BOARD_OPTIONS['build']['f_cpu']}").replace( - "L", ""))/1000000), - "CONFIG_SOC_GPIO_32", - "CONFIG_SOC_GPIO_AON", - "INFRA_MULTI_CPU_SUPPORT", - "CFW_MULTI_CPU_SUPPORT", - "HAS_SHARED_MEM" - ], - - LINKFLAGS=[ - "-Os", - "-Wl,--gc-sections", - "-Wl,-X", - "-Wl,-N", - "-Wl,-mcpu=${BOARD_OPTIONS['build']['cpu']}", - "-Wl,-marcelf", - "-static", - "-nostdlib", - "-nodefaultlibs", - "-nostartfiles", - "-Wl,--whole-archive", - "-larc32drv_arduino101", - "-Wl,--no-whole-archive" - ], - - LIBS=["nsim", "c", "m", "gcc"], - - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - - UPLOADER=join("$PIOPACKAGES_DIR", "tool-arduino101load", "arduino101load"), - UPLOADERFLAGS=[ - '"$UPLOAD_PORT"' - ], - DFUUTIL=join("$PIOPACKAGES_DIR", "tool-arduino101load", "dfu-util"), - UPLOADCMD='"$UPLOADER" "$DFUUTIL" $SOURCES $UPLOADERFLAGS verbose', - - PROGNAME="firmware", - PROGSUFFIX=".elf" -) - - -env.Append( - ASFLAGS=env.get("CCFLAGS", [])[:], - - BUILDERS=dict( - ElfToBin=Builder( - action=" ".join([ - "$OBJCOPY", - "-S", - "-O", - "binary", - "-R", - ".note", - "-R", - ".comment", - "-R", - "COMMON", - "-R", - ".eh_frame", - "$SOURCES", - "$TARGET"]), - suffix=".bin" - ), - ElfToHex=Builder( - action=" ".join([ - "$OBJCOPY", - "-S", - "-O", - "binary", - "-R", - ".note", - "-R", - ".comment", - "-R", - "COMMON", - "-R", - ".eh_frame", - "$SOURCES", - "$TARGET"]), - suffix=".hex" - ) - ) -) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") -else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload firmware -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, - [env.AutodetectUploadPort, BeforeUpload, "$UPLOADCMD"]) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/lattice_ice40.py b/platformio/builder/scripts/lattice_ice40.py deleted file mode 100755 index c2059a11..00000000 --- a/platformio/builder/scripts/lattice_ice40.py +++ /dev/null @@ -1,149 +0,0 @@ -""" - Build script for lattice ice40 FPGAs - latticeice40-builder.py -""" -import os -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, - DefaultEnvironment, Environment, Exit, GetOption, - Glob) - -env = DefaultEnvironment() -env.Replace(PROGNAME="hardware") -env.Append(SIMULNAME="simulation") - -# -- Get the local folder in which the icestorm tools should be installed -piopackages_dir = env.subst('$PIOPACKAGES_DIR') -bin_dir = join(piopackages_dir, 'toolchain-icestorm', 'bin') - -# -- Add this path to the PATH env variable. First the building tools will be -# -- searched in the local PATH. If they are not founde, the global ones will -# -- be executed (if installed) -env.PrependENVPath('PATH', bin_dir) - -# -- Target name for synthesis -TARGET = join(env['BUILD_DIR'], env['PROGNAME']) - -# -- Target name for simulation -# TARGET_SIM = join(env['PROJECT_DIR'], env['SIMULNAME']) - -# -- Get a list of all the verilog files in the src folfer, in ASCII, with -# -- the full path. All these files are used for the simulation -v_nodes = Glob(join(env['PROJECTSRC_DIR'], '*.v')) -src_sim = [str(f) for f in v_nodes] - -# --------- Get the Testbench file (there should be only 1) -# -- Create a list with all the files finished in _tb.v. It should contain -# -- the test bench -list_tb = [f for f in src_sim if f[-5:].upper() == "_TB.V"] - -if len(list_tb) > 1: - print "---> WARNING: More than one testbenches used" - -# -- Error checking -try: - testbench = list_tb[0] - -# -- there is no testbench -except IndexError: - testbench = None - -if 'sim' in COMMAND_LINE_TARGETS: - if testbench is None: - print "ERROR!!! NO testbench found for simulation" - Exit(1) - - # -- Simulation name - testbench_file = os.path.split(testbench)[-1] - SIMULNAME, ext = os.path.splitext(testbench_file) -else: - SIMULNAME = '' - - -TARGET_SIM = join(env.subst('$BUILD_DIR'), SIMULNAME) - -# -------- Get the synthesis files. They are ALL the files except the -# -------- testbench -src_synth = [f for f in src_sim if f not in list_tb] - -# -- For debugging -print "Testbench: %s" % testbench - -# -- Get the PCF file -src_dir = env.subst('$PROJECTSRC_DIR') -PCFs = join(src_dir, '*.pcf') -PCF_list = Glob(PCFs) - -try: - PCF = PCF_list[0] -except IndexError: - print "\n--------> ERROR: no .pcf file found <----------\n" - Exit(2) - -# -- Debug -print "----> PCF Found: %s" % PCF - -# -- Builder 1 (.v --> .blif) -synth = Builder(action='yosys -p \"synth_ice40 -blif %s.blif\" \ - $SOURCES' % TARGET, - suffix='.blif', - src_suffix='.v') - -# -- Builder 2 (.blif --> .asc) -pnr = Builder(action='arachne-pnr -d 1k -o $TARGET -p %s \ - $SOURCE' % PCF, - suffix='.asc', - src_suffix='.blif') - -# -- Builder 3 (.asc --> .bin) -bitstream = Builder(action='icepack $SOURCE $TARGET', - suffix='.bin', - src_suffix='.asc') - -# -- Builder 4 (.asc --> .rpt) -time_rpt = Builder(action='icetime -mtr $TARGET $SOURCE', - suffix='.rpt', - src_suffix='.asc') - -env.Append(BUILDERS={'Synth': synth, 'PnR': pnr, 'Bin': bitstream, - 'Time': time_rpt}) - -blif = env.Synth(TARGET, [src_synth]) -asc = env.PnR(TARGET, [blif, PCF]) -binf = env.Bin(TARGET, asc) - -upload = env.Alias('upload', binf, 'iceprog ' + ' $SOURCE') -AlwaysBuild(upload) - -# -- Target for calculating the time (.rpt) -# rpt = env.Time(asc) -t = env.Alias('time', env.Time('time.rpt', asc)) - -# -------------------- Simulation ------------------ -# -- Constructor para generar simulacion: icarus Verilog -iverilog = Builder(action='iverilog -o $TARGET $SOURCES ', - suffix='.out', - src_suffix='.v') - -vcd = Builder(action=' $SOURCE', - suffix='.vcd', src_suffix='.out') - -simenv = Environment(BUILDERS={'IVerilog': iverilog, 'VCD': vcd}, - ENV=os.environ) - -out = simenv.IVerilog(TARGET_SIM, src_sim) -vcd_file = simenv.VCD(SIMULNAME, out) - -waves = simenv.Alias('sim', vcd_file, 'gtkwave ' + - join(env['PROJECT_DIR'], "%s " % vcd_file[0]) + - join(env['PROJECTSRC_DIR'], SIMULNAME) + - '.gtkw') -AlwaysBuild(waves) - -Default([binf]) - -# -- These is for cleaning the files generated using the alias targets -if GetOption('clean'): - env.Default([t]) - simenv.Default([out, vcd_file]) diff --git a/platformio/builder/scripts/linux_arm.py b/platformio/builder/scripts/linux_arm.py deleted file mode 100644 index 15e73370..00000000 --- a/platformio/builder/scripts/linux_arm.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Linux ARM -""" - -from SCons.Script import AlwaysBuild, Default, DefaultEnvironment - -from platformio.util import get_systype - -env = DefaultEnvironment() - -env.Replace( - _BINPREFIX="", - AR="${_BINPREFIX}ar", - AS="${_BINPREFIX}as", - CC="${_BINPREFIX}gcc", - CXX="${_BINPREFIX}g++", - OBJCOPY="${_BINPREFIX}objcopy", - RANLIB="${_BINPREFIX}ranlib", - SIZETOOL="${_BINPREFIX}size", - - SIZEPRINTCMD='"$SIZETOOL" $SOURCES' -) - -if get_systype() == "darwin_x86_64": - env.Replace( - _BINPREFIX="arm-linux-gnueabihf-" - ) - -# -# Target: Build executable program -# - -target_bin = env.BuildProgram() - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Define targets -# - -Default([target_bin]) diff --git a/platformio/builder/scripts/linux_i686.py b/platformio/builder/scripts/linux_i686.py deleted file mode 100644 index b9aaecde..00000000 --- a/platformio/builder/scripts/linux_i686.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Linux Linux i686 / 32-bit -""" - -from SCons.Script import AlwaysBuild, Default, DefaultEnvironment - -from platformio.util import get_systype - -env = DefaultEnvironment() - -env.Replace( - _BINPREFIX="", - AR="${_BINPREFIX}ar", - AS="${_BINPREFIX}as", - CC="${_BINPREFIX}gcc", - CXX="${_BINPREFIX}g++", - OBJCOPY="${_BINPREFIX}objcopy", - RANLIB="${_BINPREFIX}ranlib", - SIZETOOL="${_BINPREFIX}size", - - SIZEPRINTCMD='"$SIZETOOL" $SOURCES' -) - -if get_systype() == "darwin_x86_64": - env.Replace( - _BINPREFIX="i586-pc-linux-" - ) - -# -# Target: Build executable program -# - -target_bin = env.BuildProgram() - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Define targets -# - -Default([target_bin]) diff --git a/platformio/builder/scripts/linux_x86_64.py b/platformio/builder/scripts/linux_x86_64.py deleted file mode 100644 index e837d2a5..00000000 --- a/platformio/builder/scripts/linux_x86_64.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Linux Linux x64_64 / 64-bit -""" - -from SCons.Script import AlwaysBuild, Default, DefaultEnvironment - -from platformio.util import get_systype - -env = DefaultEnvironment() - -env.Replace( - _BINPREFIX="", - AR="${_BINPREFIX}ar", - AS="${_BINPREFIX}as", - CC="${_BINPREFIX}gcc", - CXX="${_BINPREFIX}g++", - OBJCOPY="${_BINPREFIX}objcopy", - RANLIB="${_BINPREFIX}ranlib", - SIZETOOL="${_BINPREFIX}size", - - SIZEPRINTCMD='"$SIZETOOL" $SOURCES' -) - -if get_systype() == "darwin_x86_64": - env.Replace( - _BINPREFIX="x86_64-pc-linux-" - ) - -# -# Target: Build executable program -# - -target_bin = env.BuildProgram() - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Define targets -# - -Default([target_bin]) diff --git a/platformio/builder/scripts/microchippic32.py b/platformio/builder/scripts/microchippic32.py deleted file mode 100644 index da44457f..00000000 --- a/platformio/builder/scripts/microchippic32.py +++ /dev/null @@ -1,190 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Microchip PIC32 microcontrollers -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, - DefaultEnvironment) - -env = DefaultEnvironment() - -env.Replace( - AR="pic32-ar", - AS="pic32-as", - CC="pic32-gcc", - CXX="pic32-g++", - OBJCOPY="pic32-objcopy", - RANLIB="pic32-ranlib", - SIZETOOL="pic32-size", - - ARFLAGS=["rcs"], - - ASFLAGS=[ - "-g1", - "-O2", - "-Wa,--gdwarf-2", - "-mprocessor=$BOARD_MCU" - ], - - CCFLAGS=[ - "-w", - "-g", - "-O2", - "-MMD", - "-mdebugger", - "-mno-smart-io", - "-mprocessor=$BOARD_MCU", - "-ffunction-sections", - "-fdata-sections", - "-Wcast-align", - "-fno-short-double", - "-ftoplevel-reorder" - ], - - CXXFLAGS=["-fno-exceptions"], - - CPPDEFINES=[ - "F_CPU=$BOARD_F_CPU", - "MPIDEVER=16777998", - "MPIDE=150" - ], - - LINKFLAGS=[ - "-w", - "-Os", - "-mdebugger", - "-mprocessor=$BOARD_MCU", - "-mno-peripheral-libs", - "-nostartfiles", - "-Wl,--gc-sections", - join( - "$PLATFORMFW_DIR", - "cores", - "${BOARD_OPTIONS['build']['core']}", - "cpp-startup.S" - ), - join( - "$PLATFORMFW_DIR", - "cores", - "${BOARD_OPTIONS['build']['core']}", - "crti.S" - ) - ], - - LIBS=["m"], - - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - - UPLOADER=join("$PIOPACKAGES_DIR", "tool-pic32prog", "pic32prog"), - UPLOADERFLAGS=[ - "-b", "$UPLOAD_SPEED", - "-d", '"$UPLOAD_PORT"' - ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES', - - PROGNAME="firmware", - PROGSUFFIX=".elf" -) - -if int(env.get("BOARD_OPTIONS", {}).get( - "upload", {}).get("maximum_ram_size", 0)) < 65535: - env.Append( - ASFLAGS=["-G1024"], - CCFLAGS=["-G1024"] - ) - - -env.Append( - BUILDERS=dict( - ElfToEep=Builder( - action=" ".join([ - "$OBJCOPY", - "-O", - "ihex", - "-j", - ".eeprom", - '--set-section-flags=.eeprom="alloc,load"', - "--no-change-warnings", - "--change-section-lma", - ".eeprom=0", - "$SOURCES", - "$TARGET"]), - suffix=".eep" - ), - - ElfToHex=Builder( - action=" ".join(["pic32-bin2hex", "-a", "$SOURCES"]), suffix=".hex" - ) - ) -) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Hook: Fix option for LD script -# - -_new_linkflags = [] -for f in env['LINKFLAGS']: - if not f.startswith("-Wl,-T"): - _new_linkflags.append(f) - else: - _new_linkflags.append("-Wl,--script=%s" % f[6:]) - -env.Replace(LINKFLAGS=_new_linkflags) -env.Append( - LINKFLAGS=[ - "-Wl,--script=chipKIT-application-COMMON%s.ld" % ( - "-MZ" if "MZ" in env.get("BOARD_OPTIONS", {}).get( - "build", {}).get("mcu") else "") - ] -) - -# -# Target: Build the .hex -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.hex") -else: - target_firm = env.ElfToHex(target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload firmware -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, - [env.AutodetectUploadPort, "$UPLOADCMD"]) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/native.py b/platformio/builder/scripts/native.py deleted file mode 100644 index 41259514..00000000 --- a/platformio/builder/scripts/native.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for native platform -""" - -from SCons.Script import AlwaysBuild, Default, DefaultEnvironment - -env = DefaultEnvironment() - -env.Replace( - SIZEPRINTCMD="size $SOURCES" -) - -# -# Target: Build executable program -# - -target_bin = env.BuildProgram() - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Define targets -# - -Default([target_bin]) diff --git a/platformio/builder/scripts/nordicnrf51.py b/platformio/builder/scripts/nordicnrf51.py deleted file mode 100644 index ae4626c1..00000000 --- a/platformio/builder/scripts/nordicnrf51.py +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Nordic nRF51 series ARM microcontrollers. -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, - DefaultEnvironment, SConscript) - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - -if env.subst("$BOARD") == "rfduino": - env.Append( - CCFLAGS=["-fno-builtin"], - LINKFLAGS=["--specs=nano.specs"] - ) - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-rfdloader", "rfdloader"), - UPLOADERFLAGS=["-q", '"$UPLOAD_PORT"'], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES' - ) -else: - env.Append( - BUILDERS=dict( - MergeHex=Builder( - action=" ".join([ - join("$PIOPACKAGES_DIR", "tool-sreccat", "srec_cat"), - "$SOFTDEVICEHEX", - "-intel", - "$SOURCES", - "-intel", - "-o", - "$TARGET", - "-intel", - "--line-length=44" - ]), - suffix=".hex" - ) - ) - ) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.hex") -else: - if env.subst("$BOARD") == "rfduino": - target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) - else: - target_firm = env.MergeHex( - join("$BUILD_DIR", "firmware"), - env.ElfToHex(join("$BUILD_DIR", "userfirmware"), target_elf) - ) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default .bin file -# - -if env.subst("$BOARD") == "rfduino": - upload = env.Alias(["upload", "uploadlazy"], target_firm, - [env.AutodetectUploadPort, "$UPLOADCMD"]) -else: - upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/nxplpc.py b/platformio/builder/scripts/nxplpc.py deleted file mode 100644 index 727c9c8b..00000000 --- a/platformio/builder/scripts/nxplpc.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for NXP LPC series ARM microcontrollers. -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") -else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default .bin file -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/siliconlabsefm32.py b/platformio/builder/scripts/siliconlabsefm32.py deleted file mode 100644 index ca2d617d..00000000 --- a/platformio/builder/scripts/siliconlabsefm32.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Silicon Labs EFM32 series ARM microcontrollers. -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") -else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default .bin file -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/ststm32.py b/platformio/builder/scripts/ststm32.py deleted file mode 100644 index 8dbd70ef..00000000 --- a/platformio/builder/scripts/ststm32.py +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for ST STM32 Series ARM microcontrollers. -""" - -from os.path import isfile, join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - -if env.subst("$UPLOAD_PROTOCOL") == "gdb": - if not isfile(join(env.subst("$PROJECT_DIR"), "upload.gdb")): - env.Exit( - "Error: You are using GDB as firmware uploader. " - "Please specify upload commands in upload.gdb " - "file in project directory!" - ) - env.Replace( - UPLOADER=join( - "$PIOPACKAGES_DIR", "toolchain-gccarmnoneeabi", - "bin", "arm-none-eabi-gdb" - ), - UPLOADERFLAGS=[ - join("$BUILD_DIR", "firmware.elf"), - "-batch", - "-x", - '"%s"' % join("$PROJECT_DIR", "upload.gdb") - ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' - ) -else: - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-stlink", "st-flash"), - UPLOADERFLAGS=[ - "write", # write in flash - "$SOURCES", # firmware path to flash - "0x08000000" # flash start adress - ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' - ) - - -env.Append( - CPPDEFINES=[ - env.get("BOARD_OPTIONS", {}).get( - "build", {}).get("variant", "").upper() - ], - - LIBS=["stdc++", "nosys"], - - LINKFLAGS=[ - "-nostartfiles", - "-nostdlib" - ] -) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") -else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default .bin file -# - -if "mbed" in env.subst("$FRAMEWORK") and not env.subst("$UPLOAD_PROTOCOL"): - upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) -else: - upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/teensy.py b/platformio/builder/scripts/teensy.py deleted file mode 100644 index c01c67e8..00000000 --- a/platformio/builder/scripts/teensy.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Teensy boards -""" - -from os.path import isfile, join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - -env = DefaultEnvironment() - -if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy": - SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py"))) -elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3": - SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - env.Append( - LINKFLAGS=[ - "-Wl,--defsym=__rtc_localtime=$UNIX_TIME", - "-fsingle-precision-constant", - "--specs=nano.specs" - ], - CCFLAGS=[ - "-fsingle-precision-constant" - ] - ) - -env.Append( - CPPDEFINES=[ - "LAYOUT_US_ENGLISH" - ], - - CXXFLAGS=[ - "-std=gnu++0x", - "-felide-constructors" - ] -) - -if isfile(env.subst(join( - "$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"))): - env.Append( - UPLOADER=join( - "$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"), - UPLOADERFLAGS=[ - "-mmcu=$BOARD_MCU", - "-w", # wait for device to apear - "-s", # soft reboot if device not online - "-v" # verbose output - ], - UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES' - ) -else: - env.Append( - REBOOTER=join( - "$PIOPACKAGES_DIR", "tool-teensy", "teensy_reboot"), - UPLOADER=join( - "$PIOPACKAGES_DIR", "tool-teensy", "teensy_post_compile"), - UPLOADERFLAGS=[ - "-file=firmware", - '-path="$BUILD_DIR"', - '-tools="%s"' % join("$PIOPACKAGES_DIR", "tool-teensy") - ], - UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS' - ) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the firmware file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.hex") -else: - target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default firmware file -# - -upload = env.Alias( - ["upload", "uploadlazy"], target_firm, - ["$UPLOADHEXCMD"] + (["$REBOOTER"] if "REBOOTER" in env else [])) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/timsp430.py b/platformio/builder/scripts/timsp430.py deleted file mode 100644 index a0cd720c..00000000 --- a/platformio/builder/scripts/timsp430.py +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Texas Instruments - MSP430 Ultra-Low Power 16-bit microcontrollers -""" - -from os.path import join -from platform import system - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, - DefaultEnvironment) - -env = DefaultEnvironment() - -env.Replace( - AR="msp430-ar", - AS="msp430-as", - CC="msp430-gcc", - CXX="msp430-g++", - OBJCOPY="msp430-objcopy", - RANLIB="msp430-ranlib", - SIZETOOL="msp430-size", - - ARFLAGS=["rcs"], - - ASFLAGS=["-x", "assembler-with-cpp"], - - CCFLAGS=[ - "-g", # include debugging info (so errors include line numbers) - "-Os", # optimize for size - # "-Wall", # show warnings - "-ffunction-sections", # place each function in its own section - "-fdata-sections", - "-mmcu=$BOARD_MCU" - ], - - CPPDEFINES=[ - "F_CPU=$BOARD_F_CPU" - ], - - LINK="$CC", - LINKFLAGS=[ - "-Os", - "-mmcu=$BOARD_MCU", - "-Wl,-gc-sections,-u,main" - ], - - LIBS=["m"], - - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - - UPLOADER=join("$PIOPACKAGES_DIR", "tool-mspdebug", "mspdebug"), - UPLOADERFLAGS=[ - "$UPLOAD_PROTOCOL" if system() != "Windows" else "tilib", - "--force-reset" - ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS "prog $SOURCES"', - - PROGNAME="firmware", - PROGSUFFIX=".elf" -) - -env.Append( - ASFLAGS=env.get("CCFLAGS", [])[:], - - BUILDERS=dict( - ElfToHex=Builder( - action=" ".join([ - "$OBJCOPY", - "-O", - "ihex", - "-R", - ".eeprom", - "$SOURCES", - "$TARGET"]), - suffix=".hex" - ) - ) -) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .hex -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.hex") -else: - target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload firmware -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/titiva.py b/platformio/builder/scripts/titiva.py deleted file mode 100644 index e705cd62..00000000 --- a/platformio/builder/scripts/titiva.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Texas Instruments - Tiva C Series ARM Cortex-M4 microcontrollers. -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - -env = DefaultEnvironment() - -SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - -env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-lm4flash", "lm4flash"), - UPLOADCMD='"$UPLOADER" $SOURCES' -) - -env.Append( - LINKFLAGS=[ - "-nostartfiles", - "-nostdlib" - ] -) - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildProgram() - -# -# Target: Build the .bin file -# - -if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") -else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload firmware -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/windows_x86.py b/platformio/builder/scripts/windows_x86.py deleted file mode 100644 index db78f6c1..00000000 --- a/platformio/builder/scripts/windows_x86.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" - Builder for Windows x86 / 32bit -""" - -from SCons.Script import AlwaysBuild, Default, DefaultEnvironment - -from platformio.util import get_systype - -env = DefaultEnvironment() - -env.Replace( - _BINPREFIX="", - AR="${_BINPREFIX}ar", - AS="${_BINPREFIX}as", - CC="${_BINPREFIX}gcc", - CXX="${_BINPREFIX}g++", - OBJCOPY="${_BINPREFIX}objcopy", - RANLIB="${_BINPREFIX}ranlib", - SIZETOOL="${_BINPREFIX}size", - - SIZEPRINTCMD='"$SIZETOOL" $SOURCES', - PROGSUFFIX=".exe" -) - -if get_systype() == "darwin_x86_64": - env.Replace( - _BINPREFIX="i586-mingw32-" - ) -elif get_systype() in ("linux_x86_64", "linux_i686"): - env.Replace( - _BINPREFIX="i686-w64-mingw32-" - ) - -# -# Target: Build executable program -# - -target_bin = env.BuildProgram() - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Define targets -# - -Default([target_bin]) diff --git a/platformio/builder/tools/__init__.py b/platformio/builder/tools/__init__.py index 0c05c3b0..95899c71 100644 --- a/platformio/builder/tools/__init__.py +++ b/platformio/builder/tools/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/platformio/builder/tools/pioar.py b/platformio/builder/tools/pioar.py deleted file mode 100644 index 6d8a2be0..00000000 --- a/platformio/builder/tools/pioar.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from hashlib import md5 -from os.path import join -from tempfile import gettempdir - -MAX_SOURCES_LENGTH = 8000 # Windows CLI has limit with command length to 8192 - - -def _huge_sources_hook(sources): - _sources = str(sources).replace("\\", "/") - if len(str(_sources)) < MAX_SOURCES_LENGTH: - return sources - - tmp_file = join(gettempdir(), "pioarargs-%s" % md5(_sources).hexdigest()) - with open(tmp_file, "w") as f: - # fix space in paths - for line in _sources.split(".o "): - if not line.endswith(".o"): - line += ".o" - f.write('"%s" ' % line) - - return '@"%s"' % tmp_file - - -def exists(_): - return True - - -def generate(env): - - env.Replace( - _huge_sources_hook=_huge_sources_hook, - ARCOM=env.get("ARCOM", "").replace( - "$SOURCES", "${_huge_sources_hook(SOURCES)}")) - - return env diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py new file mode 100644 index 00000000..6a357ba5 --- /dev/null +++ b/platformio/builder/tools/piolib.py @@ -0,0 +1,610 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# pylint: disable=no-member, no-self-use, unused-argument + +from __future__ import absolute_import + +import os +import sys +from os.path import basename, commonprefix, isdir, isfile, join, realpath, sep +from platform import system + +import SCons.Scanner +from SCons.Script import ARGUMENTS + +from platformio import util +from platformio.builder.tools import platformio as piotool +from platformio.managers.lib import LibraryManager + + +class LibBuilderFactory(object): + + @staticmethod + def new(env, path): + clsname = "UnknownLibBuilder" + if isfile(join(path, "library.json")): + clsname = "PlatformIOLibBuilder" + else: + env_frameworks = [ + f.lower().strip() + for f in env.get("PIOFRAMEWORK", "").split(",") + ] + used_frameworks = LibBuilderFactory.get_used_frameworks(env, path) + common_frameworks = set(env_frameworks) & set(used_frameworks) + if common_frameworks: + clsname = "%sLibBuilder" % list(common_frameworks)[0].title() + elif used_frameworks: + clsname = "%sLibBuilder" % used_frameworks[0].title() + + obj = getattr(sys.modules[__name__], clsname)(env, path) + assert isinstance(obj, LibBuilderBase) + return obj + + @staticmethod + def get_used_frameworks(env, path): + if any([isfile(join(path, fname)) + for fname in ("library.properties", "keywords.txt")]): + return ["arduino"] + + if isfile(join(path, "module.json")): + return ["mbed"] + + # check source files + for root, _, files in os.walk(path, followlinks=True): + for fname in files: + if not env.IsFileWithExt(fname, ("c", "cpp", "h", "hpp")): + continue + with open(join(root, fname)) as f: + content = f.read() + if "Arduino.h" in content: + return ["arduino"] + elif "mbed.h" in content: + return ["mbed"] + return [] + +# pylint: disable=too-many-instance-attributes, too-many-public-methods + + +class LibBuilderBase(object): + + INC_SCANNER = SCons.Scanner.C.CScanner() + INC_DIRS_CACHE = None + + def __init__(self, env, path, manifest=None): + self.env = env.Clone() + self.envorigin = env.Clone() + self.path = realpath(env.subst(path)) + self._manifest = manifest if manifest else self.load_manifest() + self._is_dependent = False + self._depbuilders = list() + self._scanned_paths = list() + self._built_node = None + + # process extra options and append to build environment + self.process_extra_options() + + def __repr__(self): + return "%s(%r)" % (self.__class__, self.path) + + def __contains__(self, path): + p1 = self.path + p2 = path + if system() == "Windows": + p1 = p1.lower() + p2 = p2.lower() + return commonprefix((p1 + sep, p2)) == p1 + sep + + @property + def name(self): + return self._manifest.get("name", basename(self.path)) + + @property + def version(self): + return self._manifest.get("version") + + @property + def dependencies(self): + return LibraryManager.normalize_dependencies( + self._manifest.get("dependencies", [])) + + @property + def src_filter(self): + return piotool.SRC_FILTER_DEFAULT + [ + "-" % os.sep, "-" % os.sep, "-" % + os.sep, "-" % os.sep + ] + + @property + def src_dir(self): + return (join(self.path, "src") + if isdir(join(self.path, "src")) else self.path) + + @property + def build_dir(self): + return join("$BUILD_DIR", "lib", basename(self.path)) + + def get_inc_dirs(self): + return [self.src_dir] + + @property + def build_flags(self): + return None + + @property + def build_unflags(self): + return None + + @property + def extra_script(self): + return None + + @property + def lib_archive(self): + return True + + @property + def lib_ldf_mode(self): + return int(self.env.get("LIB_LDF_MODE", 1)) + + @property + def depbuilders(self): + return self._depbuilders + + @property + def dependent(self): + return self._is_dependent + + def is_platform_compatible(self, platform): + return True + + def is_framework_compatible(self, framework): + return True + + def load_manifest(self): + return {} + + def get_src_files(self): + return [ + join(self.src_dir, item) + for item in self.env.MatchSourceFiles(self.src_dir, + self.src_filter) + ] + + def process_extra_options(self): + with util.cd(self.path): + self.env.ProcessUnFlags(self.build_unflags) + self.env.ProcessFlags(self.build_flags) + if self.extra_script: + self.env.SConscript( + realpath(self.extra_script), + exports={"env": self.env, + "pio_lib_builder": self}) + + def _process_dependencies(self, lib_builders): + if not self.dependencies: + return + for item in self.dependencies: + found = False + for lb in lib_builders: + if item['name'] != lb.name: + continue + elif "frameworks" in item and \ + not any([lb.is_framework_compatible(f) + for f in item["frameworks"]]): + continue + elif "platforms" in item and \ + not any([lb.is_platform_compatible(p) + for p in item["platforms"]]): + continue + found = True + self.depend_recursive(lb, lib_builders) + break + + if not found: + sys.stderr.write( + "Error: Could not find `%s` dependency for `%s` " + "library\n" % (item['name'], self.name)) + self.env.Exit(1) + + def _validate_search_paths(self, search_paths=None): + if not search_paths: + search_paths = [] + assert isinstance(search_paths, list) + + _search_paths = [] + for path in search_paths: + if path not in self._scanned_paths: + _search_paths.append(path) + self._scanned_paths.append(path) + + return _search_paths + + def _get_found_includes(self, lib_builders, search_paths=None): + # all include directories + if not LibBuilderBase.INC_DIRS_CACHE: + inc_dirs = [] + used_inc_dirs = [] + for lb in lib_builders: + items = [self.env.Dir(d) for d in lb.get_inc_dirs()] + if lb.dependent: + used_inc_dirs.extend(items) + else: + inc_dirs.extend(items) + LibBuilderBase.INC_DIRS_CACHE = used_inc_dirs + inc_dirs + + # append self include directories + inc_dirs = [self.env.Dir(d) for d in self.get_inc_dirs()] + inc_dirs.extend(LibBuilderBase.INC_DIRS_CACHE) + + result = [] + for path in self._validate_search_paths(search_paths): + for inc in self.env.File(path).get_found_includes( + self.env, LibBuilderBase.INC_SCANNER, tuple(inc_dirs)): + if inc not in result: + result.append(inc) + return result + + def depend_recursive(self, lb, lib_builders, search_paths=None): + # assert isinstance(lb, LibBuilderBase) + if self != lb: + if self in lb.depbuilders: + sys.stderr.write("Warning! Circular dependencies detected " + "between `%s` and `%s`\n" % + (self.path, lb.path)) + elif lb not in self._depbuilders: + self._depbuilders.append(lb) + LibBuilderBase.INC_DIRS_CACHE = None + lb.search_deps_recursive(lib_builders, search_paths) + + def search_deps_recursive(self, lib_builders, search_paths=None): + if not self._is_dependent: + self._is_dependent = True + self._process_dependencies(lib_builders) + + if self.lib_ldf_mode == 2: + search_paths = self.get_src_files() + + # when LDF is disabled + if self.lib_ldf_mode == 0: + return + + lib_inc_map = {} + for inc in self._get_found_includes(lib_builders, search_paths): + for lb in lib_builders: + if inc.get_abspath() in lb: + if lb not in lib_inc_map: + lib_inc_map[lb] = [] + lib_inc_map[lb].append(inc.get_abspath()) + break + + for lb, lb_search_paths in lib_inc_map.items(): + self.depend_recursive(lb, lib_builders, lb_search_paths) + + def build(self): + libs = [] + for lb in self.depbuilders: + libs.extend(lb.build()) + # copy shared information to self env + for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): + self.env.AppendUnique(**{key: lb.env.get(key)}) + + if not self._built_node: + self.env.AppendUnique(CPPPATH=self.get_inc_dirs()) + if self.lib_archive: + self._built_node = self.env.BuildLibrary( + self.build_dir, self.src_dir, self.src_filter) + else: + self._built_node = self.env.BuildSources( + self.build_dir, self.src_dir, self.src_filter) + libs.append(self._built_node) + return libs + + +class UnknownLibBuilder(LibBuilderBase): + pass + + +class ProjectAsLibBuilder(LibBuilderBase): + + @property + def lib_ldf_mode(self): + return 2 # parse all project files + + @property + def src_filter(self): + return self.env.get("SRC_FILTER", LibBuilderBase.src_filter.fget(self)) + + def process_extra_options(self): + # skip for project, options are already processed + pass + + def search_deps_recursive(self, lib_builders, search_paths=None): + for lib_name in self.env.get("LIB_FORCE", []): + for lb in lib_builders: + if lb.name == lib_name: + if lb not in self.depbuilders: + self.depend_recursive(lb, lib_builders) + break + return LibBuilderBase.search_deps_recursive(self, lib_builders, + search_paths) + + def build(self): + # dummy mark that project is built + self._built_node = "dummy" + return [l for l in LibBuilderBase.build(self) if l != "dummy"] + + +class ArduinoLibBuilder(LibBuilderBase): + + def load_manifest(self): + manifest = {} + if not isfile(join(self.path, "library.properties")): + return manifest + with open(join(self.path, "library.properties")) as fp: + for line in fp.readlines(): + if "=" not in line: + continue + key, value = line.split("=", 1) + manifest[key.strip()] = value.strip() + return manifest + + def get_inc_dirs(self): + inc_dirs = LibBuilderBase.get_inc_dirs(self) + if isdir(join(self.path, "src")): + return inc_dirs + if isdir(join(self.path, "utility")): + inc_dirs.append(join(self.path, "utility")) + return inc_dirs + + @property + def src_filter(self): + if isdir(join(self.path, "src")): + return LibBuilderBase.src_filter.fget(self) + src_filter = [] + is_utility = isdir(join(self.path, "utility")) + for ext in piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT: + src_filter.append("+<*.%s>" % ext) + if is_utility: + src_filter.append("+" % (sep, ext)) + return src_filter + + def is_framework_compatible(self, framework): + return framework.lower() in ("arduino", "energia") + + +class MbedLibBuilder(LibBuilderBase): + + def load_manifest(self): + if not isfile(join(self.path, "module.json")): + return {} + return util.load_json(join(self.path, "module.json")) + + @property + def src_dir(self): + if isdir(join(self.path, "source")): + return join(self.path, "source") + return LibBuilderBase.src_dir.fget(self) + + def get_inc_dirs(self): + inc_dirs = LibBuilderBase.get_inc_dirs(self) + if self.path not in inc_dirs: + inc_dirs.append(self.path) + for p in self._manifest.get("extraIncludes", []): + inc_dirs.append(join(self.path, p)) + return inc_dirs + + def is_framework_compatible(self, framework): + return framework.lower() == "mbed" + + +class PlatformIOLibBuilder(LibBuilderBase): + + def load_manifest(self): + assert isfile(join(self.path, "library.json")) + manifest = util.load_json(join(self.path, "library.json")) + assert "name" in manifest + return manifest + + def _is_arduino_manifest(self): + return isfile(join(self.path, "library.properties")) + + @property + def src_filter(self): + if "srcFilter" in self._manifest.get("build", {}): + return self._manifest.get("build").get("srcFilter") + elif self._is_arduino_manifest(): + return ArduinoLibBuilder.src_filter.fget(self) + return LibBuilderBase.src_filter.fget(self) + + @property + def build_flags(self): + if "flags" in self._manifest.get("build", {}): + return self._manifest.get("build").get("flags") + return LibBuilderBase.build_flags.fget(self) + + @property + def build_unflags(self): + if "unflags" in self._manifest.get("build", {}): + return self._manifest.get("build").get("unflags") + return LibBuilderBase.build_unflags.fget(self) + + @property + def extra_script(self): + if "extraScript" in self._manifest.get("build", {}): + return self._manifest.get("build").get("extraScript") + return LibBuilderBase.extra_script.fget(self) + + @property + def lib_archive(self): + if "libArchive" in self._manifest.get("build", {}): + return self._manifest.get("build").get("libArchive") + return LibBuilderBase.lib_archive.fget(self) + + @property + def lib_ldf_mode(self): + if "libLDFMode" in self._manifest.get("build", {}): + return int(self._manifest.get("build").get("libLDFMode")) + return LibBuilderBase.lib_ldf_mode.fget(self) + + def is_platform_compatible(self, platform): + items = self._manifest.get("platforms") + if not items: + return LibBuilderBase.is_platform_compatible(self, platform) + return self._item_in_list(platform, items) + + def is_framework_compatible(self, framework): + items = self._manifest.get("frameworks") + if not items: + return LibBuilderBase.is_framework_compatible(self, framework) + return self._item_in_list(framework, items) + + def _item_in_list(self, item, ilist): + if ilist == "*": + return True + if not isinstance(ilist, list): + ilist = [i.strip() for i in ilist.split(",")] + return item.lower() in [i.lower() for i in ilist] + + def get_inc_dirs(self): + inc_dirs = LibBuilderBase.get_inc_dirs(self) + + # backwards compatibility with PlatformIO 2.0 + if ("build" not in self._manifest and self._is_arduino_manifest() and + not isdir(join(self.path, "src")) and + isdir(join(self.path, "utility"))): + inc_dirs.append(join(self.path, "utility")) + + for path in self.env['CPPPATH']: + if path not in self.envorigin['CPPPATH']: + inc_dirs.append(self.env.subst(path)) + return inc_dirs + + +def GetLibBuilders(env): + items = [] + env_frameworks = [ + f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",") + ] + compat_mode = int(env.get("LIB_COMPAT_MODE", 1)) + verbose = (int(ARGUMENTS.get("PIOVERBOSE", 0)) and + not env.GetOption('clean')) + + def _check_lib_builder(lb): + if lb.name in env.get("LIB_IGNORE", []): + if verbose: + sys.stderr.write("Ignored library %s\n" % lb.path) + return + if compat_mode > 1 and not lb.is_platform_compatible(env[ + 'PIOPLATFORM']): + if verbose: + sys.stderr.write("Platform incompatible library %s\n" % + lb.path) + return False + if compat_mode > 0 and not any([lb.is_framework_compatible(f) + for f in env_frameworks]): + if verbose: + sys.stderr.write("Framework incompatible library %s\n" % + lb.path) + return False + return True + + found_incompat = False + for libs_dir in env['LIBSOURCE_DIRS']: + libs_dir = env.subst(libs_dir) + if not isdir(libs_dir): + continue + for item in sorted(os.listdir(libs_dir)): + if item == "__cores__" or not isdir(join(libs_dir, item)): + continue + try: + lb = LibBuilderFactory.new(env, join(libs_dir, item)) + except ValueError: + if verbose: + sys.stderr.write("Skip library with broken manifest: %s\n" + % join(libs_dir, item)) + continue + if _check_lib_builder(lb): + items.append(lb) + else: + found_incompat = True + + for lb in env.get("EXTRA_LIB_BUILDERS", []): + if _check_lib_builder(lb): + items.append(lb) + else: + found_incompat = True + + if verbose and found_incompat: + sys.stderr.write( + "More details about \"Library Compatibility Mode\": " + "http://docs.platformio.org/en/latest/librarymanager/ldf.html#" + "ldf-compat-mode\n") + + return items + + +def BuildDependentLibraries(env, src_dir): + + def correct_found_libs(lib_builders): + # build full dependency graph + found_lbs = [lb for lb in lib_builders if lb.dependent] + for lb in lib_builders: + lb.search_deps_recursive(lib_builders, lb.get_src_files()) + for lb in lib_builders: + for deplb in lb.depbuilders[:]: + if deplb not in found_lbs: + lb.depbuilders.remove(deplb) + + def print_deps_tree(root, level=0): + margin = "| " * (level) + for lb in root.depbuilders: + title = "<%s>" % lb.name + if lb.version: + title += " v%s" % lb.version + if int(ARGUMENTS.get("PIOVERBOSE", 0)): + title += " (%s)" % lb.path + print "%s|-- %s" % (margin, title) + if lb.depbuilders: + print_deps_tree(lb, level + 1) + + lib_builders = env.GetLibBuilders() + + print "Collected %d compatible libraries" % len(lib_builders) + print "Looking for dependencies..." + + project = ProjectAsLibBuilder(env, src_dir) + project.env = env + project.search_deps_recursive(lib_builders) + + if int(env.get("LIB_LDF_MODE", 1)) == 1 and project.depbuilders: + correct_found_libs(lib_builders) + + if project.depbuilders: + print "Library Dependency Graph" + print_deps_tree(project) + else: + print "Project does not have dependencies" + + return project.build() + + +def exists(_): + return True + + +def generate(env): + env.AddMethod(GetLibBuilders) + env.AddMethod(BuildDependentLibraries) + return env diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index b24fca21..c38258af 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,187 +16,212 @@ from __future__ import absolute_import import atexit import re +import sys from glob import glob -from os import environ, listdir, remove -from os.path import isdir, isfile, join +from os import environ, remove, walk +from os.path import basename, isdir, isfile, join, relpath +from tempfile import mkstemp -from platformio.util import exec_command, where_is_program +from SCons.Action import Action +from SCons.Script import ARGUMENTS + +from platformio import util class InoToCPPConverter(object): - PROTOTYPE_RE = re.compile( - r"""^( - (\s*[a-z_\d]+\*?){1,2} # return type - (\s+[a-z_\d]+\s*) # name of prototype + PROTOTYPE_RE = re.compile(r"""^( + ([a-z_\d]+\*?\s+){1,2} # return type + ([a-z_\d]+\s*) # name of prototype \([a-z_,\.\*\&\[\]\s\d]*\) # arguments )\s*\{ # must end with { - """, - re.X | re.M | re.I - ) + """, re.X | re.M | re.I) DETECTMAIN_RE = re.compile(r"void\s+(setup|loop)\s*\(", re.M | re.I) PROTOPTRS_TPLRE = r"\([^&\(]*&(%s)[^\)]*\)" - def __init__(self, nodes): - self.nodes = nodes + def __init__(self, env): + self.env = env + self._main_ino = None def is_main_node(self, contents): return self.DETECTMAIN_RE.search(contents) - def _parse_prototypes(self, file_path, contents): + def convert(self, nodes): + contents = self.merge(nodes) + if not contents: + return + return self.process(contents) + + def merge(self, nodes): + assert nodes + lines = [] + for node in nodes: + contents = node.get_text_contents() + _lines = [ + '# 1 "%s"' % node.get_path().replace("\\", "/"), contents + ] + if self.is_main_node(contents): + lines = _lines + lines + self._main_ino = node.get_path() + else: + lines.extend(_lines) + + if not self._main_ino: + self._main_ino = nodes[0].get_path() + + return "\n".join(["#include "] + lines) if lines else None + + def process(self, contents): + out_file = self._main_ino + ".cpp" + assert self._gcc_preprocess(contents, out_file) + with open(out_file) as fp: + contents = fp.read() + contents = self._join_multiline_strings(contents) + with open(out_file, "w") as fp: + fp.write(self.append_prototypes(contents)) + return out_file + + def _gcc_preprocess(self, contents, out_file): + tmp_path = mkstemp()[1] + with open(tmp_path, "w") as fp: + fp.write(contents) + self.env.Execute( + self.env.VerboseAction( + '$CXX -o "{0}" -x c++ -fpreprocessed -dD -E "{1}"'.format( + out_file, tmp_path), "Converting " + basename( + out_file[:-4]))) + atexit.register(_delete_file, tmp_path) + return isfile(out_file) + + def _join_multiline_strings(self, contents): + if "\\\n" not in contents: + return contents + newlines = [] + linenum = 0 + stropen = False + for line in contents.split("\n"): + _linenum = self._parse_preproc_line_num(line) + if _linenum is not None: + linenum = _linenum + else: + linenum += 1 + + if line.endswith("\\"): + if line.startswith('"'): + stropen = True + newlines.append(line[:-1]) + continue + elif stropen: + newlines[len(newlines) - 1] += line[:-1] + continue + elif stropen and line.endswith('";'): + newlines[len(newlines) - 1] += line + stropen = False + newlines.append('#line %d "%s"' % + (linenum, self._main_ino.replace("\\", "/"))) + continue + + newlines.append(line) + + return "\n".join(newlines) + + @staticmethod + def _parse_preproc_line_num(line): + if not line.startswith("#"): + return None + tokens = line.split(" ", 3) + if len(tokens) > 2 and tokens[1].isdigit(): + return int(tokens[1]) + return None + + def _parse_prototypes(self, contents): prototypes = [] reserved_keywords = set(["if", "else", "while"]) for match in self.PROTOTYPE_RE.finditer(contents): if (set([match.group(2).strip(), match.group(3).strip()]) & reserved_keywords): continue - prototypes.append({"path": file_path, "match": match}) + prototypes.append(match) return prototypes - def append_prototypes(self, file_path, contents, prototypes): - result = [] + def _get_total_lines(self, contents): + total = 0 + for line in contents.split("\n")[::-1]: + linenum = self._parse_preproc_line_num(line) + if linenum is not None: + return total + linenum + total += 1 + return total + + def append_prototypes(self, contents): + prototypes = self._parse_prototypes(contents) if not prototypes: - return result + return contents - prototype_names = set( - [p['match'].group(3).strip() for p in prototypes]) - split_pos = prototypes[0]['match'].start() - for item in prototypes: - if item['path'] == file_path: - split_pos = item['match'].start() - break - - match_ptrs = re.search( - self.PROTOPTRS_TPLRE % ("|".join(prototype_names)), - contents[:split_pos], - re.M - ) + prototype_names = set([m.group(3).strip() for m in prototypes]) + split_pos = prototypes[0].start() + match_ptrs = re.search(self.PROTOPTRS_TPLRE % + ("|".join(prototype_names)), + contents[:split_pos], re.M) if match_ptrs: split_pos = contents.rfind("\n", 0, match_ptrs.start()) + result = [] result.append(contents[:split_pos].strip()) - result.append("%s;" % - ";\n".join([p['match'].group(1) for p in prototypes])) - result.append('#line %d "%s"' % ( - contents.count("\n", 0, split_pos) + 2, - file_path.replace("\\", "/"))) + result.append("%s;" % ";\n".join([m.group(1) for m in prototypes])) + result.append('#line %d "%s"' % + (self._get_total_lines(contents[:split_pos]), + self._main_ino.replace("\\", "/"))) result.append(contents[split_pos:].strip()) - - return result - - def convert(self): - prototypes = [] - data = [] - for node in self.nodes: - ino_contents = node.get_text_contents() - prototypes += self._parse_prototypes(node.get_path(), ino_contents) - - item = (node.get_path(), ino_contents) - if self.is_main_node(ino_contents): - data = [item] + data - else: - data.append(item) - - if not data: - return None - - result = ["#include "] - is_first = True - for file_path, contents in data: - result.append('#line 1 "%s"' % file_path.replace("\\", "/")) - - if is_first and prototypes: - result += self.append_prototypes( - file_path, contents, prototypes) - else: - result.append(contents) - is_first = False - return "\n".join(result) def ConvertInoToCpp(env): - - def delete_tmpcpp_file(file_): - try: - remove(file_) - except: # pylint: disable=bare-except - if isfile(file_): - print("Warning: Could not remove temporary file '%s'. " - "Please remove it manually." % file_) - ino_nodes = (env.Glob(join("$PROJECTSRC_DIR", "*.ino")) + env.Glob(join("$PROJECTSRC_DIR", "*.pde"))) - - c = InoToCPPConverter(ino_nodes) - data = c.convert() - - if not data: + if not ino_nodes: return + c = InoToCPPConverter(env) + out_file = c.convert(ino_nodes) - tmpcpp_file = join(env.subst("$PROJECTSRC_DIR"), "tmp_ino_to.cpp") - with open(tmpcpp_file, "w") as f: - f.write(data) + atexit.register(_delete_file, out_file) - atexit.register(delete_tmpcpp_file, tmpcpp_file) + +def _delete_file(path): + try: + if isfile(path): + remove(path) + except: # pylint: disable=bare-except + pass def DumpIDEData(env): - BOARD_CORE = env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") - def get_includes(env_): includes = [] + for item in env_.get("CPPPATH", []): - invardir = False - for vardiritem in env_.get("VARIANT_DIRS", []): - if item == vardiritem[0]: - includes.append(env_.subst(vardiritem[1])) - invardir = True - break - if not invardir: - includes.append(env_.subst(item)) + includes.append(env_.subst(item)) # installed libs - for d in env_.get("LIBSOURCE_DIRS", []): - lsd_dir = env_.subst(d) - _append_lib_includes(env_, lsd_dir, includes) + for lb in env.GetLibBuilders(): + includes.extend(lb.get_inc_dirs()) - # includes from toolchain - toolchain_dir = env_.subst( - join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN")) - toolchain_incglobs = [ - join(toolchain_dir, "*", "include*"), - join(toolchain_dir, "lib", "gcc", "*", "*", "include*") - ] - for g in toolchain_incglobs: - includes.extend(glob(g)) + # includes from toolchains + p = env.PioPlatform() + for name in p.get_installed_packages(): + if p.get_package_type(name) != "toolchain": + continue + toolchain_dir = p.get_package_dir(name) + toolchain_incglobs = [ + join(toolchain_dir, "*", "include*"), + join(toolchain_dir, "lib", "gcc", "*", "*", "include*") + ] + for g in toolchain_incglobs: + includes.extend(glob(g)) return includes - def _append_lib_includes(env_, libs_dir, includes): - if not isdir(libs_dir): - return - for name in env_.get("LIB_USE", []) + sorted(listdir(libs_dir)): - if not isdir(join(libs_dir, name)): - continue - # ignore user's specified libs - if name in env_.get("LIB_IGNORE", []): - continue - if name == "__cores__": - if isdir(join(libs_dir, name, BOARD_CORE)): - _append_lib_includes( - env_, join(libs_dir, name, BOARD_CORE), includes) - return - - include = ( - join(libs_dir, name, "src") - if isdir(join(libs_dir, name, "src")) - else join(libs_dir, name) - ) - if include not in includes: - includes.append(include) - def get_defines(env_): defines = [] # global symbols @@ -206,13 +231,10 @@ def DumpIDEData(env): defines.append(env_.subst(item).replace('\\"', '"')) # special symbol for Atmel AVR MCU - board = env_.get("BOARD_OPTIONS", {}) - if board and board['platform'] == "atmelavr": + if env['PIOPLATFORM'] == "atmelavr": defines.append( - "__AVR_%s__" % board['build']['mcu'].upper() - .replace("ATMEGA", "ATmega") - .replace("ATTINY", "ATtiny") - ) + "__AVR_%s__" % env.BoardConfig().get("build.mcu").upper() + .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny")) return defines LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS" @@ -224,9 +246,9 @@ def DumpIDEData(env): "includes": get_includes(env_), "cc_flags": env_.subst(LINTCCOM), "cxx_flags": env_.subst(LINTCXXCOM), - "cc_path": where_is_program( + "cc_path": util.where_is_program( env_.subst("$CC"), env_.subst("${ENV['PATH']}")), - "cxx_path": where_is_program( + "cxx_path": util.where_is_program( env_.subst("$CXX"), env_.subst("${ENV['PATH']}")) } @@ -254,7 +276,7 @@ def GetCompilerType(env): try: sysenv = environ.copy() sysenv['PATH'] = str(env['ENV']['PATH']) - result = exec_command([env.subst("$CC"), "-v"], env=sysenv) + result = util.exec_command([env.subst("$CC"), "-v"], env=sysenv) except OSError: return None if result['returncode'] != 0: @@ -280,12 +302,34 @@ def GetActualLDScript(env): return path if script: - env.Exit("Error: Could not find '%s' LD script in LDPATH '%s'" % ( - script, env.subst("$LIBPATH"))) + sys.stderr.write( + "Error: Could not find '%s' LD script in LDPATH '%s'\n" % + (script, env.subst("$LIBPATH"))) + env.Exit(1) return None +def VerboseAction(_, act, actstr): + if int(ARGUMENTS.get("PIOVERBOSE", 0)): + return act + else: + return Action(act, actstr) + + +def PioClean(env, clean_dir): + if not isdir(clean_dir): + print "Build environment is clean" + env.Exit(0) + for root, _, files in walk(clean_dir): + for file_ in files: + remove(join(root, file_)) + print "Removed %s" % relpath(join(root, file_)) + print "Done cleaning" + util.rmtree_(clean_dir) + env.Exit(0) + + def exists(_): return True @@ -295,4 +339,6 @@ def generate(env): env.AddMethod(DumpIDEData) env.AddMethod(GetCompilerType) env.AddMethod(GetActualLDScript) + env.AddMethod(VerboseAction) + env.AddMethod(PioClean) return env diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py new file mode 100644 index 00000000..42ad2ef4 --- /dev/null +++ b/platformio/builder/tools/pioplatform.py @@ -0,0 +1,106 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +import sys +from os.path import isdir, isfile, join + +from SCons.Script import COMMAND_LINE_TARGETS + +from platformio import exception, util +from platformio.managers.platform import PlatformFactory + + +@util.memoized +def initPioPlatform(name): + return PlatformFactory.newPlatform(name) + + +def PioPlatform(env): + variables = {} + for key in ("board", "pioframework"): + if key not in env: + continue + variables[key] = env[key.upper()] + p = initPioPlatform(env['PLATFORM_MANIFEST']) + p.configure_default_packages(variables, COMMAND_LINE_TARGETS) + return p + + +def BoardConfig(env, board=None): + p = initPioPlatform(env['PLATFORM_MANIFEST']) + try: + config = p.board_config(board if board else env['BOARD']) + except exception.UnknownBoard as e: + sys.stderr.write("Error: %s\n" % str(e)) + env.Exit(1) + return config + + +def GetFrameworkScript(env, framework): + p = env.PioPlatform() + assert p.frameworks and framework in p.frameworks + script_path = env.subst(p.frameworks[framework]['script']) + if not isfile(script_path): + script_path = join(p.get_dir(), script_path) + return script_path + + +def LoadPioPlatform(env, variables): + p = env.PioPlatform() + installed_packages = p.get_installed_packages() + + # Add toolchains and uploaders to $PATH + for name in installed_packages: + type_ = p.get_package_type(name) + if type_ not in ("toolchain", "uploader"): + continue + path = p.get_package_dir(name) + if isdir(join(path, "bin")): + path = join(path, "bin") + env.PrependENVPath("PATH", path) + + # Platform specific LD Scripts + if isdir(join(p.get_dir(), "ldscripts")): + env.Prepend(LIBPATH=[join(p.get_dir(), "ldscripts")]) + + if "BOARD" not in env: + return + + board_config = env.BoardConfig() + for k in variables.keys(): + if (k in env or + not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")])): + continue + _opt, _val = k.lower().split("_", 1) + if _opt == "board": + _opt = "build" + if _val in board_config.get(_opt): + env.Replace(**{k: board_config.get("%s.%s" % (_opt, _val))}) + + if "build.ldscript" in board_config: + env.Replace(LDSCRIPT_PATH=board_config.get("build.ldscript")) + + +def exists(_): + return True + + +def generate(env): + env.AddMethod(PioPlatform) + env.AddMethod(BoardConfig) + env.AddMethod(GetFrameworkScript) + env.AddMethod(LoadPioPlatform) + return env diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py new file mode 100644 index 00000000..e79584a3 --- /dev/null +++ b/platformio/builder/tools/piotest.py @@ -0,0 +1,51 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +from os.path import join, sep + + +def ProcessTest(env): + env.Append( + CPPDEFINES=[ + "UNIT_TEST", "UNITY_INCLUDE_CONFIG_H" + ], + CPPPATH=[ + join("$BUILD_DIR", "UnityTestLib") + ]) + unitylib = env.BuildLibrary( + join("$BUILD_DIR", "UnityTestLib"), + env.PioPlatform().get_package_dir("tool-unity")) + env.Prepend(LIBS=[unitylib]) + + src_filter = None + if "PIOTEST" in env: + src_filter = "+" + src_filter += " +<%s%s>" % (env['PIOTEST'], sep) + + return env.CollectBuildFiles( + "$BUILDTEST_DIR", + "$PROJECTTEST_DIR", + src_filter=src_filter, + duplicate=False) + + +def exists(_): + return True + + +def generate(env): + env.AddMethod(ProcessTest) + return env diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index bc81941a..9d2b1a6e 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ from __future__ import absolute_import +import sys from os import environ from os.path import isfile, join from platform import system @@ -71,20 +72,20 @@ def WaitForNewSerialPort(env, before): break if not new_port: - env.Exit("Error: Couldn't find a board on the selected port. " - "Check that you have the correct port selected. " - "If it is correct, try pressing the board's reset " - "button after initiating the upload.") + sys.stderr.write("Error: Couldn't find a board on the selected port. " + "Check that you have the correct port selected. " + "If it is correct, try pressing the board's reset " + "button after initiating the upload.\n") + env.Exit(1) return new_port def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument env = args[0] - print "Looking for upload port/disk..." def _look_for_mbed_disk(): - msdlabels = ("mbed", "nucleo", "frdm") + msdlabels = ("mbed", "nucleo", "frdm", "microbit") for item in util.get_logicaldisks(): if (not item['name'] or not any([l in item['name'].lower() for l in msdlabels])): @@ -94,8 +95,9 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument def _look_for_serial_port(): port = None - board_hwids = env.get("BOARD_OPTIONS", {}).get( - "build", {}).get("hwids", []) + board_hwids = [] + if "BOARD" in env and "build.hwids" in env.BoardConfig(): + board_hwids = env.BoardConfig().get("build.hwids") for item in util.get_serialports(): if "VID:PID" not in item['hwid']: continue @@ -107,33 +109,34 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument return port if "UPLOAD_PORT" in env: - print env.subst("Manually specified: $UPLOAD_PORT") + print env.subst("Use manually specified: $UPLOAD_PORT") return - if env.subst("$FRAMEWORK") == "mbed": + if env.subst("$PIOFRAMEWORK") == "mbed": env.Replace(UPLOAD_PORT=_look_for_mbed_disk()) else: if (system() == "Linux" and not isfile("/etc/udev/99-platformio-udev.rules")): - print( + sys.stderr.write( "\nWarning! Please install `99-platformio-udev.rules` and " "check that your board's PID and VID are listed in the rules." "\n https://raw.githubusercontent.com/platformio/platformio" - "/develop/scripts/99-platformio-udev.rules\n" - ) + "/develop/scripts/99-platformio-udev.rules\n") env.Replace(UPLOAD_PORT=_look_for_serial_port()) if env.subst("$UPLOAD_PORT"): print env.subst("Auto-detected: $UPLOAD_PORT") else: - env.Exit("Error: Please specify `upload_port` for environment or use " - "global `--upload-port` option.\n" - "For some development platforms this can be a USB flash " - "drive (i.e. /media//)\n") + sys.stderr.write( + "Error: Please specify `upload_port` for environment or use " + "global `--upload-port` option.\n" + "For some development platforms it can be a USB flash " + "drive (i.e. /media//)\n") + env.Exit(1) def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621 - env.AutodetectUploadPort() + assert "UPLOAD_PORT" in env progname = env.subst("$PROGNAME") for ext in ("bin", "hex"): fpath = join(env.subst("$BUILD_DIR"), "%s.%s" % (progname, ext)) @@ -141,17 +144,17 @@ def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621 continue copyfile(fpath, join( env.subst("$UPLOAD_PORT"), "%s.%s" % (progname, ext))) - print("Firmware has been successfully uploaded.\n" - "Please restart your board.") + print "Firmware has been successfully uploaded.\n"\ + "(Some boards may require manual hard reset)" def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621 - max_size = int(env.get("BOARD_OPTIONS", {}).get("upload", {}).get( - "maximum_size", 0)) + if "BOARD" not in env: + return + max_size = int(env.BoardConfig().get("upload.maximum_size", 0)) if max_size == 0 or "SIZETOOL" not in env: return - print "Check program size..." sysenv = environ.copy() sysenv['PATH'] = str(env['ENV']['PATH']) cmd = [env.subst("$SIZETOOL"), "-B", str(target[0])] @@ -165,8 +168,10 @@ def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621 used_size = int(values[0]) + int(values[1]) if used_size > max_size: - env.Exit("Error: The program size (%d bytes) is greater " - "than maximum allowed (%s bytes)" % (used_size, max_size)) + sys.stderr.write("Error: The program size (%d bytes) is greater " + "than maximum allowed (%s bytes)\n" % + (used_size, max_size)) + env.Exit(1) def exists(_): diff --git a/platformio/builder/tools/piowinhooks.py b/platformio/builder/tools/piowinhooks.py new file mode 100644 index 00000000..c1b0895a --- /dev/null +++ b/platformio/builder/tools/piowinhooks.py @@ -0,0 +1,88 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from hashlib import md5 +from os import makedirs +from os.path import isdir, isfile, join +from platform import system + +# Windows CLI has limit with command length to 8192 +# Leave 2000 chars for flags and other options +MAX_SOURCES_LENGTH = 6000 + + +def long_sources_hook(env, sources): + _sources = str(sources).replace("\\", "/") + if len(str(_sources)) < MAX_SOURCES_LENGTH: + return sources + + # fix space in paths + data = [] + for line in _sources.split(".o "): + line = line.strip() + if not line.endswith(".o"): + line += ".o" + data.append('"%s"' % line) + + return '@"%s"' % _file_long_data(env, " ".join(data)) + + +def long_incflags_hook(env, incflags): + _incflags = env.subst(incflags).replace("\\", "/") + if len(_incflags) < MAX_SOURCES_LENGTH: + return incflags + + # fix space in paths + data = [] + for line in _incflags.split(" -I"): + line = line.strip() + if not line.startswith("-I"): + line = "-I" + line + data.append('-I"%s"' % line[2:]) + + return '@"%s"' % _file_long_data(env, " ".join(data)) + + +def _file_long_data(env, data): + build_dir = env.subst("$BUILD_DIR") + if not isdir(build_dir): + makedirs(build_dir) + tmp_file = join(build_dir, "longcmd-%s" % md5(data).hexdigest()) + if isfile(tmp_file): + return tmp_file + with open(tmp_file, "w") as fp: + fp.write(data) + return tmp_file + + +def exists(_): + return True + + +def generate(env): + if system() != "Windows": + return + + env.Replace(_long_sources_hook=long_sources_hook) + env.Replace(_long_incflags_hook=long_incflags_hook) + coms = {} + for key in ("ARCOM", "LINKCOM"): + coms[key] = env.get(key, "").replace( + "$SOURCES", "${_long_sources_hook(__env__, SOURCES)}") + for key in ("_CCCOMCOM", "ASPPCOM"): + coms[key] = env.get(key, "").replace( + "$_CPPINCFLAGS", "${_long_incflags_hook(__env__, _CPPINCFLAGS)}") + env.Replace(**coms) + + return env diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index a10f7cf1..3f56eebd 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,10 +15,12 @@ from __future__ import absolute_import import re +import sys from glob import glob -from os import listdir, sep, walk -from os.path import basename, dirname, isdir, isfile, join, normpath, realpath +from os import sep, walk +from os.path import basename, dirname, isdir, join, realpath +from SCons.Action import Action from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript from SCons.Util import case_sensitive_suffixes @@ -26,40 +28,33 @@ from platformio.util import pioversion_to_intstr SRC_BUILD_EXT = ["c", "cpp", "S", "spp", "SPP", "sx", "s", "asm", "ASM"] SRC_HEADER_EXT = ["h", "hpp"] -SRC_DEFAULT_FILTER = " ".join([ - "+<*>", "-<.git%s>" % sep, "-" % sep, - "-" % sep, "-" % sep, - "-" % sep, "-" % sep -]) +SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] def BuildProgram(env): def _append_pio_macros(): - env.AppendUnique( - CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( - *pioversion_to_intstr())]) + env.AppendUnique(CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( + *pioversion_to_intstr())]) _append_pio_macros() # fix ASM handling under non-casitive OS if not case_sensitive_suffixes(".s", ".S"): - env.Replace( - AS="$CC", - ASCOM="$ASPPCOM" - ) + env.Replace(AS="$CC", ASCOM="$ASPPCOM") # process extra flags from board - env.ProcessFlags( - env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags")) + if "BOARD" in env and "build.extra_flags" in env.BoardConfig(): + env.ProcessFlags(env.BoardConfig().get("build.extra_flags")) # remove base flags env.ProcessUnFlags(env.get("BUILD_UNFLAGS")) # apply user flags env.ProcessFlags(env.get("BUILD_FLAGS")) - if env.get("FRAMEWORK"): + if env.get("PIOFRAMEWORK"): env.BuildFrameworks([ - f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")]) + f.lower().strip() for f in env['PIOFRAMEWORK'].split(",") + ]) # restore PIO macros if it was deleted by framework _append_pio_macros() @@ -70,18 +65,12 @@ def BuildProgram(env): # append specified LD_SCRIPT if ("LDSCRIPT_PATH" in env and not any(["-Wl,-T" in f for f in env['LINKFLAGS']])): - env.Append( - LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"'] - ) + env.Append(LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"']) # enable "cyclic reference" for linker if env.get("LIBS", deplibs) and env.GetCompilerType() == "gcc": - env.Prepend( - _LIBFLAGS="-Wl,--start-group " - ) - env.Append( - _LIBFLAGS=" -Wl,--end-group" - ) + env.Prepend(_LIBFLAGS="-Wl,--start-group ") + env.Append(_LIBFLAGS=" -Wl,--end-group") # Handle SRC_BUILD_FLAGS env.ProcessFlags(env.get("SRC_BUILD_FLAGS")) @@ -89,25 +78,28 @@ def BuildProgram(env): env.Append( CPPPATH=["$PROJECTSRC_DIR"], LIBS=deplibs, - LIBPATH=["$BUILD_DIR"] - ) + LIBPATH=["$BUILD_DIR"], + PIOBUILDFILES=env.CollectBuildFiles( + "$BUILDSRC_DIR", + "$PROJECTSRC_DIR", + src_filter=env.get("SRC_FILTER"), + duplicate=False)) - sources = env.LookupSources( - "$BUILDSRC_DIR", "$PROJECTSRC_DIR", duplicate=False, - src_filter=env.get("SRC_FILTER")) + if "test" in COMMAND_LINE_TARGETS: + env.Append(PIOBUILDFILES=env.ProcessTest()) - if not sources and not COMMAND_LINE_TARGETS: - env.Exit( + if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: + sys.stderr.write( "Error: Nothing to build. Please put your source code files " - "to '%s' folder" % env.subst("$PROJECTSRC_DIR")) + "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR")) + env.Exit(1) program = env.Program( - join("$BUILD_DIR", env.subst("$PROGNAME")), - sources - ) + join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES']) if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS): - env.AddPostAction(program, env.CheckUploadSize) + env.AddPostAction(program, Action(env.CheckUploadSize, + "Checking program size $TARGET")) return program @@ -174,12 +166,7 @@ def IsFileWithExt(env, file_, ext): # pylint: disable=W0613 return False -def VariantDirWrap(env, variant_dir, src_dir, duplicate=True): - DefaultEnvironment().Append(VARIANT_DIRS=[(variant_dir, src_dir)]) - env.VariantDir(variant_dir, src_dir, duplicate) - - -def LookupSources(env, variant_dir, src_dir, duplicate=True, src_filter=None): +def MatchSourceFiles(env, src_dir, src_filter=None): SRC_FILTER_PATTERNS_RE = re.compile(r"(\+|\-)<([^>]+)>") @@ -187,25 +174,35 @@ def LookupSources(env, variant_dir, src_dir, duplicate=True, src_filter=None): if env.IsFileWithExt(item, SRC_BUILD_EXT + SRC_HEADER_EXT): items.add(item.replace(src_dir + sep, "")) - def _match_sources(src_dir, src_filter): - matches = set() - # correct fs directory separator - src_filter = src_filter.replace("/", sep).replace("\\", sep) - for (action, pattern) in SRC_FILTER_PATTERNS_RE.findall(src_filter): - items = set() - for item in glob(join(src_dir, pattern)): - if isdir(item): - for root, _, files in walk(item, followlinks=True): - for f in files: - _append_build_item(items, join(root, f), src_dir) - else: - _append_build_item(items, item, src_dir) - if action == "+": - matches |= items - else: - matches -= items - return sorted(list(matches)) + src_dir = env.subst(src_dir) + src_filter = src_filter or SRC_FILTER_DEFAULT + if isinstance(src_filter, list) or isinstance(src_filter, tuple): + src_filter = " ".join(src_filter) + matches = set() + # correct fs directory separator + src_filter = src_filter.replace("/", sep).replace("\\", sep) + for (action, pattern) in SRC_FILTER_PATTERNS_RE.findall(src_filter): + items = set() + for item in glob(join(src_dir, pattern)): + if isdir(item): + for root, _, files in walk(item, followlinks=True): + for f in files: + _append_build_item(items, join(root, f), src_dir) + else: + _append_build_item(items, item, src_dir) + if action == "+": + matches |= items + else: + matches -= items + return sorted(list(matches)) + + +def CollectBuildFiles(env, + variant_dir, + src_dir, + src_filter=None, + duplicate=False): sources = [] variants = [] @@ -213,14 +210,14 @@ def LookupSources(env, variant_dir, src_dir, duplicate=True, src_filter=None): if src_dir.endswith(sep): src_dir = src_dir[:-1] - for item in _match_sources(src_dir, src_filter or SRC_DEFAULT_FILTER): + for item in env.MatchSourceFiles(src_dir, src_filter): _reldir = dirname(item) _src_dir = join(src_dir, _reldir) if _reldir else src_dir _var_dir = join(variant_dir, _reldir) if _reldir else variant_dir if _var_dir not in variants: variants.append(_var_dir) - env.VariantDirWrap(_var_dir, _src_dir, duplicate) + env.VariantDir(_var_dir, _src_dir, duplicate) if env.IsFileWithExt(item, SRC_BUILD_EXT): sources.append(env.File(join(_var_dir, basename(item)))) @@ -232,173 +229,43 @@ def BuildFrameworks(env, frameworks): if not frameworks or "uploadlazy" in COMMAND_LINE_TARGETS: return - board_frameworks = env.get("BOARD_OPTIONS", {}).get("frameworks", []) + if "BOARD" not in env: + sys.stderr.write("Please specify `board` in `platformio.ini` to use " + "with '%s' framework\n" % ", ".join(frameworks)) + env.Exit(1) + + board_frameworks = env.BoardConfig().get("frameworks", []) if frameworks == ["platformio"]: if board_frameworks: frameworks.insert(0, board_frameworks[0]) else: - env.Exit("Error: Please specify board type") + sys.stderr.write( + "Error: Please specify `board` in `platformio.ini`\n") + env.Exit(1) for f in frameworks: if f in ("arduino", "energia"): env.ConvertInoToCpp() if f in board_frameworks: - SConscript(env.subst( - join("$PIOBUILDER_DIR", "scripts", "frameworks", "%s.py" % f))) + SConscript(env.GetFrameworkScript(f)) else: - env.Exit("Error: This board doesn't support %s framework!" % f) + sys.stderr.write( + "Error: This board doesn't support %s framework!\n" % f) + env.Exit(1) def BuildLibrary(env, variant_dir, src_dir, src_filter=None): lib = env.Clone() - return lib.Library( + return lib.StaticLibrary( lib.subst(variant_dir), - lib.LookupSources(variant_dir, src_dir, src_filter=src_filter) - ) + lib.CollectBuildFiles( + variant_dir, src_dir, src_filter=src_filter)) -def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 - - INCLUDES_RE = re.compile( - r"^\s*#include\s+(\<|\")([^\>\"\']+)(?:\>|\")", re.M) - LIBSOURCE_DIRS = [env.subst(d) for d in env.get("LIBSOURCE_DIRS", [])] - - # start internal prototypes - - class IncludeFinder(object): - - def __init__(self, base_dir, name, is_system=False): - self.base_dir = base_dir - self.name = name - self.is_system = is_system - - self._inc_path = None - self._lib_dir = None - self._lib_name = None - - def getIncPath(self): - return self._inc_path - - def getLibDir(self): - return self._lib_dir - - def getLibName(self): - return self._lib_name - - def run(self): - if not self.is_system and self._find_in_local(): - return True - return self._find_in_system() - - def _find_in_local(self): - if isfile(join(self.base_dir, self.name)): - self._inc_path = join(self.base_dir, self.name) - return True - else: - return False - - def _find_in_system(self): - for lsd_dir in LIBSOURCE_DIRS: - if not isdir(lsd_dir): - continue - - for ld in env.get("LIB_USE", []) + sorted(listdir(lsd_dir)): - if not isdir(join(lsd_dir, ld)): - continue - - inc_path = normpath(join(lsd_dir, ld, self.name)) - try: - lib_dir = inc_path[:inc_path.index( - sep, len(lsd_dir) + 1)] - except ValueError: - continue - lib_name = basename(lib_dir) - - # ignore user's specified libs - if lib_name in env.get("LIB_IGNORE", []): - continue - - if not isfile(inc_path): - # if source code is in "src" dir - lib_dir = join(lsd_dir, lib_name, "src") - inc_path = join(lib_dir, self.name) - - if isfile(inc_path): - self._lib_dir = lib_dir - self._lib_name = lib_name - self._inc_path = inc_path - return True - return False - - def _get_dep_libs(src_dir): - state = { - "paths": set(), - "libs": set(), - "ordered": set() - } - - state = _process_src_dir(state, env.subst(src_dir)) - - result = [] - for item in sorted(state['ordered'], key=lambda s: s[0]): - result.append((item[1], item[2])) - return result - - def _process_src_dir(state, src_dir): - for root, _, files in walk(src_dir, followlinks=True): - for f in files: - if env.IsFileWithExt(f, SRC_BUILD_EXT + SRC_HEADER_EXT): - state = _parse_includes(state, env.File(join(root, f))) - return state - - def _parse_includes(state, node): - skip_includes = ("arduino.h", "energia.h") - matches = INCLUDES_RE.findall(node.get_text_contents()) - for (inc_type, inc_name) in matches: - base_dir = dirname(node.get_abspath()) - if inc_name.lower() in skip_includes: - continue - if join(base_dir, inc_name) in state['paths']: - continue - else: - state['paths'].add(join(base_dir, inc_name)) - - finder = IncludeFinder(base_dir, inc_name, inc_type == "<") - if finder.run(): - _parse_includes(state, env.File(finder.getIncPath())) - - _lib_dir = finder.getLibDir() - if _lib_dir and _lib_dir not in state['libs']: - state['ordered'].add(( - len(state['ordered']) + 1, finder.getLibName(), - _lib_dir)) - state['libs'].add(_lib_dir) - - if env.subst("$LIB_DFCYCLIC").lower() == "true": - state = _process_src_dir(state, _lib_dir) - return state - - # end internal prototypes - - deplibs = _get_dep_libs(src_dir) - for l, ld in deplibs: - env.Append( - CPPPATH=[join("$BUILD_DIR", l)] - ) - # add automatically "utility" dir from the lib (Arduino issue) - if isdir(join(ld, "utility")): - env.Append( - CPPPATH=[join("$BUILD_DIR", l, "utility")] - ) - - libs = [] - for (libname, inc_dir) in deplibs: - lib = env.BuildLibrary( - join("$BUILD_DIR", libname), inc_dir) - env.Clean(libname, lib) - libs.append(lib) - return libs +def BuildSources(env, variant_dir, src_dir, src_filter=None): + DefaultEnvironment().Append(PIOBUILDFILES=env.Clone().CollectBuildFiles( + variant_dir, src_dir, src_filter=src_filter)) def exists(_): @@ -410,9 +277,9 @@ def generate(env): env.AddMethod(ProcessFlags) env.AddMethod(ProcessUnFlags) env.AddMethod(IsFileWithExt) - env.AddMethod(VariantDirWrap) - env.AddMethod(LookupSources) + env.AddMethod(MatchSourceFiles) + env.AddMethod(CollectBuildFiles) env.AddMethod(BuildFrameworks) env.AddMethod(BuildLibrary) - env.AddMethod(BuildDependentLibraries) + env.AddMethod(BuildSources) return env diff --git a/platformio/commands/__init__.py b/platformio/commands/__init__.py index 0c05c3b0..95899c71 100644 --- a/platformio/commands/__init__.py +++ b/platformio/commands/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 0ccdfa6f..572e39a3 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,30 +16,31 @@ import json import click -from platformio.util import get_boards +from platformio.exception import APIRequestError +from platformio.managers.platform import PlatformManager -@click.command("list", short_help="Pre-configured Embedded Boards") +@click.command("boards", short_help="Pre-configured Embedded Boards") @click.argument("query", required=False) +@click.option("--installed", is_flag=True) @click.option("--json-output", is_flag=True) -def cli(query, json_output): # pylint: disable=R0912 - +def cli(query, installed, json_output): # pylint: disable=R0912 if json_output: - return ouput_boards_json(query) + return _ouput_boards_json(query, installed) BOARDLIST_TPL = ("{type:<30} {mcu:<14} {frequency:<8} " " {flash:<7} {ram:<6} {name}") terminal_width, _ = click.get_terminal_size() grpboards = {} - for type_, data in get_boards().items(): - if data['platform'] not in grpboards: - grpboards[data['platform']] = {} - grpboards[data['platform']][type_] = data + for board in _get_boards(installed): + if board['platform'] not in grpboards: + grpboards[board['platform']] = [] + grpboards[board['platform']].append(board) - for (platform, boards) in sorted(grpboards.items()): + for (platform, pboards) in sorted(grpboards.items()): if query: - search_data = json.dumps(boards).lower() + search_data = json.dumps(pboards).lower() if query.lower() not in search_data.lower(): continue @@ -47,46 +48,68 @@ def cli(query, json_output): # pylint: disable=R0912 click.echo("Platform: ", nl=False) click.secho(platform, bold=True) click.echo("-" * terminal_width) - click.echo(BOARDLIST_TPL.format( - type=click.style("Type", fg="cyan"), mcu="MCU", - frequency="Frequency", flash="Flash", ram="RAM", name="Name")) + click.echo( + BOARDLIST_TPL.format( + type=click.style( + "ID", fg="cyan"), + mcu="MCU", + frequency="Frequency", + flash="Flash", + ram="RAM", + name="Name")) click.echo("-" * terminal_width) - for type_, data in sorted(boards.items(), key=lambda b: b[1]['name']): + for board in sorted(pboards, key=lambda b: b['id']): if query: - search_data = "%s %s" % (type_, json.dumps(data).lower()) + search_data = "%s %s" % (board['id'], + json.dumps(board).lower()) if query.lower() not in search_data.lower(): continue - flash_size = "" - if "maximum_size" in data.get("upload", None): - flash_size = int(data['upload']['maximum_size']) - flash_size = "%dkB" % (flash_size / 1024) + flash_size = "%dkB" % (board['rom'] / 1024) - ram_size = "" - if "maximum_ram_size" in data.get("upload", None): - ram_size = int(data['upload']['maximum_ram_size']) - if ram_size >= 1024: - if ram_size % 1024: - ram_size = "%.1fkB" % (ram_size / 1024.0) - else: - ram_size = "%dkB" % (ram_size / 1024) + ram_size = board['ram'] + if ram_size >= 1024: + if ram_size % 1024: + ram_size = "%.1fkB" % (ram_size / 1024.0) else: - ram_size = "%dB" % ram_size + ram_size = "%dkB" % (ram_size / 1024) + else: + ram_size = "%dB" % ram_size - click.echo(BOARDLIST_TPL.format( - type=click.style(type_, fg="cyan"), mcu=data['build']['mcu'], - frequency="%dMhz" % ( - int(data['build']['f_cpu'][:-1]) / 1000000), - flash=flash_size, ram=ram_size, name=data['name'])) + click.echo( + BOARDLIST_TPL.format( + type=click.style( + board['id'], fg="cyan"), + mcu=board['mcu'], + frequency="%dMhz" % (board['fcpu'] / 1000000), + flash=flash_size, + ram=ram_size, + name=board['name'])) -def ouput_boards_json(query): - result = {} - for type_, data in get_boards().items(): +def _get_boards(installed=False): + boards = PlatformManager().get_installed_boards() + if not installed: + know_boards = ["%s:%s" % (b['platform'], b['id']) for b in boards] + for board in PlatformManager().get_registered_boards(): + key = "%s:%s" % (board['platform'], board['id']) + if key not in know_boards: + boards.append(board) + return boards + + +def _ouput_boards_json(query, installed=False): + result = [] + try: + boards = _get_boards(installed) + except APIRequestError: + if not installed: + boards = _get_boards(True) + for board in boards: if query: - search_data = "%s %s" % (type_, json.dumps(data).lower()) + search_data = "%s %s" % (board['id'], json.dumps(board).lower()) if query.lower() not in search_data.lower(): continue - result[type_] = data + result.append(board) click.echo(json.dumps(result)) diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index bb503e40..cdfc004c 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,20 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -import stat from glob import glob -from os import chmod, getenv, makedirs, remove +from os import getenv, makedirs, remove from os.path import abspath, basename, expanduser, isdir, isfile, join -from shutil import copyfile, copytree, rmtree +from shutil import copyfile, copytree from tempfile import mkdtemp import click -from platformio import app +from platformio import app, util from platformio.commands.init import cli as cmd_init +from platformio.commands.init import validate_boards from platformio.commands.run import cli as cmd_run from platformio.exception import CIBuildEnvsEmpty -from platformio.util import get_boards # pylint: disable=wrong-import-order try: @@ -34,7 +33,7 @@ except ImportError: from ConfigParser import ConfigParser -def validate_path(ctx, param, value): # pylint: disable=W0613 +def validate_path(ctx, param, value): # pylint: disable=unused-argument invalid_path = None value = list(value) for i, p in enumerate(value): @@ -51,36 +50,48 @@ def validate_path(ctx, param, value): # pylint: disable=W0613 raise click.BadParameter("Found invalid path: %s" % invalid_path) -def validate_boards(ctx, param, value): # pylint: disable=W0613 - unknown_boards = set(value) - set(get_boards().keys()) - try: - assert not unknown_boards - return value - except AssertionError: - raise click.BadParameter( - "%s. Please search for the board types using " - "`platformio boards` command" % ", ".join(unknown_boards)) - - @click.command("ci", short_help="Continuous Integration") @click.argument("src", nargs=-1, callback=validate_path) -@click.option("--lib", "-l", multiple=True, callback=validate_path) +@click.option( + "-l", "--lib", multiple=True, callback=validate_path, metavar="DIRECTORY") @click.option("--exclude", multiple=True) -@click.option("--board", "-b", multiple=True, callback=validate_boards) -@click.option("--build-dir", default=mkdtemp, - type=click.Path(exists=True, file_okay=False, dir_okay=True, - writable=True, resolve_path=True)) +@click.option( + "-b", "--board", multiple=True, metavar="ID", callback=validate_boards) +@click.option( + "--build-dir", + default=mkdtemp, + type=click.Path( + exists=True, + file_okay=False, + dir_okay=True, + writable=True, + resolve_path=True)) @click.option("--keep-build-dir", is_flag=True) -@click.option("--project-conf", - type=click.Path(exists=True, file_okay=True, dir_okay=False, - readable=True, resolve_path=True)) -@click.option("--verbose", "-v", count=True, default=3) +@click.option( + "-C", + "--project-conf", + type=click.Path( + exists=True, + file_okay=True, + dir_okay=False, + readable=True, + resolve_path=True)) +@click.option("-O", "--project-option", multiple=True) +@click.option("-v", "--verbose", is_flag=True) @click.pass_context -def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913 - build_dir, keep_build_dir, project_conf, verbose): +def cli(ctx, # pylint: disable=R0913 + src, + lib, + exclude, + board, + build_dir, + keep_build_dir, + project_conf, + project_option, + verbose): - if not src: - src = getenv("PLATFORMIO_CI_SRC", "").split(":") + if not src and getenv("PLATFORMIO_CI_SRC"): + src = validate_path(ctx, None, getenv("PLATFORMIO_CI_SRC").split(":")) if not src: raise click.BadParameter("Missing argument 'src'") @@ -105,28 +116,26 @@ def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913 _exclude_contents(build_dir, exclude) # initialise project - ctx.invoke(cmd_init, project_dir=build_dir, board=board) + ctx.invoke( + cmd_init, + project_dir=build_dir, + board=board, + project_option=project_option) # process project ctx.invoke(cmd_run, project_dir=build_dir, verbose=verbose) finally: if not keep_build_dir: - rmtree( - build_dir, onerror=lambda action, name, exc: - (chmod(name, stat.S_IWRITE), remove(name)) - ) + util.rmtree_(build_dir) def _clean_dir(dirpath): - rmtree(dirpath) + util.rmtree_(dirpath) makedirs(dirpath) def _copy_contents(dst_dir, contents): - items = { - "dirs": set(), - "files": set() - } + items = {"dirs": set(), "files": set()} for path in contents: if isdir(path): @@ -160,7 +169,7 @@ def _exclude_contents(dst_dir, patterns): for path in contents: path = abspath(path) if isdir(path): - rmtree(path) + util.rmtree_(path) elif isfile(path): remove(path) diff --git a/platformio/commands/device.py b/platformio/commands/device.py new file mode 100644 index 00000000..e423f273 --- /dev/null +++ b/platformio/commands/device.py @@ -0,0 +1,225 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import sys + +import click +from serial import VERSION as PYSERIAL_VERSION +from serial.tools import miniterm + +from platformio import app +from platformio.exception import MinitermException +from platformio.util import get_serialports + + +@click.group(short_help="Monitor device or list existing") +def cli(): + pass + + +@cli.command("list", short_help="List devices") +@click.option("--json-output", is_flag=True) +def device_list(json_output): + + if json_output: + click.echo(json.dumps(get_serialports())) + return + + for item in get_serialports(): + click.secho(item['port'], fg="cyan") + click.echo("-" * len(item['port'])) + click.echo("Hardware ID: %s" % item['hwid']) + click.echo("Description: %s" % item['description']) + click.echo("") + + +if int(PYSERIAL_VERSION[0]) == 3: + + @cli.command("monitor", short_help="Monitor device (Serial)") + @click.option("--port", "-p", help="Port, a number or a device name") + @click.option( + "--baud", + "-b", + type=int, + default=9600, + help="Set baud rate, default=9600") + @click.option( + "--parity", + default="N", + type=click.Choice(["N", "E", "O", "S", "M"]), + help="Set parity, default=N") + @click.option( + "--rtscts", + is_flag=True, + help="Enable RTS/CTS flow control, default=Off") + @click.option( + "--xonxoff", + is_flag=True, + help="Enable software flow control, default=Off") + @click.option( + "--rts", + default=None, + type=click.Choice(["0", "1"]), + help="Set initial RTS line state") + @click.option( + "--dtr", + default=None, + type=click.Choice(["0", "1"]), + help="Set initial DTR line state") + @click.option( + "--echo", is_flag=True, help="Enable local echo, default=Off") + @click.option( + "--encoding", + default="UTF-8", + help="Set the encoding for the serial port (e.g. hexlify, " + "Latin1, UTF-8), default: UTF-8") + @click.option( + "--filter", "-f", multiple=True, help="Add text transformation") + @click.option( + "--eol", + default="CRLF", + type=click.Choice(["CR", "LF", "CRLF"]), + help="End of line mode, default=CRLF") + @click.option( + "--raw", + is_flag=True, + help="Do not apply any encodings/transformations") + @click.option( + "--exit-char", + type=int, + default=29, + help="ASCII code of special character that is used to exit " + "the application, default=29 (DEC)") + @click.option( + "--menu-char", + type=int, + default=20, + help="ASCII code of special character that is used to " + "control miniterm (menu), default=20 (DEC)") + @click.option( + "--quiet", + is_flag=True, + help="Diagnostics: suppress non-error messages, default=Off") + def device_monitor(**kwargs): + if not kwargs['port']: + for item in get_serialports(): + if "VID:PID" in item['hwid']: + kwargs['port'] = item['port'] + break + + sys.argv = ["monitor"] + for k, v in kwargs.iteritems(): + if k in ("port", "baud", "rts", "dtr"): + continue + k = "--" + k.replace("_", "-") + if isinstance(v, bool): + if v: + sys.argv.append(k) + elif isinstance(v, tuple): + for i in v: + sys.argv.extend([k, i]) + else: + sys.argv.extend([k, str(v)]) + + try: + miniterm.main( # pylint: disable=E1123 + default_port=kwargs['port'], + default_baudrate=kwargs['baud'], + default_rts=kwargs['rts'], + default_dtr=kwargs['dtr']) + except Exception as e: # pylint: disable=W0702 + raise MinitermException(e) +else: + + @cli.command("monitor", short_help="Monitor device (Serial)") + @click.option("--port", "-p", help="Port, a number or a device name") + @click.option( + "--baud", + "-b", + type=int, + default=9600, + help="Set baud rate, default=9600") + @click.option( + "--parity", + default="N", + type=click.Choice(["N", "E", "O", "S", "M"]), + help="Set parity, default=N") + @click.option( + "--rtscts", + is_flag=True, + help="Enable RTS/CTS flow control, default=Off") + @click.option( + "--xonxoff", + is_flag=True, + help="Enable software flow control, default=Off") + @click.option( + "--rts", + default=None, + type=click.Choice(["0", "1"]), + help="Set initial RTS line state, default=0") + @click.option( + "--dtr", + default=None, + type=click.Choice(["0", "1"]), + help="Set initial DTR line state, default=0") + @click.option( + "--echo", is_flag=True, help="Enable local echo, default=Off") + @click.option( + "--cr", + is_flag=True, + help="Do not send CR+LF, send CR only, default=Off") + @click.option( + "--lf", + is_flag=True, + help="Do not send CR+LF, send LF only, default=Off") + @click.option( + "--debug", + "-d", + count=True, + help="""Debug received data (escape non-printable chars) + # --debug can be given multiple times: + # 0: just print what is received + # 1: escape non-printable characters, do newlines as unusual + # 2: escape non-printable characters, newlines too + # 3: hex dump everything""") + @click.option( + "--exit-char", + type=int, + default=29, + help="ASCII code of special character that is used to exit " + "the application, default=29 (DEC)") + @click.option( + "--menu-char", + type=int, + default=20, + help="ASCII code of special character that is used to " + "control miniterm (menu), default=20 (DEC)") + @click.option( + "--quiet", + is_flag=True, + help="Diagnostics: suppress non-error messages, default=Off") + def device_monitor(**kwargs): + sys.argv = app.get_session_var("command_ctx").args[1:] + + if not kwargs['port']: + for item in get_serialports(): + if "VID:PID" in item['hwid']: + sys.argv += ["--port", item['port']] + break + + try: + miniterm.main() + except Exception as e: # pylint: disable=W0702 + raise MinitermException(e) diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 6a9e964c..d7eee985 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,37 +18,55 @@ from shutil import copyfile import click -from platformio import app, exception, util -from platformio.commands.platforms import \ - platforms_install as cli_platforms_install +from platformio import exception, util +from platformio.commands.platform import \ + platform_install as cli_platform_install from platformio.ide.projectgenerator import ProjectGenerator -from platformio.platforms.base import PlatformFactory +from platformio.managers.platform import PlatformManager def validate_boards(ctx, param, value): # pylint: disable=W0613 - unknown_boards = set(value) - set(util.get_boards().keys()) + pm = PlatformManager() + # check installed boards + known_boards = set([b['id'] for b in pm.get_installed_boards()]) + # if boards are not listed as installed, check registered boards + if set(value) - known_boards: + known_boards = set([b['id'] for b in pm.get_registered_boards()]) + unknown_boards = set(value) - known_boards try: assert not unknown_boards return value except AssertionError: - raise click.BadParameter( - "%s. Please search for the board types using " - "`platformio boards` command" % ", ".join(unknown_boards)) + raise click.BadParameter("%s. Please search for the board ID using " + "`platformio boards` command" % + ", ".join(unknown_boards)) -@click.command("init", short_help="Initialize new PlatformIO based project") -@click.option("--project-dir", "-d", default=getcwd, - type=click.Path(exists=True, file_okay=False, dir_okay=True, - writable=True, resolve_path=True)) -@click.option("--board", "-b", multiple=True, metavar="TYPE", - callback=validate_boards) -@click.option("--ide", - type=click.Choice(ProjectGenerator.get_supported_ides())) -@click.option("--enable-auto-uploading", is_flag=True) +@click.command( + "init", short_help="Initialize PlatformIO project or update existing") +@click.option( + "--project-dir", + "-d", + default=getcwd, + type=click.Path( + exists=True, + file_okay=False, + dir_okay=True, + writable=True, + resolve_path=True)) +@click.option( + "-b", "--board", multiple=True, metavar="ID", callback=validate_boards) +@click.option( + "--ide", type=click.Choice(ProjectGenerator.get_supported_ides())) +@click.option("-O", "--project-option", multiple=True) @click.option("--env-prefix", default="") @click.pass_context -def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 - enable_auto_uploading, env_prefix): +def cli(ctx, # pylint: disable=R0913 + project_dir, + board, + ide, + project_option, + env_prefix): if project_dir == getcwd(): click.secho("\nThe current working directory", fg="yellow", nl=False) @@ -57,30 +75,25 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 "will be used for project.\n" "You can specify another project directory via\n" "`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.", - fg="yellow" - ) + fg="yellow") click.echo("") - click.echo("The next files/directories will be created in %s" % - click.style(project_dir, fg="cyan")) - click.echo("%s - Project Configuration File. |-> PLEASE EDIT ME <-|" % - click.style("platformio.ini", fg="cyan")) - click.echo("%s - Put your source files here" % - click.style("src", fg="cyan")) + click.echo("The next files/directories have been created in %s" % + click.style( + project_dir, fg="cyan")) + click.echo("%s - Project Configuration File" % click.style( + "platformio.ini", fg="cyan")) + click.echo("%s - Put your source files here" % click.style( + "src", fg="cyan")) click.echo("%s - Put here project specific (private) libraries" % - click.style("lib", fg="cyan")) - - if (app.get_setting("enable_prompts") and - not click.confirm("Do you want to continue?")): - raise exception.AbortedByUser() + click.style( + "lib", fg="cyan")) init_base_project(project_dir) if board: - fill_project_envs( - ctx, join(project_dir, "platformio.ini"), board, - enable_auto_uploading, env_prefix, ide is not None - ) + fill_project_envs(ctx, project_dir, board, project_option, env_prefix, + ide is not None) if ide: if not board: @@ -93,11 +106,10 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 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" - ) + "However, the IDE features (code autocompletion, syntax " + "linter) 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() @@ -110,30 +122,28 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 "`platformio run --target clean` - clean project (remove compiled " "files)\n" "`platformio run --help` - additional information", - fg="green" - ) + fg="green") def get_first_board(project_dir): - with util.cd(project_dir): - config = util.get_project_config() - for section in config.sections(): - if not section.startswith("env:"): - continue - elif config.has_option(section, "board"): - return config.get(section, "board") + config = util.load_project_config(project_dir) + for section in config.sections(): + if not section.startswith("env:"): + continue + elif config.has_option(section, "board"): + return config.get(section, "board") return None def init_base_project(project_dir): - platformio_ini = join(project_dir, "platformio.ini") - if not isfile(platformio_ini): - copyfile(join(util.get_source_dir(), "projectconftpl.ini"), - platformio_ini) + if not util.is_platformio_project(project_dir): + copyfile( + join(util.get_source_dir(), "projectconftpl.ini"), + join(project_dir, "platformio.ini")) lib_dir = join(project_dir, "lib") src_dir = join(project_dir, "src") - config = util.get_project_config(platformio_ini) + config = util.load_project_config(project_dir) if config.has_option("platformio", "src_dir"): src_dir = join(project_dir, config.get("platformio", "src_dir")) @@ -184,10 +194,8 @@ Then in `src/main.c` you should use: PlatformIO will find your libraries automatically, configure preprocessor's include paths and build them. -See additional options for PlatformIO Library Dependency Finder `lib_*`: - -http://docs.platformio.org/en/stable/projectconf.html#lib-install - +More information about PlatformIO Library Dependency Finder +- http://docs.platformio.org/en/stable/librarymanager/ldf.html """) @@ -259,51 +267,68 @@ def init_ci_conf(project_dir): # - pip install -U platformio # # script: -# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N """) def init_cvs_ignore(project_dir): - if isfile(join(project_dir, ".gitignore")): - return - with open(join(project_dir, ".gitignore"), "w") as f: - f.write(".pioenvs") + ignore_path = join(project_dir, ".gitignore") + default = [".pioenvs\n", ".piolibdeps\n"] + current = [] + if isfile(ignore_path): + with open(ignore_path) as fp: + current = fp.readlines() + if current and not current[-1].endswith("\n"): + current[-1] += "\n" + for d in default: + if d not in current: + current.append(d) + with open(ignore_path, "w") as fp: + fp.writelines(current) def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals - ctx, platformio_ini, board_types, enable_auto_uploading, - env_prefix, force_download): - builtin_boards = util.get_boards() + ctx, project_dir, board_ids, project_option, env_prefix, + force_download): + installed_boards = PlatformManager().get_installed_boards() content = [] used_boards = [] used_platforms = [] - config = util.get_project_config(platformio_ini) + config = util.load_project_config(project_dir) for section in config.sections(): if not all([section.startswith("env:"), config.has_option(section, "board")]): continue used_boards.append(config.get(section, "board")) - for type_ in board_types: - data = builtin_boards[type_] - used_platforms.append(data['platform']) + for id_ in board_ids: + manifest = None + for boards in (installed_boards, + PlatformManager.get_registered_boards()): + for b in boards: + if b['id'] == id_: + manifest = b + break + assert manifest is not None - if type_ in used_boards: + used_platforms.append(manifest['platform']) + if id_ in used_boards: continue + used_boards.append(id_) content.append("") - content.append("[env:%s%s]" % (env_prefix, type_)) - content.append("platform = %s" % data['platform']) + content.append("[env:%s%s]" % (env_prefix, id_)) + content.append("platform = %s" % manifest['platform']) # find default framework for board - frameworks = data.get("frameworks") + frameworks = manifest.get("frameworks") if frameworks: content.append("framework = %s" % frameworks[0]) - content.append("board = %s" % type_) - if enable_auto_uploading: - content.append("targets = upload") + content.append("board = %s" % id_) + if project_option: + content.extend(project_option) if force_download and used_platforms: _install_dependent_platforms(ctx, used_platforms) @@ -311,16 +336,17 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals if not content: return - with open(platformio_ini, "a") as f: + with open(join(project_dir, "platformio.ini"), "a") as f: content.append("") f.write("\n".join(content)) def _install_dependent_platforms(ctx, platforms): - installed_platforms = PlatformFactory.get_platforms(installed=True).keys() + installed_platforms = [ + p['name'] for p in PlatformManager().get_installed() + ] if set(platforms) <= set(installed_platforms): return ctx.invoke( - cli_platforms_install, - platforms=list(set(platforms) - set(installed_platforms)) - ) + cli_platform_install, + platforms=list(set(platforms) - set(installed_platforms))) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index b48b23dc..79a082c3 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,57 +13,163 @@ # limitations under the License. import json +from os.path import join +from time import sleep import click -from platformio import app, exception -from platformio.libmanager import LibraryManager +from platformio import exception, util +from platformio.managers.lib import LibraryManager from platformio.util import get_api_result + +@click.group(short_help="Library Manager") +@click.option( + "-g", + "--global", + is_flag=True, + help="Manager global PlatformIO" + " library storage `%s`" % join(util.get_home_dir(), "lib")) +@click.option( + "-d", + "--storage-dir", + default=None, + type=click.Path( + exists=True, + file_okay=False, + dir_okay=True, + writable=True, + resolve_path=True), + help="Manage custom library storage") +@click.pass_context +def cli(ctx, **options): + # skip commands that don't need storage folder + if ctx.invoked_subcommand in ("search", "register") or \ + (len(ctx.args) == 2 and ctx.args[1] in ("-h", "--help")): + return + storage_dir = options['storage_dir'] + if not storage_dir: + if options['global']: + storage_dir = join(util.get_home_dir(), "lib") + elif util.is_platformio_project(): + storage_dir = util.get_projectlibdeps_dir() + elif util.is_ci(): + storage_dir = join(util.get_home_dir(), "lib") + click.secho( + "Warning! Global library storage is used automatically. " + "Please use `platformio lib --global %s` command to remove " + "this warning." % ctx.invoked_subcommand, + fg="yellow") + + if not storage_dir and not util.is_platformio_project(): + raise exception.NotGlobalLibDir(util.get_project_dir(), + join(util.get_home_dir(), "lib"), + ctx.invoked_subcommand) + + ctx.obj = LibraryManager(storage_dir) + if "--json-output" not in ctx.args: + click.echo("Library Storage: " + storage_dir) + + +@cli.command("install", short_help="Install library") +@click.argument("libraries", required=False, nargs=-1, metavar="[LIBRARY...]") +# @click.option( +# "--save", +# is_flag=True, +# help="Save installed libraries into the project's platformio.ini " +# "library dependencies") +@click.option( + "-s", "--silent", is_flag=True, help="Suppress progress reporting") +@click.option( + "--interactive", + is_flag=True, + help="Allow to make a choice for all prompts") +@click.pass_obj +def lib_install(lm, libraries, silent, interactive): + # @TODO "save" option + for library in libraries: + lm.install(library, silent=silent, interactive=interactive) + + +@cli.command("uninstall", short_help="Uninstall libraries") +@click.argument("libraries", nargs=-1, metavar="[LIBRARY...]") +@click.pass_obj +def lib_uninstall(lm, libraries): + for library in libraries: + lm.uninstall(library) + + +@cli.command("update", short_help="Update installed libraries") +@click.argument("libraries", required=False, nargs=-1, metavar="[LIBRARY...]") +@click.option( + "-c", + "--only-check", + is_flag=True, + help="Do not update, only check for new version") +@click.pass_obj +def lib_update(lm, libraries, only_check): + if not libraries: + libraries = [str(m.get("id", m['name'])) for m in lm.get_installed()] + for library in libraries: + lm.update(library, only_check=only_check) + +####### + LIBLIST_TPL = ("[{id:^14}] {name:<25} {compatibility:<30} " "\"{authornames}\": {description}") def echo_liblist_header(): - click.echo(LIBLIST_TPL.format( - id=click.style("ID", fg="green"), - name=click.style("Name", fg="cyan"), - compatibility=click.style("Compatibility", fg="yellow"), - authornames="Authors", - description="Description" - )) + click.echo( + LIBLIST_TPL.format( + id=click.style( + "ID", fg="green"), + name=click.style( + "Name", fg="cyan"), + compatibility=click.style( + "Compatibility", fg="yellow"), + authornames="Authors", + description="Description")) terminal_width, _ = click.get_terminal_size() click.echo("-" * terminal_width) def echo_liblist_item(item): - click.echo(LIBLIST_TPL.format( - id=click.style(str(item['id']), fg="green"), - name=click.style(item['name'], fg="cyan"), - compatibility=click.style( - ", ".join(item['frameworks'] + item['platforms']), - fg="yellow" - ), - authornames=", ".join(item['authornames']), - description=item['description'] - )) + description = item.get("description", item.get("url", "")).encode("utf-8") + if "version" in item: + description += " | @" + click.style(item['version'], fg="yellow") - -@click.group(short_help="Library Manager") -def cli(): - pass + click.echo( + LIBLIST_TPL.format( + id=click.style( + str(item.get("id", "-")), fg="green"), + name=click.style( + item['name'], fg="cyan"), + compatibility=click.style( + ", ".join( + item.get("frameworks", ["-"]) + item.get("platforms", [])), + fg="yellow"), + authornames=", ".join(item.get("authornames", ["Unknown"])).encode( + "utf-8"), + description=description)) @cli.command("search", short_help="Search for library") +@click.argument("query", required=False, nargs=-1) @click.option("--json-output", is_flag=True) @click.option("--page", type=click.INT, default=1) +@click.option("-n", "--name", multiple=True) @click.option("-a", "--author", multiple=True) @click.option("-k", "--keyword", multiple=True) @click.option("-f", "--framework", multiple=True) @click.option("-p", "--platform", multiple=True) -@click.argument("query", required=False, nargs=-1) -def lib_search(query, json_output, page, **filters): +@click.option("-i", "--header", multiple=True) +@click.option( + "--noninteractive", + is_flag=True, + help="Do not prompt, automatically paginate with delay") +def lib_search(query, json_output, page, noninteractive, **filters): if not query: query = [] if not isinstance(query, list): @@ -73,8 +179,9 @@ def lib_search(query, json_output, page, **filters): for value in values: query.append('%s:"%s"' % (key, value)) - result = get_api_result("/lib/search", - dict(query=" ".join(query), page=page)) + result = get_api_result( + "/lib/search", dict( + query=" ".join(query), page=page)) if json_output: click.echo(json.dumps(result)) @@ -84,17 +191,22 @@ def lib_search(query, json_output, page, **filters): click.secho( "Nothing has been found by your request\n" "Try a less-specific search or use truncation (or wildcard) " - "operator", fg="yellow", nl=False) + "operator", + fg="yellow", + nl=False) click.secho(" *", fg="green") click.secho("For example: DS*, PCA*, DHT* and etc.\n", fg="yellow") click.echo("For more examples and advanced search syntax, " "please use documentation:") - click.secho("http://docs.platformio.org" - "/en/stable/userguide/lib/cmd_search.html\n", fg="cyan") + click.secho( + "http://docs.platformio.org" + "/en/stable/userguide/lib/cmd_search.html\n", + fg="cyan") return - click.secho("Found %d libraries:\n" % result['total'], - fg="green" if result['total'] else "yellow") + click.secho( + "Found %d libraries:\n" % result['total'], + fg="green" if result['total'] else "yellow") if result['total']: echo_liblist_header() @@ -107,98 +219,27 @@ def lib_search(query, json_output, page, **filters): int(result['total'])): break - if (app.get_setting("enable_prompts") and - click.confirm("Show next libraries?")): - result = get_api_result( - "/lib/search", - dict(query=" ".join(query), page=int(result['page']) + 1) - ) - else: - break - - -@cli.command("install", short_help="Install library") -@click.argument("libid", type=click.INT, nargs=-1, metavar="[LIBRARY_ID]") -@click.option("-v", "--version") -@click.pass_context -def lib_install(ctx, libid, version): - lm = LibraryManager() - for id_ in libid: - click.echo( - "Installing library [ %s ]:" % click.style(str(id_), fg="green")) - try: - if not lm.install(id_, version): - continue - - info = lm.get_info(id_) + if noninteractive: + click.echo() click.secho( - "The library #%s '%s' has been successfully installed!" - % (str(id_), info['name']), fg="green") - - if "dependencies" in info: - click.secho("Installing dependencies:", fg="yellow") - _dependencies = info['dependencies'] - if not isinstance(_dependencies, list): - _dependencies = [_dependencies] - for item in _dependencies: - try: - lib_install_dependency(ctx, item) - except AssertionError: - raise exception.LibInstallDependencyError(str(item)) - - except exception.LibAlreadyInstalled: - click.secho("Already installed", fg="yellow") - - -def lib_install_dependency(ctx, data): - assert isinstance(data, dict) - query = [] - for key in data: - if key in ("authors", "frameworks", "platforms", "keywords"): - values = data[key] - if not isinstance(values, list): - values = [v.strip() for v in values.split(",") if v] - for value in values: - query.append('%s:"%s"' % (key[:-1], value)) - elif isinstance(data[key], basestring): - query.append('+"%s"' % data[key]) - - result = get_api_result("/lib/search", dict(query=" ".join(query))) - assert result['total'] > 0 - - if result['total'] == 1 or not app.get_setting("enable_prompts"): - ctx.invoke(lib_install, libid=[result['items'][0]['id']]) - else: - click.secho( - "Conflict: More than one dependent libraries have been found " - "by request %s:" % json.dumps(data), fg="red") - - echo_liblist_header() - for item in result['items']: - echo_liblist_item(item) - - deplib_id = click.prompt( - "Please choose one dependent library ID", - type=click.Choice([str(i['id']) for i in result['items']])) - ctx.invoke(lib_install, libid=[int(deplib_id)]) - - -@cli.command("uninstall", short_help="Uninstall libraries") -@click.argument("libid", type=click.INT, nargs=-1) -def lib_uninstall(libid): - lm = LibraryManager() - for id_ in libid: - info = lm.get_info(id_) - if lm.uninstall(id_): - click.secho("The library #%s '%s' has been successfully " - "uninstalled!" % (str(id_), info['name']), fg="green") + "Loading next %d libraries... Press Ctrl+C to stop!" % + result['perpage'], + fg="yellow") + click.echo() + sleep(5) + elif not click.confirm("Show next libraries?"): + break + result = get_api_result( + "/lib/search", + dict( + query=" ".join(query), page=int(result['page']) + 1)) @cli.command("list", short_help="List installed libraries") @click.option("--json-output", is_flag=True) -def lib_list(json_output): - lm = LibraryManager() - items = lm.get_installed().values() +@click.pass_obj +def lib_list(lm, json_output): + items = lm.get_installed() if json_output: click.echo(json.dumps(items)) @@ -208,21 +249,34 @@ def lib_list(json_output): return echo_liblist_header() - for item in sorted(items, key=lambda i: i['id']): - item['authornames'] = [i['name'] for i in item['authors']] + for item in sorted(items, key=lambda i: i['name']): + if "authors" in item: + item['authornames'] = [i['name'] for i in item['authors']] echo_liblist_item(item) @cli.command("show", short_help="Show details about installed library") -@click.argument("libid", type=click.INT) -def lib_show(libid): - lm = LibraryManager() - info = lm.get_info(libid) - click.secho(info['name'], fg="cyan") - click.echo("-" * len(info['name'])) +@click.pass_obj +@click.argument("library", metavar="[LIBRARY]") +def lib_show(lm, library): # pylint: disable=too-many-branches + name, requirements, url = lm.parse_pkg_name(library) + package_dir = lm.get_package_dir(name, requirements, url) + if not package_dir: + click.secho( + "%s @ %s is not installed" % (name, requirements or "*"), + fg="yellow") + return + + manifest = lm.load_manifest(package_dir) + + click.secho(manifest['name'], fg="cyan") + click.echo("=" * len(manifest['name'])) + if "description" in manifest: + click.echo(manifest['description']) + click.echo() _authors = [] - for author in info['authors']: + for author in manifest.get("authors", []): _data = [] for key in ("name", "email", "url", "maintainer"): if not author[key]: @@ -234,61 +288,29 @@ def lib_show(libid): else: _data.append(author[key]) _authors.append(" ".join(_data)) - click.echo("Authors: %s" % ", ".join(_authors)) + if _authors: + click.echo("Authors: %s" % ", ".join(_authors)) - click.echo("Keywords: %s" % ", ".join(info['keywords'])) - if "frameworks" in info: - click.echo("Frameworks: %s" % ", ".join(info['frameworks'])) - if "platforms" in info: - click.echo("Platforms: %s" % ", ".join(info['platforms'])) - click.echo("Version: %s" % info['version']) - click.echo() - click.echo(info['description']) - click.echo() - - -@cli.command("update", short_help="Update installed libraries") -@click.argument("libid", type=click.INT, nargs=-1, required=False, - metavar="[LIBRARY_ID]") -@click.pass_context -def lib_update(ctx, libid): - lm = LibraryManager() - for id_, latest_version in (lm.get_latest_versions() or {}).items(): - if libid and int(id_) not in libid: - continue - - info = lm.get_info(int(id_)) - - click.echo("Updating [ %s ] %s library:" % ( - click.style(id_, fg="yellow"), - click.style(info['name'], fg="cyan"))) - - current_version = info['version'] - if latest_version is None: - click.secho("Unknown library", fg="red") - continue - - click.echo("Versions: Current=%s, Latest=%s \t " % ( - current_version, latest_version), nl=False) - - if current_version == latest_version: - click.echo("[%s]" % (click.style("Up-to-date", fg="green"))) + for key in ("keywords", "frameworks", "platforms", "license", "url", + "version"): + if key not in manifest: continue + if isinstance(manifest[key], list): + click.echo("%s: %s" % (key.title(), ", ".join(manifest[key]))) else: - click.echo("[%s]" % (click.style("Out-of-date", fg="red"))) - - ctx.invoke(lib_uninstall, libid=[int(id_)]) - ctx.invoke(lib_install, libid=[int(id_)]) + click.echo("%s: %s" % (key.title(), manifest[key])) @cli.command("register", short_help="Register new library") @click.argument("config_url") def lib_register(config_url): - if (not config_url.startswith("http://") and not - config_url.startswith("https://")): + if (not config_url.startswith("http://") and + not config_url.startswith("https://")): raise exception.InvalidLibConfURL(config_url) result = get_api_result("/lib/register", data=dict(config_url=config_url)) if "message" in result and result['message']: - click.secho(result['message'], fg="green" if "successed" in result and - result['successed'] else "red") + click.secho( + result['message'], + fg="green" + if "successed" in result and result['successed'] else "red") diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py new file mode 100644 index 00000000..825422cb --- /dev/null +++ b/platformio/commands/platform.py @@ -0,0 +1,192 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json + +import click + +from platformio import exception, util +from platformio.managers.platform import PlatformFactory, PlatformManager + + +@click.group(short_help="Platform Manager") +def cli(): + pass + + +def _print_platforms(platforms): + for platform in platforms: + click.echo("{name} ~ {title}".format( + name=click.style( + platform['name'], fg="cyan"), + title=platform['title'])) + click.echo("=" * (3 + len(platform['name'] + platform['title']))) + click.echo(platform['description']) + click.echo() + click.echo("Home: %s" % "http://platformio.org/platforms/" + platform[ + 'name']) + if platform['packages']: + click.echo("Packages: %s" % ", ".join(platform['packages'])) + if "version" in platform: + click.echo("Version: " + platform['version']) + click.echo() + + +@cli.command("search", short_help="Search for development platform") +@click.argument("query", required=False) +@click.option("--json-output", is_flag=True) +def platform_search(query, json_output): + platforms = [] + for platform in util.get_api_result("/platforms"): + if query == "all": + query = "" + + search_data = json.dumps(platform) + if query and query.lower() not in search_data.lower(): + continue + + platforms.append({ + "name": platform['name'], + "title": platform['title'], + "description": platform['description'], + "packages": platform['packages'] + }) + + if json_output: + click.echo(json.dumps(platforms)) + else: + _print_platforms(platforms) + + +@cli.command("install", short_help="Install new development platform") +@click.argument("platforms", nargs=-1, required=True, metavar="[PLATFORM...]") +@click.option("--with-package", multiple=True) +@click.option("--without-package", multiple=True) +@click.option("--skip-default-package", is_flag=True) +def platform_install(platforms, with_package, without_package, + skip_default_package): + pm = PlatformManager() + for platform in platforms: + if pm.install( + name=platform, + with_packages=with_package, + without_packages=without_package, + skip_default_package=skip_default_package): + click.secho( + "The platform '%s' has been successfully installed!\n" + "The rest of packages will be installed automatically " + "depending on your build environment." % platform, + fg="green") + + +@cli.command("uninstall", short_help="Uninstall development platform") +@click.argument("platforms", nargs=-1, required=True, metavar="[PLATFORM...]") +def platform_uninstall(platforms): + pm = PlatformManager() + for platform in platforms: + if pm.uninstall(platform): + click.secho( + "The platform '%s' has been successfully " + "uninstalled!" % platform, + fg="green") + + +@cli.command("update", short_help="Update installed development platforms") +@click.argument("platforms", nargs=-1, required=False, metavar="[PLATFORM...]") +@click.option( + "-p", + "--only-packages", + is_flag=True, + help="Update only platform packages") +@click.option( + "-c", + "--only-check", + is_flag=True, + help="Do not update, only check for new version") +def platform_update(platforms, only_packages, only_check): + pm = PlatformManager() + if not platforms: + platforms = set([m['name'] for m in pm.get_installed()]) + for platform in platforms: + click.echo("Platform %s" % click.style(platform, fg="cyan")) + click.echo("--------") + pm.update(platform, only_packages=only_packages, only_check=only_check) + click.echo() + + +@cli.command("list", short_help="List installed development platforms") +@click.option("--json-output", is_flag=True) +def platform_list(json_output): + platforms = [] + pm = PlatformManager() + for manifest in pm.get_installed(): + p = PlatformFactory.newPlatform( + pm.get_manifest_path(manifest['__pkg_dir'])) + platforms.append({ + "name": p.name, + "title": p.title, + "description": p.description, + "version": p.version, + "url": p.vendor_url, + "packages": p.get_installed_packages().keys(), + 'forDesktop': any([ + p.name.startswith(n) for n in ("native", "linux", "windows") + ]) + }) + + if json_output: + click.echo(json.dumps(platforms)) + else: + _print_platforms(platforms) + + +@cli.command("show", short_help="Show details about installed platform") +@click.argument("platform") +def platform_show(platform): + try: + p = PlatformFactory.newPlatform(platform) + except exception.UnknownPlatform: + raise exception.PlatformNotInstalledYet(platform) + + click.echo("{name} ~ {title}".format( + name=click.style( + p.name, fg="cyan"), title=p.title)) + click.echo("=" * (3 + len(p.name + p.title))) + click.echo(p.description) + click.echo() + click.echo("Version: %s" % p.version) + if p.homepage: + click.echo("Home: %s" % p.homepage) + if p.license: + click.echo("License: %s" % p.license) + if p.frameworks: + click.echo("Frameworks: %s" % ", ".join(p.frameworks.keys())) + + if not p.packages: + return + + installed_pkgs = p.get_installed_packages() + for name, opts in p.packages.items(): + click.echo() + click.echo("Package %s" % click.style(name, fg="yellow")) + click.echo("-" * (8 + len(name))) + if p.get_package_type(name): + click.echo("Type: %s" % p.get_package_type(name)) + click.echo("Requirements: %s" % opts.get("version")) + click.echo("Installed: %s" % ("Yes" if name in installed_pkgs else + "No (optional)")) + if name in installed_pkgs: + for key, value in installed_pkgs[name].items(): + if key in ("url", "version", "description"): + click.echo("%s: %s" % (key.title(), value)) diff --git a/platformio/commands/platforms.py b/platformio/commands/platforms.py deleted file mode 100644 index 70af83b3..00000000 --- a/platformio/commands/platforms.py +++ /dev/null @@ -1,169 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -from datetime import datetime - -import click - -from platformio import app -from platformio.exception import PlatformNotInstalledYet -from platformio.pkgmanager import PackageManager -from platformio.platforms.base import PlatformFactory - - -@click.group(short_help="Platforms and Packages Manager") -def cli(): - pass - - -@cli.command("install", short_help="Install new platforms") -@click.argument("platforms", nargs=-1, required=True) -@click.option("--with-package", multiple=True, metavar="") -@click.option("--without-package", multiple=True, metavar="") -@click.option("--skip-default-package", is_flag=True) -def platforms_install(platforms, with_package, without_package, - skip_default_package): - for platform in platforms: - p = PlatformFactory.newPlatform(platform) - if p.install(with_package, without_package, skip_default_package): - click.secho( - "The platform '%s' has been successfully installed!\n" - "The rest of packages will be installed automatically " - "depending on your build environment." % platform, - fg="green") - - -@cli.command("list", short_help="List installed platforms") -@click.option("--json-output", is_flag=True) -def platforms_list(json_output): - - installed_platforms = PlatformFactory.get_platforms( - installed=True).keys() - installed_platforms.sort() - - data = [] - for platform in installed_platforms: - p = PlatformFactory.newPlatform(platform) - data.append({ - "name": platform, - "packages": p.get_installed_packages() - }) - - if json_output: - click.echo(json.dumps(data)) - else: - for item in data: - click.echo("{name:<20} with packages: {pkgs}".format( - name=click.style(item['name'], fg="cyan"), - pkgs=", ".join(item['packages']) - )) - - -@cli.command("search", short_help="Search for development platforms") -@click.argument("query", required=False) -@click.option("--json-output", is_flag=True) -def platforms_search(query, json_output): - - data = [] - platforms = PlatformFactory.get_platforms().keys() - platforms.sort() - for platform in platforms: - p = PlatformFactory.newPlatform(platform) - type_ = p.get_type() - description = p.get_description() - - if query == "all": - query = "" - - search_data = "%s %s %s" % (type_, description, p.get_packages()) - if query and query.lower() not in search_data.lower(): - continue - - data.append({ - "type": type_, - "description": description, - "packages": p.get_packages() - }) - - if json_output: - click.echo(json.dumps(data)) - else: - terminal_width, _ = click.get_terminal_size() - for item in data: - click.secho(item['type'], fg="cyan", nl=False) - click.echo(" (available packages: %s)" % ", ".join( - item.get("packages").keys())) - click.echo("-" * terminal_width) - click.echo(item['description']) - click.echo() - - -@cli.command("show", short_help="Show details about installed platform") -@click.argument("platform") -@click.pass_context -def platforms_show(ctx, platform): - - installed_platforms = PlatformFactory.get_platforms( - installed=True).keys() - - if platform not in installed_platforms: - if (not app.get_setting("enable_prompts") or - click.confirm("The platform '%s' has not been installed yet. " - "Would you like to install it now?" % platform)): - ctx.invoke(platforms_install, platforms=[platform]) - else: - raise PlatformNotInstalledYet(platform) - - p = PlatformFactory.newPlatform(platform) - click.echo("{name:<20} - {description} [ {url} ]".format( - name=click.style(p.get_type(), fg="cyan"), - description=p.get_description(), url=p.get_vendor_url())) - - installed_packages = PackageManager.get_installed() - for name in p.get_installed_packages(): - data = installed_packages[name] - pkgalias = p.get_package_alias(name) - click.echo("----------") - click.echo("Package: %s" % click.style(name, fg="yellow")) - if pkgalias: - click.echo("Alias: %s" % pkgalias) - click.echo("Version: %d" % int(data['version'])) - click.echo("Installed: %s" % datetime.fromtimestamp( - data['time']).strftime("%Y-%m-%d %H:%M:%S")) - - -@cli.command("uninstall", short_help="Uninstall platforms") -@click.argument("platforms", nargs=-1, required=True) -def platforms_uninstall(platforms): - - for platform in platforms: - p = PlatformFactory.newPlatform(platform) - if p.uninstall(): - click.secho("The platform '%s' has been successfully " - "uninstalled!" % platform, fg="green") - - -@cli.command("update", short_help="Update installed Platforms and Packages") -def platforms_update(): - - installed_platforms = PlatformFactory.get_platforms( - installed=True).keys() - installed_platforms.sort() - - for platform in installed_platforms: - click.echo("\nPlatform %s" % click.style(platform, fg="cyan")) - click.echo("--------") - p = PlatformFactory.newPlatform(platform) - p.update() diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 023d0a34..1b4899da 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,59 +16,69 @@ from datetime import datetime from hashlib import sha1 from os import getcwd, makedirs, walk from os.path import getmtime, isdir, isfile, join -from shutil import rmtree from time import time import click -from platformio import __version__, app, exception, telemetry, util +from platformio import __version__, exception, telemetry, util from platformio.commands.lib import lib_install as cmd_lib_install -from platformio.libmanager import LibraryManager -from platformio.platforms.base import PlatformFactory +from platformio.commands.platform import \ + platform_install as cmd_platform_install +from platformio.managers.lib import LibraryManager +from platformio.managers.platform import PlatformFactory + +# pylint: disable=too-many-arguments,too-many-locals,too-many-branches @click.command("run", short_help="Process project environments") -@click.option("--environment", "-e", multiple=True, metavar="") -@click.option("--target", "-t", multiple=True, metavar="") -@click.option("--upload-port", metavar="") -@click.option("--project-dir", "-d", default=getcwd, - type=click.Path(exists=True, file_okay=False, dir_okay=True, - writable=True, resolve_path=True)) -@click.option("--verbose", "-v", count=True, default=3) +@click.option("-e", "--environment", multiple=True) +@click.option("-t", "--target", multiple=True) +@click.option("--upload-port") +@click.option( + "-d", + "--project-dir", + default=getcwd, + type=click.Path( + exists=True, + file_okay=True, + dir_okay=True, + writable=True, + resolve_path=True)) +@click.option("-s", "--silent", is_flag=True) +@click.option("-v", "--verbose", is_flag=True) @click.option("--disable-auto-clean", is_flag=True) @click.pass_context -def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 - project_dir, verbose, disable_auto_clean): +def cli(ctx, environment, target, upload_port, project_dir, silent, verbose, + disable_auto_clean): + # find project directory on upper level + if isfile(project_dir): + project_dir = util.find_project_dir_above(project_dir) + + if not util.is_platformio_project(project_dir): + raise exception.NotPlatformIOProject(project_dir) + with util.cd(project_dir): - config = util.get_project_config() - - if not config.sections(): - raise exception.ProjectEnvsNotAvailable() - - known = set([s[4:] for s in config.sections() - if s.startswith("env:")]) - unknown = set(environment) - known - if unknown: - raise exception.UnknownEnvNames( - ", ".join(unknown), ", ".join(known)) - # clean obsolete .pioenvs dir if not disable_auto_clean: try: - _clean_pioenvs_dir(util.get_pioenvs_dir()) + _clean_pioenvs_dir(util.get_projectpioenvs_dir()) except: # pylint: disable=bare-except click.secho( "Can not remove temporary directory `%s`. Please remove " "`.pioenvs` directory from the project manually to avoid " - "build issues" % util.get_pioenvs_dir(), - fg="yellow" - ) + "build issues" % util.get_projectpioenvs_dir(force=True), + fg="yellow") + + config = util.load_project_config() + check_project_defopts(config) + assert check_project_envs(config, environment) env_default = None if config.has_option("platformio", "env_default"): env_default = [ e.strip() - for e in config.get("platformio", "env_default").split(",")] + for e in config.get("platformio", "env_default").split(",") + ] results = [] for section in config.sections(): @@ -80,9 +90,10 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 raise exception.InvalidEnvName(section) envname = section[4:] - if ((environment and envname not in environment) or - (not environment and env_default and - envname not in env_default)): + skipenv = any([environment and envname not in environment, + not environment and env_default and + envname not in env_default]) + if skipenv: # echo("Skipped %s environment" % style(envname, fg="yellow")) continue @@ -92,74 +103,111 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 options = {} for k, v in config.items(section): options[k] = v + if "piotest" not in options and "piotest" in ctx.meta: + options['piotest'] = ctx.meta['piotest'] - ep = EnvironmentProcessor( - ctx, envname, options, target, upload_port, verbose) + ep = EnvironmentProcessor(ctx, envname, options, target, + upload_port, silent, verbose) results.append(ep.process()) if not all(results): raise exception.ReturnErrorCode() + return True class EnvironmentProcessor(object): - RENAMED_OPTIONS = { - "INSTALL_LIBS": "LIB_INSTALL", - "IGNORE_LIBS": "LIB_IGNORE", - "USE_LIBS": "LIB_USE", - "LDF_CYCLIC": "LIB_DFCYCLIC", - "SRCBUILD_FLAGS": "SRC_BUILD_FLAGS" - } + KNOWN_OPTIONS = ( + "platform", "framework", "board", "board_mcu", "board_f_cpu", + "board_f_flash", "board_flash_mode", "build_flags", "src_build_flags", + "build_unflags", "src_filter", "extra_script", "targets", + "upload_port", "upload_protocol", "upload_speed", "upload_flags", + "upload_resetmethod", "lib_install", "lib_deps", "lib_force", + "lib_ignore", "lib_extra_dirs", "lib_ldf_mode", "lib_compat_mode", + "test_ignore", "piotest") - def __init__(self, cmd_ctx, name, options, # pylint: disable=R0913 - targets, upload_port, verbose): + REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"} + + RENAMED_OPTIONS = {"lib_use": "lib_force"} + + RENAMED_PLATFORMS = {"espressif": "espressif8266"} + + def __init__(self, # pylint: disable=R0913 + cmd_ctx, + name, + options, + targets, + upload_port, + silent, + verbose): self.cmd_ctx = cmd_ctx self.name = name - self.options = self._validate_options(options) + self.options = options self.targets = targets self.upload_port = upload_port - self.verbose_level = int(verbose) + self.silent = silent + self.verbose = verbose def process(self): terminal_width, _ = click.get_terminal_size() start_time = time() - click.echo("[%s] Processing %s (%s)" % ( - datetime.now().strftime("%c"), - click.style(self.name, fg="cyan", bold=True), - ", ".join(["%s: %s" % (k, v) for k, v in self.options.iteritems()]) - )) - click.secho("-" * terminal_width, bold=True) + process_opts = [] + for k, v in self.options.items(): + if "\n" in v: + process_opts.append((k, ", ".join( + [s.strip() for s in v.split("\n") if s.strip()]))) + else: + process_opts.append((k, v)) + click.echo("[%s] Processing %s (%s)" % + (datetime.now().strftime("%c"), click.style( + self.name, fg="cyan", bold=True), + ", ".join(["%s: %s" % opts for opts in process_opts]))) + click.secho("-" * terminal_width, bold=True) + if self.silent: + click.echo("Please wait...") + + self.options = self._validate_options(self.options) result = self._run() is_error = result['returncode'] != 0 - summary_text = " Took %.2f seconds " % (time() - start_time) - half_line = "=" * ((terminal_width - len(summary_text) - 10) / 2) - click.echo("%s [%s]%s%s" % ( - half_line, - (click.style(" ERROR ", fg="red", bold=True) - if is_error else click.style("SUCCESS", fg="green", bold=True)), - summary_text, - half_line - ), err=is_error) + if is_error or "piotest_processor" not in self.cmd_ctx.meta: + print_header( + "[%s] Took %.2f seconds" % ((click.style( + "ERROR", fg="red", bold=True) if is_error else click.style( + "SUCCESS", fg="green", bold=True)), + time() - start_time), + is_error=is_error) return not is_error def _validate_options(self, options): result = {} for k, v in options.items(): - _k = k.upper() # process obsolete options - if _k in self.RENAMED_OPTIONS: + if k in self.RENAMED_OPTIONS: click.secho( "Warning! `%s` option is deprecated and will be " "removed in the next release! Please use " - "`%s` instead." % ( - k, self.RENAMED_OPTIONS[_k].lower()), - fg="yellow" - ) - k = self.RENAMED_OPTIONS[_k].lower() + "`%s` instead." % (k, self.RENAMED_OPTIONS[k]), + fg="yellow") + k = self.RENAMED_OPTIONS[k] + # process renamed platforms + if k == "platform" and v in self.RENAMED_PLATFORMS: + click.secho( + "Warning! Platform `%s` is deprecated and will be " + "removed in the next release! Please use " + "`%s` instead." % (v, self.RENAMED_PLATFORMS[v]), + fg="yellow") + v = self.RENAMED_PLATFORMS[v] + + # warn about unknown options + if k not in self.KNOWN_OPTIONS: + click.secho( + "Warning! Ignore unknown `%s` option from `[env:]` section" + % k, + fg="yellow") result[k] = v return result @@ -168,7 +216,8 @@ class EnvironmentProcessor(object): if self.upload_port: variables['upload_port'] = self.upload_port for k, v in self.options.items(): - k = k.lower() + if k in self.REMAPED_OPTIONS: + k = self.REMAPED_OPTIONS[k] if k == "targets" or (k == "upload_port" and self.upload_port): continue variables[k] = v @@ -186,7 +235,6 @@ class EnvironmentProcessor(object): if "platform" not in self.options: raise exception.UndefinedEnvPlatform(self.name) - platform = self.options['platform'] build_vars = self._get_build_variables() build_targets = self._get_build_targets() @@ -194,28 +242,34 @@ class EnvironmentProcessor(object): # install dependent libraries if "lib_install" in self.options: - _autoinstall_libs(self.cmd_ctx, self.options['lib_install']) + _autoinstall_libdeps(self.cmd_ctx, [ + int(d.strip()) for d in self.options['lib_install'].split(",") + if d.strip() + ], self.verbose) + if "lib_deps" in self.options: + _autoinstall_libdeps(self.cmd_ctx, [ + d.strip() + for d in self.options['lib_deps'].split( + "\n" if "\n" in self.options['lib_deps'] else ", ") + if d.strip() + ], self.verbose) - p = PlatformFactory.newPlatform(platform) - return p.run(build_vars, build_targets, self.verbose_level) + try: + p = PlatformFactory.newPlatform(self.options['platform']) + except exception.UnknownPlatform: + self.cmd_ctx.invoke( + cmd_platform_install, platforms=[self.options['platform']]) + p = PlatformFactory.newPlatform(self.options['platform']) + + return p.run(build_vars, build_targets, self.silent, self.verbose) -def _autoinstall_libs(ctx, libids_list): - require_libs = [int(l.strip()) for l in libids_list.split(",")] - installed_libs = [ - l['id'] for l in LibraryManager().get_installed().values() - ] - - not_intalled_libs = set(require_libs) - set(installed_libs) - if not require_libs or not not_intalled_libs: - return - - if (not app.get_setting("enable_prompts") or - click.confirm( - "The libraries with IDs '%s' have not been installed yet. " - "Would you like to install them now?" % - ", ".join([str(i) for i in not_intalled_libs]))): - ctx.invoke(cmd_lib_install, libid=not_intalled_libs) +def _autoinstall_libdeps(ctx, libraries, verbose=False): + storage_dir = util.get_projectlibdeps_dir() + ctx.obj = LibraryManager(storage_dir) + if verbose: + click.echo("Library Storage: " + storage_dir) + ctx.invoke(cmd_lib_install, libraries=libraries, silent=not verbose) def _clean_pioenvs_dir(pioenvs_dir): @@ -226,14 +280,14 @@ def _clean_pioenvs_dir(pioenvs_dir): if (isdir(pioenvs_dir) and getmtime(join(util.get_project_dir(), "platformio.ini")) > getmtime(pioenvs_dir)): - rmtree(pioenvs_dir) + util.rmtree_(pioenvs_dir) # check project structure if isdir(pioenvs_dir) and isfile(structhash_file): with open(structhash_file) as f: if f.read() == proj_hash: return - rmtree(pioenvs_dir) + util.rmtree_(pioenvs_dir) if not isdir(pioenvs_dir): makedirs(pioenvs_dir) @@ -242,6 +296,39 @@ def _clean_pioenvs_dir(pioenvs_dir): f.write(proj_hash) +def print_header(label, is_error=False): + terminal_width, _ = click.get_terminal_size() + width = len(click.unstyle(label)) + half_line = "=" * ((terminal_width - width - 2) / 2) + click.echo("%s %s %s" % (half_line, label, half_line), err=is_error) + + +def check_project_defopts(config): + if not config.has_section("platformio"): + return True + known = ("home_dir", "lib_dir", "libdeps_dir", "src_dir", "envs_dir", + "data_dir", "test_dir", "env_default") + unknown = set([k for k, _ in config.items("platformio")]) - set(known) + if not unknown: + return True + click.secho( + "Warning! Ignore unknown `%s` option from `[platformio]` section" % + ", ".join(unknown), + fg="yellow") + return False + + +def check_project_envs(config, environments): + if not config.sections(): + raise exception.ProjectEnvsNotAvailable() + + known = set([s[4:] for s in config.sections() if s.startswith("env:")]) + unknown = set(environments) - known + if unknown: + raise exception.UnknownEnvNames(", ".join(unknown), ", ".join(known)) + return True + + def calculate_project_hash(): structure = [__version__] for d in (util.get_projectsrc_dir(), util.get_projectlib_dir()): diff --git a/platformio/commands/serialports.py b/platformio/commands/serialports.py deleted file mode 100644 index 19b69ddb..00000000 --- a/platformio/commands/serialports.py +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import sys - -import click -from serial import VERSION as PYSERIAL_VERSION -from serial.tools import miniterm - -from platformio import app -from platformio.exception import MinitermException -from platformio.util import get_serialports - - -@click.group(short_help="List or Monitor Serial ports") -def cli(): - pass - - -@cli.command("list", short_help="List Serial ports") -@click.option("--json-output", is_flag=True) -def serialports_list(json_output): - - if json_output: - click.echo(json.dumps(get_serialports())) - return - - for item in get_serialports(): - click.secho(item['port'], fg="cyan") - click.echo("-" * len(item['port'])) - click.echo("Hardware ID: %s" % item['hwid']) - click.echo("Description: %s" % item['description']) - click.echo("") - - -if int(PYSERIAL_VERSION[0]) == 3: - @cli.command("monitor", short_help="Monitor Serial port") - @click.option("--port", "-p", help="Port, a number or a device name") - @click.option("--baud", "-b", type=int, default=9600, - help="Set baud rate, default=9600") - @click.option("--parity", default="N", - type=click.Choice(["N", "E", "O", "S", "M"]), - help="Set parity, default=N") - @click.option("--rtscts", is_flag=True, - help="Enable RTS/CTS flow control, default=Off") - @click.option("--xonxoff", is_flag=True, - help="Enable software flow control, default=Off") - @click.option("--rts", default=None, type=click.Choice(["0", "1"]), - help="Set initial RTS line state") - @click.option("--dtr", default=None, type=click.Choice(["0", "1"]), - help="Set initial DTR line state") - @click.option("--echo", is_flag=True, - help="Enable local echo, default=Off") - @click.option("--encoding", default="UTF-8", - help="Set the encoding for the serial port (e.g. hexlify, " - "Latin1, UTF-8), default: UTF-8") - @click.option("--filter", "-f", multiple=True, - help="Add text transformation") - @click.option("--eol", default="CRLF", - type=click.Choice(["CR", "LF", "CRLF"]), - help="End of line mode, default=CRLF") - @click.option("--raw", is_flag=True, - help="Do not apply any encodings/transformations") - @click.option("--exit-char", type=int, default=29, - help="ASCII code of special character that is used to exit " - "the application, default=29 (DEC)") - @click.option("--menu-char", type=int, default=20, - help="ASCII code of special character that is used to " - "control miniterm (menu), default=20 (DEC)") - @click.option("--quiet", is_flag=True, - help="Diagnostics: suppress non-error messages, default=Off") - def serialports_monitor(**kwargs): - if not kwargs['port']: - for item in get_serialports(): - if "VID:PID" in item['hwid']: - kwargs['port'] = item['port'] - break - - sys.argv = ["monitor"] - for k, v in kwargs.iteritems(): - if k in ("port", "baud", "rts", "dtr"): - continue - k = "--" + k.replace("_", "-") - if isinstance(v, bool): - if v: - sys.argv.append(k) - elif isinstance(v, tuple): - for i in v: - sys.argv.extend([k, i]) - else: - sys.argv.extend([k, str(v)]) - - try: - miniterm.main( # pylint: disable=E1123 - default_port=kwargs['port'], - default_baudrate=kwargs['baud'], - default_rts=kwargs['rts'], - default_dtr=kwargs['dtr'] - ) - except Exception as e: # pylint: disable=W0702 - raise MinitermException(e) -else: - @cli.command("monitor", short_help="Monitor Serial port") - @click.option("--port", "-p", help="Port, a number or a device name") - @click.option("--baud", "-b", type=int, default=9600, - help="Set baud rate, default=9600") - @click.option("--parity", default="N", - type=click.Choice(["N", "E", "O", "S", "M"]), - help="Set parity, default=N") - @click.option("--rtscts", is_flag=True, - help="Enable RTS/CTS flow control, default=Off") - @click.option("--xonxoff", is_flag=True, - help="Enable software flow control, default=Off") - @click.option("--rts", default=None, type=click.Choice(["0", "1"]), - help="Set initial RTS line state, default=0") - @click.option("--dtr", default=None, type=click.Choice(["0", "1"]), - help="Set initial DTR line state, default=0") - @click.option("--echo", is_flag=True, - help="Enable local echo, default=Off") - @click.option("--cr", is_flag=True, - help="Do not send CR+LF, send CR only, default=Off") - @click.option("--lf", is_flag=True, - help="Do not send CR+LF, send LF only, default=Off") - @click.option("--debug", "-d", count=True, - help="""Debug received data (escape non-printable chars) - # --debug can be given multiple times: - # 0: just print what is received - # 1: escape non-printable characters, do newlines as unusual - # 2: escape non-printable characters, newlines too - # 3: hex dump everything""") - @click.option("--exit-char", type=int, default=29, - help="ASCII code of special character that is used to exit " - "the application, default=29 (DEC)") - @click.option("--menu-char", type=int, default=20, - help="ASCII code of special character that is used to " - "control miniterm (menu), default=20 (DEC)") - @click.option("--quiet", is_flag=True, - help="Diagnostics: suppress non-error messages, default=Off") - def serialports_monitor(**kwargs): - sys.argv = app.get_session_var("command_ctx").args[1:] - - if not kwargs['port']: - for item in get_serialports(): - if "VID:PID" in item['hwid']: - sys.argv += ["--port", item['port']] - break - - try: - miniterm.main() - except Exception as e: # pylint: disable=W0702 - raise MinitermException(e) diff --git a/platformio/commands/settings.py b/platformio/commands/settings.py index 43be3c8d..478ed527 100644 --- a/platformio/commands/settings.py +++ b/platformio/commands/settings.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,12 +29,14 @@ def settings_get(name): list_tpl = "{name:<40} {value:<35} {description}" terminal_width, _ = click.get_terminal_size() - click.echo(list_tpl.format( - name=click.style("Name", fg="cyan"), - value=(click.style("Value", fg="green") + - click.style(" [Default]", fg="yellow")), - description="Description" - )) + click.echo( + list_tpl.format( + name=click.style( + "Name", fg="cyan"), + value=(click.style( + "Value", fg="green") + click.style( + " [Default]", fg="yellow")), + description="Description")) click.echo("-" * terminal_width) for _name, _data in sorted(app.DEFAULT_SETTINGS.items()): @@ -55,11 +57,12 @@ def settings_get(name): else: _value_str += click.style(" ", fg="yellow") - click.echo(list_tpl.format( - name=click.style(_name, fg="cyan"), - value=_value_str, - description=_data['description'] - )) + click.echo( + list_tpl.format( + name=click.style( + _name, fg="cyan"), + value=_value_str, + description=_data['description'])) @cli.command("set", short_help="Set new value for the setting") diff --git a/platformio/commands/test.py b/platformio/commands/test.py new file mode 100644 index 00000000..420c7082 --- /dev/null +++ b/platformio/commands/test.py @@ -0,0 +1,39 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +from os import getcwd + +import click + +from platformio.pioplus import pioplus_call + + +@click.command("test", short_help="Unit Testing") +@click.option("--environment", "-e", multiple=True, metavar="") +@click.option("--ignore", "-i", multiple=True, metavar="") +@click.option("--upload-port", metavar="") +@click.option( + "-d", + "--project-dir", + default=getcwd, + type=click.Path( + exists=True, + file_okay=False, + dir_okay=True, + writable=True, + resolve_path=True)) +@click.option("--verbose", "-v", is_flag=True) +def cli(*args, **kwargs): # pylint: disable=unused-argument + pioplus_call(sys.argv[1:]) diff --git a/platformio/commands/update.py b/platformio/commands/update.py index 52627a7a..2d32ef48 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,14 +15,27 @@ import click from platformio.commands.lib import lib_update as cmd_lib_update -from platformio.commands.platforms import \ - platforms_update as cmd_platforms_update +from platformio.commands.platform import platform_update as cmd_platform_update +from platformio.managers.lib import LibraryManager +from platformio.pioplus import pioplus_update -@click.command("update", - short_help="Update installed Platforms, Packages and Libraries") +@click.command( + "update", short_help="Update installed Platforms, Packages and Libraries") +@click.option( + "-c", + "--only-check", + is_flag=True, + help="Do not update, only check for new version") @click.pass_context -def cli(ctx): - ctx.invoke(cmd_platforms_update) +def cli(ctx, only_check): + click.echo("Platform Manager") + click.echo("================") + ctx.invoke(cmd_platform_update, only_check=only_check) + pioplus_update() + click.echo() - ctx.invoke(cmd_lib_update) + click.echo("Library Manager") + click.echo("===============") + ctx.obj = LibraryManager() + ctx.invoke(cmd_lib_update, only_check=only_check) diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 24676bf1..ef613fc8 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,49 +12,36 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import sys +import re import click import requests -from platformio import __version__, exception, util +from platformio import VERSION, __version__, exception, util -@click.command("upgrade", - short_help="Upgrade PlatformIO to the latest version") +@click.command( + "upgrade", short_help="Upgrade PlatformIO to the latest version") def cli(): - last = get_latest_version() - if __version__ == last: + latest = get_latest_version() + if __version__ == latest: return click.secho( "You're up-to-date!\nPlatformIO %s is currently the " - "newest version available." % __version__, fg="green" - ) + "newest version available." % __version__, + fg="green") else: - click.secho("Please wait while upgrading PlatformIO ...", - fg="yellow") + click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") - to_develop = False - try: - from pkg_resources import parse_version - to_develop = parse_version(last) < parse_version(__version__) - except ImportError: - pass - - cmds = ( - ["pip", "install", "--upgrade", - "https://github.com/platformio/platformio/archive/develop.zip" - if to_develop else "platformio"], - ["platformio", "--version"] - ) + to_develop = not all([c.isdigit() for c in latest if c != "."]) + cmds = (["pip", "install", "--upgrade", + "https://github.com/platformio/platformio/archive/develop.zip" + if to_develop else "platformio"], ["platformio", "--version"]) cmd = None r = None try: for cmd in cmds: - if sys.version_info < (2, 7, 0): - cmd[0] += ".__main__" - cmd = [os.path.normpath(sys.executable), "-m"] + cmd + cmd = [util.get_pythonexe_path(), "-m"] + cmd r = None r = util.exec_command(cmd) @@ -68,21 +55,19 @@ def cli(): actual_version = r['out'].strip().split("version", 1)[1].strip() click.secho( "PlatformIO has been successfully upgraded to %s" % - actual_version, fg="green") + actual_version, + fg="green") click.echo("Release notes: ", nl=False) - click.secho("http://docs.platformio.org/en/stable/history.html", - fg="cyan") + click.secho( + "http://docs.platformio.org/en/stable/history.html", fg="cyan") except Exception as e: # pylint: disable=W0703 if not r: - raise exception.UpgradeError( - "\n".join([str(cmd), str(e)])) - permission_errors = ( - "permission denied", - "not permitted" - ) + raise exception.UpgradeError("\n".join([str(cmd), str(e)])) + 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()): - click.secho(""" + click.secho( + """ ----------------- Permission denied ----------------- @@ -91,19 +76,50 @@ You need the `sudo` permission to install Python packages. Try > sudo pip install -U platformio WARNING! Don't use `sudo` for the rest PlatformIO commands. -""", fg="yellow", err=True) +""", + fg="yellow", + err=True) raise exception.ReturnErrorCode() else: - raise exception.UpgradeError( - "\n".join([str(cmd), r['out'], r['err']])) + raise exception.UpgradeError("\n".join([str(cmd), r['out'], r[ + 'err']])) def get_latest_version(): try: - pkgdata = requests.get( - "https://pypi.python.org/pypi/platformio/json", - headers=util.get_request_defheaders() - ).json() - return pkgdata['info']['version'] + if not str(VERSION[2]).isdigit(): + try: + return get_develop_latest_version() + except: # pylint: disable=bare-except + pass + return get_pypi_latest_version() except: raise exception.GetLatestVersionError() + + +def get_develop_latest_version(): + version = None + r = requests.get("https://raw.githubusercontent.com/platformio/platformio" + "/develop/platformio/__init__.py", + headers=util.get_request_defheaders()) + r.raise_for_status() + for line in r.text.split("\n"): + line = line.strip() + if not line.startswith("VERSION"): + continue + match = re.match(r"VERSION\s*=\s*\(([^\)]+)\)", line) + if not match: + continue + version = match.group(1) + for c in (" ", "'", '"'): + version = version.replace(c, "") + version = ".".join(version.split(",")) + assert version + return version + + +def get_pypi_latest_version(): + r = requests.get("https://pypi.python.org/pypi/platformio/json", + headers=util.get_request_defheaders()) + r.raise_for_status() + return r.json()['info']['version'] diff --git a/platformio/downloader.py b/platformio/downloader.py index bbb90e07..f35aeda4 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,22 +30,25 @@ class FileDownloader(object): CHUNK_SIZE = 1024 def __init__(self, url, dest_dir=None): - self._url = url - self._fname = url.split("/")[-1] - - self._destination = self._fname - if dest_dir: - self.set_destination(join(dest_dir, self._fname)) - - self._progressbar = None - self._request = None - # make connection - self._request = requests.get(url, stream=True, + self._request = requests.get(url, + stream=True, headers=util.get_request_defheaders()) if self._request.status_code != 200: raise FDUnrecognizedStatusCode(self._request.status_code, url) + disposition = self._request.headers.get("content-disposition") + if disposition and "filename=" in disposition: + self._fname = disposition[disposition.index("filename=") + + 9:].replace('"', "").replace("'", "") + else: + self._fname = url.split("/")[-1] + + self._progressbar = None + self._destination = self._fname + if dest_dir: + self.set_destination(join(dest_dir, self._fname)) + def set_destination(self, destination): self._destination = destination @@ -53,7 +56,7 @@ class FileDownloader(object): return self._destination def get_lmtime(self): - return self._request.headers['last-modified'] + return self._request.headers.get("last-modified") def get_size(self): if "content-length" not in self._request.headers: @@ -77,7 +80,8 @@ class FileDownloader(object): f.close() self._request.close() - self._preserve_filemtime(self.get_lmtime()) + if self.get_lmtime(): + self._preserve_filemtime(self.get_lmtime()) def verify(self, sha1=None): _dlsize = getsize(self._destination) diff --git a/platformio/exception.py b/platformio/exception.py index 07fa0248..5d8f3b76 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ class UnknownPlatform(PlatformioException): class PlatformNotInstalledYet(PlatformioException): MESSAGE = "The platform '{0}' has not been installed yet. "\ - "Use `platformio platforms install {0}` command" + "Use `platformio platform install {0}` command" class BoardNotDefined(PlatformioException): @@ -57,7 +57,12 @@ class BoardNotDefined(PlatformioException): class UnknownBoard(PlatformioException): - MESSAGE = "Unknown board type '{0}'" + MESSAGE = "Unknown board ID '{0}'" + + +class InvalidBoardManifest(PlatformioException): + + MESSAGE = "Invalid board JSON manifest '{0}'" class UnknownFramework(PlatformioException): @@ -70,14 +75,21 @@ class UnknownPackage(PlatformioException): MESSAGE = "Detected unknown package '{0}'" -class InvalidPackageVersion(PlatformioException): +class MissingPackageManifest(PlatformioException): - MESSAGE = "The package '{0}' with version '{1:d}' does not exist" + MESSAGE = "Could not find '{0}' manifest file in the package" -class NonSystemPackage(PlatformioException): +class UndefinedPackageVersion(PlatformioException): - MESSAGE = "The package '{0}' is not available for your system '{1}'" + MESSAGE = "Could not find a version that satisfies the requirement '{0}'"\ + " for your system '{1}'" + + +class PackageInstallError(PlatformioException): + + MESSAGE = "Can not install '{0}' with version requirements '{1}' "\ + "for your system '{2}'" class FDUnrecognizedStatusCode(PlatformioException): @@ -97,7 +109,7 @@ class FDSHASumMismatch(PlatformioException): "is not equal to remote '{2}'" -class NotPlatformProject(PlatformioException): +class NotPlatformIOProject(PlatformioException): MESSAGE = "Not a PlatformIO project. `platformio.ini` file has not been "\ "found in current working directory ({0}). To initialize new project "\ @@ -144,18 +156,19 @@ class APIRequestError(PlatformioException): MESSAGE = "[API] {0}" -class LibAlreadyInstalled(PlatformioException): - pass +class LibNotFound(PlatformioException): + + MESSAGE = "Library `{0}` has not been found in the registry" -class LibNotInstalled(PlatformioException): +class NotGlobalLibDir(PlatformioException): - MESSAGE = "Library #{0:d} has not been installed yet" - - -class LibInstallDependencyError(PlatformioException): - - MESSAGE = "Error has been occurred for library dependency '{0}'" + MESSAGE = "The `{0}` is not a PlatformIO project.\n\n"\ + "To manage libraries "\ + "in global storage `{1}`,\n"\ + "please use `platformio lib --global {2}` or specify custom "\ + "storage `platformio lib --storage-dir /path/to/storage/ {2}`."\ + "\nCheck `platformio lib --help` for details." class InvalidLibConfURL(PlatformioException): @@ -185,6 +198,13 @@ class CIBuildEnvsEmpty(PlatformioException): "predefined environments using `--project-conf` option" +class TestDirEmpty(PlatformioException): + + MESSAGE = "Test directory '{0}' is empty. More details about Unit "\ + "Testing:\n http://docs.platformio.org/en/stable/platforms/"\ + "unit_testing.html" + + class UpgradeError(PlatformioException): MESSAGE = """{0} diff --git a/platformio/ide/__init__.py b/platformio/ide/__init__.py index 0c05c3b0..95899c71 100644 --- a/platformio/ide/__init__.py +++ b/platformio/ide/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 4c0a4365..03df1840 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,9 +15,7 @@ import json import os import re -import sys -from os.path import (abspath, basename, expanduser, isdir, isfile, join, - normpath, relpath) +from os.path import abspath, basename, expanduser, isdir, isfile, join, relpath import bottle @@ -46,34 +44,24 @@ class ProjectGenerator(object): @util.memoized def get_project_env(self): data = {"env_name": "PlatformIO"} - 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 - if self.board == data.get("board"): - break + config = util.load_project_config(self.project_dir) + 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 + if self.board == data.get("board"): + break return data @util.memoized def get_project_build_data(self): - data = { - "defines": [], - "includes": [], - "cxx_path": None - } + data = {"defines": [], "includes": [], "cxx_path": None} envdata = self.get_project_env() if "env_name" not in envdata: return data - cmd = [ - normpath(sys.executable), "-m", - "platformio" + ( - ".__main__" if sys.version_info < (2, 7, 0) else ""), - "-f" - ] + cmd = [util.get_pythonexe_path(), "-m", "platformio", "-f"] if app.get_session_var("caller_id"): cmd.extend(["-c", app.get_session_var("caller_id")]) cmd.extend(["run", "-t", "idedata", "-e", envdata['env_name']]) @@ -81,8 +69,8 @@ class ProjectGenerator(object): result = util.exec_command(cmd) if result['returncode'] != 0 or '"includes":' not in result['out']: - raise exception.PlatformioException( - "\n".join([result['out'], result['err']])) + raise exception.PlatformioException("\n".join([result['out'], + result['err']])) output = result['out'] start_index = output.index('{"') @@ -126,8 +114,7 @@ class ProjectGenerator(object): file_name = basename(tpl_path)[:-4] self._merge_contents( join(dst_dir, file_name), - self._render_tpl(tpl_path).encode("utf8") - ) + self._render_tpl(tpl_path).encode("utf8")) def _render_tpl(self, tpl_path): content = "" @@ -162,13 +149,13 @@ class ProjectGenerator(object): "project_dir": self.project_dir, "project_src_dir": self.project_src_dir, "systype": util.get_systype(), - "platformio_path": self._fix_os_path( - util.where_is_program("platformio")), + "platformio_path": + self._fix_os_path(util.where_is_program("platformio")), "env_pathsep": os.pathsep, "env_path": self._fix_os_path(os.getenv("PATH")) }) @staticmethod def _fix_os_path(path): - return (re.sub(r"[\\]+", '\\' * 4, path) if "windows" in - util.get_systype() else path) + return (re.sub(r"[\\]+", '\\' * 4, path) + if "windows" in util.get_systype() else path) diff --git a/platformio/libmanager.py b/platformio/libmanager.py deleted file mode 100644 index 964b10d0..00000000 --- a/platformio/libmanager.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import re -from os import listdir, makedirs, remove, rename -from os.path import isdir, isfile, join -from shutil import rmtree -from tempfile import gettempdir - -from platformio import telemetry, util -from platformio.downloader import FileDownloader -from platformio.exception import LibAlreadyInstalled, LibNotInstalled -from platformio.unpacker import FileUnpacker - - -class LibraryManager(object): - - CONFIG_NAME = ".library.json" - - def __init__(self, lib_dir=None): - self.lib_dir = lib_dir or util.get_lib_dir() - - @staticmethod - def download(url, dest_dir): - fd = FileDownloader(url, dest_dir) - fd.start() - return fd.get_filepath() - - @staticmethod - def unpack(pkgpath, dest_dir): - fu = FileUnpacker(pkgpath, dest_dir) - return fu.start() - - def get_installed(self): - items = {} - if not isdir(self.lib_dir): - return items - for dirname in sorted(listdir(self.lib_dir)): - conf_path = join(self.lib_dir, dirname, self.CONFIG_NAME) - if not isfile(conf_path): - continue - items[dirname] = util.load_json(conf_path) - return items - - def get_latest_versions(self): - lib_ids = [str(item['id']) for item in self.get_installed().values()] - if not lib_ids: - return None - return util.get_api_result("/lib/version/" + str(",".join(lib_ids))) - - def get_outdated(self): - outdated = [] - for id_, latest_version in (self.get_latest_versions() or {}).items(): - info = self.get_info(int(id_)) - if latest_version != info['version']: - outdated.append(info['name']) - return outdated - - def get_info(self, id_): - for item in self.get_installed().values(): - if "id" in item and item['id'] == id_: - return item - raise LibNotInstalled(id_) - - def is_installed(self, id_): - try: - return int(self.get_info(id_)['id']) == id_ - except LibNotInstalled: - return False - - def install(self, id_, version=None): - if self.is_installed(id_): - raise LibAlreadyInstalled() - - dlinfo = util.get_api_result( - "/lib/download/" + str(id_), - dict(version=version) if version else None - ) - dlpath = None - tmplib_dir = join(self.lib_dir, str(id_)) - try: - dlpath = self.download(dlinfo['url'], gettempdir()) - if not isdir(tmplib_dir): - makedirs(tmplib_dir) - self.unpack(dlpath, tmplib_dir) - finally: - if dlpath: - remove(dlpath) - - info = self.get_info(id_) - rename(tmplib_dir, join(self.lib_dir, "%s_ID%d" % ( - re.sub(r"[^\da-zA-Z]+", "_", info['name']), id_))) - - telemetry.on_event( - category="LibraryManager", action="Install", - label="#%d %s" % (id_, info['name']) - ) - - return True - - def uninstall(self, id_): - for libdir, item in self.get_installed().iteritems(): - if "id" in item and item['id'] == id_: - rmtree(join(self.lib_dir, libdir)) - telemetry.on_event( - category="LibraryManager", action="Uninstall", - label="#%d %s" % (id_, item['name']) - ) - return True - raise LibNotInstalled(id_) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 4832793d..cb169092 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,25 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -import re -import struct -from os import getenv, remove -from os.path import isdir, isfile, join -from shutil import rmtree +import json +import os +from os import getenv +from os.path import isdir, join from time import time import click +import semantic_version from platformio import __version__, app, exception, telemetry, util -from platformio.commands.lib import lib_update as cmd_libraries_update -from platformio.commands.platforms import \ - platforms_install as cmd_platforms_install -from platformio.commands.platforms import \ - platforms_update as cmd_platforms_update +from platformio.commands.lib import lib_update as cmd_lib_update +from platformio.commands.platform import \ + platform_install as cmd_platform_install +from platformio.commands.platform import \ + platform_uninstall as cmd_platform_uninstall +from platformio.commands.platform import platform_update as cmd_platform_update from platformio.commands.upgrade import get_latest_version -from platformio.libmanager import LibraryManager -from platformio.platforms.base import PlatformFactory -from platformio.util import get_home_dir +from platformio.managers.lib import LibraryManager +from platformio.managers.platform import PlatformManager +from platformio.pioplus import pioplus_update def in_silence(ctx): @@ -40,6 +41,12 @@ def in_silence(ctx): def on_platformio_start(ctx, force, caller): + if not caller: + if getenv("PLATFORMIO_CALLER"): + caller = getenv("PLATFORMIO_CALLER") + elif getenv("C9_UID"): + caller = "C9" + app.set_session_var("command_ctx", ctx) app.set_session_var("force_option", force) app.set_session_var("caller_id", caller) @@ -58,8 +65,10 @@ def on_platformio_end(ctx, result): # pylint: disable=W0613 check_internal_updates(ctx, "platforms") check_internal_updates(ctx, "libraries") except (exception.GetLatestVersionError, exception.APIRequestError): - click.secho("Failed to check for PlatformIO upgrades. " - "Please check your Internet connection.", fg="red") + click.secho( + "Failed to check for PlatformIO upgrades. " + "Please check your Internet connection.", + fg="red") def on_platformio_exception(e): @@ -69,21 +78,15 @@ def on_platformio_exception(e): class Upgrader(object): def __init__(self, from_version, to_version): - self.from_version = self.version_to_int(from_version) - self.to_version = self.version_to_int(to_version) + self.from_version = semantic_version.Version.coerce( + util.pepver_to_semver(from_version)) + self.to_version = semantic_version.Version.coerce( + util.pepver_to_semver(to_version)) - self._upgraders = ( - (self.version_to_int("0.9.0"), self._upgrade_to_0_9_0), - (self.version_to_int("1.0.0"), self._upgrade_to_1_0_0) - ) - - @staticmethod - def version_to_int(version): - match = re.match(r"(\d+)\.(\d+)\.(\d+)(\D+)?", version) - assert match is not None and len(match.groups()) is 4 - verchrs = [chr(int(match.group(i))) for i in range(1, 4)] - verchrs.append(chr(255 if match.group(4) is None else 0)) - return struct.unpack(">I", "".join(verchrs)) + self._upgraders = [ + (semantic_version.Version("3.0.0-a1"), self._upgrade_to_3_0_0), + (semantic_version.Version("3.0.0-b11"), self._upgrade_to_3_0_0) + ] def run(self, ctx): if self.from_version > self.to_version: @@ -91,97 +94,108 @@ class Upgrader(object): result = [True] for item in self._upgraders: - if self.from_version >= item[0]: + if self.from_version >= item[0] or self.to_version < item[0]: continue result.append(item[1](ctx)) return all(result) - def _upgrade_to_0_9_0(self, ctx): # pylint: disable=R0201 - prev_platforms = [] + @staticmethod + def _upgrade_to_3_0_0(ctx): + # convert custom board configuration + boards_dir = join(util.get_home_dir(), "boards") + if isdir(boards_dir): + for item in os.listdir(boards_dir): + if not item.endswith(".json"): + continue + data = util.load_json(join(boards_dir, item)) + if set(["name", "url", "vendor"]) <= set(data.keys()): + continue + os.remove(join(boards_dir, item)) + for key, value in data.items(): + with open(join(boards_dir, "%s.json" % key), "w") as f: + json.dump(value, f, sort_keys=True, indent=2) - # remove platform's folder (obsolete package structure) - for name in PlatformFactory.get_platforms(): - pdir = join(get_home_dir(), name) - if not isdir(pdir): - continue - prev_platforms.append(name) - rmtree(pdir) - - # remove unused files - for fname in (".pioupgrade", "installed.json"): - if isfile(join(get_home_dir(), fname)): - remove(join(get_home_dir(), fname)) - - if prev_platforms: - ctx.invoke(cmd_platforms_install, platforms=prev_platforms) - - return True - - def _upgrade_to_1_0_0(self, ctx): # pylint: disable=R0201 - installed_platforms = PlatformFactory.get_platforms( - installed=True).keys() + # re-install PlatformIO 2.0 development platforms + installed_platforms = app.get_state_item("installed_platforms", []) if installed_platforms: - ctx.invoke(cmd_platforms_install, platforms=installed_platforms) + if "espressif" in installed_platforms: + installed_platforms[installed_platforms.index( + "espressif")] = "espressif8266" + ctx.invoke(cmd_platform_install, platforms=installed_platforms) + return True + @staticmethod + def _upgrade_to_3_0_0b11(ctx): + current_platforms = [m['name'] + for m in PlatformManager().get_installed()] + if "espressif" not in current_platforms: + return + ctx.invoke(cmd_platform_install, platforms=["espressif8266"]) + ctx.invoke(cmd_platform_uninstall, platforms=["espressif"]) + def after_upgrade(ctx): last_version = app.get_state_item("last_version", "0.0.0") if last_version == __version__: return - terminal_width, _ = click.get_terminal_size() - - # promotion - click.echo("") - click.echo("*" * terminal_width) - click.echo("If you like %s, please:" % ( - click.style("PlatformIO", fg="cyan") - )) - click.echo( - "- %s us on Twitter to stay up-to-date " - "on the latest project news > %s" % - (click.style("follow", fg="cyan"), - click.style("https://twitter.com/PlatformIO_Org", fg="cyan")) - ) - click.echo("- %s it on GitHub > %s" % ( - click.style("star", fg="cyan"), - click.style("https://github.com/platformio/platformio", fg="cyan") - )) - if not getenv("PLATFORMIO_IDE"): - click.echo("- %s PlatformIO IDE for IoT development > %s" % ( - click.style("try", fg="cyan"), - click.style("http://platformio.org/platformio-ide", fg="cyan") - )) - if not util.is_ci(): - click.echo("- %s to keep PlatformIO alive! > %s" % ( - click.style("donate", fg="cyan"), - click.style("http://platformio.org/donate", fg="cyan") - )) - - click.echo("*" * terminal_width) - click.echo("") - if last_version == "0.0.0": app.set_state_item("last_version", __version__) - return - - click.secho("Please wait while upgrading PlatformIO ...", - fg="yellow") - - u = Upgrader(last_version, __version__) - if u.run(ctx): - app.set_state_item("last_version", __version__) - ctx.invoke(cmd_platforms_update) - - click.secho("PlatformIO has been successfully upgraded to %s!\n" % - __version__, fg="green") - - telemetry.on_event(category="Auto", action="Upgrade", - label="%s > %s" % (last_version, __version__)) else: - raise exception.UpgradeError("Auto upgrading...") + click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") + + u = Upgrader(last_version, __version__) + if u.run(ctx): + app.set_state_item("last_version", __version__) + + # update development platforms + pm = PlatformManager() + for manifest in pm.get_installed(): + # @TODO Uncomment line below after first PIO3 release + # pm.update(manifest['name'], "^" + manifest['version']) + pm.update(manifest['name']) + + # update PlatformIO Plus tool if installed + pioplus_update() + + click.secho( + "PlatformIO has been successfully upgraded to %s!\n" % + __version__, + fg="green") + + telemetry.on_event( + category="Auto", + action="Upgrade", + label="%s > %s" % (last_version, __version__)) + else: + raise exception.UpgradeError("Auto upgrading...") + click.echo("") + + # PlatformIO banner + terminal_width, _ = click.get_terminal_size() + click.echo("*" * terminal_width) + click.echo("If you like %s, please:" % (click.style( + "PlatformIO", fg="cyan"))) + click.echo("- %s us on Twitter to stay up-to-date " + "on the latest project news > %s" % (click.style( + "follow", fg="cyan"), click.style( + "https://twitter.com/PlatformIO_Org", fg="cyan"))) + click.echo("- %s it on GitHub > %s" % (click.style( + "star", fg="cyan"), click.style( + "https://github.com/platformio/platformio", fg="cyan"))) + if not getenv("PLATFORMIO_IDE"): + click.echo("- %s PlatformIO IDE for IoT development > %s" % + (click.style( + "try", fg="cyan"), click.style( + "http://platformio.org/platformio-ide", fg="cyan"))) + if not util.is_ci(): + click.echo("- %s to keep PlatformIO alive! > %s" % (click.style( + "donate", fg="cyan"), click.style( + "http://platformio.org/donate", fg="cyan"))) + + click.echo("*" * terminal_width) click.echo("") @@ -195,30 +209,34 @@ def check_platformio_upgrade(): app.set_state_item("last_check", last_check) latest_version = get_latest_version() - if (latest_version == __version__ or - Upgrader.version_to_int(latest_version) < - Upgrader.version_to_int(__version__)): + if semantic_version.Version.coerce(util.pepver_to_semver( + latest_version)) <= semantic_version.Version.coerce( + util.pepver_to_semver(__version__)): return terminal_width, _ = click.get_terminal_size() click.echo("") click.echo("*" * terminal_width) - click.secho("There is a new version %s of PlatformIO available.\n" - "Please upgrade it via `" % latest_version, - fg="yellow", nl=False) + click.secho( + "There is a new version %s of PlatformIO available.\n" + "Please upgrade it via `" % latest_version, + fg="yellow", + nl=False) if getenv("PLATFORMIO_IDE"): - click.secho("PlatformIO IDE Menu: Upgrade PlatformIO", - fg="cyan", nl=False) + click.secho( + "PlatformIO IDE Menu: Upgrade PlatformIO", fg="cyan", nl=False) click.secho("`.", fg="yellow") + elif join("Cellar", "platformio") in util.get_source_dir(): + click.secho("brew update && brew upgrade", fg="cyan", nl=False) + click.secho("` command.", fg="yellow") else: click.secho("platformio upgrade", fg="cyan", nl=False) click.secho("` or `", fg="yellow", nl=False) click.secho("pip install -U platformio", fg="cyan", nl=False) click.secho("` command.", fg="yellow") click.secho("Changes: ", fg="yellow", nl=False) - click.secho("http://docs.platformio.org/en/stable/history.html", - fg="cyan") + click.secho("http://docs.platformio.org/en/stable/history.html", fg="cyan") click.echo("*" * terminal_width) click.echo("") @@ -232,15 +250,12 @@ def check_internal_updates(ctx, what): last_check[what + '_update'] = int(time()) app.set_state_item("last_check", last_check) + pm = PlatformManager() if what == "platforms" else LibraryManager() outdated_items = [] - if what == "platforms": - for platform in PlatformFactory.get_platforms(installed=True): - p = PlatformFactory.newPlatform(platform) - if p.is_outdated(): - outdated_items.append(platform) - elif what == "libraries": - lm = LibraryManager() - outdated_items = lm.get_outdated() + for manifest in pm.get_installed(): + if manifest['name'] not in outdated_items and \ + pm.is_outdated(manifest['name']): + outdated_items.append(manifest['name']) if not outdated_items: return @@ -249,25 +264,41 @@ def check_internal_updates(ctx, what): click.echo("") click.echo("*" * terminal_width) - click.secho("There are the new updates for %s (%s)" % - (what, ", ".join(outdated_items)), fg="yellow") + click.secho( + "There are the new updates for %s (%s)" % + (what, ", ".join(outdated_items)), + fg="yellow") if not app.get_setting("auto_update_" + what): click.secho("Please update them via ", fg="yellow", nl=False) - click.secho("`platformio %s update`" % - ("lib" if what == "libraries" else "platforms"), - fg="cyan", nl=False) + click.secho( + "`platformio %s update`" % + ("lib --global" if what == "libraries" else "platform"), + fg="cyan", + nl=False) + click.secho(" command.\n", fg="yellow") + click.secho( + "If you want to manually check for the new versions " + "without updating, please use ", + fg="yellow", + nl=False) + click.secho( + "`platformio %s update --only-check`" % + ("lib --global" if what == "libraries" else "platform"), + fg="cyan", + nl=False) click.secho(" command.", fg="yellow") else: click.secho("Please wait while updating %s ..." % what, fg="yellow") if what == "platforms": - ctx.invoke(cmd_platforms_update) + ctx.invoke(cmd_platform_update, platforms=outdated_items) elif what == "libraries": - ctx.invoke(cmd_libraries_update) + ctx.obj = pm + ctx.invoke(cmd_lib_update, libraries=outdated_items) click.echo() - telemetry.on_event(category="Auto", action="Update", - label=what.title()) + telemetry.on_event( + category="Auto", action="Update", label=what.title()) click.echo("*" * terminal_width) click.echo("") diff --git a/platformio/builder/scripts/__init__.py b/platformio/managers/__init__.py similarity index 89% rename from platformio/builder/scripts/__init__.py rename to platformio/managers/__init__.py index 0c05c3b0..95899c71 100644 --- a/platformio/builder/scripts/__init__.py +++ b/platformio/managers/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py new file mode 100644 index 00000000..2f8e6ad3 --- /dev/null +++ b/platformio/managers/lib.py @@ -0,0 +1,315 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import os +from hashlib import md5 +from os.path import dirname, join + +import click +import semantic_version + +from platformio import commands, exception, util +from platformio.managers.package import BasePkgManager + + +class LibraryManager(BasePkgManager): + + def __init__(self, package_dir=None): + if not package_dir: + package_dir = join(util.get_home_dir(), "lib") + BasePkgManager.__init__(self, package_dir) + + @property + def manifest_name(self): + return ".library.json" + + def check_pkg_structure(self, pkg_dir): + try: + return BasePkgManager.check_pkg_structure(self, pkg_dir) + except exception.MissingPackageManifest: + # we will generate manifest automatically + pass + + manifest = { + "name": "Library_" + md5(pkg_dir).hexdigest()[:5], + "version": "0.0.0" + } + manifest_path = self._find_any_manifest(pkg_dir) + if manifest_path: + _manifest = self._parse_manifest(manifest_path) + pkg_dir = dirname(manifest_path) + for key in ("name", "version"): + if key not in _manifest: + _manifest[key] = manifest[key] + manifest = _manifest + else: + for root, dirs, files in os.walk(pkg_dir): + if len(dirs) == 1 and not files: + manifest['name'] = dirs[0] + continue + if dirs or files: + pkg_dir = root + break + + with open(join(pkg_dir, self.manifest_name), "w") as fp: + json.dump(manifest, fp) + + return pkg_dir + + @staticmethod + def _find_any_manifest(pkg_dir): + manifests = ("library.json", "library.properties", "module.json") + for root, _, files in os.walk(pkg_dir): + for manifest in manifests: + if manifest in files: + return join(root, manifest) + return None + + @staticmethod + def _parse_manifest(path): + manifest = {} + if path.endswith(".json"): + return util.load_json(path) + elif path.endswith("library.properties"): + with open(path) as fp: + for line in fp.readlines(): + if "=" not in line: + continue + key, value = line.split("=", 1) + manifest[key.strip()] = value.strip() + manifest['frameworks'] = ["arduino"] + if "author" in manifest: + manifest['authors'] = [{"name": manifest['author']}] + del manifest['author'] + if "sentence" in manifest: + manifest['description'] = manifest['sentence'] + del manifest['sentence'] + return manifest + + @staticmethod + def normalize_dependencies(dependencies): + if not dependencies: + return [] + items = [] + if isinstance(dependencies, dict): + if "name" in dependencies: + items.append(dependencies) + else: + for name, version in dependencies.items(): + items.append({"name": name, "version": version}) + elif isinstance(dependencies, list): + items = [d for d in dependencies if "name" in d] + for item in items: + for k in ("frameworks", "platforms"): + if k not in item or isinstance(k, list): + continue + if item[k] == "*": + del item[k] + elif isinstance(item[k], basestring): + item[k] = [i.strip() for i in item[k].split(",") + if i.strip()] + return items + + @staticmethod + def max_satisfying_repo_version(versions, requirements=None): + + def _cmp_dates(datestr1, datestr2): + from datetime import datetime + assert "T" in datestr1 and "T" in datestr2 + dateformat = "%Y-%m-%d %H:%M:%S" + date1 = datetime.strptime(datestr1[:-1].replace("T", " "), + dateformat) + date2 = datetime.strptime(datestr2[:-1].replace("T", " "), + dateformat) + if date1 == date2: + return 0 + return -1 if date1 < date2 else 1 + + item = None + reqspec = None + if requirements: + try: + reqspec = semantic_version.Spec(requirements) + except ValueError: + pass + for v in versions: + specver = None + try: + specver = semantic_version.Version(v['version'], partial=True) + except ValueError: + pass + + if reqspec: + if not specver or specver not in reqspec: + continue + if not item or semantic_version.Version( + item['version'], partial=True) < specver: + item = v + elif requirements: + if requirements == v['version']: + return v + else: + if not item or _cmp_dates(item['date'], v['date']) == -1: + item = v + return item + + def get_latest_repo_version(self, name, requirements): + item = self.max_satisfying_repo_version( + util.get_api_result("/lib/versions/%d" % self._get_pkg_id_by_name( + name, requirements)), requirements) + return item['version'] if item else None + + def _get_pkg_id_by_name(self, + name, + requirements, + silent=False, + interactive=False): + if name.startswith("id="): + return int(name[3:]) + # try to find ID from installed packages + package_dir = self.get_package_dir(name, requirements) + if package_dir: + manifest = self.load_manifest(package_dir) + if "id" in manifest: + return int(manifest['id']) + return int( + self.search_for_library({"name": name}, silent, interactive)['id']) + + def _install_from_piorepo(self, name, requirements): + assert name.startswith("id=") + version = self.get_latest_repo_version(name, requirements) + if not version: + raise exception.UndefinedPackageVersion(requirements or "latest", + util.get_systype()) + dl_data = util.get_api_result( + "/lib/download/" + str(name[3:]), dict(version=version)) + assert dl_data + pkg_dir = None + try: + pkg_dir = self._install_from_url( + name, dl_data['url'].replace("http://", "https://"), + requirements) + except exception.APIRequestError: + pkg_dir = self._install_from_url(name, dl_data['url'], + requirements) + return pkg_dir + + def install(self, # pylint: disable=too-many-arguments + name, + requirements=None, + silent=False, + trigger_event=True, + interactive=False): + _name, _requirements, _url = self.parse_pkg_name(name, requirements) + if not _url: + _name = "id=%d" % self._get_pkg_id_by_name( + _name, _requirements, silent=silent, interactive=interactive) + already_installed = self.get_package(_name, _requirements, _url) + pkg_dir = BasePkgManager.install(self, _name if not _url else name, + _requirements, silent, trigger_event) + + if already_installed: + return + + manifest = self.load_manifest(pkg_dir) + if "dependencies" not in manifest: + return pkg_dir + + if not silent: + click.secho("Installing dependencies", fg="yellow") + + for filters in self.normalize_dependencies(manifest['dependencies']): + assert "name" in filters + if any([s in filters.get("version", "") for s in ("\\", "/")]): + self.install("{name}={version}".format(**filters)) + else: + lib_info = self.search_for_library(filters, silent, + interactive) + if filters.get("version"): + self.install( + lib_info['id'], + requirements=filters.get("version"), + silent=silent, + trigger_event=trigger_event) + else: + self.install( + lib_info['id'], + silent=silent, + trigger_event=trigger_event) + return pkg_dir + + @staticmethod + def search_for_library( # pylint: disable=too-many-branches + filters, + silent=False, + interactive=False): + assert isinstance(filters, dict) + assert "name" in filters + if not silent: + click.echo("Looking for %s library in registry" % click.style( + filters['name'], fg="cyan")) + query = [] + for key in filters: + if key not in ("name", "authors", "frameworks", "platforms"): + continue + values = filters[key] + if not isinstance(values, list): + values = [v.strip() for v in values.split(",") if v] + for value in values: + query.append('%s:"%s"' % (key[:-1] if key.endswith("s") else + key, value)) + + lib_info = None + result = util.get_api_result( + "/lib/search", dict(query=" ".join(query))) + if result['total'] == 1: + lib_info = result['items'][0] + elif result['total'] > 1: + click.secho( + "Conflict: More than one library has been found " + "by request %s:" % json.dumps(filters), + fg="red", + err=True) + commands.lib.echo_liblist_header() + for item in result['items']: + commands.lib.echo_liblist_item(item) + + if not interactive: + click.secho( + "Automatically chose the first available library " + "(use `--interactive` option to make a choice)", + fg="yellow", + err=True) + lib_info = result['items'][0] + else: + deplib_id = click.prompt( + "Please choose library ID", + type=click.Choice([str(i['id']) for i in result['items']])) + for item in result['items']: + if item['id'] == int(deplib_id): + lib_info = item + break + + if not lib_info: + if filters.keys() == ["name"]: + raise exception.LibNotFound(filters['name']) + else: + raise exception.LibNotFound(str(filters)) + if not silent: + click.echo("Found: %s" % click.style( + "http://platformio.org/lib/show/{id}/{name}".format( + **lib_info), + fg="blue")) + return lib_info diff --git a/platformio/managers/package.py b/platformio/managers/package.py new file mode 100644 index 00000000..c536a9e6 --- /dev/null +++ b/platformio/managers/package.py @@ -0,0 +1,567 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import os +from os.path import basename, dirname, isdir, isfile, islink, join +from shutil import copytree +from tempfile import mkdtemp + +import click +import requests +import semantic_version + +from platformio import exception, telemetry, util +from platformio.downloader import FileDownloader +from platformio.unpacker import FileUnpacker +from platformio.vcsclient import VCSClientFactory + +# pylint: disable=too-many-arguments + + +class PackageRepoIterator(object): + + _MANIFEST_CACHE = {} + + def __init__(self, package, repositories): + assert isinstance(repositories, list) + self.package = package + self.repositories = iter(repositories) + + def __iter__(self): + return self + + def __next__(self): + return self.next() + + def next(self): + manifest = {} + repo = next(self.repositories) + if isinstance(repo, dict): + manifest = repo + elif repo in PackageRepoIterator._MANIFEST_CACHE: + manifest = PackageRepoIterator._MANIFEST_CACHE[repo] + else: + r = None + try: + r = requests.get(repo, headers=util.get_request_defheaders()) + r.raise_for_status() + manifest = r.json() + except: # pylint: disable=bare-except + pass + finally: + if r: + r.close() + PackageRepoIterator._MANIFEST_CACHE[repo] = manifest + + if self.package in manifest: + return manifest[self.package] + else: + return self.next() + + +class PkgRepoMixin(object): + + @staticmethod + def max_satisfying_repo_version(versions, requirements=None): + item = None + systype = util.get_systype() + reqspec = None + if requirements: + try: + reqspec = semantic_version.Spec(requirements) + except ValueError: + pass + + for v in versions: + if ("system" in v and v['system'] not in ("all", "*") and + systype not in v['system']): + continue + specver = semantic_version.Version(v['version']) + if reqspec and specver not in reqspec: + continue + if not item or semantic_version.Version(item['version']) < specver: + item = v + return item + + def get_latest_repo_version(self, name, requirements): + version = None + for versions in PackageRepoIterator(name, self.repositories): + pkgdata = self.max_satisfying_repo_version(versions, requirements) + if not pkgdata: + continue + if not version or semantic_version.compare(pkgdata['version'], + version) == 1: + version = pkgdata['version'] + return version + + +class PkgInstallerMixin(object): + + VCS_MANIFEST_NAME = ".piopkgmanager.json" + + def get_vcs_manifest_path(self, pkg_dir): + for item in os.listdir(pkg_dir): + if not isdir(join(pkg_dir, item)): + continue + if isfile(join(pkg_dir, item, self.VCS_MANIFEST_NAME)): + return join(pkg_dir, item, self.VCS_MANIFEST_NAME) + return None + + def get_manifest_path(self, pkg_dir): + if not isdir(pkg_dir): + return None + manifest_path = join(pkg_dir, self.manifest_name) + if isfile(manifest_path): + return manifest_path + return self.get_vcs_manifest_path(pkg_dir) + + def manifest_exists(self, pkg_dir): + return self.get_manifest_path(pkg_dir) is not None + + def load_manifest(self, path): + assert path + pkg_dir = path + if isdir(path): + path = self.get_manifest_path(path) + else: + pkg_dir = dirname(pkg_dir) + if path: + if isfile(path) and path.endswith(self.VCS_MANIFEST_NAME): + pkg_dir = dirname(dirname(path)) + manifest = util.load_json(path) + manifest['__pkg_dir'] = pkg_dir + return manifest + return None + + def check_pkg_structure(self, pkg_dir): + if self.manifest_exists(pkg_dir): + return pkg_dir + + for root, _, _ in os.walk(pkg_dir): + if self.manifest_exists(root): + return root + + raise exception.MissingPackageManifest(self.manifest_name) + + def _install_from_piorepo(self, name, requirements): + pkg_dir = None + pkgdata = None + versions = None + for versions in PackageRepoIterator(name, self.repositories): + pkgdata = self.max_satisfying_repo_version(versions, requirements) + if not pkgdata: + continue + try: + pkg_dir = self._install_from_url( + name, pkgdata['url'], requirements, pkgdata.get("sha1")) + break + except Exception as e: # pylint: disable=broad-except + click.secho("Warning! Package Mirror: %s" % e, fg="yellow") + click.secho("Looking for the another mirror...", fg="yellow") + + if versions is None: + raise exception.UnknownPackage(name) + elif not pkgdata: + raise exception.UndefinedPackageVersion(requirements or "latest", + util.get_systype()) + return pkg_dir + + def _install_from_url(self, name, url, requirements=None, sha1=None): + pkg_dir = None + tmp_dir = mkdtemp("-package", "installing-", self.package_dir) + + try: + if url.startswith("file://"): + url = url[7:] + if isfile(url): + self.unpack(url, tmp_dir) + else: + util.rmtree_(tmp_dir) + copytree(url, tmp_dir) + elif url.startswith(("http://", "https://")): + dlpath = self.download(url, tmp_dir, sha1) + assert isfile(dlpath) + self.unpack(dlpath, tmp_dir) + os.remove(dlpath) + else: + vcs = VCSClientFactory.newClient(tmp_dir, url) + assert vcs.export() + with open(join(vcs.storage_dir, self.VCS_MANIFEST_NAME), + "w") as fp: + json.dump({ + "name": name, + "version": vcs.get_current_revision(), + "url": url, + "requirements": requirements + }, fp) + + pkg_dir = self.check_pkg_structure(tmp_dir) + pkg_dir = self._install_from_tmp_dir(pkg_dir, requirements) + finally: + if isdir(tmp_dir): + util.rmtree_(tmp_dir) + return pkg_dir + + def _install_from_tmp_dir(self, tmp_dir, requirements=None): + tmpmanifest = self.load_manifest(tmp_dir) + assert set(["name", "version"]) <= set(tmpmanifest.keys()) + name = tmpmanifest['name'] + pkg_dir = join(self.package_dir, name) + if "id" in tmpmanifest: + name += "_ID%d" % tmpmanifest['id'] + pkg_dir = join(self.package_dir, name) + + # package should satisfy requirements + if requirements: + mismatch_error = ( + "Package version %s doesn't satisfy requirements %s" % ( + tmpmanifest['version'], requirements)) + try: + reqspec = semantic_version.Spec(requirements) + tmpmanver = semantic_version.Version( + tmpmanifest['version'], partial=True) + assert tmpmanver in reqspec, mismatch_error + + if self.manifest_exists(pkg_dir): + curmanifest = self.load_manifest(pkg_dir) + curmanver = semantic_version.Version( + curmanifest['version'], partial=True) + # if current package version < new package, backup it + if tmpmanver > curmanver: + os.rename(pkg_dir, join(self.package_dir, "%s@%s" % ( + name, curmanifest['version']))) + elif tmpmanver < curmanver: + pkg_dir = join(self.package_dir, "%s@%s" % + (name, tmpmanifest['version'])) + except ValueError: + assert tmpmanifest['version'] == requirements, mismatch_error + + # remove previous/not-satisfied package + if isdir(pkg_dir): + util.rmtree_(pkg_dir) + os.rename(tmp_dir, pkg_dir) + assert isdir(pkg_dir) + return pkg_dir + + +class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): + + _INSTALLED_CACHE = {} + + def __init__(self, package_dir, repositories=None): + self.repositories = repositories + self.package_dir = package_dir + if not isdir(self.package_dir): + os.makedirs(self.package_dir) + assert isdir(self.package_dir) + + @property + def manifest_name(self): + raise NotImplementedError() + + @staticmethod + def download(url, dest_dir, sha1=None): + fd = FileDownloader(url, dest_dir) + fd.start() + if sha1: + fd.verify(sha1) + return fd.get_filepath() + + @staticmethod + def unpack(source_path, dest_dir): + fu = FileUnpacker(source_path, dest_dir) + return fu.start() + + def reset_cache(self): + if self.package_dir in BasePkgManager._INSTALLED_CACHE: + del BasePkgManager._INSTALLED_CACHE[self.package_dir] + + def print_message(self, message, nl=True): + click.echo("%s: %s" % (self.__class__.__name__, message), nl=nl) + + @staticmethod + def parse_pkg_name( # pylint: disable=too-many-branches + text, requirements=None): + text = str(text) + if not requirements and "@" in text and not text.startswith("git@"): + text, requirements = text.rsplit("@", 1) + if text.isdigit(): + text = "id=" + text + + url_marker = "://" + name, url = (None, text) + if "=" in text and not text.startswith("id="): + name, url = text.split("=", 1) + + git_conditions = [ + # Handle GitHub URL (https://github.com/user/package) + url.startswith("https://github.com/") and not url.endswith( + (".zip", ".tar.gz")), + url.startswith("http") and + (url.split("#", 1)[0] if "#" in url else url).endswith(".git") + ] + + if any(git_conditions): + url = "git+" + url + # Handle Developer Mbed URL + # (https://developer.mbed.org/users/user/code/package/) + elif url.startswith("https://developer.mbed.org"): + url = "hg+" + url + + # git@github.com:user/package.git + if url.startswith("git@"): + url_marker = "git@" + + if any([s in url for s in ("\\", "/")]) and url_marker not in url: + if isfile(url) or isdir(url): + url = "file://" + url + elif url.count("/") == 1 and not url.startswith("git@"): + url = "git+https://github.com/" + url + + # determine name + if url_marker in url and not name: + _url = url.split("#", 1)[0] if "#" in url else url + if _url.endswith(("\\", "/")): + _url = _url[:-1] + name = basename(_url) + if "." in name and not name.startswith("."): + name = name.split(".", 1)[0] + + if url_marker not in url: + url = None + return (name or text, requirements, url) + + def get_installed(self): + if self.package_dir in BasePkgManager._INSTALLED_CACHE: + return BasePkgManager._INSTALLED_CACHE[self.package_dir] + items = [] + for p in sorted(os.listdir(self.package_dir)): + pkg_dir = join(self.package_dir, p) + if not isdir(pkg_dir): + continue + manifest = self.load_manifest(pkg_dir) + if not manifest: + continue + assert set(["name", "version"]) <= set(manifest.keys()) + items.append(manifest) + BasePkgManager._INSTALLED_CACHE[self.package_dir] = items + return items + + def get_package(self, name, requirements=None, url=None): + pkg_id = int(name[3:]) if name.startswith("id=") else 0 + best = None + reqspec = None + if requirements: + try: + reqspec = semantic_version.Spec(requirements) + except ValueError: + pass + + for manifest in self.get_installed(): + if pkg_id and manifest.get("id") != pkg_id: + continue + elif not pkg_id and manifest['name'] != name: + continue + elif not reqspec and requirements: + if requirements == manifest['version']: + best = manifest + break + continue + try: + if reqspec and not reqspec.match( + semantic_version.Version( + manifest['version'], partial=True)): + continue + elif not best or (semantic_version.Version( + manifest['version'], partial=True) > + semantic_version.Version( + best['version'], partial=True)): + best = manifest + except ValueError: + pass + if best: + # check that URL is the same in installed package (VCS) + if url and best.get("url") != url: + return None + return best + return None + + def get_package_dir(self, name, requirements=None, url=None): + package = self.get_package(name, requirements, url) + return package.get("__pkg_dir") if package else None + + def is_outdated(self, name, requirements=None): + package_dir = self.get_package_dir(name, requirements) + if not package_dir: + click.secho( + "%s @ %s is not installed" % (name, requirements or "*"), + fg="yellow") + return + if self.get_vcs_manifest_path(package_dir): + return False + manifest = self.load_manifest(package_dir) + return manifest['version'] != self.get_latest_repo_version( + name, requirements) + + def install(self, + name, + requirements=None, + silent=False, + trigger_event=True, + interactive=False): # pylint: disable=unused-argument + name, requirements, url = self.parse_pkg_name(name, requirements) + package_dir = self.get_package_dir(name, requirements, url) + + if not package_dir or not silent: + msg = "Installing " + click.style(name, fg="cyan") + if requirements: + msg += " @ " + requirements + self.print_message(msg) + if package_dir: + if not silent: + click.secho( + "{name} @ {version} is already installed".format( + **self.load_manifest(package_dir)), + fg="yellow") + return package_dir + + if url: + pkg_dir = self._install_from_url(name, url, requirements) + else: + pkg_dir = self._install_from_piorepo(name, requirements) + if not pkg_dir or not self.manifest_exists(pkg_dir): + raise exception.PackageInstallError(name, requirements or "*", + util.get_systype()) + + self.reset_cache() + manifest = self.load_manifest(pkg_dir) + + if trigger_event: + telemetry.on_event( + category=self.__class__.__name__, + action="Install", + label=manifest['name']) + + click.secho( + "{name} @ {version} has been successfully installed!".format( + **manifest), + fg="green") + + return pkg_dir + + def uninstall(self, name, requirements=None, trigger_event=True): + name, requirements, url = self.parse_pkg_name(name, requirements) + package_dir = self.get_package_dir(name, requirements, url) + if not package_dir: + click.secho( + "%s @ %s is not installed" % (name, requirements or "*"), + fg="yellow") + return + + manifest = self.load_manifest(package_dir) + click.echo( + "Uninstalling %s @ %s: \t" % (click.style( + manifest['name'], fg="cyan"), manifest['version']), + nl=False) + + if isdir(package_dir): + if islink(package_dir): + os.unlink(package_dir) + else: + util.rmtree_(package_dir) + + click.echo("[%s]" % click.style("OK", fg="green")) + + self.reset_cache() + if trigger_event: + telemetry.on_event( + category=self.__class__.__name__, + action="Uninstall", + label=manifest['name']) + return True + + def update(self, # pylint: disable=too-many-return-statements + name, + requirements=None, + only_check=False): + name, requirements, url = self.parse_pkg_name(name, requirements) + package_dir = self.get_package_dir(name, requirements, url) + if not package_dir: + click.secho( + "%s @ %s is not installed" % (name, requirements or "*"), + fg="yellow") + return + + is_vcs_pkg = False + if self.get_vcs_manifest_path(package_dir): + is_vcs_pkg = True + manifest_path = self.get_vcs_manifest_path(package_dir) + else: + manifest_path = self.get_manifest_path(package_dir) + + manifest = self.load_manifest(manifest_path) + click.echo( + "%s %s @ %s: \t" % ("Checking" + if only_check else "Updating", click.style( + manifest['name'], fg="cyan"), + manifest['version']), + nl=False) + if is_vcs_pkg: + if only_check: + click.echo("[%s]" % (click.style("Skip", fg="yellow"))) + return + click.echo("[%s]" % (click.style("VCS", fg="yellow"))) + vcs = VCSClientFactory.newClient(package_dir, manifest['url']) + if not vcs.can_be_updated: + click.secho( + "Skip update because repository is fixed " + "to %s revision" % manifest['version'], + fg="yellow") + return + assert vcs.update() + with open(manifest_path, "w") as fp: + manifest['version'] = vcs.get_current_revision() + json.dump(manifest, fp) + else: + latest_version = None + try: + latest_version = self.get_latest_repo_version(name, + requirements) + except exception.PlatformioException: + pass + if not latest_version: + click.echo("[%s]" % (click.style("Unknown", fg="yellow"))) + return + if manifest['version'] == latest_version: + click.echo("[%s]" % (click.style("Up-to-date", fg="green"))) + return + click.echo("[%s]" % (click.style("Out-of-date", fg="red"))) + if only_check: + return + self.uninstall(name, manifest['version'], trigger_event=False) + self.install(name, latest_version, trigger_event=False) + + telemetry.on_event( + category=self.__class__.__name__, + action="Update", + label=manifest['name']) + return True + + +class PackageManager(BasePkgManager): + + @property + def manifest_name(self): + return "package.json" diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py new file mode 100644 index 00000000..82e41b08 --- /dev/null +++ b/platformio/managers/platform.py @@ -0,0 +1,517 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import base64 +import os +import re +from imp import load_source +from multiprocessing import cpu_count +from os.path import basename, dirname, isdir, isfile, join + +import click + +from platformio import app, exception, util +from platformio.managers.package import BasePkgManager, PackageManager + + +class PlatformManager(BasePkgManager): + + def __init__(self, package_dir=None, repositories=None): + if not repositories: + repositories = [ + "{0}://dl.platformio.org/platforms/manifest.json".format( + "http" if app.get_setting("disable_ssl") else "https") + ] + BasePkgManager.__init__(self, package_dir or + join(util.get_home_dir(), "platforms"), + repositories) + + @property + def manifest_name(self): + return "platform.json" + + def install(self, # pylint: disable=too-many-arguments + name, + requirements=None, + with_packages=None, + without_packages=None, + skip_default_package=False, + **_): + platform_dir = BasePkgManager.install(self, name, requirements) + p = PlatformFactory.newPlatform(self.get_manifest_path(platform_dir)) + p.install_packages(with_packages, without_packages, + skip_default_package) + self.cleanup_packages(p.packages.keys()) + return True + + def uninstall(self, name, requirements=None, trigger_event=True): + name, requirements, _ = self.parse_pkg_name(name, requirements) + p = PlatformFactory.newPlatform(name, requirements) + BasePkgManager.uninstall(self, name, requirements) + # trigger event is disabled when upgrading operation + # don't cleanup packages, "install" will do that + if trigger_event: + self.cleanup_packages(p.packages.keys()) + return True + + def update(self, # pylint: disable=arguments-differ + name, requirements=None, only_packages=False, only_check=False): + name, requirements, _ = self.parse_pkg_name(name, requirements) + if not only_packages: + BasePkgManager.update(self, name, requirements, only_check) + p = PlatformFactory.newPlatform(name, requirements) + p.update_packages(only_check) + self.cleanup_packages(p.packages.keys()) + return True + + def is_outdated(self, name, requirements=None): + if BasePkgManager.is_outdated(self, name, requirements): + return True + p = PlatformFactory.newPlatform(name, requirements) + return p.are_outdated_packages() + + def cleanup_packages(self, names): + self.reset_cache() + deppkgs = {} + for manifest in PlatformManager().get_installed(): + p = PlatformFactory.newPlatform(manifest['name'], + manifest['version']) + for pkgname, pkgmanifest in p.get_installed_packages().items(): + if pkgname not in deppkgs: + deppkgs[pkgname] = set() + deppkgs[pkgname].add(pkgmanifest['version']) + + pm = PackageManager(join(util.get_home_dir(), "packages")) + for manifest in pm.get_installed(): + if manifest['name'] not in names: + continue + if (manifest['name'] not in deppkgs or + manifest['version'] not in deppkgs[manifest['name']]): + pm.uninstall( + manifest['name'], manifest['version'], trigger_event=False) + + self.reset_cache() + return True + + def get_installed_boards(self): + boards = [] + for manifest in self.get_installed(): + p = PlatformFactory.newPlatform( + self.get_manifest_path(manifest['__pkg_dir'])) + for config in p.get_boards().values(): + boards.append(config.get_brief_data()) + return boards + + @staticmethod + @util.memoized + def get_registered_boards(): + return util.get_api_result("/boards") + + +class PlatformFactory(object): + + @staticmethod + def get_clsname(name): + return "%s%sPlatform" % (name.upper()[0], name.lower()[1:]) + + @staticmethod + def load_module(name, path): + module = None + try: + module = load_source("platformio.managers.platform.%s" % name, + path) + except ImportError: + raise exception.UnknownPlatform(name) + return module + + @classmethod + def newPlatform(cls, name, requirements=None): + platform_dir = None + if name.endswith("platform.json") and isfile(name): + platform_dir = dirname(name) + name = util.load_json(name)['name'] + else: + if not requirements and "@" in name: + name, requirements = name.rsplit("@", 1) + platform_dir = PlatformManager().get_package_dir(name, + requirements) + + if not platform_dir: + raise exception.UnknownPlatform(name if not requirements else + "%s@%s" % (name, requirements)) + + platform_cls = None + if isfile(join(platform_dir, "platform.py")): + platform_cls = getattr( + cls.load_module(name, join(platform_dir, "platform.py")), + cls.get_clsname(name)) + else: + platform_cls = type( + str(cls.get_clsname(name)), (PlatformBase, ), {}) + + _instance = platform_cls(join(platform_dir, "platform.json")) + assert isinstance(_instance, PlatformBase) + return _instance + + +class PlatformPackagesMixin(object): + + def install_packages(self, + with_packages=None, + without_packages=None, + skip_default_package=False, + silent=False): + with_packages = set(self.pkg_types_to_names(with_packages or [])) + without_packages = set(self.pkg_types_to_names(without_packages or [])) + + upkgs = with_packages | without_packages + ppkgs = set(self.packages.keys()) + if not upkgs.issubset(ppkgs): + raise exception.UnknownPackage(", ".join(upkgs - ppkgs)) + + for name, opts in self.packages.items(): + if name in without_packages: + continue + elif (name in with_packages or + not (skip_default_package or opts.get("optional", False))): + if any([s in opts.get("version", "") for s in ("\\", "/")]): + self.pm.install( + "%s=%s" % (name, opts['version']), silent=silent) + else: + self.pm.install(name, opts.get("version"), silent=silent) + + return True + + def get_installed_packages(self): + items = {} + for name, opts in self.packages.items(): + package = self.pm.get_package(name, opts['version']) + if package: + items[name] = package + return items + + def update_packages(self, only_check=False): + for name in self.get_installed_packages(): + self.pm.update(name, self.packages[name]['version'], only_check) + + def are_outdated_packages(self): + for name, opts in self.get_installed_packages().items(): + if (opts['version'] != self.pm.get_latest_repo_version( + name, self.packages[name].get("version"))): + return True + return False + + def get_package_dir(self, name): + return self.pm.get_package_dir(name, + self.packages[name].get("version")) + + def get_package_version(self, name): + package = self.pm.get_package(name, self.packages[name].get("version")) + return package['version'] if package else None + + +class PlatformRunMixin(object): + + LINE_ERROR_RE = re.compile(r"(\s+error|error[:\s]+)", re.I) + + def run(self, variables, targets, silent, verbose): + assert isinstance(variables, dict) + assert isinstance(targets, list) + + self.configure_default_packages(variables, targets) + self.install_packages(silent=True) + + self.silent = silent + self.verbose = verbose or app.get_setting("force_verbose") + + if "clean" in targets: + targets = ["-c", "."] + + variables['platform_manifest'] = self.manifest_path + + if "build_script" not in variables: + variables['build_script'] = self.get_build_script() + if not isfile(variables['build_script']): + raise exception.BuildScriptNotFound(variables['build_script']) + + result = self._run_scons(variables, targets) + assert "returncode" in result + + return result + + def _run_scons(self, variables, targets): + cmd = [ + util.get_pythonexe_path(), + join(self.get_package_dir("tool-scons"), "script", "scons"), "-Q", + "-j %d" % self.get_job_nums(), "--warn=no-no-parallel-support", + "-f", join(util.get_source_dir(), "builder", "main.py") + ] + cmd.append("PIOVERBOSE=%d" % (1 if self.verbose else 0)) + cmd += targets + + # encode and append variables + for key, value in variables.items(): + cmd.append("%s=%s" % (key.upper(), base64.b64encode(value))) + + util.copy_pythonpath_to_osenv() + result = util.exec_command( + cmd, + stdout=util.AsyncPipe(self.on_run_out), + stderr=util.AsyncPipe(self.on_run_err)) + return result + + def on_run_out(self, line): + self._echo_line(line, level=1) + + def on_run_err(self, line): + is_error = self.LINE_ERROR_RE.search(line) is not None + self._echo_line(line, level=3 if is_error else 2) + + def _echo_line(self, line, level): + if line.startswith("scons: "): + line = line[7:] + assert 1 <= level <= 3 + if self.silent and (level < 2 or not line): + return + fg = (None, "yellow", "red")[level - 1] + if level == 1 and "is up to date" in line: + fg = "green" + click.secho(line, fg=fg, err=level > 1) + + @staticmethod + def get_job_nums(): + try: + return cpu_count() + except NotImplementedError: + return 1 + + +class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): + + _BOARDS_CACHE = {} + + def __init__(self, manifest_path): + self._BOARDS_CACHE = {} + self.manifest_path = manifest_path + self._manifest = util.load_json(manifest_path) + + self.pm = PackageManager( + join(util.get_home_dir(), "packages"), + self._manifest.get("packageRepositories")) + + self.silent = False + self.verbose = False + + @property + def name(self): + return self._manifest['name'] + + @property + def title(self): + return self._manifest['title'] + + @property + def description(self): + return self._manifest['description'] + + @property + def version(self): + return self._manifest['version'] + + @property + def homepage(self): + return self._manifest.get("homepage") + + @property + def vendor_url(self): + return self._manifest.get("url") + + @property + def license(self): + return self._manifest.get("license") + + @property + def frameworks(self): + return self._manifest.get("frameworks") + + @property + def manifest(self): + return self._manifest + + @property + def packages(self): + if "packages" not in self._manifest: + self._manifest['packages'] = {} + if "tool-scons" not in self._manifest['packages']: + self._manifest['packages']['tool-scons'] = { + "version": self._manifest.get("engines", {}).get( + "scons", ">=2.3.0,<2.6.0"), + "optional": False + } + return self._manifest['packages'] + + def get_dir(self): + return dirname(self.manifest_path) + + def get_build_script(self): + main_script = join(self.get_dir(), "builder", "main.py") + if isfile(main_script): + return main_script + raise NotImplementedError() + + def is_embedded(self): + for opts in self.packages.values(): + if opts.get("type") == "uploader": + return True + return False + + def get_boards(self, id_=None): + + def _append_board(board_id, manifest_path): + config = PlatformBoardConfig(manifest_path) + if "platform" in config and config.get("platform") != self.name: + return + elif ("platforms" in config and + self.name not in config.get("platforms")): + return + config.manifest['platform'] = self.name + self._BOARDS_CACHE[board_id] = config + + bdirs = (join(util.get_home_dir(), "boards"), + join(self.get_dir(), "boards")) + if id_ is None: + for boards_dir in bdirs: + if not isdir(boards_dir): + continue + for item in sorted(os.listdir(boards_dir)): + _id = item[:-5] + if not item.endswith(".json") or _id in self._BOARDS_CACHE: + continue + _append_board(_id, join(boards_dir, item)) + else: + if id_ not in self._BOARDS_CACHE: + for boards_dir in bdirs: + if not isdir(boards_dir): + continue + manifest_path = join(boards_dir, "%s.json" % id_) + if not isfile(manifest_path): + continue + _append_board(id_, manifest_path) + if id_ not in self._BOARDS_CACHE: + raise exception.UnknownBoard(id_) + return self._BOARDS_CACHE[id_] if id_ else self._BOARDS_CACHE + + def board_config(self, id_): + return self.get_boards(id_) + + def get_package_type(self, name): + return self.packages[name].get("type") + + def pkg_types_to_names(self, types): + names = [] + for type_ in types: + name = type_ + # lookup by package types + for _name, _opts in self.packages.items(): + if _opts.get("type") == type_: + name = None + names.append(_name) + # if type is the right name + if name: + names.append(name) + return names + + def configure_default_packages(self, variables, targets): + # enbale used frameworks + for framework in variables.get("pioframework", "").split(","): + if not self.frameworks: + continue + framework = framework.lower().strip() + if not framework or framework not in self.frameworks: + continue + _pkg_name = self.frameworks[framework]['package'] + self.packages[_pkg_name]['optional'] = False + + # enable upload tools for upload targets + if any(["upload" in t for t in targets] + ["program" in targets]): + for _name, _opts in self.packages.iteritems(): + if _opts.get("type") == "uploader": + self.packages[_name]['optional'] = False + elif "uploadlazy" in targets: + # skip all packages, allow only upload tools + self.packages[_name]['optional'] = True + + if "test" in targets and "tool-unity" not in self.packages: + self.packages['tool-unity'] = { + "version": "~1.20302.1", + "optional": False + } + + +class PlatformBoardConfig(object): + + def __init__(self, manifest_path): + self._id = basename(manifest_path)[:-5] + assert isfile(manifest_path) + self.manifest_path = manifest_path + try: + self._manifest = util.load_json(manifest_path) + except ValueError: + raise exception.InvalidBoardManifest(manifest_path) + if not set(["name", "url", "vendor"]) <= set(self._manifest.keys()): + raise exception.PlatformioException( + "Please specify name, url and vendor fields for " + + manifest_path) + + def get(self, path, default=None): + try: + value = self._manifest + for k in path.split("."): + value = value[k] + return value + except KeyError: + if default is not None: + return default + else: + raise KeyError("Invalid board option '%s'" % path) + + def __contains__(self, key): + try: + self.get(key) + return True + except KeyError: + return False + + @property + def id_(self): + return self._id + + @property + def manifest(self): + return self._manifest + + def get_brief_data(self): + return { + "id": self.id_, + "name": self._manifest['name'], + "platform": self._manifest.get("platform"), + "mcu": self._manifest.get("build", {}).get("mcu", "").upper(), + "fcpu": + int(self._manifest.get("build", {}).get("f_cpu", "0L")[:-1]), + "ram": self._manifest.get("upload", {}).get("maximum_ram_size", 0), + "rom": self._manifest.get("upload", {}).get("maximum_size", 0), + "frameworks": self._manifest.get("frameworks"), + "vendor": self._manifest['vendor'], + "url": self._manifest['url'] + } diff --git a/platformio/pioplus.py b/platformio/pioplus.py new file mode 100644 index 00000000..edfc1166 --- /dev/null +++ b/platformio/pioplus.py @@ -0,0 +1,57 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import subprocess +from os.path import dirname, join +from platform import system + +from platformio import util +from platformio.managers.package import PackageManager + +PACKAGE_PIOPLUS_NAME = "tool-pioplus" + + +class PioPlusPackageManager(PackageManager): + + def __init__(self): + PackageManager.__init__( + self, join(util.get_home_dir(), "packages"), + ["https://dl.bintray.com/platformio/dl-packages/manifest.json", + "https://dl.platformio.org/packages/manifest.json"]) + + +def get_pioplusexe_path(): + pm = PioPlusPackageManager() + package_dir = pm.get_package_dir(PACKAGE_PIOPLUS_NAME) + if not package_dir: + pm.install(PACKAGE_PIOPLUS_NAME) + package_dir = pm.get_package_dir(PACKAGE_PIOPLUS_NAME) + assert package_dir + return join(package_dir, "pioplus") + + +def pioplus_update(): + pm = PioPlusPackageManager() + if pm.get_package_dir(PACKAGE_PIOPLUS_NAME): + pm.update(PACKAGE_PIOPLUS_NAME) + + +def pioplus_call(args, **kwargs): + pioplus_path = get_pioplusexe_path() + if system() == "Linux": + os.environ['LD_LIBRARY_PATH'] = dirname(pioplus_path) + os.environ['PYTHONEXEPATH'] = util.get_pythonexe_path() + util.copy_pythonpath_to_osenv() + subprocess.call([pioplus_path] + args, **kwargs) diff --git a/platformio/pkgmanager.py b/platformio/pkgmanager.py deleted file mode 100644 index 33f74bb7..00000000 --- a/platformio/pkgmanager.py +++ /dev/null @@ -1,172 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from os import makedirs, remove -from os.path import basename, isdir, isfile, join -from shutil import rmtree -from time import time - -import click -import requests - -from platformio import exception, telemetry, util -from platformio.app import get_state_item, set_state_item -from platformio.downloader import FileDownloader -from platformio.unpacker import FileUnpacker - - -class PackageManager(object): - - def __init__(self): - self._package_dir = join(util.get_home_dir(), "packages") - if not isdir(self._package_dir): - makedirs(self._package_dir) - assert isdir(self._package_dir) - - @classmethod - @util.memoized - def get_manifest(cls): - return util.get_api_result("/packages/manifest") - - @staticmethod - def download(url, dest_dir, sha1=None): - fd = FileDownloader(url, dest_dir) - fd.start() - fd.verify(sha1) - return fd.get_filepath() - - @staticmethod - def unpack(pkgpath, dest_dir): - fu = FileUnpacker(pkgpath, dest_dir) - return fu.start() - - @staticmethod - def get_installed(): - return get_state_item("installed_packages", {}) - - def get_outdated(self): - outdated = [] - for name, data in self.get_installed().items(): - if data['version'] != self.get_info(name)['version']: - outdated.append(name) - return outdated - - def is_installed(self, name): - return name in self.get_installed() - - def get_info(self, name, version=None): - manifest = self.get_manifest() - if name not in manifest: - raise exception.UnknownPackage(name) - - # check system platform - systype = util.get_systype() - builds = ([b for b in manifest[name] if b['system'] == "all" or systype - in b['system']]) - if not builds: - raise exception.NonSystemPackage(name, systype) - - if version: - for b in builds: - if b['version'] == version: - return b - raise exception.InvalidPackageVersion(name, version) - else: - return sorted(builds, key=lambda s: s['version'])[-1] - - def install(self, name): - click.echo("Installing %s package:" % click.style(name, fg="cyan")) - - if self.is_installed(name): - click.secho("Already installed", fg="yellow") - return False - - info = self.get_info(name) - pkg_dir = join(self._package_dir, name) - if not isdir(pkg_dir): - makedirs(pkg_dir) - - dlpath = None - try: - dlpath = self.download(info['url'], pkg_dir, info['sha1']) - except (requests.exceptions.ConnectionError, - requests.exceptions.ChunkedEncodingError, - requests.exceptions.SSLError, - exception.FDUnrecognizedStatusCode, StopIteration): - if not info['url'].startswith("http://dl.platformio.org"): - dlpath = self.download( - "http://dl.platformio.org/packages/%s" % - basename(info['url']), pkg_dir, info['sha1']) - - assert isfile(dlpath) - - if self.unpack(dlpath, pkg_dir): - self._register(name, info['version']) - # remove archive - remove(dlpath) - - telemetry.on_event( - category="PackageManager", action="Install", label=name) - - def uninstall(self, name): - click.echo("Uninstalling %s package: \t" % - click.style(name, fg="cyan"), nl=False) - - if not self.is_installed(name): - click.secho("Not installed", fg="yellow") - return False - - if isdir(join(self._package_dir, name)): - rmtree(join(self._package_dir, name)) - self._unregister(name) - click.echo("[%s]" % click.style("OK", fg="green")) - - # report usage - telemetry.on_event( - category="PackageManager", action="Uninstall", label=name) - - def update(self, name): - click.echo("Updating %s package:" % click.style(name, fg="yellow")) - - installed = self.get_installed() - current_version = installed[name]['version'] - latest_version = self.get_info(name)['version'] - - click.echo("Versions: Current=%d, Latest=%d \t " % - (current_version, latest_version), nl=False) - - if current_version == latest_version: - click.echo("[%s]" % (click.style("Up-to-date", fg="green"))) - return True - else: - click.echo("[%s]" % (click.style("Out-of-date", fg="red"))) - - self.uninstall(name) - self.install(name) - - telemetry.on_event( - category="PackageManager", action="Update", label=name) - - def _register(self, name, version): - data = self.get_installed() - data[name] = { - "version": version, - "time": int(time()) - } - set_state_item("installed_packages", data) - - def _unregister(self, name): - data = self.get_installed() - del data[name] - set_state_item("installed_packages", data) diff --git a/platformio/platforms/atmelavr.py b/platformio/platforms/atmelavr.py deleted file mode 100644 index 4469b652..00000000 --- a/platformio/platforms/atmelavr.py +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform -from platformio.util import get_boards - - -class AtmelavrPlatform(BasePlatform): - - """ - Atmel AVR 8- and 32-bit MCUs deliver a unique combination of - performance, power efficiency and design flexibility. Optimized to - speed time to market-and easily adapt to new ones-they are based on - the industrys most code-efficient architecture for C and assembly - programming. - - http://www.atmel.com/products/microcontrollers/avr/default.aspx - """ - - PACKAGES = { - - "toolchain-atmelavr": { - "alias": "toolchain", - "default": True - }, - - "tool-avrdude": { - }, - - "tool-micronucleus": { - }, - - "framework-arduinoavr": { - "alias": "framework" - }, - - "framework-simba": { - "alias": "framework" - } - } - - def get_name(self): - return "Atmel AVR" - - def configure_default_packages(self, envoptions, targets): - if envoptions.get("board"): - board = get_boards(envoptions.get("board")) - if "digispark" in board['build']['core']: - self.PACKAGES['tool-micronucleus']['alias'] = "uploader" - else: - self.PACKAGES['tool-avrdude']['alias'] = "uploader" - - return BasePlatform.configure_default_packages( - self, envoptions, targets) - - def on_run_err(self, line): # pylint: disable=R0201 - # fix STDERR "flash written" for avrdude - if "avrdude" in line: - self.on_run_out(line) - else: - BasePlatform.on_run_err(self, line) diff --git a/platformio/platforms/atmelsam.py b/platformio/platforms/atmelsam.py deleted file mode 100644 index e12f02ba..00000000 --- a/platformio/platforms/atmelsam.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform -from platformio.util import get_boards - - -class AtmelsamPlatform(BasePlatform): - - """ - Atmel | SMART offers Flash- based ARM products based on the ARM - Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB - to 2MB of Flash including a rich peripheral and feature mix. - - http://www.atmel.com/products/microcontrollers/arm/default.aspx - """ - - PACKAGES = { - - "toolchain-gccarmnoneeabi": { - "alias": "toolchain", - "default": True - }, - - "ldscripts": { - "default": True - }, - - "framework-arduinosam": { - "alias": "framework" - }, - - "framework-mbed": { - "alias": "framework" - }, - - "framework-simba": { - "alias": "framework" - }, - - "tool-bossac": { - }, - - "tool-openocd": { - }, - - "tool-avrdude": { - } - } - - def get_name(self): - return "Atmel SAM" - - def configure_default_packages(self, envoptions, targets): - if envoptions.get("board"): - board = get_boards(envoptions.get("board")) - upload_protocol = board.get("upload", {}).get("protocol", None) - upload_tool = None - if upload_protocol == "openocd": - upload_tool = "tool-openocd" - elif upload_protocol == "sam-ba": - upload_tool = "tool-bossac" - elif upload_protocol == "stk500v2": - upload_tool = "tool-avrdude" - - if upload_tool: - self.PACKAGES[upload_tool]['alias'] = "uploader" - - return BasePlatform.configure_default_packages( - self, envoptions, targets) diff --git a/platformio/platforms/base.py b/platformio/platforms/base.py deleted file mode 100644 index ba97cbe6..00000000 --- a/platformio/platforms/base.py +++ /dev/null @@ -1,547 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import base64 -import os -import re -import sys -from imp import load_source -from multiprocessing import cpu_count -from os.path import isdir, isfile, join - -import click - -from platformio import app, exception, util -from platformio.app import get_state_item, set_state_item -from platformio.pkgmanager import PackageManager - -PLATFORM_PACKAGES = { - - "framework-arduinoavr": [ - ("Arduino Wiring-based Framework (AVR Core, 1.6)", - "http://arduino.cc/en/Reference/HomePage") - ], - "framework-arduinosam": [ - ("Arduino Wiring-based Framework (SAM Core, 1.6)", - "http://arduino.cc/en/Reference/HomePage") - ], - "framework-arduinoteensy": [ - ("Arduino Wiring-based Framework", - "http://arduino.cc/en/Reference/HomePage") - ], - "framework-arduinomsp430": [ - ("Arduino Wiring-based Framework (MSP430 Core)", - "http://arduino.cc/en/Reference/HomePage") - ], - "framework-arduinoespressif": [ - ("Arduino Wiring-based Framework (ESP8266 Core)", - "https://github.com/esp8266/Arduino") - ], - "framework-arduinomicrochippic32": [ - ("Arduino Wiring-based Framework (PIC32 Core)", - "https://github.com/chipKIT32/chipKIT-core") - ], - "framework-arduinointel": [ - ("Arduino Wiring-based Framework (Intel ARC Core)", - "https://github.com/01org/corelibs-arduino101") - ], - "framework-arduinonordicnrf51": [ - ("Arduino Wiring-based Framework (RFduino Core)", - "https://github.com/RFduino/RFduino") - ], - "framework-energiamsp430": [ - ("Energia Wiring-based Framework (MSP430 Core)", - "http://energia.nu/reference/") - ], - "framework-energiativa": [ - ("Energia Wiring-based Framework (LM4F Core)", - "http://energia.nu/reference/") - ], - "framework-cmsis": [ - ("Vendor-independent hardware abstraction layer for the Cortex-M " - "processor series", - "http://www.arm.com/products/processors/" - "cortex-m/cortex-microcontroller-software-interface-standard.php") - ], - "framework-spl": [ - ("Standard Peripheral Library for STM32 MCUs", - "http://www.st.com" - "/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF257890") - ], - "framework-libopencm3": [ - ("libOpenCM3 Framework", "http://www.libopencm3.org/") - ], - "framework-mbed": [ - ("mbed Framework", "http://mbed.org") - ], - "framework-wiringpi": [ - ("GPIO Interface library for the Raspberry Pi", "http://wiringpi.com") - ], - "framework-simba": [ - ("Simba Framework", "https://github.com/eerimoq/simba") - ], - "sdk-esp8266": [ - ("ESP8266 SDK", "http://bbs.espressif.com") - ], - "ldscripts": [ - ("Linker Scripts", - "https://sourceware.org/binutils/docs/ld/Scripts.html") - ], - "toolchain-atmelavr": [ - ("avr-gcc", "https://gcc.gnu.org/wiki/avr-gcc"), - ("GDB", "http://www.gnu.org/software/gdb/"), - ("AVaRICE", "http://avarice.sourceforge.net/"), - ("SimulAVR", "http://www.nongnu.org/simulavr/") - ], - "toolchain-gccarmnoneeabi": [ - ("gcc-arm-embedded", "https://launchpad.net/gcc-arm-embedded"), - ("GDB", "http://www.gnu.org/software/gdb/") - ], - "toolchain-gccarmlinuxgnueabi": [ - ("GCC for Linux ARM GNU EABI", "https://gcc.gnu.org"), - ("GDB", "http://www.gnu.org/software/gdb/") - ], - "toolchain-gccmingw32": [ - ("MinGW", "http://www.mingw.org") - ], - "toolchain-gcclinux32": [ - ("GCC for Linux i686", "https://gcc.gnu.org") - ], - "toolchain-gcclinux64": [ - ("GCC for Linux x86_64", "https://gcc.gnu.org") - ], - "toolchain-xtensa": [ - ("xtensa-gcc", "https://github.com/jcmvbkbc/gcc-xtensa"), - ("GDB", "http://www.gnu.org/software/gdb/") - ], - "toolchain-timsp430": [ - ("msp-gcc", "http://sourceforge.net/projects/mspgcc/"), - ("GDB", "http://www.gnu.org/software/gdb/") - ], - "toolchain-icestorm": [ - ("GCC for FPGA IceStorm", "http://www.clifford.at/icestorm/") - ], - "toolchain-microchippic32": [ - ("GCC for Microchip PIC32", "https://github.com/chipKIT32/chipKIT-cxx") - ], - "toolchain-intelarc32": [ - ("GCC for Intel ARC", - "https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain") - ], - "tool-scons": [ - ("SCons software construction tool", "http://www.scons.org") - ], - "tool-avrdude": [ - ("AVRDUDE", "http://www.nongnu.org/avrdude/") - ], - "tool-micronucleus": [ - ("Micronucleus", "https://github.com/micronucleus/micronucleus") - ], - "tool-bossac": [ - ("BOSSA CLI", "https://sourceforge.net/projects/b-o-s-s-a/") - ], - "tool-openocd": [ - ("OpenOCD", "http://openocd.org") - ], - "tool-stlink": [ - ("ST-Link", "https://github.com/texane/stlink") - ], - "tool-teensy": [ - ("Teensy Loader", "https://www.pjrc.com/teensy/loader.html") - ], - "tool-lm4flash": [ - ("Flash Programmer", "http://www.ti.com/tool/lmflashprogrammer") - ], - "tool-mspdebug": [ - ("MSPDebug", "http://mspdebug.sourceforge.net/") - ], - "tool-esptool": [ - ("esptool-ck", "https://github.com/igrr/esptool-ck") - ], - "tool-rfdloader": [ - ("rfdloader", "https://github.com/RFduino/RFduino") - ], - "tool-mkspiffs": [ - ("Tool to build and unpack SPIFFS images", - "https://github.com/igrr/mkspiffs") - ], - "tool-pic32prog": [ - ("pic32prog", "https://github.com/sergev/pic32prog") - ], - "tool-arduino101load": [ - ("Genuino101 uploader", "https://github.com/01org/intel-arduino-tools") - ], - "tool-sreccat": [ - ("Merging tool", "https://github.com/marcows/SRecord") - ] -} - - -def get_packages(): - return PLATFORM_PACKAGES - - -class PlatformFactory(object): - - @staticmethod - def get_clsname(type_): - return "%s%sPlatform" % (type_.upper()[0], type_.lower()[1:]) - - @staticmethod - def load_module(type_, path): - module = None - try: - module = load_source( - "platformio.platforms.%s" % type_, path) - except ImportError: - raise exception.UnknownPlatform(type_) - return module - - @classmethod - @util.memoized - def _lookup_platforms(cls): - platforms = {} - for d in (util.get_home_dir(), util.get_source_dir()): - pdir = join(d, "platforms") - if not isdir(pdir): - continue - for p in sorted(os.listdir(pdir)): - if (p in ("__init__.py", "base.py") or not - p.endswith(".py")): - continue - type_ = p[:-3] - path = join(pdir, p) - try: - isplatform = hasattr( - cls.load_module(type_, path), - cls.get_clsname(type_) - ) - if isplatform: - platforms[type_] = path - except exception.UnknownPlatform: - pass - return platforms - - @classmethod - def get_platforms(cls, installed=False): - platforms = cls._lookup_platforms() - - if not installed: - return platforms - - installed_platforms = {} - for type_ in get_state_item("installed_platforms", []): - if type_ in platforms: - installed_platforms[type_] = platforms[type_] - return installed_platforms - - @classmethod - def newPlatform(cls, type_): - platforms = cls.get_platforms() - if type_ not in platforms: - raise exception.UnknownPlatform(type_) - - _instance = getattr( - cls.load_module(type_, platforms[type_]), - cls.get_clsname(type_) - )() - assert isinstance(_instance, BasePlatform) - return _instance - - -class BasePlatform(object): - - PACKAGES = {} - LINE_ERROR_RE = re.compile(r"(\s+error|error[:\s]+)", re.I) - - def __init__(self): - self._found_error = False - self._last_echo_line = None - - # 1 = errors - # 2 = 1 + warnings - # 3 = 2 + others - self._verbose_level = 3 - - def get_type(self): - return self.__class__.__name__[:-8].lower() - - def get_name(self): - return self.get_type().title() - - def get_build_script(self): - builtin = join(util.get_source_dir(), "builder", "scripts", "%s.py" % - self.get_type()) - if isfile(builtin): - return builtin - raise NotImplementedError() - - def get_description(self): - if self.__doc__: - doclines = [l.strip() for l in self.__doc__.splitlines() if - l.strip()] - return " ".join(doclines[:-1]).strip() - else: - raise NotImplementedError() - - def get_vendor_url(self): - if self.__doc__ and "http" in self.__doc__: - return self.__doc__[self.__doc__.index("http"):].strip() - else: - raise NotImplementedError() - - def is_embedded(self): - for name, opts in self.get_packages().items(): - if name == "framework-mbed" or opts.get("alias") == "uploader": - return True - return False - - def get_packages(self): - return self.PACKAGES - - def get_package_alias(self, pkgname): - return self.PACKAGES[pkgname].get("alias") - - def pkg_aliases_to_names(self, aliases): - names = [] - for alias in aliases: - name = alias - # lookup by package aliases - for _name, _opts in self.get_packages().items(): - if _opts.get("alias") == alias: - name = None - names.append(_name) - # if alias is the right name - if name: - names.append(name) - return names - - def get_default_packages(self): - return [k for k, v in self.get_packages().items() - if v.get("default", False)] - - def get_installed_packages(self): - pm = PackageManager() - return [n for n in self.get_packages() if pm.is_installed(n)] - - def install(self, with_packages=None, without_packages=None, - skip_default_packages=False): - with_packages = set( - self.pkg_aliases_to_names(with_packages or [])) - without_packages = set( - self.pkg_aliases_to_names(without_packages or [])) - - upkgs = with_packages | without_packages - ppkgs = set(self.get_packages().keys()) - if not upkgs.issubset(ppkgs): - raise exception.UnknownPackage(", ".join(upkgs - ppkgs)) - - requirements = [] - for name, opts in self.get_packages().items(): - if name in without_packages: - continue - elif (name in with_packages or (not skip_default_packages and - opts.get("default"))): - requirements.append(name) - - pm = PackageManager() - for name in requirements: - pm.install(name) - - # register installed platform - data = get_state_item("installed_platforms", []) - if self.get_type() not in data: - data.append(self.get_type()) - set_state_item("installed_platforms", data) - - return len(requirements) - - def uninstall(self): - platform = self.get_type() - installed_platforms = PlatformFactory.get_platforms( - installed=True).keys() - - if platform not in installed_platforms: - raise exception.PlatformNotInstalledYet(platform) - - deppkgs = set() - for item in installed_platforms: - if item == platform: - continue - p = PlatformFactory.newPlatform(item) - deppkgs = deppkgs.union(set(p.get_packages().keys())) - - pm = PackageManager() - for name in self.get_packages(): - if not pm.is_installed(name) or name in deppkgs: - continue - pm.uninstall(name) - - # unregister installed platform - installed_platforms.remove(platform) - set_state_item("installed_platforms", installed_platforms) - - return True - - def update(self): - pm = PackageManager() - for name in self.get_installed_packages(): - pm.update(name) - - def is_outdated(self): - pm = PackageManager() - obsolated = pm.get_outdated() - return not set(self.get_packages().keys()).isdisjoint(set(obsolated)) - - def configure_default_packages(self, variables, targets): - # enbale used frameworks - for pkg_name in self.pkg_aliases_to_names(["framework"]): - for framework in variables.get("framework", "").split(","): - framework = framework.lower().strip() - if not framework: - continue - if framework in pkg_name: - self.PACKAGES[pkg_name]['default'] = True - - # append SCons tool - self.PACKAGES['tool-scons'] = {"default": True} - - # enable upload tools for upload targets - if any(["upload" in t for t in targets] + ["program" in targets]): - for _name, _opts in self.PACKAGES.iteritems(): - if _opts.get("alias") == "uploader": - self.PACKAGES[_name]['default'] = True - elif "uploadlazy" in targets: - # skip all packages, allow only upload tools - self.PACKAGES[_name]['default'] = False - - def _install_default_packages(self): - installed_platforms = PlatformFactory.get_platforms( - installed=True).keys() - - if (self.get_type() in installed_platforms and - set(self.get_default_packages()) <= - set(self.get_installed_packages())): - return True - - if (not app.get_setting("enable_prompts") or - self.get_type() in installed_platforms or - click.confirm( - "The platform '%s' has not been installed yet. " - "Would you like to install it now?" % self.get_type())): - return self.install() - else: - raise exception.PlatformNotInstalledYet(self.get_type()) - - def run(self, variables, targets, verbose): - assert isinstance(variables, dict) - assert isinstance(targets, list) - - self.configure_default_packages(variables, targets) - self._install_default_packages() - - self._verbose_level = int(verbose) - - if "clean" in targets: - targets.remove("clean") - targets.append("-c") - - if "build_script" not in variables: - variables['build_script'] = self.get_build_script() - if not isfile(variables['build_script']): - raise exception.BuildScriptNotFound(variables['build_script']) - - # append aliases of the installed packages - installed_packages = PackageManager.get_installed() - for name, options in self.get_packages().items(): - if "alias" not in options or name not in installed_packages: - continue - variables['piopackage_%s' % options['alias']] = name - - self._found_error = False - result = self._run_scons(variables, targets) - assert "returncode" in result - # if self._found_error: - # result['returncode'] = 1 - - if self._last_echo_line == ".": - click.echo("") - - return result - - def _run_scons(self, variables, targets): - # pass current PYTHONPATH to SCons - if "PYTHONPATH" in os.environ: - _PYTHONPATH = os.environ.get("PYTHONPATH").split(os.pathsep) - else: - _PYTHONPATH = [] - for p in os.sys.path: - if p not in _PYTHONPATH: - _PYTHONPATH.append(p) - os.environ['PYTHONPATH'] = os.pathsep.join(_PYTHONPATH) - - cmd = [ - os.path.normpath(sys.executable), - join(util.get_home_dir(), "packages", "tool-scons", - "script", "scons"), - "-Q", - "-j %d" % self.get_job_nums(), - "--warn=no-no-parallel-support", - "-f", join(util.get_source_dir(), "builder", "main.py") - ] + targets - - # encode and append variables - for key, value in variables.items(): - cmd.append("%s=%s" % (key.upper(), base64.b64encode(value))) - - result = util.exec_command( - cmd, - stdout=util.AsyncPipe(self.on_run_out), - stderr=util.AsyncPipe(self.on_run_err) - ) - return result - - def on_run_out(self, line): - self._echo_line(line, level=3) - - def on_run_err(self, line): - is_error = self.LINE_ERROR_RE.search(line) is not None - if is_error: - self._found_error = True - self._echo_line(line, level=1 if is_error else 2) - - def _echo_line(self, line, level): - assert 1 <= level <= 3 - - fg = ("red", "yellow", None)[level - 1] - if level == 3 and "is up to date" in line: - fg = "green" - - if level > self._verbose_level: - click.secho(".", fg=fg, err=level < 3, nl=False) - self._last_echo_line = "." - return - - if self._last_echo_line == ".": - click.echo("") - self._last_echo_line = line - - click.secho(line, fg=fg, err=level < 3) - - @staticmethod - def get_job_nums(): - try: - return cpu_count() - except NotImplementedError: - return 1 diff --git a/platformio/platforms/espressif.py b/platformio/platforms/espressif.py deleted file mode 100644 index 97d95c10..00000000 --- a/platformio/platforms/espressif.py +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class EspressifPlatform(BasePlatform): - - """ - Espressif Systems is a privately held fabless semiconductor company. - They provide wireless communications and Wi-Fi chips which are widely - used in mobile devices and the Internet of Things applications. - - https://espressif.com/ - """ - - PACKAGES = { - - "toolchain-xtensa": { - "alias": "toolchain", - "default": True - }, - - "ldscripts": { - "default": True - }, - - "tool-esptool": { - "alias": "uploader", - "default": True - }, - - "tool-mkspiffs": { - "alias": "uploader" - }, - - "sdk-esp8266": { - }, - - "framework-arduinoespressif": { - "alias": "framework" - }, - - "framework-simba": { - "alias": "framework" - } - } - - def get_name(self): - return "Espressif" - - def configure_default_packages(self, envoptions, targets): - if not envoptions.get("framework"): - self.PACKAGES['sdk-esp8266']['default'] = True - - return BasePlatform.configure_default_packages( - self, envoptions, targets) diff --git a/platformio/platforms/freescalekinetis.py b/platformio/platforms/freescalekinetis.py deleted file mode 100644 index 47e387d0..00000000 --- a/platformio/platforms/freescalekinetis.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class FreescalekinetisPlatform(BasePlatform): - - """ - Freescale Kinetis Microcontrollers is family of multiple hardware- and - software-compatible ARM Cortex-M0+, Cortex-M4 and Cortex-M7-based MCU - series. Kinetis MCUs offer exceptional low-power performance, - scalability and feature integration. - - http://www.freescale.com/webapp/sps/site/homepage.jsp?code=KINETIS - """ - - PACKAGES = { - - "toolchain-gccarmnoneeabi": { - "alias": "toolchain", - "default": True - }, - - "framework-mbed": { - "alias": "framework" - } - } - - def get_name(self): - return "Freescale Kinetis" diff --git a/platformio/platforms/intel_arc32.py b/platformio/platforms/intel_arc32.py deleted file mode 100644 index a0aa7535..00000000 --- a/platformio/platforms/intel_arc32.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Intel_arc32Platform(BasePlatform): - - """ - ARC embedded processors are a family of 32-bit CPUs that are widely used - in SoC devices for storage, home, mobile, automotive, and Internet of - Things applications. - - http://www.intel.com/content/www/us/en/wearables/wearable-soc.html - """ - - PACKAGES = { - - "toolchain-intelarc32": { - "alias": "toolchain", - "default": True - }, - - "framework-arduinointel": { - "alias": "framework" - }, - - "tool-arduino101load": { - "alias": "uploader" - }, - } - - def get_name(self): - return "Intel ARC32" diff --git a/platformio/platforms/lattice_ice40.py b/platformio/platforms/lattice_ice40.py deleted file mode 100755 index 35d41ed8..00000000 --- a/platformio/platforms/lattice_ice40.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Lattice_ice40Platform(BasePlatform): - - """ - The iCE40 family of ultra-low power, non-volatile FPGAs has five devices - with densities ranging from 384 to 7680 Look-Up Tables (LUTs). In addition - to LUT-based,low-cost programmable logic, these devices feature Embedded - Block RAM (EBR), Non-volatile Configuration Memory (NVCM) and Phase Locked - Loops (PLLs). These features allow the devices to be used in low-cost, - high-volume consumer and system applications. - - http://www.latticesemi.com/Products/FPGAandCPLD/iCE40.aspx - """ - - PACKAGES = { - - "toolchain-icestorm": { - "alias": "toolchain", - "default": True - } - } - - def get_name(self): - return "Lattice iCE40" - - def is_embedded(self): - return True diff --git a/platformio/platforms/linux_arm.py b/platformio/platforms/linux_arm.py deleted file mode 100644 index 79c03ad5..00000000 --- a/platformio/platforms/linux_arm.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio import exception, util -from platformio.platforms.base import BasePlatform - - -class Linux_armPlatform(BasePlatform): - - """ - Linux ARM is a Unix-like and mostly POSIX-compliant computer - operating system (OS) assembled under the model of free and open-source - software development and distribution. - - Using host OS (Mac OS X, Linux ARM) you can build native application - for Linux ARM platform. - - http://platformio.org/platforms/linux_arm - """ - - PACKAGES = { - - "toolchain-gccarmlinuxgnueabi": { - "alias": "toolchain", - "default": True - }, - - "framework-wiringpi": { - "alias": "framework" - } - } - - def __init__(self): - if "linux_arm" in util.get_systype(): - del self.PACKAGES['toolchain-gccarmlinuxgnueabi'] - BasePlatform.__init__(self) - - def configure_default_packages(self, envoptions, targets): - if (envoptions.get("framework") == "wiringpi" and - "linux_arm" not in util.get_systype()): - raise exception.PlatformioException( - "PlatformIO does not support temporary cross-compilation " - "for WiringPi framework. Please run PlatformIO directly on " - "Raspberry Pi" - ) - - return BasePlatform.configure_default_packages( - self, envoptions, targets) diff --git a/platformio/platforms/linux_i686.py b/platformio/platforms/linux_i686.py deleted file mode 100644 index 11f1ac01..00000000 --- a/platformio/platforms/linux_i686.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform -from platformio.util import get_systype - - -class Linux_i686Platform(BasePlatform): - - """ - Linux i686 (32-bit) is a Unix-like and mostly POSIX-compliant - computer operating system (OS) assembled under the model of free and - open-source software development and distribution. - - Using host OS (Mac OS X or Linux 32-bit) you can build native - application for Linux i686 platform. - - http://platformio.org/platforms/linux_i686 - """ - - PACKAGES = { - - "toolchain-gcclinux32": { - "alias": "toolchain", - "default": True - } - } - - def __init__(self): - if get_systype() == "linux_i686": - del self.PACKAGES['toolchain-gcclinux32'] - BasePlatform.__init__(self) diff --git a/platformio/platforms/linux_x86_64.py b/platformio/platforms/linux_x86_64.py deleted file mode 100644 index c3bf330e..00000000 --- a/platformio/platforms/linux_x86_64.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform -from platformio.util import get_systype - - -class Linux_x86_64Platform(BasePlatform): - - """ - Linux x86_64 (64-bit) is a Unix-like and mostly POSIX-compliant - computer operating system (OS) assembled under the model of free and - open-source software development and distribution. - - Using host OS (Mac OS X or Linux 64-bit) you can build native - application for Linux x86_64 platform. - - http://platformio.org/platforms/linux_i686 - """ - - PACKAGES = { - - "toolchain-gcclinux64": { - "alias": "toolchain", - "default": True - } - } - - def __init__(self): - if get_systype() == "linux_x86_64": - del self.PACKAGES['toolchain-gcclinux64'] - BasePlatform.__init__(self) diff --git a/platformio/platforms/microchippic32.py b/platformio/platforms/microchippic32.py deleted file mode 100644 index 22888125..00000000 --- a/platformio/platforms/microchippic32.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Microchippic32Platform(BasePlatform): - - """ - Microchip's 32-bit portfolio with the MIPS microAptiv or M4K core offer - high performance microcontrollers, and all the tools needed to develop - your embedded projects. PIC32 MCUs gives your application the processing - power, memory and peripherals your design needs! - - http://www.microchip.com/design-centers/32-bit - """ - - PACKAGES = { - - "toolchain-microchippic32": { - "alias": "toolchain", - "default": True - }, - - "framework-arduinomicrochippic32": { - "alias": "framework" - }, - - "tool-pic32prog": { - "alias": "uploader" - } - } - - def get_name(self): - return "Microchip PIC32" diff --git a/platformio/platforms/nordicnrf51.py b/platformio/platforms/nordicnrf51.py deleted file mode 100644 index 32a0d054..00000000 --- a/platformio/platforms/nordicnrf51.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Nordicnrf51Platform(BasePlatform): - - """ - The Nordic nRF51 Series is a family of highly flexible, - multi-protocol, system-on-chip (SoC) devices for ultra-low power - wireless applications. nRF51 Series devices support a range of - protocol stacks including Bluetooth Smart (previously called - Bluetooth low energy), ANT and proprietary 2.4GHz protocols such as - Gazell. - - https://www.nordicsemi.com/eng/Products/nRF51-Series-SoC - """ - - PACKAGES = { - - "toolchain-gccarmnoneeabi": { - "alias": "toolchain", - "default": True - }, - - "framework-mbed": { - "alias": "framework" - }, - - "framework-arduinonordicnrf51": { - "alias": "framework" - }, - - "tool-sreccat": { - "default": True - }, - - "tool-rfdloader": { - } - } - - def get_name(self): - return "Nordic nRF51" - - def configure_default_packages(self, envoptions, targets): - if envoptions.get("board") == "rfduino": - self.PACKAGES['tool-rfdloader']['alias'] = "uploader" - - return BasePlatform.configure_default_packages( - self, envoptions, targets) diff --git a/platformio/platforms/nxplpc.py b/platformio/platforms/nxplpc.py deleted file mode 100644 index d359b117..00000000 --- a/platformio/platforms/nxplpc.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class NxplpcPlatform(BasePlatform): - - """ - The NXP LPC is a family of 32-bit microcontroller integrated circuits - by NXP Semiconductors. The LPC chips are grouped into related series - that are based around the same 32-bit ARM processor core, such as the - Cortex-M4F, Cortex-M3, Cortex-M0+, or Cortex-M0. Internally, each - microcontroller consists of the processor core, static RAM memory, - flash memory, debugging interface, and various peripherals. - - http://www.nxp.com/products/microcontrollers/ - """ - - PACKAGES = { - - "toolchain-gccarmnoneeabi": { - "alias": "toolchain", - "default": True - }, - - "framework-mbed": { - "alias": "framework" - } - } - - def get_name(self): - return "NXP LPC" diff --git a/platformio/platforms/siliconlabsefm32.py b/platformio/platforms/siliconlabsefm32.py deleted file mode 100644 index 8aa642ea..00000000 --- a/platformio/platforms/siliconlabsefm32.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Siliconlabsefm32Platform(BasePlatform): - - """ - Silicon Labs EFM32 Gecko 32-bit microcontroller (MCU) family includes - devices that offer flash memory configurations up to 256 kB, 32 kB of - RAM and CPU speeds up to 48 MHz. - - Based on the powerful ARM Cortex-M core, the Gecko family features - innovative low energy techniques, short wake-up time from energy saving - modes and a wide selection of peripherals, making it ideal for battery - operated applications and other systems requiring high performance and - low-energy consumption. - - http://www.silabs.com/products/mcu/32-bit/efm32-gecko/Pages/efm32-gecko.aspx - """ - - PACKAGES = { - - "toolchain-gccarmnoneeabi": { - "alias": "toolchain", - "default": True - }, - - "framework-mbed": { - "alias": "framework" - } - } - - def get_name(self): - return "Silicon Labs EFM32" diff --git a/platformio/platforms/ststm32.py b/platformio/platforms/ststm32.py deleted file mode 100644 index 10203ec4..00000000 --- a/platformio/platforms/ststm32.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Ststm32Platform(BasePlatform): - - """ - The STM32 family of 32-bit Flash MCUs based on the ARM Cortex-M - processor is designed to offer new degrees of freedom to MCU users. - It offers a 32-bit product range that combines very high performance, - real-time capabilities, digital signal processing, and low-power, - low-voltage operation, while maintaining full integration and ease of - development. - - http://www.st.com/web/en/catalog/mmc/FM141/SC1169?sc=stm32 - """ - - PACKAGES = { - - "toolchain-gccarmnoneeabi": { - "alias": "toolchain", - "default": True - }, - - "ldscripts": { - "default": True - }, - - "tool-stlink": { - "alias": "uploader" - }, - - "framework-cmsis": { - "alias": "framework" - }, - - "framework-spl": { - "alias": "framework" - }, - - "framework-libopencm3": { - "alias": "framework" - }, - - "framework-mbed": { - "alias": "framework" - } - } - - def get_name(self): - return "ST STM32" - - def configure_default_packages(self, envoptions, targets): - if envoptions.get("framework") == "cmsis": - self.PACKAGES['framework-mbed']['default'] = True - - return BasePlatform.configure_default_packages( - self, envoptions, targets) diff --git a/platformio/platforms/teensy.py b/platformio/platforms/teensy.py deleted file mode 100644 index 45e62562..00000000 --- a/platformio/platforms/teensy.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform -from platformio.util import get_boards - - -class TeensyPlatform(BasePlatform): - - """ - Teensy is a complete USB-based microcontroller development system, in - a very small footprint, capable of implementing many types of projects. - All programming is done via the USB port. No special programmer is - needed, only a standard USB cable and a PC or Macintosh with a USB port. - - https://www.pjrc.com/teensy - """ - - PACKAGES = { - - "toolchain-atmelavr": { - }, - - "toolchain-gccarmnoneeabi": { - }, - - "ldscripts": { - "default": True - }, - - "framework-arduinoteensy": { - "alias": "framework" - }, - - "framework-mbed": { - "alias": "framework" - }, - - "tool-teensy": { - "alias": "uploader" - } - } - - def get_name(self): - return "Teensy" - - def configure_default_packages(self, envoptions, targets): - if envoptions.get("board"): - board = get_boards(envoptions.get("board")) - if board['build']['core'] == "teensy": - name = "toolchain-atmelavr" - else: - name = "toolchain-gccarmnoneeabi" - self.PACKAGES[name]['alias'] = "toolchain" - self.PACKAGES[name]['default'] = True - - return BasePlatform.configure_default_packages( - self, envoptions, targets) diff --git a/platformio/platforms/timsp430.py b/platformio/platforms/timsp430.py deleted file mode 100644 index e3ce6ee4..00000000 --- a/platformio/platforms/timsp430.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Timsp430Platform(BasePlatform): - - """ - MSP430 microcontrollers (MCUs) from Texas Instruments (TI) - are 16-bit, RISC-based, mixed-signal processors designed for ultra-low - power. These MCUs offer the lowest power consumption and the perfect - mix of integrated peripherals for thousands of applications. - - http://www.ti.com/lsds/ti/microcontrollers_16-bit_32-bit/msp/overview.page - """ - - PACKAGES = { - - "toolchain-timsp430": { - "alias": "toolchain", - "default": True - }, - - "tool-mspdebug": { - "alias": "uploader" - }, - - "framework-energiamsp430": { - "alias": "framework" - }, - - "framework-arduinomsp430": { - "alias": "framework" - } - } - - def get_name(self): - return "TI MSP430" diff --git a/platformio/platforms/titiva.py b/platformio/platforms/titiva.py deleted file mode 100644 index fbe4981e..00000000 --- a/platformio/platforms/titiva.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class TitivaPlatform(BasePlatform): - - """ - Texas Instruments TM4C12x MCUs offer the industrys most popular - ARM Cortex-M4 core with scalable memory and package options, unparalleled - connectivity peripherals, advanced application functions, industry-leading - analog integration, and extensive software solutions. - - http://www.ti.com/lsds/ti/microcontrollers_16-bit_32-bit/c2000_performance/control_automation/tm4c12x/overview.page - """ - - PACKAGES = { - - "toolchain-gccarmnoneeabi": { - "alias": "toolchain", - "default": True - }, - - "ldscripts": { - "default": True - }, - - "tool-lm4flash": { - "alias": "uploader" - }, - - "framework-energiativa": { - "alias": "framework" - }, - - "framework-libopencm3": { - "alias": "framework" - } - } - - def get_name(self): - return "TI TIVA" diff --git a/platformio/platforms/windows_x86.py b/platformio/platforms/windows_x86.py deleted file mode 100644 index bf52cc1c..00000000 --- a/platformio/platforms/windows_x86.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from platformio.platforms.base import BasePlatform - - -class Windows_x86Platform(BasePlatform): - - """ - Windows x86 (32-bit) is a metafamily of graphical operating systems - developed and marketed by Microsoft. - Using host OS (Windows, Linux 32/64 or Mac OS X) you can build native - application for Windows x86 platform. - - http://platformio.org/platforms/windows_x86 - """ - - PACKAGES = { - - "toolchain-gccmingw32": { - "alias": "toolchain", - "default": True - } - } diff --git a/platformio/projectconftpl.ini b/platformio/projectconftpl.ini index 0e9de3f9..fa77ae29 100644 --- a/platformio/projectconftpl.ini +++ b/platformio/projectconftpl.ini @@ -1,6 +1,8 @@ -# -# PlatformIO Project Configuration File -# -# Please make sure to read documentation with examples first -# http://docs.platformio.org/en/stable/projectconf.html -# \ No newline at end of file +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 48ca79ab..68a1e517 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ import platform import Queue import sys import threading -import uuid from collections import deque from os import getenv from time import sleep, time @@ -27,13 +26,10 @@ import click import requests from platformio import __version__, app, exception, util -from platformio.ide.projectgenerator import ProjectGenerator class TelemetryBase(object): - MACHINE_ID = str(uuid.uuid5(uuid.NAMESPACE_OID, str(uuid.getnode()))) - def __init__(self): self._params = {} @@ -47,20 +43,13 @@ class TelemetryBase(object): if name in self._params: del self._params[name] - def get_cid(self): - cid = app.get_state_item("cid") - if not cid: - cid = self.MACHINE_ID - app.set_state_item("cid", cid) - return cid - def send(self, hittype): raise NotImplementedError() class MeasurementProtocol(TelemetryBase): - TRACKING_ID = "UA-1768265-9" + TID = "UA-1768265-9" PARAMS_MAP = { "screen_name": "cd", "event_category": "ec", @@ -72,8 +61,8 @@ class MeasurementProtocol(TelemetryBase): def __init__(self): TelemetryBase.__init__(self) self['v'] = 1 - self['tid'] = self.TRACKING_ID - self['cid'] = self.get_cid() + self['tid'] = self.TID + self['cid'] = app.get_cid() self['sr'] = "%dx%d" % click.get_terminal_size() self._prefill_screen_name() @@ -106,8 +95,9 @@ class MeasurementProtocol(TelemetryBase): self['cd1'] = util.get_systype() self['cd2'] = "Python/%s %s" % (platform.python_version(), platform.platform()) - self['cd4'] = (1 if app.get_setting("enable_prompts") or - app.get_session_var("caller_id") else 0) + self['cd4'] = 1 if not util.is_ci() else 0 + if app.get_session_var("caller_id"): + self['cd5'] = str(app.get_session_var("caller_id")).lower() def _prefill_screen_name(self): self['cd3'] = " ".join([str(s).lower() for s in sys.argv[1:]]) @@ -118,7 +108,7 @@ class MeasurementProtocol(TelemetryBase): args = [str(s).lower() for s in ctx_args if not str(s).startswith("-")] if not args: return - if args[0] in ("lib", "platforms", "serialports", "settings"): + if args[0] in ("lib", "platform", "serialports", "settings"): cmd_path = args[:2] else: cmd_path = args[:1] @@ -210,8 +200,7 @@ class MPDataPusher(object): "https://ssl.google-analytics.com/collect", data=data, headers=util.get_request_defheaders(), - timeout=1 - ) + timeout=1) r.raise_for_status() return True except: # pylint: disable=W0702 @@ -228,16 +217,9 @@ def on_command(): if util.is_ci(): measure_ci() - if app.get_session_var("caller_id"): - measure_caller(app.get_session_var("caller_id")) - def measure_ci(): - event = { - "category": "CI", - "action": "NoName", - "label": None - } + event = {"category": "CI", "action": "NoName", "label": None} envmap = { "APPVEYOR": {"label": getenv("APPVEYOR_REPO_NAME")}, @@ -256,18 +238,6 @@ def measure_ci(): on_event(**event) -def measure_caller(calller_id): - calller_id = str(calller_id)[:20].lower() - event = { - "category": "Caller", - "action": "Misc", - "label": calller_id - } - if calller_id in (["atom", "vim"] + ProjectGenerator.get_supported_ides()): - event['action'] = "IDE" - on_event(**event) - - def on_run_environment(options, targets): opts = ["%s=%s" % (opt, value) for opt, value in sorted(options.items())] targets = [t.title() for t in targets or ["run"]] @@ -288,7 +258,9 @@ def on_event(category, action, label=None, value=None, screen_name=None): def on_exception(e): - if isinstance(e, exception.AbortedByUser): + if any([isinstance(e, cls) + for cls in (IOError, exception.AbortedByUser, + exception.NotGlobalLibDir)]): return is_crash = any([ not isinstance(e, exception.PlatformioException), diff --git a/platformio/unpacker.py b/platformio/unpacker.py index ab8955cd..67ca78a7 100644 --- a/platformio/unpacker.py +++ b/platformio/unpacker.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -64,8 +64,7 @@ class ZIPArchive(ArchiveBase): def preserve_mtime(item, dest_dir): util.change_filemtime( join(dest_dir, item.filename), - mktime(list(item.date_time) + [0] * 3) - ) + mktime(list(item.date_time) + [0] * 3)) def get_items(self): return self._afo.infolist() @@ -97,8 +96,8 @@ class FileUnpacker(object): for item in self._unpacker.get_items(): self._unpacker.extract_item(item, self._dest_dir) else: - with click.progressbar(self._unpacker.get_items(), - label="Unpacking") as pb: + items = self._unpacker.get_items() + with click.progressbar(items, label="Unpacking") as pb: for item in pb: self._unpacker.extract_item(item, self._dest_dir) return True diff --git a/platformio/util.py b/platformio/util.py index f5e96b20..faf6a6bf 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,15 +17,21 @@ import functools import json import os import re +import stat import subprocess import sys from glob import glob from os.path import (abspath, basename, dirname, expanduser, isdir, isfile, - join, splitdrive) + join, normpath, splitdrive) from platform import system, uname +from shutil import rmtree from threading import Thread +from time import sleep -from platformio import __apiip__, __apiurl__, __version__, exception +import click +import requests + +from platformio import __apiurl__, __version__, exception # pylint: disable=wrong-import-order try: @@ -81,7 +87,6 @@ class cd(object): class memoized(object): - ''' Decorator. Caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned @@ -122,6 +127,7 @@ def singleton(cls): if cls not in _instances: _instances[cls] = cls(*args, **kwargs) return _instances[cls] + return get_instance @@ -149,23 +155,21 @@ def _get_projconf_option_dir(name, default=None): return os.getenv(_env_name) try: - config = get_project_config() + config = load_project_config() if (config.has_section("platformio") and config.has_option("platformio", name)): option_dir = config.get("platformio", name) if option_dir.startswith("~"): option_dir = expanduser(option_dir) return abspath(option_dir) - except exception.NotPlatformProject: + except exception.NotPlatformIOProject: pass return default def get_home_dir(): - home_dir = _get_projconf_option_dir( - "home_dir", - join(expanduser("~"), ".platformio") - ) + home_dir = _get_projconf_option_dir("home_dir", + join(expanduser("~"), ".platformio")) if "windows" in get_systype(): try: @@ -180,13 +184,6 @@ def get_home_dir(): return home_dir -def get_lib_dir(): - return _get_projconf_option_dir( - "lib_dir", - join(get_home_dir(), "lib") - ) - - def get_source_dir(): curpath = abspath(__file__) if not isfile(curpath): @@ -201,48 +198,71 @@ def get_project_dir(): return os.getcwd() -def get_projectsrc_dir(): - return _get_projconf_option_dir( - "src_dir", - join(get_project_dir(), "src") - ) +def find_project_dir_above(path): + if isfile(path): + path = dirname(path) + if is_platformio_project(path): + return path + if isdir(dirname(path)): + return find_project_dir_above(dirname(path)) + return None + + +def is_platformio_project(project_dir=None): + if not project_dir: + project_dir = get_project_dir() + return isfile(join(project_dir, "platformio.ini")) def get_projectlib_dir(): - return join(get_project_dir(), "lib") + return _get_projconf_option_dir("lib_dir", join(get_project_dir(), "lib")) -def get_pioenvs_dir(): - path = _get_projconf_option_dir( - "envs_dir", - join(get_project_dir(), ".pioenvs") - ) - if not isdir(path): - os.makedirs(path) - dontmod_path = join(path, "do-not-modify-files-here.url") - if not isfile(dontmod_path): - with open(dontmod_path, "w") as fp: - fp.write(""" +def get_projectlibdeps_dir(): + return _get_projconf_option_dir("libdeps_dir", + join(get_project_dir(), ".piolibdeps")) + + +def get_projectsrc_dir(): + return _get_projconf_option_dir("src_dir", join(get_project_dir(), "src")) + + +def get_projecttest_dir(): + return _get_projconf_option_dir("test_dir", join(get_project_dir(), + "test")) + + +def get_projectpioenvs_dir(force=False): + path = _get_projconf_option_dir("envs_dir", + join(get_project_dir(), ".pioenvs")) + try: + if not isdir(path): + os.makedirs(path) + dontmod_path = join(path, "do-not-modify-files-here.url") + if not isfile(dontmod_path): + with open(dontmod_path, "w") as fp: + fp.write(""" [InternetShortcut] URL=http://docs.platformio.org/en/stable/projectconf.html#envs-dir """) + except Exception as e: # pylint: disable=broad-except + if not force: + raise Exception(e) return path def get_projectdata_dir(): - return _get_projconf_option_dir( - "data_dir", - join(get_project_dir(), "data") - ) + return _get_projconf_option_dir("data_dir", + join(get_project_dir(), "data")) -def get_project_config(ini_path=None): - if not ini_path: - ini_path = join(get_project_dir(), "platformio.ini") - if not isfile(ini_path): - raise exception.NotPlatformProject(get_project_dir()) +def load_project_config(project_dir=None): + if not project_dir: + project_dir = get_project_dir() + if not is_platformio_project(project_dir): + raise exception.NotPlatformIOProject(project_dir) cp = ConfigParser() - cp.read(ini_path) + cp.read(join(project_dir, "platformio.ini")) return cp @@ -255,17 +275,9 @@ def is_ci(): def exec_command(*args, **kwargs): - result = { - "out": None, - "err": None, - "returncode": None - } + result = {"out": None, "err": None, "returncode": None} - default = dict( - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=system() == "Windows" - ) + default = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE) default.update(kwargs) kwargs = default @@ -291,6 +303,16 @@ def exec_command(*args, **kwargs): return result +def copy_pythonpath_to_osenv(): + _PYTHONPATH = [] + if "PYTHONPATH" in os.environ: + _PYTHONPATH = os.environ.get("PYTHONPATH").split(os.pathsep) + for p in os.sys.path: + if p not in _PYTHONPATH: + _PYTHONPATH.append(p) + os.environ['PYTHONPATH'] = os.pathsep.join(_PYTHONPATH) + + def get_serialports(): try: from serial.tools.list_ports import comports @@ -339,116 +361,76 @@ def get_logicaldisks(): def get_request_defheaders(): - import requests - return {"User-Agent": "PlatformIO/%s CI/%d %s" % ( - __version__, int(is_ci()), requests.utils.default_user_agent() - )} + data = (__version__, int(is_ci()), requests.utils.default_user_agent()) + return {"User-Agent": "PlatformIO/%s CI/%d %s" % data} -def get_api_result(path, params=None, data=None, skipdns=False): - import requests +@memoized +def _api_request_session(): + return requests.Session() + + +def _get_api_result( + path, # pylint: disable=too-many-branches + params=None, + data=None): + from platformio.app import get_setting + result = None r = None headers = get_request_defheaders() url = __apiurl__ - if skipdns: - url = "http://%s" % __apiip__ - headers['host'] = __apiurl__[__apiurl__.index("://")+3:] + + if get_setting("disable_ssl"): + url = url.replace("https://", "http://") try: if data: - r = requests.post( + r = _api_request_session().post( url + path, params=params, data=data, headers=headers) else: - r = requests.get(url + path, params=params, headers=headers) - r.raise_for_status() + r = _api_request_session().get(url + path, + params=params, + headers=headers) result = r.json() + r.raise_for_status() except requests.exceptions.HTTPError as e: if result and "errors" in result: raise exception.APIRequestError(result['errors'][0]['title']) else: raise exception.APIRequestError(e) - except (requests.exceptions.ConnectionError, - requests.exceptions.ConnectTimeout, - requests.exceptions.ReadTimeout): - if not skipdns: - return get_api_result(path, params, data, skipdns=True) - raise exception.APIRequestError( - "Could not connect to PlatformIO Registry Service. " - "Please try later.") except ValueError: - raise exception.APIRequestError( - "Invalid response: %s" % r.text.encode("utf-8")) + raise exception.APIRequestError("Invalid response: %s" % + r.text.encode("utf-8")) finally: if r: r.close() return result -@memoized -def _lookup_boards(): - boards = {} - bdirs = [join(get_source_dir(), "boards")] - if isdir(join(get_home_dir(), "boards")): - bdirs.append(join(get_home_dir(), "boards")) +def get_api_result(path, params=None, data=None): + max_retries = 5 + total = 0 + while total < max_retries: + try: + return _get_api_result(path, params, data) + except (requests.exceptions.ConnectionError, + requests.exceptions.Timeout) as e: + total += 1 + click.secho( + "[API] ConnectionError: {0} (incremented retry: max={1}, " + "total={2})".format(e, max_retries, total), + fg="yellow") + sleep(2 * total) - for bdir in bdirs: - for json_file in sorted(os.listdir(bdir)): - if not json_file.endswith(".json"): - continue - boards.update(load_json(join(bdir, json_file))) - return boards + raise exception.APIRequestError( + "Could not connect to PlatformIO Registry Service. " + "Please try later.") -def get_boards(type_=None): - boards = _lookup_boards() - - if type_ is None: - return boards - else: - if type_ not in boards: - raise exception.UnknownBoard(type_) - return boards[type_] - - -@memoized -def _lookup_frameworks(): - frameworks = {} - frameworks_path = join( - get_source_dir(), "builder", "scripts", "frameworks") - - frameworks_list = [f[:-3] for f in os.listdir(frameworks_path) - if not f.startswith("__") and f.endswith(".py")] - for _type in frameworks_list: - script_path = join(frameworks_path, "%s.py" % _type) - with open(script_path) as f: - fcontent = f.read() - assert '"""' in fcontent - _doc_start = fcontent.index('"""') + 3 - fdoc = fcontent[ - _doc_start:fcontent.index('"""', _doc_start)].strip() - doclines = [l.strip() for l in fdoc.splitlines() if l.strip()] - frameworks[_type] = { - "name": doclines[0], - "description": " ".join(doclines[1:-1]), - "url": doclines[-1], - "script": script_path - } - return frameworks - - -def get_frameworks(type_=None): - frameworks = _lookup_frameworks() - - if type_ is None: - return frameworks - else: - if type_ not in frameworks: - raise exception.UnknownFramework(type_) - return frameworks[type_] - - return frameworks +def get_pythonexe_path(): + return os.environ.get("PYTHONEXEPATH", normpath(sys.executable)) def where_is_program(program, envpath=None): @@ -460,8 +442,7 @@ def where_is_program(program, envpath=None): try: result = exec_command( ["where" if "windows" in get_systype() else "which", program], - env=env - ) + env=env) if result['returncode'] == 0 and isfile(result['out'].strip()): return result['out'].strip() except OSError: @@ -475,3 +456,16 @@ def where_is_program(program, envpath=None): return join(bin_dir, "%s.exe" % program) return program + + +def pepver_to_semver(pepver): + return re.sub(r"(\.\d+)\.?(dev|a|b|rc|post)", r"\1-\2", pepver, 1) + + +def rmtree_(path): + + def _onerror(_, name, __): + os.chmod(name, stat.S_IWRITE) + os.remove(name) + + return rmtree(path, onerror=_onerror) diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py new file mode 100644 index 00000000..a509302b --- /dev/null +++ b/platformio/vcsclient.py @@ -0,0 +1,186 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re +from os.path import join +from subprocess import check_call +from sys import modules +from urlparse import urlparse + +from platformio import util +from platformio.exception import PlatformioException + + +class VCSClientFactory(object): + + @staticmethod + def newClient(src_dir, remote_url): + result = urlparse(remote_url) + type_ = result.scheme + if not type_ and remote_url.startswith("git@"): + type_ = "git" + elif "+" in result.scheme: + type_, _ = result.scheme.split("+", 1) + remote_url = remote_url[len(type_) + 1:] + if result.fragment: + remote_url = remote_url.rsplit("#", 1)[0] + if not type_: + raise PlatformioException("VCS: Unknown repository type %s" % + remote_url) + obj = getattr(modules[__name__], "%sClient" % type_.title())( + src_dir, remote_url, result.fragment) + assert isinstance(obj, VCSClientBase) + return obj + + +class VCSClientBase(object): + + command = None + + def __init__(self, src_dir, remote_url=None, tag=None): + self.src_dir = src_dir + self.remote_url = remote_url + self.tag = tag + self.check_client() + + def check_client(self): + try: + assert self.command + assert self.run_cmd(["--version"]) + except (AssertionError, OSError): + raise PlatformioException( + "VCS: `%s` client is not installed in your system" % + self.command) + return True + + @property + def storage_dir(self): + return join(self.src_dir, "." + self.command) + + def export(self): + raise NotImplementedError + + def update(self): + raise NotImplementedError + + @property + def can_be_updated(self): + return not self.tag + + def get_current_revision(self): + raise NotImplementedError + + def run_cmd(self, args, **kwargs): + args = [self.command] + args + if "cwd" not in kwargs: + kwargs['cwd'] = self.src_dir + return check_call(args, **kwargs) == 0 + + def get_cmd_output(self, args, **kwargs): + args = [self.command] + args + if "cwd" not in kwargs: + kwargs['cwd'] = self.src_dir + result = util.exec_command(args, **kwargs) + if result['returncode'] == 0: + return result['out'].strip() + raise PlatformioException( + "VCS: Could not receive an output from `%s` command (%s)" % ( + args, result)) + + +class GitClient(VCSClientBase): + + command = "git" + + def get_branches(self): + output = self.get_cmd_output(["branch"]) + output = output.replace("*", "") # fix active branch + return [b.strip() for b in output.split("\n")] + + def get_tags(self): + output = self.get_cmd_output(["tag", "-l"]) + return [t.strip() for t in output.split("\n")] + + @staticmethod + def is_commit_id(text): + return text and re.match(r"[0-9a-f]{7,}$", text) is not None + + @property + def can_be_updated(self): + return not self.tag or not self.is_commit_id(self.tag) + + def export(self): + is_commit = self.is_commit_id(self.tag) + args = ["clone", "--recursive"] + if not self.tag or not is_commit: + args += ["--depth", "1"] + if self.tag: + args += ["--branch", self.tag] + args += [self.remote_url, self.src_dir] + assert self.run_cmd(args) + if is_commit: + return self.run_cmd(["reset", "--hard", self.tag]) + return True + + def update(self): + args = ["pull"] + return self.run_cmd(args) + + def get_current_revision(self): + return self.get_cmd_output(["rev-parse", "--short", "HEAD"]) + + +class HgClient(VCSClientBase): + + command = "hg" + + def export(self): + args = ["clone"] + if self.tag: + args.extend(["--updaterev", self.tag]) + args.extend([self.remote_url, self.src_dir]) + return self.run_cmd(args) + + def update(self): + args = ["pull", "--update"] + return self.run_cmd(args) + + def get_current_revision(self): + return self.get_cmd_output(["identify", "--id"]) + + +class SvnClient(VCSClientBase): + + command = "svn" + + def export(self): + args = ["checkout"] + if self.tag: + args.extend(["--revision", self.tag]) + args.extend([self.remote_url, self.src_dir]) + return self.run_cmd(args) + + def update(self): + + args = ["update"] + return self.run_cmd(args) + + def get_current_revision(self): + output = self.get_cmd_output(["info", "--non-interactive", + "--trust-server-cert", "-r", "HEAD"]) + for line in output.split("\n"): + line = line.strip() + if line.startswith("Revision:"): + return line.split(":", 1)[1].strip() + raise PlatformioException("Could not detect current SVN revision") diff --git a/scripts/99-platformio-udev.rules b/scripts/99-platformio-udev.rules index ac52af74..3156ef0e 100644 --- a/scripts/99-platformio-udev.rules +++ b/scripts/99-platformio-udev.rules @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/docspregen.py b/scripts/docspregen.py index 90fb3455..f977c49a 100644 --- a/scripts/docspregen.py +++ b/scripts/docspregen.py @@ -1,4 +1,4 @@ -# Copyright 2014-present Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,12 +20,17 @@ from sys import path path.append("..") from platformio import util -from platformio.platforms.base import PlatformFactory, get_packages +from platformio.managers.platform import PlatformFactory, PlatformManager + +API_PACKAGES = util.get_api_result("/packages") +API_FRAMEWORKS = util.get_api_result("/frameworks") +BOARDS = PlatformManager().get_installed_boards() +PLATFORM_MANIFESTS = PlatformManager().get_installed() def is_compat_platform_and_framework(platform, framework): p = PlatformFactory.newPlatform(platform) - for pkg in p.get_packages().keys(): + for pkg in p.packages.keys(): if pkg.startswith("framework-%s" % framework): return True return False @@ -56,34 +61,29 @@ def generate_boards(boards): - Flash - RAM""") - for board in sorted(boards): - for type_, data in board.iteritems(): - assert type_ in util.get_boards() - board_ram = float(data['upload']['maximum_ram_size']) / 1024 - lines.append(""" - * - ``{type}`` + for data in sorted(boards, key=lambda item: item['id']): + board_ram = float(data['ram']) / 1024 + lines.append(""" + * - ``{id}`` - `{name} <{url}>`_ - {mcu} - {f_cpu:d} MHz - {rom} Kb - {ram} Kb""".format( - type=type_, - name=data['name'], - url=data['url'], - mcu=data['build']['mcu'].upper(), - f_cpu=int((data['build']['f_cpu'][:-1])) / 1000000, - ram=int(board_ram) if board_ram % 1 == 0 else board_ram, - rom=_round_memory_size( - data['upload']['maximum_size'] / 1024) - )) + id=data['id'], + name=data['name'], + url=data['url'], + mcu=data['mcu'].upper(), + f_cpu=int(data['fcpu']) / 1000000, + ram=int(board_ram) if board_ram % 1 == 0 else board_ram, + rom=_round_memory_size(data['rom'] / 1024))) return "\n".join(lines + [""]) -def generate_packages(platform, packages, is_embedded): - if not packages: +def generate_packages(platform, packagenames, is_embedded): + if not packagenames: return - allpackages = get_packages() lines = [] lines.append(""" Packages @@ -94,17 +94,15 @@ Packages * - Name - Contents""") - for type_, data in packages.iteritems(): - assert type_ in allpackages + for name in sorted(packagenames): + assert name in API_PACKAGES contitems = [ - "`%s <%s>`_" % (name, url) - for name, url in allpackages[type_] + "`{name} <{url}>`_".format(**item) for item in API_PACKAGES[name] ] lines.append(""" - * - ``{type_}`` + * - ``{name}`` - {contents}""".format( - type_=type_, - contents=", ".join(contitems))) + name=name, contents=", ".join(contitems))) if is_embedded: lines.append(""" @@ -134,7 +132,8 @@ def generate_platform(name): print "Processing platform: %s" % name lines = [] - lines.append(""".. Copyright 2014-present Ivan Kravets + lines.append( + """.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -154,33 +153,31 @@ def generate_platform(name): lines.append("=" * len(_title)) p = PlatformFactory.newPlatform(name) - lines.append(p.get_description()) + lines.append(p.description) lines.append(""" For more detailed information please visit `vendor site <%s>`_.""" % - p.get_vendor_url()) + p.vendor_url) lines.append(""" .. contents::""") # # Packages # - _packages_content = generate_packages(name, p.get_packages(), p.is_embedded()) + _packages_content = generate_packages(name, p.packages.keys(), + p.is_embedded()) if _packages_content: lines.append(_packages_content) # # Frameworks # - _frameworks = util.get_frameworks() _frameworks_lines = [] - for framework in sorted(_frameworks.keys()): - if not is_compat_platform_and_framework(name, framework): + for framework in API_FRAMEWORKS: + if not is_compat_platform_and_framework(name, framework['name']): continue _frameworks_lines.append(""" - * - :ref:`framework_{type_}` - - {description}""".format( - type_=framework, - description=_frameworks[framework]['description'])) + * - :ref:`framework_{name}` + - {description}""".format(**framework)) if _frameworks_lines: lines.append(""" @@ -197,14 +194,13 @@ Frameworks # Boards # vendors = {} - for board, data in util.get_boards().items(): - platform = data['platform'] - vendor = data['vendor'] - if name in platform: + for board in BOARDS: + vendor = board['vendor'] + if name in board['platform']: if vendor in vendors: - vendors[vendor].append({board: data}) + vendors[vendor].append(board) else: - vendors[vendor] = [{board: data}] + vendors[vendor] = [board] if vendors: lines.append(""" @@ -227,9 +223,10 @@ Boards def update_platform_docs(): - for name in PlatformFactory.get_platforms().keys(): - platforms_dir = join(dirname(realpath(__file__)), - "..", "docs", "platforms") + for manifest in PLATFORM_MANIFESTS: + name = manifest['name'] + platforms_dir = join( + dirname(realpath(__file__)), "..", "docs", "platforms") rst_path = join(platforms_dir, "%s.rst" % name) with open(rst_path, "w") as f: f.write(generate_platform(name)) @@ -241,7 +238,8 @@ def generate_framework(type_, data): print "Processing framework: %s" % type_ lines = [] - lines.append(""".. Copyright 2014-present Ivan Kravets + lines.append( + """.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -276,16 +274,15 @@ Platforms - Description""") _found_platform = False - for platform in sorted(PlatformFactory.get_platforms().keys()): - if not is_compat_platform_and_framework(platform, type_): + for manifest in PLATFORM_MANIFESTS: + if not is_compat_platform_and_framework(manifest['name'], type_): continue _found_platform = True - p = PlatformFactory.newPlatform(platform) + p = PlatformFactory.newPlatform(manifest['name']) lines.append(""" * - :ref:`platform_{type_}` - {description}""".format( - type_=platform, - description=p.get_description())) + type_=manifest['name'], description=p.description)) if not _found_platform: del lines[-1] @@ -300,14 +297,14 @@ Boards """) vendors = {} - for board, data in util.get_boards().items(): + for data in BOARDS: frameworks = data['frameworks'] vendor = data['vendor'] if type_ in frameworks: if vendor in vendors: - vendors[vendor].append({board: data}) + vendors[vendor].append(data) else: - vendors[vendor] = [{board: data}] + vendors[vendor] = [data] for vendor, boards in sorted(vendors.iteritems()): lines.append(str(vendor)) lines.append("~" * len(vendor)) @@ -316,18 +313,18 @@ Boards def update_framework_docs(): - for name, data in util.get_frameworks().items(): - frameworks_dir = join(dirname(realpath(__file__)), - "..", "docs", "frameworks") + for framework in API_FRAMEWORKS: + name = framework['name'] + frameworks_dir = join( + dirname(realpath(__file__)), "..", "docs", "frameworks") rst_path = join(frameworks_dir, "%s.rst" % name) with open(rst_path, "w") as f: - f.write(generate_framework(name, data)) + f.write(generate_framework(name, framework)) if isfile(join(frameworks_dir, "%s_extra.rst" % name)): f.write("\n.. include:: %s_extra.rst\n" % name) def update_create_platform_doc(): - allpackages = get_packages() lines = [] lines.append(""".. _platform_creating_packages: @@ -342,32 +339,28 @@ Packages * - Name - Contents""") - for type_, data in sorted(allpackages.iteritems()): - contitems = [ - "`%s <%s>`_" % (name, url) - for name, url in allpackages[type_] - ] + for name, items in sorted(API_PACKAGES.iteritems()): + contitems = ["`{name} <{url}>`_".format(**item) for item in items] lines.append(""" - * - ``{type_}`` + * - ``{name}`` - {contents}""".format( - type_=type_, - contents=", ".join(contitems))) + name=name, contents=", ".join(contitems))) - with open(join(util.get_source_dir(), "..", "docs", "platforms", - "creating_platform.rst"), "r+") as fp: + with open( + join(util.get_source_dir(), "..", "docs", "platforms", + "creating_platform.rst"), "r+") as fp: content = fp.read() fp.seek(0, 0) - fp.write( - content[:content.index(".. _platform_creating_packages:")] + - "\n".join(lines) + "\n\n" + - content[content.index(".. _platform_creating_manifest_file:"):] - ) + fp.write(content[:content.index(".. _platform_creating_packages:")] + + "\n".join(lines) + "\n\n" + content[content.index( + ".. _platform_creating_manifest_file:"):]) def update_embedded_boards(): lines = [] - lines.append(""".. Copyright 2014-present Ivan Kravets + lines.append( + """.. Copyright 2014-present PlatformIO Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -400,20 +393,21 @@ popular embedded boards and IDE. lines.append("") vendors = {} - for board, data in util.get_boards().items(): + for data in BOARDS: vendor = data['vendor'] if vendor in vendors: - vendors[vendor].append({board: data}) + vendors[vendor].append(data) else: - vendors[vendor] = [{board: data}] + vendors[vendor] = [data] for vendor, boards in sorted(vendors.iteritems()): lines.append(str(vendor)) lines.append("~" * len(vendor)) lines.append(generate_boards(boards)) - emboards_rst = join(dirname(realpath(__file__)), - "..", "docs", "platforms", "embedded_boards.rst") + emboards_rst = join( + dirname(realpath(__file__)), "..", "docs", "platforms", + "embedded_boards.rst") with open(emboards_rst, "w") as f: f.write("\n".join(lines)) @@ -424,5 +418,6 @@ def main(): update_framework_docs() update_embedded_boards() + if __name__ == "__main__": sys_exit(main()) diff --git a/scripts/fixsymlink.py b/scripts/fixsymlink.py index d7d97f37..44a628fd 100644 --- a/scripts/fixsymlink.py +++ b/scripts/fixsymlink.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index 75453e56..c67debfe 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/mbed_to_package.py b/scripts/mbed_to_package.py deleted file mode 100644 index fcf5581c..00000000 --- a/scripts/mbed_to_package.py +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import argparse -import zipfile -from os import getcwd, listdir, makedirs, mkdir, rename -from os.path import isdir, isfile, join -from shutil import move, rmtree -from sys import exit as sys_exit -from sys import path - -path.append("..") - -from platformio.util import exec_command, get_home_dir - - -def _unzip_generated_file(mbed_dir, output_dir, mcu): - filename = join( - mbed_dir, "build", "export", "MBED_A1_emblocks_%s.zip" % mcu) - variant_dir = join(output_dir, "variant", mcu) - if isfile(filename): - with zipfile.ZipFile(filename) as zfile: - mkdir(variant_dir) - zfile.extractall(variant_dir) - for f in listdir(join(variant_dir, "MBED_A1")): - if not f.lower().startswith("mbed"): - continue - move(join(variant_dir, "MBED_A1", f), variant_dir) - rename(join(variant_dir, "MBED_A1.eix"), - join(variant_dir, "%s.eix" % mcu)) - rmtree(join(variant_dir, "MBED_A1")) - else: - print "Warning! Skipped board: %s" % mcu - - -def buildlib(mbed_dir, mcu, lib="mbed"): - build_command = [ - "python", - join(mbed_dir, "workspace_tools", "build.py"), - "--mcu", mcu, - "-t", "GCC_ARM" - ] - if lib is not "mbed": - build_command.append(lib) - build_result = exec_command(build_command, cwd=getcwd()) - if build_result['returncode'] != 0: - print "* %s doesn't support %s library!" % (mcu, lib) - - -def copylibs(mbed_dir, output_dir): - libs = ["dsp", "fat", "net", "rtos", "usb", "usb_host"] - libs_dir = join(output_dir, "libs") - makedirs(libs_dir) - - print "Moving generated libraries to framework dir..." - for lib in libs: - if lib == "net": - move(join(mbed_dir, "build", lib, "eth"), libs_dir) - continue - move(join(mbed_dir, "build", lib), libs_dir) - - -def main(mbed_dir, output_dir): - print "Starting..." - - path.append(mbed_dir) - from workspace_tools.export import gccarm - - if isdir(output_dir): - print "Deleting previous framework dir..." - rmtree(output_dir) - - settings_file = join(mbed_dir, "workspace_tools", "private_settings.py") - if not isfile(settings_file): - with open(settings_file, "w") as f: - f.write("GCC_ARM_PATH = '%s'" % - join(get_home_dir(), "packages", "toolchain-gccarmnoneeabi", - "bin")) - - makedirs(join(output_dir, "variant")) - mbed_libs = ["--rtos", "--dsp", "--fat", "--eth", "--usb", "--usb_host"] - - for mcu in set(gccarm.GccArm.TARGETS): - print "Processing board: %s" % mcu - buildlib(mbed_dir, mcu) - for lib in mbed_libs: - buildlib(mbed_dir, mcu, lib) - result = exec_command( - ["python", join(mbed_dir, "workspace_tools", "project.py"), - "--mcu", mcu, "-i", "emblocks", "-p", "0", "-b"], cwd=getcwd() - ) - if result['returncode'] != 0: - print "Unable to build the project for %s" % mcu - continue - _unzip_generated_file(mbed_dir, output_dir, mcu) - copylibs(mbed_dir, output_dir) - - with open(join(output_dir, "boards.txt"), "w") as fp: - fp.write("\n".join(sorted(listdir(join(output_dir, "variant"))))) - - print "Complete!" - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument('--mbed', help="The path to mbed framework") - parser.add_argument('--output', help="The path to output directory") - args = vars(parser.parse_args()) - sys_exit(main(args["mbed"], args["output"])) diff --git a/setup.py b/setup.py index 83d9acb9..29a759d9 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys - from setuptools import find_packages, setup from platformio import (__author__, __description__, __email__, __license__, @@ -21,16 +19,14 @@ from platformio import (__author__, __description__, __email__, __license__, install_requires = [ "bottle<0.13", - "click>=3.2,<6", + "click>=5,<6", "lockfile>=0.9.1,<0.13", "requests>=2.4.0,<3", + "semantic_version>=2.5.0", "colorama", "pyserial<4" ] -if sys.version_info < (2, 7, 0): - install_requires[-1] = "pyserial<3" - setup( name=__title__, version=__version__, @@ -45,7 +41,6 @@ setup( package_data={ "platformio": [ "projectconftpl.ini", - "boards/*.json", "ide/tpls/*/.*.tpl", "ide/tpls/*/*.tpl", "ide/tpls/*/*/*.tpl", diff --git a/tests/commands/test_boards.py b/tests/commands/test_boards.py index f137096c..6b216146 100644 --- a/tests/commands/test_boards.py +++ b/tests/commands/test_boards.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,38 +14,40 @@ import json -from platformio import util from platformio.commands.boards import cli as cmd_boards -from platformio.commands.platforms import \ - platforms_search as cmd_platforms_search +from platformio.commands.platform import platform_search as cmd_platform_search -def test_board_json_output(platformio_setup, clirunner, validate_cliresult): - result = clirunner.invoke(cmd_boards, ["cortex", "--json-output"]) +def test_board_json_output(clirunner, validate_cliresult): + result = clirunner.invoke(cmd_boards, ["mbed", "--json-output"]) validate_cliresult(result) boards = json.loads(result.output) - assert isinstance(boards, dict) - assert "teensy30" in boards + assert isinstance(boards, list) + assert any(["mbed" in b['frameworks'] for b in boards]) -def test_board_raw_output(platformio_setup, clirunner, validate_cliresult): +def test_board_raw_output(clirunner, validate_cliresult): result = clirunner.invoke(cmd_boards, ["energia"]) validate_cliresult(result) assert "titiva" in result.output -def test_board_options(platformio_setup, clirunner, validate_cliresult): +def test_board_options(clirunner, validate_cliresult): required_opts = set( - ["build", "platform", "upload", "name"]) + ["fcpu", "frameworks", "id", "mcu", "name", "platform"]) # fetch available platforms - result = clirunner.invoke(cmd_platforms_search, ["--json-output"]) + result = clirunner.invoke(cmd_platform_search, ["--json-output"]) validate_cliresult(result) search_result = json.loads(result.output) assert isinstance(search_result, list) assert len(search_result) - platforms = [item['type'] for item in search_result] + platforms = [item['name'] for item in search_result] - for _, opts in util.get_boards().iteritems(): - assert required_opts.issubset(set(opts)) - assert opts['platform'] in platforms + result = clirunner.invoke(cmd_boards, ["mbed", "--json-output"]) + validate_cliresult(result) + boards = json.loads(result.output) + + for board in boards: + assert required_opts.issubset(set(board)) + assert board['platform'] in platforms diff --git a/tests/commands/test_ci.py b/tests/commands/test_ci.py new file mode 100644 index 00000000..884e9b50 --- /dev/null +++ b/tests/commands/test_ci.py @@ -0,0 +1,53 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from os.path import join + +from platformio.commands.ci import cli as cmd_ci + + +def test_ci_empty(clirunner): + result = clirunner.invoke(cmd_ci) + assert result.exit_code == 2 + assert "Invalid value: Missing argument 'src'" in result.output + + +def test_ci_boards(clirunner, validate_cliresult): + result = clirunner.invoke(cmd_ci, [ + join("examples", "atmelavr-and-arduino", "arduino-internal-libs", + "src", "ChatServer.ino"), "-b", "uno", "-b", "leonardo" + ]) + validate_cliresult(result) + + +def test_ci_project_conf(clirunner, validate_cliresult): + project_dir = join("examples", "atmelavr-and-arduino", + "arduino-internal-libs") + result = clirunner.invoke(cmd_ci, [ + join(project_dir, "src", "ChatServer.ino"), "--project-conf", + join(project_dir, "platformio.ini") + ]) + validate_cliresult(result) + assert all([s in result.output for s in ("ethernet", "leonardo", "yun")]) + + +def test_ci_lib_and_board(clirunner, validate_cliresult): + example_dir = join("examples", "atmelavr-and-arduino", + "arduino-external-libs") + result = clirunner.invoke(cmd_ci, [ + join(example_dir, "lib", "OneWire", "examples", "DS2408_Switch", + "DS2408_Switch.pde"), "-l", join(example_dir, "lib", "OneWire"), + "-b", "uno" + ]) + validate_cliresult(result) diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index 5e136f47..5f08c336 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os import makedirs, getcwd +import json +from os import getcwd, makedirs from os.path import getsize, isdir, isfile, join -from platformio.commands.init import cli -from platformio import util +from platformio import exception, util +from platformio.commands.boards import cli as cmd_boards +from platformio.commands.init import cli as cmd_init def validate_pioproject(pioproject_dir): @@ -26,70 +28,112 @@ def validate_pioproject(pioproject_dir): join(pioproject_dir, "lib")) -def test_init_default(platformio_setup, clirunner, validate_cliresult): +def test_init_default(clirunner, validate_cliresult): with clirunner.isolated_filesystem(): - result = clirunner.invoke(cli) + result = clirunner.invoke(cmd_init) validate_cliresult(result) validate_pioproject(getcwd()) -def test_init_ext_folder(platformio_setup, clirunner, validate_cliresult): +def test_init_ext_folder(clirunner, validate_cliresult): with clirunner.isolated_filesystem(): ext_folder_name = "ext_folder" makedirs(ext_folder_name) - result = clirunner.invoke(cli, ["-d", ext_folder_name]) + result = clirunner.invoke(cmd_init, ["-d", ext_folder_name]) validate_cliresult(result) validate_pioproject(join(getcwd(), ext_folder_name)) -def test_init_ide_eclipse(platformio_setup, clirunner, validate_cliresult): +def test_init_duplicated_boards(clirunner, validate_cliresult, tmpdir): + with tmpdir.as_cwd(): + for _ in range(2): + result = clirunner.invoke(cmd_init, ["-b", "uno", "-b", "uno"]) + validate_cliresult(result) + validate_pioproject(str(tmpdir)) + config = util.load_project_config() + assert set(config.sections()) == set(["env:uno"]) + + +def test_init_ide_without_board(clirunner, validate_cliresult, tmpdir): + with tmpdir.as_cwd(): + result = clirunner.invoke(cmd_init, ["--ide", "atom"]) + assert result.exit_code == -1 + assert isinstance(result.exception, exception.BoardNotDefined) + + +def test_init_ide_atom(clirunner, validate_cliresult, tmpdir): + with tmpdir.as_cwd(): + result = clirunner.invoke( + cmd_init, ["--ide", "atom", "-b", "uno", "-b", "teensy31"]) + validate_cliresult(result) + validate_pioproject(str(tmpdir)) + assert all([tmpdir.join(f).check() + for f in (".clang_complete", ".gcc-flags.json")]) + assert "arduinoavr" in tmpdir.join(".clang_complete").read() + + # switch to NodeMCU + result = clirunner.invoke( + cmd_init, ["--ide", "atom", "-b", "nodemcuv2", "-b", "uno"]) + validate_cliresult(result) + validate_pioproject(str(tmpdir)) + assert "arduinoespressif" in tmpdir.join(".clang_complete").read() + + # switch to the first board + result = clirunner.invoke(cmd_init, ["--ide", "atom"]) + validate_cliresult(result) + validate_pioproject(str(tmpdir)) + assert "arduinoavr" in tmpdir.join(".clang_complete").read() + + +def test_init_ide_eclipse(clirunner, validate_cliresult): with clirunner.isolated_filesystem(): - result = clirunner.invoke(cli, ["-b", "uno", "--ide", "eclipse"]) + result = clirunner.invoke(cmd_init, ["-b", "uno", "--ide", "eclipse"]) validate_cliresult(result) validate_pioproject(getcwd()) assert all([isfile(f) for f in (".cproject", ".project")]) -def test_init_special_board(platformio_setup, clirunner, validate_cliresult): +def test_init_special_board(clirunner, validate_cliresult): with clirunner.isolated_filesystem(): - result = clirunner.invoke(cli, ["-b", "uno"]) + result = clirunner.invoke(cmd_init, ["-b", "uno"]) validate_cliresult(result) validate_pioproject(getcwd()) - uno = util.get_boards("uno") - config = util.get_project_config() + result = clirunner.invoke(cmd_boards, ["Arduino Uno", "--json-output"]) + validate_cliresult(result) + boards = json.loads(result.output) + + config = util.load_project_config() expected_result = [ - ("platform", str(uno['platform'])), - ("framework", str(uno['frameworks'][0])), - ("board", "uno") + ("platform", str(boards[0]['platform'])), + ("framework", str(boards[0]['frameworks'][0])), ("board", "uno") ] assert config.has_section("env:uno") - assert len(set(expected_result).symmetric_difference( - set(config.items("env:uno")))) == 0 + assert len( + set(expected_result).symmetric_difference( + set(config.items("env:uno")))) == 0 -def test_init_enable_auto_uploading(platformio_setup, clirunner, - validate_cliresult): +def test_init_enable_auto_uploading(clirunner, validate_cliresult): with clirunner.isolated_filesystem(): - result = clirunner.invoke(cli, - ["-b", "uno", "--enable-auto-uploading"]) + result = clirunner.invoke( + cmd_init, ["-b", "uno", "--project-option", "targets=upload"]) validate_cliresult(result) validate_pioproject(getcwd()) - config = util.get_project_config() + config = util.load_project_config() expected_result = [ - ("platform", "atmelavr"), - ("framework", "arduino"), - ("board", "uno"), - ("targets", "upload") + ("platform", "atmelavr"), ("framework", "arduino"), + ("board", "uno"), ("targets", "upload") ] assert config.has_section("env:uno") - assert len(set(expected_result).symmetric_difference( - set(config.items("env:uno")))) == 0 + assert len( + set(expected_result).symmetric_difference( + set(config.items("env:uno")))) == 0 def test_init_incorrect_board(clirunner): - result = clirunner.invoke(cli, ["-b", "missed_board"]) + result = clirunner.invoke(cmd_init, ["-b", "missed_board"]) assert result.exit_code == 2 - assert 'Error: Invalid value for "--board" / "-b"' in result.output + assert 'Error: Invalid value for "-b" / "--board' in result.output assert isinstance(result.exception, SystemExit) diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index e749a68c..9e8f1c26 100644 --- a/tests/commands/test_lib.py +++ b/tests/commands/test_lib.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,64 +12,145 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os import listdir -from os.path import isdir, isfile, join - +import json import re +from os.path import basename -from platformio.commands.lib import cli from platformio import util +from platformio.commands.init import cli as cmd_init +from platformio.commands.lib import cli as cmd_lib -def validate_libfolder(): - libs_path = util.get_lib_dir() - installed_libs = listdir(libs_path) - for lib in installed_libs: - assert isdir(join(libs_path, lib)) - assert isfile(join(libs_path, lib, ".library.json")) and isfile( - join(libs_path, lib, "library.json")) - - -def test_lib_search(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["search", "DHT22"]) +def test_search(clirunner, validate_cliresult): + result = clirunner.invoke(cmd_lib, ["search", "DHT22"]) validate_cliresult(result) match = re.search(r"Found\s+(\d+)\slibraries:", result.output) assert int(match.group(1)) > 2 - result = clirunner.invoke(cli, ["search", "DHT22", "--platform=timsp430"]) + result = clirunner.invoke(cmd_lib, + ["search", "DHT22", "--platform=timsp430"]) validate_cliresult(result) match = re.search(r"Found\s+(\d+)\slibraries:", result.output) - assert int(match.group(1)) == 1 + assert int(match.group(1)) > 1 -def test_lib_install(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["install", "58", "115"]) +def test_global_install_registry(clirunner, validate_cliresult, + isolated_pio_home): + result = clirunner.invoke(cmd_lib, [ + "-g", "install", "58", "OneWire", + "http://dl.platformio.org/libraries/archives/3/3756.tar.gz", + "ArduinoJson@5.4.0", "ArduinoJson@>5.4" + ]) validate_cliresult(result) - validate_libfolder() + items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()] + items2 = ["DHT22_ID58", "ArduinoJson_ID64", "Json_ID64", "OneWire_ID1", + "ESPAsyncTCP_ID305"] + assert set(items1) == set(items2) -def test_lib_list(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["list"]) +def test_global_install_archive(clirunner, validate_cliresult, + isolated_pio_home): + result = clirunner.invoke(cmd_lib, [ + "-g", "install", "https://github.com/adafruit/Adafruit-ST7735-Library/" + "archive/master.zip", + "http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.62.zip" + ]) validate_cliresult(result) - assert "58" in result.output and "115" in result.output + items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()] + items2 = ["Adafruit ST7735 Library", "RadioHead"] + assert set(items1) >= set(items2) -def test_lib_show(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["show", "115"]) +def test_global_install_repository(clirunner, validate_cliresult, + isolated_pio_home): + result = clirunner.invoke( + cmd_lib, + ["-g", + "install", + "https://github.com/gioblu/PJON.git#3.0", + "https://gitlab.com/ivankravets/rs485-nodeproto.git", + # "https://developer.mbed.org/users/simon/code/TextLCD/", + "knolleary/pubsubclient"]) validate_cliresult(result) - assert "arduino" in result.output and "atmelavr" in result.output + items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()] + items2 = ["PJON", "ESPAsyncTCP", "PubSubClient"] + assert set(items2) & set(items1) - result = clirunner.invoke(cli, ["show", "58"]) + +def test_global_lib_list(clirunner, validate_cliresult, isolated_pio_home): + result = clirunner.invoke(cmd_lib, ["-g", "list"]) validate_cliresult(result) - assert "energia" in result.output and "timsp430" in result.output + assert all([n in result.output for n in ("OneWire", "DHT22", "64")]) + + result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"]) + assert all( + [n in result.output + for n in ("PJON", "git+https://github.com/knolleary/pubsubclient")]) + items1 = [i['name'] for i in json.loads(result.output)] + items2 = ["OneWire", "DHT22", "PJON", "ESPAsyncTCP", "Json", "ArduinoJson", + "pubsubclient", "rs485-nodeproto", "Adafruit ST7735 Library", + "RadioHead"] + assert set(items1) == set(items2) -def test_lib_update(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["update"]) +def test_global_lib_show(clirunner, validate_cliresult, isolated_pio_home): + result = clirunner.invoke(cmd_lib, ["-g", "show", "64@5.4.0"]) validate_cliresult(result) - assert "58" in result.output and "115" in result.output + assert all([s in result.output + for s in ("Json", "arduino", "atmelavr", "5.4.0")]) - -def test_lib_uninstall(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["uninstall", "58", "115"]) + result = clirunner.invoke(cmd_lib, ["-g", "show", "ArduinoJson@>5.4.0"]) validate_cliresult(result) + assert all( + [s in result.output for s in ("ArduinoJson", "arduino", "atmelavr")]) + assert "5.4.0" not in result.output + + result = clirunner.invoke(cmd_lib, ["-g", "show", "1"]) + validate_cliresult(result) + assert "OneWire" in result.output + + +def test_global_lib_update(clirunner, validate_cliresult, isolated_pio_home): + result = clirunner.invoke(cmd_lib, ["-g", "update"]) + validate_cliresult(result) + assert all([s in result.output for s in ("[Up-to-date]", "[VCS]")]) + + +def test_global_lib_uninstall(clirunner, validate_cliresult, + isolated_pio_home): + result = clirunner.invoke(cmd_lib, + ["-g", "uninstall", "1", "ArduinoJson@!=5.4.0", + "TextLCD", "Adafruit ST7735 Library"]) + validate_cliresult(result) + items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()] + items2 = ["DHT22_ID58", "Json_ID64", "ESPAsyncTCP_ID305", "pubsubclient", + "PJON", "rs485-nodeproto", "RadioHead_ID124"] + assert set(items1) == set(items2) + + +def test_project_lib_complex(clirunner, validate_cliresult, tmpdir): + with tmpdir.as_cwd(): + # init + result = clirunner.invoke(cmd_init) + validate_cliresult(result) + + # isntall + result = clirunner.invoke(cmd_lib, ["install", "54", "ArduinoJson"]) + validate_cliresult(result) + items1 = [d.basename + for d in tmpdir.join(basename(util.get_projectlibdeps_dir())) + .listdir()] + items2 = ["DallasTemperature_ID54", "OneWire_ID1", "ArduinoJson_ID64"] + assert set(items1) == set(items2) + + # list + result = clirunner.invoke(cmd_lib, ["list", "--json-output"]) + validate_cliresult(result) + items1 = [i['name'] for i in json.loads(result.output)] + items2 = ["DallasTemperature", "OneWire", "ArduinoJson"] + assert set(items1) == set(items2) + + # update + result = clirunner.invoke(cmd_lib, ["update"]) + validate_cliresult(result) + assert "[Up-to-date]" in result.output diff --git a/tests/commands/test_platform.py b/tests/commands/test_platform.py new file mode 100644 index 00000000..ec618a90 --- /dev/null +++ b/tests/commands/test_platform.py @@ -0,0 +1,126 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import os +from os.path import join + +from platformio import exception, util +from platformio.commands import platform as cli_platform + + +def test_list_json_output(clirunner, validate_cliresult): + result = clirunner.invoke(cli_platform.platform_list, ["--json-output"]) + validate_cliresult(result) + list_result = json.loads(result.output) + assert isinstance(list_result, list) + assert len(list_result) + platforms = [item['name'] for item in list_result] + assert "titiva" in platforms + + +def test_list_raw_output(clirunner, validate_cliresult): + result = clirunner.invoke(cli_platform.platform_list) + validate_cliresult(result) + assert "teensy" in result.output + + +def test_search_json_output(clirunner, validate_cliresult): + result = clirunner.invoke(cli_platform.platform_search, + ["arduino", "--json-output"]) + validate_cliresult(result) + search_result = json.loads(result.output) + assert isinstance(search_result, list) + assert len(search_result) + platforms = [item['name'] for item in search_result] + assert "atmelsam" in platforms + + +def test_search_raw_output(clirunner, validate_cliresult): + result = clirunner.invoke(cli_platform.platform_search, ["arduino"]) + validate_cliresult(result) + assert "teensy" in result.output + + +def test_install_uknown_from_registry(clirunner, validate_cliresult): + result = clirunner.invoke(cli_platform.platform_install, + ["uknown-platform"]) + assert result.exit_code == -1 + assert isinstance(result.exception, exception.UnknownPackage) + + +def test_install_uknown_version(clirunner, validate_cliresult): + result = clirunner.invoke(cli_platform.platform_install, + ["atmelavr@99.99.99"]) + assert result.exit_code == -1 + assert isinstance(result.exception, exception.UndefinedPackageVersion) + + +def test_complex(clirunner, validate_cliresult): + items = [ + "teensy", + "https://github.com/platformio/platform-teensy/archive/develop.zip", + "https://github.com/platformio/platform-teensy.git", + "platformio/platform-teensy", + ] + for item in items: + with clirunner.isolated_filesystem(): + os.environ["PLATFORMIO_HOME_DIR"] = os.getcwd() + try: + result = clirunner.invoke(cli_platform.platform_install, + [item]) + validate_cliresult(result) + assert all([ + s in result.output + for s in ("teensy", "Downloading", "Unpacking", + "tool-scons") + ]) + + # show platform information + result = clirunner.invoke(cli_platform.platform_show, + ["teensy"]) + validate_cliresult(result) + assert "teensy" in result.output + + # list platforms + result = clirunner.invoke(cli_platform.platform_list, + ["--json-output"]) + validate_cliresult(result) + list_result = json.loads(result.output) + assert isinstance(list_result, list) + assert len(list_result) == 1 + assert list_result[0]["name"] == "teensy" + assert list_result[0]["packages"] == ["tool-scons"] + + # try to install again + result = clirunner.invoke(cli_platform.platform_install, + ["teensy"]) + validate_cliresult(result) + assert "is already installed" in result.output + + # try to update + result = clirunner.invoke(cli_platform.platform_update) + validate_cliresult(result) + assert "teensy" in result.output + assert "Up-to-date" in result.output + + # try to uninstall + result = clirunner.invoke(cli_platform.platform_uninstall, + ["teensy"]) + validate_cliresult(result) + for folder in ("platforms", "packages"): + assert len(os.listdir(join(util.get_home_dir(), + folder))) == 0 + finally: + del os.environ["PLATFORMIO_HOME_DIR"] diff --git a/tests/commands/test_platforms.py b/tests/commands/test_platforms.py deleted file mode 100644 index 0d0251d1..00000000 --- a/tests/commands/test_platforms.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2014-2016 Ivan Kravets -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json - -from platformio.commands.platforms import \ - platforms_list as cmd_platforms_list -from platformio.commands.platforms import \ - platforms_search as cmd_platforms_search - - -def test_list_json_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platforms_list, ["--json-output"]) - validate_cliresult(result) - list_result = json.loads(result.output) - assert isinstance(list_result, list) - assert len(list_result) - platforms = [item['name'] for item in list_result] - assert "titiva" in platforms - - -def test_list_raw_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platforms_list) - validate_cliresult(result) - assert "teensy" in result.output - - -def test_search_json_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platforms_search, - ["arduino", "--json-output"]) - validate_cliresult(result) - search_result = json.loads(result.output) - assert isinstance(search_result, list) - assert len(search_result) - platforms = [item['type'] for item in search_result] - assert "atmelsam" in platforms - - -def test_search_raw_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platforms_search, ["arduino"]) - validate_cliresult(result) - assert "teensy" in result.output diff --git a/tests/commands/test_settings.py b/tests/commands/test_settings.py index d74c3ad8..bec21889 100644 --- a/tests/commands/test_settings.py +++ b/tests/commands/test_settings.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from platformio.commands.settings import cli from platformio import app +from platformio.commands.settings import cli def test_settings_check(clirunner, validate_cliresult): diff --git a/platformio/builder/scripts/frameworks/simba.py b/tests/commands/test_test.py old mode 100755 new mode 100644 similarity index 55% rename from platformio/builder/scripts/frameworks/simba.py rename to tests/commands/test_test.py index 52c875e4..173f8113 --- a/platformio/builder/scripts/frameworks/simba.py +++ b/tests/commands/test_test.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,24 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Simba - -Simba is an RTOS and build framework. It aims to make embedded -programming easy and portable. - -http://simba-os.readthedocs.org - -""" - from os.path import join -from SCons.Script import DefaultEnvironment, SConscript +import pytest -env = DefaultEnvironment() +from platformio import util -env.Replace( - PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-simba") -) -SConscript( - [env.subst(join("$PLATFORMFW_DIR", "make", "platformio.sconscript"))]) +def test_local_env(): + result = util.exec_command(["platformio", "test", "-d", + join("examples", "unit-testing", "calculator"), + "-e", "local"]) + if result['returncode'] != 0: + pytest.fail(result) + assert all( + [s in result['out'] for s in ("[PASSED]", "[IGNORED]", "[FAILED]")]) diff --git a/platformio/platforms/native.py b/tests/commands/test_update.py similarity index 50% rename from platformio/platforms/native.py rename to tests/commands/test_update.py index 9c4ed8bb..f17f5bbd 100644 --- a/platformio/platforms/native.py +++ b/tests/commands/test_update.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,18 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from platformio.platforms.base import BasePlatform +from platformio.commands.update import cli as cmd_update -class NativePlatform(BasePlatform): - - """ - Native development platform is intended to be used for desktop OS. - This platform uses built-in toolchains (preferable based on GCC), - frameworks, libs from particular OS where it will be run. - - http://platformio.org/platforms/native - """ - - PACKAGES = { - } +def test_update(clirunner, validate_cliresult): + matches = ( + "Platform Manager", + "Up-to-date", + "Library Manager" + ) + result = clirunner.invoke(cmd_update, ["--only-check"]) + validate_cliresult(result) + assert all([m in result.output for m in matches]) + result = clirunner.invoke(cmd_update) + validate_cliresult(result) + assert all([m in result.output for m in matches]) diff --git a/tests/conftest.py b/tests/conftest.py index f4cdc110..46670a44 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,37 +12,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os import environ - -from click.testing import CliRunner +import os import pytest +import requests +from click.testing import CliRunner + +requests.packages.urllib3.disable_warnings() -@pytest.fixture(scope="session") -def platformio_setup(request): - pioenvvars = ("ENABLE_PROMPTS", "ENABLE_TELEMETRY") - for v in pioenvvars: - environ["PLATFORMIO_SETTING_%s" % v] = "No" - - def platformio_teardown(): - for v in pioenvvars: - _name = "PLATFORMIO_SETTING_%s" % v - if _name in environ: - del environ[_name] - - request.addfinalizer(platformio_teardown) - - -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def clirunner(): return CliRunner() @pytest.fixture(scope="session") def validate_cliresult(): + def decorator(result): assert result.exit_code == 0 assert not result.exception - assert "error" not in result.output.lower() + return decorator + + +@pytest.fixture(scope="module") +def isolated_pio_home(request, tmpdir_factory): + home_dir = tmpdir_factory.mktemp(".platformio") + os.environ['PLATFORMIO_HOME_DIR'] = str(home_dir) + + def fin(): + del os.environ['PLATFORMIO_HOME_DIR'] + + request.addfinalizer(fin) + return home_dir diff --git a/tests/ino2cpp/basic/basic.ino b/tests/ino2cpp/basic/basic.ino new file mode 100644 index 00000000..6f764fed --- /dev/null +++ b/tests/ino2cpp/basic/basic.ino @@ -0,0 +1,45 @@ +#define SQR(a) \ +( a * a ) + +typedef struct Item item; +struct Item { + byte foo[50]; + int bar; + void (*noob)(item*); +}; + +// test callback +class Foo { + + public: + Foo(void (*function)()) { + #warning "Line number is 16" + } + + bool childFunc() { + + } + +}; + +Foo foo(&fooCallback); + +// + +void setup() { + struct Item item1; + myFunction(&item1); +} + + +void loop() { + +} + +void myFunction(struct Item *item) { + +} + +void fooCallback(){ + +} diff --git a/tests/ino2cpp/multifiles/bar.ino b/tests/ino2cpp/multifiles/bar.ino new file mode 100644 index 00000000..6040586a --- /dev/null +++ b/tests/ino2cpp/multifiles/bar.ino @@ -0,0 +1,4 @@ +unsigned int barFunc () // my comment +{ + return 0; +} \ No newline at end of file diff --git a/tests/ino2cpp/multifiles/foo.pde b/tests/ino2cpp/multifiles/foo.pde new file mode 100644 index 00000000..9b2913cb --- /dev/null +++ b/tests/ino2cpp/multifiles/foo.pde @@ -0,0 +1,13 @@ +char buf[5]; + +void setup() { + fooFunc(); +} + +void loop() { + +} + +char* fooFunc() { + return buf; +} diff --git a/tests/ino2cpp/strmultilines/main.ino b/tests/ino2cpp/strmultilines/main.ino new file mode 100644 index 00000000..c5df8f30 --- /dev/null +++ b/tests/ino2cpp/strmultilines/main.ino @@ -0,0 +1,79 @@ +const char headerEndP[] PROGMEM = +"\ +\ +\ +"; + +void setup() { + +} + +const char javaScriptPinControlP[] PROGMEM = +"
\ +
\ +"; + +#warning "Line 75" + +void loop() { + +} \ No newline at end of file diff --git a/tests/test_examples.py b/tests/test_examples.py index f953feab..42ff2b5e 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,11 +15,10 @@ from glob import glob from os import listdir, walk from os.path import dirname, getsize, isdir, isfile, join, normpath -from shutil import rmtree import pytest -from platformio.util import exec_command +from platformio import util def pytest_generate_tests(metafunc): @@ -36,11 +35,11 @@ def pytest_generate_tests(metafunc): @pytest.mark.examples -def test_run(platformio_setup, pioproject_dir): +def test_run(pioproject_dir): if isdir(join(pioproject_dir, ".pioenvs")): - rmtree(join(pioproject_dir, ".pioenvs")) + util.rmtree_(join(pioproject_dir, ".pioenvs")) - result = exec_command( + result = util.exec_command( ["platformio", "--force", "run", "--project-dir", pioproject_dir] ) if result['returncode'] != 0: diff --git a/tests/test_ino2cpp.py b/tests/test_ino2cpp.py new file mode 100644 index 00000000..c8f411c0 --- /dev/null +++ b/tests/test_ino2cpp.py @@ -0,0 +1,48 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from os import listdir +from os.path import dirname, isdir, join, normpath + +from platformio.commands.ci import cli as cmd_ci + +INOTEST_DIR = normpath(join(dirname(__file__), "ino2cpp")) + + +def pytest_generate_tests(metafunc): + if "piotest_dir" not in metafunc.fixturenames: + return + test_dirs = [] + for name in listdir(INOTEST_DIR): + if isdir(join(INOTEST_DIR, name)): + test_dirs.append(join(INOTEST_DIR, name)) + test_dirs.sort() + metafunc.parametrize("piotest_dir", test_dirs) + + +def test_example(clirunner, validate_cliresult, piotest_dir): + result = clirunner.invoke(cmd_ci, [piotest_dir, "-b", "uno"]) + validate_cliresult(result) + + +def test_warning_line(clirunner, validate_cliresult): + result = clirunner.invoke(cmd_ci, + [join(INOTEST_DIR, "basic"), "-b", "uno"]) + validate_cliresult(result) + assert ('basic.ino:16:14: warning: #warning "Line number is 16"' in + result.output) + result = clirunner.invoke( + cmd_ci, [join(INOTEST_DIR, "strmultilines"), "-b", "uno"]) + validate_cliresult(result) + assert ('main.ino:75:2: warning: #warning "Line 75"' in result.output) diff --git a/tests/test_maintenance.py b/tests/test_maintenance.py new file mode 100644 index 00000000..b4f7a97d --- /dev/null +++ b/tests/test_maintenance.py @@ -0,0 +1,196 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +from time import time + +from platformio import app, maintenance +from platformio.__main__ import cli as cli_pio +from platformio.commands import upgrade as cmd_upgrade +from platformio.managers.platform import PlatformManager + + +def test_after_upgrade_2_to_3(clirunner, validate_cliresult, + isolated_pio_home): + app.set_state_item("last_version", "2.11.2") + app.set_state_item("installed_platforms", ["native"]) + + # generate PlatformIO 2.0 boards + boards = isolated_pio_home.mkdir("boards") + board_ids = set() + for prefix in ("foo", "bar"): + data = {} + for i in range(3): + board_id = "board_%s_%d" % (prefix, i) + board_ids.add(board_id) + data[board_id] = { + "name": "Board %s #%d" % (prefix, i), + "url": "", + "vendor": "" + } + boards.join(prefix + ".json").write(json.dumps(data)) + + result = clirunner.invoke(cli_pio, ["settings", "get"]) + validate_cliresult(result) + assert "upgraded to 3" + assert isolated_pio_home.join("platforms", "native", + "platform.json").check() + + # check PlatformIO 3.0 boards + assert board_ids == set([p.basename[:-5] for p in boards.listdir()]) + + result = clirunner.invoke(cli_pio, + ["boards", "--installed", "--json-output"]) + validate_cliresult(result) + assert board_ids == set([b['id'] for b in json.loads(result.output)]) + + +def test_after_upgrade_silence(clirunner, validate_cliresult, + isolated_pio_home): + app.set_state_item("last_version", "2.11.2") + result = clirunner.invoke(cli_pio, ["boards", "--json-output"]) + validate_cliresult(result) + boards = json.loads(result.output) + assert any([b['id'] == "uno" for b in boards]) + + +def test_check_pio_upgrade(clirunner, validate_cliresult, isolated_pio_home): + + def _patch_pio_version(version): + maintenance.__version__ = version + cmd_upgrade.VERSION = version.split(".", 3) + + interval = int(app.get_setting("check_platformio_interval")) * 3600 * 24 + last_check = {"platformio_upgrade": time() - interval - 1} + origin_version = maintenance.__version__ + + # check development version + _patch_pio_version("3.0.0-a1") + app.set_state_item("last_check", last_check) + result = clirunner.invoke(cli_pio, ["platform", "list"]) + validate_cliresult(result) + assert "There is a new version" in result.output + assert "Please upgrade" in result.output + + # check stable version + _patch_pio_version("2.11.0") + app.set_state_item("last_check", last_check) + result = clirunner.invoke(cli_pio, ["platform", "list"]) + validate_cliresult(result) + assert "There is a new version" in result.output + assert "Please upgrade" in result.output + + # restore original version + _patch_pio_version(origin_version) + + +def test_check_lib_updates(clirunner, validate_cliresult, isolated_pio_home): + # install obsolete library + result = clirunner.invoke(cli_pio, + ["lib", "-g", "install", "PubSubClient@<2.6"]) + validate_cliresult(result) + + # reset check time + interval = int(app.get_setting("check_libraries_interval")) * 3600 * 24 + last_check = {"libraries_update": time() - interval - 1} + app.set_state_item("last_check", last_check) + + result = clirunner.invoke(cli_pio, ["lib", "-g", "list"]) + validate_cliresult(result) + assert ("There are the new updates for libraries (PubSubClient)" in + result.output) + + +def test_check_and_update_libraries(clirunner, validate_cliresult, + isolated_pio_home): + # enable library auto-updates + result = clirunner.invoke( + cli_pio, ["settings", "set", "auto_update_libraries", "Yes"]) + + # reset check time + interval = int(app.get_setting("check_libraries_interval")) * 3600 * 24 + last_check = {"libraries_update": time() - interval - 1} + app.set_state_item("last_check", last_check) + + # fetch installed version + result = clirunner.invoke(cli_pio, ["lib", "-g", "list", "--json-output"]) + validate_cliresult(result) + prev_data = json.loads(result.output) + assert len(prev_data) == 1 + + # initiate auto-updating + result = clirunner.invoke(cli_pio, ["lib", "-g", "show", "PubSubClient"]) + validate_cliresult(result) + assert ("There are the new updates for libraries (PubSubClient)" in + result.output) + assert "Please wait while updating libraries" in result.output + assert "[Out-of-date]" in result.output + + # check updated version + result = clirunner.invoke(cli_pio, ["lib", "-g", "list", "--json-output"]) + validate_cliresult(result) + assert prev_data[0]['version'] != json.loads(result.output)[0]['version'] + + +def test_check_platform_updates(clirunner, validate_cliresult, + isolated_pio_home): + # install obsolete platform + result = clirunner.invoke(cli_pio, ["platform", "install", "native"]) + validate_cliresult(result) + manifest_path = isolated_pio_home.join("platforms", "native", + "platform.json") + manifest = json.loads(manifest_path.read()) + manifest['version'] = "0.0.0" + manifest_path.write(json.dumps(manifest)) + # reset cached manifests + PlatformManager().reset_cache() + + # reset check time + interval = int(app.get_setting("check_platforms_interval")) * 3600 * 24 + last_check = {"platforms_update": time() - interval - 1} + app.set_state_item("last_check", last_check) + + result = clirunner.invoke(cli_pio, ["platform", "list"]) + validate_cliresult(result) + assert "There are the new updates for platforms (native)" in result.output + + +def test_check_and_update_platforms(clirunner, validate_cliresult, + isolated_pio_home): + # enable library auto-updates + result = clirunner.invoke( + cli_pio, ["settings", "set", "auto_update_platforms", "Yes"]) + + # reset check time + interval = int(app.get_setting("check_platforms_interval")) * 3600 * 24 + last_check = {"platforms_update": time() - interval - 1} + app.set_state_item("last_check", last_check) + + # fetch installed version + result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"]) + validate_cliresult(result) + prev_data = json.loads(result.output) + assert len(prev_data) == 1 + + # initiate auto-updating + result = clirunner.invoke(cli_pio, ["platform", "show", "native"]) + validate_cliresult(result) + assert "There are the new updates for platforms (native)" in result.output + assert "Please wait while updating platforms" in result.output + assert "[Out-of-date]" in result.output + + # check updated version + result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"]) + validate_cliresult(result) + assert prev_data[0]['version'] != json.loads(result.output)[0]['version'] diff --git a/tests/test_managers.py b/tests/test_managers.py new file mode 100644 index 00000000..f99038e6 --- /dev/null +++ b/tests/test_managers.py @@ -0,0 +1,68 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from platformio import util +from platformio.managers.package import BasePkgManager + + +def test_pkg_name_parser(): + items = [ + ["PkgName", ("PkgName", None, None)], + [("PkgName", "!=1.2.3,<2.0"), ("PkgName", "!=1.2.3,<2.0", None)], + ["PkgName@1.2.3", ("PkgName", "1.2.3", None)], + [("PkgName@1.2.3", "1.2.5"), ("PkgName@1.2.3", "1.2.5", None)], + ["id:13", ("id:13", None, None)], + ["id:13@~1.2.3", ("id:13", "~1.2.3", None)], + [util.get_home_dir(), + (".platformio", None, "file://" + util.get_home_dir())], + ["LocalName=" + util.get_home_dir(), + ("LocalName", None, "file://" + util.get_home_dir())], + ["https://github.com/user/package.git", + ("package", None, "git+https://github.com/user/package.git")], + ["https://gitlab.com/user/package.git", + ("package", None, "git+https://gitlab.com/user/package.git")], + ["https://github.com/user/package/archive/branch.zip", + ("branch", None, + "https://github.com/user/package/archive/branch.zip")], + ["https://github.com/user/package/archive/branch.tar.gz", + ("branch", None, + "https://github.com/user/package/archive/branch.tar.gz")], + ["https://developer.mbed.org/users/user/code/package/", + ("package", None, + "hg+https://developer.mbed.org/users/user/code/package/")], + ["https://github.com/user/package#v1.2.3", + ("package", None, "git+https://github.com/user/package#v1.2.3")], + ["https://github.com/user/package.git#branch", + ("package", None, "git+https://github.com/user/package.git#branch")], + ["PkgName=https://github.com/user/package.git#a13d344fg56", + ("PkgName", None, + "git+https://github.com/user/package.git#a13d344fg56")], + ["PkgName=user/package", + ("PkgName", None, "git+https://github.com/user/package")], + ["PkgName=user/package#master", + ("PkgName", None, "git+https://github.com/user/package#master")], + ["git+https://github.com/user/package", + ("package", None, "git+https://github.com/user/package")], + ["hg+https://example.com/user/package", + ("package", None, "hg+https://example.com/user/package")], + ["git@github.com:user/package.git", + ("package", None, "git@github.com:user/package.git")], + ["git@github.com:user/package.git#v1.2.0", + ("package", None, "git@github.com:user/package.git#v1.2.0")] + ] + for params, result in items: + if isinstance(params, tuple): + assert BasePkgManager.parse_pkg_name(*params) == result + else: + assert BasePkgManager.parse_pkg_name(params) == result diff --git a/tests/test_pkgmanifest.py b/tests/test_pkgmanifest.py index 62b1b9d6..8793f9ab 100644 --- a/tests/test_pkgmanifest.py +++ b/tests/test_pkgmanifest.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,13 +15,12 @@ import pytest import requests -from platformio.util import get_api_result - def pytest_generate_tests(metafunc): if "package_data" not in metafunc.fixturenames: return - pkgs_manifest = get_api_result("/packages/manifest") + pkgs_manifest = requests.get( + "https://dl.bintray.com/platformio/dl-packages/manifest.json").json() assert isinstance(pkgs_manifest, dict) packages = [] for _, variants in pkgs_manifest.iteritems(): diff --git a/tox.ini b/tox.ini index 7b32c481..13c4e891 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # limitations under the License. [tox] -envlist = py26, py27, docs, lint +envlist = py27, docs, lint [testenv:develop] basepython = python2.7 @@ -21,6 +21,9 @@ usedevelop = True deps = isort flake8 + yapf + pylint + pytest commands = python --version [testenv:docs] @@ -50,12 +53,19 @@ commands = pylint --rcfile=./.pylintrc ./platformio [testenv] -basepython = - py26: python2.6 - py27: python2.7 -usedevelop = True +basepython = python2.7 passenv = * -deps = pytest +deps = + pytest commands = {envpython} --version py.test -v --basetemp="{envtmpdir}" tests + +[testenv:coverage] +basepython = python2.7 +passenv = * +deps = + pytest + pytest-cov +commands = + py.test --cov=platformio --cov-report term --cov-report xml --ignore=tests/test_examples.py --ignore=tests/test_pkgmanifest.py -v tests