diff --git a/.gitignore b/.gitignore index dfcb0c78..89257136 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ docs/_build dist build +.cache diff --git a/HISTORY.rst b/HISTORY.rst index ec59872a..fe6d261e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,22 @@ Release Notes PlatformIO 2.0 -------------- +2.11.0 (2016-06-28) +~~~~~~~~~~~~~~~~~~~ + +* New ESP8266-based boards: Generic ESP8285 Module, Phoenix 1.0 & 2.0, WifInfo +* Added support for Arduino M0 Pro board + (`issue #472 `_) +* Added support for Arduino MKR1000 board + (`issue #620 `_) +* Added support for Adafruit Feather M0, SparkFun SAMD21 and SparkFun SAMD21 + Mini Breakout boards + (`issue #520 `_) +* Updated Arduino ESP8266 core for Espressif platform to 2.3.0 +* Better removing unnecessary flags using ``build_unflags`` option + (`issue #698 `_) +* Fixed issue with ``platformio init --ide`` command for Python 2.6 + 2.10.3 (2016-06-15) ~~~~~~~~~~~~~~~~~~~ diff --git a/README.rst b/README.rst index 7976f9ac..391214f2 100644 --- a/README.rst +++ b/README.rst @@ -198,8 +198,9 @@ Contributing 6. Make changes to code, documentation, etc. 7. Lint source code ``tox -e lint`` 8. Run the tests ``tox -e py27`` -9. Commit changes to your forked repository -10. Submit a Pull Request on GitHub. +9. Build documentation ``tox -e docs`` (creates a directory _build under docs where you can find the html) +10. Commit changes to your forked repository +11. Submit a Pull Request on GitHub. Licence ------- diff --git a/docs/articles.rst b/docs/articles.rst index 8791784c..3dbe604c 100644 --- a/docs/articles.rst +++ b/docs/articles.rst @@ -23,6 +23,10 @@ Here are recent articles about PlatformIO: 2016 ^^^^ +* Jun 14, 2016 - **Glyn Hudson** - `OpenEnergyMonitor Part 2/3: Firmware Continuous Test & Build `_ +* Jun 13, 2016 - **Daniel Eichhorn** - `New Weather Station Demo on Github `_ +* Jun 12, 2016 - **Glyn Hudson** - `OpenEnergyMonitor Part 1/3: PlatformIO open-source embedded development ecosystem `_ +* Jun 12, 2016 - **Uli Wolf** - `Nutzung von PlatformIO im Atom Editor zur Entwicklung von Arduino Code (Use PlatformIO and Atom Editor to develop Arduino code, German) `_ * Jun 3, 2016 - **Daniel Eichhorn** - `ESP8266: Continuous Delivery Pipeline – Push To Production `_ * May 30, 2016 - **Ron Moerman** - `IoT Development with PlatformIO `_ * May 29, 2016 - **Chris Synan** - `Reverse Engineer RF Remote Controller for IoT! `_ diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index f7a4877a..db5b6d92 100644 --- a/docs/frameworks/arduino.rst +++ b/docs/frameworks/arduino.rst @@ -1211,7 +1211,7 @@ OpenEnergyMonitor - RAM * - ``emonpi`` - - `emonPi `_ + - `OpenEnergyMonitor emonPi `_ - ATMEGA328P - 16 MHz - 32 Kb diff --git a/docs/librarymanager/creating.rst b/docs/librarymanager/creating.rst index efbfc32f..2fe3dbbd 100644 --- a/docs/librarymanager/creating.rst +++ b/docs/librarymanager/creating.rst @@ -20,6 +20,9 @@ source code structure. The only one requirement is library's manifest file - :ref:`library_config`. It can be located inside your library or in the another location where |PIOAPICR| will have *HTTP* access. +Updates to existing libraries are done every 24 hours. In case a more urgent +update is required, you can post a request on PlatformIO `community `_. + .. contents:: Source Code Location @@ -152,6 +155,12 @@ to :ref:`install ` it. Examples -------- +Command: + +.. code-block:: bash + + $ platformio lib register http://my.example.com/library.json + * `GitHub + fixed release `_ * `Dependencies by author and framework `_ * `Multiple libraries in the one repository `_ diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index 58185e7c..fb181900 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -826,7 +826,7 @@ OpenEnergyMonitor - RAM * - ``emonpi`` - - `emonPi `_ + - `OpenEnergyMonitor emonPi `_ - ATMEGA328P - 16 MHz - 32 Kb diff --git a/docs/platforms/embedded_boards.rst b/docs/platforms/embedded_boards.rst index 23721690..bd52ca0c 100644 --- a/docs/platforms/embedded_boards.rst +++ b/docs/platforms/embedded_boards.rst @@ -1576,7 +1576,7 @@ OpenEnergyMonitor - RAM * - ``emonpi`` - - `emonPi `_ + - `OpenEnergyMonitor emonPi `_ - ATMEGA328P - 16 MHz - 32 Kb diff --git a/docs/platforms/espressif_extra.rst b/docs/platforms/espressif_extra.rst index fd04de77..65d7356a 100644 --- a/docs/platforms/espressif_extra.rst +++ b/docs/platforms/espressif_extra.rst @@ -240,6 +240,7 @@ Using Arduino Framework with Staging version Articles -------- +* 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! `_ * May 22, 2016 - **Pedro Minatel** - `Estação meteorológica com ESP8266 (Weather station with ESP8266, Portuguese) `_ diff --git a/platformio/__init__.py b/platformio/__init__.py index 0f8db754..7931da16 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 10, 3) +VERSION = (2, 11, 0) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/boards/adafruit.json b/platformio/boards/adafruit.json index 6200608e..fc5ef21c 100644 --- a/platformio/boards/adafruit.json +++ b/platformio/boards/adafruit.json @@ -248,5 +248,35 @@ }, "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 index dab169e5..6baf0751 100644 --- a/platformio/boards/arduino.json +++ b/platformio/boards/arduino.json @@ -885,7 +885,7 @@ "disable_flushing": true, "maximum_ram_size": 32768, "maximum_size": 262144, - "protocol": "sam-ba", + "protocol": "openocd", "require_upload_port" : false, "use_1200bps_touch": false, "wait_for_upload_port": false @@ -923,5 +923,68 @@ }, "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", + "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", + "ldscript": "samd21g18a_bootloader_org.ld", + "hwids": [ + ["0x03EB", "0x2111"], + ["0x2A03", "0x804F"] + ] + }, + "frameworks": ["arduino"], + "name": "Arduino M0 Pro (Programming Port)", + "platform": "atmelsam", + "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" } } diff --git a/platformio/boards/espressif.json b/platformio/boards/espressif.json index a3db71e2..3c9d21be 100644 --- a/platformio/boards/espressif.json +++ b/platformio/boards/espressif.json @@ -358,7 +358,7 @@ "d1": { "build": { "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_NODEMCU", + "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DESP8266_WEMOS_D1MINI", "f_cpu": "80000000L", "f_flash": "40000000L", "flash_mode": "dio", @@ -383,7 +383,7 @@ "d1_mini": { "build": { "core": "esp8266", - "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_NODEMCU", + "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DESP8266_WEMOS_D1MINI", "f_cpu": "80000000L", "f_flash": "40000000L", "flash_mode": "dio", @@ -478,5 +478,105 @@ }, "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/misc.json b/platformio/boards/misc.json index a8cc9e5a..114e8022 100644 --- a/platformio/boards/misc.json +++ b/platformio/boards/misc.json @@ -52,7 +52,7 @@ "variant": "standard" }, "frameworks": ["arduino"], - "name": "emonPi", + "name": "OpenEnergyMonitor emonPi", "platform": "atmelavr", "upload": { "maximum_ram_size": 2048, diff --git a/platformio/boards/sparkfun.json b/platformio/boards/sparkfun.json index 44d5cb52..b14a9ab9 100644 --- a/platformio/boards/sparkfun.json +++ b/platformio/boards/sparkfun.json @@ -238,5 +238,67 @@ }, "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" } -} \ No newline at end of file +} diff --git a/platformio/builder/scripts/atmelsam.py b/platformio/builder/scripts/atmelsam.py index 5fa5cd4b..8fe0a0c7 100644 --- a/platformio/builder/scripts/atmelsam.py +++ b/platformio/builder/scripts/atmelsam.py @@ -25,14 +25,6 @@ from platformio.util import get_serialports def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - board_type = env.subst("$BOARD") - if "zero" not in board_type: - env.Append( - UPLOADERFLAGS=[ - "-U", - "true" if ("usb" in board_type.lower( - ) or board_type == "digix") else "false" - ]) upload_options = env.get("BOARD_OPTIONS", {}).get("upload", {}) @@ -48,7 +40,8 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports)) # use only port name for BOSSA - if "/" in env.subst("$UPLOAD_PORT"): + if ("/" in env.subst("$UPLOAD_PORT") and + env.subst("$UPLOAD_PROTOCOL") == "sam-ba"): env.Replace(UPLOAD_PORT=basename(env.subst("$UPLOAD_PORT"))) @@ -56,41 +49,8 @@ env = DefaultEnvironment() SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) -if env.subst("$BOARD") == "zero": - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-openocd", "bin", "openocd"), - UPLOADERFLAGS=[ - "-d2", - "-s", - join( - "$PIOPACKAGES_DIR", - "tool-openocd", "share", "openocd", "scripts"), - "-f", - join( - "$PLATFORMFW_DIR", "variants", - "${BOARD_OPTIONS['build']['variant']}", "openocd_scripts", - "${BOARD_OPTIONS['build']['variant']}.cfg" - ), - "-c", "\"telnet_port", "disabled;", - "program", "{{$SOURCES}}", - "verify", "reset", "0x00002000;", "shutdown\"" - ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' - ) -else: - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"), - UPLOADERFLAGS=[ - "--info", - "--port", '"$UPLOAD_PORT"', - "--erase", - "--write", - "--verify", - "--reset", - "--debug" - ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES' - ) +BOARD_OPTIONS = env.get("BOARD_OPTIONS", {}) + env.Append( @@ -120,8 +80,21 @@ env.Append( ] ) +user_code_section = BOARD_OPTIONS.get("upload", {}).get("section_start", False) -if "sam3x8e" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu", None): +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" @@ -137,7 +110,7 @@ if "sam3x8e" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu", None): ] ) -elif "zero" in env.subst("$BOARD"): +elif "samd" in BOARD_OPTIONS.get("build", {}).get("mcu", ""): env.Append( LINKFLAGS=[ "--specs=nosys.specs", @@ -145,6 +118,62 @@ elif "zero" in env.subst("$BOARD"): ] ) + +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", + "-s", join( + "$PIOPACKAGES_DIR", + "tool-openocd", + "share", + "openocd", + "scripts" + ), + + "-f", join( + "$PLATFORMFW_DIR", + "variants", + "${BOARD_OPTIONS['build']['variant']}", + "openocd_scripts", + "${BOARD_OPTIONS['build']['variant']}.cfg" + ), + + "-c", "\"telnet_port", "disabled;", + "program", "{{$SOURCES}}", + "verify", "reset", + "%s;" % user_code_section if user_code_section else "0x2000", + "shutdown\"" + ], + + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' + ) + +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' + ) + # # Target: Build executable and linkable firmware # @@ -171,7 +200,7 @@ AlwaysBuild(target_size) # Target: Upload by default .bin file # -if env.subst("$BOARD") == "zero": +if upload_protocol == "openocd": upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") else: upload = env.Alias( diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 7c167489..d9cef77b 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -82,8 +82,7 @@ env.Replace( "-falign-functions=4", "-U__STRICT_ANSI__", "-ffunction-sections", - "-fdata-sections", - "-MMD" # output dependancy info + "-fdata-sections" ], CXXFLAGS=[ diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index a81d29b3..21be9b6a 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -60,8 +60,11 @@ elif env.get("PLATFORM") == "espressif": join("$PLATFORMFW_DIR", "tools", "sdk", "lwip", "include") ], LIBPATH=[join("$PLATFORMFW_DIR", "tools", "sdk", "lib")], - LIBS=["mesh", "wpa2", "smartconfig", "pp", "main", "wpa", "lwip", - "net80211", "wps", "crypto", "phy", "hal", "axtls", "gcc", "m"] + LIBS=[ + "mesh", "wpa2", "smartconfig", "pp", "main", "wpa", "lwip", + "net80211", "wps", "crypto", "phy", "hal", "axtls", "gcc", + "m", "stdc++" + ] ) env.VariantDirWrap( join("$BUILD_DIR", "generic"), diff --git a/platformio/builder/scripts/frameworks/mbed.py b/platformio/builder/scripts/frameworks/mbed.py index 2b1bd2ad..3c7dc2e0 100644 --- a/platformio/builder/scripts/frameworks/mbed.py +++ b/platformio/builder/scripts/frameworks/mbed.py @@ -163,7 +163,7 @@ def add_mbedlib(libname, libar): continue if "TARGET_" in root: - if all([p not in root.upper() for p in target_includes]): + if all([p not in root for p in target_includes]): continue var_dir = join("$BUILD_DIR", "FrameworkMbed%sInc%d" % @@ -264,13 +264,12 @@ env.Replace( ) # restore external build flags -env.ProcessFlags([ - env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_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")]) +env.ProcessFlags(env.get("BUILD_FLAGS")) # Hook for K64F and K22F if board_type in ("frdm_k22f", "frdm_k64f"): diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 1fa62f93..a848ea0e 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -122,8 +122,8 @@ def ConvertInoToCpp(env): remove(file_) except: # pylint: disable=bare-except if isfile(file_): - print ("Warning: Could not remove temporary file '%s'. " - "Please remove it manually." % 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"))) @@ -202,9 +202,7 @@ def DumpIDEData(env): def get_defines(env_): defines = [] # global symbols - for item in env_.get("CPPDEFINES", []): - if isinstance(item, list): - item = "=".join(item) + for item in env.Flatten(env_.get("CPPDEFINES", [])): defines.append(env_.subst(item).replace('\\"', '"')) # special symbol for Atmel AVR MCU @@ -232,9 +230,7 @@ def DumpIDEData(env): # https://github.com/platformio/platformio-atom-ide/issues/34 _new_defines = [] - for item in env_.get("CPPDEFINES", []): - if isinstance(item, list): - item = "=".join(item) + for item in env.Flatten(env_.get("CPPDEFINES", [])): item = item.replace('\\"', '"') if " " in item: _new_defines.append(item.replace(" ", "\\\\ ")) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 01b50f57..e1b599c8 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -36,12 +36,9 @@ SRC_DEFAULT_FILTER = " ".join([ def BuildProgram(env): def _append_pio_macros(): - if any(["PLATFORMIO=" in str(d) for d in env.get("CPPDEFINES", [])]): - return - env.Append( + env.AppendUnique( CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( - *pioversion_to_intstr())], - ) + *pioversion_to_intstr())]) _append_pio_macros() @@ -53,13 +50,12 @@ def BuildProgram(env): ) # process extra flags from board - env.ProcessFlags([ - env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_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")]) + env.ProcessFlags(env.get("BUILD_FLAGS")) if env.get("FRAMEWORK"): env.BuildFrameworks([ @@ -88,7 +84,7 @@ def BuildProgram(env): ) # Handle SRC_BUILD_FLAGS - env.ProcessFlags([env.get("SRC_BUILD_FLAGS", None)]) + env.ProcessFlags(env.get("SRC_BUILD_FLAGS")) env.Append( CPPPATH=["$PROJECTSRC_DIR"], @@ -117,18 +113,17 @@ def BuildProgram(env): def ProcessFlags(env, flags): - for f in flags: - if not f: + if not flags: + return + parsed_flags = env.ParseFlags(str(flags)) + for flag in parsed_flags.pop("CPPDEFINES"): + if not isinstance(flag, list): + env.Append(CPPDEFINES=flag) continue - parsed_flags = env.ParseFlags(str(f)) - for flag in parsed_flags.pop("CPPDEFINES"): - if not isinstance(flag, list): - env.Append(CPPDEFINES=flag) - continue - if '\"' in flag[1]: - flag[1] = flag[1].replace('\"', '\\\"') - env.Append(CPPDEFINES=[flag]) - env.Append(**parsed_flags) + if '\"' in flag[1]: + flag[1] = flag[1].replace('\"', '\\\"') + env.Append(CPPDEFINES=[flag]) + env.Append(**parsed_flags) # fix relative CPPPATH & LIBPATH for k in ("CPPPATH", "LIBPATH"): @@ -153,10 +148,17 @@ def ProcessFlags(env, flags): def ProcessUnFlags(env, flags): if not flags: return - for var, values in env.ParseFlags(flags).items(): - for v in values: - if v in env[var]: - env[var].remove(v) + parsed_flags = env.ParseFlags(flags) + all_flags = [] + for items in parsed_flags.values(): + all_flags.extend(items) + all_flags = set(all_flags) + + for key in parsed_flags.keys(): + cur_flags = set(env.get(key, [])) + for item in cur_flags & all_flags: + while item in env[key]: + env[key].remove(item) def IsFileWithExt(env, file_, ext): # pylint: disable=W0613 diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 894e8182..44e3b8ea 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -52,6 +52,8 @@ def cli(): 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 r = None r = util.exec_command(cmd) diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 2afd9d40..b4be53a3 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -66,7 +66,12 @@ class ProjectGenerator(object): envdata = self.get_project_env() if "env_name" not in envdata: return data - cmd = [normpath(sys.executable), "-m", "platformio", "-f"] + cmd = [ + normpath(sys.executable), "-m", + "platformio" + ( + ".__main__" if sys.version_info < (2, 7, 0) else ""), + "-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']])