diff --git a/.gitignore b/.gitignore index 452e43a2f1..61b52bc4c0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ .pioenvs .tox .sconsign.dblite +examples/ide-eclipse/.metadata +examples/ide-eclipse/RemoteSystemsTempFiles diff --git a/HISTORY.rst b/HISTORY.rst index 12cf9c6cb1..f721c4c469 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,16 @@ Release History =============== +0.3.0 (2014-06-21) +--------- + +* Allowed to pass multiple "SomePlatform" to install/uninstall commands +* Added "IDE Integration" section to README with Eclipse project examples +* Created auto installer script for *PlatformIO* (`issue #3 `_) +* Added "Super-Quick" way to Installation section (README) +* Implemented "build_flags" option for environments (`issue #4 `_) + + 0.2.0 (2014-06-15) ------------------ diff --git a/README.rst b/README.rst index fd7a4def36..f89eed60c2 100644 --- a/README.rst +++ b/README.rst @@ -10,19 +10,22 @@ PlatformIO .. image:: https://pypip.in/version/platformio/badge.png :target: https://pypi.python.org/pypi/platformio/ :alt: Latest Version +.. image:: https://pypip.in/download/platformio/badge.png + :target: https://pypi.python.org/pypi/platformio/ + :alt: Downloads .. image:: https://pypip.in/license/platformio/badge.png :target: https://pypi.python.org/pypi/platformio/ :alt: License -**Platformio** is a console tool to build code with different development +**PlatformIO** is a console tool to build code with different development platforms. -You have no need to install any *IDE* or compile any toolchains. *Platformio* +You have no need to install any *IDE* or compile any toolchains. *PlatformIO* has pre-built different development platforms including: compiler, debugger, flasher (for embedded) and many other useful tools. -**Platformio** allows developer to compile the same code with different +**PlatformIO** allows developer to compile the same code with different platforms using only one command ``platformio run``. This happens due to ``platformio.ini`` project's file (see `default template `_) @@ -33,7 +36,12 @@ Each platform consists of packages which are located in own repository. Due to ``platformio update`` command you will have up-to-date development instruments. -**Platformio** is well suited for **embedded development**. It can: +.. image:: examples/platformio-examples.png + :target: https://github.com/ivankravets/platformio/raw/develop/examples/platformio-examples.png + :alt: Examples + :width: 730px + +**PlatformIO** is well suited for **embedded development**. It can: * Automatically analyse dependency * Reliably detect build changes @@ -56,10 +64,16 @@ It has support for many popular embedded platforms like these: See project `examples with screenshots `_. +IDE Integration +--------------- + +* [Eclipse] `Building and debugging Atmel AVR (Arduino-based) project using Eclipse IDE+PlatformIO `_ + + Python & OS Support ------------------- -**Platformio** is written in `Python `_ and works with +**PlatformIO** is written in `Python `_ and works with versions 2.6 and 2.7 on Unix/Linux, OS X, and Windows. @@ -68,9 +82,6 @@ Quickstart .. code-block:: bash - # Install platformio - $ pip install platformio && pip install --egg scons - # Print all availalbe development platforms for installing $ platformio search all @@ -93,29 +104,55 @@ Installation All commands below should be executed in `Command-line `_ -application in your OS: +application in your *OS*: * *Unix/Linux/OS X* this is *Terminal* application. * *Windows* this is `Command Prompt `_ (``cmd.exe``) application. -2. Check a ``python`` version: +Also, the `Python Interpreter `_ (2.6 or 2.7) +is required. + + +Super-Quick +~~~~~~~~~~~ + +To install or upgrade *PlatformIO*, download +`get-platformio.py `_ script. + +Then run the following (which may require administrator access): + +.. code-block:: bash + + $ python get-platformio.py + +On *Windows OS* it may look like: + +.. code-block:: bash + + C:\Python27\python.exe get-platformio.py + + +Full Guide +~~~~~~~~~~ + +1. Check a ``python`` version (only 2.6-2.7 is supported): .. code-block:: bash $ python --version -Windows OS Users only: +*Windows OS* Users only: - * `Download Python `_ and install it. + * `Download Python 2.7 `_ and install it. * Add to PATH system variable ``;C:\Python27;C:\Python27\Scripts;`` and reopen *Command Prompt* (``cmd.exe``) application. Please read this article `How to set the path and environment variables in Windows `_. -2. Check a ``pip`` tool for installing and managing Python packages: +2. Check a ``pip`` tool for installing and managing *Python* packages: .. code-block:: bash @@ -193,7 +230,7 @@ Search for development platforms: ``platformio install`` ~~~~~~~~~~~~~~~~~~~~~~ -*Platformio* has pre-built development platforms with related packages. You +*PlatformIO* has pre-built development platforms with related packages. You can install one of them: .. code-block:: bash @@ -294,7 +331,7 @@ Initialize new platformio based project. After this command ``platformio`` will create: * ``.pioenvs`` - a temporary working directory. -* ``lib`` - a directory for project specific libraries. Platformio will +* ``lib`` - a directory for project specific libraries. PlatformIO will compile their to static libraries and link to executable file * ``src`` - a source directory. Put code here. * ``platformio.ini`` - a configuration file for project diff --git a/examples/ide-eclipse/README.rst b/examples/ide-eclipse/README.rst new file mode 100644 index 0000000000..8e02c923f1 --- /dev/null +++ b/examples/ide-eclipse/README.rst @@ -0,0 +1,14 @@ +Eclipse IDE Integration +======================= + +The detailed information and steps are described in this article: +`Building and debugging Atmel AVR (Arduino-based) project using Eclipse IDE+PlatformIO `_. + + +.. image:: http://www.ikravets.com/wp-content/uploads/2014/06/eclipse_build_arduino_pro5v-1024x822.png + :width: 850px + :target: http://www.ikravets.com/computer-life/programming/2014/06/20/building-and-debugging-atmel-avr-arduino-based-project-using-eclipse-ideplatformio + +.. image:: http://www.ikravets.com/wp-content/uploads/2014/06/eclipse_debugging_result_1-1024x775.png + :width: 850px + :target: http://www.ikravets.com/computer-life/programming/2014/06/20/building-and-debugging-atmel-avr-arduino-based-project-using-eclipse-ideplatformio diff --git a/examples/ide-eclipse/arduino_pro5/.cproject b/examples/ide-eclipse/arduino_pro5/.cproject new file mode 100644 index 0000000000..d58b4a4789 --- /dev/null +++ b/examples/ide-eclipse/arduino_pro5/.cproject @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ide-eclipse/arduino_pro5/.project b/examples/ide-eclipse/arduino_pro5/.project new file mode 100644 index 0000000000..25893375a7 --- /dev/null +++ b/examples/ide-eclipse/arduino_pro5/.project @@ -0,0 +1,27 @@ + + + arduino_pro5 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/examples/ide-eclipse/arduino_pro5/Makefile b/examples/ide-eclipse/arduino_pro5/Makefile new file mode 100644 index 0000000000..eb5632a03e --- /dev/null +++ b/examples/ide-eclipse/arduino_pro5/Makefile @@ -0,0 +1,5 @@ +all: + platformio run -t upload + +clean: + platformio run -t clean diff --git a/examples/ide-eclipse/arduino_pro5/platformio.ini b/examples/ide-eclipse/arduino_pro5/platformio.ini new file mode 100644 index 0000000000..c39b5c74ad --- /dev/null +++ b/examples/ide-eclipse/arduino_pro5/platformio.ini @@ -0,0 +1,8 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +[env:arduino_pro5v] +platform = atmelavr +framework = arduino +board = pro16MHzatmega168 +upload_port = /dev/tty.SLAB_USBtoUART \ No newline at end of file diff --git a/examples/ide-eclipse/arduino_pro5/src/main.c b/examples/ide-eclipse/arduino_pro5/src/main.c new file mode 100644 index 0000000000..07fc3605bd --- /dev/null +++ b/examples/ide-eclipse/arduino_pro5/src/main.c @@ -0,0 +1,20 @@ +/** + * Copyright (C) Ivan Kravets + * See LICENSE for details. + */ + +#include "Arduino.h" +#define WLED 13 // Most Arduino boards already have an LED attached to pin 13 on the board itself + +void setup() +{ + pinMode(WLED, OUTPUT); // set pin as output +} + +void loop() +{ + digitalWrite(WLED, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(WLED, LOW); // set the LED off + delay(1000); // wait for a second +} diff --git a/examples/ide-eclipse/atmelavr_atmega168/.cproject b/examples/ide-eclipse/atmelavr_atmega168/.cproject new file mode 100644 index 0000000000..bf75df5c95 --- /dev/null +++ b/examples/ide-eclipse/atmelavr_atmega168/.cproject @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ide-eclipse/atmelavr_atmega168/.project b/examples/ide-eclipse/atmelavr_atmega168/.project new file mode 100644 index 0000000000..b42a00177c --- /dev/null +++ b/examples/ide-eclipse/atmelavr_atmega168/.project @@ -0,0 +1,27 @@ + + + atmelavr_atmega168 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/examples/ide-eclipse/atmelavr_atmega168/.settings/org.eclipse.cdt.codan.core.prefs b/examples/ide-eclipse/atmelavr_atmega168/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000..77386c23cb --- /dev/null +++ b/examples/ide-eclipse/atmelavr_atmega168/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,67 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} diff --git a/examples/ide-eclipse/atmelavr_atmega168/Makefile b/examples/ide-eclipse/atmelavr_atmega168/Makefile new file mode 100644 index 0000000000..eb5632a03e --- /dev/null +++ b/examples/ide-eclipse/atmelavr_atmega168/Makefile @@ -0,0 +1,5 @@ +all: + platformio run -t upload + +clean: + platformio run -t clean diff --git a/examples/ide-eclipse/atmelavr_atmega168/platformio.ini b/examples/ide-eclipse/atmelavr_atmega168/platformio.ini new file mode 100644 index 0000000000..3814277ce8 --- /dev/null +++ b/examples/ide-eclipse/atmelavr_atmega168/platformio.ini @@ -0,0 +1,12 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +[env:atmelavr_atmega168] +platform = atmelavr +board_mcu = atmega168 +board_f_cpu = 16000000L + +upload_port = /dev/tty.SLAB_USBtoUART +# upload_port = COM3 +upload_protocol = arduino +upload_speed = 19200 \ No newline at end of file diff --git a/examples/ide-eclipse/atmelavr_atmega168/src/main.c b/examples/ide-eclipse/atmelavr_atmega168/src/main.c new file mode 100644 index 0000000000..757d3c5f3f --- /dev/null +++ b/examples/ide-eclipse/atmelavr_atmega168/src/main.c @@ -0,0 +1,23 @@ +/** + * Copyright (C) Ivan Kravets + * See LICENSE for details. + */ + +#include +#include + +int main(void) +{ + // make the LED pin an output for PORTB5 + DDRB = 1 << 5; + + while (1) + { + _delay_ms(500); + + // toggle the LED + PORTB ^= 1 << 5; + } + + return 0; +} diff --git a/examples/ide-eclipse/tilaunchpad_msp430g2/.cproject b/examples/ide-eclipse/tilaunchpad_msp430g2/.cproject new file mode 100644 index 0000000000..d0028b0be0 --- /dev/null +++ b/examples/ide-eclipse/tilaunchpad_msp430g2/.cproject @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ide-eclipse/tilaunchpad_msp430g2/.project b/examples/ide-eclipse/tilaunchpad_msp430g2/.project new file mode 100644 index 0000000000..14e9c18547 --- /dev/null +++ b/examples/ide-eclipse/tilaunchpad_msp430g2/.project @@ -0,0 +1,27 @@ + + + tilaunchpad_msp430g2 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/examples/ide-eclipse/tilaunchpad_msp430g2/Makefile b/examples/ide-eclipse/tilaunchpad_msp430g2/Makefile new file mode 100644 index 0000000000..eb5632a03e --- /dev/null +++ b/examples/ide-eclipse/tilaunchpad_msp430g2/Makefile @@ -0,0 +1,5 @@ +all: + platformio run -t upload + +clean: + platformio run -t clean diff --git a/examples/ide-eclipse/tilaunchpad_msp430g2/platformio.ini b/examples/ide-eclipse/tilaunchpad_msp430g2/platformio.ini new file mode 100644 index 0000000000..55a857bccf --- /dev/null +++ b/examples/ide-eclipse/tilaunchpad_msp430g2/platformio.ini @@ -0,0 +1,9 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +[env:launchpad_msp430g2] +platform = timsp430 +board_mcu = msp430g2553 +board_f_cpu = 16000000L + +upload_protocol = rf2500 diff --git a/examples/ide-eclipse/tilaunchpad_msp430g2/src/main.c b/examples/ide-eclipse/tilaunchpad_msp430g2/src/main.c new file mode 100644 index 0000000000..38a421a51f --- /dev/null +++ b/examples/ide-eclipse/tilaunchpad_msp430g2/src/main.c @@ -0,0 +1,26 @@ +/** + * Copyright (C) Ivan Kravets + * See LICENSE for details. + */ + +#include + +int main(void) +{ + WDTCTL = WDTPW + WDTHOLD; + + // make the LED pin an output for P1.0 + P1DIR |= 0x01; + + volatile int i; + + while (1) + { + for (i = 0; i < 10000; i++); + + // toggle the LED + P1OUT ^= 0x01; + } + + return 0; +} diff --git a/examples/ide-eclipse/titiva_lm4f120/.cproject b/examples/ide-eclipse/titiva_lm4f120/.cproject new file mode 100644 index 0000000000..45fa200df5 --- /dev/null +++ b/examples/ide-eclipse/titiva_lm4f120/.cproject @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ide-eclipse/titiva_lm4f120/.project b/examples/ide-eclipse/titiva_lm4f120/.project new file mode 100644 index 0000000000..36085734f9 --- /dev/null +++ b/examples/ide-eclipse/titiva_lm4f120/.project @@ -0,0 +1,27 @@ + + + titiva_lm4f120 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/examples/ide-eclipse/titiva_lm4f120/Makefile b/examples/ide-eclipse/titiva_lm4f120/Makefile new file mode 100644 index 0000000000..eb5632a03e --- /dev/null +++ b/examples/ide-eclipse/titiva_lm4f120/Makefile @@ -0,0 +1,5 @@ +all: + platformio run -t upload + +clean: + platformio run -t clean diff --git a/examples/ide-eclipse/titiva_lm4f120/platformio.ini b/examples/ide-eclipse/titiva_lm4f120/platformio.ini new file mode 100644 index 0000000000..7e91575237 --- /dev/null +++ b/examples/ide-eclipse/titiva_lm4f120/platformio.ini @@ -0,0 +1,8 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +[env:launchpad_lm4f120] +platform = titiva +framework = energia +board = lplm4f120h5qr +targets = upload diff --git a/examples/ide-eclipse/titiva_lm4f120/src/main.c b/examples/ide-eclipse/titiva_lm4f120/src/main.c new file mode 100644 index 0000000000..c943670e28 --- /dev/null +++ b/examples/ide-eclipse/titiva_lm4f120/src/main.c @@ -0,0 +1,42 @@ +/** + * Copyright (C) Ivan Kravets + * See LICENSE for details. + */ + +#define false 0 +#define true 1 +typedef int bool; + +#include +#include "inc/hw_memmap.h" +#include "driverlib/gpio.h" +#include "driverlib/sysctl.h" + +#define LED_RED GPIO_PIN_1 +#define LED_BLUE GPIO_PIN_2 +#define LED_GREEN GPIO_PIN_3 + +int main(void) +{ + SysCtlClockSet( + SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); + + SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); + GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN); + + while (1) + { + GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN, LED_RED); + SysCtlDelay(3000000); + GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN, LED_BLUE); + SysCtlDelay(3000000); + GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN, LED_GREEN); + SysCtlDelay(3000000); + } + + return 0; +} + +// hook for Energia main.cpp where these methods are defined +void setup() {} +void loop() {} diff --git a/examples/platformio-examples.png b/examples/platformio-examples.png new file mode 100644 index 0000000000..0c793f6f1d Binary files /dev/null and b/examples/platformio-examples.png differ diff --git a/examples/wiring-blink/README.rst b/examples/wiring-blink/README.rst index 1f7ec10688..17e78fd2f6 100644 --- a/examples/wiring-blink/README.rst +++ b/examples/wiring-blink/README.rst @@ -12,13 +12,9 @@ Wiring Framework (Arduino + Energia) Blink Example $ cd platformio-develop/examples/wiring-blink/ # Install Atmel AVR development platform with Arduino Framework - $ platformio install atmelavr --with-package=framework-arduinoavr - # Install TI MSP430 development platform with Energia Framework - $ platformio install timsp430 --with-package=framework-energiamsp430 - # Install TI TIVA development platform with Energia Framework - $ platformio install titiva --with-package=framework-energiativa + $ platformio install atmelavr timsp430 titiva # Process example project $ platformio run diff --git a/examples/wiring-blink/console-result.png b/examples/wiring-blink/console-result.png index 1ca159258d..bf22625f32 100644 Binary files a/examples/wiring-blink/console-result.png and b/examples/wiring-blink/console-result.png differ diff --git a/examples/wiring-blink/platformio.ini b/examples/wiring-blink/platformio.ini index 5cf7ab39d5..096d1349ed 100644 --- a/examples/wiring-blink/platformio.ini +++ b/examples/wiring-blink/platformio.ini @@ -16,3 +16,4 @@ board = lpmsp430g2553 platform = titiva framework = energia board = lplm4f120h5qr +build_flags = "-DLED_PIN=GREEN_LED" diff --git a/examples/wiring-blink/src/main.c b/examples/wiring-blink/src/main.c index a86fe00919..a97b51567e 100644 --- a/examples/wiring-blink/src/main.c +++ b/examples/wiring-blink/src/main.c @@ -8,27 +8,22 @@ with intervals of 1 second (1000 milliseconds) */ -#ifdef ENERGIA - -#include "Energia.h" -#define WLED RED_LED - -#else - #include "Arduino.h" -#define WLED 13 // Most Arduino boards already have an LED attached to pin 13 on the board itself +#ifndef LED_PIN +#define LED_PIN 13 // Most Arduino boards already have an LED attached to pin 13 on the board itself #endif + void setup() { - pinMode(WLED, OUTPUT); // set pin as output + pinMode(LED_PIN, OUTPUT); // set pin as output } void loop() { - digitalWrite(WLED, HIGH); // set the LED on - delay(1000); // wait for a second - digitalWrite(WLED, LOW); // set the LED off - delay(1000); // wait for a second + digitalWrite(LED_PIN, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(LED_PIN, LOW); // set the LED off + delay(1000); // wait for a second } diff --git a/platformio/__init__.py b/platformio/__init__.py index d8f50a348a..6ad01aad28 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (0, 2, 0) +VERSION = (0, 3, 0) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/__main__.py b/platformio/__main__.py index a7a74f2a41..3b9be17444 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -35,7 +35,7 @@ def get_command(self, ctx, name): @command(cls=PlatformioCLI) -@version_option(__version__) +@version_option(__version__, "platformio") def cli(): pass diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 47e1594191..15b0dab8b5 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -16,6 +16,7 @@ ("PIOENV",), ("PLATFORM",), ("FRAMEWORK",), + ("BUILD_FLAGS",), # board options ("BOARD",), diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index fdc03f53f6..05b4f6b02e 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -26,9 +26,9 @@ ASFLAGS=[ "-g", # include debugging info (so errors include line numbers) "-x", "assembler-with-cpp", - "-mmcu=$BOARD_MCU", - "-DF_CPU=$BOARD_F_CPU" + "-mmcu=$BOARD_MCU" ], + CCFLAGS=[ "-g", # include debugging info (so errors include line numbers) "-Os", # optimize for size @@ -36,11 +36,15 @@ "-ffunction-sections", # place each function in its own section "-fdata-sections", "-MMD", # output dependancy info - "-mmcu=$BOARD_MCU", - "-DF_CPU=$BOARD_F_CPU" + "-mmcu=$BOARD_MCU" ], + CXXFLAGS=["-fno-exceptions"], + CPPDEFINES=[ + "F_CPU=$BOARD_F_CPU" + ], + LINKFLAGS=[ "-Os", "-Wl,--gc-sections", @@ -62,6 +66,9 @@ UPLOADEEPCMD="$UPLOADER $UPLOADERFLAGS -U eeprom:w:$SOURCES:i" ) +if "BUILD_FLAGS" in env: + env.MergeFlags(env['BUILD_FLAGS']) + env.Append( BUILDERS=dict( ElfToEep=Builder( diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index 345b5a301e..18bd7ae3ca 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -19,18 +19,14 @@ ARDUINO_VERSION = int( open(join(env.subst("$PLATFORMFW_DIR"), "version.txt")).read().replace(".", "").strip()) -ARDUINO_FLAGS = [ - "-DARDUINO=%d" % ARDUINO_VERSION, - "-DARDUINO_%s" % BOARD_OPTIONS['build.board'] -] # usb flags +ARDUINO_USBDEFINES = [] if "build.usb_product" in BOARD_OPTIONS: - ARDUINO_FLAGS += [ - "-DUSB_VID=%s" % BOARD_OPTIONS['build.vid'], - "-DUSB_PID=%s" % BOARD_OPTIONS['build.pid'], - "-DUSB_PRODUCT=%s" % BOARD_OPTIONS['build.usb_product'].replace( - '"', "") + ARDUINO_USBDEFINES = [ + "USB_VID=%s" % BOARD_OPTIONS['build.vid'], + "USB_PID=%s" % BOARD_OPTIONS['build.pid'], + "USB_PRODUCT=%s" % BOARD_OPTIONS['build.usb_product'].replace('"', "") ] # include board variant @@ -40,8 +36,10 @@ ) env.Append( - ASFLAGS=ARDUINO_FLAGS, - CCFLAGS=ARDUINO_FLAGS, + CPPDEFINES=[ + "ARDUINO=%d" % ARDUINO_VERSION, + "ARDUINO_%s" % BOARD_OPTIONS['build.board'] + ] + ARDUINO_USBDEFINES, CPPPATH=[ join("$BUILD_DIR", "core"), join("$BUILD_DIR", "variant") diff --git a/platformio/builder/scripts/frameworks/energia.py b/platformio/builder/scripts/frameworks/energia.py index 4169b084e9..e86a7b5d8e 100644 --- a/platformio/builder/scripts/frameworks/energia.py +++ b/platformio/builder/scripts/frameworks/energia.py @@ -19,10 +19,6 @@ ENERGIA_VERSION = int( open(join(env.subst("$PLATFORMFW_DIR"), "version.txt")).read().replace(".", "").strip()) -ENERGIA_FLAGS = [ - "-DARDUINO=101", - "-DENERGIA=%d" % ENERGIA_VERSION -] # include board variant env.VariantDir( @@ -31,8 +27,10 @@ ) env.Append( - ASFLAGS=ENERGIA_FLAGS, - CCFLAGS=ENERGIA_FLAGS, + CPPDEFINES=[ + "ARDUINO=101", + "ENERGIA=%d" % ENERGIA_VERSION + ], CPPPATH=[ join("$BUILD_DIR", "core"), join("$BUILD_DIR", "variant") diff --git a/platformio/builder/scripts/timsp430.py b/platformio/builder/scripts/timsp430.py index d251de3b02..4578de998a 100644 --- a/platformio/builder/scripts/timsp430.py +++ b/platformio/builder/scripts/timsp430.py @@ -28,9 +28,9 @@ ASFLAGS=[ "-g", # include debugging info (so errors include line numbers) "-x", "-assembler-with-cpp", - "-mmcu=$BOARD_MCU", - "-DF_CPU=$BOARD_F_CPU" + "-mmcu=$BOARD_MCU" ], + CCFLAGS=[ "-g", # include debugging info (so errors include line numbers) "-Os", # optimize for size @@ -38,8 +38,11 @@ "-ffunction-sections", # place each function in its own section "-fdata-sections", "-MMD", # output dependancy info - "-mmcu=$BOARD_MCU", - "-DF_CPU=$BOARD_F_CPU" + "-mmcu=$BOARD_MCU" + ], + + CPPDEFINES=[ + "F_CPU=$BOARD_F_CPU" ], LINK="$CC", @@ -57,6 +60,9 @@ UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"' ) +if "BUILD_FLAGS" in env: + env.MergeFlags(env['BUILD_FLAGS']) + env.Append( BUILDERS=dict( ElfToHex=Builder( diff --git a/platformio/builder/scripts/titiva.py b/platformio/builder/scripts/titiva.py index c23ba8a6cb..c5ad725fb8 100644 --- a/platformio/builder/scripts/titiva.py +++ b/platformio/builder/scripts/titiva.py @@ -31,8 +31,7 @@ "-mcpu=cortex-m4", "-mfloat-abi=hard", "-mfpu=fpv4-sp-d16", - "-fsingle-precision-constant", - "-DF_CPU=$BOARD_F_CPU" + "-fsingle-precision-constant" ], CCFLAGS=[ @@ -47,8 +46,7 @@ "-mfloat-abi=hard", "-mfpu=fpv4-sp-d16", "-fsingle-precision-constant", - "-MMD", # output dependancy info - "-DF_CPU=$BOARD_F_CPU" + "-MMD" # output dependancy info ], CXXFLAGS=[ @@ -56,6 +54,10 @@ "-fno-exceptions" ], + CPPDEFINES=[ + "F_CPU=$BOARD_F_CPU" + ], + LINKFLAGS=[ "-Os", "-nostartfiles", @@ -73,6 +75,9 @@ UPLOADCMD="$UPLOADER $SOURCES" ) +if "BUILD_FLAGS" in env: + env.MergeFlags(env['BUILD_FLAGS']) + env.Append( BUILDERS=dict( ElfToBin=Builder( diff --git a/platformio/commands/install.py b/platformio/commands/install.py index e45013142c..09f75500e3 100644 --- a/platformio/commands/install.py +++ b/platformio/commands/install.py @@ -7,13 +7,15 @@ @command("install", short_help="Install new platforms") -@argument("platform") +@argument("platforms", nargs=-1) @option('--with-package', multiple=True, metavar="") @option('--without-package', multiple=True, metavar="") -def cli(platform, with_package, without_package): +def cli(platforms, with_package, without_package): - p = PlatformFactory().newPlatform(platform) + for platform in platforms: - if p.install(with_package, without_package): - secho("The platform '%s' has been successfully installed!" % platform, - fg="green") + p = PlatformFactory().newPlatform(platform) + + if p.install(with_package, without_package): + secho("The platform '%s' has been successfully installed!" % + platform, fg="green") diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 8c1c470c4f..5f88253f29 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -3,7 +3,7 @@ from click import command, echo, option, secho, style -from platformio.exception import ProjecEnvsNotAvaialable, UndefinedEnvPlatform +from platformio.exception import ProjectEnvsNotAvaialable, UndefinedEnvPlatform from platformio.platforms._base import PlatformFactory from platformio.util import get_project_config @@ -16,7 +16,7 @@ def cli(environment, target): config = get_project_config() if not config.sections(): - raise ProjecEnvsNotAvaialable() + raise ProjectEnvsNotAvaialable() for section in config.sections(): if section[:4] != "env:": diff --git a/platformio/commands/uninstall.py b/platformio/commands/uninstall.py index 13f09e694b..92c5b0cf6a 100644 --- a/platformio/commands/uninstall.py +++ b/platformio/commands/uninstall.py @@ -9,13 +9,15 @@ @command("uninstall", short_help="Uninstall the platforms") -@argument("platform") -def cli(platform): +@argument("platforms", nargs=-1) +def cli(platforms): - if platform not in PackageManager.get_installed(): - raise PlatformNotInstalledYet(platform) + for platform in platforms: - p = PlatformFactory().newPlatform(platform) - if p.uninstall(): - secho("The platform '%s' has been successfully " - "uninstalled!" % platform, fg="green") + if platform not in PackageManager.get_installed(): + raise PlatformNotInstalledYet(platform) + + p = PlatformFactory().newPlatform(platform) + if p.uninstall(): + secho("The platform '%s' has been successfully " + "uninstalled!" % platform, fg="green") diff --git a/platformio/exception.py b/platformio/exception.py index 7709870d2b..e58b35b3d9 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -63,7 +63,7 @@ class FDSHASumMismatch(PlatformioException): class NotPlatformProject(PlatformioException): - MESSAGE = "Not a platformio project. Use `platformio init` command" + MESSAGE = "Not a PlatformIO project. Use `platformio init` command" class UndefinedEnvPlatform(PlatformioException): @@ -82,6 +82,6 @@ class ProjectInitialized(PlatformioException): "Process it with `platformio run` command") -class ProjecEnvsNotAvaialable(PlatformioException): +class ProjectEnvsNotAvaialable(PlatformioException): MESSAGE = "Please setup environments in `platformio.ini` file." diff --git a/platformio/projectconftpl.ini b/platformio/projectconftpl.ini index 2d43649700..18348f52d9 100644 --- a/platformio/projectconftpl.ini +++ b/platformio/projectconftpl.ini @@ -11,6 +11,11 @@ #[env:mybaseenv] #platform = %INSTALLED_PLATFORM_NAME_HERE% +# Environment with specific build flags +#[env:specbuildflags] +#platform = %INSTALLED_PLATFORM_NAME_HERE% +#build_flags = "-I/opt/include -L/opt/lib -lfoo -DMYDEFINE=13" + # # Atmel AVR based board # diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py new file mode 100644 index 0000000000..79bf85d748 --- /dev/null +++ b/scripts/get-platformio.py @@ -0,0 +1,120 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +import os +import sys +from subprocess import check_output +from tempfile import NamedTemporaryFile + + +CURINTERPRETER_PATH = os.path.normpath(sys.executable) +IS_WINDOWS = sys.platform.startswith("win") + + +def fix_winpython_pathenv(): + """ + Add Python & Python Scripts to the search path on Windows + """ + import ctypes + from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM, LPVOID + try: + import _winreg as winreg + except ImportError: + import winreg + + # took these lines from the native "win_add2path.py" + pythonpath = os.path.dirname(CURINTERPRETER_PATH) + scripts = os.path.join(pythonpath, "Scripts") + + with winreg.CreateKey(winreg.HKEY_CURRENT_USER, u"Environment") as key: + try: + envpath = winreg.QueryValueEx(key, u"PATH")[0] + except WindowsError: + envpath = u"%PATH%" + + paths = [envpath] + for path in (pythonpath, scripts): + if path and path not in envpath and os.path.isdir(path): + paths.append(path) + + envpath = os.pathsep.join(paths) + winreg.SetValueEx(key, u"PATH", 0, winreg.REG_EXPAND_SZ, envpath) + winreg.ExpandEnvironmentStrings(envpath) + + # notify the system about the changes + SendMessage = ctypes.windll.user32.SendMessageW + SendMessage.argtypes = HWND, UINT, WPARAM, LPVOID + SendMessage.restype = LPARAM + SendMessage(0xFFFF, 0x1A, 0, u"Environment") + return True + + +def exec_python_cmd(args): + return check_output([CURINTERPRETER_PATH] + args, shell=IS_WINDOWS).strip() + + +def install_pip(): + try: + from urllib2 import urlopen + except ImportError: + from urllib.request import urlopen + + f = NamedTemporaryFile(delete=False) + response = urlopen("https://bootstrap.pypa.io/get-pip.py") + f.write(response.read()) + f.close() + + try: + print (exec_python_cmd([f.name])) + finally: + os.unlink(f.name) + + +def install_pypi_packages(packages): + for p in packages: + print (exec_python_cmd(["-m", "pip", "install", "-U"] + p.split())) + + +def main(): + steps = [ + ("Fixing Windows %PATH% Environment", fix_winpython_pathenv, []), + ("Installing Python Package Manager", install_pip, []), + ("Installing PlatformIO and dependencies", install_pypi_packages, + (["platformio", "--egg scons"],)), + ] + + if not IS_WINDOWS: + del steps[0] + + is_error = False + for s in steps: + print ("\n==> %s ..." % s[0]) + try: + s[1](*s[2]) + print ("[SUCCESS]") + except Exception, e: + is_error = True + print (e) + print ("[FAILURE]") + + if is_error: + print ("The installation process has been FAILED!\n" + "Please report about this problem here\n" + "< https://github.com/ivankravets/platformio/issues >") + return + else: + print ("\n ==> Installation process has been " + "successfully FINISHED! <==\n") + + try: + print (check_output("platformio", shell=IS_WINDOWS)) + except: + try: + print (exec_python_cmd(["-m", "platformio"])) + finally: + print ("\n Please RESTART your Terminal Application and run " + "`platformio --help` command.") + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/setup.py b/setup.py index dae1ed807e..2850082816 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. +from sys import platform as sysplatform + from setuptools import find_packages, setup from platformio import (__author__, __description__, __email__, __license__, @@ -17,11 +19,10 @@ license=__license__, install_requires=[ "click", - "colorama", "pyserial", "requests", # "SCons" - ], + ] + (["colorama"] if sysplatform.startswith("win") else []), packages=find_packages(), package_data={"platformio": ["*.ini"]}, entry_points={