From 349b159a7b23b2c2d2ec54b719f501d831d2b043 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 23 May 2016 22:28:48 +0300 Subject: [PATCH 001/119] Move boards and platforms to separate repos // Issue #479 --- platformio/boards/adafruit.json | 252 ----- platformio/boards/arduino.json | 927 ------------------ platformio/boards/atmelsam.json | 50 - platformio/boards/digistump.json | 107 -- platformio/boards/engduino.json | 86 -- platformio/boards/espressif.json | 476 --------- platformio/boards/freescalekinetis.json | 114 --- platformio/boards/intel.json | 30 - platformio/boards/lattice.json | 45 - platformio/boards/microchippic32.json | 577 ----------- platformio/boards/microduino.json | 197 ---- platformio/boards/mightycore.json | 155 --- platformio/boards/misc.json | 742 -------------- platformio/boards/nordicnrf51.json | 182 ---- platformio/boards/nxplpc.json | 210 ---- platformio/boards/punchthrough.json | 22 - platformio/boards/raspberrypi.json | 52 - platformio/boards/siliconlabsefm32.json | 103 -- platformio/boards/sparkfun.json | 242 ----- platformio/boards/ststm32.json | 625 ------------ platformio/boards/teensy.json | 95 -- platformio/boards/timsp430.json | 164 ---- platformio/boards/titiva.json | 59 -- platformio/builder/scripts/__init__.py | 13 - platformio/builder/scripts/atmelavr.py | 168 ---- platformio/builder/scripts/atmelsam.py | 189 ---- platformio/builder/scripts/basearm.py | 97 -- platformio/builder/scripts/baseavr.py | 98 -- platformio/builder/scripts/espressif.py | 357 ------- .../builder/scripts/frameworks/__init__.py | 13 - .../builder/scripts/frameworks/arduino.py | 339 ------- .../builder/scripts/frameworks/cmsis.py | 93 -- .../builder/scripts/frameworks/energia.py | 74 -- .../builder/scripts/frameworks/libopencm3.py | 191 ---- platformio/builder/scripts/frameworks/mbed.py | 289 ------ .../builder/scripts/frameworks/simba.py | 35 - platformio/builder/scripts/frameworks/spl.py | 119 --- .../builder/scripts/frameworks/wiringpi.py | 65 -- .../builder/scripts/freescalekinetis.py | 61 -- platformio/builder/scripts/intel_arc32.py | 200 ---- platformio/builder/scripts/lattice_ice40.py | 149 --- platformio/builder/scripts/linux_arm.py | 60 -- platformio/builder/scripts/linux_i686.py | 60 -- platformio/builder/scripts/linux_x86_64.py | 60 -- platformio/builder/scripts/microchippic32.py | 190 ---- platformio/builder/scripts/native.py | 44 - platformio/builder/scripts/nordicnrf51.py | 77 -- platformio/builder/scripts/nxplpc.py | 70 -- .../builder/scripts/siliconlabsefm32.py | 61 -- platformio/builder/scripts/ststm32.py | 113 --- platformio/builder/scripts/teensy.py | 115 --- platformio/builder/scripts/timsp430.py | 127 --- platformio/builder/scripts/titiva.py | 74 -- platformio/builder/scripts/windows_x86.py | 65 -- .../commands/{platforms.py => platform.py} | 0 .../{pkgmanager.py => managers/package.py} | 0 .../base.py => managers/platform.py} | 0 platformio/platforms/__init__.py | 13 - platformio/platforms/atmelavr.py | 74 -- platformio/platforms/atmelsam.py | 61 -- platformio/platforms/espressif.py | 68 -- platformio/platforms/freescalekinetis.py | 42 - platformio/platforms/intel_arc32.py | 45 - platformio/platforms/lattice_ice40.py | 43 - platformio/platforms/linux_arm.py | 59 -- platformio/platforms/linux_i686.py | 43 - platformio/platforms/linux_x86_64.py | 43 - platformio/platforms/microchippic32.py | 46 - platformio/platforms/native.py | 29 - platformio/platforms/nordicnrf51.py | 58 -- platformio/platforms/nxplpc.py | 44 - platformio/platforms/siliconlabsefm32.py | 47 - platformio/platforms/ststm32.py | 71 -- platformio/platforms/teensy.py | 69 -- platformio/platforms/timsp430.py | 50 - platformio/platforms/titiva.py | 54 - platformio/platforms/windows_x86.py | 35 - 77 files changed, 10172 deletions(-) delete mode 100644 platformio/boards/adafruit.json delete mode 100644 platformio/boards/arduino.json delete mode 100644 platformio/boards/atmelsam.json delete mode 100644 platformio/boards/digistump.json delete mode 100644 platformio/boards/engduino.json delete mode 100644 platformio/boards/espressif.json delete mode 100644 platformio/boards/freescalekinetis.json delete mode 100644 platformio/boards/intel.json delete mode 100755 platformio/boards/lattice.json delete mode 100644 platformio/boards/microchippic32.json delete mode 100644 platformio/boards/microduino.json delete mode 100644 platformio/boards/mightycore.json delete mode 100644 platformio/boards/misc.json delete mode 100644 platformio/boards/nordicnrf51.json delete mode 100644 platformio/boards/nxplpc.json delete mode 100644 platformio/boards/punchthrough.json delete mode 100644 platformio/boards/raspberrypi.json delete mode 100644 platformio/boards/siliconlabsefm32.json delete mode 100644 platformio/boards/sparkfun.json delete mode 100644 platformio/boards/ststm32.json delete mode 100644 platformio/boards/teensy.json delete mode 100644 platformio/boards/timsp430.json delete mode 100644 platformio/boards/titiva.json delete mode 100644 platformio/builder/scripts/__init__.py delete mode 100644 platformio/builder/scripts/atmelavr.py delete mode 100644 platformio/builder/scripts/atmelsam.py delete mode 100644 platformio/builder/scripts/basearm.py delete mode 100644 platformio/builder/scripts/baseavr.py delete mode 100644 platformio/builder/scripts/espressif.py delete mode 100644 platformio/builder/scripts/frameworks/__init__.py delete mode 100644 platformio/builder/scripts/frameworks/arduino.py delete mode 100644 platformio/builder/scripts/frameworks/cmsis.py delete mode 100644 platformio/builder/scripts/frameworks/energia.py delete mode 100644 platformio/builder/scripts/frameworks/libopencm3.py delete mode 100644 platformio/builder/scripts/frameworks/mbed.py delete mode 100755 platformio/builder/scripts/frameworks/simba.py delete mode 100644 platformio/builder/scripts/frameworks/spl.py delete mode 100644 platformio/builder/scripts/frameworks/wiringpi.py delete mode 100644 platformio/builder/scripts/freescalekinetis.py delete mode 100644 platformio/builder/scripts/intel_arc32.py delete mode 100755 platformio/builder/scripts/lattice_ice40.py delete mode 100644 platformio/builder/scripts/linux_arm.py delete mode 100644 platformio/builder/scripts/linux_i686.py delete mode 100644 platformio/builder/scripts/linux_x86_64.py delete mode 100644 platformio/builder/scripts/microchippic32.py delete mode 100644 platformio/builder/scripts/native.py delete mode 100644 platformio/builder/scripts/nordicnrf51.py delete mode 100644 platformio/builder/scripts/nxplpc.py delete mode 100644 platformio/builder/scripts/siliconlabsefm32.py delete mode 100644 platformio/builder/scripts/ststm32.py delete mode 100644 platformio/builder/scripts/teensy.py delete mode 100644 platformio/builder/scripts/timsp430.py delete mode 100644 platformio/builder/scripts/titiva.py delete mode 100644 platformio/builder/scripts/windows_x86.py rename platformio/commands/{platforms.py => platform.py} (100%) rename platformio/{pkgmanager.py => managers/package.py} (100%) rename platformio/{platforms/base.py => managers/platform.py} (100%) delete mode 100644 platformio/platforms/__init__.py delete mode 100644 platformio/platforms/atmelavr.py delete mode 100644 platformio/platforms/atmelsam.py delete mode 100644 platformio/platforms/espressif.py delete mode 100644 platformio/platforms/freescalekinetis.py delete mode 100644 platformio/platforms/intel_arc32.py delete mode 100755 platformio/platforms/lattice_ice40.py delete mode 100644 platformio/platforms/linux_arm.py delete mode 100644 platformio/platforms/linux_i686.py delete mode 100644 platformio/platforms/linux_x86_64.py delete mode 100644 platformio/platforms/microchippic32.py delete mode 100644 platformio/platforms/native.py delete mode 100644 platformio/platforms/nordicnrf51.py delete mode 100644 platformio/platforms/nxplpc.py delete mode 100644 platformio/platforms/siliconlabsefm32.py delete mode 100644 platformio/platforms/ststm32.py delete mode 100644 platformio/platforms/teensy.py delete mode 100644 platformio/platforms/timsp430.py delete mode 100644 platformio/platforms/titiva.py delete mode 100644 platformio/platforms/windows_x86.py diff --git a/platformio/boards/adafruit.json b/platformio/boards/adafruit.json deleted file mode 100644 index 9fb2dda4..00000000 --- a/platformio/boards/adafruit.json +++ /dev/null @@ -1,252 +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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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" - } -} diff --git a/platformio/boards/arduino.json b/platformio/boards/arduino.json deleted file mode 100644 index 602c066e..00000000 --- a/platformio/boards/arduino.json +++ /dev/null @@ -1,927 +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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["0x2341", "0x804D"], - ["0x03EB", "0x2157"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino Zero (Programming Port)", - "platform": "atmelsam", - "upload": { - "disable_flushing": true, - "maximum_ram_size": 32768, - "maximum_size": 262144, - "protocol": "sam-ba", - "require_upload_port" : false, - "use_1200bps_touch": false, - "wait_for_upload_port": false - }, - "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", - "hwid": [ - ["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" - } -} diff --git a/platformio/boards/atmelsam.json b/platformio/boards/atmelsam.json deleted file mode 100644 index bb2561ee..00000000 --- a/platformio/boards/atmelsam.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "samr21_xpro": { - "build": { - "f_cpu": "48000000L", - "cpu": "cortex-m0plus", - "mcu": "atsamr21g18a" - }, - "frameworks": ["mbed"], - "name": "Atmel ATSAMR21-XPRO", - "platform": "atmelsam", - "upload": { - "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", - "upload": { - "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", - "upload": { - "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 24634358..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", - "hwid": [ - ["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 5e7c1c48..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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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 691b4dc6..00000000 --- a/platformio/boards/espressif.json +++ /dev/null @@ -1,476 +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" - }, - "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" - }, - "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 -DARDUINO_ESP8266_NODEMCU", - "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 -DARDUINO_ESP8266_NODEMCU", - "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" - } -} 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 e74bdd39..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", - "usb_product": "Genuino 101", - "variant": "arduino_101", - "hwid": [ - ["0x8087", "0x0AB6"] - ] - }, - "frameworks": ["arduino"], - "name": "Arduino/Genuino 101", - "platform": "intel_arc32", - "upload": { - "maximum_ram_size": 81920, - "maximum_size": 196608, - "use_1200bps_touch": true, - "protocol": "script", - "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": false - }, - "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 ce31a2e4..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", - "hwid": [ - ["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", - "hwid": [ - ["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 b5a949be..00000000 --- a/platformio/boards/microchippic32.json +++ /dev/null @@ -1,577 +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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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": "cchipKIT-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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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": "Default_64" - }, - "frameworks": ["arduino"], - "name": "PONTECH UAV100", - "platform": "microchippic32", - "upload": { - "maximum_ram_size": 32768, - "maximum_size": 520192, - "protocol": "stk500v2", - "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "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": "MZ-application-32MZ2048ECX.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, - "wait_for_upload_port": true - }, - "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, - "wait_for_upload_port": true - }, - "url": "http://shop.openbci.com/", - "vendor": "OpenBCI" - } -} diff --git a/platformio/boards/microduino.json b/platformio/boards/microduino.json deleted file mode 100644 index 64e88ec5..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", - "hwid": [ - ["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 bbff9241..00000000 --- a/platformio/boards/misc.json +++ /dev/null @@ -1,742 +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" - }, - - "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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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" - } -} 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 6bf11499..00000000 --- a/platformio/boards/sparkfun.json +++ /dev/null @@ -1,242 +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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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", - "hwid": [ - ["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" - } -} \ No newline at end of file diff --git a/platformio/boards/ststm32.json b/platformio/boards/ststm32.json deleted file mode 100644 index 187d811f..00000000 --- a/platformio/boards/ststm32.json +++ /dev/null @@ -1,625 +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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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 - }, - "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" - }, - "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 ca46ffad..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": "msp430g2553", - "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": "msp430g2553", - "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/scripts/__init__.py b/platformio/builder/scripts/__init__.py deleted file mode 100644 index 0c05c3b0..00000000 --- a/platformio/builder/scripts/__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/atmelavr.py b/platformio/builder/scripts/atmelavr.py deleted file mode 100644 index daff63af..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") == "raspduino": - - def _rpi_sysgpio(path, value): - with open(path, "w") as f: - f.write(str(value)) - - _rpi_sysgpio("/sys/class/gpio/export", 18) - _rpi_sysgpio("/sys/class/gpio/gpio18/direction", "out") - _rpi_sysgpio("/sys/class/gpio/gpio18/value", 1) - sleep(0.1) - _rpi_sysgpio("/sys/class/gpio/gpio18/value", 0) - _rpi_sysgpio("/sys/class/gpio/unexport", 18) - else: - if not upload_options.get("disable_flushing", False): - env.FlushSerialBuffer("$UPLOAD_PORT") - - before_ports = [i['port'] for i in 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 d91b0bf0..00000000 --- a/platformio/builder/scripts/atmelsam.py +++ /dev/null @@ -1,189 +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, Default, - DefaultEnvironment, SConscript) - -from platformio.util import get_serialports - - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - env.AutodetectUploadPort() - - 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", {}) - - if not upload_options.get("disable_flushing", False): - env.FlushSerialBuffer("$UPLOAD_PORT") - - before_ports = [i['port'] for i in 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"): - env.Replace(UPLOAD_PORT=basename(env.subst("$UPLOAD_PORT"))) - - -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' - ) - -env.Append( - - CCFLAGS=[ - "--param", "max-inline-insns-single=500", - "-MMD" - ], - - CFLAGS=[ - "-std=gnu11" - ], - - CXXFLAGS=[ - "-std=gnu++11", - "-fno-threadsafe-statics" - ], - - CPPDEFINES=[ - "USBCON", - 'USB_MANUFACTURER="PlatformIO"' - ], - - LINKFLAGS=[ - "-Wl,--check-sections", - "-Wl,--unresolved-symbols=report-all", - "-Wl,--warn-common", - "-Wl,--warn-section-align" - ] -) - - -if "sam3x8e" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu", None): - env.Append( - CPPDEFINES=[ - "printf=iprintf" - ], - - LINKFLAGS=[ - "-Wl,--entry=Reset_Handler", - "-Wl,--start-group" - ], - - UPLOADERFLAGS=[ - "--boot", - ] - - ) -elif "zero" in env.subst("$BOARD"): - env.Append( - LINKFLAGS=[ - "--specs=nosys.specs", - "--specs=nano.specs" - ] - ) - -# -# 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 env.subst("$BOARD") == "zero": - upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") -else: - upload = env.Alias(["upload", "uploadlazy"], target_firm, - [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 8f74ca71..00000000 --- a/platformio/builder/scripts/espressif.py +++ /dev/null @@ -1,357 +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", - "-MMD" # output dependancy info - ], - - 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, - [lambda target, source, env: 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 d3170687..00000000 --- a/platformio/builder/scripts/frameworks/arduino.py +++ /dev/null @@ -1,339 +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( - 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", - "net80211", "wps", "crypto", "phy", "hal", "axtls", "gcc", "m"] - ) - 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']}" - ) - ] - ) - -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']['hwid'][0][0]}", - "USB_PID=${BOARD_OPTIONS['build']['hwid'][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 - ] -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", "CMSIS", "Include") - ) - env.VariantDirWrap( - join("$BUILD_DIR", "FrameworkDeviceInc"), - join("$PLATFORMFW_DIR", "system", "CMSIS", "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) - -# -# 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 24b04dbe..00000000 --- a/platformio/builder/scripts/frameworks/mbed.py +++ /dev/null @@ -1,289 +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 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": "NRF51822" -} - -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.keys(): - 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" - ) - - for root, _, files in walk(lib_dir): - if (not any(f.endswith(".h") for f in files) and - basename(root) not in sysincdirs): - 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) - - 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.get("BOARD_OPTIONS", {}).get("platform") != "ststm32"): - 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) - -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])) -) - -# restore external build flags -env.ProcessFlags([ - env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags"), - 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/simba.py b/platformio/builder/scripts/frameworks/simba.py deleted file mode 100755 index 52c875e4..00000000 --- a/platformio/builder/scripts/frameworks/simba.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. - -"""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 - -env = DefaultEnvironment() - -env.Replace( - PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-simba") -) - -SConscript( - [env.subst(join("$PLATFORMFW_DIR", "make", "platformio.sconscript"))]) 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 e5db85d8..00000000 --- a/platformio/builder/scripts/intel_arc32.py +++ /dev/null @@ -1,200 +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) - - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - - if "program" in COMMAND_LINE_TARGETS: - return - - env.AutodetectUploadPort() - env.Prepend(UPLOADERFLAGS=['"$UPLOAD_PORT"']) - - if env.get("BOARD_OPTIONS", {}).get("upload", {}).get( - "use_1200bps_touch", False): - env.TouchSerialPort("$UPLOAD_PORT", 1200) - - -env = DefaultEnvironment() - -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", - "-mav2em", - "-mlittle-endian", - "-m${BOARD_OPTIONS['build']['mcu']}", - "-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,-m${BOARD_OPTIONS['build']['mcu']}", - "-Wl,-marcelf", - "-static", - "-nostdlib", - "-nodefaultlibs", - "-nostartfiles", - "-Wl,--whole-archive", - "-larc32drv_arduino101", - "-Wl,--no-whole-archive" - ], - - LIBS=["c", "m", "gcc"], - - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - - UPLOADER=join("$PIOPACKAGES_DIR", "tool-arduino101load", "arduino101load"), - 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, [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 01695a96..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) - - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - - env.AutodetectUploadPort() - env.Prepend(UPLOADERFLAGS=["-d", '"$UPLOAD_PORT"']) - -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" - ], - - LIBS=["m"], - - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - - UPLOADER=join("$PIOPACKAGES_DIR", "tool-pic32prog", "pic32prog"), - UPLOADERFLAGS=[ - "-b", "$UPLOAD_SPEED" - ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES', - - PROGNAME="firmware", - PROGSUFFIX=".elf" -) - -if int(env.get("BOARD_OPTIONS", {}).get( - "upload", {}).get("maximum_ram_size", 0)) < 65535: - env.Append( - 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([ - "$OBJCOPY", - "-O", - "ihex", - "-R", - ".eeprom", - "$SOURCES", - "$TARGET"]), - 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(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, [BeforeUpload, "$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 a39e94fa..00000000 --- a/platformio/builder/scripts/nordicnrf51.py +++ /dev/null @@ -1,77 +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, 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' - ) - -# -# 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: - 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 .bin file -# - -if env.subst("$BOARD") == "rfduino": - upload = env.Alias( - ["upload", "uploadlazy"], target_firm, - [lambda target, source, env: 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 a3f5eed3..00000000 --- a/platformio/builder/scripts/nxplpc.py +++ /dev/null @@ -1,70 +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 shutil import copyfile - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - - -def UploadToDisk(target, source, env): # pylint: disable=W0613,W0621 - env.AutodetectUploadPort() - copyfile(join(env.subst("$BUILD_DIR"), "firmware.bin"), - join(env.subst("$UPLOAD_PORT"), "firmware.bin")) - print("Firmware has been successfully uploaded.\n" - "Please restart your board.") - -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, 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 34eee8d8..00000000 --- a/platformio/builder/scripts/ststm32.py +++ /dev/null @@ -1,113 +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 43e293f3..00000000 --- a/platformio/builder/scripts/teensy.py +++ /dev/null @@ -1,115 +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=[ - "USB_SERIAL", - "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/commands/platforms.py b/platformio/commands/platform.py similarity index 100% rename from platformio/commands/platforms.py rename to platformio/commands/platform.py diff --git a/platformio/pkgmanager.py b/platformio/managers/package.py similarity index 100% rename from platformio/pkgmanager.py rename to platformio/managers/package.py diff --git a/platformio/platforms/base.py b/platformio/managers/platform.py similarity index 100% rename from platformio/platforms/base.py rename to platformio/managers/platform.py diff --git a/platformio/platforms/__init__.py b/platformio/platforms/__init__.py deleted file mode 100644 index 0c05c3b0..00000000 --- a/platformio/platforms/__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/platforms/atmelavr.py b/platformio/platforms/atmelavr.py deleted file mode 100644 index 62fef55d..00000000 --- a/platformio/platforms/atmelavr.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. - -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": { - "alias": "uploader" - }, - - "tool-micronucleus": { - "alias": "uploader" - }, - - "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")) - disable_tool = "tool-micronucleus" - if "digispark" in board['build']['core']: - disable_tool = "tool-avrdude" - del self.PACKAGES[disable_tool]['alias'] - - 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 0e8d7da2..00000000 --- a/platformio/platforms/atmelsam.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. - -from platformio.platforms.base import BasePlatform - - -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": { - "alias": "uploader" - }, - - "tool-openocd": { - "alias": "uploader" - } - } - - def get_name(self): - return "Atmel SAM" 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/native.py b/platformio/platforms/native.py deleted file mode 100644 index 9c4ed8bb..00000000 --- a/platformio/platforms/native.py +++ /dev/null @@ -1,29 +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 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 = { - } diff --git a/platformio/platforms/nordicnrf51.py b/platformio/platforms/nordicnrf51.py deleted file mode 100644 index b68e240b..00000000 --- a/platformio/platforms/nordicnrf51.py +++ /dev/null @@ -1,58 +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-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 - } - } From d68eb2862985cba157ca5ae3343374b71eaa466b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 26 May 2016 19:43:36 +0300 Subject: [PATCH 002/119] Decentralized architecture for development platforms // Issue #479 --- .isort.cfg | 2 +- HISTORY.rst | 11 + docs/ci/circleci.rst | 4 +- docs/demo.rst | 12 +- docs/index.rst | 6 +- docs/platforms/creating_board.rst | 6 +- docs/platforms/creating_platform.rst | 12 +- docs/platforms/index.rst | 6 +- docs/projectconf.rst | 6 +- docs/userguide/cmd_boards.rst | 7 +- docs/userguide/cmd_update.rst | 4 +- docs/userguide/index.rst | 4 +- docs/userguide/platforms/cmd_install.rst | 18 +- docs/userguide/platforms/cmd_list.rst | 49 +- docs/userguide/platforms/cmd_search.rst | 145 +++-- docs/userguide/platforms/cmd_show.rst | 81 ++- docs/userguide/platforms/cmd_uninstall.rst | 14 +- docs/userguide/platforms/cmd_update.rst | 78 ++- docs/userguide/platforms/index.rst | 8 +- docs/what-is-platformio.rst | 4 +- platformio/__init__.py | 4 +- platformio/__main__.py | 14 +- platformio/builder/main.py | 60 +- platformio/builder/tools/devplatform.py | 107 ++++ platformio/builder/tools/piomisc.py | 41 +- platformio/builder/tools/pioupload.py | 12 +- platformio/builder/tools/platformio.py | 16 +- platformio/commands/boards.py | 85 +-- platformio/commands/ci.py | 18 +- platformio/commands/init.py | 63 +- platformio/commands/platform.py | 232 +++---- platformio/commands/run.py | 4 +- platformio/commands/update.py | 7 +- platformio/exception.py | 15 +- platformio/maintenance.py | 111 ++-- platformio/managers/__init__.py | 13 + platformio/managers/package.py | 318 +++++++--- platformio/managers/platform.py | 682 ++++++++++----------- platformio/util.py | 28 +- setup.py | 4 +- 40 files changed, 1269 insertions(+), 1042 deletions(-) create mode 100644 platformio/builder/tools/devplatform.py create mode 100644 platformio/managers/__init__.py 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/HISTORY.rst b/HISTORY.rst index 8f8afef1..a9f78dca 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,17 @@ Release Notes ============= +PlatformIO 3.0 +-------------- + +3.0.0 (2016-??-??) +~~~~~~~~~~~~~~~~~~ + +* Decentralized architecture for development platforms: "platform.json", + semantic versioning, package dependencies, embedded board configs, isolated + build scripts + (`issue #479 `_) + PlatformIO 2.0 -------------- diff --git a/docs/ci/circleci.rst b/docs/ci/circleci.rst index ba6d6932..f8d4e333 100644 --- a/docs/ci/circleci.rst +++ b/docs/ci/circleci.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -152,7 +152,7 @@ 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: diff --git a/docs/demo.rst b/docs/demo.rst index e53a31fa..7d073458 100644 --- a/docs/demo.rst +++ b/docs/demo.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -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/index.rst b/docs/index.rst index b2f1fcca..ec3acee8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -58,7 +58,7 @@ Embedded Development. *Easier Than Ever.* * Built-in :ref:`Serial Port Monitor ` and configurable build :ref:`-flags/-options ` * Pre-built toolchains, :ref:`frameworks` for the - :ref:`Development Platforms ` + :ref:`platforms` Smart Build System. *Fast and Reliable.* ---------------------------------------- @@ -108,7 +108,7 @@ Contents :caption: Instruments :maxdepth: 3 - Platforms & Boards + platforms/index frameworks/index .. toctree:: diff --git a/docs/platforms/creating_board.rst b/docs/platforms/creating_board.rst index 60c6e2e5..b618498d 100644 --- a/docs/platforms/creating_board.rst +++ b/docs/platforms/creating_board.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -33,10 +33,10 @@ JSON Structure The key fields: -* ``build`` data will be used by :ref:`Platforms ` and +* ``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`` main type of :ref:`platforms` * ``upload`` upload settings which depend on the ``platform`` .. code-block:: json diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index 1b606a40..df7e803c 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -27,7 +27,7 @@ different/own build scripts, uploader and etc. .. note:: If you want to change some build flags for the existing - :ref:`Platforms `, you don't need to create (or duplicate) own + :ref:`platforms`, you don't need to create (or duplicate) own development platforms! Please use :ref:`projectconf_build_flags` option. **Step-by-Step Manual** @@ -361,9 +361,9 @@ 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 +3. Search available platforms via :ref:`cmd_platform_search` command. You should see ``test`` platform. -4. Install ``test`` platform via :ref:`cmd_platforms_install` command. +4. Install ``test`` platform via :ref:`cmd_platform_install` command. Now, you can use ``test`` for the :ref:`projectconf_env_platform` option in :ref:`projectconf`. @@ -480,6 +480,6 @@ and copy there two files: 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. +Now, we should see ``ststm32gdb`` platform using :ref:`cmd_platform_search` command output +and can install it via :ref:`platformio platform install ststm32gdb ` command. diff --git a/docs/platforms/index.rst b/docs/platforms/index.rst index 01b6df47..c02760aa 100644 --- a/docs/platforms/index.rst +++ b/docs/platforms/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -11,8 +11,8 @@ .. _platforms: -Platforms & Embedded Boards -=========================== +Development Platforms +===================== *PlatformIO* has pre-built different development platforms for popular OS (*Mac OS X, Linux (+ARM) and Windows*). Each of them include compiler, diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 0af9c5f5..145b241d 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -194,7 +194,7 @@ General options ``platform`` ^^^^^^^^^^^^ -:ref:`Platform ` type. +:ref:`platforms` name. .. _projectconf_env_framework: @@ -202,7 +202,7 @@ General options ``framework`` ^^^^^^^^^^^^^ -:ref:`Framework ` type. +:ref:`frameworks` name. The multiple frameworks are allowed, split them with comma ``,`` separator. diff --git a/docs/userguide/cmd_boards.rst b/docs/userguide/cmd_boards.rst index 83b7f86f..8083e8bb 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 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 @@ -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_update.rst b/docs/userguide/cmd_update.rst index 22a65099..d429bb0d 100644 --- a/docs/userguide/cmd_update.rst +++ b/docs/userguide/cmd_update.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -27,7 +27,7 @@ Usage Description ----------- -Check or update installed :ref:`Platforms ` and +Check or update installed :ref:`platforms` and :ref:`Libraries ` diff --git a/docs/userguide/index.rst b/docs/userguide/index.rst index d447a775..1d9851ab 100644 --- a/docs/userguide/index.rst +++ b/docs/userguide/index.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -62,7 +62,7 @@ Commands cmd_boards cmd_ci cmd_init - platformio platforms + platformio platform cmd_run cmd_serialports cmd_settings diff --git a/docs/userguide/platforms/cmd_install.rst b/docs/userguide/platforms/cmd_install.rst index fc36d9ed..b3753537 100644 --- a/docs/userguide/platforms/cmd_install.rst +++ b/docs/userguide/platforms/cmd_install.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -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,13 +21,13 @@ Usage .. code-block:: bash - platformio platforms install [OPTIONS] [PLATFORMS] + platformio platform install [OPTIONS] [PLATFORMS] Description ----------- -Install pre-built development :ref:`Platforms ` with related +Install pre-built development :ref:`platforms` with related packages. There are several predefined aliases for packages, such as: @@ -38,7 +38,7 @@ There are several predefined aliases for packages, such as: Options ------- -.. program:: platformio platforms install +.. program:: platformio platform install .. option:: --with-package @@ -63,7 +63,7 @@ Examples .. code-block:: bash - $ platformio platforms install timsp430 + $ platformio platform install timsp430 Installing toolchain-timsp430 package: Downloading [####################################] 100% Unpacking [####################################] 100% @@ -81,7 +81,7 @@ Examples .. code-block:: bash - $ platformio platforms install timsp430 --skip-default-package --with-package=uploader + $ platformio platform install timsp430 --skip-default-package --with-package=uploader Installing tool-mspdebug package: Downloading [####################################] 100% Unpacking [####################################] 100% diff --git a/docs/userguide/platforms/cmd_list.rst b/docs/userguide/platforms/cmd_list.rst index b1b9bb2d..aca7aec1 100644 --- a/docs/userguide/platforms/cmd_list.rst +++ b/docs/userguide/platforms/cmd_list.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -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,18 +21,18 @@ Usage .. code-block:: bash - platformio platforms list [OPTIONS] + platformio platform list [OPTIONS] Description ----------- -List installed :ref:`Platforms ` +List installed :ref:`platforms` Options ~~~~~~~ -.. program:: platformio platforms list +.. program:: platformio platform list .. option:: --json-output @@ -44,13 +44,28 @@ Examples .. code-block:: bash - $ 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 + + espressif ~ Espressif + ===================== + 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/espressif + Packages: framework-simba, tool-esptool, framework-arduinoespressif, 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 1f372518..96f1bf5e 100644 --- a/docs/userguide/platforms/cmd_search.rst +++ b/docs/userguide/platforms/cmd_search.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -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,18 +21,18 @@ Usage .. code-block:: bash - platformio platforms search QUERY [OPTIONS] + platformio platform search QUERY [OPTIONS] Description ----------- -Search for development :ref:`Platforms ` +Search for development :ref:`platforms` Options ~~~~~~~ -.. program:: platformio platforms search +.. program:: platformio platform search .. option:: --json-output @@ -47,73 +47,100 @@ Examples .. code-block:: bash - $ 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 + 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. - atmelsam (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - -------- - Atmel | SMART offers Flash- based ARM products based on the ... + Home: http://platformio.org/platforms/atmelavr + Packages: toolchain-atmelavr, framework-simba + Version: 0.0.0 - freescalekinetis (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ---------------- - Freescale Kinetis Microcontrollers is family of multiple hardware- and ... + 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. - nordicnrf51 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ----------- - The Nordic nRF51 Series is a family of highly flexible, multi-protocol ... + Home: http://platformio.org/platforms/atmelsam + Packages: framework-arduinosam, framework-mbed, framework-simba, toolchain-gccarmnoneeabi, tool-bossac + Version: 0.0.0 - nxplpc (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------ - The NXP LPC is a family of 32-bit microcontroller integrated circuits ... + espressif ~ Espressif + ===================== + 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. - 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 ... - - 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-arduinoespressif, sdk-esp8266, toolchain-xtensa + Version: 0.0.0 + ... 2. Search for TI development platforms .. code-block:: bash - $ 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 + 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. - 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/timsp430 + Packages: toolchain-timsp430, tool-mspdebug, framework-energiamsp430, framework-arduinomsp430 -3. Search for development platforms which support "mbed Framework" + 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. + + Home: http://platformio.org/platforms/titiva + Packages: ldscripts, framework-libopencm3, toolchain-gccarmnoneeabi, tool-lm4flash, framework-energiativa .. code-block:: bash - $ 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 ... + $ platformio platform search framework-mbed + 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. - nordicnrf51 (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ----------- - The Nordic nRF51 Series is a family of highly flexible, multi-protocol ... + Home: http://platformio.org/platforms/atmelsam + Packages: toolchain-gccarmnoneeabi, framework-arduinosam, framework-simba, tool-openocd, framework-mbed, ldscripts, tool-bossac - nxplpc (available packages: ldscripts, toolchain-gccarmnoneeabi, tool-lm4flash, framework-opencm3, framework-energiativa) - ------ - The NXP LPC is a family of 32-bit microcontroller integrated circuits ... + 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. - 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 ... + 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 20f005b0..114b4bce 100644 --- a/docs/userguide/platforms/cmd_show.rst +++ b/docs/userguide/platforms/cmd_show.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -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,13 +21,13 @@ Usage .. code-block:: bash - platformio platforms show PLATFORM + platformio platform show PLATFORM Description ----------- -Show details about the installed :ref:`Platforms ` +Show details about the installed :ref:`platforms` Examples @@ -35,22 +35,53 @@ Examples .. code-block:: bash - $ 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 a9e5411a..67cc273a 100644 --- a/docs/userguide/platforms/cmd_uninstall.rst +++ b/docs/userguide/platforms/cmd_uninstall.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -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,13 +21,13 @@ Usage .. code-block:: bash - platformio platforms uninstall PLATFORM + platformio platform uninstall PLATFORM Description ----------- -Uninstall specified :ref:`Platforms ` +Uninstall specified :ref:`platforms` Examples @@ -35,7 +35,7 @@ Examples .. code-block:: bash - $ platformio platforms uninstall timsp430 + $ platformio platform uninstall timsp430 Uninstalling toolchain-timsp430 package: [OK] Uninstalling tool-mspdebug package: [OK] Uninstalling framework-energiamsp430 package: [OK] diff --git a/docs/userguide/platforms/cmd_update.rst b/docs/userguide/platforms/cmd_update.rst index f8ba36c9..8e4fec64 100644 --- a/docs/userguide/platforms/cmd_update.rst +++ b/docs/userguide/platforms/cmd_update.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present 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 @@ -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,90 +21,100 @@ Usage .. code-block:: bash - platformio platforms update + platformio platform update Description ----------- -Check or update installed :ref:`Platforms ` +Check or update installed :ref:`platforms` +Options +------- + +.. program:: platformio platform update + +.. option:: + --only-packages + +Update only platform related packages. Do not update development platform +build scripts, board configs and etc. Examples -------- .. code-block:: bash - $ platformio platforms update + $ platformio platform update Platform atmelavr -------- Updating toolchain-atmelavr package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating tool-avrdude package: - Versions: Current=2, Latest=2 [Up-to-date] + Versions: Current=2, Latest=2 [Up-to-date] Updating framework-arduinoavr package: - Versions: Current=12, Latest=12 [Up-to-date] + Versions: Current=12, Latest=12 [Up-to-date] Updating tool-micronucleus package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Platform atmelsam -------- Updating framework-arduinosam package: - Versions: Current=3, Latest=3 [Up-to-date] + Versions: Current=3, Latest=3 [Up-to-date] Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating tool-bossac package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Platform stm32 -------- Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating tool-stlink package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating framework-spl package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating framework-cmsis package: - Versions: Current=2, Latest=2 [Up-to-date] + Versions: Current=2, Latest=2 [Up-to-date] Updating framework-opencm3 package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Platform teensy -------- Updating toolchain-atmelavr package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating framework-arduinoteensy package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating tool-teensy package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Platform timsp430 -------- Updating toolchain-timsp430 package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating tool-mspdebug package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating framework-energiamsp430 package: - Versions: Current=2, Latest=2 [Up-to-date] + Versions: Current=2, Latest=2 [Up-to-date] Platform titiva -------- Updating ldscripts package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating toolchain-gccarmnoneeabi package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating tool-lm4flash package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating framework-opencm3 package: - Versions: Current=1, Latest=1 [Up-to-date] + Versions: Current=1, Latest=1 [Up-to-date] Updating framework-energiativa package: - Versions: Current=4, Latest=4 [Up-to-date] + Versions: Current=4, Latest=4 [Up-to-date] diff --git a/docs/userguide/platforms/index.rst b/docs/userguide/platforms/index.rst index 1d084ccd..437826f1 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 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 @@ -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..f7849078 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 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 @@ -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/platformio/__init__.py b/platformio/__init__.py index d8d22716..fe5bd51c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ import sys -VERSION = (2, 9, "2.dev0") +VERSION = (3, 0, "0.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/__main__.py b/platformio/__main__.py index c553e8f6..a9d6b8b8 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -51,15 +51,9 @@ 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 raise AttributeError() diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 8b01c7b2..b4f00241 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,23 +22,18 @@ from time import time from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables from platformio import util -from platformio.exception import UnknownBoard # AllowSubstExceptions() # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( + ("PLATFORM_MANIFEST",), ("BUILD_SCRIPT",), ("EXTRA_SCRIPT",), ("PIOENV",), ("PLATFORM",), - # package aliases - ("PIOPACKAGE_TOOLCHAIN",), - ("PIOPACKAGE_FRAMEWORK",), - ("PIOPACKAGE_UPLOADER",), - # options ("FRAMEWORK",), ("BUILD_FLAGS",), @@ -67,9 +62,9 @@ commonvars.AddVariables( DefaultEnvironment( tools=[ "gcc", "g++", "as", "ar", "gnulink", - "platformio", "pioupload", "pioar", "piomisc" + "platformio", "devplatform", "pioupload", "pioar", "piomisc" ], - toolpath=[join("$PIOBUILDER_DIR", "tools")], + toolpath=[join(util.get_source_dir(), "builder", "tools")], variables=commonvars, # Propagating External Environment @@ -85,15 +80,11 @@ DefaultEnvironment( 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"), BUILDSRC_DIR=join("$BUILD_DIR", "src"), LIBSOURCE_DIRS=[ "$PROJECTLIB_DIR", - util.get_lib_dir(), - join("$PLATFORMFW_DIR", "libraries") + util.get_lib_dir() ], PYTHONEXE=normpath(sys.executable) @@ -106,58 +97,27 @@ for k in commonvars.keys(): if k in env: env[k] = base64.b64decode(env[k]) -env.Prepend(LIBPATH=[join("$PIOPACKAGES_DIR", "ldscripts")]) - -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"))) - +env.LoadDevPlatform(commonvars) +# Parse library names 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"): k = "PLATFORMIO_%s" % var if environ.get(k): env[var] = environ.get(k) + env.SConscriptChdir(0) env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite")) env.SConscript("$BUILD_SCRIPT") + if "UPLOAD_FLAGS" in env: env.Append(UPLOADERFLAGS=["$UPLOAD_FLAGS"]) diff --git a/platformio/builder/tools/devplatform.py b/platformio/builder/tools/devplatform.py new file mode 100644 index 00000000..ac5cda6d --- /dev/null +++ b/platformio/builder/tools/devplatform.py @@ -0,0 +1,107 @@ +# Copyright 2014-present 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 __future__ import absolute_import + +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 initDevPlatform(name): + return PlatformFactory.newPlatform(name) + + +def DevPlatform(env): + variables = {} + for key in ("board", "framework"): + if key not in env: + continue + variables[key] = env[key.upper()] + p = initDevPlatform(env['PLATFORM_MANIFEST']) + p.configure_default_packages(variables, COMMAND_LINE_TARGETS) + return p + + +def BoardConfig(env, board=None): + p = initDevPlatform(env['PLATFORM_MANIFEST']) + try: + config = p.board_config(board if board else env['BOARD']) + except exception.UnknownBoard as e: + env.Exit("Error: %s" % str(e)) + return config + + +def GetFrameworkScript(env, framework): + p = env.DevPlatform() + frameworks = p.get_frameworks() + assert frameworks and framework in frameworks + script_path = env.subst(frameworks[framework]['script']) + if not isfile(script_path): + script_path = join(p.get_dir(), script_path) + return script_path + + +def LoadDevPlatform(env, variables): + p = env.DevPlatform() + installed_packages = p.get_installed_packages() + + # Add toolchains and uploaders to $PATH + for name in installed_packages.keys(): + 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(DevPlatform) + env.AddMethod(BoardConfig) + env.AddMethod(GetFrameworkScript) + env.AddMethod(LoadDevPlatform) + return env diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 1fa62f93..396ef4b1 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 Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ from glob import glob from os import environ, listdir, remove from os.path import isdir, isfile, join -from platformio.util import exec_command, where_is_program +from platformio import util class InoToCPPConverter(object): @@ -143,8 +143,6 @@ def ConvertInoToCpp(env): def DumpIDEData(env): - BOARD_CORE = env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") - def get_includes(env_): includes = [] # includes from used framework and libs @@ -164,15 +162,18 @@ def DumpIDEData(env): lsd_dir = env_.subst(d) _append_lib_includes(env_, lsd_dir, includes) - # 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.DevPlatform() + for name in p.get_installed_packages().keys(): + 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 @@ -186,9 +187,10 @@ def DumpIDEData(env): if name in env_.get("LIB_IGNORE", []): continue if name == "__cores__": - if isdir(join(libs_dir, name, BOARD_CORE)): + board_core = env_.BoardConfig().get("build.core") + if isdir(join(libs_dir, name, board_core)): _append_lib_includes( - env_, join(libs_dir, name, BOARD_CORE), includes) + env_, join(libs_dir, name, board_core), includes) return include = ( @@ -208,10 +210,9 @@ 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.subst("$PLATFORM") == "atmelavr": defines.append( - "__AVR_%s__" % board['build']['mcu'].upper() + "__AVR_%s__" % env.BoardConfig().get("build.mcu").upper() .replace("ATMEGA", "ATmega") .replace("ATTINY", "ATtiny") ) @@ -226,7 +227,7 @@ def DumpIDEData(env): "includes": get_includes(env_), "cc_flags": env_.subst(LINTCCOM), "cxx_flags": env_.subst(LINTCXXCOM), - "cxx_path": where_is_program( + "cxx_path": util.where_is_program( env_.subst("$CXX"), env_.subst("${ENV['PATH']}")) } @@ -254,7 +255,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: diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index d1cd6dab..1b3ae2ac 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 Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -83,14 +83,16 @@ def AutodetectUploadPort(env): env.Replace(UPLOAD_PORT=item['disk']) break else: - board_build_opts = env.get("BOARD_OPTIONS", {}).get("build", {}) + board_hwids = [] + if "BOARD" in env and "build.hwids" in env.BoardConfig(): + board_hwids = env.BoardConfig().get("build.hwids") for item in get_serialports(): if "VID:PID" not in item['hwid']: continue env.Replace(UPLOAD_PORT=item['port']) - for hwid in board_build_opts.get("hwid", []): - board_hwid = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") - if board_hwid in item['hwid']: + for hwid in board_hwids: + hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") + if hwid_str in item['hwid']: break if "UPLOAD_PORT" in env: diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index f897d24a..10c93f6b 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 Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -43,9 +43,8 @@ def BuildProgram(env): ) # 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 @@ -208,20 +207,21 @@ def BuildFrameworks(env, frameworks): if not frameworks or "uploadlazy" in COMMAND_LINE_TARGETS: return - board_frameworks = env.get("BOARD_OPTIONS", {}).get("frameworks", []) + board_frameworks = [] + if "BOARD" in env: + 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") + env.Exit("Error: Please specify `board` in `platformio.ini`") 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) diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 0ccdfa6f..585ff84b 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # 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,30 @@ import json import click -from platformio.util import get_boards +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 @@ -48,45 +48,56 @@ def cli(query, json_output): # pylint: disable=R0912 click.secho(platform, bold=True) click.echo("-" * terminal_width) click.echo(BOARDLIST_TPL.format( - type=click.style("Type", fg="cyan"), mcu="MCU", + 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'])) + 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_registered_boards() + if installed: + _installed_boards = [ + "%s:%s" % (b['platform'], b['id']) + for b in PlatformManager().get_installed_boards() + ] + _new_boards = [] + for board in boards: + key = "%s:%s" % (board['platform'], board['id']) + if key in _installed_boards: + _new_boards.append(board) + boards = _new_boards + return boards + +def _ouput_boards_json(query, installed=False): + result = [] + for board in _get_boards(installed): 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 602ef67d..f18f077c 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ import click from platformio import app 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 def validate_path(ctx, param, value): # pylint: disable=W0613 @@ -45,22 +45,12 @@ 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("--exclude", multiple=True) -@click.option("--board", "-b", multiple=True, callback=validate_boards) +@click.option("--board", "-b", 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)) diff --git a/platformio/commands/init.py b/platformio/commands/init.py index d9b48288..c0837fad 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,21 +19,26 @@ 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.commands.platform import \ + platform_install as cli_platform_install from platformio.ide.projectgenerator import ProjectGenerator -from platformio.platforms.base import PlatformFactory -from platformio.util import get_boards, get_source_dir +from platformio.managers.platform import PlatformManager def validate_boards(ctx, param, value): # pylint: disable=W0613 - unknown_boards = set(value) - set(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 " + "%s. Please search for the board ID using " "`platformio boards` command" % ", ".join(unknown_boards)) @@ -41,7 +46,7 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613 @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", +@click.option("--board", "-b", multiple=True, metavar="ID", callback=validate_boards) @click.option("--ide", type=click.Choice(ProjectGenerator.get_supported_ides())) @@ -90,9 +95,9 @@ 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)), + "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( @@ -115,7 +120,7 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 def init_base_project(project_dir): platformio_ini = join(project_dir, "platformio.ini") if not isfile(platformio_ini): - copyfile(join(get_source_dir(), "projectconftpl.ini"), + copyfile(join(util.get_source_dir(), "projectconftpl.ini"), platformio_ini) lib_dir = join(project_dir, "lib") @@ -246,7 +251,7 @@ 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 """) @@ -258,9 +263,9 @@ def init_cvs_ignore(project_dir): def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals - ctx, platformio_ini, board_types, enable_auto_uploading, + ctx, platformio_ini, board_ids, enable_auto_uploading, env_prefix, force_download): - builtin_boards = get_boards() + installed_boards = PlatformManager().get_installed_boards() content = [] used_boards = [] used_platforms = [] @@ -272,23 +277,30 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals 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 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_) + content.append("board = %s" % id_) if enable_auto_uploading: content.append("targets = upload") @@ -304,10 +316,11 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals 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, + cli_platform_install, platforms=list(set(platforms) - set(installed_platforms)) ) diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 70af83b3..2a159f02 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,31 +13,76 @@ # 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 +from platformio import app, exception, util +from platformio.managers.platform import PlatformFactory, PlatformManager -@click.group(short_help="Platforms and Packages Manager") +@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 platforms") +@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 + + # @TODO update API with NAME/TITLE + platforms.append({ + "name": platform['type'], + "title": platform['name'], + "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 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): +def platform_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): + _platform = platform + _version = None + if "@" in platform: + _platform, _version = platform.rsplit("@", 1) + if PlatformManager().install(_platform, _version, 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 " @@ -47,123 +92,96 @@ def platforms_install(platforms, with_package, without_package, @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() +def platform_list(json_output): + platforms = [] + for manifest in PlatformManager().get_installed(): + p = PlatformFactory.newPlatform(manifest['_manifest_path']) + platforms.append({ + "name": p.get_name(), + "title": p.get_title(), + "description": p.get_description(), + "version": p.get_version(), + "packages": p.get_installed_packages().keys() }) if json_output: - click.echo(json.dumps(data)) + click.echo(json.dumps(platforms)) else: - for item in data: - click.echo("{name:<20} with packages: {pkgs}".format( - name=click.style(item['name'], fg="cyan"), - pkgs=", ".join(item['packages']) - )) + _print_platforms(platforms) -@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") +@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: +def platform_show(ctx, platform): + try: + p = PlatformFactory.newPlatform(platform) + except exception.UnknownPlatform: 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]) + ctx.invoke(platform_install, platforms=[platform]) else: - raise PlatformNotInstalledYet(platform) + raise exception.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())) + click.echo("{name} ~ {title}".format( + name=click.style(p.get_name(), fg="cyan"), title=p.get_title())) + click.echo("=" * (3 + len(p.get_name() + p.get_title()))) + click.echo(p.get_manifest().get("description")) + click.echo() + click.echo("Version: %s" % p.get_version()) + if "homepage" in p.get_manifest(): + click.echo("Home: %s" % p.get_manifest().get("homepage")) + if "license" in p.get_manifest(): + click.echo("License: %s" % p.get_manifest().get("license").get("type")) + if "frameworks" in p.get_manifest(): + click.echo("Frameworks: %s" % + ", ".join(p.get_manifest().get("frameworks").keys())) - 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")) + if not p.get_packages(): + return + + installed_pkgs = p.get_installed_packages() + for name, opts in p.get_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)) @cli.command("uninstall", short_help="Uninstall platforms") @click.argument("platforms", nargs=-1, required=True) -def platforms_uninstall(platforms): - +def platform_uninstall(platforms): for platform in platforms: - p = PlatformFactory.newPlatform(platform) - if p.uninstall(): + _platform = platform + _version = None + if "@" in platform: + _platform, _version = platform.rsplit("@", 1) + if PlatformManager().uninstall(_platform, _version): 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")) +@cli.command("update", short_help="Update installed Platforms") +@click.option("--only-packages", is_flag=True) +def platform_update(only_packages): + for manifest in PlatformManager().get_installed(): + click.echo("Platform %s @ %s" % ( + click.style(manifest['name'], fg="cyan"), manifest['version'])) click.echo("--------") - p = PlatformFactory.newPlatform(platform) - p.update() + if only_packages: + status = PlatformFactory.newPlatform( + manifest['name'], manifest['version']).update_packages() + if status is None: + click.secho("Packages are up-to-date", fg="green") + else: + PlatformManager().update(manifest['name'], manifest['version']) + click.echo() diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 0834edf0..e32654ef 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import click from platformio import app, 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.managers.platform import PlatformFactory @click.command("run", short_help="Process project environments") diff --git a/platformio/commands/update.py b/platformio/commands/update.py index 52627a7a..42830dc2 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # 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,13 @@ 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 @click.command("update", short_help="Update installed Platforms, Packages and Libraries") @click.pass_context def cli(ctx): - ctx.invoke(cmd_platforms_update) + ctx.invoke(cmd_platform_update) click.echo() ctx.invoke(cmd_lib_update) diff --git a/platformio/exception.py b/platformio/exception.py index 78059eb2..ce3d7cc6 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ class BoardNotDefined(PlatformioException): class UnknownBoard(PlatformioException): - MESSAGE = "Unknown board type '{0}'" + MESSAGE = "Unknown board ID '{0}'" class UnknownFramework(PlatformioException): @@ -70,9 +70,16 @@ class UnknownPackage(PlatformioException): MESSAGE = "Detected unknown package '{0}'" -class InvalidPackageVersion(PlatformioException): +class UndefinedPackageVersion(PlatformioException): - MESSAGE = "The package '{0}' with version '{1:d}' does not exist" + MESSAGE = "Can not find package '{0}' with version requirements '{1}'"\ + " for your system '{2}'" + + +class PackageInstallError(PlatformioException): + + MESSAGE = "Can not install package '{0}' with version requirements '{1}' "\ + "for your system '{2}'" class NonSystemPackage(PlatformioException): diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 34395604..0e82bb58 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,23 +14,19 @@ import re import struct -from os import getenv, remove -from os.path import isdir, isfile, join -from shutil import rmtree +from os import getenv from time import time import click 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.platform import \ + platform_install as cmd_platform_install +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.platform import PlatformManager def in_silence(ctx): @@ -72,10 +68,9 @@ class Upgrader(object): self.from_version = self.version_to_int(from_version) self.to_version = self.version_to_int(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) - ) + self._upgraders = [ + (self.version_to_int("3.0.0"), self._upgrade_to_3_0_0) + ] @staticmethod def version_to_int(version): @@ -91,38 +86,16 @@ 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 = [] - - # remove platform's folder (obsolete package structure) - for name in PlatformFactory.get_platforms().keys(): - 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() + def _upgrade_to_3_0_0(self, ctx): # pylint: disable=R0201 + installed_platforms = app.get_state_item("installed_platforms", []) if installed_platforms: - ctx.invoke(cmd_platforms_install, platforms=installed_platforms) + ctx.invoke(cmd_platform_install, platforms=installed_platforms) return True @@ -131,10 +104,28 @@ def after_upgrade(ctx): if last_version == __version__: return - terminal_width, _ = click.get_terminal_size() + if last_version == "0.0.0": + app.set_state_item("last_version", __version__) + else: + click.secho("Please wait while upgrading PlatformIO ...", + fg="yellow") - # promotion - click.echo("") + u = Upgrader(last_version, __version__) + if u.run(ctx): + app.set_state_item("last_version", __version__) + ctx.invoke(cmd_platform_update, only_packages=True) + + 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") @@ -163,27 +154,6 @@ def after_upgrade(ctx): 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.echo("") - def check_platformio_upgrade(): last_check = app.get_state_item("last_check", {}) @@ -234,10 +204,11 @@ def check_internal_updates(ctx, what): outdated_items = [] if what == "platforms": - for platform in PlatformFactory.get_platforms(installed=True).keys(): - p = PlatformFactory.newPlatform(platform) - if p.is_outdated(): - outdated_items.append(platform) + pm = PlatformManager() + for manifest in pm.get_installed(): + if pm.is_outdated(manifest['name'], manifest['version']): + outdated_items.append( + "%s@%s" % (manifest['name'], manifest['version'])) elif what == "libraries": lm = LibraryManager() outdated_items = lm.get_outdated() @@ -255,13 +226,13 @@ def check_internal_updates(ctx, what): 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"), + ("lib" 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) elif what == "libraries": ctx.invoke(cmd_libraries_update) click.echo() diff --git a/platformio/managers/__init__.py b/platformio/managers/__init__.py new file mode 100644 index 00000000..5466a0e8 --- /dev/null +++ b/platformio/managers/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2014-present 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/managers/package.py b/platformio/managers/package.py index 33f74bb7..7654109f 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,38 +12,41 @@ # 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 +import os +from os.path import dirname, isdir, isfile, join from shutil import rmtree -from time import time import click import requests +import semantic_version 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) + _INSTALLED_CACHE = {} - @classmethod - @util.memoized - def get_manifest(cls): - return util.get_api_result("/packages/manifest") + def __init__(self, package_dir=None, repositories=None): + self._INSTALLED_CACHE = {} + self.repositories = repositories + self.package_dir = package_dir or join(util.get_home_dir(), "packages") + if not isdir(self.package_dir): + os.makedirs(self.package_dir) + assert isdir(self.package_dir) + + @staticmethod + def reset_cache(): + PackageManager._INSTALLED_CACHE = {} @staticmethod def download(url, dest_dir, sha1=None): fd = FileDownloader(url, dest_dir) fd.start() - fd.verify(sha1) + if sha1: + fd.verify(sha1) return fd.get_filepath() @staticmethod @@ -52,98 +55,180 @@ class PackageManager(object): return fu.start() @staticmethod - def get_installed(): - return get_state_item("installed_packages", {}) + def get_manifest_name(): + return "package.json" - 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 + @staticmethod + def max_satisfying_version(versions, requirements=None): + item = None 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 requirements is not None: + requirements = str(requirements) + for v in versions: + if isinstance(v['version'], int): + continue + if v['system'] not in ("all", "*") and systype not in v['system']: + continue + if requirements and not semantic_version.match( + requirements, v['version']): + continue + if item is None or semantic_version.compare( + v['version'], item['version']) == 1: + item = v + return item - 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 get_installed(self): + if self.package_dir in PackageManager._INSTALLED_CACHE: + return PackageManager._INSTALLED_CACHE[self.package_dir] + items = [] + for p in sorted(os.listdir(self.package_dir)): + manifest_path = join(self.package_dir, p, self.get_manifest_name()) + if not isfile(manifest_path): + continue + manifest = util.load_json(manifest_path) + manifest['_manifest_path'] = manifest_path + assert set(["name", "version"]) <= set(manifest.keys()) + items.append(manifest) + PackageManager._INSTALLED_CACHE[self.package_dir] = items + return items - def install(self, name): - click.echo("Installing %s package:" % click.style(name, fg="cyan")) + def is_installed(self, name, requirements=None): + installed = self.get_installed() + if requirements is None: + return any([p['name'] == name for p in installed]) - if self.is_installed(name): - click.secho("Already installed", fg="yellow") - return False + for p in installed: + if p['name'] != name: + continue + elif semantic_version.match(requirements, p['version']): + return True + return None - info = self.get_info(name) - pkg_dir = join(self._package_dir, name) - if not isdir(pkg_dir): - makedirs(pkg_dir) + def get_latest_version(self, name, requirements): + for versions in PackageRepoIterator(name, self.repositories): + pkgdata = self.max_satisfying_version(versions, requirements) + if pkgdata: + return pkgdata['version'] + return None - 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"): + def install(self, name, requirements, silent=False, trigger_event=True): + installed = self.is_installed(name, requirements) + if not installed or not silent: + click.echo("Installing package %s @ %s:" % ( + click.style(name, fg="cyan"), + requirements if requirements else "latest")) + if installed: + if not silent: + click.secho("Already installed", fg="yellow") + return + + if not self._install_from_piorepo(name, requirements): + raise exception.PackageInstallError( + name, requirements, util.get_systype()) + + self.reset_cache() + if trigger_event: + telemetry.on_event( + category="PackageManager", action="Install", label=name) + + def _install_from_piorepo(self, name, requirements): + pkg_dir = None + success = False + pkgdata = None + versions = None + for versions in PackageRepoIterator(name, self.repositories): + dlpath = None + pkgdata = self.max_satisfying_version(versions, requirements) + if not pkgdata: + continue + + pkg_dir = join(self.package_dir, name) + if isfile(join(pkg_dir, self.get_manifest_name())): + pkg_dir = join( + self.package_dir, "%s@%s" % (name, pkgdata['version'])) + + # remove previous/not-satisfied package + if isdir(pkg_dir): + rmtree(pkg_dir) + os.makedirs(pkg_dir) + + try: dlpath = self.download( - "http://dl.platformio.org/packages/%s" % - basename(info['url']), pkg_dir, info['sha1']) + pkgdata['url'], pkg_dir, pkgdata.get("sha1")) + assert isfile(dlpath) + self.unpack(dlpath, pkg_dir) + success = True + break + except Exception as e: # pylint: disable=broad-except + click.secho("Warning! Package Mirror: %s" % e, fg="yellow") + click.secho("Looking for other Package Mirror...", fg="yellow") + finally: + if dlpath and isfile(dlpath): + os.remove(dlpath) - assert isfile(dlpath) + if versions is None: + raise exception.UnknownPackage(name) + elif not pkgdata: + raise exception.UndefinedPackageVersion( + name, requirements, util.get_systype()) - if self.unpack(dlpath, pkg_dir): - self._register(name, info['version']) - # remove archive - remove(dlpath) + return success - telemetry.on_event( - category="PackageManager", action="Install", label=name) + def uninstall(self, name, requirements=None, trigger_event=True): + click.echo("Uninstalling package %s @ %s: \t" % ( + click.style(name, fg="cyan"), + requirements if requirements else "latest"), nl=False) + found = False + for manifest in self.get_installed(): + if manifest['name'] != name: + continue + if (requirements and not semantic_version.match( + requirements, manifest['version'])): + continue + found = True + if isfile(manifest['_manifest_path']): + rmtree(dirname(manifest['_manifest_path'])) - def uninstall(self, name): - click.echo("Uninstalling %s package: \t" % - click.style(name, fg="cyan"), nl=False) - - if not self.is_installed(name): + if not found: click.secho("Not installed", fg="yellow") return False + else: + click.echo("[%s]" % click.style("OK", fg="green")) - if isdir(join(self._package_dir, name)): - rmtree(join(self._package_dir, name)) - self._unregister(name) - click.echo("[%s]" % click.style("OK", fg="green")) + self.reset_cache() + if trigger_event: + telemetry.on_event( + category="PackageManager", action="Uninstall", label=name) - # report usage - telemetry.on_event( - category="PackageManager", action="Uninstall", label=name) + def update(self, name, requirements=None, keep_versions=None): + click.echo("Updating package %s @ %s:" % ( + click.style(name, fg="yellow"), + requirements if requirements else "latest")) - def update(self, name): - click.echo("Updating %s package:" % click.style(name, fg="yellow")) + latest_version = self.get_latest_version(name, requirements) + if latest_version is None: + click.secho("Ignored! '%s' is not listed in " + "Package Repository" % name, fg="yellow") + return - installed = self.get_installed() - current_version = installed[name]['version'] - latest_version = self.get_info(name)['version'] + current = None + other_versions = [] + for manifest in self.get_installed(): + if manifest['name'] != name: + continue + other_versions.append(manifest['version']) + if (requirements and not semantic_version.match( + requirements, manifest['version'])): + continue + if (not current or semantic_version.compare( + manifest['version'], current['version']) == 1): + current = manifest - click.echo("Versions: Current=%d, Latest=%d \t " % + if current is None: + return + + current_version = current['version'] + click.echo("Versions: Current=%s, Latest=%s \t " % (current_version, latest_version), nl=False) if current_version == latest_version: @@ -152,21 +237,52 @@ class PackageManager(object): else: click.echo("[%s]" % (click.style("Out-of-date", fg="red"))) - self.uninstall(name) - self.install(name) + for v in other_versions: + if not keep_versions or v not in keep_versions: + self.uninstall(name, v, trigger_event=False) + self.install(name, latest_version, trigger_event=False) telemetry.on_event( category="PackageManager", action="Update", label=name) + return True - 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) +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() diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 8486967d..2526ad29 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,251 +18,234 @@ import re import sys from imp import load_source from multiprocessing import cpu_count -from os.path import isdir, isfile, join +from os.path import basename, dirname, isdir, isfile, join import click +import semantic_version -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") - ] -} +from platformio import exception, util +from platformio.managers.package import PackageManager -def get_packages(): - return PLATFORM_PACKAGES +class PlatformManager(PackageManager): + + def __init__(self): + PackageManager.__init__( + self, + join(util.get_home_dir(), "platforms"), + ["http://dl.platformio.org/misc/platforms_manifest.json"] + ) + + @staticmethod + def get_manifest_name(): + return "platform.json" + + def find_best_platform(self, name, requirements=None): + best = None + for manifest in self.get_installed(): + if manifest['name'] != name: + continue + elif requirements and not semantic_version.match( + requirements, manifest['version']): + continue + elif (not best or semantic_version.compare( + manifest['version'], best['version']) == 1): + best = manifest + return best + + def install(self, # pylint: disable=too-many-arguments,arguments-differ + name, requirements=None, with_packages=None, + without_packages=None, skip_default_packages=False): + PackageManager.install(self, name, requirements) + return PlatformFactory.newPlatform( + name, requirements).install_packages( + with_packages, without_packages, skip_default_packages) + + def uninstall(self, # pylint: disable=arguments-differ + name, requirements=None): + if PlatformFactory.newPlatform( + name, requirements).uninstall_packages(): + return PackageManager.uninstall(self, name, requirements) + return False + + def update(self, name, version): + raise NotImplementedError() + + def is_outdated(self, name, version): + raise NotImplementedError() + + def get_installed_boards(self): + boards = [] + for manifest in self.get_installed(): + p = PlatformFactory.newPlatform(manifest['_manifest_path']) + for id_, config in p.get_boards().items(): + manifest = config.get_manifest().copy() + manifest['id'] = id_ + manifest['platform'] = p.get_name() + boards.append(manifest) + return boards + + @staticmethod + @util.memoized + def get_registered_boards(): + boards = util.get_api_result("/boards") + for item in boards: + # @TODO remove type from API + item['id'] = item['type'] + del item['type'] + return boards class PlatformFactory(object): @staticmethod - def get_clsname(type_): - return "%s%sPlatform" % (type_.upper()[0], type_.lower()[1:]) + def get_clsname(name): + return "%s%sPlatform" % (name.upper()[0], name.lower()[1:]) @staticmethod - def load_module(type_, path): + def load_module(name, path): module = None try: module = load_source( - "platformio.platforms.%s" % type_, path) + "platformio.managers.platform.%s" % name, path) except ImportError: - raise exception.UnknownPlatform(type_) + raise exception.UnknownPlatform(name) 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 + 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: + _manifest = PlatformManager().find_best_platform( + name, requirements) + if _manifest: + platform_dir = dirname(_manifest['_manifest_path']) + if not platform_dir: + raise exception.UnknownPlatform( + name if not requirements else "%s@%s" % (name, requirements)) - @classmethod - def get_platforms(cls, installed=False): - platforms = cls._lookup_platforms() + 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)), (BasePlatform,), {}) - 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_) - )() + _instance = platform_cls(join(platform_dir, "platform.json")) assert isinstance(_instance, BasePlatform) return _instance -class BasePlatform(object): +class PlatformPackagesMixin(object): + + def get_installed_packages(self): + items = {} + installed = self.pm.get_installed() + for name, opts in self.get_packages().items(): + manifest = None + for p in installed: + if (p['name'] != name or not semantic_version.match( + opts['version'], p['version'])): + continue + elif (not manifest or semantic_version.compare( + p['version'], manifest['version']) == 1): + manifest = p + if manifest: + items[name] = manifest + return items + + def install_packages(self, with_packages=None, without_packages=None, + skip_default_packages=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.get_packages().keys()) + if not upkgs.issubset(ppkgs): + raise exception.UnknownPackage(", ".join(upkgs - ppkgs)) + + for name, opts in self.get_packages().items(): + if name in without_packages: + continue + elif (name in with_packages or + not (skip_default_packages or opts.get("optional", False))): + self.pm.install(name, opts.get("version"), silent=silent) + + return True + + def uninstall_packages(self): + deppkgs = set() + for manifest in PlatformManager().get_installed(): + if manifest['name'] == self.get_name(): + continue + p = PlatformFactory.newPlatform( + manifest['name'], manifest['version']) + for pkgname, pkgmanifest in p.get_installed_packages().items(): + deppkgs.add((pkgname, pkgmanifest['version'])) + + for manifest in self.pm.get_installed(): + if manifest['name'] not in self.get_packages().keys(): + continue + if (manifest['name'], manifest['version']) not in deppkgs: + self.pm.uninstall(manifest['name'], manifest['version']) + return True + + def update_packages(self): + outdated = None + for pkgname, pkgmanifest in self.get_installed_packages().items(): + requirements = self.get_packages()[pkgname]['version'] + latest_version = self.pm.get_latest_version( + pkgname, requirements) + if (not latest_version or + pkgmanifest['version'] == latest_version): + continue + + # check other platforms + keep_versions = set([latest_version]) + for pfmanifest in PlatformManager().get_installed(): + if pfmanifest['name'] == self.get_name(): + continue + p = PlatformFactory.newPlatform( + pfmanifest['name'], pfmanifest['version']) + if pkgname not in p.get_packages(): + continue + keep_versions.add(p.pm.get_latest_version( + pkgname, p.get_packages()[pkgname]['version'])) + + outdated = self.pm.update( + pkgname, requirements, keep_versions) + return outdated + + def are_outdated_packages(self): + for name, opts in self.get_installed_packages().items(): + if (opts['version'] != self.pm.get_latest_version( + name, self.get_packages()[name].get("version"))): + return True + return False + + +class BasePlatform(PlatformPackagesMixin): + + _BOARDS_CACHE = {} - PACKAGES = {} LINE_ERROR_RE = re.compile(r"(\s+error|error[:\s]+)", re.I) - def __init__(self): + def __init__(self, manifest_path): + self._BOARDS_CACHE = {} + self.manifest_path = manifest_path + self.manifest = util.load_json(manifest_path) + + self.pm = PackageManager( + repositories=self.manifest.get("packageRepositories")) + self._found_error = False self._last_echo_line = None @@ -271,182 +254,125 @@ class BasePlatform(object): # 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() + return self.manifest['name'] - 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_title(self): + return self.manifest['title'] 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() + return self.manifest['description'] - 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 get_version(self): + return self.manifest['version'] + + def get_manifest(self): + return self.manifest + + 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 name, opts in self.get_packages().items(): - if name == "framework-mbed" or opts.get("alias") == "uploader": + for opts in self.get_packages().values(): + if opts.get("type") == "uploader": return True return False + def get_boards(self, id_=None): + if id_ is None: + boards_dir = join(self.get_dir(), "boards") + if not isdir(boards_dir): + return {} + for item in sorted(os.listdir(boards_dir)): + _id = item[:-5] + if _id in self._BOARDS_CACHE: + continue + self._BOARDS_CACHE[_id] = PlatformBoardConfig( + join(self.get_dir(), "boards", item) + ) + else: + if id_ not in self._BOARDS_CACHE: + self._BOARDS_CACHE[id_] = PlatformBoardConfig( + join(self.get_dir(), "boards", "%s.json" % id_) + ) + return self._BOARDS_CACHE[id_] if id_ else self._BOARDS_CACHE + + def board_config(self, id_): + return self.get_boards(id_) + def get_packages(self): - return self.PACKAGES + return self.manifest.get("packages", {}) - def get_package_alias(self, pkgname): - return self.PACKAGES[pkgname].get("alias") + def get_frameworks(self): + return self.get_manifest().get("frameworks") - def pkg_aliases_to_names(self, aliases): + def get_package_dir(self, name): + packages = self.get_installed_packages() + if name not in packages: + return None + return dirname(packages[name]['_manifest_path']) + + def get_package_version(self, name): + packages = self.get_installed_packages() + if name not in packages: + return None + return packages[name]['version'] + + def get_package_type(self, name): + return self.get_packages()[name].get("type") + + def pkg_types_to_names(self, types): names = [] - for alias in aliases: - name = alias - # lookup by package aliases + for type_ in types: + name = type_ + # lookup by package types for _name, _opts in self.get_packages().items(): - if _opts.get("alias") == alias: + if _opts.get("type") == type_: name = None names.append(_name) - # if alias is the right name + # if type 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().keys() 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().keys(): - 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 + frameworks = self.get_frameworks() + for framework in variables.get("framework", "").split(","): + framework = framework.lower().strip() + if not framework or framework not in frameworks: + continue + _pkg_name = frameworks[framework]['package'] + self.get_packages()[_pkg_name]['optional'] = False # append SCons tool - self.PACKAGES['tool-scons'] = {"default": True} + self.get_packages()['tool-scons'] = { + "version": self.manifest.get("engines", {}).get( + "scons", ">=2.3.0,<2.5.0"), + "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("alias") == "uploader": - self.PACKAGES[_name]['default'] = True + for _name, _opts in self.get_packages().iteritems(): + if _opts.get("type") == "uploader": + self.get_packages()[_name]['optional'] = False 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()) + self.get_packages()[_name]['optional'] = True 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.install_packages(silent=True) self._verbose_level = int(verbose) @@ -454,18 +380,13 @@ class BasePlatform(object): targets.remove("clean") targets.append("-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']) - # 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 @@ -542,3 +463,34 @@ class BasePlatform(object): return cpu_count() except NotImplementedError: return 1 + + +class PlatformBoardConfig(object): + + def __init__(self, manifest_path): + if not isfile(manifest_path): + raise exception.UnknownBoard(basename(manifest_path[:-5])) + self.manifest_path = manifest_path + self.manifest = util.load_json(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 + + def get_manifest(self): + return self.manifest diff --git a/platformio/util.py b/platformio/util.py index 6dc1bd5e..dd6026e9 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -375,32 +375,6 @@ def get_api_result(path, params=None, data=None, skipdns=False): 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")) - - 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 - - -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 = {} diff --git a/setup.py b/setup.py index 83d9acb9..d228de9c 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ install_requires = [ "click>=3.2,<6", "lockfile>=0.9.1,<0.13", "requests>=2.4.0,<3", + "semantic_version>=2.5.0", "colorama", "pyserial<4" ] @@ -45,7 +46,6 @@ setup( package_data={ "platformio": [ "projectconftpl.ini", - "boards/*.json", "ide/tpls/*/.*.tpl", "ide/tpls/*/*.tpl", "ide/tpls/*/*/*.tpl", From 9a1f1ddb8bcf831c07b5bde3e121a2da0072b47a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 26 May 2016 22:33:17 +0300 Subject: [PATCH 003/119] Allow to install development platform from local directory // Issue #479 --- docs/userguide/platforms/cmd_install.rst | 7 +- platformio/downloader.py | 5 +- platformio/exception.py | 5 + platformio/managers/package.py | 112 +++++++++++++++++------ platformio/managers/platform.py | 4 +- 5 files changed, 101 insertions(+), 32 deletions(-) diff --git a/docs/userguide/platforms/cmd_install.rst b/docs/userguide/platforms/cmd_install.rst index b3753537..86b678af 100644 --- a/docs/userguide/platforms/cmd_install.rst +++ b/docs/userguide/platforms/cmd_install.rst @@ -21,14 +21,17 @@ Usage .. code-block:: bash + # install platform by name platformio platform install [OPTIONS] [PLATFORMS] + # install platform from local directory + platformio platform install [OPTIONS] [file:///local/path/to/platform/dir] + Description ----------- -Install pre-built development :ref:`platforms` with related -packages. +Install development :ref:`platforms` and dependent packages. There are several predefined aliases for packages, such as: diff --git a/platformio/downloader.py b/platformio/downloader.py index bbb90e07..891e7bf5 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -53,7 +53,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 +77,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 ce3d7cc6..39630594 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -70,6 +70,11 @@ class UnknownPackage(PlatformioException): MESSAGE = "Detected unknown package '{0}'" +class InvalidLocalPackage(PlatformioException): + + MESSAGE = "Invalid local package '{0}'. Can not find manifest '{1}'" + + class UndefinedPackageVersion(PlatformioException): MESSAGE = "Can not find package '{0}' with version requirements '{1}'"\ diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 7654109f..c1e94f1c 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -14,7 +14,7 @@ import os from os.path import dirname, isdir, isfile, join -from shutil import rmtree +from shutil import copyfile, copytree, rmtree import click import requests @@ -41,6 +41,10 @@ class PackageManager(object): def reset_cache(): PackageManager._INSTALLED_CACHE = {} + @staticmethod + def get_manifest_name(): + return "package.json" + @staticmethod def download(url, dest_dir, sha1=None): fd = FileDownloader(url, dest_dir) @@ -50,13 +54,56 @@ class PackageManager(object): return fd.get_filepath() @staticmethod - def unpack(pkgpath, dest_dir): - fu = FileUnpacker(pkgpath, dest_dir) + def unpack(source_path, dest_dir): + fu = FileUnpacker(source_path, dest_dir) return fu.start() - @staticmethod - def get_manifest_name(): - return "package.json" + def check_structure(self, pkg_dir): + if isfile(join(pkg_dir, self.get_manifest_name())): + return True + + for root, _, files in os.walk(pkg_dir): + if self.get_manifest_name() not in files: + continue + # copy contents to the root of package directory + for item in os.listdir(root): + item_path = join(root, item) + if isfile(item_path): + copyfile(item_path, join(pkg_dir, item)) + elif isdir(item_path): + copytree(item_path, join(pkg_dir, item), symlinks=True) + # remove not used contents + while True: + rmtree(root) + root = dirname(root) + if root == pkg_dir: + break + break + + if isfile(join(pkg_dir, self.get_manifest_name())): + return True + + raise exception.PlatformioException( + "Could not find '%s' manifest file in the package" % + self.get_manifest_name()) + + def make_pkg_dir(self, name, version): + pkg_dir = join(self.package_dir, name) + if isfile(join(pkg_dir, self.get_manifest_name())): + _manifest = util.load_json( + join(pkg_dir, self.get_manifest_name())) + if (_manifest['name'] == name and + _manifest['version'] != version): + pkg_dir = join( + self.package_dir, "%s@%s" % (name, version)) + + # remove previous/not-satisfied package + if isdir(pkg_dir): + rmtree(pkg_dir) + os.makedirs(pkg_dir) + assert isdir(pkg_dir) + + return pkg_dir @staticmethod def max_satisfying_version(versions, requirements=None): @@ -114,7 +161,8 @@ class PackageManager(object): def install(self, name, requirements, silent=False, trigger_event=True): installed = self.is_installed(name, requirements) if not installed or not silent: - click.echo("Installing package %s @ %s:" % ( + click.echo("Installing %s %s @ %s:" % ( + self.get_manifest_name().split(".")[0], click.style(name, fg="cyan"), requirements if requirements else "latest")) if installed: @@ -122,18 +170,24 @@ class PackageManager(object): click.secho("Already installed", fg="yellow") return - if not self._install_from_piorepo(name, requirements): + manifest_path = None + if name.startswith("file://"): + manifest_path = self._install_from_local_dir(name[7:]) + else: + manifest_path = self._install_from_piorepo(name, requirements) + if not isfile(manifest_path): raise exception.PackageInstallError( - name, requirements, util.get_systype()) + name, requirements or "latest", util.get_systype()) self.reset_cache() if trigger_event: telemetry.on_event( category="PackageManager", action="Install", label=name) + return manifest_path + def _install_from_piorepo(self, name, requirements): pkg_dir = None - success = False pkgdata = None versions = None for versions in PackageRepoIterator(name, self.repositories): @@ -142,26 +196,17 @@ class PackageManager(object): if not pkgdata: continue - pkg_dir = join(self.package_dir, name) - if isfile(join(pkg_dir, self.get_manifest_name())): - pkg_dir = join( - self.package_dir, "%s@%s" % (name, pkgdata['version'])) - - # remove previous/not-satisfied package - if isdir(pkg_dir): - rmtree(pkg_dir) - os.makedirs(pkg_dir) - + pkg_dir = self.make_pkg_dir(name, pkgdata['version']) try: dlpath = self.download( pkgdata['url'], pkg_dir, pkgdata.get("sha1")) assert isfile(dlpath) self.unpack(dlpath, pkg_dir) - success = True + self.check_structure(pkg_dir) break except Exception as e: # pylint: disable=broad-except click.secho("Warning! Package Mirror: %s" % e, fg="yellow") - click.secho("Looking for other Package Mirror...", fg="yellow") + click.secho("Looking for another mirror...", fg="yellow") finally: if dlpath and isfile(dlpath): os.remove(dlpath) @@ -170,12 +215,26 @@ class PackageManager(object): raise exception.UnknownPackage(name) elif not pkgdata: raise exception.UndefinedPackageVersion( - name, requirements, util.get_systype()) + name, requirements or "latest", util.get_systype()) - return success + return join(pkg_dir, self.get_manifest_name()) + + def _install_from_local_dir(self, local_dir): + if not isfile(join(local_dir, self.get_manifest_name())): + raise exception.InvalidLocalPackage( + local_dir, self.get_manifest_name()) + + manifest = util.load_json(join(local_dir, self.get_manifest_name())) + assert set(["name", "version"]) <= set(manifest.keys()) + pkg_dir = self.make_pkg_dir(manifest['name'], manifest['version']) + rmtree(pkg_dir) + copytree(local_dir, pkg_dir, symlinks=True) + + return join(pkg_dir, self.get_manifest_name()) def uninstall(self, name, requirements=None, trigger_event=True): - click.echo("Uninstalling package %s @ %s: \t" % ( + click.echo("Uninstalling %s %s @ %s: \t" % ( + self.get_manifest_name().split(".")[0], click.style(name, fg="cyan"), requirements if requirements else "latest"), nl=False) found = False @@ -201,7 +260,8 @@ class PackageManager(object): category="PackageManager", action="Uninstall", label=name) def update(self, name, requirements=None, keep_versions=None): - click.echo("Updating package %s @ %s:" % ( + click.echo("Updating %s %s @ %s:" % ( + self.get_manifest_name().split(".")[0], click.style(name, fg="yellow"), requirements if requirements else "latest")) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 2526ad29..f903b6bb 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -56,9 +56,9 @@ class PlatformManager(PackageManager): def install(self, # pylint: disable=too-many-arguments,arguments-differ name, requirements=None, with_packages=None, without_packages=None, skip_default_packages=False): - PackageManager.install(self, name, requirements) + manifest_path = PackageManager.install(self, name, requirements) return PlatformFactory.newPlatform( - name, requirements).install_packages( + manifest_path, requirements).install_packages( with_packages, without_packages, skip_default_packages) def uninstall(self, # pylint: disable=arguments-differ From 567f9c06cc7a038b80cd50140352c38a9d9bc777 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 May 2016 12:35:20 +0300 Subject: [PATCH 004/119] Disable platform auto-update (temporary) --- platformio/managers/platform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index f903b6bb..608fa34b 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -72,6 +72,8 @@ class PlatformManager(PackageManager): raise NotImplementedError() def is_outdated(self, name, version): + # @TODO disable auto-update temporary + return False raise NotImplementedError() def get_installed_boards(self): From 46893e2f04212982995f48b10548ecbe7bd3751e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 May 2016 12:48:10 +0300 Subject: [PATCH 005/119] Stop build process when framework is used and board is not specified --- platformio/builder/tools/platformio.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 10c93f6b..1be9a2c0 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -207,9 +207,12 @@ def BuildFrameworks(env, frameworks): if not frameworks or "uploadlazy" in COMMAND_LINE_TARGETS: return - board_frameworks = [] - if "BOARD" in env: - board_frameworks = env.BoardConfig().get("frameworks", []) + if "BOARD" not in env: + env.Exit( + "Please specify `board` in `platformio.ini` to use " + "with '%s' framework" % ", ".join(frameworks)) + + board_frameworks = env.BoardConfig().get("frameworks", []) if frameworks == ["platformio"]: if board_frameworks: frameworks.insert(0, board_frameworks[0]) From 825c60e2bd3d6eda466f570cdbd5180d9e3815d9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 May 2016 14:47:22 +0300 Subject: [PATCH 006/119] Automatically add SCons to the packages list if it is missed in platform manifest // Issue #479 --- platformio/managers/platform.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 608fa34b..778896e4 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -309,7 +309,14 @@ class BasePlatform(PlatformPackagesMixin): return self.get_boards(id_) def get_packages(self): - return self.manifest.get("packages", {}) + packages = self.manifest.get("packages", {}) + if "tool-scons" not in packages: + packages['tool-scons'] = { + "version": self.manifest.get("engines", {}).get( + "scons", ">=2.3.0,<2.6.0"), + "optional": False + } + return packages def get_frameworks(self): return self.get_manifest().get("frameworks") @@ -353,13 +360,6 @@ class BasePlatform(PlatformPackagesMixin): _pkg_name = frameworks[framework]['package'] self.get_packages()[_pkg_name]['optional'] = False - # append SCons tool - self.get_packages()['tool-scons'] = { - "version": self.manifest.get("engines", {}).get( - "scons", ">=2.3.0,<2.5.0"), - "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.get_packages().iteritems(): @@ -413,8 +413,7 @@ class BasePlatform(PlatformPackagesMixin): cmd = [ os.path.normpath(sys.executable), - join(util.get_home_dir(), "packages", "tool-scons", - "script", "scons"), + join(self.get_package_dir("tool-scons"), "script", "scons"), "-Q", "-j %d" % self.get_job_nums(), "--warn=no-no-parallel-support", From 426389b2550ab4e8d789abae58a7525a002c72bc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 May 2016 15:50:57 +0300 Subject: [PATCH 007/119] Fix package removing when it is symbolically linked --- platformio/managers/package.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index c1e94f1c..d34e4ab4 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -13,7 +13,7 @@ # limitations under the License. import os -from os.path import dirname, isdir, isfile, join +from os.path import dirname, isdir, isfile, islink, join from shutil import copyfile, copytree, rmtree import click @@ -246,7 +246,11 @@ class PackageManager(object): continue found = True if isfile(manifest['_manifest_path']): - rmtree(dirname(manifest['_manifest_path'])) + pkg_dir = dirname(manifest['_manifest_path']) + if islink(pkg_dir): + os.unlink(pkg_dir) + else: + rmtree(pkg_dir) if not found: click.secho("Not installed", fg="yellow") From 23ef51a4e8d4af4f39425345d5c6569fc16cc2ab Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 28 May 2016 22:51:33 +0300 Subject: [PATCH 008/119] Update tests according new development platforms architecture // Issue #479 --- platformio/commands/boards.py | 1 + platformio/commands/run.py | 15 +++++++++++++-- platformio/managers/platform.py | 1 + tests/commands/test_boards.py | 26 +++++++++++++++----------- tests/commands/test_init.py | 11 ++++++++--- tests/commands/test_platforms.py | 18 +++++++++--------- 6 files changed, 47 insertions(+), 25 deletions(-) diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 585ff84b..1a5c258d 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -92,6 +92,7 @@ def _get_boards(installed=False): boards = _new_boards return boards + def _ouput_boards_json(query, installed=False): result = [] for board in _get_boards(installed): diff --git a/platformio/commands/run.py b/platformio/commands/run.py index e32654ef..6e350a27 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -23,6 +23,8 @@ import click from platformio import app, exception, telemetry, util from platformio.commands.lib import lib_install as cmd_lib_install +from platformio.commands.platform import \ + platform_install as cmd_platform_install from platformio.libmanager import LibraryManager from platformio.managers.platform import PlatformFactory @@ -186,7 +188,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() @@ -196,7 +197,17 @@ class EnvironmentProcessor(object): if "lib_install" in self.options: _autoinstall_libs(self.cmd_ctx, self.options['lib_install']) - p = PlatformFactory.newPlatform(platform) + platform = self.options['platform'] + version = None + if "@" in platform: + platform, version = platform.rsplit("@", 1) + + try: + p = PlatformFactory.newPlatform(platform) + except exception.UnknownPlatform: + self.cmd_ctx.invoke(cmd_platform_install, platforms=[platform]) + p = PlatformFactory.newPlatform(platform) + return p.run(build_vars, build_targets, self.verbose_level) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 778896e4..d2bad516 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -125,6 +125,7 @@ class PlatformFactory(object): name, requirements) if _manifest: platform_dir = dirname(_manifest['_manifest_path']) + if not platform_dir: raise exception.UnknownPlatform( name if not requirements else "%s@%s" % (name, requirements)) diff --git a/tests/commands/test_boards.py b/tests/commands/test_boards.py index f137096c..1a2539fd 100644 --- a/tests/commands/test_boards.py +++ b/tests/commands/test_boards.py @@ -16,16 +16,16 @@ 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"]) + 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): @@ -36,16 +36,20 @@ def test_board_raw_output(platformio_setup, clirunner, validate_cliresult): def test_board_options(platformio_setup, 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_init.py b/tests/commands/test_init.py index 93b47053..3cea718a 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json from os import makedirs, getcwd from os.path import getsize, isdir, isfile, join from platformio.commands.init import cli +from platformio.commands.boards import cli as cmd_boards from platformio import util @@ -48,11 +50,14 @@ def test_init_special_board(platformio_setup, clirunner, validate_cliresult): validate_cliresult(result) validate_pioproject(getcwd()) - uno = util.get_boards("uno") + result = clirunner.invoke(cmd_boards, ["Arduino Uno", "--json-output"]) + validate_cliresult(result) + boards = json.loads(result.output) + config = util.get_project_config() expected_result = [ - ("platform", str(uno['platform'])), - ("framework", str(uno['frameworks'][0])), + ("platform", str(boards[0]['platform'])), + ("framework", str(boards[0]['frameworks'][0])), ("board", "uno") ] diff --git a/tests/commands/test_platforms.py b/tests/commands/test_platforms.py index 0d0251d1..db4d735e 100644 --- a/tests/commands/test_platforms.py +++ b/tests/commands/test_platforms.py @@ -14,14 +14,14 @@ import json -from platformio.commands.platforms import \ - platforms_list as cmd_platforms_list -from platformio.commands.platforms import \ - platforms_search as cmd_platforms_search +from platformio.commands.platform import \ + platform_list as cmd_platform_list +from platformio.commands.platform import \ + platform_search as cmd_platform_search def test_list_json_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platforms_list, ["--json-output"]) + result = clirunner.invoke(cmd_platform_list, ["--json-output"]) validate_cliresult(result) list_result = json.loads(result.output) assert isinstance(list_result, list) @@ -31,23 +31,23 @@ def test_list_json_output(clirunner, validate_cliresult): def test_list_raw_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platforms_list) + result = clirunner.invoke(cmd_platform_list) validate_cliresult(result) assert "teensy" in result.output def test_search_json_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platforms_search, + result = clirunner.invoke(cmd_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['type'] for item in 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(cmd_platforms_search, ["arduino"]) + result = clirunner.invoke(cmd_platform_search, ["arduino"]) validate_cliresult(result) assert "teensy" in result.output From 420c93aaa3838d9d97f2a88748624e0ac302f924 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 29 May 2016 00:50:05 +0300 Subject: [PATCH 009/119] Automatically install missed development platform for run command --- platformio/commands/run.py | 4 +- platformio/managers/package.py | 2 +- platformio/managers/platform.py | 206 ++++++++++++++++---------------- 3 files changed, 108 insertions(+), 104 deletions(-) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 6e350a27..8b80d26d 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -203,10 +203,10 @@ class EnvironmentProcessor(object): platform, version = platform.rsplit("@", 1) try: - p = PlatformFactory.newPlatform(platform) + p = PlatformFactory.newPlatform(platform, version) except exception.UnknownPlatform: self.cmd_ctx.invoke(cmd_platform_install, platforms=[platform]) - p = PlatformFactory.newPlatform(platform) + p = PlatformFactory.newPlatform(platform, version) return p.run(build_vars, build_targets, self.verbose_level) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index d34e4ab4..93053d08 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -286,7 +286,7 @@ class PackageManager(object): continue if (not current or semantic_version.compare( manifest['version'], current['version']) == 1): - current = manifest + current = manifest if current is None: return diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index d2bad516..ab39c45f 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -33,7 +33,7 @@ class PlatformManager(PackageManager): PackageManager.__init__( self, join(util.get_home_dir(), "platforms"), - ["http://dl.platformio.org/misc/platforms_manifest.json"] + ["http://dl.platformio.org/platforms/manifest.json"] ) @staticmethod @@ -68,7 +68,8 @@ class PlatformManager(PackageManager): return PackageManager.uninstall(self, name, requirements) return False - def update(self, name, version): + def update(self, # pylint: disable=arguments-differ + name, version): raise NotImplementedError() def is_outdated(self, name, version): @@ -235,12 +236,111 @@ class PlatformPackagesMixin(object): return False -class BasePlatform(PlatformPackagesMixin): - - _BOARDS_CACHE = {} +class PlatformRunMixin(object): LINE_ERROR_RE = re.compile(r"(\s+error|error[:\s]+)", re.I) + def run(self, variables, targets, verbose): + assert isinstance(variables, dict) + assert isinstance(targets, list) + + self.configure_default_packages(variables, targets) + self.install_packages(silent=True) + + self._verbose_level = int(verbose) + + if "clean" in targets: + targets.remove("clean") + targets.append("-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']) + + 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(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") + ] + 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 + + +class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): + + _BOARDS_CACHE = {} + def __init__(self, manifest_path): self._BOARDS_CACHE = {} self.manifest_path = manifest_path @@ -370,102 +470,6 @@ class BasePlatform(PlatformPackagesMixin): # skip all packages, allow only upload tools self.get_packages()[_name]['optional'] = True - def run(self, variables, targets, verbose): - assert isinstance(variables, dict) - assert isinstance(targets, list) - - self.configure_default_packages(variables, targets) - self.install_packages(silent=True) - - self._verbose_level = int(verbose) - - if "clean" in targets: - targets.remove("clean") - targets.append("-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']) - - 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(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") - ] + 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 - class PlatformBoardConfig(object): From 806f6cd2abff59ea66916885c0c377f380fce826 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 29 May 2016 17:59:08 +0300 Subject: [PATCH 010/119] Fix platform installer if platform is already installed --- platformio/managers/package.py | 22 ++++++++++++++++++---- platformio/managers/platform.py | 15 +-------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 93053d08..ec569f2f 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -106,7 +106,7 @@ class PackageManager(object): return pkg_dir @staticmethod - def max_satisfying_version(versions, requirements=None): + def max_satisfying_repo_version(versions, requirements=None): item = None systype = util.get_systype() if requirements is not None: @@ -124,6 +124,19 @@ class PackageManager(object): item = v return item + def max_satisfying_version(self, name, requirements=None): + best = None + for manifest in self.get_installed(): + if manifest['name'] != name: + continue + elif requirements and not semantic_version.match( + requirements, manifest['version']): + continue + elif (not best or semantic_version.compare( + manifest['version'], best['version']) == 1): + best = manifest + return best + def get_installed(self): if self.package_dir in PackageManager._INSTALLED_CACHE: return PackageManager._INSTALLED_CACHE[self.package_dir] @@ -153,7 +166,7 @@ class PackageManager(object): def get_latest_version(self, name, requirements): for versions in PackageRepoIterator(name, self.repositories): - pkgdata = self.max_satisfying_version(versions, requirements) + pkgdata = self.max_satisfying_repo_version(versions, requirements) if pkgdata: return pkgdata['version'] return None @@ -168,7 +181,8 @@ class PackageManager(object): if installed: if not silent: click.secho("Already installed", fg="yellow") - return + return self.max_satisfying_version( + name, requirements).get("_manifest_path") manifest_path = None if name.startswith("file://"): @@ -192,7 +206,7 @@ class PackageManager(object): versions = None for versions in PackageRepoIterator(name, self.repositories): dlpath = None - pkgdata = self.max_satisfying_version(versions, requirements) + pkgdata = self.max_satisfying_repo_version(versions, requirements) if not pkgdata: continue diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index ab39c45f..b0430b8e 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -40,19 +40,6 @@ class PlatformManager(PackageManager): def get_manifest_name(): return "platform.json" - def find_best_platform(self, name, requirements=None): - best = None - for manifest in self.get_installed(): - if manifest['name'] != name: - continue - elif requirements and not semantic_version.match( - requirements, manifest['version']): - continue - elif (not best or semantic_version.compare( - manifest['version'], best['version']) == 1): - best = manifest - return best - def install(self, # pylint: disable=too-many-arguments,arguments-differ name, requirements=None, with_packages=None, without_packages=None, skip_default_packages=False): @@ -122,7 +109,7 @@ class PlatformFactory(object): platform_dir = dirname(name) name = util.load_json(name)['name'] else: - _manifest = PlatformManager().find_best_platform( + _manifest = PlatformManager().max_satisfying_version( name, requirements) if _manifest: platform_dir = dirname(_manifest['_manifest_path']) From 2ecc007615c6901bfdd259ffea8171c98323ba87 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 29 May 2016 23:28:50 +0300 Subject: [PATCH 011/119] Implement packages updating; other improvements to Package Manager // Issue #479 --- platformio/builder/tools/devplatform.py | 5 +- platformio/commands/platform.py | 45 +++--- platformio/exception.py | 5 + platformio/managers/package.py | 83 +++++----- platformio/managers/platform.py | 199 ++++++++++++------------ 5 files changed, 175 insertions(+), 162 deletions(-) diff --git a/platformio/builder/tools/devplatform.py b/platformio/builder/tools/devplatform.py index ac5cda6d..4c78a6d5 100644 --- a/platformio/builder/tools/devplatform.py +++ b/platformio/builder/tools/devplatform.py @@ -49,9 +49,8 @@ def BoardConfig(env, board=None): def GetFrameworkScript(env, framework): p = env.DevPlatform() - frameworks = p.get_frameworks() - assert frameworks and framework in frameworks - script_path = env.subst(frameworks[framework]['script']) + 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 diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 2a159f02..5a703fdd 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -97,10 +97,10 @@ def platform_list(json_output): for manifest in PlatformManager().get_installed(): p = PlatformFactory.newPlatform(manifest['_manifest_path']) platforms.append({ - "name": p.get_name(), - "title": p.get_title(), - "description": p.get_description(), - "version": p.get_version(), + "name": p.name, + "title": p.title, + "description": p.description, + "version": p.version, "packages": p.get_installed_packages().keys() }) @@ -125,24 +125,23 @@ def platform_show(ctx, platform): raise exception.PlatformNotInstalledYet(platform) click.echo("{name} ~ {title}".format( - name=click.style(p.get_name(), fg="cyan"), title=p.get_title())) - click.echo("=" * (3 + len(p.get_name() + p.get_title()))) - click.echo(p.get_manifest().get("description")) + 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.get_version()) - if "homepage" in p.get_manifest(): - click.echo("Home: %s" % p.get_manifest().get("homepage")) - if "license" in p.get_manifest(): - click.echo("License: %s" % p.get_manifest().get("license").get("type")) - if "frameworks" in p.get_manifest(): - click.echo("Frameworks: %s" % - ", ".join(p.get_manifest().get("frameworks").keys())) + click.echo("Version: %s" % p.version) + if p.homepage: + click.echo("Home: %s" % p.homepage) + if p.license: + click.echo("License: %s" % p.license.get("type")) + if p.frameworks: + click.echo("Frameworks: %s" % ", ".join(p.frameworks.keys())) - if not p.get_packages(): + if not p.packages: return installed_pkgs = p.get_installed_packages() - for name, opts in p.get_packages().items(): + for name, opts in p.packages.items(): click.echo() click.echo("Package %s" % click.style(name, fg="yellow")) click.echo("-" * (8 + len(name))) @@ -173,15 +172,11 @@ def platform_uninstall(platforms): @cli.command("update", short_help="Update installed Platforms") @click.option("--only-packages", is_flag=True) def platform_update(only_packages): - for manifest in PlatformManager().get_installed(): + pm = PlatformManager() + for manifest in pm.get_installed(): click.echo("Platform %s @ %s" % ( click.style(manifest['name'], fg="cyan"), manifest['version'])) click.echo("--------") - if only_packages: - status = PlatformFactory.newPlatform( - manifest['name'], manifest['version']).update_packages() - if status is None: - click.secho("Packages are up-to-date", fg="green") - else: - PlatformManager().update(manifest['name'], manifest['version']) + pm.update(manifest['name'], manifest['version'], + only_packages=only_packages) click.echo() diff --git a/platformio/exception.py b/platformio/exception.py index 39630594..a375b587 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -81,6 +81,11 @@ class UndefinedPackageVersion(PlatformioException): " for your system '{2}'" +class UndefinedPlatformVersion(PlatformioException): + + MESSAGE = "Can not find platform '{0}' with version requirements '{1}'" + + class PackageInstallError(PlatformioException): MESSAGE = "Can not install package '{0}' with version requirements '{1}' "\ diff --git a/platformio/managers/package.py b/platformio/managers/package.py index ec569f2f..8b37520b 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -41,8 +41,8 @@ class PackageManager(object): def reset_cache(): PackageManager._INSTALLED_CACHE = {} - @staticmethod - def get_manifest_name(): + @property + def manifest_name(self): return "package.json" @staticmethod @@ -59,11 +59,11 @@ class PackageManager(object): return fu.start() def check_structure(self, pkg_dir): - if isfile(join(pkg_dir, self.get_manifest_name())): + if isfile(join(pkg_dir, self.manifest_name)): return True for root, _, files in os.walk(pkg_dir): - if self.get_manifest_name() not in files: + if self.manifest_name not in files: continue # copy contents to the root of package directory for item in os.listdir(root): @@ -80,20 +80,27 @@ class PackageManager(object): break break - if isfile(join(pkg_dir, self.get_manifest_name())): + if isfile(join(pkg_dir, self.manifest_name)): return True raise exception.PlatformioException( "Could not find '%s' manifest file in the package" % - self.get_manifest_name()) + self.manifest_name) def make_pkg_dir(self, name, version): pkg_dir = join(self.package_dir, name) - if isfile(join(pkg_dir, self.get_manifest_name())): - _manifest = util.load_json( - join(pkg_dir, self.get_manifest_name())) - if (_manifest['name'] == name and - _manifest['version'] != version): + if isfile(join(pkg_dir, self.manifest_name)): + manifest = util.load_json( + join(pkg_dir, self.manifest_name)) + + cmp_result = semantic_version.compare(version, manifest['version']) + if cmp_result == 1: + # if main package version < new package, backup it + print pkg_dir, join( + self.package_dir, "%s@%s" % (name, manifest['version'])) + os.rename(pkg_dir, join( + self.package_dir, "%s@%s" % (name, manifest['version']))) + elif cmp_result == -1: pkg_dir = join( self.package_dir, "%s@%s" % (name, version)) @@ -103,6 +110,7 @@ class PackageManager(object): os.makedirs(pkg_dir) assert isdir(pkg_dir) + self.reset_cache() return pkg_dir @staticmethod @@ -124,6 +132,17 @@ class PackageManager(object): 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 + def max_satisfying_version(self, name, requirements=None): best = None for manifest in self.get_installed(): @@ -142,7 +161,7 @@ class PackageManager(object): return PackageManager._INSTALLED_CACHE[self.package_dir] items = [] for p in sorted(os.listdir(self.package_dir)): - manifest_path = join(self.package_dir, p, self.get_manifest_name()) + manifest_path = join(self.package_dir, p, self.manifest_name) if not isfile(manifest_path): continue manifest = util.load_json(manifest_path) @@ -164,18 +183,11 @@ class PackageManager(object): return True return None - def get_latest_version(self, name, requirements): - for versions in PackageRepoIterator(name, self.repositories): - pkgdata = self.max_satisfying_repo_version(versions, requirements) - if pkgdata: - return pkgdata['version'] - return None - def install(self, name, requirements, silent=False, trigger_event=True): installed = self.is_installed(name, requirements) if not installed or not silent: click.echo("Installing %s %s @ %s:" % ( - self.get_manifest_name().split(".")[0], + self.manifest_name.split(".")[0], click.style(name, fg="cyan"), requirements if requirements else "latest")) if installed: @@ -228,27 +240,31 @@ class PackageManager(object): if versions is None: raise exception.UnknownPackage(name) elif not pkgdata: - raise exception.UndefinedPackageVersion( - name, requirements or "latest", util.get_systype()) + if "platform" in self.manifest_name: + raise exception.UndefinedPlatformVersion( + name, requirements or "latest") + else: + raise exception.UndefinedPackageVersion( + name, requirements or "latest", util.get_systype()) - return join(pkg_dir, self.get_manifest_name()) + return join(pkg_dir, self.manifest_name) def _install_from_local_dir(self, local_dir): - if not isfile(join(local_dir, self.get_manifest_name())): + if not isfile(join(local_dir, self.manifest_name)): raise exception.InvalidLocalPackage( - local_dir, self.get_manifest_name()) + local_dir, self.manifest_name) - manifest = util.load_json(join(local_dir, self.get_manifest_name())) + manifest = util.load_json(join(local_dir, self.manifest_name)) assert set(["name", "version"]) <= set(manifest.keys()) pkg_dir = self.make_pkg_dir(manifest['name'], manifest['version']) rmtree(pkg_dir) copytree(local_dir, pkg_dir, symlinks=True) - return join(pkg_dir, self.get_manifest_name()) + return join(pkg_dir, self.manifest_name) def uninstall(self, name, requirements=None, trigger_event=True): click.echo("Uninstalling %s %s @ %s: \t" % ( - self.get_manifest_name().split(".")[0], + self.manifest_name.split(".")[0], click.style(name, fg="cyan"), requirements if requirements else "latest"), nl=False) found = False @@ -277,24 +293,22 @@ class PackageManager(object): telemetry.on_event( category="PackageManager", action="Uninstall", label=name) - def update(self, name, requirements=None, keep_versions=None): + def update(self, name, requirements=None): click.echo("Updating %s %s @ %s:" % ( - self.get_manifest_name().split(".")[0], + self.manifest_name.split(".")[0], click.style(name, fg="yellow"), requirements if requirements else "latest")) - latest_version = self.get_latest_version(name, requirements) + latest_version = self.get_latest_repo_version(name, requirements) if latest_version is None: click.secho("Ignored! '%s' is not listed in " "Package Repository" % name, fg="yellow") return current = None - other_versions = [] for manifest in self.get_installed(): if manifest['name'] != name: continue - other_versions.append(manifest['version']) if (requirements and not semantic_version.match( requirements, manifest['version'])): continue @@ -315,9 +329,6 @@ class PackageManager(object): else: click.echo("[%s]" % (click.style("Out-of-date", fg="red"))) - for v in other_versions: - if not keep_versions or v not in keep_versions: - self.uninstall(name, v, trigger_event=False) self.install(name, latest_version, trigger_event=False) telemetry.on_event( diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index b0430b8e..611933f1 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -36,33 +36,61 @@ class PlatformManager(PackageManager): ["http://dl.platformio.org/platforms/manifest.json"] ) - @staticmethod - def get_manifest_name(): + @property + def manifest_name(self): return "platform.json" def install(self, # pylint: disable=too-many-arguments,arguments-differ name, requirements=None, with_packages=None, without_packages=None, skip_default_packages=False): manifest_path = PackageManager.install(self, name, requirements) - return PlatformFactory.newPlatform( + PlatformFactory.newPlatform( manifest_path, requirements).install_packages( with_packages, without_packages, skip_default_packages) + self.cleanup_packages() + return True def uninstall(self, # pylint: disable=arguments-differ name, requirements=None): - if PlatformFactory.newPlatform( - name, requirements).uninstall_packages(): - return PackageManager.uninstall(self, name, requirements) - return False + PackageManager.uninstall(self, name, requirements) + self.cleanup_packages() + return True def update(self, # pylint: disable=arguments-differ - name, version): - raise NotImplementedError() + name, requirements=None, only_packages=False): + if not only_packages: + PackageManager.update(self, name) + PlatformFactory.newPlatform( + name, requirements).update_packages() + self.cleanup_packages() + return True - def is_outdated(self, name, version): - # @TODO disable auto-update temporary - return False - raise NotImplementedError() + def is_outdated(self, name, requirements=None): + p = PlatformFactory.newPlatform(name, requirements) + return (p.are_outdated_packages() or + p.version != self.get_latest_repo_version(name, requirements)) + + def cleanup_packages(self): + 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() + for manifest in pm.get_installed(): + if manifest['name'] not in deppkgs: + continue + if 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 = [] @@ -71,7 +99,7 @@ class PlatformManager(PackageManager): for id_, config in p.get_boards().items(): manifest = config.get_manifest().copy() manifest['id'] = id_ - manifest['platform'] = p.get_name() + manifest['platform'] = p.name boards.append(manifest) return boards @@ -138,7 +166,7 @@ class PlatformPackagesMixin(object): def get_installed_packages(self): items = {} installed = self.pm.get_installed() - for name, opts in self.get_packages().items(): + for name, opts in self.packages.items(): manifest = None for p in installed: if (p['name'] != name or not semantic_version.match( @@ -159,11 +187,11 @@ class PlatformPackagesMixin(object): self.pkg_types_to_names(without_packages or [])) upkgs = with_packages | without_packages - ppkgs = set(self.get_packages().keys()) + ppkgs = set(self.packages.keys()) if not upkgs.issubset(ppkgs): raise exception.UnknownPackage(", ".join(upkgs - ppkgs)) - for name, opts in self.get_packages().items(): + for name, opts in self.packages.items(): if name in without_packages: continue elif (name in with_packages or @@ -172,53 +200,14 @@ class PlatformPackagesMixin(object): return True - def uninstall_packages(self): - deppkgs = set() - for manifest in PlatformManager().get_installed(): - if manifest['name'] == self.get_name(): - continue - p = PlatformFactory.newPlatform( - manifest['name'], manifest['version']) - for pkgname, pkgmanifest in p.get_installed_packages().items(): - deppkgs.add((pkgname, pkgmanifest['version'])) - - for manifest in self.pm.get_installed(): - if manifest['name'] not in self.get_packages().keys(): - continue - if (manifest['name'], manifest['version']) not in deppkgs: - self.pm.uninstall(manifest['name'], manifest['version']) - return True - def update_packages(self): - outdated = None - for pkgname, pkgmanifest in self.get_installed_packages().items(): - requirements = self.get_packages()[pkgname]['version'] - latest_version = self.pm.get_latest_version( - pkgname, requirements) - if (not latest_version or - pkgmanifest['version'] == latest_version): - continue - - # check other platforms - keep_versions = set([latest_version]) - for pfmanifest in PlatformManager().get_installed(): - if pfmanifest['name'] == self.get_name(): - continue - p = PlatformFactory.newPlatform( - pfmanifest['name'], pfmanifest['version']) - if pkgname not in p.get_packages(): - continue - keep_versions.add(p.pm.get_latest_version( - pkgname, p.get_packages()[pkgname]['version'])) - - outdated = self.pm.update( - pkgname, requirements, keep_versions) - return outdated + for name in self.get_installed_packages().keys(): + self.pm.update(name, self.packages[name]['version']) def are_outdated_packages(self): for name, opts in self.get_installed_packages().items(): - if (opts['version'] != self.pm.get_latest_version( - name, self.get_packages()[name].get("version"))): + if (opts['version'] != self.pm.get_latest_repo_version( + name, self.packages[name].get("version"))): return True return False @@ -331,10 +320,10 @@ class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): def __init__(self, manifest_path): self._BOARDS_CACHE = {} self.manifest_path = manifest_path - self.manifest = util.load_json(manifest_path) + self._manifest = util.load_json(manifest_path) self.pm = PackageManager( - repositories=self.manifest.get("packageRepositories")) + repositories=self._manifest.get("packageRepositories")) self._found_error = False self._last_echo_line = None @@ -344,20 +333,48 @@ class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): # 3 = 2 + others self._verbose_level = 3 - def get_name(self): - return self.manifest['name'] + @property + def name(self): + return self._manifest['name'] - def get_title(self): - return self.manifest['title'] + @property + def title(self): + return self._manifest['title'] - def get_description(self): - return self.manifest['description'] + @property + def description(self): + return self._manifest['description'] - def get_version(self): - return self.manifest['version'] + @property + def version(self): + return self._manifest['version'] - def get_manifest(self): - return self.manifest + @property + def homepage(self): + return self._manifest.get("homepage") + + @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): + packages = self._manifest.get("packages", {}) + if "tool-scons" not in packages: + packages['tool-scons'] = { + "version": self._manifest.get("engines", {}).get( + "scons", ">=2.3.0,<2.6.0"), + "optional": False + } + return packages def get_dir(self): return dirname(self.manifest_path) @@ -369,7 +386,7 @@ class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): raise NotImplementedError() def is_embedded(self): - for opts in self.get_packages().values(): + for opts in self.packages.values(): if opts.get("type") == "uploader": return True return False @@ -396,19 +413,6 @@ class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): def board_config(self, id_): return self.get_boards(id_) - def get_packages(self): - packages = self.manifest.get("packages", {}) - if "tool-scons" not in packages: - packages['tool-scons'] = { - "version": self.manifest.get("engines", {}).get( - "scons", ">=2.3.0,<2.6.0"), - "optional": False - } - return packages - - def get_frameworks(self): - return self.get_manifest().get("frameworks") - def get_package_dir(self, name): packages = self.get_installed_packages() if name not in packages: @@ -422,14 +426,14 @@ class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): return packages[name]['version'] def get_package_type(self, name): - return self.get_packages()[name].get("type") + 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.get_packages().items(): + for _name, _opts in self.packages.items(): if _opts.get("type") == type_: name = None names.append(_name) @@ -440,22 +444,21 @@ class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): def configure_default_packages(self, variables, targets): # enbale used frameworks - frameworks = self.get_frameworks() for framework in variables.get("framework", "").split(","): framework = framework.lower().strip() - if not framework or framework not in frameworks: + if not framework or framework not in self.frameworks: continue - _pkg_name = frameworks[framework]['package'] - self.get_packages()[_pkg_name]['optional'] = False + _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.get_packages().iteritems(): + for _name, _opts in self.packages.iteritems(): if _opts.get("type") == "uploader": - self.get_packages()[_name]['optional'] = False + self.packages[_name]['optional'] = False elif "uploadlazy" in targets: # skip all packages, allow only upload tools - self.get_packages()[_name]['optional'] = True + self.packages[_name]['optional'] = True class PlatformBoardConfig(object): @@ -464,11 +467,11 @@ class PlatformBoardConfig(object): if not isfile(manifest_path): raise exception.UnknownBoard(basename(manifest_path[:-5])) self.manifest_path = manifest_path - self.manifest = util.load_json(manifest_path) + self._manifest = util.load_json(manifest_path) def get(self, path, default=None): try: - value = self.manifest + value = self._manifest for k in path.split("."): value = value[k] return value @@ -486,4 +489,4 @@ class PlatformBoardConfig(object): return False def get_manifest(self): - return self.manifest + return self._manifest From bf149c075d57fb9335dff862ee9c504bef8abb6e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 30 May 2016 14:31:58 +0300 Subject: [PATCH 012/119] Auto install too-unity for hardware unit testing --- platformio/managers/platform.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 611933f1..4697dc61 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -154,10 +154,10 @@ class PlatformFactory(object): ) else: platform_cls = type( - str(cls.get_clsname(name)), (BasePlatform,), {}) + str(cls.get_clsname(name)), (PlatformBase,), {}) _instance = platform_cls(join(platform_dir, "platform.json")) - assert isinstance(_instance, BasePlatform) + assert isinstance(_instance, PlatformBase) return _instance @@ -313,7 +313,7 @@ class PlatformRunMixin(object): return 1 -class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): +class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): _BOARDS_CACHE = {} @@ -460,6 +460,12 @@ class BasePlatform(PlatformPackagesMixin, PlatformRunMixin): # 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.0", + "optional": False + } + class PlatformBoardConfig(object): From bfd66deb37ccbae8f431ccad9704c568a2de9e1a Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 30 May 2016 17:50:37 +0300 Subject: [PATCH 013/119] Initial support for unit testing // Issue #408 --- platformio/builder/main.py | 4 +- platformio/builder/tools/piotest.py | 146 +++++++++++++++++++++++++ platformio/builder/tools/platformio.py | 3 + platformio/util.py | 7 ++ 4 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 platformio/builder/tools/piotest.py diff --git a/platformio/builder/main.py b/platformio/builder/main.py index b4f00241..faaa1e1a 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -62,7 +62,7 @@ commonvars.AddVariables( DefaultEnvironment( tools=[ "gcc", "g++", "as", "ar", "gnulink", - "platformio", "devplatform", "pioupload", "pioar", "piomisc" + "platformio", "devplatform", "piotest", "pioupload", "pioar", "piomisc" ], toolpath=[join(util.get_source_dir(), "builder", "tools")], variables=commonvars, @@ -77,11 +77,13 @@ DefaultEnvironment( 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(), BUILD_DIR=join("$PIOENVS_DIR", "$PIOENV"), BUILDSRC_DIR=join("$BUILD_DIR", "src"), + BUILDTEST_DIR=join("$BUILD_DIR", "test"), LIBSOURCE_DIRS=[ "$PROJECTLIB_DIR", util.get_lib_dir() diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py new file mode 100644 index 00000000..c8044d93 --- /dev/null +++ b/platformio/builder/tools/piotest.py @@ -0,0 +1,146 @@ +# 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 __future__ import absolute_import + +import atexit +from os import remove +from os.path import isdir, isfile, join +from string import Template + +FRAMEWORKS_PARAMETERS = { + "arduino": { + "framework": "Arduino.h", + "serial_obj": "", + "serial_putc": "Serial.write(a)", + "serial_flush": "Serial.flush()", + "serial_begin": "Serial.begin(9600)", + "serial_end": "Serial.end()" + }, + + "mbed": { + "framework": "mbed.h", + "serial_obj": "Serial pc(USBTX, USBRX);", + "serial_putc": "pc.putc(a)", + "serial_flush": "", + "serial_begin": "pc.baud(9600)", + "serial_end": "" + }, + + "energia": { + "framework": "Energia.h", + "serial_obj": "", + "serial_putc": "Serial.write(a)", + "serial_flush": "Serial.flush()", + "serial_begin": "Serial.begin(9600)", + "serial_end": "Serial.end()" + } +} + + +def ProcessTest(env): + + test_dir = env.subst("$PROJECTTEST_DIR") + + env.Append( + CPPDEFINES=[ + "UNIT_TEST", + "UNITY_INCLUDE_CONFIG_H" + ], + + CPPPATH=[ + join("$BUILD_DIR", "UnityTestLib") + ] + ) + + unitylib = env.BuildLibrary( + join("$BUILD_DIR", "UnityTestLib"), + env.DevPlatform().get_package_dir("tool-unity") + + ) + + env.Prepend(LIBS=[unitylib]) + + env.GenerateOutputReplacement(test_dir) + + return env.LookupSources( + "$BUILDTEST_DIR", test_dir, duplicate=False) + + +def GenerateOutputReplacement(env, destination_dir): + + if not isdir(env.subst(destination_dir)): + env.Exit( + "Error: Test folder doesn't exist. Please put your test suite " + 'to \"test\" folder in project\'s root directory.') + + TEMPLATECPP = """ +# include <$framework> +# include + +$serial_obj + +void output_char(int a) +{ + $serial_putc; +} + +void output_flush(void) +{ + $serial_flush; +} + +void output_start(unsigned int baudrate) +{ + $serial_begin; +} + +void output_complete(void) +{ + $serial_end; +} + +""" + + def delete_tmptest_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_) + + framework = env.subst("$FRAMEWORK").lower() + if framework not in FRAMEWORKS_PARAMETERS.keys(): + env.Exit( + "Error: %s framework doesn't support testing feature!" % framework) + else: + data = Template(TEMPLATECPP).substitute( + FRAMEWORKS_PARAMETERS[framework]) + + tmp_file = join(destination_dir, "output_export.cpp") + with open(tmp_file, "w") as f: + f.write(data) + + atexit.register(delete_tmptest_file, tmp_file) + + +def exists(_): + return True + + +def generate(env): + env.AddMethod(ProcessTest) + env.AddMethod(GenerateOutputReplacement) + return env diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index f7c88fd5..9599dbd6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -88,6 +88,9 @@ def BuildProgram(env): "$BUILDSRC_DIR", "$PROJECTSRC_DIR", duplicate=False, src_filter=env.get("SRC_FILTER")) + if "test" in COMMAND_LINE_TARGETS: + sources.extend(env.ProcessTest()) + if not sources and not COMMAND_LINE_TARGETS: env.Exit( "Error: Nothing to build. Please put your source code files " diff --git a/platformio/util.py b/platformio/util.py index dd6026e9..394b3201 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -207,6 +207,13 @@ def get_projectsrc_dir(): ) +def get_projecttest_dir(): + return _get_projconf_option_dir( + "test_dir", + join(get_project_dir(), "test") + ) + + def get_projectlib_dir(): return join(get_project_dir(), "lib") From d6b6fa2baf69741fad8d45bdbe45e08ce9722953 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 31 May 2016 00:22:25 +0300 Subject: [PATCH 014/119] Install development platform from local dir and VCS(git, hg, svn) // Issue #479 --- docs/projectconf.rst | 25 ++++ docs/userguide/platforms/cmd_install.rst | 138 ++++++++++++++++++--- docs/userguide/platforms/cmd_uninstall.rst | 13 +- docs/userguide/platforms/cmd_update.rst | 110 +++++++--------- platformio/commands/run.py | 3 +- platformio/exception.py | 5 - platformio/managers/package.py | 117 +++++++++-------- platformio/managers/platform.py | 24 ++-- platformio/vcsclient.py | 97 +++++++++++++++ 9 files changed, 374 insertions(+), 158 deletions(-) create mode 100644 platformio/vcsclient.py diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 3ddf6ea5..13c1b3ca 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -196,6 +196,31 @@ General options :ref:`platforms` name. +PlatformIO allows to use specific platform versions 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: diff --git a/docs/userguide/platforms/cmd_install.rst b/docs/userguide/platforms/cmd_install.rst index 86b678af..64298e01 100644 --- a/docs/userguide/platforms/cmd_install.rst +++ b/docs/userguide/platforms/cmd_install.rst @@ -22,22 +22,90 @@ Usage .. code-block:: bash # install platform by name - platformio platform install [OPTIONS] [PLATFORMS] + platformio platform install [OPTIONS] PLATFORM - # install platform from local directory - platformio platform install [OPTIONS] [file:///local/path/to/platform/dir] + # install specific platform version using Semantic Versioning + platformio platform install [OPTIONS] PLATFORM@X.Y.Z + + # install platform using URL + platformio platform install [OPTIONS] URL Description ----------- -Install development :ref:`platforms` and dependent packages. +Install :ref:`platforms` and dependent packages. There are several predefined aliases for packages, such as: +* ``framework`` * ``toolchain`` * ``uploader`` +Local +~~~~~ + +PlatformIO supports installing development platform from local directory. Here +is supported form: + +* file:///local/path/to/the/platform/dir + +VCS +~~~ + +PlatformIO supports installing from Git, Mercurial and Subversion, and detects +the type of VCS using url prefixes: "git+", "hg+", or "svn+". + +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: + +* 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 + Options ------- @@ -62,30 +130,68 @@ Skip default packages Examples -------- -1. Install :ref:`platform_timsp430` with default packages +1. Install :ref:`platform_atmelavr` with default packages .. code-block:: bash - $ platformio platform install timsp430 - Installing toolchain-timsp430 package: + $ platformio platform install atmelavr + Installing platform atmelavr @ latest: + Downloading... + Unpacking [####################################] 100% + Installing package tool-scons @ >=2.3.0,<2.6.0: Downloading [####################################] 100% Unpacking [####################################] 100% - Installing tool-mspdebug package: + Installing package toolchain-atmelavr @ ~1.40801.0: Downloading [####################################] 100% Unpacking [####################################] 100% - Installing framework-energiamsp430 package: - Downloading [####################################] 100% - Unpacking [####################################] 100% - The platform 'timsp430' 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 - $ platformio platform install timsp430 --skip-default-package --with-package=uploader - Installing tool-mspdebug package: + $ platformio platform install atmelavr --skip-default-package --with-package=uploader + Installing platform atmelavr @ latest: Downloading [####################################] 100% Unpacking [####################################] 100% - The platform 'timsp430' has been successfully installed! + Installing package tool-micronucleus @ ~1.200.0: + Downloading [####################################] 100% + Unpacking [####################################] 100% + Installing package tool-avrdude @ >=1.60001.0,<1.60101.0: + Downloading [####################################] 100% + Unpacking [####################################] 100% + 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-block:: bash + + $ platformio platform install https://github.com/platformio/platform-atmelavr.git + Installing platform https://github.com/platformio/platform-atmelavr.git @ latest: + git version 2.7.4 (Apple Git-66) + Cloning into '/Users/ikravets/.platformio/platforms/installing-XMIsAE-package'... + remote: Counting objects: 172, done. + remote: Compressing objects: 100% (51/51), done. + remote: Total 172 (delta 109), reused 168 (delta 109), pack-reused 0 + Receiving objects: 100% (172/172), 38.18 KiB | 0 bytes/s, done. + Resolving deltas: 100% (109/109), 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: 87, done. + remote: Total 87 (delta 0), reused 0 (delta 0), pack-reused 87 + Unpacking objects: 100% (87/87), done. + Checking connectivity... done. + Submodule path 'examples/arduino-external-libs/lib/OneWire': checked out '57c18c6de80c13429275f70875c7c341f1719201' + Installing package tool-scons @ >=2.3.0,<2.6.0: + Downloading [####################################] 100% + Unpacking [####################################] 100% + Installing package toolchain-atmelavr @ ~1.40801.0: + Downloading [####################################] 100% + Unpacking [####################################] 100% + 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_uninstall.rst b/docs/userguide/platforms/cmd_uninstall.rst index 67cc273a..f1375d5e 100644 --- a/docs/userguide/platforms/cmd_uninstall.rst +++ b/docs/userguide/platforms/cmd_uninstall.rst @@ -23,6 +23,9 @@ Usage platformio platform uninstall PLATFORM + # uninstall specific platform version using Semantic Versioning + platformio platform uninstall PLATFORM@X.Y.Z + Description ----------- @@ -35,8 +38,8 @@ Examples .. code-block:: bash - $ platformio platform 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 @ latest: [OK] + Uninstalling package tool-scons @ 2.5.0: [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 8e4fec64..918aca8a 100644 --- a/docs/userguide/platforms/cmd_update.rst +++ b/docs/userguide/platforms/cmd_update.rst @@ -46,75 +46,53 @@ Examples .. code-block:: bash $ platformio platform update - - Platform atmelavr + Platform atmelavr @ 0.0.0 -------- - 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 platform atmelavr @ latest: + Versions: Current=0.0.0, Latest=0.0.0 [Up-to-date] + Updating package framework-arduinoavr @ ~1.10608.0: + Versions: Current=1.10608.0, Latest=1.10608.0 [Up-to-date] + Updating package toolchain-atmelavr @ ~1.40801.0: + Versions: Current=1.40801.0, Latest=1.40801.0 [Up-to-date] + Updating package framework-simba @ ~1.500.0: + Versions: Current=1.500.0, Latest=1.500.0 [Up-to-date] + Updating package tool-scons @ >=2.3.0,<2.6.0: + Versions: Current=2.5.0, Latest=2.5.0 [Up-to-date] - Platform atmelsam + Platform atmelsam @ 0.0.0 -------- - 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 platform atmelsam @ latest: + Versions: Current=0.0.0, Latest=0.0.0 [Up-to-date] + Updating package toolchain-gccarmnoneeabi @ >=1.40803.0,<1.40805.0: + Versions: Current=1.40804.0, Latest=1.40804.0 [Up-to-date] + Updating package framework-arduinosam @ ~1.10607.0: + Versions: Current=1.10607.0, Latest=1.10607.0 [Up-to-date] + Updating package framework-simba @ ~1.500.0: + Versions: Current=1.500.0, Latest=1.500.0 [Up-to-date] + Updating package framework-mbed @ ~1.117.0: + Versions: Current=1.117.0, Latest=1.117.0 [Up-to-date] + Updating package tool-scons @ >=2.3.0,<2.6.0: + Versions: Current=2.5.0, Latest=2.5.0 [Up-to-date] + Updating package tool-bossac @ ~1.10500.0: + Versions: Current=1.10500.0, Latest=1.10500.0 [Up-to-date] - Platform stm32 + Platform espressif @ 0.0.0 -------- - 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 platform espressif @ latest: + Versions: Current=0.0.0, Latest=0.0.0 [Up-to-date] + Updating package tool-scons @ >=2.3.0,<2.6.0: + Versions: Current=2.5.0, Latest=2.5.0 [Up-to-date] + Updating package toolchain-xtensa @ ~1.40802.0: + Versions: Current=1.40802.0, Latest=1.40802.0 [Up-to-date] + Updating package framework-simba @ ~1.500.0: + Versions: Current=1.500.0, Latest=1.500.0 [Up-to-date] + Updating package tool-esptool @ ~1.408.0: + Versions: Current=1.408.0, Latest=1.408.0 [Up-to-date] + Updating package tool-mkspiffs @ ~1.102.0: + Versions: Current=1.102.0, Latest=1.102.0 [Up-to-date] + Updating package framework-arduinoespressif @ ~1.20200.0: + Versions: Current=1.20200.0, Latest=1.20200.0 [Up-to-date] + Updating package sdk-esp8266 @ ~1.10502.0: + Versions: Current=1.10502.0, Latest=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] - - 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/platformio/commands/run.py b/platformio/commands/run.py index 8b80d26d..76f375a5 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -205,7 +205,8 @@ class EnvironmentProcessor(object): try: p = PlatformFactory.newPlatform(platform, version) except exception.UnknownPlatform: - self.cmd_ctx.invoke(cmd_platform_install, platforms=[platform]) + self.cmd_ctx.invoke( + cmd_platform_install, platforms=[self.options['platform']]) p = PlatformFactory.newPlatform(platform, version) return p.run(build_vars, build_targets, self.verbose_level) diff --git a/platformio/exception.py b/platformio/exception.py index a375b587..3fe366f2 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -70,11 +70,6 @@ class UnknownPackage(PlatformioException): MESSAGE = "Detected unknown package '{0}'" -class InvalidLocalPackage(PlatformioException): - - MESSAGE = "Invalid local package '{0}'. Can not find manifest '{1}'" - - class UndefinedPackageVersion(PlatformioException): MESSAGE = "Can not find package '{0}' with version requirements '{1}'"\ diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 8b37520b..5d0e0a63 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -15,6 +15,7 @@ import os from os.path import dirname, isdir, isfile, islink, join from shutil import copyfile, copytree, rmtree +from tempfile import mkdtemp import click import requests @@ -23,6 +24,7 @@ import semantic_version from platformio import exception, telemetry, util from platformio.downloader import FileDownloader from platformio.unpacker import FileUnpacker +from platformio.vcsclient import VCSClientFactory class PackageManager(object): @@ -87,32 +89,6 @@ class PackageManager(object): "Could not find '%s' manifest file in the package" % self.manifest_name) - def make_pkg_dir(self, name, version): - pkg_dir = join(self.package_dir, name) - if isfile(join(pkg_dir, self.manifest_name)): - manifest = util.load_json( - join(pkg_dir, self.manifest_name)) - - cmp_result = semantic_version.compare(version, manifest['version']) - if cmp_result == 1: - # if main package version < new package, backup it - print pkg_dir, join( - self.package_dir, "%s@%s" % (name, manifest['version'])) - os.rename(pkg_dir, join( - self.package_dir, "%s@%s" % (name, manifest['version']))) - elif cmp_result == -1: - pkg_dir = join( - self.package_dir, "%s@%s" % (name, version)) - - # remove previous/not-satisfied package - if isdir(pkg_dir): - rmtree(pkg_dir) - os.makedirs(pkg_dir) - assert isdir(pkg_dir) - - self.reset_cache() - return pkg_dir - @staticmethod def max_satisfying_repo_version(versions, requirements=None): item = None @@ -196,12 +172,11 @@ class PackageManager(object): return self.max_satisfying_version( name, requirements).get("_manifest_path") - manifest_path = None - if name.startswith("file://"): - manifest_path = self._install_from_local_dir(name[7:]) + if "://" in name: + pkg_dir = self._install_from_url(name, requirements) else: - manifest_path = self._install_from_piorepo(name, requirements) - if not isfile(manifest_path): + pkg_dir = self._install_from_piorepo(name, requirements) + if not pkg_dir or not isfile(join(pkg_dir, self.manifest_name)): raise exception.PackageInstallError( name, requirements or "latest", util.get_systype()) @@ -210,32 +185,23 @@ class PackageManager(object): telemetry.on_event( category="PackageManager", action="Install", label=name) - return manifest_path + return join(pkg_dir, self.manifest_name) def _install_from_piorepo(self, name, requirements): pkg_dir = None pkgdata = None versions = None for versions in PackageRepoIterator(name, self.repositories): - dlpath = None pkgdata = self.max_satisfying_repo_version(versions, requirements) if not pkgdata: continue - - pkg_dir = self.make_pkg_dir(name, pkgdata['version']) try: - dlpath = self.download( - pkgdata['url'], pkg_dir, pkgdata.get("sha1")) - assert isfile(dlpath) - self.unpack(dlpath, pkg_dir) - self.check_structure(pkg_dir) + pkg_dir = self._install_from_url( + 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 another mirror...", fg="yellow") - finally: - if dlpath and isfile(dlpath): - os.remove(dlpath) if versions is None: raise exception.UnknownPackage(name) @@ -246,21 +212,64 @@ class PackageManager(object): else: raise exception.UndefinedPackageVersion( name, requirements or "latest", util.get_systype()) + return pkg_dir - return join(pkg_dir, self.manifest_name) + def _install_from_url(self, url, requirements=None, sha1=None): + pkg_dir = None + tmp_dir = mkdtemp("-package", "installing-", self.package_dir) - def _install_from_local_dir(self, local_dir): - if not isfile(join(local_dir, self.manifest_name)): - raise exception.InvalidLocalPackage( - local_dir, self.manifest_name) + # Handle GitHub URL (https://github.com/user/repo.git) + if url.endswith(".git") and not url.startswith("git"): + url = "git+" + url - manifest = util.load_json(join(local_dir, self.manifest_name)) - assert set(["name", "version"]) <= set(manifest.keys()) - pkg_dir = self.make_pkg_dir(manifest['name'], manifest['version']) - rmtree(pkg_dir) - copytree(local_dir, pkg_dir, symlinks=True) + try: + if url.startswith("file://"): + rmtree(tmp_dir) + copytree(url[7:], tmp_dir) + elif url.startswith(("http://", "https://", "ftp://")): + dlpath = self.download(url, tmp_dir, sha1) + assert isfile(dlpath) + self.unpack(dlpath, tmp_dir) + os.remove(dlpath) + else: + repo = VCSClientFactory.newClient(url) + repo.export(tmp_dir) - return join(pkg_dir, self.manifest_name) + self.check_structure(tmp_dir) + pkg_dir = self._install_from_tmp_dir(tmp_dir, requirements) + finally: + if isdir(tmp_dir): + rmtree(tmp_dir) + return pkg_dir + + def _install_from_tmp_dir(self, tmp_dir, requirements=None): + tmpmanifest = util.load_json(join(tmp_dir, self.manifest_name)) + assert set(["name", "version"]) <= set(tmpmanifest.keys()) + name = tmpmanifest['name'] + + # package should satisfy requirements + if requirements: + assert semantic_version.match(requirements, tmpmanifest['version']) + + pkg_dir = join(self.package_dir, name) + if isfile(join(pkg_dir, self.manifest_name)): + manifest = util.load_json(join(pkg_dir, self.manifest_name)) + cmp_result = semantic_version.compare( + tmpmanifest['version'], manifest['version']) + if cmp_result == 1: + # if main package version < new package, backup it + os.rename(pkg_dir, join( + self.package_dir, "%s@%s" % (name, manifest['version']))) + elif cmp_result == -1: + pkg_dir = join( + self.package_dir, "%s@%s" % (name, tmpmanifest['version'])) + + # remove previous/not-satisfied package + if isdir(pkg_dir): + rmtree(pkg_dir) + os.rename(tmp_dir, pkg_dir) + assert isdir(pkg_dir) + return pkg_dir def uninstall(self, name, requirements=None, trigger_event=True): click.echo("Uninstalling %s %s @ %s: \t" % ( diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 4697dc61..ed5140a8 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -44,25 +44,26 @@ class PlatformManager(PackageManager): name, requirements=None, with_packages=None, without_packages=None, skip_default_packages=False): manifest_path = PackageManager.install(self, name, requirements) - PlatformFactory.newPlatform( - manifest_path, requirements).install_packages( - with_packages, without_packages, skip_default_packages) - self.cleanup_packages() + p = PlatformFactory.newPlatform(manifest_path, requirements) + p.install_packages( + with_packages, without_packages, skip_default_packages) + self.cleanup_packages(p.packages.keys()) return True def uninstall(self, # pylint: disable=arguments-differ name, requirements=None): + p = PlatformFactory.newPlatform(name, requirements) PackageManager.uninstall(self, name, requirements) - self.cleanup_packages() + self.cleanup_packages(p.packages.keys()) return True def update(self, # pylint: disable=arguments-differ name, requirements=None, only_packages=False): if not only_packages: PackageManager.update(self, name) - PlatformFactory.newPlatform( - name, requirements).update_packages() - self.cleanup_packages() + p = PlatformFactory.newPlatform(name, requirements) + p.update_packages() + self.cleanup_packages(p.packages.keys()) return True def is_outdated(self, name, requirements=None): @@ -70,7 +71,7 @@ class PlatformManager(PackageManager): return (p.are_outdated_packages() or p.version != self.get_latest_repo_version(name, requirements)) - def cleanup_packages(self): + def cleanup_packages(self, names): self.reset_cache() deppkgs = {} for manifest in PlatformManager().get_installed(): @@ -83,9 +84,10 @@ class PlatformManager(PackageManager): pm = PackageManager() for manifest in pm.get_installed(): - if manifest['name'] not in deppkgs: + if manifest['name'] not in names: continue - if manifest['version'] not in deppkgs[manifest['name']]: + if (manifest['name'] not in deppkgs or + manifest['version'] not in deppkgs[manifest['name']]): pm.uninstall( manifest['name'], manifest['version'], trigger_event=False) diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py new file mode 100644 index 00000000..612f287a --- /dev/null +++ b/platformio/vcsclient.py @@ -0,0 +1,97 @@ +# Copyright 2014-present 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 platform import system +from subprocess import check_call +from sys import modules +from urlparse import urlsplit, urlunsplit + +from platformio.exception import PlatformioException + + +class VCSClientFactory(object): + + @staticmethod + def newClient(url): + scheme, netloc, path, query, fragment = urlsplit(url) + type_ = scheme + if "+" in type_: + type_, scheme = type_.split("+", 1) + url = urlunsplit((scheme, netloc, path, query, None)) + clsname = "%sClient" % type_.title() + obj = getattr(modules[__name__], clsname)(url, fragment) + assert isinstance(obj, VCSClientBase) + return obj + + +class VCSClientBase(object): + + command = None + + def __init__(self, url, branch=None): + self.url = url + self.branch = branch + self.check_client() + + def check_client(self): + try: + assert self.command + assert self.run_cmd(["--version"]) == 0 + except (AssertionError, OSError): + raise PlatformioException( + "VCS: `%s` client is not installed in your system" % + self.command) + return True + + def export(self, dst_dir): + raise NotImplementedError + + def run_cmd(self, args): + return check_call([self.command] + args, shell=system() == "Windows") + + +class GitClient(VCSClientBase): + + command = "git" + + def export(self, dst_dir): + args = ["clone", "--recursive", "--depth", "1"] + if self.branch: + args.extend(["--branch", self.branch]) + args.extend([self.url, dst_dir]) + self.run_cmd(args) + + +class HgClient(VCSClientBase): + + command = "hg" + + def export(self, dst_dir): + args = ["clone"] + if self.branch: + args.extend(["--updaterev", self.branch]) + args.extend([self.url, dst_dir]) + self.run_cmd(args) + + +class SvnClient(VCSClientBase): + + command = "svn" + + def export(self, dst_dir): + args = ["export", "--force"] + if self.branch: + args.extend(["--revision", self.branch]) + args.extend([self.url, dst_dir]) + self.run_cmd(args) From ff7bc9092db8f6e45db09267cb5818362dfb0500 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 31 May 2016 23:43:27 +0300 Subject: [PATCH 015/119] Patch development platforms after upgrade process // Issue #479 --- platformio/maintenance.py | 6 +++++- platformio/managers/platform.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 0e82bb58..ac056bdf 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -113,7 +113,11 @@ def after_upgrade(ctx): u = Upgrader(last_version, __version__) if u.run(ctx): app.set_state_item("last_version", __version__) - ctx.invoke(cmd_platform_update, only_packages=True) + + # patch development platforms + pm = PlatformManager() + for manifest in pm.get_installed(): + pm.update(manifest['name'], "~" + manifest['version']) click.secho("PlatformIO has been successfully upgraded to %s!\n" % __version__, fg="green") diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index ed5140a8..4fab1720 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -60,7 +60,7 @@ class PlatformManager(PackageManager): def update(self, # pylint: disable=arguments-differ name, requirements=None, only_packages=False): if not only_packages: - PackageManager.update(self, name) + PackageManager.update(self, name, requirements) p = PlatformFactory.newPlatform(name, requirements) p.update_packages() self.cleanup_packages(p.packages.keys()) From 3a143270c24e2d299785ba8db7288194c5fc5f41 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Jun 2016 13:34:49 +0300 Subject: [PATCH 016/119] Handle custom boards --- platformio/commands/boards.py | 25 ++++++------ platformio/maintenance.py | 42 +++++++++++-------- platformio/managers/platform.py | 72 ++++++++++++++++++++++++--------- 3 files changed, 91 insertions(+), 48 deletions(-) diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 1a5c258d..07b800a0 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -16,6 +16,7 @@ import json import click +from platformio.exception import APIRequestError from platformio.managers.platform import PlatformManager @@ -78,24 +79,24 @@ def cli(query, installed, json_output): # pylint: disable=R0912 def _get_boards(installed=False): - boards = PlatformManager.get_registered_boards() - if installed: - _installed_boards = [ - "%s:%s" % (b['platform'], b['id']) - for b in PlatformManager().get_installed_boards() - ] - _new_boards = [] - for board in boards: + 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 in _installed_boards: - _new_boards.append(board) - boards = _new_boards + if key not in know_boards: + boards.append(board) return boards def _ouput_boards_json(query, installed=False): result = [] - for board in _get_boards(installed): + try: + boards = _get_boards(installed) + except APIRequestError: + if not installed: + boards = _get_boards(True) + for board in boards: if query: search_data = "%s %s" % (board['id'], json.dumps(board).lower()) if query.lower() not in search_data.lower(): diff --git a/platformio/maintenance.py b/platformio/maintenance.py index ac056bdf..c91857dc 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import re -import struct +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 @@ -65,21 +67,13 @@ 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(from_version) + self.to_version = semantic_version.Version.coerce(to_version) self._upgraders = [ - (self.version_to_int("3.0.0"), self._upgrade_to_3_0_0) + (semantic_version.Version("3.0.0"), self._upgrade_to_3_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)) - def run(self, ctx): if self.from_version > self.to_version: return True @@ -93,9 +87,26 @@ class Upgrader(object): return all(result) def _upgrade_to_3_0_0(self, ctx): # pylint: disable=R0201 + # 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) + + # re-install PlatformIO 2.0 development platforms installed_platforms = app.get_state_item("installed_platforms", []) if installed_platforms: ctx.invoke(cmd_platform_install, platforms=installed_platforms) + return True @@ -169,9 +180,8 @@ 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(latest_version) <= + semantic_version.Version.coerce(__version__)): return terminal_width, _ = click.get_terminal_size() diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 4fab1720..649166ef 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -98,11 +98,8 @@ class PlatformManager(PackageManager): boards = [] for manifest in self.get_installed(): p = PlatformFactory.newPlatform(manifest['_manifest_path']) - for id_, config in p.get_boards().items(): - manifest = config.get_manifest().copy() - manifest['id'] = id_ - manifest['platform'] = p.name - boards.append(manifest) + for config in p.get_boards().values(): + boards.append(config.get_brief_data()) return boards @staticmethod @@ -394,22 +391,37 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): 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: - boards_dir = join(self.get_dir(), "boards") - if not isdir(boards_dir): - return {} - for item in sorted(os.listdir(boards_dir)): - _id = item[:-5] - if _id in self._BOARDS_CACHE: + for boards_dir in bdirs: + if not isdir(boards_dir): continue - self._BOARDS_CACHE[_id] = PlatformBoardConfig( - join(self.get_dir(), "boards", item) - ) + 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: - self._BOARDS_CACHE[id_] = PlatformBoardConfig( - join(self.get_dir(), "boards", "%s.json" % id_) - ) + for boards_dir in bdirs: + manifest_path = join(bdirs, "%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_): @@ -472,10 +484,11 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): class PlatformBoardConfig(object): def __init__(self, manifest_path): - if not isfile(manifest_path): - raise exception.UnknownBoard(basename(manifest_path[:-5])) + self._id = basename(manifest_path)[:-5] + assert isfile(manifest_path) self.manifest_path = manifest_path self._manifest = util.load_json(manifest_path) + assert set(["name", "url", "vendor"]) <= set(self._manifest.keys()) def get(self, path, default=None): try: @@ -496,5 +509,24 @@ class PlatformBoardConfig(object): except KeyError: return False - def get_manifest(self): + @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", "")[:-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'] + } From e892473af7f522422386b97825484dec9843f8d3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Jun 2016 13:47:03 +0300 Subject: [PATCH 017/119] Refactor AutodetectUploadPort --- platformio/builder/tools/pioupload.py | 44 ++++++++++++++++----------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index ebb13fb6..e3ca5ac9 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -79,17 +79,36 @@ def WaitForNewSerialPort(env, before): def AutodetectUploadPort(env): - if "UPLOAD_PORT" in env: - return - if env.subst("$FRAMEWORK") == "mbed": + def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm") for item in get_logicaldisks(): if (not item['name'] or not any([l in item['name'].lower() for l in msdlabels])): continue - env.Replace(UPLOAD_PORT=item['disk']) - break + return item['disk'] + return None + + def _look_for_serial_port(): + port = None + board_hwids = [] + if "BOARD" in env and "build.hwids" in env.BoardConfig(): + board_hwids = env.BoardConfig().get("build.hwids") + for item in get_serialports(): + if "VID:PID" not in item['hwid']: + continue + port = item['port'] + for hwid in board_hwids: + hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") + if hwid_str in item['hwid']: + return port + return port + + if "UPLOAD_PORT" in env: + return + + if env.subst("$FRAMEWORK") == "mbed": + env.Replace(UPLOAD_PORT=_look_for_mbed_disk()) else: if (system() == "Linux" and not isfile("/etc/udev/99-platformio-udev.rules")): @@ -99,20 +118,9 @@ def AutodetectUploadPort(env): "\n https://raw.githubusercontent.com/platformio/platformio" "/develop/scripts/99-platformio-udev.rules\n" ) + env.Replace(UPLOAD_PORT=_look_for_serial_port()) - board_hwids = [] - if "BOARD" in env and "build.hwids" in env.BoardConfig(): - board_hwids = env.BoardConfig().get("build.hwids") - for item in get_serialports(): - if "VID:PID" not in item['hwid']: - continue - env.Replace(UPLOAD_PORT=item['port']) - for hwid in board_hwids: - hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") - if hwid_str in item['hwid']: - break - - if "UPLOAD_PORT" in env: + if env.subst("$UPLOAD_PORT"): print "Auto-detected UPLOAD_PORT/DISK: %s" % env['UPLOAD_PORT'] else: env.Exit("Error: Please specify `upload_port` for environment or use " From ff3e100b33c0bd6ac5468b3e3540a10ca15b62a3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Jun 2016 14:00:40 +0300 Subject: [PATCH 018/119] Minor fixes --- docs/userguide/platforms/cmd_install.rst | 2 +- platformio/managers/platform.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/userguide/platforms/cmd_install.rst b/docs/userguide/platforms/cmd_install.rst index 64298e01..c43c3123 100644 --- a/docs/userguide/platforms/cmd_install.rst +++ b/docs/userguide/platforms/cmd_install.rst @@ -48,7 +48,7 @@ Local PlatformIO supports installing development platform from local directory. Here is supported form: -* file:///local/path/to/the/platform/dir +* ``file:///local/path/to/the/platform/dir`` VCS ~~~ diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 649166ef..c27a66ec 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -416,7 +416,9 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): else: if id_ not in self._BOARDS_CACHE: for boards_dir in bdirs: - manifest_path = join(bdirs, "%s.json" % id_) + 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) From 41617f5560d08680f960f51f7e93493045dbd914 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 11 Jun 2016 17:37:32 +0300 Subject: [PATCH 019/119] Update documentation for the new decentralised development platforms // Resolve #479 --- docs/platforms/creating_board.rst | 42 ++-- docs/platforms/creating_platform.rst | 283 ++++++++------------------- 2 files changed, 108 insertions(+), 217 deletions(-) diff --git a/docs/platforms/creating_board.rst b/docs/platforms/creating_board.rst index c55b1649..afe0fa78 100644 --- a/docs/platforms/creating_board.rst +++ b/docs/platforms/creating_board.rst @@ -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 df7e803c..316316bb 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -14,7 +14,7 @@ Custom 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`. @@ -184,89 +184,82 @@ 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": { + "type": "Apache-2.0", + "url": "http://opensource.org/licenses/apache2.0.php" + }, + "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 @@ -344,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 @@ -360,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_platform_search` command. You should see - ``test`` platform. -4. Install ``test`` platform via :ref:`cmd_platform_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_platform_search` command output -and can install it via :ref:`platformio platform install ststm32gdb ` command. +Examples +-------- +Please take a look at the source code of +`PlatformIO Development Platforms `_. From 4383f81c0fa0d95e65f4a3d62f07e9a24fb076cd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 14 Jun 2016 20:47:25 +0300 Subject: [PATCH 020/119] Restore PIO macros if it was deleted by framework --- platformio/builder/tools/platformio.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index f43a0dc8..5745a51f 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -35,10 +35,13 @@ SRC_DEFAULT_FILTER = " ".join([ def BuildProgram(env): - env.Append( - CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( - *pioversion_to_intstr())], - ) + def _append_pio_macros(): + 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"): @@ -59,6 +62,9 @@ def BuildProgram(env): env.BuildFrameworks([ f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")]) + # restore PIO macros if it was deleted by framework + _append_pio_macros() + # build dependent libs deplibs = env.BuildDependentLibraries("$PROJECTSRC_DIR") From f5727af40e040eb30aff8b5dcfb567ffd08cef40 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 15 Jun 2016 13:25:35 +0300 Subject: [PATCH 021/119] Fix upload size checker --- platformio/builder/tools/pioupload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index e22a724f..5c7730ac 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -157,7 +157,7 @@ def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621 print "Check program size..." sysenv = environ.copy() sysenv['PATH'] = str(env['ENV']['PATH']) - cmd = [env.subst("$SIZETOOL"), "-B", str(source[0])] + cmd = [env.subst("$SIZETOOL"), "-B", str(target[0])] result = util.exec_command(cmd, env=sysenv) if result['returncode'] != 0: return From bb22a1297bc2e4c3131530f15a2b4b3914836560 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 15 Jun 2016 14:10:42 +0300 Subject: [PATCH 022/119] Unit Testing for Embedded // Resolve #408 --- HISTORY.rst | 3 +- docs/envvars.rst | 4 + docs/index.rst | 1 + docs/platforms/unit_testing.rst | 390 ++++++++++++++++++++++++++++ docs/projectconf.rst | 15 +- docs/quickstart.rst | 3 +- docs/userguide/cmd_run.rst | 4 +- docs/userguide/cmd_test.rst | 68 +++++ docs/userguide/index.rst | 1 + platformio/__init__.py | 2 +- platformio/builder/main.py | 1 + platformio/builder/tools/piotest.py | 21 +- platformio/commands/run.py | 54 ++-- platformio/commands/test.py | 188 ++++++++++++++ platformio/exception.py | 7 + 15 files changed, 725 insertions(+), 37 deletions(-) create mode 100644 docs/platforms/unit_testing.rst create mode 100644 docs/userguide/cmd_test.rst create mode 100644 platformio/commands/test.py diff --git a/HISTORY.rst b/HISTORY.rst index d9ae5b10..e9b1ff11 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,7 +10,8 @@ PlatformIO 3.0 * Decentralized architecture for development platforms: "platform.json", semantic versioning, package dependencies, embedded board configs, isolated build scripts - (`issue #479 `_) +* Unit Testing for Embedded (`docs `__) + (`issue #408 `_) PlatformIO 2.0 -------------- diff --git a/docs/envvars.rst b/docs/envvars.rst index e9316c64..d0165b05 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -69,6 +69,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 -------- diff --git a/docs/index.rst b/docs/index.rst index ce0d088c..2db1a873 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -111,6 +111,7 @@ Contents platforms/embedded_boards frameworks/index platforms/custom_platform_and_board + platforms/unit_testing .. toctree:: :caption: Library Manager diff --git a/docs/platforms/unit_testing.rst b/docs/platforms/unit_testing.rst new file mode 100644 index 00000000..86c8eb63 --- /dev/null +++ b/docs/platforms/unit_testing.rst @@ -0,0 +1,390 @@ +.. Copyright 2014-present 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. + +.. _unit_testing: + +Unit Testing +============ + +`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 Test System is very interesting for embedded development. +It allows you to write tests locally and run them directly on the target +device (hardware unit testing). Also, you will be able to run the same tests +on the different target devices (:ref:`embedded_boards`). + +PlatformIO Test System consists of: + +* Project builder +* Test builder +* Firmware uploader +* Test processor + +.. contents:: + +.. _unit_testing_design: + +Design +------ + +PlatformIO Test System 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 +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 + void setup () { + // some code... + } + + void loop () { + // some code... + } + #endif + + /** + * Generic C/C++ + */ + #ifndef UNIT_TEST + int main() { + // setup code... + + while (1) { + // loop code... + } + } + #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 Test System 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)`` + +Example +------- + +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 + + ; Project Configuration File + ; Docs: http://docs.platformio.org/en/latest/projectconf.html + + [env:uno] + platform = atmelavr + framework = arduino + board = uno + + [env:nodemcu] + platform = espressif + 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); + } + else if (i == max_blinks) { + UNITY_END(); // IMPORTANT LINE! + } + i++; + } + + #endif + +Test results +~~~~~~~~~~~~ + +.. code-block:: bash + + > platformio test --environment uno + Collected 1 items + + ========================= [test::*] Building... (1/3) ============================== + + [Wed Jun 15 00:27:42 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino) + -------------------------------------------------------------------------------------------------------------------------------------------------------------------- + avr-g++ -o .pioenvs/uno/test/test_main.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DPLATFORMIO=030000 -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO -DARDUINO=10608 -DUNIT_TEST -DUNITY_INCLUDE_CONFIG_H -I.pioenvs/uno/FrameworkArduino -I.pioenvs/uno/FrameworkArduinoVariant -Isrc -I.pioenvs/uno/UnityTestLib test/test_main.cpp + avr-g++ -o .pioenvs/uno/firmware.elf -Os -mmcu=atmega328p -Wl,--gc-sections,--relax .pioenvs/uno/src/main.o .pioenvs/uno/test/output_export.o .pioenvs/uno/test/test_main.o -L.pioenvs/uno -Wl,--start-group .pioenvs/uno/libUnityTestLib.a .pioenvs/uno/libFrameworkArduinoVariant.a .pioenvs/uno/libFrameworkArduino.a -lm -Wl,--end-group + avr-objcopy -O ihex -R .eeprom .pioenvs/uno/firmware.elf .pioenvs/uno/firmware.hex + avr-size --mcu=atmega328p -C -d .pioenvs/uno/firmware.elf + AVR Memory Usage + ---------------- + Device: atmega328p + + Program: 4702 bytes (14.3% Full) + (.text + .data + .bootloader) + + Data: 460 bytes (22.5% Full) + (.data + .bss + .noinit) + + + ========================= [test::*] Uploading... (2/3) ============================== + + [Wed Jun 15 00:27:43 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino) + -------------------------------------------------------------------------------------------------------------------------------------------------------------------- + avr-g++ -o .pioenvs/uno/firmware.elf -Os -mmcu=atmega328p -Wl,--gc-sections,--relax .pioenvs/uno/src/main.o .pioenvs/uno/test/output_export.o .pioenvs/uno/test/test_main.o -L.pioenvs/uno -Wl,--start-group .pioenvs/uno/libUnityTestLib.a .pioenvs/uno/libFrameworkArduinoVariant.a .pioenvs/uno/libFrameworkArduino.a -lm -Wl,--end-group + MethodWrapper([".pioenvs/uno/firmware.elf"], [".pioenvs/uno/src/main.o", ".pioenvs/uno/test/output_export.o", ".pioenvs/uno/test/test_main.o"]) + Check program size... + text data bss dec hex filename + 4464 238 222 4924 133c .pioenvs/uno/firmware.elf + BeforeUpload(["upload"], [".pioenvs/uno/firmware.hex"]) + Looking for upload port/disk... + avr-size --mcu=atmega328p -C -d .pioenvs/uno/firmware.elf + + Auto-detected: /dev/cu.usbmodemFD131 + avrdude -v -p atmega328p -C "/Users/ikravets/.platformio/packages/tool-avrdude/avrdude.conf" -c arduino -b 115200 -P "/dev/cu.usbmodemFD131" -D -U flash:w:.pioenvs/uno/firmware.hex:i + + [...] + + avrdude done. Thank you. + + ========================= [test::*] Testing... (3/3) ========================= + + If you do not see any output for the first 10 secs, please reset board (press reset button) + + test/test_main.cpp:30:test_led_builtin_pin_number 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 + 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 0 Failures 0 Ignored + + ========================= [TEST SUMMARY] ===================================== + test:*/env:uno PASSED + ========================= [PASSED] Took 13.35 seconds ======================== diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 34685842..8572d229 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -113,7 +113,7 @@ 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. @@ -130,6 +130,19 @@ project. This option can be overridden by global environment variable :envvar:`PLATFORMIO_DATA_DIR`. +.. _projectconf_pio_test_dir: + +``test_dir`` +^^^^^^^^^^^^ + +Directory for :ref:`unit_testing`. + +A default value is ``test`` which 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`` diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 3b2d0c24..0ed47471 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -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 diff --git a/docs/userguide/cmd_run.rst b/docs/userguide/cmd_run.rst index 6034cb04..383970c1 100644 --- a/docs/userguide/cmd_run.rst +++ b/docs/userguide/cmd_run.rst @@ -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_serialports` command. + +If upload port is not specified, PlatformIO will try to detect it automatically. .. option:: -d, --project-dir diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst new file mode 100644 index 00000000..8d163db8 --- /dev/null +++ b/docs/userguide/cmd_test.rst @@ -0,0 +1,68 @@ +.. 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. + +.. _cmd_test: + +platformio test +=============== + +.. 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:: + --upload-port + +Upload port of embedded board. To print all available ports use +:ref:`cmd_serialports` 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 details about the results of processing environments. More details +:option:`platformio run --verbose` + +Examples +-------- + +For the examples please follow to :ref:`unit_testing` page. diff --git a/docs/userguide/index.rst b/docs/userguide/index.rst index 1d9851ab..856ebda2 100644 --- a/docs/userguide/index.rst +++ b/docs/userguide/index.rst @@ -66,5 +66,6 @@ Commands cmd_run cmd_serialports cmd_settings + cmd_test cmd_update cmd_upgrade diff --git a/platformio/__init__.py b/platformio/__init__.py index fe5bd51c..1e9074a2 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev0") +VERSION = (3, 0, "0.dev1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index faaa1e1a..ab957d57 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -32,6 +32,7 @@ commonvars.AddVariables( ("BUILD_SCRIPT",), ("EXTRA_SCRIPT",), ("PIOENV",), + ("PIOTEST",), ("PLATFORM",), # options diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index c8044d93..8f97a9cc 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -16,10 +16,10 @@ from __future__ import absolute_import import atexit from os import remove -from os.path import isdir, isfile, join +from os.path import isdir, isfile, join, sep from string import Template -FRAMEWORKS_PARAMETERS = { +FRAMEWORK_PARAMETERS = { "arduino": { "framework": "Arduino.h", "serial_obj": "", @@ -50,9 +50,6 @@ FRAMEWORKS_PARAMETERS = { def ProcessTest(env): - - test_dir = env.subst("$PROJECTTEST_DIR") - env.Append( CPPDEFINES=[ "UNIT_TEST", @@ -63,19 +60,23 @@ def ProcessTest(env): join("$BUILD_DIR", "UnityTestLib") ] ) - unitylib = env.BuildLibrary( join("$BUILD_DIR", "UnityTestLib"), env.DevPlatform().get_package_dir("tool-unity") ) - env.Prepend(LIBS=[unitylib]) + test_dir = env.subst("$PROJECTTEST_DIR") env.GenerateOutputReplacement(test_dir) + src_filter = None + if "PIOTEST" in env: + src_filter = "+" + src_filter += " +<%s%s>" % (env['PIOTEST'], sep) return env.LookupSources( - "$BUILDTEST_DIR", test_dir, duplicate=False) + "$BUILDTEST_DIR", test_dir, duplicate=False, src_filter=src_filter + ) def GenerateOutputReplacement(env, destination_dir): @@ -122,12 +123,12 @@ void output_complete(void) "Please remove it manually." % file_) framework = env.subst("$FRAMEWORK").lower() - if framework not in FRAMEWORKS_PARAMETERS.keys(): + if framework not in FRAMEWORK_PARAMETERS.keys(): env.Exit( "Error: %s framework doesn't support testing feature!" % framework) else: data = Template(TEMPLATECPP).substitute( - FRAMEWORKS_PARAMETERS[framework]) + FRAMEWORK_PARAMETERS[framework]) tmp_file = join(destination_dir, "output_export.cpp") with open(tmp_file, "w") as f: diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 76f375a5..fca60880 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -41,19 +41,8 @@ from platformio.managers.platform import PlatformFactory @click.pass_context def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 project_dir, verbose, disable_auto_clean): + assert check_project_envs(project_dir, environment) 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: @@ -66,6 +55,7 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 fg="yellow" ) + config = util.get_project_config() env_default = None if config.has_option("platformio", "env_default"): env_default = [ @@ -94,6 +84,8 @@ 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) @@ -136,15 +128,12 @@ class EnvironmentProcessor(object): 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 @@ -254,6 +243,29 @@ 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_envs(project_dir, environments): + 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(environments) - known + if unknown: + raise exception.UnknownEnvNames( + ", ".join(unknown), ", ".join(known)) + return True + + def calculate_project_hash(): structure = [] for d in (util.get_projectsrc_dir(), util.get_projectlib_dir()): diff --git a/platformio/commands/test.py b/platformio/commands/test.py new file mode 100644 index 00000000..62105c7a --- /dev/null +++ b/platformio/commands/test.py @@ -0,0 +1,188 @@ +# Copyright 2014-present 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 getcwd, listdir +from os.path import isdir, join +from time import sleep, time + +import click +import serial + +from platformio import exception, util +from platformio.commands.run import cli as cmd_run +from platformio.commands.run import check_project_envs, print_header +from platformio.managers.platform import PlatformFactory + + +@click.command("test", short_help="Unit Testing") +@click.option("--environment", "-e", 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.pass_context +def cli(ctx, environment, upload_port, # pylint: disable=R0913,R0914 + project_dir, verbose): + assert check_project_envs(project_dir, environment) + with util.cd(project_dir): + test_dir = util.get_projecttest_dir() + if not isdir(test_dir): + raise exception.TestDirEmpty(test_dir) + config = util.get_project_config() + env_names = set( + [s[4:] for s in config.sections() if s.startswith("env:")]) + + test_names = [] + for item in sorted(listdir(test_dir)): + if isdir(join(test_dir, item)): + test_names.append(item) + if not test_names: + test_names = ["*"] + click.echo("Collected %d items" % len(test_names)) + click.echo() + + start_time = time() + results = [] + for testname in test_names: + for envname in env_names: + if environment and envname not in environment: + continue + tp = TestProcessor(ctx, testname, envname, { + "project_config": config, + "project_dir": project_dir, + "upload_port": upload_port, + "verbose": verbose + }) + results.append((tp.process(), testname, envname)) + + click.echo() + print_header("[%s]" % click.style("TEST SUMMARY")) + + passed = True + for result in results: + if not result[0]: + passed = False + click.echo("test:%s/env:%s\t%s" % ( + click.style(result[1], fg="yellow"), + click.style(result[2], fg="cyan"), + click.style("PASSED" if passed else "FAILED", fg="green" + if passed else "red")), err=not passed) + + print_header("[%s] Took %.2f seconds" % ( + (click.style("PASSED", fg="green", bold=True) if passed + else click.style("FAILED", fg="red", bold=True)), + time() - start_time + ), is_error=not passed) + + if not passed: + raise exception.ReturnErrorCode() + + +class TestProcessor(object): + + SERIAL_TIMEOUT = 600 + SERIAL_BAUDRATE = 9600 + + def __init__(self, cmd_ctx, testname, envname, options): + self.cmd_ctx = cmd_ctx + self.cmd_ctx.meta['piotest_processor'] = True + self.test_name = testname + self.env_name = envname + self.options = options + + def process(self): + self._progress("Building... (1/3)") + self._build_or_upload(["test"]) + self._progress("Uploading... (2/3)") + self._build_or_upload(["test", "upload"]) + self._progress("Testing... (3/3)") + sleep(1.0) # wait while board is starting... + return self._run_hardware_test() + + def _progress(self, text, is_error=False): + print_header("[test::%s] %s" % ( + click.style(self.test_name, fg="yellow", bold=True), + text + ), is_error=is_error) + click.echo() + + def _build_or_upload(self, target): + if self.test_name != "*": + self.cmd_ctx.meta['piotest'] = self.test_name + return self.cmd_ctx.invoke( + cmd_run, project_dir=self.options['project_dir'], + upload_port=self.options['upload_port'], + verbose=self.options['verbose'], environment=[self.env_name], + target=target + ) + + def _run_hardware_test(self): + click.echo("If you don't see any output for the first 10 secs, " + "please reset board (press reset button)") + click.echo() + ser = serial.Serial(self.get_serial_port(), self.SERIAL_BAUDRATE, + timeout=self.SERIAL_TIMEOUT) + passed = True + while True: + line = ser.readline().strip() + if not line: + continue + if line.endswith(":PASS"): + click.echo("%s\t%s" % ( + line[:-5], click.style("PASSED", fg="green"))) + elif ":FAIL:" in line: + passed = False + click.secho(line, fg="red") + else: + click.echo(line) + if all([l in line for l in ("Tests", "Failures", "Ignored")]): + break + ser.close() + return passed + + def get_serial_port(self): + config = self.options['project_config'] + envdata = {} + for k, v in config.items("env:" + self.env_name): + envdata[k] = v + + # if upload port is specified manually + if self.options.get("upload_port", envdata.get("upload_port")): + return self.options.get("upload_port", envdata.get("upload_port")) + + platform = envdata['platform'] + version = None + if "@" in platform: + platform, version = platform.rsplit("@", 1) + p = PlatformFactory.newPlatform(platform, version) + bconfig = p.board_config(envdata['board']) + + port = None + board_hwids = [] + if "build.hwids" in bconfig: + board_hwids = bconfig.get("build.hwids") + for item in util.get_serialports(): + if "VID:PID" not in item['hwid']: + continue + port = item['port'] + for hwid in board_hwids: + hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") + if hwid_str in item['hwid']: + return port + if not port: + raise exception.PlatformioException( + "Please specify `upload_port` for environment or use " + "global `--upload-port` option.") + return port diff --git a/platformio/exception.py b/platformio/exception.py index 3fe366f2..9b117740 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -197,6 +197,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/latest/platforms/"\ + "unit_testing.html" + + class UpgradeError(PlatformioException): MESSAGE = """{0} From 4b553dd659c625d472d745b7f1fe1cd8b3fb51d0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 15 Jun 2016 14:13:43 +0300 Subject: [PATCH 023/119] Revert link to the issue --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index e9b1ff11..3771ce8a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,7 @@ PlatformIO 3.0 * Decentralized architecture for development platforms: "platform.json", semantic versioning, package dependencies, embedded board configs, isolated build scripts + (`issue #479 `_) * Unit Testing for Embedded (`docs `__) (`issue #408 `_) From 1ac1e93bbf2621a7a28da342d944972d6466c0e2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 15 Jun 2016 14:36:10 +0300 Subject: [PATCH 024/119] Add links to the main command and repo with examples --- docs/platforms/unit_testing.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/platforms/unit_testing.rst b/docs/platforms/unit_testing.rst index 86c8eb63..b37c68aa 100644 --- a/docs/platforms/unit_testing.rst +++ b/docs/platforms/unit_testing.rst @@ -32,6 +32,8 @@ PlatformIO Test System consists of: * Firmware uploader * Test processor +There is special command :ref:`cmd_test` to run tests from PlatformIO Project. + .. contents:: .. _unit_testing_design: @@ -388,3 +390,8 @@ Test results ========================= [TEST SUMMARY] ===================================== test:*/env:uno PASSED ========================= [PASSED] Took 13.35 seconds ======================== + +------- + +For the other examples and source code please follow to +`PlatformIO Unit Testing Examples `_ repository. From 8a67ea9ca284f14889531520f6d394a083afc351 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 16 Jun 2016 00:36:04 +0300 Subject: [PATCH 025/119] Allow to ignore tests using glob patterns // Issue #408 --- docs/platforms/unit_testing.rst | 20 ++++++++--------- docs/userguide/cmd_test.rst | 26 ++++++++++++++++++++++ platformio/commands/test.py | 39 +++++++++++++++++++++++---------- 3 files changed, 63 insertions(+), 22 deletions(-) diff --git a/docs/platforms/unit_testing.rst b/docs/platforms/unit_testing.rst index b37c68aa..19f51e1c 100644 --- a/docs/platforms/unit_testing.rst +++ b/docs/platforms/unit_testing.rst @@ -44,7 +44,7 @@ Design PlatformIO Test System 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 + 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 @@ -53,8 +53,8 @@ PlatformIO Test System design is based on a few isolated components: Workflow -------- -1. Create PlatformIO project using :ref:`cmd_init` command -2. Place source code of main program to ``src`` directory +1. Create PlatformIO project using :ref:`cmd_init` command. +2. Place source code of main program to ``src`` directory. 3. Wrap ``main()`` or ``setup()/loop()`` methods of main program in ``UNIT_TEST`` guard: @@ -86,10 +86,10 @@ Workflow } #endif -4. Create ``test`` directory in the root of project. See :ref:`projectconf_pio_test_dir` +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()`` + 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 @@ -185,11 +185,11 @@ Example ------- 1. Please follow to :ref:`quickstart` and create "Blink Project". According - to the Unit Testing :ref:`unit_testing_design` it is the **Main program** + 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) + 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 + guard. 4. Run tests using :ref:`cmd_test` command. Project structure @@ -313,11 +313,11 @@ Source files delay(500); RUN_TEST(test_led_state_low); delay(500); + i++; } else if (i == max_blinks) { - UNITY_END(); // IMPORTANT LINE! + UNITY_END(); // stop unit testing } - i++; } #endif diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst index 8d163db8..af38f9b7 100644 --- a/docs/userguide/cmd_test.rst +++ b/docs/userguide/cmd_test.rst @@ -42,6 +42,32 @@ Options Process specified environments. More details :option:`platformio run --environment` +.. option:: + -i, --ignore + +Ignore tests where the name matches with specified pattern. More than one +option/pattern is allowed. + +.. 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 diff --git a/platformio/commands/test.py b/platformio/commands/test.py index 62105c7a..ee09f8a9 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from fnmatch import fnmatch from os import getcwd, listdir from os.path import isdir, join from time import sleep, time @@ -27,22 +28,21 @@ from platformio.managers.platform import PlatformFactory @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("--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.pass_context -def cli(ctx, environment, upload_port, # pylint: disable=R0913,R0914 +def cli(ctx, environment, ignore, upload_port, # pylint: disable=R0913,R0914 project_dir, verbose): assert check_project_envs(project_dir, environment) with util.cd(project_dir): test_dir = util.get_projecttest_dir() if not isdir(test_dir): raise exception.TestDirEmpty(test_dir) - config = util.get_project_config() - env_names = set( - [s[4:] for s in config.sections() if s.startswith("env:")]) + projectconf = util.get_project_config() test_names = [] for item in sorted(listdir(test_dir)): @@ -56,11 +56,20 @@ def cli(ctx, environment, upload_port, # pylint: disable=R0913,R0914 start_time = time() results = [] for testname in test_names: - for envname in env_names: + for envname in projectconf.sections(): + if not envname.startswith("env:"): + continue + envname = envname[4:] if environment and envname not in environment: continue + + # check ignore patterns + if testname != "*" and any([fnmatch(testname, i) for i in ignore]): + results.append((None, testname, envname)) + continue + tp = TestProcessor(ctx, testname, envname, { - "project_config": config, + "project_config": projectconf, "project_dir": project_dir, "upload_port": upload_port, "verbose": verbose @@ -72,13 +81,18 @@ def cli(ctx, environment, upload_port, # pylint: disable=R0913,R0914 passed = True for result in results: - if not result[0]: + status, testname, envname = result + status_str = click.style("PASSED", fg="green") + if status is False: passed = False + status_str = click.style("FAILED", fg="red") + elif status is None: + status_str = click.style("IGNORED", fg="yellow") + click.echo("test:%s/env:%s\t%s" % ( - click.style(result[1], fg="yellow"), - click.style(result[2], fg="cyan"), - click.style("PASSED" if passed else "FAILED", fg="green" - if passed else "red")), err=not passed) + click.style(testname, fg="yellow"), + click.style(envname, fg="cyan"), + status_str), err=status is False) print_header("[%s] Took %.2f seconds" % ( (click.style("PASSED", fg="green", bold=True) if passed @@ -144,7 +158,8 @@ class TestProcessor(object): line[:-5], click.style("PASSED", fg="green"))) elif ":FAIL:" in line: passed = False - click.secho(line, fg="red") + click.echo("%s\t%s" % ( + line, click.style("FAILED", fg="red"))) else: click.echo(line) if all([l in line for l in ("Tests", "Failures", "Ignored")]): From 8a13a18737a1e7fe6caea3eb8c13911850dc32a8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 16 Jun 2016 00:53:19 +0300 Subject: [PATCH 026/119] Fix PyLint warning --- platformio/commands/test.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/platformio/commands/test.py b/platformio/commands/test.py index ee09f8a9..0769f7f7 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.py @@ -42,14 +42,9 @@ def cli(ctx, environment, ignore, upload_port, # pylint: disable=R0913,R0914 test_dir = util.get_projecttest_dir() if not isdir(test_dir): raise exception.TestDirEmpty(test_dir) + test_names = get_test_names(test_dir) projectconf = util.get_project_config() - test_names = [] - for item in sorted(listdir(test_dir)): - if isdir(join(test_dir, item)): - test_names.append(item) - if not test_names: - test_names = ["*"] click.echo("Collected %d items" % len(test_names)) click.echo() @@ -201,3 +196,13 @@ class TestProcessor(object): "Please specify `upload_port` for environment or use " "global `--upload-port` option.") return port + + +def get_test_names(test_dir): + names = [] + for item in sorted(listdir(test_dir)): + if isdir(join(test_dir, item)): + names.append(item) + if not names: + names = ["*"] + return names From 76e07d5012211ae9c4988f2c2275e9fffda5ccde Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 20 Jun 2016 20:33:53 +0300 Subject: [PATCH 027/119] Refactor source files finder --- platformio/builder/tools/piotest.py | 4 +- platformio/builder/tools/platformio.py | 62 ++++++++++++++------------ 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index 8f97a9cc..75336f0e 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -74,8 +74,8 @@ def ProcessTest(env): src_filter = "+" src_filter += " +<%s%s>" % (env['PIOTEST'], sep) - return env.LookupSources( - "$BUILDTEST_DIR", test_dir, duplicate=False, src_filter=src_filter + return env.CollectBuildFiles( + "$BUILDTEST_DIR", test_dir, src_filter=src_filter ) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 7b866bca..ff48faea 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -92,9 +92,8 @@ def BuildProgram(env): LIBPATH=["$BUILD_DIR"] ) - sources = env.LookupSources( - "$BUILDSRC_DIR", "$PROJECTSRC_DIR", duplicate=False, - src_filter=env.get("SRC_FILTER")) + sources = env.CollectBuildFiles( + "$BUILDSRC_DIR", "$PROJECTSRC_DIR", src_filter=env.get("SRC_FILTER")) if "test" in COMMAND_LINE_TARGETS: sources.extend(env.ProcessTest()) @@ -173,12 +172,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): SRC_FILTER_PATTERNS_RE = re.compile(r"(\+|\-)<([^>]+)>") @@ -186,25 +180,32 @@ 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 + 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: - matches -= items - return sorted(list(matches)) + _append_build_item(items, item, src_dir) + if action == "+": + matches |= items + else: + matches -= items + return sorted(list(matches)) + +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 CollectBuildFiles(env, variant_dir, src_dir, + src_filter=None, duplicate=False): sources = [] variants = [] @@ -212,7 +213,8 @@ 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 or SRC_DEFAULT_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 @@ -257,7 +259,8 @@ def BuildLibrary(env, variant_dir, src_dir, src_filter=None): lib = env.Clone() return lib.Library( lib.subst(variant_dir), - lib.LookupSources(variant_dir, src_dir, src_filter=src_filter) + lib.CollectBuildFiles( + variant_dir, src_dir, src_filter=src_filter) ) @@ -413,8 +416,9 @@ def generate(env): env.AddMethod(ProcessFlags) env.AddMethod(ProcessUnFlags) env.AddMethod(IsFileWithExt) + env.AddMethod(MatchSourceFiles) env.AddMethod(VariantDirWrap) - env.AddMethod(LookupSources) + env.AddMethod(CollectBuildFiles) env.AddMethod(BuildFrameworks) env.AddMethod(BuildLibrary) env.AddMethod(BuildDependentLibraries) From d656d6d5941cd0445fbf78350b1e1317186cabbe Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 20 Jun 2016 21:37:10 +0300 Subject: [PATCH 028/119] Duplicate source files to pioenvs --- platformio/builder/tools/piotest.py | 2 +- platformio/builder/tools/platformio.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index 75336f0e..6d2ceb18 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -75,7 +75,7 @@ def ProcessTest(env): src_filter += " +<%s%s>" % (env['PIOTEST'], sep) return env.CollectBuildFiles( - "$BUILDTEST_DIR", test_dir, src_filter=src_filter + "$BUILDTEST_DIR", test_dir, src_filter=src_filter, duplicate=False ) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index ff48faea..a80c54b6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -93,7 +93,8 @@ def BuildProgram(env): ) sources = env.CollectBuildFiles( - "$BUILDSRC_DIR", "$PROJECTSRC_DIR", src_filter=env.get("SRC_FILTER")) + "$BUILDSRC_DIR", "$PROJECTSRC_DIR", + src_filter=env.get("SRC_FILTER"), duplicate=False) if "test" in COMMAND_LINE_TARGETS: sources.extend(env.ProcessTest()) @@ -205,7 +206,7 @@ def VariantDirWrap(env, variant_dir, src_dir, duplicate=True): def CollectBuildFiles(env, variant_dir, src_dir, - src_filter=None, duplicate=False): + src_filter=None, duplicate=True): sources = [] variants = [] From 4736bfeea624f93511871cbf4dea4fe1f987758b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 20 Jun 2016 21:47:13 +0300 Subject: [PATCH 029/119] Fix missed build.extra_flags for the board --- platformio/builder/tools/platformio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index a80c54b6..3d513a57 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -51,7 +51,7 @@ def BuildProgram(env): # process extra flags from board if "BOARD" in env: - env.ProcessFlags(env.BoardConfig().get("build.extra_flags")) + env.ProcessFlags(env.BoardConfig().get("build.extra_flags", None)) # remove base flags env.ProcessUnFlags(env.get("BUILD_UNFLAGS")) # apply user flags From bb7bf4e91b7e1b01927cbfedf1b0cb9e69dae058 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 22 Jun 2016 19:56:22 +0300 Subject: [PATCH 030/119] Fix issue with board extraFlags --- platformio/builder/tools/platformio.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 3d513a57..ac9306a3 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -50,8 +50,8 @@ def BuildProgram(env): ) # process extra flags from board - if "BOARD" in env: - env.ProcessFlags(env.BoardConfig().get("build.extra_flags", None)) + 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 From f8db1d11a703d5ebcc41a621109c4dc46046ac5b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 22 Jun 2016 21:25:44 +0300 Subject: [PATCH 031/119] New Library Build System: intelligent dependency finder that interprets C Preprocessor conditional macros // Resolve #432 --- HISTORY.rst | 3 + platformio/__init__.py | 2 +- platformio/builder/main.py | 3 +- platformio/builder/tools/piolib.py | 242 +++++++++++++++++++++++++ platformio/builder/tools/platformio.py | 162 +---------------- 5 files changed, 256 insertions(+), 156 deletions(-) create mode 100644 platformio/builder/tools/piolib.py diff --git a/HISTORY.rst b/HISTORY.rst index d7fb834a..a337c560 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,6 +13,9 @@ PlatformIO 3.0 (`issue #479 `_) * Unit Testing for Embedded (`docs `__) (`issue #408 `_) +* New Library Build System: intelligent dependency finder that interprets + C Preprocessor conditional macros + (`issue #432 `_) PlatformIO 2.0 -------------- diff --git a/platformio/__init__.py b/platformio/__init__.py index 1e9074a2..facbf112 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev1") +VERSION = (3, 0, "0.dev2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index ab957d57..94b1e41b 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -63,7 +63,8 @@ commonvars.AddVariables( DefaultEnvironment( tools=[ "gcc", "g++", "as", "ar", "gnulink", - "platformio", "devplatform", "piotest", "pioupload", "pioar", "piomisc" + "platformio", "devplatform", + "piolib", "piotest", "pioupload", "pioar", "piomisc" ], toolpath=[join(util.get_source_dir(), "builder", "tools")], variables=commonvars, diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py new file mode 100644 index 00000000..a0836a8a --- /dev/null +++ b/platformio/builder/tools/piolib.py @@ -0,0 +1,242 @@ +# Copyright 2014-present 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 __future__ import absolute_import + +import os +from os.path import basename, commonprefix, isdir, isfile, join +from sys import modules + +import SCons.Scanner + +from platformio import util + + +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("FRAMEWORK", "").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(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")): + 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 [] + + +class LibBuilderBase(object): + + def __init__(self, env, path): + self.env = env + self.path = path + self._is_built = False + + def __repr__(self): + return "%s(%r)" % (self.__class__, self.path) + + def __contains__(self, path): + return commonprefix((self.path, path)) == self.path + + @property + def name(self): + return basename(self.path) + + @property + def src_filter(self): + return " ".join([ + "+<*>", "-<.git%s>" % os.sep, "-" % os.sep, + "-" % 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", self.name) + + @property + def is_built(self): + return self._is_built + + def get_path_dirs(self, use_build_dir=False): + return [self.build_dir if use_build_dir else self.src_dir] + + def build(self): + print "Depends on: %s" % self.name + assert self._is_built is False + self._is_built = True + return self.env.BuildLibrary(self.build_dir, self.src_dir) + + +class UnknownLibBuilder(LibBuilderBase): + pass + + +class ArduinoLibBuilder(LibBuilderBase): + + def get_path_dirs(self, use_build_dir=False): + path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) + if not isdir(join(self.src_dir, "utility")): + return path_dirs + path_dirs.append(join(self.build_dir if use_build_dir + else self.src_dir, "utility")) + return path_dirs + + +class MbedLibBuilder(LibBuilderBase): + + def __init__(self, env, path): + self.module_json = {} + if isfile(join(path, "module.json")): + self.module_json = util.load_json(join(path, "module.json")) + + LibBuilderBase.__init__(self, env, path) + + @property + def src_dir(self): + if isdir(join(self.path, "source")): + return join(self.path, "source") + return LibBuilderBase.src_dir.fget(self) + + def get_path_dirs(self, use_build_dir=False): + path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) + for p in self.module_json.get("extraIncludes", []): + if p.startswith("source/"): + p = p[7:] + path_dirs.append( + join(self.build_dir if use_build_dir else self.src_dir, p)) + return path_dirs + + +class PlatformIOLibBuilder(LibBuilderBase): + + def __init__(self, env, path): + self.library_json = {} + if isfile(join(path, "library.json")): + self.library_json = util.load_json(join(path, "library.json")) + + LibBuilderBase.__init__(self, env, path) + + +def find_deps(env, scanner, path_dirs, src_dir, src_filter): + result = [] + for item in env.MatchSourceFiles(src_dir, src_filter): + result.extend(env.File(join(src_dir, item)).get_implicit_deps( + env, scanner, path_dirs)) + return result + + +def find_and_build_deps(env, lib_builders, scanner, + src_dir, src_filter): + path_dirs = tuple() + built_path_dirs = tuple() + for lb in lib_builders: + items = [env.Dir(d) for d in lb.get_path_dirs()] + if lb.is_built: + built_path_dirs += tuple(items) + else: + path_dirs += tuple(items) + path_dirs = built_path_dirs + path_dirs + + target_lbs = [] + deps = find_deps(env, scanner, path_dirs, src_dir, src_filter) + for d in deps: + for lb in lib_builders: + if d.get_abspath() in lb: + if lb not in target_lbs and not lb.is_built: + target_lbs.append(lb) + break + + libs = [] + # add build dirs to global CPPPATH + for lb in target_lbs: + env.Append( + CPPPATH=lb.get_path_dirs(use_build_dir=True) + ) + # start builder + for lb in target_lbs: + libs.append(lb.build()) + + if env.get("LIB_DFCYCLIC", "").lower() == "true": + for lb in target_lbs: + libs.extend(find_and_build_deps( + env, lib_builders, scanner, lb.src_dir, lb.src_filter)) + + return libs + + +def BuildDependentLibraries(env, src_dir): + lib_builders = [] + libs_dirs = [env.subst(d) for d in env.get("LIBSOURCE_DIRS", []) + if isdir(env.subst(d))] + for libs_dir in libs_dirs: + if not isdir(libs_dir): + continue + for item in sorted(os.listdir(libs_dir)): + if isdir(join(libs_dir, item)): + lib_builders.append( + LibBuilderFactory.new(env, join(libs_dir, item))) + + print "Looking for dependencies..." + print "Library locations: " + ", ".join(libs_dirs) + print "Collecting %d libraries" % len(lib_builders) + + return find_and_build_deps( + env, lib_builders, SCons.Scanner.C.CScanner(), + src_dir, env.get("SRC_FILTER")) + + +def exists(_): + return True + + +def generate(env): + env.AddMethod(BuildDependentLibraries) + return env diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index ac9306a3..138ba0b7 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -16,8 +16,8 @@ from __future__ import absolute_import import re 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, normpath, realpath from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript from SCons.Util import case_sensitive_suffixes @@ -26,11 +26,7 @@ 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 = " ".join(["+<*>", "-<.git%s>" % sep, "-" % sep]) def BuildProgram(env): @@ -173,7 +169,7 @@ def IsFileWithExt(env, file_, ext): # pylint: disable=W0613 return False -def MatchSourceFiles(env, src_dir, src_filter): +def MatchSourceFiles(env, src_dir, src_filter=None): SRC_FILTER_PATTERNS_RE = re.compile(r"(\+|\-)<([^>]+)>") @@ -181,6 +177,9 @@ def MatchSourceFiles(env, src_dir, src_filter): if env.IsFileWithExt(item, SRC_BUILD_EXT + SRC_HEADER_EXT): items.add(item.replace(src_dir + sep, "")) + src_dir = env.subst(src_dir) + src_filter = src_filter or SRC_FILTER_DEFAULT + matches = set() # correct fs directory separator src_filter = src_filter.replace("/", sep).replace("\\", sep) @@ -214,8 +213,7 @@ def CollectBuildFiles(env, variant_dir, src_dir, if src_dir.endswith(sep): src_dir = src_dir[:-1] - for item in env.MatchSourceFiles( - 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 @@ -265,149 +263,6 @@ def BuildLibrary(env, variant_dir, src_dir, src_filter=None): ) -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 exists(_): return True @@ -422,5 +277,4 @@ def generate(env): env.AddMethod(CollectBuildFiles) env.AddMethod(BuildFrameworks) env.AddMethod(BuildLibrary) - env.AddMethod(BuildDependentLibraries) return env From 3572b60afd51080c9aaa7b9c7177ebde0a0a996f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 22 Jun 2016 23:17:02 +0300 Subject: [PATCH 032/119] Show detailed build information about dependent libraries // Resolve #617 --- HISTORY.rst | 2 ++ platformio/builder/tools/piolib.py | 3 +-- platformio/builder/tools/platformio.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index a337c560..242f6205 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,8 @@ PlatformIO 3.0 * New Library Build System: intelligent dependency finder that interprets C Preprocessor conditional macros (`issue #432 `_) +* Show detailed build information about dependent libraries + (`issue #617 `_) PlatformIO 2.0 -------------- diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index a0836a8a..4547c24d 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -109,7 +109,7 @@ class LibBuilderBase(object): return [self.build_dir if use_build_dir else self.src_dir] def build(self): - print "Depends on: %s" % self.name + print "Depends on <%s> (%s)" % (self.name, self.path) assert self._is_built is False self._is_built = True return self.env.BuildLibrary(self.build_dir, self.src_dir) @@ -225,7 +225,6 @@ def BuildDependentLibraries(env, src_dir): LibBuilderFactory.new(env, join(libs_dir, item))) print "Looking for dependencies..." - print "Library locations: " + ", ".join(libs_dirs) print "Collecting %d libraries" % len(lib_builders) return find_and_build_deps( diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 138ba0b7..fa556e30 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import re from glob import glob from os import sep, walk -from os.path import basename, dirname, isdir, join, normpath, realpath +from os.path import basename, dirname, isdir, join, realpath from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript from SCons.Util import case_sensitive_suffixes From 1d7add213ecd12954e1e4a5ac514216f7f6bfd2d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 22 Jun 2016 23:21:36 +0300 Subject: [PATCH 033/119] Embedded Board compatibility with more than one development platform // Resolve #456 --- HISTORY.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 242f6205..3df3a341 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,8 @@ PlatformIO 3.0 (`issue #432 `_) * Show detailed build information about dependent libraries (`issue #617 `_) +* Embedded Board compatibility with more than one development platform + (`issue #456 `_) PlatformIO 2.0 -------------- From 2ed00064e2f7763fa9a8b36447d29201053c379f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 22 Jun 2016 23:58:42 +0300 Subject: [PATCH 034/119] Fix PyLint warning --- platformio/builder/tools/piolib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 4547c24d..2f6f49a9 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -143,7 +143,7 @@ class MbedLibBuilder(LibBuilderBase): def src_dir(self): if isdir(join(self.path, "source")): return join(self.path, "source") - return LibBuilderBase.src_dir.fget(self) + return super(LibBuilderBase, self).src_dir # pylint: disable=no-member def get_path_dirs(self, use_build_dir=False): path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) From d4a866414f764e7b4ae190868096305b07882ce5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 23 Jun 2016 15:51:08 +0300 Subject: [PATCH 035/119] Minor fixes --- platformio/builder/tools/piolib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 2f6f49a9..73f97b13 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -56,7 +56,7 @@ class LibBuilderFactory(object): # check source files for root, _, files in os.walk(path, followlinks=True): for fname in files: - if not env.IsFileWithExt(fname, ("c", "cpp", "h")): + if not env.IsFileWithExt(fname, ("c", "cpp", "h", "hpp")): continue with open(join(root, fname)) as f: content = f.read() @@ -109,7 +109,7 @@ class LibBuilderBase(object): return [self.build_dir if use_build_dir else self.src_dir] def build(self): - print "Depends on <%s> (%s)" % (self.name, self.path) + print "Depends on <%s>" % self.name assert self._is_built is False self._is_built = True return self.env.BuildLibrary(self.build_dir, self.src_dir) From 476b43d539204804a3f8e94e95eb6bb402b8806b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 23 Jun 2016 21:39:24 +0300 Subject: [PATCH 036/119] Fix issue with super() --- platformio/builder/tools/piolib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 73f97b13..ae3ba1dc 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -143,7 +143,7 @@ class MbedLibBuilder(LibBuilderBase): def src_dir(self): if isdir(join(self.path, "source")): return join(self.path, "source") - return super(LibBuilderBase, self).src_dir # pylint: disable=no-member + return LibBuilderBase.src_dir.fget(self) # pylint: disable=no-member def get_path_dirs(self, use_build_dir=False): path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) From dd111aac4adc8e421299951b69eda737d5e15dc3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 23 Jun 2016 23:25:13 +0300 Subject: [PATCH 037/119] Library deep search for dependency finder --- HISTORY.rst | 2 +- docs/projectconf.rst | 59 ++++++++++++++++++++++++------ platformio/builder/main.py | 2 +- platformio/builder/tools/piolib.py | 2 +- platformio/commands/run.py | 2 +- 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3df3a341..90250fa8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,7 +14,7 @@ PlatformIO 3.0 * Unit Testing for Embedded (`docs `__) (`issue #408 `_) * New Library Build System: intelligent dependency finder that interprets - C Preprocessor conditional macros + C Preprocessor conditional macros, `library deep search `__ (`issue #432 `_) * Show detailed build information about dependent libraries (`issue #617 `_) diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 8572d229..89eaf6c4 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -620,24 +620,59 @@ Example: [env:ignore_some_libs] lib_ignore = SPI,EngduinoV3_ID123 -``lib_dfcyclic`` -^^^^^^^^^^^^^^^^ +``lib_deep_search`` +^^^^^^^^^^^^^^^^^^^ -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`. +By default, this option is turned OFF (``lib_deep_search = false``) and means +that ``Library Dependency Finder (LDF)`` will looking only for the libraries +that are mentioned (using ``#include <...>``) in the source files from the +project :ref:`projectconf_pio_src_dir`. Also, ``LDF`` analyzes nested +``#include <...>`` by default. -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 +If you want to enable deep search, please set this option to ``true``. +Founded library will be treated like a new source files and ``LDF`` will search dependencies for it. -Example: +For example, there are 2 libraries: -.. code-block:: ini +* Library "Foo" with files: - [env:libs_with_enabled_ldf_cyclic] - lib_dfcyclic = True + - ``Foo/foo.h`` + - ``Foo/foo.cpp`` + +* Library "Bar" with files: + + - ``Bar/bar.h`` + - ``Bar/bar.cpp`` + +:Case 1: + + * ``lib_deep_search = false`` + * ``Foo/foo.h`` depends on "Bar" library (contains ``#include ``) + * ``#include `` is located in the 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_deep_search = false`` + * ``Foo/foo.cpp`` depends on "Bar" library (contains ``#include ``) + * ``#include `` is located in the 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_deep_search = true`` + * ``Foo/foo.cpp`` depends on "Bar" library (contains ``#include ``) + * ``#include `` is located in the 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 dependent libraries will not be parsed. ----------- diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 94b1e41b..37ad9648 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -41,7 +41,7 @@ commonvars.AddVariables( ("SRC_BUILD_FLAGS",), ("BUILD_UNFLAGS",), ("SRC_FILTER",), - ("LIB_DFCYCLIC",), + ("LIB_DEEP_SEARCH",), ("LIB_IGNORE",), ("LIB_USE",), diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index ae3ba1dc..c11ceca4 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -204,7 +204,7 @@ def find_and_build_deps(env, lib_builders, scanner, for lb in target_lbs: libs.append(lb.build()) - if env.get("LIB_DFCYCLIC", "").lower() == "true": + if env.get("LIB_DEEP_SEARCH", "").lower() == "true": for lb in target_lbs: libs.extend(find_and_build_deps( env, lib_builders, scanner, lb.src_dir, lb.src_filter)) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index fca60880..e2d735d6 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -101,7 +101,7 @@ class EnvironmentProcessor(object): "INSTALL_LIBS": "LIB_INSTALL", "IGNORE_LIBS": "LIB_IGNORE", "USE_LIBS": "LIB_USE", - "LDF_CYCLIC": "LIB_DFCYCLIC", + "LIB_DFCYCLIC": "LIB_DEEP_SEARCH", "SRCBUILD_FLAGS": "SRC_BUILD_FLAGS" } From bc30bf55660c33e2d4908efb5b658098982fe2a8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 24 Jun 2016 12:54:01 +0300 Subject: [PATCH 038/119] Typo fixes --- docs/projectconf.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 89eaf6c4..f88fc21e 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -624,13 +624,13 @@ Example: ^^^^^^^^^^^^^^^^^^^ By default, this option is turned OFF (``lib_deep_search = false``) and means -that ``Library Dependency Finder (LDF)`` will looking only for the libraries +that ``Library Dependency Finder (LDF)`` will look only for the libraries that are mentioned (using ``#include <...>``) in the source files from the project :ref:`projectconf_pio_src_dir`. Also, ``LDF`` analyzes nested ``#include <...>`` by default. If you want to enable deep search, please set this option to ``true``. -Founded library will be treated like a new source files and +Found library will be treated like the new source files and ``LDF`` will search dependencies for it. For example, there are 2 libraries: @@ -649,7 +649,7 @@ For example, there are 2 libraries: * ``lib_deep_search = false`` * ``Foo/foo.h`` depends on "Bar" library (contains ``#include ``) - * ``#include `` is located in the one of the project source files + * ``#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". @@ -658,7 +658,7 @@ For example, there are 2 libraries: * ``lib_deep_search = false`` * ``Foo/foo.cpp`` depends on "Bar" library (contains ``#include ``) - * ``#include `` is located in the one of the project source files + * ``#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``). @@ -667,7 +667,7 @@ For example, there are 2 libraries: * ``lib_deep_search = true`` * ``Foo/foo.cpp`` depends on "Bar" library (contains ``#include ``) - * ``#include `` is located in the one of the project source files + * ``#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 ``. From 51a9565a727e7df14d709e6dd90d714319070343 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Jun 2016 13:23:24 +0300 Subject: [PATCH 039/119] Refactored `lib_force` and `lib_ignore` logic --- docs/projectconf.rst | 15 ++-- platformio/__init__.py | 2 +- platformio/builder/main.py | 4 +- platformio/builder/tools/piolib.py | 112 ++++++++++++++++++++-------- platformio/builder/tools/piomisc.py | 31 +------- platformio/commands/run.py | 5 +- 6 files changed, 96 insertions(+), 73 deletions(-) diff --git a/docs/projectconf.rst b/docs/projectconf.rst index f88fc21e..77d72526 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -595,18 +595,19 @@ Example: [env:depends_on_some_libs] lib_install = 1,13,19 -``lib_use`` -^^^^^^^^^^^ +``lib_force`` +^^^^^^^^^^^^^ -Specify libraries which should be used by ``Library Dependency Finder (LDF)`` with -the highest priority. +Force Library Build System to build specified libraries if even they are not +included in the project source code. Also, these libraries will be processed +in the first order. Example: .. code-block:: ini - [env:libs_with_highest_priority] - lib_use = OneWire_ID1,SPI + [env:myenv] + lib_force = OneWire, SPI ``lib_ignore`` ^^^^^^^^^^^^^^ @@ -618,7 +619,7 @@ Example: .. code-block:: ini [env:ignore_some_libs] - lib_ignore = SPI,EngduinoV3_ID123 + lib_ignore = SPI, Ethernet ``lib_deep_search`` ^^^^^^^^^^^^^^^^^^^ diff --git a/platformio/__init__.py b/platformio/__init__.py index facbf112..ca2ab2ae 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev2") +VERSION = (3, 0, "0.dev3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 37ad9648..0fdcc752 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -43,7 +43,7 @@ commonvars.AddVariables( ("SRC_FILTER",), ("LIB_DEEP_SEARCH",), ("LIB_IGNORE",), - ("LIB_USE",), + ("LIB_FORCE",), # board options ("BOARD",), @@ -104,7 +104,7 @@ for k in commonvars.keys(): env.LoadDevPlatform(commonvars) # Parse library names -for opt in ("LIB_IGNORE", "LIB_USE"): +for opt in ("LIB_IGNORE", "LIB_FORCE"): if opt not in env: continue env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index c11ceca4..e97f271c 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=no-member + from __future__ import absolute_import import os @@ -73,6 +75,7 @@ class LibBuilderBase(object): self.env = env self.path = path self._is_built = False + self._manifest = self.load_manifest() def __repr__(self): return "%s(%r)" % (self.__class__, self.path) @@ -82,7 +85,11 @@ class LibBuilderBase(object): @property def name(self): - return basename(self.path) + return self._manifest.get("name", basename(self.path)) + + @property + def version(self): + return self._manifest.get("version") @property def src_filter(self): @@ -105,13 +112,25 @@ class LibBuilderBase(object): def is_built(self): return self._is_built + def load_manifest(self): # pylint: disable=no-self-use + return {} + def get_path_dirs(self, use_build_dir=False): return [self.build_dir if use_build_dir else self.src_dir] + def append_to_cpppath(self): + self.env.AppendUnique( + CPPPATH=self.get_path_dirs(use_build_dir=True) + ) + def build(self): - print "Depends on <%s>" % self.name + if self.version: + print "Depends on <%s> v%s" % (self.name, self.version) + else: + print "Depends on <%s>" % self.name assert self._is_built is False self._is_built = True + self.append_to_cpppath() return self.env.BuildLibrary(self.build_dir, self.src_dir) @@ -121,33 +140,43 @@ class UnknownLibBuilder(LibBuilderBase): 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_path_dirs(self, use_build_dir=False): path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) if not isdir(join(self.src_dir, "utility")): return path_dirs - path_dirs.append(join(self.build_dir if use_build_dir - else self.src_dir, "utility")) + path_dirs.append( + join(self.build_dir if use_build_dir else self.src_dir, "utility")) return path_dirs class MbedLibBuilder(LibBuilderBase): - def __init__(self, env, path): - self.module_json = {} - if isfile(join(path, "module.json")): - self.module_json = util.load_json(join(path, "module.json")) - - LibBuilderBase.__init__(self, env, path) + 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) # pylint: disable=no-member + return LibBuilderBase.src_dir.fget(self) def get_path_dirs(self, use_build_dir=False): path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) - for p in self.module_json.get("extraIncludes", []): + for p in self._manifest.get("extraIncludes", []): if p.startswith("source/"): p = p[7:] path_dirs.append( @@ -157,12 +186,11 @@ class MbedLibBuilder(LibBuilderBase): class PlatformIOLibBuilder(LibBuilderBase): - def __init__(self, env, path): - self.library_json = {} - if isfile(join(path, "library.json")): - self.library_json = util.load_json(join(path, "library.json")) - - LibBuilderBase.__init__(self, env, path) + 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 find_deps(env, scanner, path_dirs, src_dir, src_filter): @@ -195,11 +223,9 @@ def find_and_build_deps(env, lib_builders, scanner, break libs = [] - # add build dirs to global CPPPATH + # append PATH directories to global CPPPATH before build starts for lb in target_lbs: - env.Append( - CPPPATH=lb.get_path_dirs(use_build_dir=True) - ) + lb.append_to_cpppath() # start builder for lb in target_lbs: libs.append(lb.build()) @@ -212,24 +238,45 @@ def find_and_build_deps(env, lib_builders, scanner, return libs -def BuildDependentLibraries(env, src_dir): - lib_builders = [] +def GetLibBuilders(env): + items = [] libs_dirs = [env.subst(d) for d in env.get("LIBSOURCE_DIRS", []) if isdir(env.subst(d))] for libs_dir in libs_dirs: - if not isdir(libs_dir): - continue for item in sorted(os.listdir(libs_dir)): - if isdir(join(libs_dir, item)): - lib_builders.append( - LibBuilderFactory.new(env, join(libs_dir, item))) + if item == "__cores__" or not isdir(join(libs_dir, item)): + continue + lb = LibBuilderFactory.new(env, join(libs_dir, item)) + if lb.name in env.get("LIB_IGNORE", []): + continue + items.append(lb) + return items + + +def BuildDependentLibraries(env, src_dir): + libs = [] + scanner = SCons.Scanner.C.CScanner() + lib_builders = env.GetLibBuilders() print "Looking for dependencies..." print "Collecting %d libraries" % len(lib_builders) - return find_and_build_deps( - env, lib_builders, SCons.Scanner.C.CScanner(), - src_dir, env.get("SRC_FILTER")) + built_lib_names = [] + for lib_name in env.get("LIB_FORCE", []): + for lb in lib_builders: + if lb.name != lib_name or lb.name in built_lib_names: + continue + built_lib_names.append(lb.name) + libs.extend(find_and_build_deps( + env, lib_builders, scanner, lb.src_dir, lb.src_filter)) + if not lb.is_built: + libs.append(lb.build()) + + # process project source code + libs.extend(find_and_build_deps( + env, lib_builders, scanner, src_dir, env.get("SRC_FILTER"))) + + return libs def exists(_): @@ -237,5 +284,6 @@ def exists(_): 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 6d0095f5..26ec5945 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -145,7 +145,7 @@ def DumpIDEData(env): def get_includes(env_): includes = [] - # includes from used framework and libs + # includes from used frameworks and libs for item in env_.get("VARIANT_DIRS", []): if "$BUILDSRC_DIR" in item[0]: continue @@ -158,9 +158,8 @@ def DumpIDEData(env): 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_path_dirs()) # includes from toolchains p = env.DevPlatform() @@ -177,30 +176,6 @@ def DumpIDEData(env): 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__": - board_core = env_.BoardConfig().get("build.core") - 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 diff --git a/platformio/commands/run.py b/platformio/commands/run.py index e2d735d6..78591e2e 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -100,9 +100,8 @@ class EnvironmentProcessor(object): RENAMED_OPTIONS = { "INSTALL_LIBS": "LIB_INSTALL", "IGNORE_LIBS": "LIB_IGNORE", - "USE_LIBS": "LIB_USE", - "LIB_DFCYCLIC": "LIB_DEEP_SEARCH", - "SRCBUILD_FLAGS": "SRC_BUILD_FLAGS" + "LIB_USE": "LIB_FORCE", + "LIB_DFCYCLIC": "LIB_DEEP_SEARCH" } def __init__(self, cmd_ctx, name, options, # pylint: disable=R0913 From 7344828cf798ee55e1e8ad2344a37e3ea7681f14 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Jun 2016 13:34:51 +0300 Subject: [PATCH 040/119] Update history --- HISTORY.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 90250fa8..d5cf04e6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,7 +14,8 @@ PlatformIO 3.0 * Unit Testing for Embedded (`docs `__) (`issue #408 `_) * New Library Build System: intelligent dependency finder that interprets - C Preprocessor conditional macros, `library deep search `__ + C Preprocessor conditional macros, `library deep search `__, support for the 3rd party + manifests (Arduino IDE ``library.properties``, ARM mbed ``module.json``) (`issue #432 `_) * Show detailed build information about dependent libraries (`issue #617 `_) From 13112ad6d4266b5de48033e2ca7d5f138c991af5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 6 Jul 2016 15:27:46 +0300 Subject: [PATCH 041/119] Fix issue when development platform doesn't support frameworks --- examples | 2 +- platformio/builder/tools/piomisc.py | 4 ++-- platformio/managers/platform.py | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples b/examples index a5498135..6c0a7e44 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit a5498135baca2dd71e518406ee5cf19ac4be058b +Subproject commit 6c0a7e4458056fa04657a14422aeae277560341d diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 26ec5945..9b657e68 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -17,8 +17,8 @@ from __future__ import absolute_import import atexit import re from glob import glob -from os import environ, listdir, remove -from os.path import isdir, isfile, join +from os import environ, remove +from os.path import isfile, join from platformio import util diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index c27a66ec..4c148b50 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -461,6 +461,8 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): def configure_default_packages(self, variables, targets): # enbale used frameworks for framework in variables.get("framework", "").split(","): + if not self.frameworks: + continue framework = framework.lower().strip() if not framework or framework not in self.frameworks: continue From d88997c4181a2756a4a1dccf01d2c5494dbea893 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Jul 2016 19:30:02 +0300 Subject: [PATCH 042/119] Typo fix --- platformio/builder/tools/devplatform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/devplatform.py b/platformio/builder/tools/devplatform.py index 4c7921dd..5004c0c7 100644 --- a/platformio/builder/tools/devplatform.py +++ b/platformio/builder/tools/devplatform.py @@ -78,7 +78,7 @@ def LoadDevPlatform(env, variables): return board_config = env.BoardConfig() - for k in variables: + for k in variables.keys(): if (k in env or not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")])): continue From 8427b9c7eef25c89322f9dffd19644ee197ad41a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 11 Jul 2016 13:27:30 +0300 Subject: [PATCH 043/119] Create BasePkgManager for PlatformManager and Library Manager --- platformio/managers/package.py | 36 +++++++++++++++++++++------------ platformio/managers/platform.py | 18 +++++++++-------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 5d0e0a63..79f57416 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -27,25 +27,25 @@ from platformio.unpacker import FileUnpacker from platformio.vcsclient import VCSClientFactory -class PackageManager(object): +class BasePkgManager(object): _INSTALLED_CACHE = {} - def __init__(self, package_dir=None, repositories=None): + def __init__(self, package_dir, repositories=None): self._INSTALLED_CACHE = {} self.repositories = repositories - self.package_dir = package_dir or join(util.get_home_dir(), "packages") + self.package_dir = package_dir if not isdir(self.package_dir): os.makedirs(self.package_dir) assert isdir(self.package_dir) @staticmethod def reset_cache(): - PackageManager._INSTALLED_CACHE = {} + BasePkgManager._INSTALLED_CACHE = {} @property def manifest_name(self): - return "package.json" + raise NotImplementedError() @staticmethod def download(url, dest_dir, sha1=None): @@ -133,8 +133,8 @@ class PackageManager(object): return best def get_installed(self): - if self.package_dir in PackageManager._INSTALLED_CACHE: - return PackageManager._INSTALLED_CACHE[self.package_dir] + 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)): manifest_path = join(self.package_dir, p, self.manifest_name) @@ -144,7 +144,7 @@ class PackageManager(object): manifest['_manifest_path'] = manifest_path assert set(["name", "version"]) <= set(manifest.keys()) items.append(manifest) - PackageManager._INSTALLED_CACHE[self.package_dir] = items + BasePkgManager._INSTALLED_CACHE[self.package_dir] = items return items def is_installed(self, name, requirements=None): @@ -183,7 +183,8 @@ class PackageManager(object): self.reset_cache() if trigger_event: telemetry.on_event( - category="PackageManager", action="Install", label=name) + category=self.__class__.__name__, + action="Install", label=name) return join(pkg_dir, self.manifest_name) @@ -300,7 +301,8 @@ class PackageManager(object): self.reset_cache() if trigger_event: telemetry.on_event( - category="PackageManager", action="Uninstall", label=name) + category=self.__class__.__name__, + action="Uninstall", label=name) def update(self, name, requirements=None): click.echo("Updating %s %s @ %s:" % ( @@ -310,8 +312,8 @@ class PackageManager(object): latest_version = self.get_latest_repo_version(name, requirements) if latest_version is None: - click.secho("Ignored! '%s' is not listed in " - "Package Repository" % name, fg="yellow") + click.secho("Ignored! '%s' is not listed in repository" % name, + fg="yellow") return current = None @@ -341,7 +343,8 @@ class PackageManager(object): self.install(name, latest_version, trigger_event=False) telemetry.on_event( - category="PackageManager", action="Update", label=name) + category=self.__class__.__name__, + action="Update", label=name) return True @@ -384,3 +387,10 @@ class PackageRepoIterator(object): return manifest[self.package] else: return self.next() + + +class PackageManager(BasePkgManager): + + @property + def manifest_name(self): + return "package.json" diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index ebff72c8..504821ff 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -24,13 +24,15 @@ import click import semantic_version from platformio import exception, util -from platformio.managers.package import PackageManager +from platformio.managers.package import BasePkgManager, PackageManager + +PACKAGE_DIR = join(util.get_home_dir(), "packages") -class PlatformManager(PackageManager): +class PlatformManager(BasePkgManager): def __init__(self): - PackageManager.__init__( + BasePkgManager.__init__( self, join(util.get_home_dir(), "platforms"), ["http://dl.platformio.org/platforms/manifest.json"] @@ -43,7 +45,7 @@ class PlatformManager(PackageManager): def install(self, # pylint: disable=too-many-arguments,arguments-differ name, requirements=None, with_packages=None, without_packages=None, skip_default_packages=False): - manifest_path = PackageManager.install(self, name, requirements) + manifest_path = BasePkgManager.install(self, name, requirements) p = PlatformFactory.newPlatform(manifest_path, requirements) p.install_packages( with_packages, without_packages, skip_default_packages) @@ -53,14 +55,14 @@ class PlatformManager(PackageManager): def uninstall(self, # pylint: disable=arguments-differ name, requirements=None): p = PlatformFactory.newPlatform(name, requirements) - PackageManager.uninstall(self, name, requirements) + BasePkgManager.uninstall(self, name, requirements) self.cleanup_packages(p.packages.keys()) return True def update(self, # pylint: disable=arguments-differ name, requirements=None, only_packages=False): if not only_packages: - PackageManager.update(self, name, requirements) + BasePkgManager.update(self, name, requirements) p = PlatformFactory.newPlatform(name, requirements) p.update_packages() self.cleanup_packages(p.packages.keys()) @@ -82,7 +84,7 @@ class PlatformManager(PackageManager): deppkgs[pkgname] = set() deppkgs[pkgname].add(pkgmanifest['version']) - pm = PackageManager() + pm = PackageManager(PACKAGE_DIR) for manifest in pm.get_installed(): if manifest['name'] not in names: continue @@ -322,7 +324,7 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): self._manifest = util.load_json(manifest_path) self.pm = PackageManager( - repositories=self._manifest.get("packageRepositories")) + PACKAGE_DIR, self._manifest.get("packageRepositories")) self._found_error = False self._last_echo_line = None From 4b622b86036bd519d6958845eb76ab6fd9078d72 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Jul 2016 13:24:44 +0300 Subject: [PATCH 044/119] Improve library builder for Arduino lib structure --- platformio/builder/tools/piolib.py | 26 +++++++++++++++++--------- platformio/builder/tools/platformio.py | 4 +++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index e97f271c..d110a279 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -23,6 +23,7 @@ from sys import modules import SCons.Scanner from platformio import util +from platformio.builder.tools import platformio as piotool class LibBuilderFactory(object): @@ -72,7 +73,7 @@ class LibBuilderFactory(object): class LibBuilderBase(object): def __init__(self, env, path): - self.env = env + self.env = env.Clone() self.path = path self._is_built = False self._manifest = self.load_manifest() @@ -93,11 +94,10 @@ class LibBuilderBase(object): @property def src_filter(self): - return " ".join([ - "+<*>", "-<.git%s>" % os.sep, "-" % os.sep, + return piotool.SRC_FILTER_DEFAULT + [ "-" % os.sep, "-" % os.sep, "-" % os.sep, "-" % os.sep - ]) + ] @property def src_dir(self): @@ -118,8 +118,8 @@ class LibBuilderBase(object): def get_path_dirs(self, use_build_dir=False): return [self.build_dir if use_build_dir else self.src_dir] - def append_to_cpppath(self): - self.env.AppendUnique( + def append_to_cpppath(self, env): + env.AppendUnique( CPPPATH=self.get_path_dirs(use_build_dir=True) ) @@ -130,8 +130,8 @@ class LibBuilderBase(object): print "Depends on <%s>" % self.name assert self._is_built is False self._is_built = True - self.append_to_cpppath() - return self.env.BuildLibrary(self.build_dir, self.src_dir) + return self.env.BuildLibrary( + self.build_dir, self.src_dir, self.src_filter) class UnknownLibBuilder(LibBuilderBase): @@ -160,6 +160,13 @@ class ArduinoLibBuilder(LibBuilderBase): join(self.build_dir if use_build_dir else self.src_dir, "utility")) return path_dirs + @property + def src_filter(self): + if isdir(join(self.path, "src")): + return LibBuilderBase.src_filter.fget(self) + return ["+<*.%s>" % ext + for ext in piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT] + class MbedLibBuilder(LibBuilderBase): @@ -225,7 +232,7 @@ def find_and_build_deps(env, lib_builders, scanner, libs = [] # append PATH directories to global CPPPATH before build starts for lb in target_lbs: - lb.append_to_cpppath() + lb.append_to_cpppath(env) # start builder for lb in target_lbs: libs.append(lb.build()) @@ -270,6 +277,7 @@ def BuildDependentLibraries(env, src_dir): libs.extend(find_and_build_deps( env, lib_builders, scanner, lb.src_dir, lb.src_filter)) if not lb.is_built: + lb.append_to_cpppath(env) libs.append(lb.build()) # process project source code diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index b96c47a6..91a0a149 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -26,7 +26,7 @@ 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_FILTER_DEFAULT = " ".join(["+<*>", "-<.git%s>" % sep, "-" % sep]) +SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] def BuildProgram(env): @@ -179,6 +179,8 @@ def MatchSourceFiles(env, src_dir, src_filter=None): 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 From 4997528f6aaf3e71ab9945ce61edf7a51991836a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Jul 2016 16:12:07 +0300 Subject: [PATCH 045/119] Handle specific extra build flags from library.json // Resolve #289 --- HISTORY.rst | 3 + docs/faq.rst | 6 -- docs/librarymanager/config.rst | 80 +++++++++++++++++++++++++- docs/projectconf.rst | 2 + platformio/__init__.py | 2 +- platformio/builder/tools/piolib.py | 63 +++++++++++++++++--- platformio/builder/tools/platformio.py | 2 +- 7 files changed, 141 insertions(+), 17 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index cded83ea..a948fcfa 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,9 @@ PlatformIO 3.0 C Preprocessor conditional macros, `library deep search `__, support for the 3rd party manifests (Arduino IDE ``library.properties``, ARM mbed ``module.json``) (`issue #432 `_) +* Handle extra build flags and build script from + `library.json `__ + (`issue #289 `_) * Show detailed build information about dependent libraries (`issue #617 `_) * Embedded Board compatibility with more than one development platform diff --git a/docs/faq.rst b/docs/faq.rst index 663c108f..75ed3cfb 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -155,12 +155,6 @@ Answered in `issue #144 `_ -* `#331: Unable to use MySensors library `_ - ARM toolchain: cc1plus: error while loading shared libraries '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index c56d74ed..2072aabc 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -22,6 +22,7 @@ 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 @@ -397,7 +398,7 @@ See more ``library.json`` :ref:`library_creating_examples`. .. _libjson_examples: ``examples`` ----------------- +------------ *Optional* | Type: ``String`` or ``Array`` | `Glob Pattern `_ @@ -413,3 +414,80 @@ A list of example patterns. This field is predefined with default value: "[Ee]xamples/*/*.ino", "[Ee]xamples/*/*.pde" ] + + +.. _libjson_build: + +``build`` +------------ + +*Optional* | Type: ``Object`` + +Specify advanced settings, options and flags for the build system. Possible +options: + +* ``flags`` - extra flags to control preprocessing, compilation, assembly and + linking processes. More details :ref:`projectconf_build_flags` +* ``unflags`` - remove base/initial flags which were set by development + platform. More details :ref:`projectconf_build_unflags` +* ``srcFilter`` - specify which source files should be included/excluded + from build process. More details :ref:`projectconf_src_filter` +* ``extraScript`` - launch extra script before build process. + More details :ref:`projectconf_extra_script`. + +**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 ``C11`` + +.. code-block:: javascript + + "build": { + "unflags": "-std=gnu++11", + "flags": "-std=c99" + } + +4. Build source files (``c, cpp, h``) only from the root 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() + + # some python code that generates headers files "on-the-fly" diff --git a/docs/projectconf.rst b/docs/projectconf.rst index f3700743..5d5b9596 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -422,6 +422,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`` ^^^^^^^^^^^^^^^^^ diff --git a/platformio/__init__.py b/platformio/__init__.py index 15f4a2a8..6ab03493 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev4") +VERSION = (3, 0, "0.dev5") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index d110a279..ac31c85f 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import os -from os.path import basename, commonprefix, isdir, isfile, join +from os.path import basename, commonprefix, isdir, isfile, join, realpath from sys import modules import SCons.Scanner @@ -73,7 +73,7 @@ class LibBuilderFactory(object): class LibBuilderBase(object): def __init__(self, env, path): - self.env = env.Clone() + self.env = env self.path = path self._is_built = False self._manifest = self.load_manifest() @@ -108,6 +108,18 @@ class LibBuilderBase(object): def build_dir(self): return join("$BUILD_DIR", "lib", self.name) + @property + def build_flags(self): + return None + + @property + def build_unflags(self): + return None + + @property + def extra_script(self): + return None + @property def is_built(self): return self._is_built @@ -118,8 +130,8 @@ class LibBuilderBase(object): def get_path_dirs(self, use_build_dir=False): return [self.build_dir if use_build_dir else self.src_dir] - def append_to_cpppath(self, env): - env.AppendUnique( + def append_to_cpppath(self): + self.env.AppendUnique( CPPPATH=self.get_path_dirs(use_build_dir=True) ) @@ -130,8 +142,20 @@ class LibBuilderBase(object): print "Depends on <%s>" % self.name assert self._is_built is False self._is_built = True - return self.env.BuildLibrary( - self.build_dir, self.src_dir, self.src_filter) + self.append_to_cpppath() + + env = self.env.Clone() + with util.cd(self.path): + env.ProcessUnFlags(self.build_unflags) + env.ProcessFlags(self.build_flags) + if self.extra_script: + env.SConscript(realpath(self.extra_script), exports="env") + + # copy some data to global env + for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): + self.env.AppendUnique(**{key: env.get(key)}) + + return env.BuildLibrary(self.build_dir, self.src_dir, self.src_filter) class UnknownLibBuilder(LibBuilderBase): @@ -199,6 +223,30 @@ class PlatformIOLibBuilder(LibBuilderBase): assert "name" in manifest return manifest + @property + def src_filter(self): + if "srcFilter" in self._manifest.get("build", {}): + return self._manifest.get("build").get("srcFilter") + 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 "extra_script" in self._manifest.get("build", {}): + return self._manifest.get("build").get("extra_script") + return LibBuilderBase.extra_script.fget(self) + def find_deps(env, scanner, path_dirs, src_dir, src_filter): result = [] @@ -232,7 +280,7 @@ def find_and_build_deps(env, lib_builders, scanner, libs = [] # append PATH directories to global CPPPATH before build starts for lb in target_lbs: - lb.append_to_cpppath(env) + lb.append_to_cpppath() # start builder for lb in target_lbs: libs.append(lb.build()) @@ -277,7 +325,6 @@ def BuildDependentLibraries(env, src_dir): libs.extend(find_and_build_deps( env, lib_builders, scanner, lb.src_dir, lb.src_filter)) if not lb.is_built: - lb.append_to_cpppath(env) libs.append(lb.build()) # process project source code diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 91a0a149..7ce3692e 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -154,7 +154,7 @@ def ProcessUnFlags(env, flags): all_flags = set(all_flags) for key in parsed_flags: - cur_flags = set(env.get(key, [])) + cur_flags = set(env.Flatten(env.get(key, []))) for item in cur_flags & all_flags: while item in env[key]: env[key].remove(item) From c7d9ab84747e81ac16351c33e51b69ff9f2942f6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Jul 2016 18:41:16 +0300 Subject: [PATCH 046/119] Allow to use extra build options as array for library.json // Issue #289 --- docs/librarymanager/config.rst | 41 +++++++++++++++++++------- platformio/builder/tools/platformio.py | 5 +++- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index 2072aabc..50a82cc9 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -426,14 +426,28 @@ A list of example patterns. This field is predefined with default value: Specify advanced settings, options and flags for the build system. Possible options: -* ``flags`` - extra flags to control preprocessing, compilation, assembly and - linking processes. More details :ref:`projectconf_build_flags` -* ``unflags`` - remove base/initial flags which were set by development - platform. More details :ref:`projectconf_build_unflags` -* ``srcFilter`` - specify which source files should be included/excluded - from build process. More details :ref:`projectconf_src_filter` -* ``extraScript`` - launch extra script before build process. - More details :ref:`projectconf_extra_script`. +.. list-table:: + :header-rows: 1 + + * - Option + - Type + - Description + * - ``flags`` + - ``String`` or ``Array`` + - Extra flags to control preprocessing, compilation, assembly and + linking processes. More details :ref:`projectconf_build_flags` + * - ``unflags`` + - ``String`` or ``Array`` + - Remove base/initial flags which were set by development + platform. More details :ref:`projectconf_build_unflags` + * - ``srcFilter`` + - ``String`` or ``Array`` + - Specify which source files should be included/excluded + from build process. More details :ref:`projectconf_src_filter` + * - ``extraScript`` + - ``String`` + - Launch extra script before build process. + More details :ref:`projectconf_extra_script` **Examples** @@ -450,7 +464,10 @@ options: .. code-block:: javascript "build": { - "flags": "-I inc -I inc/target_x13" + "flags": [ + "-I inc", + "-I inc/target_x13" + ] } 3. Force to use ``C99`` standard instead ``C11`` @@ -487,7 +504,11 @@ options: .. code-block:: python - # Import('env') + Import('env') # print env.Dump() + env.Append( + CPPDEFINES=["HELLO=WORLD", "TAG=1.2.3", "DEBUG"], + CPPPATH=["inc", "inc/devices"] + ) # some python code that generates headers files "on-the-fly" diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 7ce3692e..c3440897 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -114,7 +114,9 @@ def BuildProgram(env): def ProcessFlags(env, flags): if not flags: return - parsed_flags = env.ParseFlags(str(flags)) + if isinstance(flags, list): + flags = " ".join(flags) + parsed_flags = env.ParseFlags(flags) for flag in parsed_flags.pop("CPPDEFINES"): if not isinstance(flag, list): env.Append(CPPDEFINES=flag) @@ -147,6 +149,7 @@ def ProcessFlags(env, flags): def ProcessUnFlags(env, flags): if not flags: return + flags = " ".join(flags) parsed_flags = env.ParseFlags(flags) all_flags = [] for items in parsed_flags.values(): From 8726f8317c0bd4bc0251bea3f6658ef5cc75b0e2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Jul 2016 18:59:10 +0300 Subject: [PATCH 047/119] Typo fix --- platformio/builder/tools/platformio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index c3440897..6010088f 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -149,7 +149,8 @@ def ProcessFlags(env, flags): def ProcessUnFlags(env, flags): if not flags: return - flags = " ".join(flags) + if isinstance(flags, list): + flags = " ".join(flags) parsed_flags = env.ParseFlags(flags) all_flags = [] for items in parsed_flags.values(): From 06494729f13c33ea6d9364ab68852bc7a2ad9b6e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Jul 2016 19:40:11 +0300 Subject: [PATCH 048/119] Fix for Python 2.6 --- platformio/builder/tools/platformio.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 6010088f..fe196955 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -116,7 +116,7 @@ def ProcessFlags(env, flags): return if isinstance(flags, list): flags = " ".join(flags) - parsed_flags = env.ParseFlags(flags) + parsed_flags = env.ParseFlags(str(flags)) for flag in parsed_flags.pop("CPPDEFINES"): if not isinstance(flag, list): env.Append(CPPDEFINES=flag) @@ -151,7 +151,7 @@ def ProcessUnFlags(env, flags): return if isinstance(flags, list): flags = " ".join(flags) - parsed_flags = env.ParseFlags(flags) + parsed_flags = env.ParseFlags(str(flags)) all_flags = [] for items in parsed_flags.values(): all_flags.extend(items) From 2bfa3517f052217b117e70e5c4134be2ed31f0b1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Jul 2016 19:57:55 +0300 Subject: [PATCH 049/119] Add license field to library.json // Resolve #522 --- HISTORY.rst | 2 ++ docs/librarymanager/config.rst | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index a948fcfa..74948581 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,8 @@ PlatformIO 3.0 * Handle extra build flags and build script from `library.json `__ (`issue #289 `_) +* Added ``license`` field to `library.json `__ + (`issue #522 `_) * Show detailed build information about dependent libraries (`issue #617 `_) * Embedded Board compatibility with more than one development platform diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index 50a82cc9..709e42ff 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -222,6 +222,19 @@ Example: }, "version": "1.0.0" + +``license`` +----------- + +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`` @@ -479,7 +492,7 @@ options: "flags": "-std=c99" } -4. Build source files (``c, cpp, h``) only from the root of the library +4. Build source files (``c, cpp, h``) at the top level of the library .. code-block:: javascript From 9838aef6b80f4b985ec5abc2daed6ce6028d3d57 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Jul 2016 23:06:10 +0300 Subject: [PATCH 050/119] Check library compatibility with project environment before building // Resolve #415 --- HISTORY.rst | 2 ++ platformio/__init__.py | 2 +- platformio/builder/tools/piolib.py | 40 +++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 74948581..d6fbe399 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,8 @@ PlatformIO 3.0 * Handle extra build flags and build script from `library.json `__ (`issue #289 `_) +* Check library compatibility with project environment before building + (`issue #415 `_) * Added ``license`` field to `library.json `__ (`issue #522 `_) * Show detailed build information about dependent libraries diff --git a/platformio/__init__.py b/platformio/__init__.py index 6ab03493..d770fc9b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev5") +VERSION = (3, 0, "0.dev6") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index ac31c85f..5c1389ce 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -124,6 +124,12 @@ class LibBuilderBase(object): def is_built(self): return self._is_built + def is_platform_compatible(self, platform): + return True + + def is_framework_compatible(self, framework): + return True + def load_manifest(self): # pylint: disable=no-self-use return {} @@ -191,6 +197,9 @@ class ArduinoLibBuilder(LibBuilderBase): return ["+<*.%s>" % ext for ext in piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT] + def is_framework_compatible(self, framework): + return framework.lower() in ("arduino", "energia") + class MbedLibBuilder(LibBuilderBase): @@ -214,6 +223,9 @@ class MbedLibBuilder(LibBuilderBase): join(self.build_dir if use_build_dir else self.src_dir, p)) return path_dirs + def is_framework_compatible(self, framework): + return framework.lower() == "mbed" + class PlatformIOLibBuilder(LibBuilderBase): @@ -247,6 +259,25 @@ class PlatformIOLibBuilder(LibBuilderBase): return self._manifest.get("build").get("extra_script") return LibBuilderBase.extra_script.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 find_deps(env, scanner, path_dirs, src_dir, src_filter): result = [] @@ -295,6 +326,8 @@ def find_and_build_deps(env, lib_builders, scanner, def GetLibBuilders(env): items = [] + env_frameworks = [ + f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")] libs_dirs = [env.subst(d) for d in env.get("LIBSOURCE_DIRS", []) if isdir(env.subst(d))] for libs_dir in libs_dirs: @@ -304,6 +337,11 @@ def GetLibBuilders(env): lb = LibBuilderFactory.new(env, join(libs_dir, item)) if lb.name in env.get("LIB_IGNORE", []): continue + if not lb.is_platform_compatible(env['PLATFORM']): + continue + if not any([lb.is_framework_compatible(f) + for f in env_frameworks]): + continue items.append(lb) return items @@ -314,7 +352,7 @@ def BuildDependentLibraries(env, src_dir): lib_builders = env.GetLibBuilders() print "Looking for dependencies..." - print "Collecting %d libraries" % len(lib_builders) + print "Collecting %d compatible libraries" % len(lib_builders) built_lib_names = [] for lib_name in env.get("LIB_FORCE", []): From 02e883b55c4ef172d3495703f17d9f72319deb8b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Jul 2016 23:51:33 +0300 Subject: [PATCH 051/119] Implement "lib_extra_dirs" option for project environment // Resolve #537 --- HISTORY.rst | 3 +++ docs/envvars.rst | 4 ++++ docs/projectconf.rst | 24 ++++++++++++++++++++++++ platformio/__init__.py | 2 +- platformio/builder/main.py | 24 +++++++++++++----------- platformio/builder/tools/piolib.py | 14 ++++++++++---- 6 files changed, 55 insertions(+), 16 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index d6fbe399..981c883e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,9 @@ PlatformIO 3.0 C Preprocessor conditional macros, `library deep search `__, support for the 3rd party manifests (Arduino IDE ``library.properties``, ARM mbed ``module.json``) (`issue #432 `_) +* New `lib_extra_dirs `__ option for project environment. + Multiple custom library locations! + (`issue #537 `_) * Handle extra build flags and build script from `library.json `__ (`issue #289 `_) diff --git a/docs/envvars.rst b/docs/envvars.rst index d0165b05..40d93b83 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -107,6 +107,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 --------- diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 5d5b9596..0c905b2f 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -681,6 +681,30 @@ For example, there are 2 libraries: Secondly, it will parse all sources from "Bar" library and this operation continues until all dependent libraries will not be parsed. +.. _projectconf_lib_extra_dirs: + +``lib_extra_dirs`` +^^^^^^^^^^^^^^^^^^ + +A list with extra directories where ``Library Dependency Finder (LDF)`` will +look for dependencies. Multiple paths are allowed. Please separate them using +comma ``,`` symbol. + +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 directory that contains libraries grouped by folders. For example, + ``/extra/lib/path/`` but not ``/extra/lib/path/MyLibrary``. + +Example: + +.. code-block:: ini + + [env:custom_lib_dirs] + lib_extra_dirs = /path/to/private/dir1,/path/to/private/dir2 + ----------- .. _projectconf_examples: diff --git a/platformio/__init__.py b/platformio/__init__.py index d770fc9b..28a1507b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev6") +VERSION = (3, 0, "0.dev7") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 0fdcc752..822421ec 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -34,16 +34,19 @@ commonvars.AddVariables( ("PIOENV",), ("PIOTEST",), ("PLATFORM",), - - # options ("FRAMEWORK",), + + # build options ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",), ("BUILD_UNFLAGS",), ("SRC_FILTER",), + + # library options ("LIB_DEEP_SEARCH",), ("LIB_IGNORE",), ("LIB_FORCE",), + ("LIB_EXTRA_DIRS",), # board options ("BOARD",), @@ -101,21 +104,20 @@ for k in commonvars.keys(): if k in env: env[k] = base64.b64decode(env[k]) -env.LoadDevPlatform(commonvars) - -# Parse library names -for opt in ("LIB_IGNORE", "LIB_FORCE"): - if opt not in env: - continue - env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] - # 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.LoadDevPlatform(commonvars) env.SConscriptChdir(0) env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite")) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 5c1389ce..6a06f985 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=no-member +# pylint: disable=no-member, no-self-use, unused-argument from __future__ import absolute_import @@ -130,7 +130,7 @@ class LibBuilderBase(object): def is_framework_compatible(self, framework): return True - def load_manifest(self): # pylint: disable=no-self-use + def load_manifest(self): return {} def get_path_dirs(self, use_build_dir=False): @@ -326,10 +326,16 @@ def find_and_build_deps(env, lib_builders, scanner, def GetLibBuilders(env): items = [] + libs_dirs = [] env_frameworks = [ f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")] - libs_dirs = [env.subst(d) for d in env.get("LIBSOURCE_DIRS", []) - if isdir(env.subst(d))] + + for key in ("LIB_EXTRA_DIRS", "LIBSOURCE_DIRS"): + for d in env.get(key, []): + d = env.subst(d) + if isdir(d): + libs_dirs.append(d) + for libs_dir in libs_dirs: for item in sorted(os.listdir(libs_dir)): if item == "__cores__" or not isdir(join(libs_dir, item)): From da6f424b111ae78395d8a4b789054e1b20fc582d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Jul 2016 00:19:56 +0300 Subject: [PATCH 052/119] Export root "env" to the extra script --- docs/projectconf.rst | 4 +--- platformio/builder/main.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 0c905b2f..f0e6b941 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -486,9 +486,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') diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 822421ec..7c1fc192 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -128,7 +128,7 @@ 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() From 70031040b371a71933f45c30b4645386228cfff0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Jul 2016 18:00:55 +0300 Subject: [PATCH 053/119] Rename test --ignore option to --skip --- docs/userguide/cmd_test.rst | 6 +++--- platformio/commands/test.py | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst index af38f9b7..1a4dba6c 100644 --- a/docs/userguide/cmd_test.rst +++ b/docs/userguide/cmd_test.rst @@ -43,9 +43,9 @@ Options Process specified environments. More details :option:`platformio run --environment` .. option:: - -i, --ignore + --skip -Ignore tests where the name matches with specified pattern. More than one +Skip over tests where the name matches specified patterns. More than one option/pattern is allowed. .. list-table:: @@ -66,7 +66,7 @@ option/pattern is allowed. * - ``[!seq]`` - matches any character not in seq -For example, ``platformio test --ignore "mytest*" -i "test[13]"`` +For example, ``platformio test --skip "mytest*" -i "test[13]"`` .. option:: --upload-port diff --git a/platformio/commands/test.py b/platformio/commands/test.py index 0769f7f7..0585a0b1 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=R0913,R0914 + from fnmatch import fnmatch from os import getcwd, listdir from os.path import isdir, join @@ -28,15 +30,14 @@ from platformio.managers.platform import PlatformFactory @click.command("test", short_help="Unit Testing") @click.option("--environment", "-e", multiple=True, metavar="") -@click.option("--ignore", "-i", multiple=True, metavar="") +@click.option("--skip", 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.pass_context -def cli(ctx, environment, ignore, upload_port, # pylint: disable=R0913,R0914 - project_dir, verbose): +def cli(ctx, environment, skip, upload_port, project_dir, verbose): assert check_project_envs(project_dir, environment) with util.cd(project_dir): test_dir = util.get_projecttest_dir() @@ -58,8 +59,8 @@ def cli(ctx, environment, ignore, upload_port, # pylint: disable=R0913,R0914 if environment and envname not in environment: continue - # check ignore patterns - if testname != "*" and any([fnmatch(testname, i) for i in ignore]): + # check skip patterns + if testname != "*" and any([fnmatch(testname, p) for p in skip]): results.append((None, testname, envname)) continue @@ -133,7 +134,8 @@ class TestProcessor(object): return self.cmd_ctx.invoke( cmd_run, project_dir=self.options['project_dir'], upload_port=self.options['upload_port'], - verbose=self.options['verbose'], environment=[self.env_name], + verbose=self.options['verbose'], + environment=[self.env_name], target=target ) From daac1b2590f267f1ea22a97281751865b55e8208 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Jul 2016 00:48:59 +0300 Subject: [PATCH 054/119] Print human-readable information when processing environments without // Resolve #721 --- HISTORY.rst | 3 + docs/envvars.rst | 4 + docs/userguide/cmd_ci.rst | 6 +- docs/userguide/cmd_run.rst | 157 ++++++++++++++----------- docs/userguide/cmd_settings.rst | 14 +++ docs/userguide/cmd_test.rst | 6 +- platformio/__init__.py | 2 +- platformio/app.py | 4 + platformio/builder/main.py | 10 +- platformio/builder/tools/piomisc.py | 9 ++ platformio/builder/tools/platformio.py | 4 +- platformio/commands/ci.py | 2 +- platformio/commands/run.py | 6 +- platformio/commands/test.py | 2 +- platformio/managers/platform.py | 52 +++----- 15 files changed, 161 insertions(+), 120 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 981c883e..e89b8e1d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -25,6 +25,9 @@ PlatformIO 3.0 (`issue #289 `_) * Check library compatibility with project environment before building (`issue #415 `_) +* Print human-readable information when processing environments without + ``-v, --verbose`` option + (`issue #721 `_) * Added ``license`` field to `library.json `__ (`issue #522 `_) * Show detailed build information about dependent libraries diff --git a/docs/envvars.rst b/docs/envvars.rst index 40d93b83..fdbbada7 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -157,3 +157,7 @@ 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`. diff --git a/docs/userguide/cmd_ci.rst b/docs/userguide/cmd_ci.rst index d97d3b96..785f2e0d 100644 --- a/docs/userguide/cmd_ci.rst +++ b/docs/userguide/cmd_ci.rst @@ -112,8 +112,10 @@ Buid project using pre-configured :ref:`projectconf`. .. 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 -------- diff --git a/docs/userguide/cmd_run.rst b/docs/userguide/cmd_run.rst index 383970c1..6d2696de 100644 --- a/docs/userguide/cmd_run.rst +++ b/docs/userguide/cmd_run.rst @@ -77,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 @@ -103,17 +96,34 @@ Examples .. code-block:: bash $ 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. + [Sun Jul 17 00:09:16 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino) + ----------------------------------------------------------------------------------------------- + Looking for dependencies... + Collecting 32 compatible libraries + Processing src/main.cpp + Processing .pioenvs/uno/libFrameworkArduinoVariant.a + Processing .platformio/packages/framework-arduinoavr/cores/arduino/CDC.cpp + Processing .platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial.cpp + Processing .platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial0.cpp + ... + Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_analog.c + Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_digital.c + Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_pulse.c + Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_shift.c + Processing .pioenvs/uno/libFrameworkArduino.a + Processing .pioenvs/uno/firmware.elf + Processing .pioenvs/uno/firmware.hex + Processing size + AVR Memory Usage + ---------------- + Device: atmega328p - Processing launchpad_msp430g2 environment: - scons: `.pioenvs/launchpad_msp430g2/firmware.elf' is up to date. - scons: `.pioenvs/launchpad_msp430g2/firmware.hex' is up to date. + Program: 1034 bytes (3.2% Full) + (.text + .data + .bootloader) + + Data: 9 bytes (0.4% Full) + (.data + .bss + .noinit) - Processing launchpad_lm4f120 environment: - scons: `.pioenvs/launchpad_lm4f120/firmware.elf' is up to date. - scons: `.pioenvs/launchpad_lm4f120/firmware.hex' is up to date 2. Process specific environment @@ -121,13 +131,27 @@ Examples .. code-block:: bash $ 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. - - Processing launchpad_lm4f120 environment: - scons: `.pioenvs/launchpad_lm4f120/firmware.elf' is up to date. - scons: `.pioenvs/launchpad_lm4f120/firmware.hex' is up to date. + [Sun Jul 17 00:10:14 2016] Processing nodemcu (platform: espressif, board: nodemcu, framework: arduino) + -------------------------------------------------------------------------------------------------------- + Looking for dependencies... + Collecting 29 compatible libraries + Processing src/main.cpp + Processing .pioenvs/nodemcu/libFrameworkArduinoVariant.a + Processing .platformio/packages/framework-arduinoespressif/cores/esp8266/Esp.cpp + ... + Processing .platformio/packages/framework-arduinoespressif/cores/esp8266/pgmspace.cpp + Processing .platformio/packages/framework-arduinoespressif/cores/esp8266/setjmp.S + Processing .pioenvs/nodemcu/libFrameworkArduino.a + Processing .platformio/packages/framework-arduinoespressif/tools/sdk/lib/libmesh.a + ... + Processing .platformio/packages/framework-arduinoespressif/tools/sdk/lib/libaxtls.a + Processing .platformio/packages/framework-arduinoespressif/tools/sdk/lib/libstdc++.a + Processing .pioenvs/nodemcu/firmware.elf + Processing .platformio/packages/tool-esptool/esptool + Processing .pioenvs/nodemcu/firmware.bin + Processing size + text data bss dec hex filename + 221456 884 29496 251836 3d7bc .pioenvs/nodemcu/firmware.elf 3. Process specific target @@ -135,52 +159,49 @@ Examples .. code-block:: bash $ platformio run -t clean - Processing arduino_pro5v environment: - Removed .pioenvs/arduino_pro5v/src/main.o + [Sun Jul 17 00:19:36 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino) + ---------------------------------------------------------------------------------------------------------------------------------------------------------------- + Looking for dependencies... + Collecting 32 compatible libraries + Removed .pioenvs/uno/FrameworkArduino/CDC.o + Removed .pioenvs/uno/FrameworkArduino/HardwareSerial.o ... - Removed .pioenvs/arduino_pro5v/firmware.hex - - Processing launchpad_msp430g2 environment: - Removed .pioenvs/launchpad_msp430g2/src/main.o - ... - Removed .pioenvs/launchpad_msp430g2/firmware.hex - - Processing launchpad_lm4f120 environment: - Removed .pioenvs/launchpad_lm4f120/src/main.o - ... - Removed .pioenvs/launchpad_lm4f120/firmware.hex + Removed .pioenvs/uno/libFrameworkArduinoVariant.a + Removed .pioenvs/uno/src/main.o + Removed .pioenvs/uno/libFrameworkArduino.a + Removed .pioenvs/uno/firmware.elf + Removed .pioenvs/uno/firmware.hex 4. Mix environments and targets .. code-block:: bash - $ 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. - - 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 + $ platformio run -e teensy31 -t upload + [Sun Jul 17 00:27:14 2016] Processing teensy31 (platform: teensy, board: teensy31, framework: arduino) + ------------------------------------------------------------------------------------------------------- + Looking for dependencies... + Collecting 25 compatible libraries + Processing src/main.cpp + Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/AudioStream.cpp + Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/DMAChannel.cpp + Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial1.cpp + ... + Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/yield.cpp + Processing .platformio/packages/tool-teensy/teensy_loader_cli + Processing .pioenvs/teensy31/libFrameworkArduino.a + Processing .pioenvs/teensy31/firmware.elf + Check program size... + text data bss dec hex filename + 11080 168 2288 13536 34e0 .pioenvs/teensy31/firmware.elf + Processing .pioenvs/teensy31/firmware.hex + Processing upload + Teensy Loader, Command Line, Version 2.0 + Read ".pioenvs/teensy31/firmware.hex": 11248 bytes, 4.3% usage + Soft reboot is not implemented for OSX + Waiting for Teensy device... + (hint: press the reset button) + Found HalfKay Bootloader + Read ".pioenvs/teensy31/firmware.hex": 11248 bytes, 4.3% usage + Programming........... + Booting diff --git a/docs/userguide/cmd_settings.rst b/docs/userguide/cmd_settings.rst index ff5640d0..24d592d3 100644 --- a/docs/userguide/cmd_settings.rst +++ b/docs/userguide/cmd_settings.rst @@ -87,6 +87,20 @@ Check for the new PlatformIO interval. Check for the platform updates interval. +.. _setting_force_verbose: + +``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_prompts: ``enable_prompts`` diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst index 1a4dba6c..628be957 100644 --- a/docs/userguide/cmd_test.rst +++ b/docs/userguide/cmd_test.rst @@ -85,8 +85,10 @@ to current working directory (``CWD``). .. 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 -------- diff --git a/platformio/__init__.py b/platformio/__init__.py index 28a1507b..4c0361d7 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev7") +VERSION = (3, 0, "0.dev8") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/app.py b/platformio/app.py index f7fcce2a..ab2d71d4 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -44,6 +44,10 @@ DEFAULT_SETTINGS = { "description": "Automatically update libraries (Yes/No)", "value": False }, + "force_verbose": { + "description": "Force verbose output when processing environments", + "value": False + }, "enable_telemetry": { "description": ( "Telemetry service 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) + click.secho(line, fg=fg, err=level > 1) @staticmethod def get_job_nums(): @@ -326,13 +310,7 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): self.pm = PackageManager( PACKAGE_DIR, self._manifest.get("packageRepositories")) - self._found_error = False - self._last_echo_line = None - - # 1 = errors - # 2 = 1 + warnings - # 3 = 2 + others - self._verbose_level = 3 + self._verbose = False @property def name(self): From 8eed54ca4582500e30628daa2b1bd001eaa37034 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Jul 2016 16:05:28 +0300 Subject: [PATCH 055/119] Refactor PLATFORM and FRAMEWORK build variables with PIO prefix --- platformio/builder/main.py | 4 ++-- platformio/builder/tools/devplatform.py | 2 +- platformio/builder/tools/piolib.py | 4 ++-- platformio/builder/tools/piomisc.py | 2 +- platformio/builder/tools/piotest.py | 2 +- platformio/builder/tools/pioupload.py | 2 +- platformio/builder/tools/platformio.py | 4 ++-- platformio/commands/run.py | 7 +++++++ platformio/managers/platform.py | 2 +- 9 files changed, 18 insertions(+), 11 deletions(-) diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 3fbb0d58..1f4dd490 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -34,8 +34,8 @@ commonvars.AddVariables( ("EXTRA_SCRIPT",), ("PIOENV",), ("PIOTEST",), - ("PLATFORM",), - ("FRAMEWORK",), + ("PIOPLATFORM",), + ("PIOFRAMEWORK",), # build options ("BUILD_FLAGS",), diff --git a/platformio/builder/tools/devplatform.py b/platformio/builder/tools/devplatform.py index 5004c0c7..deaa017e 100644 --- a/platformio/builder/tools/devplatform.py +++ b/platformio/builder/tools/devplatform.py @@ -29,7 +29,7 @@ def initDevPlatform(name): def DevPlatform(env): variables = {} - for key in ("board", "framework"): + for key in ("board", "pioframework"): if key not in env: continue variables[key] = env[key.upper()] diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 6a06f985..d00f0c08 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -35,7 +35,7 @@ class LibBuilderFactory(object): clsname = "PlatformIOLibBuilder" else: env_frameworks = [ - f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")] + 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: @@ -328,7 +328,7 @@ def GetLibBuilders(env): items = [] libs_dirs = [] env_frameworks = [ - f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")] + f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",")] for key in ("LIB_EXTRA_DIRS", "LIBSOURCE_DIRS"): for d in env.get(key, []): diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 4280d353..94b2b4d6 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -185,7 +185,7 @@ def DumpIDEData(env): defines.append(env_.subst(item).replace('\\"', '"')) # special symbol for Atmel AVR MCU - if env.subst("$PLATFORM") == "atmelavr": + if env['PIOPLATFORM'] == "atmelavr": defines.append( "__AVR_%s__" % env.BoardConfig().get("build.mcu").upper() .replace("ATMEGA", "ATmega") diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index db1e1886..af820dc4 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -122,7 +122,7 @@ void output_complete(void) print("Warning: Could not remove temporary file '%s'. " "Please remove it manually." % file_) - framework = env.subst("$FRAMEWORK").lower() + framework = env.subst("$PIOFRAMEWORK").lower() if framework not in FRAMEWORK_PARAMETERS: env.Exit( "Error: %s framework doesn't support testing feature!" % framework) diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index 88b1d4ff..198885cd 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -114,7 +114,7 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument print env.subst("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 diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 601b43e5..f1963f36 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -53,9 +53,9 @@ def BuildProgram(env): # 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() diff --git a/platformio/commands/run.py b/platformio/commands/run.py index a678ceae..f23e35ac 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -97,6 +97,11 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 class EnvironmentProcessor(object): + REMAPED_OPTIONS = { + "FRAMEWORK": "PIOFRAMEWORK", + "PLATFORM": "PIOPLATFORM" + } + RENAMED_OPTIONS = { "INSTALL_LIBS": "LIB_INSTALL", "IGNORE_LIBS": "LIB_IGNORE", @@ -158,6 +163,8 @@ class EnvironmentProcessor(object): if self.upload_port: variables['upload_port'] = self.upload_port for k, v in self.options.items(): + if k.upper() in self.REMAPED_OPTIONS: + k = self.REMAPED_OPTIONS[k.upper()] k = k.lower() if k == "targets" or (k == "upload_port" and self.upload_port): continue diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 16cf6c86..d0d83b93 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -440,7 +440,7 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): def configure_default_packages(self, variables, targets): # enbale used frameworks - for framework in variables.get("framework", "").split(","): + for framework in variables.get("pioframework", "").split(","): if not self.frameworks: continue framework = framework.lower().strip() From 49f5c1d0788256d4066b0dd9d7edaea289abbfd4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Jul 2016 16:19:24 +0300 Subject: [PATCH 056/119] Fix PyLint "line too long" warning --- platformio/builder/tools/piolib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index d00f0c08..56b59458 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -35,7 +35,8 @@ class LibBuilderFactory(object): clsname = "PlatformIOLibBuilder" else: env_frameworks = [ - f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",")] + 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: From e264788f8ee94f58819735e2001d83f719eab3ad Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Jul 2016 16:36:05 +0300 Subject: [PATCH 057/119] Fix non renamed PLATFORM variable --- platformio/builder/tools/piolib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 56b59458..082b4a74 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -344,7 +344,7 @@ def GetLibBuilders(env): lb = LibBuilderFactory.new(env, join(libs_dir, item)) if lb.name in env.get("LIB_IGNORE", []): continue - if not lb.is_platform_compatible(env['PLATFORM']): + if not lb.is_platform_compatible(env['PIOPLATFORM']): continue if not any([lb.is_framework_compatible(f) for f in env_frameworks]): From 7b3a235bd7dd89256c66b7ba93742e949bdc15bb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Jul 2016 19:19:53 +0300 Subject: [PATCH 058/119] Don't duplicate source code to .pioenvs directory --- platformio/builder/tools/platformio.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index f1963f36..66e4893c 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -205,13 +205,13 @@ def MatchSourceFiles(env, src_dir, src_filter=None): return sorted(list(matches)) -def VariantDirWrap(env, variant_dir, src_dir, duplicate=None): +def VariantDirWrap(env, variant_dir, src_dir, duplicate=False): DefaultEnvironment().Append(VARIANT_DIRS=[(variant_dir, src_dir)]) env.VariantDir(variant_dir, src_dir, duplicate) def CollectBuildFiles(env, variant_dir, src_dir, - src_filter=None, duplicate=None): + src_filter=None, duplicate=False): sources = [] variants = [] From f10202c00b845c2c4b1aeceea6b21381c3b34cf3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Jul 2016 01:38:35 +0300 Subject: [PATCH 059/119] Refactor base package manager; Full VCS support as external package item --- platformio/__init__.py | 2 +- platformio/commands/platform.py | 6 +- platformio/managers/package.py | 707 +++++++++++++++++--------------- platformio/managers/platform.py | 25 +- platformio/vcsclient.py | 94 +++-- 5 files changed, 479 insertions(+), 355 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 4c0361d7..8fb65016 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev8") +VERSION = (3, 0, "0.dev9") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 5a703fdd..0fdd6d70 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -13,6 +13,7 @@ # limitations under the License. import json +from os.path import basename import click @@ -79,7 +80,10 @@ def platform_install(platforms, with_package, without_package, for platform in platforms: _platform = platform _version = None - if "@" in platform: + if any([s in platform for s in ("\\", "/")]): + _platform = basename(platform) + _version = platform + elif "@" in platform: _platform, _version = platform.rsplit("@", 1) if PlatformManager().install(_platform, _version, with_package, without_package, skip_default_package): diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 79f57416..f0cec055 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import os from os.path import dirname, isdir, isfile, islink, join from shutil import copyfile, copytree, rmtree @@ -27,327 +28,6 @@ from platformio.unpacker import FileUnpacker from platformio.vcsclient import VCSClientFactory -class BasePkgManager(object): - - _INSTALLED_CACHE = {} - - def __init__(self, package_dir, repositories=None): - self._INSTALLED_CACHE = {} - self.repositories = repositories - self.package_dir = package_dir - if not isdir(self.package_dir): - os.makedirs(self.package_dir) - assert isdir(self.package_dir) - - @staticmethod - def reset_cache(): - BasePkgManager._INSTALLED_CACHE = {} - - @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 check_structure(self, pkg_dir): - if isfile(join(pkg_dir, self.manifest_name)): - return True - - for root, _, files in os.walk(pkg_dir): - if self.manifest_name not in files: - continue - # copy contents to the root of package directory - for item in os.listdir(root): - item_path = join(root, item) - if isfile(item_path): - copyfile(item_path, join(pkg_dir, item)) - elif isdir(item_path): - copytree(item_path, join(pkg_dir, item), symlinks=True) - # remove not used contents - while True: - rmtree(root) - root = dirname(root) - if root == pkg_dir: - break - break - - if isfile(join(pkg_dir, self.manifest_name)): - return True - - raise exception.PlatformioException( - "Could not find '%s' manifest file in the package" % - self.manifest_name) - - @staticmethod - def max_satisfying_repo_version(versions, requirements=None): - item = None - systype = util.get_systype() - if requirements is not None: - requirements = str(requirements) - for v in versions: - if isinstance(v['version'], int): - continue - if v['system'] not in ("all", "*") and systype not in v['system']: - continue - if requirements and not semantic_version.match( - requirements, v['version']): - continue - if item is None or semantic_version.compare( - v['version'], item['version']) == 1: - 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 - - def max_satisfying_version(self, name, requirements=None): - best = None - for manifest in self.get_installed(): - if manifest['name'] != name: - continue - elif requirements and not semantic_version.match( - requirements, manifest['version']): - continue - elif (not best or semantic_version.compare( - manifest['version'], best['version']) == 1): - best = manifest - return best - - 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)): - manifest_path = join(self.package_dir, p, self.manifest_name) - if not isfile(manifest_path): - continue - manifest = util.load_json(manifest_path) - manifest['_manifest_path'] = manifest_path - assert set(["name", "version"]) <= set(manifest.keys()) - items.append(manifest) - BasePkgManager._INSTALLED_CACHE[self.package_dir] = items - return items - - def is_installed(self, name, requirements=None): - installed = self.get_installed() - if requirements is None: - return any([p['name'] == name for p in installed]) - - for p in installed: - if p['name'] != name: - continue - elif semantic_version.match(requirements, p['version']): - return True - return None - - def install(self, name, requirements, silent=False, trigger_event=True): - installed = self.is_installed(name, requirements) - if not installed or not silent: - click.echo("Installing %s %s @ %s:" % ( - self.manifest_name.split(".")[0], - click.style(name, fg="cyan"), - requirements if requirements else "latest")) - if installed: - if not silent: - click.secho("Already installed", fg="yellow") - return self.max_satisfying_version( - name, requirements).get("_manifest_path") - - if "://" in name: - pkg_dir = self._install_from_url(name, requirements) - else: - pkg_dir = self._install_from_piorepo(name, requirements) - if not pkg_dir or not isfile(join(pkg_dir, self.manifest_name)): - raise exception.PackageInstallError( - name, requirements or "latest", util.get_systype()) - - self.reset_cache() - if trigger_event: - telemetry.on_event( - category=self.__class__.__name__, - action="Install", label=name) - - return join(pkg_dir, 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( - 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 another mirror...", fg="yellow") - - if versions is None: - raise exception.UnknownPackage(name) - elif not pkgdata: - if "platform" in self.manifest_name: - raise exception.UndefinedPlatformVersion( - name, requirements or "latest") - else: - raise exception.UndefinedPackageVersion( - name, requirements or "latest", util.get_systype()) - return pkg_dir - - def _install_from_url(self, url, requirements=None, sha1=None): - pkg_dir = None - tmp_dir = mkdtemp("-package", "installing-", self.package_dir) - - # Handle GitHub URL (https://github.com/user/repo.git) - if url.endswith(".git") and not url.startswith("git"): - url = "git+" + url - - try: - if url.startswith("file://"): - rmtree(tmp_dir) - copytree(url[7:], tmp_dir) - elif url.startswith(("http://", "https://", "ftp://")): - dlpath = self.download(url, tmp_dir, sha1) - assert isfile(dlpath) - self.unpack(dlpath, tmp_dir) - os.remove(dlpath) - else: - repo = VCSClientFactory.newClient(url) - repo.export(tmp_dir) - - self.check_structure(tmp_dir) - pkg_dir = self._install_from_tmp_dir(tmp_dir, requirements) - finally: - if isdir(tmp_dir): - rmtree(tmp_dir) - return pkg_dir - - def _install_from_tmp_dir(self, tmp_dir, requirements=None): - tmpmanifest = util.load_json(join(tmp_dir, self.manifest_name)) - assert set(["name", "version"]) <= set(tmpmanifest.keys()) - name = tmpmanifest['name'] - - # package should satisfy requirements - if requirements: - assert semantic_version.match(requirements, tmpmanifest['version']) - - pkg_dir = join(self.package_dir, name) - if isfile(join(pkg_dir, self.manifest_name)): - manifest = util.load_json(join(pkg_dir, self.manifest_name)) - cmp_result = semantic_version.compare( - tmpmanifest['version'], manifest['version']) - if cmp_result == 1: - # if main package version < new package, backup it - os.rename(pkg_dir, join( - self.package_dir, "%s@%s" % (name, manifest['version']))) - elif cmp_result == -1: - pkg_dir = join( - self.package_dir, "%s@%s" % (name, tmpmanifest['version'])) - - # remove previous/not-satisfied package - if isdir(pkg_dir): - rmtree(pkg_dir) - os.rename(tmp_dir, pkg_dir) - assert isdir(pkg_dir) - return pkg_dir - - def uninstall(self, name, requirements=None, trigger_event=True): - click.echo("Uninstalling %s %s @ %s: \t" % ( - self.manifest_name.split(".")[0], - click.style(name, fg="cyan"), - requirements if requirements else "latest"), nl=False) - found = False - for manifest in self.get_installed(): - if manifest['name'] != name: - continue - if (requirements and not semantic_version.match( - requirements, manifest['version'])): - continue - found = True - if isfile(manifest['_manifest_path']): - pkg_dir = dirname(manifest['_manifest_path']) - if islink(pkg_dir): - os.unlink(pkg_dir) - else: - rmtree(pkg_dir) - - if not found: - click.secho("Not installed", fg="yellow") - return False - else: - click.echo("[%s]" % click.style("OK", fg="green")) - - self.reset_cache() - if trigger_event: - telemetry.on_event( - category=self.__class__.__name__, - action="Uninstall", label=name) - - def update(self, name, requirements=None): - click.echo("Updating %s %s @ %s:" % ( - self.manifest_name.split(".")[0], - click.style(name, fg="yellow"), - requirements if requirements else "latest")) - - latest_version = self.get_latest_repo_version(name, requirements) - if latest_version is None: - click.secho("Ignored! '%s' is not listed in repository" % name, - fg="yellow") - return - - current = None - for manifest in self.get_installed(): - if manifest['name'] != name: - continue - if (requirements and not semantic_version.match( - requirements, manifest['version'])): - continue - if (not current or semantic_version.compare( - manifest['version'], current['version']) == 1): - current = manifest - - if current is None: - return - - current_version = current['version'] - 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"))) - return True - else: - click.echo("[%s]" % (click.style("Out-of-date", fg="red"))) - - self.install(name, latest_version, trigger_event=False) - - telemetry.on_event( - category=self.__class__.__name__, - action="Update", label=name) - return True - - class PackageRepoIterator(object): _MANIFEST_CACHE = {} @@ -389,6 +69,391 @@ class PackageRepoIterator(object): return self.next() +class PkgRepoMixin(object): + + @staticmethod + def max_satisfying_repo_version(versions, requirements=None): + item = None + systype = util.get_systype() + if requirements is not None: + requirements = str(requirements) + for v in versions: + if isinstance(v['version'], int): + continue + if v['system'] not in ("all", "*") and systype not in v['system']: + continue + if requirements and not semantic_version.match( + requirements, v['version']): + continue + if item is None or semantic_version.compare( + v['version'], item['version']) == 1: + 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_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 + 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 manifest_exists(self, pkg_dir): + return self.get_manifest_path(pkg_dir) is not None + + def load_manifest(self, pkg_dir): + manifest_path = self.get_manifest_path(pkg_dir) + if manifest_path: + manifest = util.load_json(manifest_path) + manifest['_manifest_path'] = manifest_path + manifest['__pkg_dir'] = pkg_dir + return manifest + return None + + 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 another mirror...", fg="yellow") + + if versions is None: + raise exception.UnknownPackage(name) + elif not pkgdata: + if "platform" in self.manifest_name: + raise exception.UndefinedPlatformVersion( + name, requirements or "latest") + else: + raise exception.UndefinedPackageVersion( + name, 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) + + # Handle GitHub URL (https://github.com/user/repo.git) + if url.endswith(".git") and not url.startswith("git"): + url = "git+" + url + + try: + if url.startswith("file://"): + url = url[7:] + if isfile(url): + self.unpack(url, tmp_dir) + else: + rmtree(tmp_dir) + copytree(url, tmp_dir) + elif url.startswith(("http://", "https://", "ftp://")): + 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": "0.0.0+rev%s" % vcs.get_latest_revision(), + "url": url}, fp) + + self._check_pkg_structure(tmp_dir) + pkg_dir = self._install_from_tmp_dir(tmp_dir, requirements) + finally: + if isdir(tmp_dir): + rmtree(tmp_dir) + return pkg_dir + + def _check_pkg_structure(self, pkg_dir): + if self.manifest_exists(pkg_dir): + return True + + for root, _, _ in os.walk(pkg_dir): + if not self.manifest_exists(root): + continue + # copy contents to the root of package directory + for item in os.listdir(root): + item_path = join(root, item) + if isfile(item_path): + copyfile(item_path, join(pkg_dir, item)) + elif isdir(item_path): + copytree(item_path, join(pkg_dir, item), symlinks=True) + # remove not used contents + while True: + rmtree(root) + root = dirname(root) + if root == pkg_dir: + break + break + + if self.manifest_exists(pkg_dir): + return True + + raise exception.PlatformioException( + "Could not find '%s' manifest file in the package" % + self.manifest_name) + + 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) + + # package should satisfy requirements + if requirements: + assert semantic_version.match( + requirements, tmpmanifest['version']) + + if self.manifest_exists(pkg_dir): + manifest = self.load_manifest(pkg_dir) + cmp_result = semantic_version.compare( + tmpmanifest['version'], manifest['version']) + if cmp_result == 1: + # if main package version < new package, backup it + os.rename(pkg_dir, join( + self.package_dir, "%s@%s" % (name, manifest['version']))) + elif cmp_result == -1: + pkg_dir = join( + self.package_dir, "%s@%s" % (name, tmpmanifest['version'])) + + # remove previous/not-satisfied package + if isdir(pkg_dir): + 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._INSTALLED_CACHE = {} + 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 reset_cache(): + BasePkgManager._INSTALLED_CACHE = {} + + @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 print_message(self, message, nl=True): + click.echo("%s: %s" % (self.__class__.__name__, message), nl=nl) + + 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)): + manifest = self.load_manifest(join(self.package_dir, p)) + if not manifest: + continue + assert set(["name", "version"]) <= set(manifest.keys()) + items.append(manifest) + BasePkgManager._INSTALLED_CACHE[self.package_dir] = items + return items + + def is_installed(self, name, requirements=None): + installed = self.get_installed() + reqspec = None + if requirements: + try: + reqspec = semantic_version.Spec(requirements) + except ValueError: + pass + + if not reqspec: + return any([p['name'] == name for p in installed]) + + for p in installed: + if p['name'] != name: + continue + elif reqspec.match(semantic_version.Version(p['version'])): + return True + return None + + def max_installed_version(self, name, requirements=None): + best = None + reqspec = None + if requirements: + try: + reqspec = semantic_version.Spec(requirements) + except ValueError: + pass + + for manifest in self.get_installed(): + if manifest['name'] != name: + continue + elif reqspec and not reqspec.match( + semantic_version.Version(manifest['version'])): + continue + elif (not best or semantic_version.compare( + manifest['version'], best['version']) == 1): + best = manifest + + if best: + return best.get("__pkg_dir") + return None + + def install(self, name, requirements, silent=False, trigger_event=True): + installed = self.is_installed(name, requirements) + if not installed or not silent: + self.print_message("Installing %s @ %s:" % ( + click.style(name, fg="cyan"), + requirements if requirements else "latest")) + if installed: + if not silent: + click.secho("Already installed", fg="yellow") + return self.max_installed_version( + name, requirements) + + if (requirements and any([s in requirements for s in ("\\", "/")]) and + "://" not in requirements and ( + isfile(requirements) or isdir(requirements))): + requirements = "file://" + requirements + + if requirements and "://" in requirements: + pkg_dir = self._install_from_url(name, 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 "latest", util.get_systype()) + + self.reset_cache() + if trigger_event: + telemetry.on_event( + category=self.__class__.__name__, + action="Install", label=name) + + return pkg_dir + + def uninstall(self, name, requirements=None, trigger_event=True): + self.print_message("Uninstalling %s @ %s: \t" % ( + click.style(name, fg="cyan"), + requirements if requirements else "latest"), nl=False) + found = False + for manifest in self.get_installed(): + if manifest['name'] != name: + continue + if (requirements and not semantic_version.match( + requirements, manifest['version'])): + continue + found = True + if isdir(manifest['__pkg_dir']): + if islink(manifest['__pkg_dir']): + os.unlink(manifest['__pkg_dir']) + else: + rmtree(manifest['__pkg_dir']) + + if not found: + click.secho("Not installed", fg="yellow") + return False + else: + click.echo("[%s]" % click.style("OK", fg="green")) + + self.reset_cache() + if trigger_event: + telemetry.on_event( + category=self.__class__.__name__, + action="Uninstall", label=name) + + def update(self, name, requirements=None): + self.print_message("Updating %s @ %s:" % ( + click.style(name, fg="yellow"), + requirements if requirements else "latest")) + + latest_version = self.get_latest_repo_version(name, requirements) + if latest_version is None: + click.secho( + "Ignored! '%s' is not listed in registry" % name, + fg="yellow") + return + + current = None + for manifest in self.get_installed(): + if manifest['name'] != name: + continue + if (requirements and not semantic_version.match( + requirements, manifest['version'])): + continue + if (not current or semantic_version.compare( + manifest['version'], current['version']) == 1): + current = manifest + + if current is None: + return + + current_version = current['version'] + 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"))) + return True + else: + click.echo("[%s]" % (click.style("Out-of-date", fg="red"))) + + self.install(name, latest_version, trigger_event=False) + + telemetry.on_event( + category=self.__class__.__name__, + action="Update", label=name) + return True + + class PackageManager(BasePkgManager): @property diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index d0d83b93..83402f0f 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -45,8 +45,8 @@ class PlatformManager(BasePkgManager): def install(self, # pylint: disable=too-many-arguments,arguments-differ name, requirements=None, with_packages=None, without_packages=None, skip_default_packages=False): - manifest_path = BasePkgManager.install(self, name, requirements) - p = PlatformFactory.newPlatform(manifest_path, requirements) + 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_packages) self.cleanup_packages(p.packages.keys()) @@ -99,7 +99,8 @@ class PlatformManager(BasePkgManager): def get_installed_boards(self): boards = [] for manifest in self.get_installed(): - p = PlatformFactory.newPlatform(manifest['_manifest_path']) + 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 @@ -138,10 +139,8 @@ class PlatformFactory(object): platform_dir = dirname(name) name = util.load_json(name)['name'] else: - _manifest = PlatformManager().max_satisfying_version( + platform_dir = PlatformManager().max_installed_version( name, requirements) - if _manifest: - platform_dir = dirname(_manifest['_manifest_path']) if not platform_dir: raise exception.UnknownPlatform( @@ -169,9 +168,17 @@ class PlatformPackagesMixin(object): installed = self.pm.get_installed() for name, opts in self.packages.items(): manifest = None + reqspec = None + try: + reqspec = semantic_version.Spec(opts['version']) + except ValueError: + pass + for p in installed: - if (p['name'] != name or not semantic_version.match( - opts['version'], p['version'])): + if p['name'] != name: + continue + if reqspec and not reqspec.match( + semantic_version.Version(p['version'])): continue elif (not manifest or semantic_version.compare( p['version'], manifest['version']) == 1): @@ -413,7 +420,7 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): packages = self.get_installed_packages() if name not in packages: return None - return dirname(packages[name]['_manifest_path']) + return packages[name]['__pkg_dir'] def get_package_version(self, name): packages = self.get_installed_packages() diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index 612f287a..f915e0e3 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.py @@ -12,25 +12,42 @@ # See the License for the specific language governing permissions and # limitations under the License. +from os import listdir +from os.path import isdir, join from platform import system from subprocess import check_call from sys import modules from urlparse import urlsplit, urlunsplit +from platformio import util from platformio.exception import PlatformioException class VCSClientFactory(object): @staticmethod - def newClient(url): - scheme, netloc, path, query, fragment = urlsplit(url) - type_ = scheme - if "+" in type_: - type_, scheme = type_.split("+", 1) - url = urlunsplit((scheme, netloc, path, query, None)) - clsname = "%sClient" % type_.title() - obj = getattr(modules[__name__], clsname)(url, fragment) + def newClient(src_dir, remote_url=None, branch=None): + clsnametpl = "%sClient" + vcscls = None + type_ = None + if remote_url: + scheme, netloc, path, query, branch = urlsplit(remote_url) + type_ = scheme + if "+" in type_: + type_, scheme = type_.split("+", 1) + remote_url = urlunsplit((scheme, netloc, path, query, None)) + vcscls = getattr(modules[__name__], clsnametpl % type_.title()) + elif isdir(src_dir): + for item in listdir(src_dir): + if not isdir(join(src_dir, item)) or not item.startswith("."): + continue + try: + vcscls = getattr( + modules[__name__], clsnametpl % item[1:].title()) + except AttributeError: + pass + assert vcscls + obj = vcscls(src_dir, remote_url, branch) assert isinstance(obj, VCSClientBase) return obj @@ -39,59 +56,90 @@ class VCSClientBase(object): command = None - def __init__(self, url, branch=None): - self.url = url + def __init__(self, src_dir, remote_url=None, branch=None): + self.src_dir = src_dir + self.remote_url = remote_url self.branch = branch self.check_client() def check_client(self): try: assert self.command - assert self.run_cmd(["--version"]) == 0 + assert self.run_cmd(["--version"]) except (AssertionError, OSError): raise PlatformioException( "VCS: `%s` client is not installed in your system" % self.command) return True - def export(self, dst_dir): + @property + def storage_dir(self): + return join(self.src_dir, "." + self.command) + + def export(self): raise NotImplementedError - def run_cmd(self, args): - return check_call([self.command] + args, shell=system() == "Windows") + def get_latest_revision(self): + raise NotImplementedError + + def run_cmd(self, args, **kwargs): + args = [self.command] + args + kwargs['shell'] = system() == "Windows" + return check_call(args, **kwargs) == 0 + + def get_cmd_output(self, args, **kwargs): + args = [self.command] + args + result = util.exec_command(args, **kwargs) + if result['returncode'] == 0: + return result['out'] + raise PlatformioException( + "VCS: Could not receive an output from `%s` command (%s)" % ( + args, result)) class GitClient(VCSClientBase): command = "git" - def export(self, dst_dir): + def export(self): args = ["clone", "--recursive", "--depth", "1"] if self.branch: args.extend(["--branch", self.branch]) - args.extend([self.url, dst_dir]) - self.run_cmd(args) + args.extend([self.remote_url, self.src_dir]) + return self.run_cmd(args) + + def get_latest_revision(self): + return self.get_cmd_output(["rev-parse", "--short", "HEAD"], + cwd=self.src_dir).strip() class HgClient(VCSClientBase): command = "hg" - def export(self, dst_dir): + def export(self): args = ["clone"] if self.branch: args.extend(["--updaterev", self.branch]) - args.extend([self.url, dst_dir]) - self.run_cmd(args) + args.extend([self.remote_url, self.src_dir]) + return self.run_cmd(args) + + def get_latest_revision(self): + return self.get_cmd_output(["identify", "--id"], + cwd=self.src_dir).strip() class SvnClient(VCSClientBase): command = "svn" - def export(self, dst_dir): + def export(self): args = ["export", "--force"] if self.branch: args.extend(["--revision", self.branch]) - args.extend([self.url, dst_dir]) - self.run_cmd(args) + args.extend([self.remote_url, self.src_dir]) + return self.run_cmd(args) + + def get_latest_revision(self): + return self.get_cmd_output(["info", "-r", "HEAD"], + cwd=self.src_dir).strip() From 5b68d34764f7ce347a5c4a21451109d91f076feb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Jul 2016 15:36:08 +0300 Subject: [PATCH 060/119] Allow to load PlatformIO project using passed directory --- platformio/commands/init.py | 28 +++++++++++++--------------- platformio/commands/run.py | 21 ++++++++++----------- platformio/commands/test.py | 2 +- platformio/ide/projectgenerator.py | 19 +++++++++---------- platformio/util.py | 21 ++++++++++++++------- 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 3cdec20c..ca429aa0 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -84,7 +84,7 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 if board: fill_project_envs( - ctx, join(project_dir, "platformio.ini"), board, + ctx, project_dir, board, enable_auto_uploading, env_prefix, ide is not None ) @@ -121,25 +121,23 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 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): + if not util.is_platformio_project(project_dir): copyfile(join(util.get_source_dir(), "projectconftpl.ini"), - platformio_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")) @@ -277,14 +275,14 @@ def init_cvs_ignore(project_dir): def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals - ctx, platformio_ini, board_ids, enable_auto_uploading, + ctx, project_dir, board_ids, enable_auto_uploading, 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")]): @@ -324,7 +322,7 @@ 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)) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index f23e35ac..910c15c0 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -55,7 +55,7 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 fg="yellow" ) - config = util.get_project_config() + config = util.load_project_config() env_default = None if config.has_option("platformio", "env_default"): env_default = [ @@ -257,18 +257,17 @@ def print_header(label, is_error=False): def check_project_envs(project_dir, environments): - with util.cd(project_dir): - config = util.get_project_config() + config = util.load_project_config(project_dir) - if not config.sections(): - raise exception.ProjectEnvsNotAvailable() + 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)) + 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 diff --git a/platformio/commands/test.py b/platformio/commands/test.py index 7dcc0060..35b7fe97 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.py @@ -44,7 +44,7 @@ def cli(ctx, environment, skip, upload_port, project_dir, verbose): if not isdir(test_dir): raise exception.TestDirEmpty(test_dir) test_names = get_test_names(test_dir) - projectconf = util.get_project_config() + projectconf = util.load_project_config() click.echo("Collected %d items" % len(test_names)) click.echo() diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 4c0a4365..f59ed98b 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -46,16 +46,15 @@ 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 diff --git a/platformio/util.py b/platformio/util.py index 0e5271d0..ff1fc5b3 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -81,6 +81,7 @@ 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 @@ -148,7 +149,7 @@ 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) @@ -232,16 +233,22 @@ def get_projectdata_dir(): ) -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.NotPlatformProject(project_dir) cp = ConfigParser() - cp.read(ini_path) + cp.read(join(project_dir, "platformio.ini")) return cp +def is_platformio_project(project_dir=None): + if not project_dir: + project_dir = get_project_dir() + return isfile(join(project_dir, "platformio.ini")) + + def change_filemtime(path, time): os.utime(path, (time, time)) From 1127914512304fd0dbfb5ace37843c93a1df6dd8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Jul 2016 15:47:38 +0300 Subject: [PATCH 061/119] Fix broken import --- tests/commands/test_init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index b702e323..817e0cbb 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -62,7 +62,7 @@ def test_init_special_board(platformio_setup, clirunner, validate_cliresult): validate_cliresult(result) boards = json.loads(result.output) - config = util.get_project_config() + config = util.load_project_config() expected_result = [ ("platform", str(boards[0]['platform'])), ("framework", str(boards[0]['frameworks'][0])), @@ -81,7 +81,7 @@ def test_init_enable_auto_uploading(platformio_setup, clirunner, ["-b", "uno", "--enable-auto-uploading"]) validate_cliresult(result) validate_pioproject(getcwd()) - config = util.get_project_config() + config = util.load_project_config() expected_result = [ ("platform", "atmelavr"), ("framework", "arduino"), From 30733e837677b941c54806aae8b850b21f8ec006 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Jul 2016 23:49:50 +0300 Subject: [PATCH 062/119] Improve package caching for PkgManager --- platformio/managers/package.py | 9 ++++----- platformio/managers/platform.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index f0cec055..352c0d00 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -261,7 +261,6 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): _INSTALLED_CACHE = {} def __init__(self, package_dir, repositories=None): - self._INSTALLED_CACHE = {} self.repositories = repositories self.package_dir = package_dir if not isdir(self.package_dir): @@ -272,10 +271,6 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): def manifest_name(self): raise NotImplementedError() - @staticmethod - def reset_cache(): - BasePkgManager._INSTALLED_CACHE = {} - @staticmethod def download(url, dest_dir, sha1=None): fd = FileDownloader(url, dest_dir) @@ -289,6 +284,10 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): 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) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 83402f0f..db7ea51a 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -26,17 +26,17 @@ import semantic_version from platformio import app, exception, util from platformio.managers.package import BasePkgManager, PackageManager -PACKAGE_DIR = join(util.get_home_dir(), "packages") +PLATFORMS_DIR = join(util.get_home_dir(), "platforms") +PACKAGES_DIR = join(util.get_home_dir(), "packages") class PlatformManager(BasePkgManager): - def __init__(self): + def __init__(self, package_dir=None, repositories=None): + if not repositories: + repositories = ["http://dl.platformio.org/platforms/manifest.json"] BasePkgManager.__init__( - self, - join(util.get_home_dir(), "platforms"), - ["http://dl.platformio.org/platforms/manifest.json"] - ) + self, package_dir or PLATFORMS_DIR, repositories) @property def manifest_name(self): @@ -84,7 +84,7 @@ class PlatformManager(BasePkgManager): deppkgs[pkgname] = set() deppkgs[pkgname].add(pkgmanifest['version']) - pm = PackageManager(PACKAGE_DIR) + pm = PackageManager(PACKAGES_DIR) for manifest in pm.get_installed(): if manifest['name'] not in names: continue @@ -315,7 +315,7 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): self._manifest = util.load_json(manifest_path) self.pm = PackageManager( - PACKAGE_DIR, self._manifest.get("packageRepositories")) + PACKAGES_DIR, self._manifest.get("packageRepositories")) self._verbose = False From 1738f44847053c05c76758241fdd7b76babbbc4b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Jul 2016 23:51:22 +0300 Subject: [PATCH 063/119] Simplify platformio.ini default template --- platformio/projectconftpl.ini | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/platformio/projectconftpl.ini b/platformio/projectconftpl.ini index da48cf88..8e3b9e7d 100644 --- a/platformio/projectconftpl.ini +++ b/platformio/projectconftpl.ini @@ -1,18 +1,6 @@ # -# Project Configuration File +# PlatformIO Project Configuration File # -# A detailed documentation with the EXAMPLES is located here: +# Please check documentation with examples # http://docs.platformio.org/en/latest/projectconf.html # - -# A sign `#` at the beginning of the line indicates a comment -# Comment lines are ignored. - -# Simple and base environment -# [env:mybaseenv] -# platform = %INSTALLED_PLATFORM_NAME_HERE% -# framework = -# board = -# -# Automatic targets - enable auto-uploading -# targets = upload From 6900052ecd67e5d97c7203ec0c56646f7eee1155 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Jul 2016 18:02:04 +0300 Subject: [PATCH 064/119] Reorder command options --- platformio/commands/__init__.py | 2 +- platformio/commands/ci.py | 6 +++--- platformio/commands/init.py | 2 +- platformio/commands/platform.py | 4 ++-- platformio/commands/run.py | 10 +++++----- platformio/commands/test.py | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/platformio/commands/__init__.py b/platformio/commands/__init__.py index 0c05c3b0..5466a0e8 100644 --- a/platformio/commands/__init__.py +++ b/platformio/commands/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # 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/ci.py b/platformio/commands/ci.py index 1df83ba8..b7b1fe32 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -53,9 +53,9 @@ def validate_path(ctx, param, value): # pylint: disable=W0613 @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) @click.option("--exclude", multiple=True) -@click.option("--board", "-b", multiple=True, metavar="ID", +@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, @@ -64,7 +64,7 @@ def validate_path(ctx, param, value): # pylint: disable=W0613 @click.option("--project-conf", type=click.Path(exists=True, file_okay=True, dir_okay=False, readable=True, resolve_path=True)) -@click.option("--verbose", "-v", is_flag=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): diff --git a/platformio/commands/init.py b/platformio/commands/init.py index ca429aa0..a7e3d750 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -46,7 +46,7 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613 @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="ID", +@click.option("-b", "--board", multiple=True, metavar="ID", callback=validate_boards) @click.option("--ide", type=click.Choice(ProjectGenerator.get_supported_ides())) diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 0fdd6d70..eb81ddac 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -72,8 +72,8 @@ def platform_search(query, json_output): @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("--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): diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 910c15c0..9aaa9912 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -30,13 +30,13 @@ from platformio.managers.platform import PlatformFactory @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, +@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=False, dir_okay=True, writable=True, resolve_path=True)) -@click.option("--verbose", "-v", 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 diff --git a/platformio/commands/test.py b/platformio/commands/test.py index 35b7fe97..55ea49df 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.py @@ -32,7 +32,7 @@ from platformio.managers.platform import PlatformFactory @click.option("--environment", "-e", multiple=True, metavar="") @click.option("--skip", multiple=True, metavar="") @click.option("--upload-port", metavar="") -@click.option("--project-dir", "-d", default=getcwd, +@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) From fc9c66b0c38f48fc54450c43c9e3a14a2b1ee4a1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Jul 2016 18:03:35 +0300 Subject: [PATCH 065/119] Update examples --- examples | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples b/examples index a657ca42..3b8f997b 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit a657ca4225f55af7239b89486350c9f02bb3ee93 +Subproject commit 3b8f997b6e69879f1b935087e988290046a3fc84 From 2892cb8c2f54bc52adf525e617099ce8b0e59538 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Jul 2016 18:16:26 +0300 Subject: [PATCH 066/119] Fix cmd_init test --- tests/commands/test_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index 817e0cbb..45c23ed5 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -96,5 +96,5 @@ def test_init_enable_auto_uploading(platformio_setup, clirunner, def test_init_incorrect_board(clirunner): result = clirunner.invoke(cli, ["-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) From 01c0b45ea22ed98cf2ee0680344a2b1a2e375222 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 Jul 2016 18:17:23 +0300 Subject: [PATCH 067/119] Introduce "lib_compat_level" option for project configuration file --- HISTORY.rst | 7 ++- docs/faq.rst | 27 ++++++++++++ docs/projectconf.rst | 70 ++++++++++++++++++++++++------ platformio/__init__.py | 2 +- platformio/builder/main.py | 2 + platformio/builder/tools/piolib.py | 37 +++++++++------- 6 files changed, 114 insertions(+), 31 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index fd52b09a..084ce934 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,8 +14,11 @@ PlatformIO 3.0 * Unit Testing for Embedded (`docs `__) (`issue #408 `_) * New Library Build System: intelligent dependency finder that interprets - C Preprocessor conditional macros, `library deep search `__, support for the 3rd party - manifests (Arduino IDE ``library.properties``, ARM mbed ``module.json``) + C Preprocessor conditional macros, + `library deep search `__, + `library compatibility level `__, + support for the 3rd party manifests (Arduino IDE ``library.properties``, + ARM mbed ``module.json``) (`issue #432 `_) * New `lib_extra_dirs `__ option for project environment. Multiple custom library locations! diff --git a/docs/faq.rst b/docs/faq.rst index 75ed3cfb..18605764 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -33,6 +33,33 @@ What is ``.pioenvs`` directory Please refer to :ref:`projectconf_pio_envs_dir`. +.. _faq_ldf: + +How works Library Dependency Finder (LDF) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Library Dependency Finder is a part of PlatformIO Library Build System. It +operates with the header files (``*.h, *.hpp``) and looks for +``#include <...>`` directives. What is more, LDF interprets C Preprocessor +conditional macros (``#ifdef ...``, etc.). Library Dependency Finder starts +work from analyzing source files from :ref:`projectconf_pio_src_dir`. It +understands "nested includes/chain" by default if they depend on each other. + +There are different library storages where Library Dependency Finder looks for +dependencies. These storages/folders have priority. LDF operates in the next +order: + +1. :ref:`projectconf_lib_extra_dirs` +2. :ref:`projectconf_pio_lib_dir` +3. :ref:`projectconf_pio_home_dir`/lib + +Library Dependency Finder has a few key factors from :ref:`projectconf`: + +* :ref:`projectconf_lib_ignore` +* :ref:`projectconf_lib_deep_search` +* :ref:`projectconf_lib_extra_dirs` +* :ref:`projectconf_lib_compat_level` + Command completion in Terminal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 17e0bf23..aef7c784 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -606,10 +606,15 @@ Example: ``lib_force`` ^^^^^^^^^^^^^ -Force Library Build System to build specified libraries if even they are not +Force Library Build System to build specified libraries if they even are not included in the project source code. Also, these libraries 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 ``,`` separator. + Example: .. code-block:: ini @@ -617,10 +622,19 @@ Example: [env:myenv] lib_force = OneWire, SPI +.. _projectconf_lib_ignore: + ``lib_ignore`` ^^^^^^^^^^^^^^ -Specify libraries which should be ignored by ``Library Dependency Finder (LDF)`` +Please make sure to read :ref:`faq_ldf` guides 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 ``,`` separator. Example: @@ -629,18 +643,25 @@ Example: [env:ignore_some_libs] lib_ignore = SPI, Ethernet +.. _projectconf_lib_deep_search: + ``lib_deep_search`` ^^^^^^^^^^^^^^^^^^^ +Please make sure to read :ref:`faq_ldf` guides first. + By default, this option is turned OFF (``lib_deep_search = false``) and means -that ``Library Dependency Finder (LDF)`` will look only for the libraries -that are mentioned (using ``#include <...>``) in the source files from the -project :ref:`projectconf_pio_src_dir`. Also, ``LDF`` analyzes nested -``#include <...>`` by default. +that Library Dependency Finder will analyzes only "nested includes/chain". + +Nevertheless, some libraries depend on other libraries and the +``#include <...>`` directives for these libraries are not declared in the +"main" header file that is used by upper library. In this case, LDF will not +handle these libraries automatically because it doesn't analyze "each source +file" of the nested libraries. If you want to enable deep search, please set this option to ``true``. -Found library will be treated like the new source files and -``LDF`` will search dependencies for it. +Found library will be treated like the new source files and LDF will +search dependencies for it. For example, there are 2 libraries: @@ -688,17 +709,19 @@ For example, there are 2 libraries: ``lib_extra_dirs`` ^^^^^^^^^^^^^^^^^^ -A list with extra directories where ``Library Dependency Finder (LDF)`` will -look for dependencies. Multiple paths are allowed. Please separate them using -comma ``,`` symbol. +Please make sure to read :ref:`faq_ldf` guides first. + +A list with extra directories/storages where Library Dependency Finder will +look for dependencies. Multiple paths are allowed. Please separate them +using comma ``,`` symbol. 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 directory that contains libraries grouped by folders. For example, - ``/extra/lib/path/`` but not ``/extra/lib/path/MyLibrary``. + to storage that contains libraries grouped by folders. For example, + ``/extra/lib/storage/`` but not ``/extra/lib/storage/MyLibrary``. Example: @@ -707,6 +730,27 @@ Example: [env:custom_lib_dirs] lib_extra_dirs = /path/to/private/dir1,/path/to/private/dir2 +.. _projectconf_lib_compat_level: + +``lib_compat_level`` +^^^^^^^^^^^^^^^^^^^^ + +Please make sure to read :ref:`faq_ldf` guides first. + +Library compatibility level that allows to control Library Dependency Finder +strictness. If library contains manifest file (:ref:`library_config`, +``library.properties``, ``module.json``), then LDF check compatibility of this +library with real build environment. Available compatibility levels: + +* ``0`` - don't check for compatibility (disable) +* ``1`` - check for the compatibility with :ref:`projectconf_env_framework` + from build environment +* ``2`` - check for the compatibility with :ref:`projectconf_env_framework` + and :ref:`projectconf_env_platform` from build environment. + +By default, this value is set to ``lib_compat_level = 1`` and means that LDF +will check only for framework compatibility. + ----------- .. _projectconf_examples: diff --git a/platformio/__init__.py b/platformio/__init__.py index 8fb65016..f133db64 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev9") +VERSION = (3, 0, "0.dev10") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 1f4dd490..1fc1d079 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -45,6 +45,7 @@ commonvars.AddVariables( # library options ("LIB_DEEP_SEARCH",), + ("LIB_COMPAT_LEVEL",), ("LIB_IGNORE",), ("LIB_FORCE",), ("LIB_EXTRA_DIRS",), @@ -121,6 +122,7 @@ for opt in ("LIB_IGNORE", "LIB_FORCE", "LIB_EXTRA_DIRS"): continue env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] +env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) env.LoadDevPlatform(commonvars) env.SConscriptChdir(0) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 082b4a74..b930fe2f 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -17,8 +17,8 @@ from __future__ import absolute_import import os +import sys from os.path import basename, commonprefix, isdir, isfile, join, realpath -from sys import modules import SCons.Scanner @@ -44,7 +44,7 @@ class LibBuilderFactory(object): elif used_frameworks: clsname = "%sLibBuilder" % used_frameworks[0].title() - obj = getattr(modules[__name__], clsname)(env, path) + obj = getattr(sys.modules[__name__], clsname)(env, path) assert isinstance(obj, LibBuilderBase) return obj @@ -327,27 +327,34 @@ def find_and_build_deps(env, lib_builders, scanner, def GetLibBuilders(env): items = [] - libs_dirs = [] env_frameworks = [ - f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",")] + f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",") + ] + compat_level = int(env.get("LIB_COMPAT_LEVEL", 1)) - for key in ("LIB_EXTRA_DIRS", "LIBSOURCE_DIRS"): - for d in env.get(key, []): - d = env.subst(d) - if isdir(d): - libs_dirs.append(d) - - for libs_dir in libs_dirs: + 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 lb = LibBuilderFactory.new(env, join(libs_dir, item)) if lb.name in env.get("LIB_IGNORE", []): + if not env.GetOption("silent"): + print "Ignored library " + lb.path continue - if not lb.is_platform_compatible(env['PIOPLATFORM']): + if compat_level > 1 and not lb.is_platform_compatible(env[ + 'PIOPLATFORM']): + if not env.GetOption("silent"): + sys.stderr.write("Platform incompatible library %s\n" % + lb.path) continue - if not any([lb.is_framework_compatible(f) - for f in env_frameworks]): + if compat_level > 0 and not any([lb.is_framework_compatible(f) + for f in env_frameworks]): + if not env.GetOption("silent"): + sys.stderr.write("Framework incompatible library %s\n" % + lb.path) continue items.append(lb) return items @@ -358,8 +365,8 @@ def BuildDependentLibraries(env, src_dir): scanner = SCons.Scanner.C.CScanner() lib_builders = env.GetLibBuilders() - print "Looking for dependencies..." print "Collecting %d compatible libraries" % len(lib_builders) + print "Looking for dependencies..." built_lib_names = [] for lib_name in env.get("LIB_FORCE", []): From 187315fc08063e770dcf9f72e8b5582f892cde41 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 Jul 2016 20:04:09 +0300 Subject: [PATCH 068/119] Allow to disable library archiving ("*.ar") // Resolve #719 --- HISTORY.rst | 39 +++++++++++++++----------- docs/librarymanager/config.rst | 4 +++ platformio/__init__.py | 2 +- platformio/builder/tools/piolib.py | 25 +++++++++++++++-- platformio/builder/tools/platformio.py | 29 +++++++++++-------- 5 files changed, 66 insertions(+), 33 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 084ce934..b78463ae 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,28 +13,33 @@ PlatformIO 3.0 (`issue #479 `_) * Unit Testing for Embedded (`docs `__) (`issue #408 `_) -* New Library Build System: intelligent dependency finder that interprets - C Preprocessor conditional macros, - `library deep search `__, - `library compatibility level `__, - support for the 3rd party manifests (Arduino IDE ``library.properties``, - ARM mbed ``module.json``) - (`issue #432 `_) -* New `lib_extra_dirs `__ option for project environment. - Multiple custom library locations! - (`issue #537 `_) -* Handle extra build flags and build script from - `library.json `__ - (`issue #289 `_) -* Check library compatibility with project environment before building - (`issue #415 `_) +* New Intelligent Library Build System + + + `Library Dependency Finder `__ + that interprets C Preprocessor conditional macros and nested includes/chain + + Check library compatibility with project environment before building + (`issue #415 `_) + + Control Library Dependency Finder for compatibility using + `lib_compat_level `__ + 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") + * Print human-readable information when processing environments without ``-v, --verbose`` option (`issue #721 `_) * Added ``license`` field to `library.json `__ (`issue #522 `_) -* Show detailed build information about dependent libraries - (`issue #617 `_) * Embedded Board compatibility with more than one development platform (`issue #456 `_) diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index 709e42ff..ae31284e 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -461,6 +461,10 @@ options: - ``String`` - Launch extra script before build process. More details :ref:`projectconf_extra_script` + * - ``libArchive`` + - ``Boolean`` + - Archive object files to Static Library. This is default behavior of + PlatformIO Build System (``"libArchive": true``). **Examples** diff --git a/platformio/__init__.py b/platformio/__init__.py index f133db64..d37c5b19 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev10") +VERSION = (3, 0, "0.dev11") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index b930fe2f..777dbb7e 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -121,6 +121,10 @@ class LibBuilderBase(object): def extra_script(self): return None + @property + def lib_archive(self): + return True + @property def is_built(self): return self._is_built @@ -162,7 +166,12 @@ class LibBuilderBase(object): for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): self.env.AppendUnique(**{key: env.get(key)}) - return env.BuildLibrary(self.build_dir, self.src_dir, self.src_filter) + if self.lib_archive: + return env.BuildLibrary( + self.build_dir, self.src_dir, self.src_filter) + else: + return env.BuildSources( + self.build_dir, self.src_dir, self.src_filter) class UnknownLibBuilder(LibBuilderBase): @@ -260,6 +269,12 @@ class PlatformIOLibBuilder(LibBuilderBase): return self._manifest.get("build").get("extra_script") 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) + def is_platform_compatible(self, platform): items = self._manifest.get("platforms") if not items: @@ -315,7 +330,9 @@ def find_and_build_deps(env, lib_builders, scanner, lb.append_to_cpppath() # start builder for lb in target_lbs: - libs.append(lb.build()) + lib_node = lb.build() + if lib_node: + libs.append(lib_node) if env.get("LIB_DEEP_SEARCH", "").lower() == "true": for lb in target_lbs: @@ -377,7 +394,9 @@ def BuildDependentLibraries(env, src_dir): libs.extend(find_and_build_deps( env, lib_builders, scanner, lb.src_dir, lb.src_filter)) if not lb.is_built: - libs.append(lb.build()) + lib_node = lb.build() + if lib_node: + libs.append(lib_node) # process project source code libs.extend(find_and_build_deps( diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 66e4893c..e4875e15 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -85,24 +85,24 @@ def BuildProgram(env): env.Append( CPPPATH=["$PROJECTSRC_DIR"], LIBS=deplibs, - LIBPATH=["$BUILD_DIR"] - ) - - sources = env.CollectBuildFiles( - "$BUILDSRC_DIR", "$PROJECTSRC_DIR", - src_filter=env.get("SRC_FILTER"), duplicate=False) + LIBPATH=["$BUILD_DIR"], + PIOBUILDFILES=env.CollectBuildFiles( + "$BUILDSRC_DIR", + "$PROJECTSRC_DIR", + src_filter=env.get("SRC_FILTER"), + duplicate=False)) if "test" in COMMAND_LINE_TARGETS: - sources.extend(env.ProcessTest()) + env.Append(PIOBUILDFILES=env.ProcessTest()) - if not sources and not COMMAND_LINE_TARGETS: + if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: env.Exit( "Error: Nothing to build. Please put your source code files " "to '%s' folder" % env.subst("$PROJECTSRC_DIR")) program = env.Program( join("$BUILD_DIR", env.subst("$PROGNAME")), - sources + env['PIOBUILDFILES'] ) if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS): @@ -262,11 +262,15 @@ def BuildFrameworks(env, frameworks): def BuildLibrary(env, variant_dir, src_dir, src_filter=None): lib = env.Clone() - return lib.Library( + return lib.StaticLibrary( lib.subst(variant_dir), lib.CollectBuildFiles( - variant_dir, src_dir, src_filter=src_filter) - ) + variant_dir, src_dir, src_filter=src_filter)) + + +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(_): @@ -283,4 +287,5 @@ def generate(env): env.AddMethod(CollectBuildFiles) env.AddMethod(BuildFrameworks) env.AddMethod(BuildLibrary) + env.AddMethod(BuildSources) return env From be85eb3e4a3c9af91a59cecd6b7c9975b9ae5a4f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 01:52:18 +0300 Subject: [PATCH 069/119] Refactor Library Dependency Finder --- HISTORY.rst | 2 +- docs/faq.rst | 3 +-- docs/projectconf.rst | 19 +++++++++---------- docs/userguide/lib/cmd_install.rst | 8 ++++++++ platformio/__init__.py | 2 +- setup.py | 2 +- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index b78463ae..b9a19c34 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,7 +16,7 @@ PlatformIO 3.0 * New Intelligent Library Build System + `Library Dependency Finder `__ - that interprets C Preprocessor conditional macros and nested includes/chain + that interprets 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 diff --git a/docs/faq.rst b/docs/faq.rst index 18605764..bd55be30 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -42,8 +42,7 @@ Library Dependency Finder is a part of PlatformIO Library Build System. It operates with the header files (``*.h, *.hpp``) and looks for ``#include <...>`` directives. What is more, LDF interprets C Preprocessor conditional macros (``#ifdef ...``, etc.). Library Dependency Finder starts -work from analyzing source files from :ref:`projectconf_pio_src_dir`. It -understands "nested includes/chain" by default if they depend on each other. +work from analyzing source files from :ref:`projectconf_pio_src_dir`. There are different library storages where Library Dependency Finder looks for dependencies. These storages/folders have priority. LDF operates in the next diff --git a/docs/projectconf.rst b/docs/projectconf.rst index aef7c784..6f5ae26f 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -650,18 +650,17 @@ Example: Please make sure to read :ref:`faq_ldf` guides first. -By default, this option is turned OFF (``lib_deep_search = false``) and means -that Library Dependency Finder will analyzes only "nested includes/chain". +By default, this option is turned ON (``lib_deep_search = true``) and means +that Library Dependency Finder will analyze ALL source files from the library +and will try automatically find all dependencies. -Nevertheless, some libraries depend on other libraries and the +If you want to disable deep search, please set this option to ``false``. +Note! Some libraries depend on other libraries and the ``#include <...>`` directives for these libraries are not declared in the -"main" header file that is used by upper library. In this case, LDF will not -handle these libraries automatically because it doesn't analyze "each source -file" of the nested libraries. - -If you want to enable deep search, please set this option to ``true``. -Found library will be treated like the new source files and LDF will -search dependencies for it. +"main" header file that is used by upper library. If LDF is turned OFF +(``lib_deep_search = false``), it will not handle these libraries automatically +because it doesn't analyze "each source file" of the nested libraries +(only "nested includes/chain"). For example, there are 2 libraries: diff --git a/docs/userguide/lib/cmd_install.rst b/docs/userguide/lib/cmd_install.rst index a28c24a6..7b6e2986 100644 --- a/docs/userguide/lib/cmd_install.rst +++ b/docs/userguide/lib/cmd_install.rst @@ -30,6 +30,14 @@ Description Install new library by specified `PlatformIO Library Registry ID `_. +Installs the project library dependencies or a specific set of libraries. +[LIBRARY] can have multiple forms: , @, + or =@ + +Where, is a registry ID, registry name, repository URL, physical +location, is a valid semantic version/range, commit, branch, etc., and + is the name it should have locally. + Options ------- diff --git a/platformio/__init__.py b/platformio/__init__.py index d37c5b19..7d384e5c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev11") +VERSION = (3, 0, "0.dev12") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/setup.py b/setup.py index d228de9c..c1511504 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ 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", From e3e6676420dc79bd5f66a937399b4adac1f3fd11 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 01:54:09 +0300 Subject: [PATCH 070/119] Refactor Library Dependency Finder --- platformio/builder/tools/piolib.py | 292 +++++++++++++++++------------ 1 file changed, 176 insertions(+), 116 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 777dbb7e..3b2068ac 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -36,7 +36,8 @@ class LibBuilderFactory(object): else: env_frameworks = [ f.lower().strip() - for f in env.get("PIOFRAMEWORK", "").split(",")] + 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: @@ -73,11 +74,19 @@ class LibBuilderFactory(object): class LibBuilderBase(object): + INC_SCANNER = SCons.Scanner.C.CScanner() + def __init__(self, env, path): - self.env = env - self.path = path - self._is_built = False + self.env = env.Clone() + self.path = env.subst(path) self._manifest = self.load_manifest() + self._is_dependent = False + self._deps = [] + self._scanner_visited = tuple() + 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) @@ -96,14 +105,14 @@ class LibBuilderBase(object): @property def src_filter(self): return piotool.SRC_FILTER_DEFAULT + [ - "-" % os.sep, "-" % os.sep, - "-" % os.sep, "-" % os.sep + "-" % 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) + return (join(self.path, "src") + if isdir(join(self.path, "src")) else self.path) @property def build_dir(self): @@ -126,8 +135,17 @@ class LibBuilderBase(object): return True @property - def is_built(self): - return self._is_built + def dependencies(self): + return self._deps + + def depends_on(self, lb): + assert isinstance(lb, LibBuilderBase) + if lb not in self._deps: + self._deps.append(lb) + + @property + def dependent(self): + return self._is_dependent def is_platform_compatible(self, platform): return True @@ -138,46 +156,123 @@ class LibBuilderBase(object): def load_manifest(self): return {} - def get_path_dirs(self, use_build_dir=False): + 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") + + def get_inc_dirs(self, use_build_dir=False): return [self.build_dir if use_build_dir else self.src_dir] - def append_to_cpppath(self): - self.env.AppendUnique( - CPPPATH=self.get_path_dirs(use_build_dir=True) - ) + def _validate_search_paths(self, lib_builders, search_paths=None): + if not search_paths: + search_paths = tuple() + deep_search = self.env.get("LIB_DEEP_SEARCH", "true").lower() == "true" + + if not self._scanner_visited and ( + isinstance(self, ProjectAsLibBuilder) or deep_search): + for item in self.env.MatchSourceFiles(self.src_dir, + self.src_filter): + path = join(self.src_dir, item) + if (path not in self._scanner_visited and + path not in search_paths): + search_paths += (path, ) + + _search_paths = tuple() + for path in search_paths: + if path not in self._scanner_visited: + _search_paths += (path, ) + self._scanner_visited += (path, ) + + return _search_paths + + def _get_found_includes(self, lib_builders, search_paths=None): + inc_dirs = tuple() + used_inc_dirs = tuple() + for lb in [self] + lib_builders: + items = tuple(self.env.Dir(d) for d in lb.get_inc_dirs()) + if lb.dependent: + used_inc_dirs += items + else: + inc_dirs += items + inc_dirs = used_inc_dirs + inc_dirs + + result = tuple() + for path in self._validate_search_paths(search_paths): + for inc in self.env.File(path).get_found_includes( + self.env, LibBuilderBase.INC_SCANNER, inc_dirs): + if inc not in result: + result += (inc, ) + return result + + def search_dependencies(self, lib_builders, search_paths=None): + self._is_dependent = True + 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_src_files in lib_inc_map.items(): + if lb != self and lb not in self.dependencies: + self.depends_on(lb) + lb.search_dependencies(lib_builders, lb_src_files) def build(self): - if self.version: - print "Depends on <%s> v%s" % (self.name, self.version) - else: - print "Depends on <%s>" % self.name - assert self._is_built is False - self._is_built = True - self.append_to_cpppath() + libs = [] + for lb in self.dependencies: + 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)}) - env = self.env.Clone() - with util.cd(self.path): - env.ProcessUnFlags(self.build_unflags) - env.ProcessFlags(self.build_flags) - if self.extra_script: - env.SConscript(realpath(self.extra_script), exports="env") + self.env.AppendUnique(CPPPATH=self.get_inc_dirs(use_build_dir=True)) - # copy some data to global env - for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): - self.env.AppendUnique(**{key: env.get(key)}) - - if self.lib_archive: - return env.BuildLibrary( - self.build_dir, self.src_dir, self.src_filter) - else: - return env.BuildSources( - self.build_dir, self.src_dir, self.src_filter) + if not self._built_node: + 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) + return libs + [self._built_node] class UnknownLibBuilder(LibBuilderBase): pass +class ProjectAsLibBuilder(LibBuilderBase): + + @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_dependencies(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 and lb not in self.dependencies: + self.depends_on(lb) + lb.search_dependencies(lib_builders) + break + return LibBuilderBase.search_dependencies(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): @@ -192,13 +287,13 @@ class ArduinoLibBuilder(LibBuilderBase): manifest[key.strip()] = value.strip() return manifest - def get_path_dirs(self, use_build_dir=False): - path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) + def get_inc_dirs(self, use_build_dir=False): + inc_dirs = LibBuilderBase.get_inc_dirs(self, use_build_dir) if not isdir(join(self.src_dir, "utility")): - return path_dirs - path_dirs.append( + return inc_dirs + inc_dirs.append( join(self.build_dir if use_build_dir else self.src_dir, "utility")) - return path_dirs + return inc_dirs @property def src_filter(self): @@ -224,14 +319,13 @@ class MbedLibBuilder(LibBuilderBase): return join(self.path, "source") return LibBuilderBase.src_dir.fget(self) - def get_path_dirs(self, use_build_dir=False): - path_dirs = LibBuilderBase.get_path_dirs(self, use_build_dir) + def get_inc_dirs(self, use_build_dir=False): + inc_dirs = LibBuilderBase.get_inc_dirs(self, use_build_dir) + if self.path not in inc_dirs: + inc_dirs.append(self.path) for p in self._manifest.get("extraIncludes", []): - if p.startswith("source/"): - p = p[7:] - path_dirs.append( - join(self.build_dir if use_build_dir else self.src_dir, p)) - return path_dirs + inc_dirs.append(join(self.path, p)) + return inc_dirs def is_framework_compatible(self, framework): return framework.lower() == "mbed" @@ -295,53 +389,6 @@ class PlatformIOLibBuilder(LibBuilderBase): return item.lower() in [i.lower() for i in ilist] -def find_deps(env, scanner, path_dirs, src_dir, src_filter): - result = [] - for item in env.MatchSourceFiles(src_dir, src_filter): - result.extend(env.File(join(src_dir, item)).get_implicit_deps( - env, scanner, path_dirs)) - return result - - -def find_and_build_deps(env, lib_builders, scanner, - src_dir, src_filter): - path_dirs = tuple() - built_path_dirs = tuple() - for lb in lib_builders: - items = [env.Dir(d) for d in lb.get_path_dirs()] - if lb.is_built: - built_path_dirs += tuple(items) - else: - path_dirs += tuple(items) - path_dirs = built_path_dirs + path_dirs - - target_lbs = [] - deps = find_deps(env, scanner, path_dirs, src_dir, src_filter) - for d in deps: - for lb in lib_builders: - if d.get_abspath() in lb: - if lb not in target_lbs and not lb.is_built: - target_lbs.append(lb) - break - - libs = [] - # append PATH directories to global CPPPATH before build starts - for lb in target_lbs: - lb.append_to_cpppath() - # start builder - for lb in target_lbs: - lib_node = lb.build() - if lib_node: - libs.append(lib_node) - - if env.get("LIB_DEEP_SEARCH", "").lower() == "true": - for lb in target_lbs: - libs.extend(find_and_build_deps( - env, lib_builders, scanner, lb.src_dir, lb.src_filter)) - - return libs - - def GetLibBuilders(env): items = [] env_frameworks = [ @@ -378,31 +425,44 @@ def GetLibBuilders(env): def BuildDependentLibraries(env, src_dir): - libs = [] - scanner = SCons.Scanner.C.CScanner() + + def print_deps_tree(root, level=0): + margin = "| " * (level) + for lb in root.dependencies: + title = "<%s>" % lb.name + if lb.version: + title += " v%s" % lb.version + if not env.GetOption("silent"): + title += " (%s)" % lb.path + print "%s|-- %s" % (margin, title) + if lb.dependencies: + print_deps_tree(lb, level + 1) + lib_builders = env.GetLibBuilders() - print "Collecting %d compatible libraries" % len(lib_builders) + print "Collected %d compatible libraries" % len(lib_builders) print "Looking for dependencies..." - built_lib_names = [] - for lib_name in env.get("LIB_FORCE", []): - for lb in lib_builders: - if lb.name != lib_name or lb.name in built_lib_names: - continue - built_lib_names.append(lb.name) - libs.extend(find_and_build_deps( - env, lib_builders, scanner, lb.src_dir, lb.src_filter)) - if not lb.is_built: - lib_node = lb.build() - if lib_node: - libs.append(lib_node) + from time import time + start = time() + project = ProjectAsLibBuilder(env, src_dir) + project.env = env + project.search_dependencies(lib_builders) + print 13, time() - start - # process project source code - libs.extend(find_and_build_deps( - env, lib_builders, scanner, src_dir, env.get("SRC_FILTER"))) + if project.dependencies: + print "Library Dependency Map" + print_deps_tree(project) + else: + print "Project does not have dependencies" - return libs + # print "root", lbproj, lbproj._deps + # for lb_ in lib_builders: + # if not lb_.dependent: + # continue + # print lb_.name, lb_, lb_._deps + + return project.build() def exists(_): From 3c795a215ec69e5340516fcee7abd27de9670507 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 02:08:30 +0300 Subject: [PATCH 071/119] Fix typo --- platformio/builder/tools/piomisc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 94b2b4d6..dd198061 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -159,7 +159,7 @@ def DumpIDEData(env): # installed libs for lb in env.GetLibBuilders(): - includes.extend(lb.get_path_dirs()) + includes.extend(lb.get_inc_dirs()) # includes from toolchains p = env.DevPlatform() From b177bb5bfb6c4ad8c7f822f0ee046a1e743211d4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 14:09:29 +0300 Subject: [PATCH 072/119] Remove debug code; a few bugfixes --- platformio/builder/tools/piolib.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 3b2068ac..bccc9073 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -166,9 +166,10 @@ class LibBuilderBase(object): def get_inc_dirs(self, use_build_dir=False): return [self.build_dir if use_build_dir else self.src_dir] - def _validate_search_paths(self, lib_builders, search_paths=None): + def _validate_search_paths(self, search_paths=None): if not search_paths: search_paths = tuple() + assert isinstance(search_paths, tuple) deep_search = self.env.get("LIB_DEEP_SEARCH", "true").lower() == "true" if not self._scanner_visited and ( @@ -214,8 +215,8 @@ class LibBuilderBase(object): 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()) + lib_inc_map[lb] = tuple() + lib_inc_map[lb] += (inc.get_abspath(), ) break for lb, lb_src_files in lib_inc_map.items(): @@ -231,9 +232,9 @@ class LibBuilderBase(object): for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): self.env.AppendUnique(**{key: lb.env.get(key)}) - self.env.AppendUnique(CPPPATH=self.get_inc_dirs(use_build_dir=True)) - if not self._built_node: + self.env.AppendUnique(CPPPATH=self.get_inc_dirs( + use_build_dir=True)) if self.lib_archive: self._built_node = self.env.BuildLibrary( self.build_dir, self.src_dir, self.src_filter) @@ -443,12 +444,9 @@ def BuildDependentLibraries(env, src_dir): print "Collected %d compatible libraries" % len(lib_builders) print "Looking for dependencies..." - from time import time - start = time() project = ProjectAsLibBuilder(env, src_dir) project.env = env project.search_dependencies(lib_builders) - print 13, time() - start if project.dependencies: print "Library Dependency Map" @@ -456,12 +454,6 @@ def BuildDependentLibraries(env, src_dir): else: print "Project does not have dependencies" - # print "root", lbproj, lbproj._deps - # for lb_ in lib_builders: - # if not lb_.dependent: - # continue - # print lb_.name, lb_, lb_._deps - return project.build() From 269967a809d300a406f25228e21d23a13f8bf5c9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 14:39:38 +0300 Subject: [PATCH 073/119] Typo fix --- docs/librarymanager/config.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index ae31284e..13c0745f 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -487,7 +487,7 @@ options: ] } -3. Force to use ``C99`` standard instead ``C11`` +3. Force to use ``C99`` standard instead of ``C11`` .. code-block:: javascript @@ -528,4 +528,4 @@ options: CPPPATH=["inc", "inc/devices"] ) - # some python code that generates headers files "on-the-fly" + # some python code that generates header files "on-the-fly" From 8c5fabe41107cfba898dc5a7942ed93ae84a9325 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 16:13:49 +0300 Subject: [PATCH 074/119] Avoid infinite loop when we've already searched for dependencies --- platformio/builder/tools/piolib.py | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index bccc9073..3e34bc03 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -78,10 +78,11 @@ class LibBuilderBase(object): def __init__(self, env, path): self.env = env.Clone() + self.envorigin = env self.path = env.subst(path) self._manifest = self.load_manifest() self._is_dependent = False - self._deps = [] + self._deps = tuple() self._scanner_visited = tuple() self._built_node = None @@ -138,11 +139,6 @@ class LibBuilderBase(object): def dependencies(self): return self._deps - def depends_on(self, lb): - assert isinstance(lb, LibBuilderBase) - if lb not in self._deps: - self._deps.append(lb) - @property def dependent(self): return self._is_dependent @@ -192,7 +188,7 @@ class LibBuilderBase(object): def _get_found_includes(self, lib_builders, search_paths=None): inc_dirs = tuple() used_inc_dirs = tuple() - for lb in [self] + lib_builders: + for lb in (self, ) + lib_builders: items = tuple(self.env.Dir(d) for d in lb.get_inc_dirs()) if lb.dependent: used_inc_dirs += items @@ -208,6 +204,17 @@ class LibBuilderBase(object): result += (inc, ) return result + def depends_on(self, lb, lib_builders, search_paths=None): + assert isinstance(lb, LibBuilderBase) + if lb not in self._deps: + self._deps += (lb, ) + + # avoid infinite loop when we've already searched for dependencies + for lb_ in lib_builders: + if lb in lb_._deps: + return + lb.search_dependencies(lib_builders, search_paths) + def search_dependencies(self, lib_builders, search_paths=None): self._is_dependent = True lib_inc_map = {} @@ -221,8 +228,7 @@ class LibBuilderBase(object): for lb, lb_src_files in lib_inc_map.items(): if lb != self and lb not in self.dependencies: - self.depends_on(lb) - lb.search_dependencies(lib_builders, lb_src_files) + self.depends_on(lb, lib_builders, lb_src_files) def build(self): libs = [] @@ -262,8 +268,7 @@ class ProjectAsLibBuilder(LibBuilderBase): for lib_name in self.env.get("LIB_FORCE", []): for lb in lib_builders: if lb.name == lib_name and lb not in self.dependencies: - self.depends_on(lb) - lb.search_dependencies(lib_builders) + self.depends_on(lb, lib_builders) break return LibBuilderBase.search_dependencies(self, lib_builders, search_paths) @@ -391,7 +396,7 @@ class PlatformIOLibBuilder(LibBuilderBase): def GetLibBuilders(env): - items = [] + items = tuple() env_frameworks = [ f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",") ] @@ -421,7 +426,7 @@ def GetLibBuilders(env): sys.stderr.write("Framework incompatible library %s\n" % lb.path) continue - items.append(lb) + items += (lb, ) return items From 339acab9179b6a28d37b16dc06367eb3fa341a1e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 16:27:48 +0300 Subject: [PATCH 075/119] PyLint fix --- platformio/builder/tools/piolib.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 3e34bc03..5e440952 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -78,7 +78,6 @@ class LibBuilderBase(object): def __init__(self, env, path): self.env = env.Clone() - self.envorigin = env self.path = env.subst(path) self._manifest = self.load_manifest() self._is_dependent = False @@ -208,11 +207,6 @@ class LibBuilderBase(object): assert isinstance(lb, LibBuilderBase) if lb not in self._deps: self._deps += (lb, ) - - # avoid infinite loop when we've already searched for dependencies - for lb_ in lib_builders: - if lb in lb_._deps: - return lb.search_dependencies(lib_builders, search_paths) def search_dependencies(self, lib_builders, search_paths=None): From 3a7032ec9c4cbe2b1f156d269d9c06c2b904c8ae Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 17:29:53 +0300 Subject: [PATCH 076/119] Show a warning about Circular Dependencies --- platformio/builder/tools/piolib.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 5e440952..f9797560 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -203,11 +203,13 @@ class LibBuilderBase(object): result += (inc, ) return result - def depends_on(self, lb, lib_builders, search_paths=None): + def depends_on(self, lb): assert isinstance(lb, LibBuilderBase) - if lb not in self._deps: + if self in lb.dependencies: + sys.stderr.write("Warning! Circular dependencies detected " + "between `%s` and `%s`\n" % (self.path, lb.path)) + elif lb not in self._deps: self._deps += (lb, ) - lb.search_dependencies(lib_builders, search_paths) def search_dependencies(self, lib_builders, search_paths=None): self._is_dependent = True @@ -222,7 +224,8 @@ class LibBuilderBase(object): for lb, lb_src_files in lib_inc_map.items(): if lb != self and lb not in self.dependencies: - self.depends_on(lb, lib_builders, lb_src_files) + self.depends_on(lb) + lb.search_dependencies(lib_builders, lb_src_files) def build(self): libs = [] @@ -262,7 +265,8 @@ class ProjectAsLibBuilder(LibBuilderBase): for lib_name in self.env.get("LIB_FORCE", []): for lb in lib_builders: if lb.name == lib_name and lb not in self.dependencies: - self.depends_on(lb, lib_builders) + self.depends_on(lb) + lb.search_dependencies(lib_builders) break return LibBuilderBase.search_dependencies(self, lib_builders, search_paths) From 34b1f3b0a14310e681beb7dc4b7081a5050b50c4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Jul 2016 22:15:03 +0300 Subject: [PATCH 077/119] Handle includes from CPPPATH for PlatformIOLibBuilder --- platformio/__init__.py | 2 +- platformio/builder/tools/piolib.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 7d384e5c..735c7548 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev12") +VERSION = (3, 0, "0.dev13") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index f9797560..ebddb279 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -72,12 +72,13 @@ class LibBuilderFactory(object): return [] -class LibBuilderBase(object): +class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes INC_SCANNER = SCons.Scanner.C.CScanner() def __init__(self, env, path): self.env = env.Clone() + self.envorigin = env.Clone() self.path = env.subst(path) self._manifest = self.load_manifest() self._is_dependent = False @@ -156,7 +157,10 @@ class LibBuilderBase(object): 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.SConscript( + realpath(self.extra_script), + exports={"env": self.env, + "pio_lib_builder": self}) def get_inc_dirs(self, use_build_dir=False): return [self.build_dir if use_build_dir else self.src_dir] @@ -363,8 +367,8 @@ class PlatformIOLibBuilder(LibBuilderBase): @property def extra_script(self): - if "extra_script" in self._manifest.get("build", {}): - return self._manifest.get("build").get("extra_script") + if "extraScript" in self._manifest.get("build", {}): + return self._manifest.get("build").get("extraScript") return LibBuilderBase.extra_script.fget(self) @property @@ -392,6 +396,14 @@ class PlatformIOLibBuilder(LibBuilderBase): ilist = [i.strip() for i in ilist.split(",")] return item.lower() in [i.lower() for i in ilist] + def get_inc_dirs(self, use_build_dir=False): + inc_dirs = LibBuilderBase.get_inc_dirs(self, use_build_dir) + for path in self.env['CPPPATH']: + if path not in self.envorigin['CPPPATH']: + inc_dirs.append( + path if use_build_dir else self.env.subst(path)) + return inc_dirs + def GetLibBuilders(env): items = tuple() From b364389541b02ad8f3e5437af549357776ce5849 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 30 Jul 2016 19:46:08 +0300 Subject: [PATCH 078/119] If platformio is installed via brew, show it for upgrade --- platformio/maintenance.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index c91857dc..ad190080 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -195,14 +195,16 @@ def check_platformio_upgrade(): 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/latest/history.html", - fg="cyan") + click.secho("http://docs.platformio.org/en/latest/history.html", fg="cyan") click.echo("*" * terminal_width) click.echo("") From 74af8a5c397f728b8d4337084affe73f4b950a8c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 31 Jul 2016 00:00:58 +0300 Subject: [PATCH 079/119] Handle "dependencies" from library and project when build libraries // Issue #709 --- docs/faq.rst | 13 +++- docs/librarymanager/config.rst | 16 +++- platformio/__init__.py | 2 +- platformio/builder/tools/piolib.py | 113 +++++++++++++++++++++-------- 4 files changed, 108 insertions(+), 36 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index bd55be30..72b13163 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -39,10 +39,15 @@ How works Library Dependency Finder (LDF) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Library Dependency Finder is a part of PlatformIO Library Build System. It -operates with the header files (``*.h, *.hpp``) and looks for -``#include <...>`` directives. What is more, LDF interprets C Preprocessor -conditional macros (``#ifdef ...``, etc.). Library Dependency Finder starts -work from analyzing source files from :ref:`projectconf_pio_src_dir`. +operates with the C/C++ source files and looks for ``#include <...>`` +directives. Also, LDF interprets C Preprocessor conditional macros +(``#if``, ``ifdef``, etc.). Library Dependency Finder starts +work from analyzing source files from :ref:`projectconf_pio_src_dir` by default. + +If project or library contains own ``dependencies`` list (see +:ref:`libjson_dependencies`), the LDF will not looking for dependencies in +the source code. The specified libraries will be built automatically without +check. There are different library storages where Library Dependency Finder looks for dependencies. These storages/folders have priority. LDF operates in the next diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index 13c0745f..1c0e5354 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -381,6 +381,7 @@ 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`` @@ -401,10 +402,23 @@ 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`. diff --git a/platformio/__init__.py b/platformio/__init__.py index 735c7548..5f0228e9 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev13") +VERSION = (3, 0, "0.dev14") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index ebddb279..ce1a110a 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -82,8 +82,8 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes self.path = env.subst(path) self._manifest = self.load_manifest() self._is_dependent = False - self._deps = tuple() - self._scanner_visited = tuple() + self._depbuilders = tuple() + self._scanned_paths = tuple() self._built_node = None # process extra options and append to build environment @@ -103,6 +103,31 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes def version(self): return self._manifest.get("version") + @property + def dependencies(self): + deps = self._manifest.get("dependencies") + if not deps: + return deps + items = [] + if isinstance(deps, dict): + if "name" in deps: + items.append(deps) + else: + for name, version in deps.items(): + items.append({"name": name, "version": version}) + elif isinstance(deps, list): + items = [d for d in deps 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 + @property def src_filter(self): return piotool.SRC_FILTER_DEFAULT + [ @@ -136,8 +161,8 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes return True @property - def dependencies(self): - return self._deps + def depbuilders(self): + return self._depbuilders @property def dependent(self): @@ -171,20 +196,20 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes assert isinstance(search_paths, tuple) deep_search = self.env.get("LIB_DEEP_SEARCH", "true").lower() == "true" - if not self._scanner_visited and ( + if not self._scanned_paths and ( isinstance(self, ProjectAsLibBuilder) or deep_search): for item in self.env.MatchSourceFiles(self.src_dir, self.src_filter): path = join(self.src_dir, item) - if (path not in self._scanner_visited and + if (path not in self._scanned_paths and path not in search_paths): search_paths += (path, ) _search_paths = tuple() for path in search_paths: - if path not in self._scanner_visited: + if path not in self._scanned_paths: _search_paths += (path, ) - self._scanner_visited += (path, ) + self._scanned_paths += (path, ) return _search_paths @@ -207,16 +232,46 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes result += (inc, ) return result - def depends_on(self, lb): + def depend_recursive(self, lb, lib_builders, search_paths=None): assert isinstance(lb, LibBuilderBase) - if self in lb.dependencies: - sys.stderr.write("Warning! Circular dependencies detected " - "between `%s` and `%s`\n" % (self.path, lb.path)) - elif lb not in self._deps: - self._deps += (lb, ) + 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 += (lb, ) + lb.search_deps_recursive(lib_builders, search_paths) - def search_dependencies(self, lib_builders, search_paths=None): + def search_deps_recursive(self, lib_builders, search_paths=None): self._is_dependent = True + + # if dependencies are specified, don't use automatic finder + if self.dependencies: + 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(2) + return + lib_inc_map = {} for inc in self._get_found_includes(lib_builders, search_paths): for lb in lib_builders: @@ -227,13 +282,11 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes break for lb, lb_src_files in lib_inc_map.items(): - if lb != self and lb not in self.dependencies: - self.depends_on(lb) - lb.search_dependencies(lib_builders, lb_src_files) + self.depend_recursive(lb, lib_builders, lb_src_files) def build(self): libs = [] - for lb in self.dependencies: + for lb in self.depbuilders: libs.extend(lb.build()) # copy shared information to self env for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): @@ -265,15 +318,15 @@ class ProjectAsLibBuilder(LibBuilderBase): # skip for project, options are already processed pass - def search_dependencies(self, lib_builders, search_paths=None): + 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 and lb not in self.dependencies: - self.depends_on(lb) - lb.search_dependencies(lib_builders) + if lb.name == lib_name: + if lb not in self.depbuilders: + self.depend_recursive(lb, lib_builders) break - return LibBuilderBase.search_dependencies(self, lib_builders, - search_paths) + return LibBuilderBase.search_deps_recursive(self, lib_builders, + search_paths) def build(self): # dummy mark that project is built @@ -422,7 +475,7 @@ def GetLibBuilders(env): lb = LibBuilderFactory.new(env, join(libs_dir, item)) if lb.name in env.get("LIB_IGNORE", []): if not env.GetOption("silent"): - print "Ignored library " + lb.path + sys.stderr.write("Ignored library %s\n" % lb.path) continue if compat_level > 1 and not lb.is_platform_compatible(env[ 'PIOPLATFORM']): @@ -444,14 +497,14 @@ def BuildDependentLibraries(env, src_dir): def print_deps_tree(root, level=0): margin = "| " * (level) - for lb in root.dependencies: + for lb in root.depbuilders: title = "<%s>" % lb.name if lb.version: title += " v%s" % lb.version if not env.GetOption("silent"): title += " (%s)" % lb.path print "%s|-- %s" % (margin, title) - if lb.dependencies: + if lb.depbuilders: print_deps_tree(lb, level + 1) lib_builders = env.GetLibBuilders() @@ -461,9 +514,9 @@ def BuildDependentLibraries(env, src_dir): project = ProjectAsLibBuilder(env, src_dir) project.env = env - project.search_dependencies(lib_builders) + project.search_deps_recursive(lib_builders) - if project.dependencies: + if project.depbuilders: print "Library Dependency Map" print_deps_tree(project) else: From 22e67e6fdd9186d3120210180426cfaf43bf8d76 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 31 Jul 2016 15:46:57 +0300 Subject: [PATCH 080/119] Rename "lib_compat_level" to "lib_compat_mode" --- HISTORY.rst | 2 +- docs/faq.rst | 4 ++-- docs/projectconf.rst | 14 +++++++------- platformio/builder/main.py | 2 +- platformio/builder/tools/piolib.py | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index b9a19c34..763eb9d3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,7 +20,7 @@ PlatformIO 3.0 + Check library compatibility with project environment before building (`issue #415 `_) + Control Library Dependency Finder for compatibility using - `lib_compat_level `__ + `lib_compat_mode `__ option + Custom library storages/directories with `lib_extra_dirs `__ option diff --git a/docs/faq.rst b/docs/faq.rst index 72b13163..e8f650d5 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -57,12 +57,12 @@ order: 2. :ref:`projectconf_pio_lib_dir` 3. :ref:`projectconf_pio_home_dir`/lib -Library Dependency Finder has a few key factors from :ref:`projectconf`: +Library Dependency Finder has a few controls from :ref:`projectconf`: * :ref:`projectconf_lib_ignore` * :ref:`projectconf_lib_deep_search` * :ref:`projectconf_lib_extra_dirs` -* :ref:`projectconf_lib_compat_level` +* :ref:`projectconf_lib_compat_mode` Command completion in Terminal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 6f5ae26f..3f4a9005 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -729,25 +729,25 @@ Example: [env:custom_lib_dirs] lib_extra_dirs = /path/to/private/dir1,/path/to/private/dir2 -.. _projectconf_lib_compat_level: +.. _projectconf_lib_compat_mode: -``lib_compat_level`` -^^^^^^^^^^^^^^^^^^^^ +``lib_compat_mode`` +^^^^^^^^^^^^^^^^^^^ Please make sure to read :ref:`faq_ldf` guides first. -Library compatibility level that allows to control Library Dependency Finder +Library compatibility mode that allows to control Library Dependency Finder strictness. If library contains manifest file (:ref:`library_config`, ``library.properties``, ``module.json``), then LDF check compatibility of this -library with real build environment. Available compatibility levels: +library with real build environment. Available compatibility modes: -* ``0`` - don't check for compatibility (disable) +* ``0`` - don't check for compatibility * ``1`` - check for the compatibility with :ref:`projectconf_env_framework` from build environment * ``2`` - check for the compatibility with :ref:`projectconf_env_framework` and :ref:`projectconf_env_platform` from build environment. -By default, this value is set to ``lib_compat_level = 1`` and means that LDF +By default, this value is set to ``lib_compat_mode = 1`` and means that LDF will check only for framework compatibility. ----------- diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 1fc1d079..40184898 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -45,7 +45,7 @@ commonvars.AddVariables( # library options ("LIB_DEEP_SEARCH",), - ("LIB_COMPAT_LEVEL",), + ("LIB_COMPAT_MODE",), ("LIB_IGNORE",), ("LIB_FORCE",), ("LIB_EXTRA_DIRS",), diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index ce1a110a..7e94f784 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -463,7 +463,7 @@ def GetLibBuilders(env): env_frameworks = [ f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",") ] - compat_level = int(env.get("LIB_COMPAT_LEVEL", 1)) + compat_mode = int(env.get("LIB_COMPAT_MODE", 1)) for libs_dir in env['LIBSOURCE_DIRS']: libs_dir = env.subst(libs_dir) @@ -477,14 +477,14 @@ def GetLibBuilders(env): if not env.GetOption("silent"): sys.stderr.write("Ignored library %s\n" % lb.path) continue - if compat_level > 1 and not lb.is_platform_compatible(env[ + if compat_mode > 1 and not lb.is_platform_compatible(env[ 'PIOPLATFORM']): if not env.GetOption("silent"): sys.stderr.write("Platform incompatible library %s\n" % lb.path) continue - if compat_level > 0 and not any([lb.is_framework_compatible(f) - for f in env_frameworks]): + if compat_mode > 0 and not any([lb.is_framework_compatible(f) + for f in env_frameworks]): if not env.GetOption("silent"): sys.stderr.write("Framework incompatible library %s\n" % lb.path) From 513577958fe6c50434d2fc16f4f4d7c96e6a4371 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 00:14:22 +0300 Subject: [PATCH 081/119] Introduce "Library Dependency Finder" --- docs/faq.rst | 31 ----- docs/index.rst | 1 + docs/librarymanager/ldf.rst | 171 +++++++++++++++++++++++ docs/platforms/unit_testing.rst | 2 + docs/projectconf.rst | 211 +++++++++++++++-------------- docs/userguide/cmd_test.rst | 2 + platformio/builder/main.py | 25 ++-- platformio/builder/tools/piolib.py | 6 +- platformio/exception.py | 2 +- platformio/util.py | 71 +++++----- 10 files changed, 337 insertions(+), 185 deletions(-) create mode 100644 docs/librarymanager/ldf.rst diff --git a/docs/faq.rst b/docs/faq.rst index e8f650d5..75ed3cfb 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -33,37 +33,6 @@ What is ``.pioenvs`` directory Please refer to :ref:`projectconf_pio_envs_dir`. -.. _faq_ldf: - -How works Library Dependency Finder (LDF) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Library Dependency Finder is a part of PlatformIO Library Build System. It -operates with the C/C++ source files and looks for ``#include <...>`` -directives. Also, LDF interprets C Preprocessor conditional macros -(``#if``, ``ifdef``, etc.). Library Dependency Finder starts -work from analyzing source files from :ref:`projectconf_pio_src_dir` by default. - -If project or library contains own ``dependencies`` list (see -:ref:`libjson_dependencies`), the LDF will not looking for dependencies in -the source code. The specified libraries will be built automatically without -check. - -There are different library storages where Library Dependency Finder looks for -dependencies. These storages/folders have priority. LDF operates in the next -order: - -1. :ref:`projectconf_lib_extra_dirs` -2. :ref:`projectconf_pio_lib_dir` -3. :ref:`projectconf_pio_home_dir`/lib - -Library Dependency Finder has a few controls from :ref:`projectconf`: - -* :ref:`projectconf_lib_ignore` -* :ref:`projectconf_lib_deep_search` -* :ref:`projectconf_lib_extra_dirs` -* :ref:`projectconf_lib_compat_mode` - Command completion in Terminal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/index.rst b/docs/index.rst index 2db1a873..3b95e020 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -119,6 +119,7 @@ Contents Quickstart User Guide + librarymanager/ldf librarymanager/config librarymanager/creating diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst new file mode 100644 index 00000000..c3526436 --- /dev/null +++ b/docs/librarymanager/ldf.rst @@ -0,0 +1,171 @@ +.. Copyright 2014-present 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. + +.. _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_extra_dirs` + * :ref:`projectconf_lib_force` + * :ref:`projectconf_lib_ignore` + * :ref:`projectconf_lib_compat_mode` + * :ref:`projectconf_lib_ldf_mode` + +----------- + +.. contents:: + +Storage +------- + +There are different storages/folders where Library Dependency Finder looks for +libraries. These folders/path 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_piolibdeps_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 + dependent libraries. Builds only the libraries that are specified in + manifests (:ref:`library_config`, ``module.json``) or in the :ref:`projectconf`. +* ``1`` - parses ALL C/C++ source code of the project and follows only by + nested includes/chain (``#include ...``) from the libraries. +* ``2`` - **default** - parses ALL C/C++ source code of the project and parses + ALL C/C++ source code of the each dependent library (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 dependent libraries 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`. + +Manual dependencies +------------------- + +If project or library contains own ``dependencies`` list (see +:ref:`libjson_dependencies`), the LDF will not looking for dependencies in +the source code. The specified libraries will be built automatically without +check. + +.. _ldf_c_cond_syntax: + +C Preprocessor conditional syntax +--------------------------------- + +In spite of the fact that Library Dependency Finder is written in pure Python, +it interprets (emulates) `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/platforms/unit_testing.rst b/docs/platforms/unit_testing.rst index 19f51e1c..809eb76c 100644 --- a/docs/platforms/unit_testing.rst +++ b/docs/platforms/unit_testing.rst @@ -14,6 +14,8 @@ Unit Testing ============ +.. versionadded:: 3.0 + `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, diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 3f4a9005..748d0478 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -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_piolibdeps_dir: + +``piolibdeps_dir`` +^^^^^^^^^^^^^^^^^^ + +Internal storage where :ref:`librarymanager` will install project dependencies. +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_PIOLIBDEPS_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,7 +149,7 @@ 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 @@ -127,8 +166,7 @@ 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 @@ -139,9 +177,8 @@ This option can be overridden by global environment variable ``test_dir`` ^^^^^^^^^^^^ -Directory for :ref:`unit_testing`. - -A default value is ``test`` which means that folder is located in the root of +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 @@ -206,6 +243,9 @@ For example, ``[env:hello_world]``. General options ~~~~~~~~~~~~~~~ +.. contents:: + :local: + .. _projectconf_env_platform: ``platform`` @@ -265,6 +305,9 @@ using `PlatformIO Embedded Boards Explorer `_. Board options ~~~~~~~~~~~~~ +.. contents:: + :local: + ``board_mcu`` ^^^^^^^^^^^^^ @@ -309,8 +352,11 @@ 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. -Building options -~~~~~~~~~~~~~~~~ +Build options +~~~~~~~~~~~~~ + +.. contents:: + :local: .. _projectconf_build_flags: @@ -456,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 @@ -529,8 +575,11 @@ The list with available targets is located in :option:`platformio run --target`. When no targets are defined, *PlatformIO* will build only sources by default. -Uploading options -~~~~~~~~~~~~~~~~~ +Upload options +~~~~~~~~~~~~~~ + +.. contents:: + :local: .. _projectconf_upload_port: @@ -587,6 +636,9 @@ development platforms. The only :ref:`platform_espressif` supports it. Library options ~~~~~~~~~~~~~~~ +.. contents:: + :local: + ``lib_install`` ^^^^^^^^^^^^^^^ @@ -603,12 +655,17 @@ Example: [env:depends_on_some_libs] lib_install = 1,13,19 +.. _projectconf_lib_force: + ``lib_force`` ^^^^^^^^^^^^^ -Force Library Build System to build specified libraries if they even are not -included in the project source code. Also, these libraries will be processed -in the first order. +.. seealso:: + Please make sure to read :ref:`ldf` guide first. + +Force Library Dependency Finder to depend on the specified libraries if +they even are not included in the project source code. Also, these +libraries 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 @@ -627,7 +684,8 @@ Example: ``lib_ignore`` ^^^^^^^^^^^^^^ -Please make sure to read :ref:`faq_ldf` guides first. +.. seealso:: + Please make sure to read :ref:`ldf` guide first. Specify libraries which should be ignored by Library Dependency Finder. @@ -643,72 +701,14 @@ Example: [env:ignore_some_libs] lib_ignore = SPI, Ethernet -.. _projectconf_lib_deep_search: - -``lib_deep_search`` -^^^^^^^^^^^^^^^^^^^ - -Please make sure to read :ref:`faq_ldf` guides first. - -By default, this option is turned ON (``lib_deep_search = true``) and means -that Library Dependency Finder will analyze ALL source files from the library -and will try automatically find all dependencies. - -If you want to disable deep search, please set this option to ``false``. -Note! Some libraries depend on other libraries and the -``#include <...>`` directives for these libraries are not declared in the -"main" header file that is used by upper library. If LDF is turned OFF -(``lib_deep_search = false``), it will not handle these libraries automatically -because it doesn't analyze "each source file" of the nested libraries -(only "nested includes/chain"). - -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_deep_search = false`` - * ``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_deep_search = false`` - * ``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_deep_search = true`` - * ``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 dependent libraries will not be parsed. - .. _projectconf_lib_extra_dirs: ``lib_extra_dirs`` ^^^^^^^^^^^^^^^^^^ -Please make sure to read :ref:`faq_ldf` guides first. +.. versionadded:: 3.0 +.. seealso:: + Please make sure to read :ref:`ldf` guide first. A list with extra directories/storages where Library Dependency Finder will look for dependencies. Multiple paths are allowed. Please separate them @@ -729,23 +729,34 @@ Example: [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. + +Library Dependency Finder starts work from analyzing source files of the +project (:ref:`projectconf_pio_src_dir`) and can work in the different modes +(see :ref:`ldf_mode`). + +By default, this value is set to ``lib_ldf_mode = 2`` and means that LDF +will parse ALL C/C++ source code of the project and will parse ALL C/C++ +source code of the each dependent library (recursively). + .. _projectconf_lib_compat_mode: ``lib_compat_mode`` ^^^^^^^^^^^^^^^^^^^ -Please make sure to read :ref:`faq_ldf` guides first. +.. versionadded:: 3.0 +.. seealso:: + Please make sure to read :ref:`ldf` guide first. -Library compatibility mode that allows to control Library Dependency Finder -strictness. If library contains manifest file (:ref:`library_config`, -``library.properties``, ``module.json``), then LDF check compatibility of this -library with real build environment. Available compatibility modes: - -* ``0`` - don't check for compatibility -* ``1`` - check for the compatibility with :ref:`projectconf_env_framework` - from build environment -* ``2`` - check for the compatibility with :ref:`projectconf_env_framework` - and :ref:`projectconf_env_platform` from build environment. +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. diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst index 628be957..0749f6ec 100644 --- a/docs/userguide/cmd_test.rst +++ b/docs/userguide/cmd_test.rst @@ -14,6 +14,8 @@ platformio test =============== +.. versionadded:: 3.0 + .. contents:: Usage diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 40184898..493f1a22 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -44,7 +44,7 @@ commonvars.AddVariables( ("SRC_FILTER",), # library options - ("LIB_DEEP_SEARCH",), + ("LIB_LDF_MODE",), ("LIB_COMPAT_MODE",), ("LIB_IGNORE",), ("LIB_FORCE",), @@ -63,41 +63,35 @@ commonvars.AddVariables( ("UPLOAD_SPEED",), ("UPLOAD_FLAGS",), ("UPLOAD_RESETMETHOD",) -) +) # yapf: disable DefaultEnvironment( tools=[ "ar", "as", "gcc", "g++", "gnulink", "platformio", "devplatform", "piolib", "piotest", "pioupload", "pioar", "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(), - - 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() + util.get_projectlib_dir(), util.get_projectlibdeps_dir(), + join("$PIOHOME_DIR", "lib") ], - - PYTHONEXE=normpath(sys.executable) -) + PYTHONEXE=normpath(sys.executable)) env = DefaultEnvironment() @@ -126,10 +120,9 @@ env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) env.LoadDevPlatform(commonvars) env.SConscriptChdir(0) -env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite")) +env.SConsignFile(join("$PROJECTPIOENVS_DIR", ".sconsign.dblite")) env.SConscript("$BUILD_SCRIPT") - if "UPLOAD_FLAGS" in env: env.Append(UPLOADERFLAGS=["$UPLOAD_FLAGS"]) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 7e94f784..bfa941da 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -194,7 +194,7 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes if not search_paths: search_paths = tuple() assert isinstance(search_paths, tuple) - deep_search = self.env.get("LIB_DEEP_SEARCH", "true").lower() == "true" + deep_search = int(self.env.get("LIB_LDF_MODE", 2)) == 2 if not self._scanned_paths and ( isinstance(self, ProjectAsLibBuilder) or deep_search): @@ -270,6 +270,10 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes "Error: Could not find `%s` dependency for `%s` " "library\n" % (item['name'], self.name)) self.env.Exit(2) + + # when LDF is disabled + if "LIB_LDF_MODE" in self.env and \ + int(self.env.get("LIB_LDF_MODE")) == 0: return lib_inc_map = {} diff --git a/platformio/exception.py b/platformio/exception.py index 9b117740..33a49e77 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -109,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 "\ diff --git a/platformio/util.py b/platformio/util.py index 8cc9645b..2eeaec55 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -156,7 +156,7 @@ def _get_projconf_option_dir(name, default=None): if option_dir.startswith("~"): option_dir = expanduser(option_dir) return abspath(option_dir) - except exception.NotPlatformProject: + except exception.NotPlatformIOProject: pass return default @@ -180,13 +180,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,29 +194,33 @@ def get_project_dir(): return os.getcwd() -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 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") - ) +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(): + 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") @@ -247,18 +244,12 @@ 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.NotPlatformProject(project_dir) + raise exception.NotPlatformIOProject(project_dir) cp = ConfigParser() cp.read(join(project_dir, "platformio.ini")) return cp -def is_platformio_project(project_dir=None): - if not project_dir: - project_dir = get_project_dir() - return isfile(join(project_dir, "platformio.ini")) - - def change_filemtime(path, time): os.utime(path, (time, time)) @@ -358,6 +349,12 @@ def get_request_defheaders(): )} +@memoized +def _api_request_session(): + import requests + return requests.Session() + + def get_api_result(path, params=None, data=None, skipdns=False): import requests result = None @@ -371,12 +368,14 @@ def get_api_result(path, params=None, data=None, skipdns=False): 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']) From e49994e205862eb1d11ad7fca7918e716b65dbfb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 00:16:52 +0300 Subject: [PATCH 082/119] Fix PyLint warning --- platformio/builder/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 493f1a22..714d7ca7 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -70,7 +70,7 @@ DefaultEnvironment( "ar", "as", "gcc", "g++", "gnulink", "platformio", "devplatform", "piolib", "piotest", "pioupload", "pioar", "piomisc" - ], # yapf: disable + ], # yapf: disable toolpath=[join(util.get_source_dir(), "builder", "tools")], variables=commonvars, From 34231327b73bf45d93e04f680f17bc604db8266a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 00:19:43 +0300 Subject: [PATCH 083/119] Minor fixes --- platformio/__init__.py | 2 +- platformio/commands/run.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 5f0228e9..6ac5d903 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev14") +VERSION = (3, 0, "0.dev15") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 9aaa9912..f29e053e 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -46,14 +46,13 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 # 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(), + fg="yellow") config = util.load_project_config() env_default = None @@ -105,8 +104,7 @@ class EnvironmentProcessor(object): RENAMED_OPTIONS = { "INSTALL_LIBS": "LIB_INSTALL", "IGNORE_LIBS": "LIB_IGNORE", - "LIB_USE": "LIB_FORCE", - "LIB_DFCYCLIC": "LIB_DEEP_SEARCH" + "LIB_USE": "LIB_FORCE" } def __init__(self, cmd_ctx, name, options, # pylint: disable=R0913 From ef535e399e24233f110976079dc615d385234973 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 00:21:52 +0300 Subject: [PATCH 084/119] Cleanup docs --- docs/librarymanager/ldf.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst index c3526436..c1a8d79b 100644 --- a/docs/librarymanager/ldf.rst +++ b/docs/librarymanager/ldf.rst @@ -131,14 +131,6 @@ library with real build environment. Available compatibility modes: This mode can be changed using :ref:`projectconf_lib_compat_mode` option in :ref:`projectconf`. -Manual dependencies -------------------- - -If project or library contains own ``dependencies`` list (see -:ref:`libjson_dependencies`), the LDF will not looking for dependencies in -the source code. The specified libraries will be built automatically without -check. - .. _ldf_c_cond_syntax: C Preprocessor conditional syntax From e5b76687a8948698eb8ee1921350f4ca36a61cb1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 00:32:38 +0300 Subject: [PATCH 085/119] Minor changes for PyLint --- platformio/builder/tools/piolib.py | 55 ++++++++++++++++-------------- platformio/libmanager.py | 2 +- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index bfa941da..6249107f 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -144,6 +144,9 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes def build_dir(self): return join("$BUILD_DIR", "lib", self.name) + def get_inc_dirs(self, use_build_dir=False): + return [self.build_dir if use_build_dir else self.src_dir] + @property def build_flags(self): return None @@ -187,8 +190,31 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes exports={"env": self.env, "pio_lib_builder": self}) - def get_inc_dirs(self, use_build_dir=False): - return [self.build_dir if use_build_dir else self.src_dir] + 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(2) def _validate_search_paths(self, search_paths=None): if not search_paths: @@ -246,30 +272,7 @@ class LibBuilderBase(object): # pylint: disable=too-many-instance-attributes def search_deps_recursive(self, lib_builders, search_paths=None): self._is_dependent = True - # if dependencies are specified, don't use automatic finder - if self.dependencies: - 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(2) + self._process_dependencies(lib_builders) # when LDF is disabled if "LIB_LDF_MODE" in self.env and \ diff --git a/platformio/libmanager.py b/platformio/libmanager.py index 964b10d0..8235d102 100644 --- a/platformio/libmanager.py +++ b/platformio/libmanager.py @@ -29,7 +29,7 @@ class LibraryManager(object): CONFIG_NAME = ".library.json" def __init__(self, lib_dir=None): - self.lib_dir = lib_dir or util.get_lib_dir() + self.lib_dir = lib_dir or join(util.get_home_dir(), "lib") @staticmethod def download(url, dest_dir): From c728b91914cc519940e8d0bb912a778db4f4108d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 14:25:11 +0300 Subject: [PATCH 086/119] Check development version automatically --- platformio/commands/upgrade.py | 60 +++++++++++++++++++++++++--------- platformio/maintenance.py | 11 ++++--- platformio/util.py | 4 +++ 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 44e3b8ea..4f1f9b8e 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,19 +13,20 @@ # limitations under the License. import os +import re import sys 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") 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" @@ -34,13 +35,7 @@ def cli(): 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 - + to_develop = not all([c.isdigit() for c in latest if c != "."]) cmds = ( ["pip", "install", "--upgrade", "https://github.com/platformio/platformio/archive/develop.zip" @@ -100,10 +95,43 @@ WARNING! Don't use `sudo` for the rest PlatformIO commands. 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 isinstance(VERSION[2], int): + 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/maintenance.py b/platformio/maintenance.py index ad190080..5bc31f2c 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -67,8 +67,10 @@ def on_platformio_exception(e): class Upgrader(object): def __init__(self, from_version, to_version): - self.from_version = semantic_version.Version.coerce(from_version) - self.to_version = semantic_version.Version.coerce(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 = [ (semantic_version.Version("3.0.0"), self._upgrade_to_3_0_0) @@ -180,8 +182,9 @@ def check_platformio_upgrade(): app.set_state_item("last_check", last_check) latest_version = get_latest_version() - if (semantic_version.Version.coerce(latest_version) <= - semantic_version.Version.coerce(__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() diff --git a/platformio/util.py b/platformio/util.py index 2eeaec55..d3ac1980 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -461,3 +461,7 @@ 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) From e3bf12f65ce63a4e91b131b868638d881cced047 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 14:50:03 +0300 Subject: [PATCH 087/119] Rename test for platform command --- tests/commands/{test_platforms.py => test_platform.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/commands/{test_platforms.py => test_platform.py} (100%) diff --git a/tests/commands/test_platforms.py b/tests/commands/test_platform.py similarity index 100% rename from tests/commands/test_platforms.py rename to tests/commands/test_platform.py From e60c2a6ba1515a3fc8560cb6e921fb294204df8a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 1 Aug 2016 17:05:48 +0300 Subject: [PATCH 088/119] Improve base package manager; VCS and package ID support --- docs/userguide/platforms/cmd_install.rst | 60 +-- docs/userguide/platforms/cmd_uninstall.rst | 6 +- docs/userguide/platforms/cmd_update.rst | 77 ++-- platformio/commands/platform.py | 99 ++--- platformio/commands/run.py | 8 +- platformio/commands/test.py | 6 +- platformio/exception.py | 18 +- platformio/maintenance.py | 8 +- platformio/managers/package.py | 448 ++++++++++++--------- platformio/managers/platform.py | 94 +++-- platformio/vcsclient.py | 122 ++++-- tests/commands/test_platform.py | 89 +++- tests/test_managers.py | 66 +++ 13 files changed, 668 insertions(+), 433 deletions(-) create mode 100644 tests/test_managers.py diff --git a/docs/userguide/platforms/cmd_install.rst b/docs/userguide/platforms/cmd_install.rst index c43c3123..3ada1992 100644 --- a/docs/userguide/platforms/cmd_install.rst +++ b/docs/userguide/platforms/cmd_install.rst @@ -22,7 +22,7 @@ Usage .. code-block:: bash # install platform by name - platformio platform install [OPTIONS] PLATFORM + platformio platform install [OPTIONS] [PLATFORM...] # install specific platform version using Semantic Versioning platformio platform install [OPTIONS] PLATFORM@X.Y.Z @@ -45,10 +45,16 @@ There are several predefined aliases for packages, such as: Local ~~~~~ -PlatformIO supports installing development platform from local directory. Here -is supported form: +PlatformIO supports installing development platform from local directory or +archive. Need to use ``file://`` prefix before local path. Also, platform +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`` + +Remote +~~~~~~ VCS ~~~ @@ -135,34 +141,38 @@ Examples .. code-block:: bash $ platformio platform install atmelavr - Installing platform atmelavr @ latest: + PlatformManager: Installing atmelavr Downloading... Unpacking [####################################] 100% - Installing package tool-scons @ >=2.3.0,<2.6.0: + atmelavr @ 0.0.0 has been successfully installed! + PackageManager: Installing tool-scons @ >=2.3.0,<2.6.0 Downloading [####################################] 100% Unpacking [####################################] 100% - Installing package toolchain-atmelavr @ ~1.40801.0: + 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 'atmelavr' has been successfully installed! The rest of packages will be installed automatically depending on your build environment. - 2. Install :ref:`platform_atmelavr` with ``uploader`` utility only and skip default packages .. code-block:: bash - $ platformio platform install atmelavr --skip-default-package --with-package=uploader - Installing platform atmelavr @ latest: + PlatformManager: Installing atmelavr Downloading [####################################] 100% Unpacking [####################################] 100% - Installing package tool-micronucleus @ ~1.200.0: + atmelavr @ 0.0.0 has been successfully installed! + PackageManager: Installing tool-micronucleus @ ~1.200.0 Downloading [####################################] 100% Unpacking [####################################] 100% - Installing package tool-avrdude @ >=1.60001.0,<1.60101.0: + 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. @@ -171,27 +181,31 @@ Examples .. code-block:: bash $ platformio platform install https://github.com/platformio/platform-atmelavr.git - Installing platform https://github.com/platformio/platform-atmelavr.git @ latest: + + PlatformManager: Installing platform-atmelavr git version 2.7.4 (Apple Git-66) - Cloning into '/Users/ikravets/.platformio/platforms/installing-XMIsAE-package'... - remote: Counting objects: 172, done. - remote: Compressing objects: 100% (51/51), done. - remote: Total 172 (delta 109), reused 168 (delta 109), pack-reused 0 - Receiving objects: 100% (172/172), 38.18 KiB | 0 bytes/s, done. - Resolving deltas: 100% (109/109), done. + 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: 87, done. - remote: Total 87 (delta 0), reused 0 (delta 0), pack-reused 87 - Unpacking objects: 100% (87/87), done. + 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' - Installing package tool-scons @ >=2.3.0,<2.6.0: + atmelavr @ 0.0.0 has been successfully installed! + PackageManager: Installing tool-scons @ >=2.3.0,<2.6.0 Downloading [####################################] 100% Unpacking [####################################] 100% - Installing package toolchain-atmelavr @ ~1.40801.0: + 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_uninstall.rst b/docs/userguide/platforms/cmd_uninstall.rst index f1375d5e..3292f147 100644 --- a/docs/userguide/platforms/cmd_uninstall.rst +++ b/docs/userguide/platforms/cmd_uninstall.rst @@ -21,7 +21,7 @@ Usage .. code-block:: bash - platformio platform uninstall PLATFORM + platformio platform uninstall [PLATFORM...] # uninstall specific platform version using Semantic Versioning platformio platform uninstall PLATFORM@X.Y.Z @@ -39,7 +39,7 @@ Examples .. code-block:: bash $ platformio platform uninstall atmelavr - Uninstalling platform atmelavr @ latest: [OK] - Uninstalling package tool-scons @ 2.5.0: [OK] + 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 918aca8a..c48f802b 100644 --- a/docs/userguide/platforms/cmd_update.rst +++ b/docs/userguide/platforms/cmd_update.rst @@ -21,7 +21,10 @@ Usage .. code-block:: bash - platformio platform update + platformio platform update [OPTIONS] [PLATFORM...] + + # update specific platform version using Semantic Versioning + platformio platform update PLATFORM@X.Y.Z Description @@ -35,64 +38,48 @@ Options .. program:: platformio platform update .. option:: - --only-packages + -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 $ platformio platform update - Platform atmelavr @ 0.0.0 + Platform atmelavr -------- - Updating platform atmelavr @ latest: - Versions: Current=0.0.0, Latest=0.0.0 [Up-to-date] - Updating package framework-arduinoavr @ ~1.10608.0: - Versions: Current=1.10608.0, Latest=1.10608.0 [Up-to-date] - Updating package toolchain-atmelavr @ ~1.40801.0: - Versions: Current=1.40801.0, Latest=1.40801.0 [Up-to-date] - Updating package framework-simba @ ~1.500.0: - Versions: Current=1.500.0, Latest=1.500.0 [Up-to-date] - Updating package tool-scons @ >=2.3.0,<2.6.0: - Versions: Current=2.5.0, Latest=2.5.0 [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 @ 0.0.0 + Platform espressif -------- - Updating platform atmelsam @ latest: - Versions: Current=0.0.0, Latest=0.0.0 [Up-to-date] - Updating package toolchain-gccarmnoneeabi @ >=1.40803.0,<1.40805.0: - Versions: Current=1.40804.0, Latest=1.40804.0 [Up-to-date] - Updating package framework-arduinosam @ ~1.10607.0: - Versions: Current=1.10607.0, Latest=1.10607.0 [Up-to-date] - Updating package framework-simba @ ~1.500.0: - Versions: Current=1.500.0, Latest=1.500.0 [Up-to-date] - Updating package framework-mbed @ ~1.117.0: - Versions: Current=1.117.0, Latest=1.117.0 [Up-to-date] - Updating package tool-scons @ >=2.3.0,<2.6.0: - Versions: Current=2.5.0, Latest=2.5.0 [Up-to-date] - Updating package tool-bossac @ ~1.10500.0: - Versions: Current=1.10500.0, Latest=1.10500.0 [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-arduinoespressif @ 1.20300.0: [Up-to-date] + Updating sdk-esp8266 @ 1.10502.0: [Up-to-date] - Platform espressif @ 0.0.0 + Platform teensy -------- - Updating platform espressif @ latest: - Versions: Current=0.0.0, Latest=0.0.0 [Up-to-date] - Updating package tool-scons @ >=2.3.0,<2.6.0: - Versions: Current=2.5.0, Latest=2.5.0 [Up-to-date] - Updating package toolchain-xtensa @ ~1.40802.0: - Versions: Current=1.40802.0, Latest=1.40802.0 [Up-to-date] - Updating package framework-simba @ ~1.500.0: - Versions: Current=1.500.0, Latest=1.500.0 [Up-to-date] - Updating package tool-esptool @ ~1.408.0: - Versions: Current=1.408.0, Latest=1.408.0 [Up-to-date] - Updating package tool-mkspiffs @ ~1.102.0: - Versions: Current=1.102.0, Latest=1.102.0 [Up-to-date] - Updating package framework-arduinoespressif @ ~1.20200.0: - Versions: Current=1.20200.0, Latest=1.20200.0 [Up-to-date] - Updating package sdk-esp8266 @ ~1.10502.0: - Versions: Current=1.10502.0, Latest=1.10502.0 [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] ... diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index eb81ddac..9a6d7704 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -13,7 +13,6 @@ # limitations under the License. import json -from os.path import basename import click @@ -29,13 +28,14 @@ def cli(): def _print_platforms(platforms): for platform in platforms: click.echo("{name} ~ {title}".format( - name=click.style(platform['name'], fg="cyan"), + 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']) + click.echo("Home: %s" % "http://platformio.org/platforms/" + platform[ + 'name']) if platform['packages']: click.echo("Packages: %s" % ", ".join(platform['packages'])) if "version" in platform: @@ -71,22 +71,19 @@ def platform_search(query, json_output): @cli.command("install", short_help="Install new platforms") -@click.argument("platforms", nargs=-1, required=True) +@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: - _platform = platform - _version = None - if any([s in platform for s in ("\\", "/")]): - _platform = basename(platform) - _version = platform - elif "@" in platform: - _platform, _version = platform.rsplit("@", 1) - if PlatformManager().install(_platform, _version, with_package, - without_package, skip_default_package): + 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 " @@ -94,12 +91,49 @@ def platform_install(platforms, with_package, without_package, fg="green") +@cli.command("uninstall", short_help="Uninstall platforms") +@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 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 platforms") @click.option("--json-output", is_flag=True) def platform_list(json_output): platforms = [] - for manifest in PlatformManager().get_installed(): - p = PlatformFactory.newPlatform(manifest['_manifest_path']) + 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, @@ -129,7 +163,8 @@ def platform_show(ctx, platform): raise exception.PlatformNotInstalledYet(platform) click.echo("{name} ~ {title}".format( - name=click.style(p.name, fg="cyan"), title=p.title)) + name=click.style( + p.name, fg="cyan"), title=p.title)) click.echo("=" * (3 + len(p.name + p.title))) click.echo(p.description) click.echo() @@ -152,35 +187,9 @@ def platform_show(ctx, platform): 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)")) + 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)) - - -@cli.command("uninstall", short_help="Uninstall platforms") -@click.argument("platforms", nargs=-1, required=True) -def platform_uninstall(platforms): - for platform in platforms: - _platform = platform - _version = None - if "@" in platform: - _platform, _version = platform.rsplit("@", 1) - if PlatformManager().uninstall(_platform, _version): - click.secho("The platform '%s' has been successfully " - "uninstalled!" % platform, fg="green") - - -@cli.command("update", short_help="Update installed Platforms") -@click.option("--only-packages", is_flag=True) -def platform_update(only_packages): - pm = PlatformManager() - for manifest in pm.get_installed(): - click.echo("Platform %s @ %s" % ( - click.style(manifest['name'], fg="cyan"), manifest['version'])) - click.echo("--------") - pm.update(manifest['name'], manifest['version'], - only_packages=only_packages) - click.echo() diff --git a/platformio/commands/run.py b/platformio/commands/run.py index f29e053e..53fc96de 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -190,17 +190,13 @@ class EnvironmentProcessor(object): if "lib_install" in self.options: _autoinstall_libs(self.cmd_ctx, self.options['lib_install']) - platform = self.options['platform'] - version = None - if "@" in platform: - platform, version = platform.rsplit("@", 1) try: - p = PlatformFactory.newPlatform(platform, version) + p = PlatformFactory.newPlatform(self.options['platform']) except exception.UnknownPlatform: self.cmd_ctx.invoke( cmd_platform_install, platforms=[self.options['platform']]) - p = PlatformFactory.newPlatform(platform, version) + p = PlatformFactory.newPlatform(self.options['platform']) return p.run(build_vars, build_targets, self.verbose) diff --git a/platformio/commands/test.py b/platformio/commands/test.py index 55ea49df..31811afd 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.py @@ -174,11 +174,7 @@ class TestProcessor(object): if self.options.get("upload_port", envdata.get("upload_port")): return self.options.get("upload_port", envdata.get("upload_port")) - platform = envdata['platform'] - version = None - if "@" in platform: - platform, version = platform.rsplit("@", 1) - p = PlatformFactory.newPlatform(platform, version) + p = PlatformFactory.newPlatform(envdata['platform']) bconfig = p.board_config(envdata['board']) port = None diff --git a/platformio/exception.py b/platformio/exception.py index 33a49e77..197ec0f9 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -72,24 +72,14 @@ class UnknownPackage(PlatformioException): class UndefinedPackageVersion(PlatformioException): - MESSAGE = "Can not find package '{0}' with version requirements '{1}'"\ - " for your system '{2}'" - - -class UndefinedPlatformVersion(PlatformioException): - - MESSAGE = "Can not find platform '{0}' with version requirements '{1}'" + MESSAGE = "Could not find a version that satisfies the requirement '{0}'"\ + " for your system '{1}'" class PackageInstallError(PlatformioException): - MESSAGE = "Can not install package '{0}' with version requirements '{1}' "\ - "for your system '{2}'" - - -class NonSystemPackage(PlatformioException): - - MESSAGE = "The package '{0}' is not available for your system '{1}'" + MESSAGE = "Can not install '{0}' with version requirements '{1}' "\ + "for your system '{2}'" class FDUnrecognizedStatusCode(PlatformioException): diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 5bc31f2c..ccea3cd1 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -130,7 +130,7 @@ def after_upgrade(ctx): # patch development platforms pm = PlatformManager() for manifest in pm.get_installed(): - pm.update(manifest['name'], "~" + manifest['version']) + pm.update(manifest['name'], "^" + manifest['version']) click.secho("PlatformIO has been successfully upgraded to %s!\n" % __version__, fg="green") @@ -225,9 +225,9 @@ def check_internal_updates(ctx, what): if what == "platforms": pm = PlatformManager() for manifest in pm.get_installed(): - if pm.is_outdated(manifest['name'], manifest['version']): - outdated_items.append( - "%s@%s" % (manifest['name'], manifest['version'])) + if manifest['name'] not in outdated_items and \ + pm.is_outdated(manifest['name']): + outdated_items.append(manifest['name']) elif what == "libraries": lm = LibraryManager() outdated_items = lm.get_outdated() diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 352c0d00..45e3e174 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -14,7 +14,7 @@ import json import os -from os.path import dirname, isdir, isfile, islink, join +from os.path import basename, dirname, isdir, isfile, islink, join from shutil import copyfile, copytree, rmtree from tempfile import mkdtemp @@ -75,18 +75,21 @@ class PkgRepoMixin(object): def max_satisfying_repo_version(versions, requirements=None): item = None systype = util.get_systype() - if requirements is not None: - requirements = str(requirements) + reqspec = None + if requirements: + try: + reqspec = semantic_version.Spec(requirements) + except ValueError: + pass + for v in versions: - if isinstance(v['version'], int): + if ("system" in v and v['system'] not in ("all", "*") and + systype not in v['system']): continue - if v['system'] not in ("all", "*") and systype not in v['system']: + specver = semantic_version.Version(v['version']) + if reqspec and specver not in reqspec: continue - if requirements and not semantic_version.match( - requirements, v['version']): - continue - if item is None or semantic_version.compare( - v['version'], item['version']) == 1: + if not item or semantic_version.Version(item['version']) < specver: item = v return item @@ -96,8 +99,8 @@ class PkgRepoMixin(object): pkgdata = self.max_satisfying_repo_version(versions, requirements) if not pkgdata: continue - if (not version or semantic_version.compare( - pkgdata['version'], version) == 1): + if not version or semantic_version.compare(pkgdata['version'], + version) == 1: version = pkgdata['version'] return version @@ -126,77 +129,11 @@ class PkgInstallerMixin(object): manifest_path = self.get_manifest_path(pkg_dir) if manifest_path: manifest = util.load_json(manifest_path) - manifest['_manifest_path'] = manifest_path manifest['__pkg_dir'] = pkg_dir return manifest return None - 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 another mirror...", fg="yellow") - - if versions is None: - raise exception.UnknownPackage(name) - elif not pkgdata: - if "platform" in self.manifest_name: - raise exception.UndefinedPlatformVersion( - name, requirements or "latest") - else: - raise exception.UndefinedPackageVersion( - name, 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) - - # Handle GitHub URL (https://github.com/user/repo.git) - if url.endswith(".git") and not url.startswith("git"): - url = "git+" + url - - try: - if url.startswith("file://"): - url = url[7:] - if isfile(url): - self.unpack(url, tmp_dir) - else: - rmtree(tmp_dir) - copytree(url, tmp_dir) - elif url.startswith(("http://", "https://", "ftp://")): - 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": "0.0.0+rev%s" % vcs.get_latest_revision(), - "url": url}, fp) - - self._check_pkg_structure(tmp_dir) - pkg_dir = self._install_from_tmp_dir(tmp_dir, requirements) - finally: - if isdir(tmp_dir): - rmtree(tmp_dir) - return pkg_dir - - def _check_pkg_structure(self, pkg_dir): + def check_pkg_structure(self, pkg_dir): if self.manifest_exists(pkg_dir): return True @@ -225,28 +162,98 @@ class PkgInstallerMixin(object): "Could not find '%s' manifest file in the package" % 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: + 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) + + self.check_pkg_structure(tmp_dir) + pkg_dir = self._install_from_tmp_dir(tmp_dir, requirements) + finally: + if isdir(tmp_dir): + 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: - assert semantic_version.match( - requirements, tmpmanifest['version']) + 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): - manifest = self.load_manifest(pkg_dir) - cmp_result = semantic_version.compare( - tmpmanifest['version'], manifest['version']) - if cmp_result == 1: - # if main package version < new package, backup it - os.rename(pkg_dir, join( - self.package_dir, "%s@%s" % (name, manifest['version']))) - elif cmp_result == -1: - pkg_dir = join( - self.package_dir, "%s@%s" % (name, tmpmanifest['version'])) + 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): @@ -291,6 +298,50 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): 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) + + # Handle GitHub URL (https://github.com/user/package.git) + if url.startswith("https://github.com/") and \ + not url.endswith((".zip", ".tar.gz")): + url = "git+" + url + # Handle Developer Mbed URL + # (https://developer.mbed.org/users/user/code/package/) + if 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 + 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] @@ -304,26 +355,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): BasePkgManager._INSTALLED_CACHE[self.package_dir] = items return items - def is_installed(self, name, requirements=None): - installed = self.get_installed() - reqspec = None - if requirements: - try: - reqspec = semantic_version.Spec(requirements) - except ValueError: - pass - - if not reqspec: - return any([p['name'] == name for p in installed]) - - for p in installed: - if p['name'] != name: - continue - elif reqspec.match(semantic_version.Version(p['version'])): - return True - return None - - def max_installed_version(self, name, requirements=None): + def get_installed_dir(self, name, requirements=None, url=None): + pkg_id = int(name[3:]) if name.startswith("id=") else 0 best = None reqspec = None if requirements: @@ -333,123 +366,152 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): pass for manifest in self.get_installed(): - if manifest['name'] != name: + if pkg_id and manifest.get("id") != pkg_id: continue - elif reqspec and not reqspec.match( - semantic_version.Version(manifest['version'])): + elif not pkg_id and manifest['name'] != name: continue - elif (not best or semantic_version.compare( - manifest['version'], best['version']) == 1): - best = manifest - + 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.get("__pkg_dir") return None - def install(self, name, requirements, silent=False, trigger_event=True): - installed = self.is_installed(name, requirements) - if not installed or not silent: - self.print_message("Installing %s @ %s:" % ( - click.style(name, fg="cyan"), - requirements if requirements else "latest")) - if installed: - if not silent: - click.secho("Already installed", fg="yellow") - return self.max_installed_version( - name, requirements) + def install(self, name, requirements=None, quiet=False, + trigger_event=True): + name, requirements, url = self.parse_pkg_name(name, requirements) + installed_dir = self.get_installed_dir(name, requirements, url) - if (requirements and any([s in requirements for s in ("\\", "/")]) and - "://" not in requirements and ( - isfile(requirements) or isdir(requirements))): - requirements = "file://" + requirements + if not installed_dir or not quiet: + msg = "Installing " + click.style(name, fg="cyan") + if requirements: + msg += " @ " + requirements + self.print_message(msg) + if installed_dir: + if not quiet: + click.secho( + "{name} @ {version} is already installed".format( + **self.load_manifest(installed_dir)), + fg="yellow") + return installed_dir - if requirements and "://" in requirements: - pkg_dir = self._install_from_url(name, requirements) + 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 "latest", util.get_systype()) + 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=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): - self.print_message("Uninstalling %s @ %s: \t" % ( - click.style(name, fg="cyan"), - requirements if requirements else "latest"), nl=False) - found = False - for manifest in self.get_installed(): - if manifest['name'] != name: - continue - if (requirements and not semantic_version.match( - requirements, manifest['version'])): - continue - found = True - if isdir(manifest['__pkg_dir']): - if islink(manifest['__pkg_dir']): - os.unlink(manifest['__pkg_dir']) - else: - rmtree(manifest['__pkg_dir']) + name, requirements, url = self.parse_pkg_name(name, requirements) + installed_dir = self.get_installed_dir(name, requirements, url) + if not installed_dir: + click.secho( + "%s @ %s is not installed" % (name, requirements or "*"), + fg="yellow") + return - if not found: - click.secho("Not installed", fg="yellow") - return False - else: - click.echo("[%s]" % click.style("OK", fg="green")) + manifest = self.load_manifest(installed_dir) + click.echo( + "Uninstalling %s @ %s: \t" % (click.style( + manifest['name'], fg="cyan"), manifest['version']), + nl=False) + + if isdir(installed_dir): + if islink(installed_dir): + os.unlink(installed_dir) + else: + rmtree(installed_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=name) + action="Uninstall", + label=manifest['name']) + return True - def update(self, name, requirements=None): - self.print_message("Updating %s @ %s:" % ( - click.style(name, fg="yellow"), - requirements if requirements else "latest")) - - latest_version = self.get_latest_repo_version(name, requirements) - if latest_version is None: + def update(self, name, requirements=None, only_check=False): + name, requirements, url = self.parse_pkg_name(name, requirements) + installed_dir = self.get_installed_dir(name, requirements, url) + if not installed_dir: click.secho( - "Ignored! '%s' is not listed in registry" % name, + "%s @ %s is not installed" % (name, requirements or "*"), fg="yellow") return - current = None - for manifest in self.get_installed(): - if manifest['name'] != name: - continue - if (requirements and not semantic_version.match( - requirements, manifest['version'])): - continue - if (not current or semantic_version.compare( - manifest['version'], current['version']) == 1): - current = manifest - - if current is None: - return - - current_version = current['version'] - 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"))) - return True + manifest = self.load_manifest(installed_dir) + click.echo( + "Updating %s @ %s: \t" % (click.style( + manifest['name'], fg="cyan"), manifest['version']), + nl=False) + manifest_path = self.get_manifest_path(installed_dir) + if manifest_path.endswith(self.VCS_MANIFEST_NAME): + if only_check: + click.echo("[%s]" % (click.style("Skip", fg="yellow"))) + return + click.echo("[%s]" % (click.style("Checking", fg="yellow"))) + vcs = VCSClientFactory.newClient(installed_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 = self.get_latest_repo_version(name, requirements) + 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"))) - - self.install(name, latest_version, trigger_event=False) + if only_check: + return + self.install(name, latest_version, trigger_event=False) telemetry.on_event( category=self.__class__.__name__, - action="Update", label=name) + action="Update", + label=manifest['name']) return True diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index db7ea51a..2a485f07 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -26,17 +26,17 @@ import semantic_version from platformio import app, exception, util from platformio.managers.package import BasePkgManager, PackageManager -PLATFORMS_DIR = join(util.get_home_dir(), "platforms") -PACKAGES_DIR = join(util.get_home_dir(), "packages") - class PlatformManager(BasePkgManager): def __init__(self, package_dir=None, repositories=None): if not repositories: - repositories = ["http://dl.platformio.org/platforms/manifest.json"] - BasePkgManager.__init__( - self, package_dir or PLATFORMS_DIR, repositories) + repositories = [ + "https://dl.platformio.org/platforms/manifest.json" + ] + BasePkgManager.__init__(self, package_dir or + join(util.get_home_dir(), "platforms"), + repositories) @property def manifest_name(self): @@ -44,27 +44,29 @@ class PlatformManager(BasePkgManager): def install(self, # pylint: disable=too-many-arguments,arguments-differ name, requirements=None, with_packages=None, - without_packages=None, skip_default_packages=False): + 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_packages) + p.install_packages(with_packages, without_packages, + skip_default_package) self.cleanup_packages(p.packages.keys()) return True - def uninstall(self, # pylint: disable=arguments-differ - name, requirements=None): + def uninstall( # pylint: disable=arguments-differ + self, name, requirements=None): + name, requirements, _ = self.parse_pkg_name(name, requirements) p = PlatformFactory.newPlatform(name, requirements) BasePkgManager.uninstall(self, name, requirements) self.cleanup_packages(p.packages.keys()) return True def update(self, # pylint: disable=arguments-differ - name, requirements=None, only_packages=False): + 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) + BasePkgManager.update(self, name, requirements, only_check) p = PlatformFactory.newPlatform(name, requirements) - p.update_packages() + p.update_packages(only_check) self.cleanup_packages(p.packages.keys()) return True @@ -77,14 +79,14 @@ class PlatformManager(BasePkgManager): self.reset_cache() deppkgs = {} for manifest in PlatformManager().get_installed(): - p = PlatformFactory.newPlatform( - manifest['name'], manifest['version']) + 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(PACKAGES_DIR) + pm = PackageManager(join(util.get_home_dir(), "packages")) for manifest in pm.get_installed(): if manifest['name'] not in names: continue @@ -126,35 +128,36 @@ class PlatformFactory(object): def load_module(name, path): module = None try: - module = load_source( - "platformio.managers.platform.%s" % name, path) + module = load_source("platformio.managers.platform.%s" % name, + path) except ImportError: raise exception.UnknownPlatform(name) return module @classmethod def newPlatform(cls, name, requirements=None): + if not requirements and "@" in name: + name, requirements = name.rsplit("@", 1) platform_dir = None if name.endswith("platform.json") and isfile(name): platform_dir = dirname(name) name = util.load_json(name)['name'] else: - platform_dir = PlatformManager().max_installed_version( - name, requirements) + platform_dir = PlatformManager().get_installed_dir(name, + requirements) if not platform_dir: - raise exception.UnknownPlatform( - name if not requirements else "%s@%s" % (name, requirements)) + 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) - ) + cls.get_clsname(name)) else: platform_cls = type( - str(cls.get_clsname(name)), (PlatformBase,), {}) + str(cls.get_clsname(name)), (PlatformBase, ), {}) _instance = platform_cls(join(platform_dir, "platform.json")) assert isinstance(_instance, PlatformBase) @@ -187,12 +190,13 @@ class PlatformPackagesMixin(object): items[name] = manifest return items - def install_packages(self, with_packages=None, without_packages=None, - skip_default_packages=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 [])) + def install_packages(self, + with_packages=None, + without_packages=None, + skip_default_package=False, + quiet=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()) @@ -203,14 +207,18 @@ class PlatformPackagesMixin(object): if name in without_packages: continue elif (name in with_packages or - not (skip_default_packages or opts.get("optional", False))): - self.pm.install(name, opts.get("version"), silent=silent) + 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']), quiet=quiet) + else: + self.pm.install(name, opts.get("version"), quiet=quiet) return True - def update_packages(self): + def update_packages(self, only_check=False): for name in self.get_installed_packages(): - self.pm.update(name, self.packages[name]['version']) + self.pm.update(name, self.packages[name]['version'], only_check) def are_outdated_packages(self): for name, opts in self.get_installed_packages().items(): @@ -229,7 +237,7 @@ class PlatformRunMixin(object): assert isinstance(targets, list) self.configure_default_packages(variables, targets) - self.install_packages(silent=True) + self.install_packages(quiet=True) self._verbose = verbose or app.get_setting("force_verbose") @@ -261,10 +269,8 @@ class PlatformRunMixin(object): cmd = [ os.path.normpath(sys.executable), - join(self.get_package_dir("tool-scons"), "script", "scons"), - "-Q", - "-j %d" % self.get_job_nums(), - "--warn=no-no-parallel-support", + 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") ] if not self._verbose and "-c" not in targets: @@ -278,8 +284,7 @@ class PlatformRunMixin(object): result = util.exec_command( cmd, stdout=util.AsyncPipe(self.on_run_out), - stderr=util.AsyncPipe(self.on_run_err) - ) + stderr=util.AsyncPipe(self.on_run_err)) return result def on_run_out(self, line): @@ -315,7 +320,8 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): self._manifest = util.load_json(manifest_path) self.pm = PackageManager( - PACKAGES_DIR, self._manifest.get("packageRepositories")) + join(util.get_home_dir(), "packages"), + self._manifest.get("packageRepositories")) self._verbose = False diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index f915e0e3..fffd6792 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.py @@ -12,12 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os import listdir -from os.path import isdir, join -from platform import system +import re +from os.path import join from subprocess import check_call from sys import modules -from urlparse import urlsplit, urlunsplit +from urlparse import urlparse from platformio import util from platformio.exception import PlatformioException @@ -26,28 +25,16 @@ from platformio.exception import PlatformioException class VCSClientFactory(object): @staticmethod - def newClient(src_dir, remote_url=None, branch=None): - clsnametpl = "%sClient" - vcscls = None - type_ = None - if remote_url: - scheme, netloc, path, query, branch = urlsplit(remote_url) - type_ = scheme - if "+" in type_: - type_, scheme = type_.split("+", 1) - remote_url = urlunsplit((scheme, netloc, path, query, None)) - vcscls = getattr(modules[__name__], clsnametpl % type_.title()) - elif isdir(src_dir): - for item in listdir(src_dir): - if not isdir(join(src_dir, item)) or not item.startswith("."): - continue - try: - vcscls = getattr( - modules[__name__], clsnametpl % item[1:].title()) - except AttributeError: - pass - assert vcscls - obj = vcscls(src_dir, remote_url, branch) + def newClient(src_dir, remote_url): + result = urlparse(remote_url) + type_ = result.scheme + if "+" 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] + obj = getattr(modules[__name__], "%sClient" % type_.title())( + src_dir, remote_url, result.fragment) assert isinstance(obj, VCSClientBase) return obj @@ -79,19 +66,29 @@ class VCSClientBase(object): def export(self): raise NotImplementedError - def get_latest_revision(self): + def update(self): + raise NotImplementedError + + @property + def can_be_updated(self): + return not self.branch + + def get_current_revision(self): raise NotImplementedError def run_cmd(self, args, **kwargs): args = [self.command] + args - kwargs['shell'] = system() == "Windows" + 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'] + return result['out'].strip() raise PlatformioException( "VCS: Could not receive an output from `%s` command (%s)" % ( args, result)) @@ -101,16 +98,42 @@ 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.branch or not self.is_commit_id(self.branch) + def export(self): - args = ["clone", "--recursive", "--depth", "1"] - if self.branch: - args.extend(["--branch", self.branch]) - args.extend([self.remote_url, self.src_dir]) + is_commit = self.is_commit_id(self.branch) + args = ["clone", "--recursive"] + if not self.branch or not is_commit: + args += ["--depth", "1"] + if self.branch: + args += ["--branch", self.branch] + args += [self.remote_url, self.src_dir] + assert self.run_cmd(args) + if is_commit: + return self.run_cmd(["reset", "--hard", self.branch]) + return True + + def update(self): + args = ["pull"] return self.run_cmd(args) - def get_latest_revision(self): - return self.get_cmd_output(["rev-parse", "--short", "HEAD"], - cwd=self.src_dir).strip() + def get_current_revision(self): + return self.get_cmd_output(["rev-parse", "--short", "HEAD"]) class HgClient(VCSClientBase): @@ -124,9 +147,12 @@ class HgClient(VCSClientBase): args.extend([self.remote_url, self.src_dir]) return self.run_cmd(args) - def get_latest_revision(self): - return self.get_cmd_output(["identify", "--id"], - cwd=self.src_dir).strip() + 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): @@ -134,12 +160,22 @@ class SvnClient(VCSClientBase): command = "svn" def export(self): - args = ["export", "--force"] + args = ["checkout"] if self.branch: args.extend(["--revision", self.branch]) args.extend([self.remote_url, self.src_dir]) return self.run_cmd(args) - def get_latest_revision(self): - return self.get_cmd_output(["info", "-r", "HEAD"], - cwd=self.src_dir).strip() + 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/tests/commands/test_platform.py b/tests/commands/test_platform.py index db4d735e..bd96230e 100644 --- a/tests/commands/test_platform.py +++ b/tests/commands/test_platform.py @@ -13,15 +13,15 @@ # limitations under the License. import json +import os +from os.path import join -from platformio.commands.platform import \ - platform_list as cmd_platform_list -from platformio.commands.platform import \ - platform_search as cmd_platform_search +from platformio.commands import platform as cli_platform +from platformio import exception, util def test_list_json_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platform_list, ["--json-output"]) + result = clirunner.invoke(cli_platform.platform_list, ["--json-output"]) validate_cliresult(result) list_result = json.loads(result.output) assert isinstance(list_result, list) @@ -31,13 +31,13 @@ def test_list_json_output(clirunner, validate_cliresult): def test_list_raw_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platform_list) + 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(cmd_platform_search, + result = clirunner.invoke(cli_platform.platform_search, ["arduino", "--json-output"]) validate_cliresult(result) search_result = json.loads(result.output) @@ -48,6 +48,79 @@ def test_search_json_output(clirunner, validate_cliresult): def test_search_raw_output(clirunner, validate_cliresult): - result = clirunner.invoke(cmd_platform_search, ["arduino"]) + 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/test_managers.py b/tests/test_managers.py new file mode 100644 index 00000000..abed10a1 --- /dev/null +++ b/tests/test_managers.py @@ -0,0 +1,66 @@ +# Copyright 2014-present 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 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://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 From bfab3dac813aab5ca963a084e00cb0bb1e0d68a2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 2 Aug 2016 14:04:32 +0300 Subject: [PATCH 089/119] Measure code coverage by tests // Resolve #101 --- .coveragerc | 26 ++++++++++++++++++++++++++ .gitignore | 2 ++ .travis.yml | 3 +++ README.rst | 2 ++ tox.ini | 14 +++++++++++--- 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..cfb6fb9d --- /dev/null +++ b/.coveragerc @@ -0,0 +1,26 @@ +# Copyright 2014-present 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. + +[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/.gitignore b/.gitignore index 89257136..549cf8bb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ docs/_build dist build .cache +coverage.xml +.coverage diff --git a/.travis.yml b/.travis.yml index 0a418de9..8c34f8da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,9 @@ install: script: - tox -e $TOX_ENV +after_success: + - tox -e coverage + notifications: slack: secure: ksQmXOP5NVsf8IgoDuxD68Q/YNwDpZuwq0V29h2dxYCr38oYdAkq/Os4LSCs0X6P0cQFf6nC1hM/d+cAvU+SmzcHGxEceHNEGCg3/TAj+68KIwooPU93Lfq1zwdfteZWxANjKlCQy4+wZliHLhL8fvCYgfJww/6qKmqSYleBNM= diff --git a/README.rst b/README.rst index a3854318..3f51c344 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 diff --git a/tox.ini b/tox.ini index 7b32c481..39e23c8d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -55,7 +55,15 @@ basepython = py27: python2.7 usedevelop = True passenv = * -deps = pytest +deps = + pytest + pytest-cov commands = {envpython} --version - py.test -v --basetemp="{envtmpdir}" tests + py.test --cov=platformio -v --basetemp="{envtmpdir}" tests + +[testenv:coverage] +passenv = * +basepython = python2.7 +deps = codecov +commands = codecov From 26dae8ee94c9ccee48527eb280f575e18bcba28e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 2 Aug 2016 15:45:05 +0300 Subject: [PATCH 090/119] Skip some tests from coverage --- tox.ini | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 39e23c8d..efc4138c 100644 --- a/tox.ini +++ b/tox.ini @@ -60,10 +60,12 @@ deps = pytest-cov commands = {envpython} --version - py.test --cov=platformio -v --basetemp="{envtmpdir}" tests + py.test -v --basetemp="{envtmpdir}" tests [testenv:coverage] passenv = * basepython = python2.7 deps = codecov -commands = codecov +commands = + py.test --cov=platformio -v tests --ignore=tests/test_examples.py --ignore=tests/test_pkgmanifest.py + codecov From 5b5a63cb5f4d58b7314ffe75a2bc91486775d962 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 2 Aug 2016 15:50:04 +0300 Subject: [PATCH 091/119] Use codecov after success script --- .gitignore | 1 + .travis.yml | 3 ++- tox.ini | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 549cf8bb..0a54e681 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build .cache coverage.xml .coverage +htmlcov diff --git a/.travis.yml b/.travis.yml index 8c34f8da..5b210f4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: install: - git submodule update --init --recursive - - pip install -U pip setuptools tox + - pip install -U pip setuptools tox codecov - sudo apt-get install -qq lib32z1 lib32ncurses5 lib32bz2-1.0 # temporarily script: @@ -18,6 +18,7 @@ script: after_success: - tox -e coverage + - bash <(curl -s https://codecov.io/bash) notifications: slack: diff --git a/tox.ini b/tox.ini index efc4138c..71717e00 100644 --- a/tox.ini +++ b/tox.ini @@ -65,7 +65,5 @@ commands = [testenv:coverage] passenv = * basepython = python2.7 -deps = codecov commands = py.test --cov=platformio -v tests --ignore=tests/test_examples.py --ignore=tests/test_pkgmanifest.py - codecov From 758396c9ead77cd8050754b50ba202ee44570cff Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 2 Aug 2016 19:10:29 +0300 Subject: [PATCH 092/119] PlatformIO Library Manager 3.0 // Resolve #588 , Resolve #414, Resolve #498, Resolve #475, Resolve #410, Resolve #461, Resolve #361, Resolve #507, Resolve #554 --- HISTORY.rst | 76 +++-- docs/librarymanager/ldf.rst | 2 +- docs/projectconf.rst | 2 +- docs/userguide/lib/cmd_install.rst | 228 +++++++++++--- docs/userguide/lib/cmd_list.rst | 42 ++- docs/userguide/lib/cmd_register.rst | 6 +- docs/userguide/lib/cmd_search.rst | 195 ++++++------ docs/userguide/lib/cmd_show.rst | 67 ++++- docs/userguide/lib/cmd_uninstall.rst | 48 ++- docs/userguide/lib/cmd_update.rst | 119 +++++--- docs/userguide/lib/index.rst | 39 ++- docs/userguide/platforms/cmd_install.rst | 104 ++++--- docs/userguide/platforms/cmd_list.rst | 5 +- docs/userguide/platforms/cmd_search.rst | 15 +- docs/userguide/platforms/cmd_show.rst | 5 +- docs/userguide/platforms/cmd_uninstall.rst | 4 +- docs/userguide/platforms/cmd_update.rst | 5 +- docs/userguide/platforms/index.rst | 4 +- platformio/__init__.py | 2 +- platformio/commands/lib.py | 333 ++++++++++----------- platformio/commands/run.py | 33 +- platformio/exception.py | 13 +- platformio/libmanager.py | 121 -------- platformio/maintenance.py | 35 ++- platformio/managers/lib.py | 209 +++++++++++++ platformio/managers/package.py | 16 +- platformio/managers/platform.py | 5 +- platformio/vcsclient.py | 26 +- tests/commands/test_boards.py | 4 +- tests/commands/test_init.py | 6 +- tests/commands/test_lib.py | 85 ++++-- tests/commands/test_platform.py | 2 +- tests/commands/test_settings.py | 2 +- tests/conftest.py | 27 +- 34 files changed, 1185 insertions(+), 700 deletions(-) delete mode 100644 platformio/libmanager.py create mode 100644 platformio/managers/lib.py diff --git a/HISTORY.rst b/HISTORY.rst index 763eb9d3..a85dcbac 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,41 +7,65 @@ PlatformIO 3.0 3.0.0 (2016-??-??) ~~~~~~~~~~~~~~~~~~ -* Decentralized architecture for development platforms: "platform.json", - semantic versioning, package dependencies, embedded board configs, isolated - build scripts - (`issue #479 `_) -* Unit Testing for Embedded (`docs `__) +* 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 `_) + +* `Unit Testing `__ for Embedded (`issue #408 `_) + +* Library Manager 3.0 + + + `Semantic Versioning `__ for library commands and + dependencies + (`issue #410 `_) + + Multiple library storages: project's local, PlatformIO 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 `_) + * New Intelligent Library Build System - + `Library Dependency Finder `__ - that interprets 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") + + `Library Dependency Finder `__ + that interprets 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") * Print human-readable information when processing environments without ``-v, --verbose`` option (`issue #721 `_) * Added ``license`` field to `library.json `__ (`issue #522 `_) -* Embedded Board compatibility with more than one development platform - (`issue #456 `_) + PlatformIO 2.0 -------------- diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst index c1a8d79b..e833687b 100644 --- a/docs/librarymanager/ldf.rst +++ b/docs/librarymanager/ldf.rst @@ -50,7 +50,7 @@ libraries. These folders/path have priority and LDF operates in the next order: 2. :ref:`projectconf_pio_lib_dir` - own/private library storage per project 3. :ref:`projectconf_pio_piolibdeps_dir` - project dependencies storage used by :ref:`librarymanager` -4. :ref:`projectconf_pio_home_dir`/lib - global storage per all projects. +4. ":ref:`projectconf_pio_home_dir`/lib" - global storage per all projects. .. _ldf_mode: diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 748d0478..d4866ec3 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -253,7 +253,7 @@ General options :ref:`platforms` name. -PlatformIO allows to use specific platform versions using +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: diff --git a/docs/userguide/lib/cmd_install.rst b/docs/userguide/lib/cmd_install.rst index 7b6e2986..ddfef32b 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 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 @@ -21,22 +21,67 @@ 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 @ + 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) Description ----------- -Install new library by specified -`PlatformIO Library Registry ID `_. +Install a library, and any libraries that it depends on using: -Installs the project library dependencies or a specific set of libraries. -[LIBRARY] can have multiple forms: , @, - or =@ +1. Library ``id`` or ``name`` from `PlatformIO Library Registry `_ +2. Custom folder, repository or archive. -Where, is a registry ID, registry name, repository URL, physical -location, is a valid semantic version/range, commit, branch, etc., and - is the name it should have locally. +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`` + +Also, 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 ------- @@ -44,50 +89,151 @@ Options .. program:: platformio lib install .. option:: - -v, --version + -q, --quiet -Install specified version of library +Suppress progress reporting + +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! diff --git a/docs/userguide/lib/cmd_list.rst b/docs/userguide/lib/cmd_list.rst index deb19b9c..fb2be037 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 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 @@ -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, espressif, 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..54ec524d 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 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 @@ -32,6 +32,6 @@ Register new library and allow others to install it. Examples -------- -.. code-block:: bash +.. code:: - $ platformio lib register http://my.example.com/library.json + platformio lib register http://my.example.com/raw-library.json diff --git a/docs/userguide/lib/cmd_search.rst b/docs/userguide/lib/cmd_search.rst index 4325fe7f..0502b340 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 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 @@ -74,6 +74,11 @@ Options .. program:: platformio lib search +.. option:: + -n, --name + +Filter libraries by specified name (strict search) + .. option:: -a, --author @@ -112,126 +117,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..9ee69da4 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 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 @@ -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, espressif, 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..5df77eca 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 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 @@ -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..4e47ac9f 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 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 @@ -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..f6aed45b 100644 --- a/docs/userguide/lib/index.rst +++ b/docs/userguide/lib/index.rst @@ -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 3ada1992..11563c3c 100644 --- a/docs/userguide/platforms/cmd_install.rst +++ b/docs/userguide/platforms/cmd_install.rst @@ -21,14 +21,18 @@ Usage .. code-block:: bash - # install platform by name platformio platform install [OPTIONS] [PLATFORM...] - # install specific platform version using Semantic Versioning - platformio platform install [OPTIONS] PLATFORM@X.Y.Z - - # install platform using URL - platformio platform install [OPTIONS] URL + # [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 @@ -36,33 +40,56 @@ Description 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: -* ``framework`` -* ``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`` -Local -~~~~~ - -PlatformIO supports installing development platform from local directory or -archive. Need to use ``file://`` prefix before local path. Also, platform -directory or archive should contain ``platform.json`` manifest. +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`` -Remote -~~~~~~ +Options +------- -VCS -~~~ +.. program:: platformio platform install + +.. option:: + --with-package + +Install specified package (or alias) + + +.. option:: + --without-package + +Do not install specified package (or alias) + +.. option:: + --skip-default + +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+". -PlatformIO requires a working VCS command on your path: git, hg or svn. +.. note:: + PlatformIO requires a working VCS command on your path: ``git``, ``hg`` + or ``svn``. Git ^^^ @@ -70,6 +97,7 @@ 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 @@ -112,35 +140,15 @@ You can also give specific revisions to an SVN URL, like so: * svn+svn://svn.server.org/my-platform#13 -Options -------- - -.. program:: platformio platform install - -.. option:: - --with-package - -Install specified package (or alias) - - -.. option:: - --without-package - -Do not install specified package (or alias) - -.. option:: - --skip-default - -Skip default packages - Examples -------- 1. Install :ref:`platform_atmelavr` with default packages -.. code-block:: bash +.. code:: + + > platformio platform install atmelavr - $ platformio platform install atmelavr PlatformManager: Installing atmelavr Downloading... Unpacking [####################################] 100% @@ -159,7 +167,9 @@ Examples 2. Install :ref:`platform_atmelavr` with ``uploader`` utility only and skip default packages -.. code-block:: bash +.. code:: + + > platformio platform install atmelavr --skip-default-package --with-package=uploader PlatformManager: Installing atmelavr Downloading [####################################] 100% @@ -178,9 +188,9 @@ Examples 3. Install the latest development :ref:`platform_atmelavr` from Git repository -.. code-block:: bash +.. code:: - $ platformio platform install https://github.com/platformio/platform-atmelavr.git + > platformio platform install https://github.com/platformio/platform-atmelavr.git PlatformManager: Installing platform-atmelavr git version 2.7.4 (Apple Git-66) diff --git a/docs/userguide/platforms/cmd_list.rst b/docs/userguide/platforms/cmd_list.rst index aca7aec1..c4e19756 100644 --- a/docs/userguide/platforms/cmd_list.rst +++ b/docs/userguide/platforms/cmd_list.rst @@ -42,9 +42,10 @@ Return the output in `JSON `_ format Examples -------- -.. code-block:: bash +.. code:: + + > platformio platform list - $ 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. diff --git a/docs/userguide/platforms/cmd_search.rst b/docs/userguide/platforms/cmd_search.rst index 96f1bf5e..e377b631 100644 --- a/docs/userguide/platforms/cmd_search.rst +++ b/docs/userguide/platforms/cmd_search.rst @@ -45,9 +45,10 @@ Examples 1. Print all available development platforms -.. code-block:: bash +.. code:: + + > platformio platform search - $ platformio platform search 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. @@ -75,9 +76,10 @@ Examples 2. Search for TI development platforms -.. code-block:: bash +.. code:: + + > platformio platform search texas - $ platformio platform search texas 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. @@ -92,9 +94,10 @@ Examples Home: http://platformio.org/platforms/titiva Packages: ldscripts, framework-libopencm3, toolchain-gccarmnoneeabi, tool-lm4flash, framework-energiativa -.. code-block:: bash +.. code:: + + > platformio platform search framework-mbed - $ platformio platform search framework-mbed 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. diff --git a/docs/userguide/platforms/cmd_show.rst b/docs/userguide/platforms/cmd_show.rst index 114b4bce..9d02d1f9 100644 --- a/docs/userguide/platforms/cmd_show.rst +++ b/docs/userguide/platforms/cmd_show.rst @@ -33,9 +33,10 @@ Show details about the installed :ref:`platforms` Examples -------- -.. code-block:: bash +.. code:: + + > platformio platform show atmelavr - $ 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. diff --git a/docs/userguide/platforms/cmd_uninstall.rst b/docs/userguide/platforms/cmd_uninstall.rst index 3292f147..5066a9c6 100644 --- a/docs/userguide/platforms/cmd_uninstall.rst +++ b/docs/userguide/platforms/cmd_uninstall.rst @@ -36,9 +36,9 @@ Uninstall specified :ref:`platforms` Examples -------- -.. code-block:: bash +.. code:: - $ platformio platform uninstall atmelavr + > 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] diff --git a/docs/userguide/platforms/cmd_update.rst b/docs/userguide/platforms/cmd_update.rst index c48f802b..b225fcb3 100644 --- a/docs/userguide/platforms/cmd_update.rst +++ b/docs/userguide/platforms/cmd_update.rst @@ -51,9 +51,10 @@ Do not update, only check for new version Examples -------- -.. code-block:: bash +.. code:: + + > platformio platform update - $ platformio platform update Platform atmelavr -------- Updating atmelavr @ 0.0.0: [Up-to-date] diff --git a/docs/userguide/platforms/index.rst b/docs/userguide/platforms/index.rst index 437826f1..cc113e86 100644 --- a/docs/userguide/platforms/index.rst +++ b/docs/userguide/platforms/index.rst @@ -18,8 +18,8 @@ To print all available commands and options use: .. code-block:: bash - $ platformio platform --help - $ platformio platform COMMAND --help + platformio platform --help + platformio platform COMMAND --help .. image:: ../../_static/platformio-demo-platforms.gif diff --git a/platformio/__init__.py b/platformio/__init__.py index 6ac5d903..9fd6f088 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev15") +VERSION = (3, 0, "0.dev16") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index bbf8bb09..2a708d81 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,51 +13,136 @@ # limitations under the License. import json +from os.path import join import click -from platformio import app, exception -from platformio.libmanager import LibraryManager +from platformio import app, 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 and options['global']: + storage_dir = join(util.get_home_dir(), "lib") + + if not storage_dir and not util.is_platformio_project(): + raise exception.PlatformioException( + "The `%s` is not a PlatformIO project.\nTo manage libraries " + "in the global storage `%s`, please use " + "`platformio lib --global %s` instead." % + (util.get_project_dir(), join(util.get_home_dir(), "lib"), + ctx.invoked_subcommand)) + + ctx.obj = LibraryManager(storage_dir) + 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( + "-q", "--quiet", is_flag=True, help="Suppress progress reporting") +@click.pass_obj +def lib_install(lm, libraries, save, quiet): # pylint: disable=unused-argument + # @TODO "save" option + for library in libraries: + lm.install(library, quiet=quiet) + + +@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'] - )) - - -@click.group(short_help="Library Manager") -def cli(): - pass + click.echo( + LIBLIST_TPL.format( + id=click.style( + str(item.get("id", "VCS")), 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"])), + description=item.get("description", item.get("url", ""))) + + (" | @" + click.style( + item['version'], fg="yellow") if "version" in item else "")) @cli.command("search", short_help="Search for library") @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) @@ -73,8 +158,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 +170,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/latest/userguide/lib/cmd_search.html\n", fg="cyan") + click.secho( + "http://docs.platformio.org" + "/en/latest/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() @@ -111,94 +202,17 @@ def lib_search(query, json_output, page, **filters): click.confirm("Show next libraries?")): result = get_api_result( "/lib/search", - dict(query=" ".join(query), page=int(result['page']) + 1) - ) + 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_) - 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") - - @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 +222,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) + installed_dir = lm.get_installed_dir(name, requirements, url) + if not installed_dir: + click.secho( + "%s @ %s is not installed" % (name, requirements or "*"), + fg="yellow") + return + + manifest = lm.load_manifest(installed_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 +261,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/run.py b/platformio/commands/run.py index 53fc96de..56dab189 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -21,11 +21,11 @@ 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.commands.platform import \ platform_install as cmd_platform_install -from platformio.libmanager import LibraryManager +from platformio.managers.lib import LibraryManager from platformio.managers.platform import PlatformFactory @@ -188,8 +188,8 @@ class EnvironmentProcessor(object): # install dependent libraries if "lib_install" in self.options: - _autoinstall_libs(self.cmd_ctx, self.options['lib_install']) - + _autoinstall_libs(self.cmd_ctx, self.options['lib_install'], + self.verbose) try: p = PlatformFactory.newPlatform(self.options['platform']) @@ -201,22 +201,15 @@ class EnvironmentProcessor(object): return p.run(build_vars, build_targets, 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_libs(ctx, libids_list, 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=[int(l.strip()) for l in libids_list.split(",")], + quiet=not verbose) def _clean_pioenvs_dir(pioenvs_dir): diff --git a/platformio/exception.py b/platformio/exception.py index 197ec0f9..c05d23d0 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -146,18 +146,9 @@ class APIRequestError(PlatformioException): MESSAGE = "[API] {0}" -class LibAlreadyInstalled(PlatformioException): - pass +class LibNotFound(PlatformioException): - -class LibNotInstalled(PlatformioException): - - MESSAGE = "Library #{0:d} has not been installed yet" - - -class LibInstallDependencyError(PlatformioException): - - MESSAGE = "Error has been occurred for library dependency '{0}'" + MESSAGE = "Library `{0}` has not been found in the registry" class InvalidLibConfURL(PlatformioException): diff --git a/platformio/libmanager.py b/platformio/libmanager.py deleted file mode 100644 index 8235d102..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 join(util.get_home_dir(), "lib") - - @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 ccea3cd1..2f7d66d1 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -22,12 +22,12 @@ 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.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_update as cmd_platform_update from platformio.commands.upgrade import get_latest_version -from platformio.libmanager import LibraryManager +from platformio.managers.lib import LibraryManager from platformio.managers.platform import PlatformManager @@ -221,16 +221,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": - pm = PlatformManager() - for manifest in pm.get_installed(): - if manifest['name'] not in outdated_items and \ - pm.is_outdated(manifest['name']): - outdated_items.append(manifest['name']) - 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 @@ -245,19 +241,26 @@ def check_internal_updates(ctx, what): 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 "platform"), + ("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_platform_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/managers/lib.py b/platformio/managers/lib.py new file mode 100644 index 00000000..7a1fd221 --- /dev/null +++ b/platformio/managers/lib.py @@ -0,0 +1,209 @@ +# Copyright 2014-present 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 os.path import join + +import click +import semantic_version + +from platformio import app, 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" + + @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, quiet=False): + if name.startswith("id="): + return int(name[3:]) + # try to find ID from installed packages + installed_dir = self.get_installed_dir(name, requirements) + if installed_dir: + manifest = self.load_manifest(installed_dir) + if "id" in manifest: + return int(manifest['id']) + return int(self.search_for_library({"name": name}, quiet)['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, name, requirements=None, quiet=False, + trigger_event=True): + _name, _requirements, _url = self.parse_pkg_name(name, requirements) + if not _url: + _name = "id=%d" % self._get_pkg_id_by_name( + _name, _requirements, quiet=quiet) + already_installed = self.get_installed_dir(_name, _requirements, _url) + pkg_dir = BasePkgManager.install(self, _name if not _url else name, + _requirements, quiet, trigger_event) + + if already_installed: + return + + manifest = self.load_manifest(pkg_dir) + if "dependencies" not in manifest: + return pkg_dir + + if not quiet: + click.secho("Installing dependencies", fg="yellow") + + _dependencies = manifest['dependencies'] + if not isinstance(_dependencies, list): + _dependencies = [_dependencies] + for filters in _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, quiet) + if filters.get("version"): + self.install( + lib_info['id'], + requirements=filters.get("version"), + quiet=quiet, + trigger_event=trigger_event) + else: + self.install( + lib_info['id'], + quiet=quiet, + trigger_event=trigger_event) + return pkg_dir + + @staticmethod + def search_for_library( # pylint: disable=too-many-branches + filters, quiet=False): + assert isinstance(filters, dict) + assert "name" in filters + if not quiet: + 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") + commands.lib.echo_liblist_header() + for item in result['items']: + commands.lib.echo_liblist_item(item) + + if not app.get_setting("enable_prompts"): + click.echo("Automatically chose the first available library") + 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: + raise exception.LibNotFound(str(filters)) + if not quiet: + 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 index 45e3e174..ac481866 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -312,7 +312,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): if "=" in text and not text.startswith("id="): name, url = text.split("=", 1) - # Handle GitHub URL (https://github.com/user/package.git) + # Handle GitHub URL (https://github.com/user/package) if url.startswith("https://github.com/") and \ not url.endswith((".zip", ".tar.gz")): url = "git+" + url @@ -394,6 +394,20 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): return best.get("__pkg_dir") return None + def is_outdated(self, name, requirements=None): + installed_dir = self.get_installed_dir(name, requirements) + if not installed_dir: + click.secho( + "%s @ %s is not installed" % (name, requirements or "*"), + fg="yellow") + return + manifest_path = self.get_manifest_path(installed_dir) + if manifest_path.endswith(self.VCS_MANIFEST_NAME): + return False + manifest = self.load_manifest(installed_dir) + return manifest['version'] != self.get_latest_repo_version( + name, requirements) + def install(self, name, requirements=None, quiet=False, trigger_event=True): name, requirements, url = self.parse_pkg_name(name, requirements) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 2a485f07..9855746c 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -71,9 +71,10 @@ class PlatformManager(BasePkgManager): 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() or - p.version != self.get_latest_repo_version(name, requirements)) + return p.are_outdated_packages() def cleanup_packages(self, names): self.reset_cache() diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index fffd6792..da0f9316 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.py @@ -43,10 +43,10 @@ class VCSClientBase(object): command = None - def __init__(self, src_dir, remote_url=None, branch=None): + def __init__(self, src_dir, remote_url=None, tag=None): self.src_dir = src_dir self.remote_url = remote_url - self.branch = branch + self.tag = tag self.check_client() def check_client(self): @@ -71,7 +71,7 @@ class VCSClientBase(object): @property def can_be_updated(self): - return not self.branch + return not self.tag def get_current_revision(self): raise NotImplementedError @@ -113,19 +113,19 @@ class GitClient(VCSClientBase): @property def can_be_updated(self): - return not self.branch or not self.is_commit_id(self.branch) + return not self.tag or not self.is_commit_id(self.tag) def export(self): - is_commit = self.is_commit_id(self.branch) + is_commit = self.is_commit_id(self.tag) args = ["clone", "--recursive"] - if not self.branch or not is_commit: + if not self.tag or not is_commit: args += ["--depth", "1"] - if self.branch: - args += ["--branch", self.branch] + 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.branch]) + return self.run_cmd(["reset", "--hard", self.tag]) return True def update(self): @@ -142,8 +142,8 @@ class HgClient(VCSClientBase): def export(self): args = ["clone"] - if self.branch: - args.extend(["--updaterev", self.branch]) + if self.tag: + args.extend(["--updaterev", self.tag]) args.extend([self.remote_url, self.src_dir]) return self.run_cmd(args) @@ -161,8 +161,8 @@ class SvnClient(VCSClientBase): def export(self): args = ["checkout"] - if self.branch: - args.extend(["--revision", self.branch]) + if self.tag: + args.extend(["--revision", self.tag]) args.extend([self.remote_url, self.src_dir]) return self.run_cmd(args) diff --git a/tests/commands/test_boards.py b/tests/commands/test_boards.py index 1a2539fd..be537c15 100644 --- a/tests/commands/test_boards.py +++ b/tests/commands/test_boards.py @@ -14,10 +14,8 @@ import json -from platformio import util from platformio.commands.boards import cli as cmd_boards -from platformio.commands.platform import \ - platform_search as cmd_platform_search +from platformio.commands.platform import platform_search as cmd_platform_search def test_board_json_output(platformio_setup, clirunner, validate_cliresult): diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index 45c23ed5..1605bba0 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -13,12 +13,12 @@ # limitations under the License. import json -from os import makedirs, getcwd +from os import getcwd, makedirs from os.path import getsize, isdir, isfile, join -from platformio.commands.init import cli -from platformio.commands.boards import cli as cmd_boards from platformio import util +from platformio.commands.boards import cli as cmd_boards +from platformio.commands.init import cli def validate_pioproject(pioproject_dir): diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index e749a68c..220ff632 100644 --- a/tests/commands/test_lib.py +++ b/tests/commands/test_lib.py @@ -12,25 +12,12 @@ # 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 re from platformio.commands.lib import cli -from platformio import util -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): +def test_search(clirunner, validate_cliresult): result = clirunner.invoke(cli, ["search", "DHT22"]) validate_cliresult(result) match = re.search(r"Found\s+(\d+)\slibraries:", result.output) @@ -42,34 +29,70 @@ def test_lib_search(clirunner, validate_cliresult): 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( + cli, ["-g", "install", "58", "OneWire", "Json@5.4.0", "Json@>5.4"]) validate_cliresult(result) - validate_libfolder() + items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()] + items2 = ["DHT22_ID58", "Json_ID64", "Json_ID64@5.4.0", "OneWire_ID1"] + assert set(items1) == set(items2) -def test_lib_list(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["list"]) +def test_global_install_repository(clirunner, validate_cliresult, + isolated_pio_home): + result = clirunner.invoke( + cli, ["-g", "install", "https://github.com/gioblu/PJON.git#3.0", + "https://developer.mbed.org/users/simon/code/TextLCD/", + "http://dl.platformio.org/libraries/archives/3/3756.tar.gz", + "knolleary/pubsubclient"]) 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 = ["PJON", "TextLCD", "ESPAsyncTCP", "PubSubClient"] + assert set(items2) & set(items1) -def test_lib_show(clirunner, validate_cliresult): - result = clirunner.invoke(cli, ["show", "115"]) +def test_global_lib_list(clirunner, validate_cliresult, isolated_pio_home): + result = clirunner.invoke(cli, ["-g", "list"]) validate_cliresult(result) - assert "arduino" in result.output and "atmelavr" in result.output + assert all([n in result.output for n in ("OneWire", "DHT22", "64")]) - result = clirunner.invoke(cli, ["show", "58"]) + result = clirunner.invoke(cli, ["-g", "list", "--json-output"]) validate_cliresult(result) - assert "energia" in result.output and "timsp430" in result.output + assert all( + [n in result.output + for n in ("PJON", + "https://developer.mbed.org/users/simon/code/TextLCD/")]) -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(cli, ["-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(cli, ["-g", "show", "Json@>5.4.0"]) validate_cliresult(result) + assert all([s in result.output for s in ("Json", "arduino", "atmelavr")]) + assert "5.4.0" not in result.output + + result = clirunner.invoke(cli, ["-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(cli, ["-g", "update"]) + validate_cliresult(result) + assert all([s in result.output for s in ("Up-to-date", "Checking")]) + + +def test_global_lib_uninstall(clirunner, validate_cliresult, + isolated_pio_home): + result = clirunner.invoke( + cli, ["-g", "uninstall", "1", "Json@!=5.4.0", "TextLCD"]) + validate_cliresult(result) + items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()] + items2 = ["DHT22_ID58", "Json_ID64@5.4.0", "ESPAsyncTCP_ID305", + "pubsubclient", "PJON"] + assert set(items1) == set(items2) diff --git a/tests/commands/test_platform.py b/tests/commands/test_platform.py index bd96230e..2379ec16 100644 --- a/tests/commands/test_platform.py +++ b/tests/commands/test_platform.py @@ -16,8 +16,8 @@ import json import os from os.path import join -from platformio.commands import platform as cli_platform from platformio import exception, util +from platformio.commands import platform as cli_platform def test_list_json_output(clirunner, validate_cliresult): diff --git a/tests/commands/test_settings.py b/tests/commands/test_settings.py index d74c3ad8..b1403e39 100644 --- a/tests/commands/test_settings.py +++ b/tests/commands/test_settings.py @@ -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/tests/conftest.py b/tests/conftest.py index f4cdc110..ca5b70f9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,4 @@ -# Copyright 2014-2016 Ivan Kravets +# Copyright 2014-present Ivan Kravets # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,29 +12,28 @@ # 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 +from click.testing import CliRunner @pytest.fixture(scope="session") def platformio_setup(request): pioenvvars = ("ENABLE_PROMPTS", "ENABLE_TELEMETRY") for v in pioenvvars: - environ["PLATFORMIO_SETTING_%s" % v] = "No" + os.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] + if _name in os.environ: + del os.environ[_name] request.addfinalizer(platformio_teardown) -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def clirunner(): return CliRunner() @@ -46,3 +45,15 @@ def validate_cliresult(): 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 From bd430e5afd69d197d8409f87e94aa2a4791b23e7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 2 Aug 2016 20:19:52 +0300 Subject: [PATCH 093/119] Makefile with useful targets --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..383bf6ee --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ + +lint: + pylint --rcfile=./.pylintrc ./platformio + +isort: + isort -rc ./platformio + +clean: + find . -name \*.pyc -delete \ No newline at end of file From 677cff1230a5f9f1d3a38225924b91e9b684709b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 2 Aug 2016 20:35:28 +0300 Subject: [PATCH 094/119] Stop Supporting Python 2.6 --- .travis.yml | 1 - HISTORY.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5b210f4d..b73e5dd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ python: env: - TOX_ENV=docs - TOX_ENV=lint - - TOX_ENV=py26 - TOX_ENV=py27 install: diff --git a/HISTORY.rst b/HISTORY.rst index a85dcbac..392c156e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -65,6 +65,7 @@ PlatformIO 3.0 (`issue #721 `_) * Added ``license`` field to `library.json `__ (`issue #522 `_) +* Stopped Supporting Python 2.6 PlatformIO 2.0 From 1cb8d61787684ac4b85d7a75158a1fd2610f42f1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 2 Aug 2016 20:40:54 +0300 Subject: [PATCH 095/119] Stop Supporting Python 2.6 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 9fd6f088..6bd42967 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -36,7 +36,7 @@ __apiurl__ = "http://api.platformio.org" __apiip__ = "198.7.57.247" -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])) From fbadf839976ea28341a4c75e867eff298ade6de7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 00:26:48 +0300 Subject: [PATCH 096/119] Use stable docs --- platformio/__init__.py | 2 +- platformio/commands/lib.py | 2 +- platformio/exception.py | 2 +- platformio/maintenance.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 6bd42967..46a60abe 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev16") +VERSION = (3, 0, "0.dev17") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 2a708d81..aacf0fc6 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -179,7 +179,7 @@ def lib_search(query, json_output, page, **filters): "please use documentation:") click.secho( "http://docs.platformio.org" - "/en/latest/userguide/lib/cmd_search.html\n", + "/en/stable/userguide/lib/cmd_search.html\n", fg="cyan") return diff --git a/platformio/exception.py b/platformio/exception.py index 049d178e..50da0265 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -181,7 +181,7 @@ class CIBuildEnvsEmpty(PlatformioException): class TestDirEmpty(PlatformioException): MESSAGE = "Test directory '{0}' is empty. More details about Unit "\ - "Testing:\n http://docs.platformio.org/en/latest/platforms/"\ + "Testing:\n http://docs.platformio.org/en/stable/platforms/"\ "unit_testing.html" diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 2f7d66d1..78407ab5 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -207,7 +207,7 @@ def check_platformio_upgrade(): 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/latest/history.html", fg="cyan") + click.secho("http://docs.platformio.org/en/stable/history.html", fg="cyan") click.echo("*" * terminal_width) click.echo("") From 98a6449b063ee61e1f54f3239d26f1cabf564711 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 01:04:40 +0300 Subject: [PATCH 097/119] Show hint about verbosity mode --- platformio/builder/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 714d7ca7..c27e30ed 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -96,6 +96,7 @@ DefaultEnvironment( env = DefaultEnvironment() if env.GetOption("silent"): + print "Use `-v, --verbose` option to enable verbose mode" Progress(env.ProgressHandler) # decode common variables From 82a7e67bece90942ca3c4d9bcb56286e3fcce858 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 17:06:30 +0300 Subject: [PATCH 098/119] Don't show verbose info for LDF when is a clean target --- platformio/builder/tools/piolib.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 6249107f..e108256f 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -21,6 +21,7 @@ import sys from os.path import basename, commonprefix, isdir, isfile, join, realpath import SCons.Scanner +from SCons.Script import COMMAND_LINE_TARGETS from platformio import util from platformio.builder.tools import platformio as piotool @@ -471,6 +472,7 @@ def GetLibBuilders(env): f.lower().strip() for f in env.get("PIOFRAMEWORK", "").split(",") ] compat_mode = int(env.get("LIB_COMPAT_MODE", 1)) + verbose = not (env.GetOption("silent") or env.GetOption('clean')) for libs_dir in env['LIBSOURCE_DIRS']: libs_dir = env.subst(libs_dir) @@ -481,18 +483,18 @@ def GetLibBuilders(env): continue lb = LibBuilderFactory.new(env, join(libs_dir, item)) if lb.name in env.get("LIB_IGNORE", []): - if not env.GetOption("silent"): + if verbose: sys.stderr.write("Ignored library %s\n" % lb.path) continue if compat_mode > 1 and not lb.is_platform_compatible(env[ 'PIOPLATFORM']): - if not env.GetOption("silent"): + if verbose: sys.stderr.write("Platform incompatible library %s\n" % lb.path) continue if compat_mode > 0 and not any([lb.is_framework_compatible(f) for f in env_frameworks]): - if not env.GetOption("silent"): + if verbose: sys.stderr.write("Framework incompatible library %s\n" % lb.path) continue From 11c8ab52f6eda89ea357c962e6ef25d1123df8f5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 17:43:54 +0300 Subject: [PATCH 099/119] Improve "update" command; add test --- docs/userguide/cmd_update.rst | 248 +++++++++++++++++++++-------- docs/userguide/cmd_upgrade.rst | 7 +- platformio/builder/tools/piolib.py | 1 - platformio/commands/update.py | 18 ++- tests/commands/test_update.py | 29 ++++ 5 files changed, 234 insertions(+), 69 deletions(-) create mode 100644 tests/commands/test_update.py diff --git a/docs/userguide/cmd_update.rst b/docs/userguide/cmd_update.rst index d429bb0d..d27c80dd 100644 --- a/docs/userguide/cmd_update.rst +++ b/docs/userguide/cmd_update.rst @@ -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 espressif -------- - 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 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-arduinoespressif @ 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..bc61fd0d 100644 --- a/docs/userguide/cmd_upgrade.rst +++ b/docs/userguide/cmd_upgrade.rst @@ -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/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index e108256f..e50436d3 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -21,7 +21,6 @@ import sys from os.path import basename, commonprefix, isdir, isfile, join, realpath import SCons.Scanner -from SCons.Script import COMMAND_LINE_TARGETS from platformio import util from platformio.builder.tools import platformio as piotool diff --git a/platformio/commands/update.py b/platformio/commands/update.py index 42830dc2..7fabeb21 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.py @@ -16,12 +16,24 @@ import click from platformio.commands.lib import lib_update as cmd_lib_update from platformio.commands.platform import platform_update as cmd_platform_update +from platformio.managers.lib import LibraryManager @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_platform_update) +def cli(ctx, only_check): + click.echo("Platform Manager") + click.echo("================") + ctx.invoke(cmd_platform_update, only_check=only_check) + 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/tests/commands/test_update.py b/tests/commands/test_update.py new file mode 100644 index 00000000..c78e55b6 --- /dev/null +++ b/tests/commands/test_update.py @@ -0,0 +1,29 @@ +# Copyright 2014-present 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.commands.update import cli as cmd_update + + +def test_update(platformio_setup, 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]) From 6b064cb915361c40deac6eef2e684e44c753848c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 19:58:35 +0300 Subject: [PATCH 100/119] Refactor DevPlatform to PioPlatform --- platformio/__init__.py | 2 +- platformio/builder/main.py | 4 ++-- platformio/builder/tools/piomisc.py | 2 +- .../tools/{devplatform.py => pioplatform.py} | 18 +++++++++--------- platformio/builder/tools/piotest.py | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) rename platformio/builder/tools/{devplatform.py => pioplatform.py} (90%) diff --git a/platformio/__init__.py b/platformio/__init__.py index 46a60abe..031e0d08 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev17") +VERSION = (3, 0, "0.dev18") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index c27e30ed..0e75f873 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -68,7 +68,7 @@ commonvars.AddVariables( DefaultEnvironment( tools=[ "ar", "as", "gcc", "g++", "gnulink", - "platformio", "devplatform", + "platformio", "pioplatform", "piolib", "piotest", "pioupload", "pioar", "piomisc" ], # yapf: disable toolpath=[join(util.get_source_dir(), "builder", "tools")], @@ -118,7 +118,7 @@ for opt in ("LIB_IGNORE", "LIB_FORCE", "LIB_EXTRA_DIRS"): env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) -env.LoadDevPlatform(commonvars) +env.LoadPioPlatform(commonvars) env.SConscriptChdir(0) env.SConsignFile(join("$PROJECTPIOENVS_DIR", ".sconsign.dblite")) diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index e2153798..07a8c55f 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -161,7 +161,7 @@ def DumpIDEData(env): includes.extend(lb.get_inc_dirs()) # includes from toolchains - p = env.DevPlatform() + p = env.PioPlatform() for name in p.get_installed_packages(): if p.get_package_type(name) != "toolchain": continue diff --git a/platformio/builder/tools/devplatform.py b/platformio/builder/tools/pioplatform.py similarity index 90% rename from platformio/builder/tools/devplatform.py rename to platformio/builder/tools/pioplatform.py index deaa017e..521ecdec 100644 --- a/platformio/builder/tools/devplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -23,23 +23,23 @@ from platformio.managers.platform import PlatformFactory @util.memoized -def initDevPlatform(name): +def initPioPlatform(name): return PlatformFactory.newPlatform(name) -def DevPlatform(env): +def PioPlatform(env): variables = {} for key in ("board", "pioframework"): if key not in env: continue variables[key] = env[key.upper()] - p = initDevPlatform(env['PLATFORM_MANIFEST']) + p = initPioPlatform(env['PLATFORM_MANIFEST']) p.configure_default_packages(variables, COMMAND_LINE_TARGETS) return p def BoardConfig(env, board=None): - p = initDevPlatform(env['PLATFORM_MANIFEST']) + p = initPioPlatform(env['PLATFORM_MANIFEST']) try: config = p.board_config(board if board else env['BOARD']) except exception.UnknownBoard as e: @@ -48,7 +48,7 @@ def BoardConfig(env, board=None): def GetFrameworkScript(env, framework): - p = env.DevPlatform() + p = env.PioPlatform() assert p.frameworks and framework in p.frameworks script_path = env.subst(p.frameworks[framework]['script']) if not isfile(script_path): @@ -56,8 +56,8 @@ def GetFrameworkScript(env, framework): return script_path -def LoadDevPlatform(env, variables): - p = env.DevPlatform() +def LoadPioPlatform(env, variables): + p = env.PioPlatform() installed_packages = p.get_installed_packages() # Add toolchains and uploaders to $PATH @@ -99,8 +99,8 @@ def exists(_): def generate(env): - env.AddMethod(DevPlatform) + env.AddMethod(PioPlatform) env.AddMethod(BoardConfig) env.AddMethod(GetFrameworkScript) - env.AddMethod(LoadDevPlatform) + env.AddMethod(LoadPioPlatform) return env diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index af820dc4..d4fce7c7 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -62,7 +62,7 @@ def ProcessTest(env): ) unitylib = env.BuildLibrary( join("$BUILD_DIR", "UnityTestLib"), - env.DevPlatform().get_package_dir("tool-unity") + env.PioPlatform().get_package_dir("tool-unity") ) env.Prepend(LIBS=[unitylib]) From 823e8374b1bc0406ccab7dd641970ed27cf48120 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 20:21:23 +0300 Subject: [PATCH 101/119] Don't show tools in processing output --- platformio/builder/tools/piomisc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 07a8c55f..87f0a9e7 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -265,7 +265,8 @@ def GetActualLDScript(env): def ProgressHandler(env, node): item = str(node) - if "toolchain-" in item or item.endswith((".o", ".h", ".hpp", ".ipp")): + if ("toolchain-" in item or "tool-" in item) or \ + item.endswith((".o", ".h", ".hpp", ".ipp")): return item = item.replace(env['PIOHOME_DIR'], ".platformio") print "Processing %s" % item From 306b77a3f405e7a13d95f9756bc35d9b0186e0cd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 22:01:11 +0300 Subject: [PATCH 102/119] Extend a clean target --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 383bf6ee..d9f0aeb3 100644 --- a/Makefile +++ b/Makefile @@ -5,5 +5,13 @@ lint: isort: isort -rc ./platformio -clean: - find . -name \*.pyc -delete \ No newline at end of file +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 From 0c9d539a920b2b20c0378fb1cb0f3568117c6ddf Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 22:18:51 +0300 Subject: [PATCH 103/119] Update copyrights --- .coveragerc | 2 +- README.rst | 2 +- docs/_static/extra.css | 2 +- docs/articles.rst | 2 +- docs/ci/appveyor.rst | 2 +- docs/ci/circleci.rst | 2 +- docs/ci/drone.rst | 2 +- docs/ci/index.rst | 2 +- docs/ci/shippable.rst | 2 +- docs/ci/travis.rst | 2 +- docs/demo.rst | 2 +- docs/envvars.rst | 2 +- docs/faq.rst | 2 +- docs/frameworks/arduino.rst | 2 +- docs/frameworks/cmsis.rst | 2 +- docs/frameworks/cmsis_extra.rst | 2 +- docs/frameworks/energia.rst | 2 +- docs/frameworks/index.rst | 2 +- docs/frameworks/libopencm3.rst | 2 +- docs/frameworks/libopencm3_extra.rst | 2 +- docs/frameworks/mbed.rst | 2 +- docs/frameworks/mbed_extra.rst | 2 +- docs/frameworks/simba.rst | 2 +- docs/frameworks/simba_extra.rst | 2 +- docs/frameworks/spl.rst | 2 +- docs/frameworks/spl_extra.rst | 2 +- docs/frameworks/wiringpi.rst | 2 +- docs/frameworks/wiringpi_extra.rst | 2 +- docs/history.rst | 2 +- docs/ide.rst | 2 +- docs/ide/_platformio_ide_extra.rst | 2 +- docs/ide/atom.rst | 2 +- docs/ide/clion.rst | 2 +- docs/ide/codeblocks.rst | 2 +- docs/ide/eclipse.rst | 2 +- docs/ide/emacs.rst | 2 +- docs/ide/netbeans.rst | 2 +- docs/ide/qtcreator.rst | 2 +- docs/ide/sublimetext.rst | 2 +- docs/ide/vim.rst | 2 +- docs/ide/visualstudio.rst | 2 +- docs/index.rst | 2 +- docs/installation.rst | 2 +- docs/librarymanager/config.rst | 2 +- docs/librarymanager/creating.rst | 2 +- docs/librarymanager/index.rst | 2 +- docs/librarymanager/ldf.rst | 2 +- docs/platforms/atmelavr.rst | 2 +- docs/platforms/atmelavr_extra.rst | 2 +- docs/platforms/atmelsam.rst | 2 +- docs/platforms/creating_board.rst | 2 +- docs/platforms/creating_platform.rst | 2 +- docs/platforms/custom_platform_and_board.rst | 2 +- docs/platforms/embedded_boards.rst | 2 +- docs/platforms/espressif.rst | 2 +- docs/platforms/espressif_extra.rst | 2 +- docs/platforms/freescalekinetis.rst | 2 +- docs/platforms/index.rst | 2 +- docs/platforms/intel_arc32.rst | 2 +- docs/platforms/lattice_ice40.rst | 2 +- docs/platforms/linux_arm.rst | 2 +- docs/platforms/linux_i686.rst | 2 +- docs/platforms/linux_x86_64.rst | 2 +- docs/platforms/microchippic32.rst | 2 +- docs/platforms/native.rst | 2 +- docs/platforms/nordicnrf51.rst | 2 +- docs/platforms/nordicnrf51_extra.rst | 2 +- docs/platforms/nxplpc.rst | 2 +- docs/platforms/siliconlabsefm32.rst | 2 +- docs/platforms/ststm32.rst | 2 +- docs/platforms/ststm32_extra.rst | 2 +- docs/platforms/teensy.rst | 2 +- docs/platforms/teensy_extra.rst | 2 +- docs/platforms/timsp430.rst | 2 +- docs/platforms/timsp430_extra.rst | 2 +- docs/platforms/titiva.rst | 2 +- docs/platforms/titiva_extra.rst | 2 +- docs/platforms/unit_testing.rst | 2 +- docs/platforms/windows_x86.rst | 2 +- docs/projectconf.rst | 2 +- docs/quickstart.rst | 2 +- docs/userguide/cmd_boards.rst | 2 +- docs/userguide/cmd_ci.rst | 2 +- docs/userguide/cmd_init.rst | 2 +- docs/userguide/cmd_run.rst | 2 +- docs/userguide/cmd_serialports.rst | 2 +- docs/userguide/cmd_settings.rst | 2 +- docs/userguide/cmd_test.rst | 2 +- docs/userguide/cmd_update.rst | 2 +- docs/userguide/cmd_upgrade.rst | 2 +- docs/userguide/index.rst | 2 +- docs/userguide/lib/cmd_install.rst | 2 +- docs/userguide/lib/cmd_list.rst | 2 +- docs/userguide/lib/cmd_register.rst | 2 +- docs/userguide/lib/cmd_search.rst | 2 +- docs/userguide/lib/cmd_show.rst | 2 +- docs/userguide/lib/cmd_uninstall.rst | 2 +- docs/userguide/lib/cmd_update.rst | 2 +- docs/userguide/lib/index.rst | 2 +- docs/userguide/platforms/cmd_install.rst | 2 +- docs/userguide/platforms/cmd_list.rst | 2 +- docs/userguide/platforms/cmd_search.rst | 2 +- docs/userguide/platforms/cmd_show.rst | 2 +- docs/userguide/platforms/cmd_uninstall.rst | 2 +- docs/userguide/platforms/cmd_update.rst | 2 +- docs/userguide/platforms/index.rst | 2 +- docs/what-is-platformio.rst | 2 +- examples | 2 +- platformio/__init__.py | 2 +- platformio/__main__.py | 2 +- platformio/app.py | 2 +- platformio/builder/__init__.py | 2 +- platformio/builder/main.py | 2 +- platformio/builder/tools/__init__.py | 2 +- platformio/builder/tools/pioar.py | 2 +- platformio/builder/tools/piolib.py | 2 +- platformio/builder/tools/piomisc.py | 2 +- platformio/builder/tools/pioplatform.py | 2 +- platformio/builder/tools/piotest.py | 2 +- platformio/builder/tools/pioupload.py | 2 +- platformio/builder/tools/platformio.py | 2 +- platformio/commands/__init__.py | 2 +- platformio/commands/boards.py | 2 +- platformio/commands/ci.py | 2 +- platformio/commands/init.py | 2 +- platformio/commands/lib.py | 2 +- platformio/commands/platform.py | 2 +- platformio/commands/run.py | 2 +- platformio/commands/serialports.py | 2 +- platformio/commands/settings.py | 2 +- platformio/commands/test.py | 2 +- platformio/commands/update.py | 2 +- platformio/commands/upgrade.py | 2 +- platformio/downloader.py | 2 +- platformio/exception.py | 2 +- platformio/ide/__init__.py | 2 +- platformio/ide/projectgenerator.py | 2 +- platformio/maintenance.py | 2 +- platformio/managers/__init__.py | 2 +- platformio/managers/lib.py | 2 +- platformio/managers/package.py | 2 +- platformio/managers/platform.py | 2 +- platformio/telemetry.py | 2 +- platformio/unpacker.py | 2 +- platformio/util.py | 2 +- platformio/vcsclient.py | 2 +- scripts/99-platformio-udev.rules | 2 +- scripts/docspregen.py | 8 ++++---- scripts/fixsymlink.py | 2 +- scripts/get-platformio.py | 2 +- scripts/mbed_to_package.py | 2 +- setup.py | 2 +- tests/commands/test_boards.py | 2 +- tests/commands/test_init.py | 2 +- tests/commands/test_lib.py | 2 +- tests/commands/test_platform.py | 2 +- tests/commands/test_settings.py | 2 +- tests/commands/test_update.py | 2 +- tests/conftest.py | 2 +- tests/test_examples.py | 2 +- tests/test_managers.py | 2 +- tests/test_pkgmanifest.py | 2 +- tox.ini | 2 +- 163 files changed, 166 insertions(+), 166 deletions(-) diff --git a/.coveragerc b/.coveragerc index cfb6fb9d..32d9f345 100644 --- a/.coveragerc +++ b/.coveragerc @@ -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. diff --git a/README.rst b/README.rst index d8270b88..b0d469df 100644 --- a/README.rst +++ b/README.rst @@ -192,7 +192,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/docs/_static/extra.css b/docs/_static/extra.css index 1d7f3b0b..6c61b363 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. diff --git a/docs/articles.rst b/docs/articles.rst index 3ceb7fce..7acd3e5a 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 diff --git a/docs/ci/appveyor.rst b/docs/ci/appveyor.rst index 2fc919dd..af246a86 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 diff --git a/docs/ci/circleci.rst b/docs/ci/circleci.rst index f8d4e333..c159a4ef 100644 --- a/docs/ci/circleci.rst +++ b/docs/ci/circleci.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/ci/drone.rst b/docs/ci/drone.rst index 37d0ac0b..8156a449 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 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..aafc2d07 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 diff --git a/docs/ci/travis.rst b/docs/ci/travis.rst index cb27dd33..53ff0f06 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 diff --git a/docs/demo.rst b/docs/demo.rst index ed55b719..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 diff --git a/docs/envvars.rst b/docs/envvars.rst index fdbbada7..771f043e 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 diff --git a/docs/faq.rst b/docs/faq.rst index 75ed3cfb..dd30f4bd 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 diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index b16c12d6..ff28614b 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 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..05009466 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 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..93512001 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 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..fdfe142b 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 diff --git a/docs/ide/clion.rst b/docs/ide/clion.rst index 387dad92..01600f2e 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 diff --git a/docs/ide/codeblocks.rst b/docs/ide/codeblocks.rst index 04819998..dd1857dd 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 diff --git a/docs/ide/eclipse.rst b/docs/ide/eclipse.rst index 6f889b6b..558117c8 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 diff --git a/docs/ide/emacs.rst b/docs/ide/emacs.rst index ef402dfb..769a64ce 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 diff --git a/docs/ide/netbeans.rst b/docs/ide/netbeans.rst index 432ddb26..d4a95e98 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 diff --git a/docs/ide/qtcreator.rst b/docs/ide/qtcreator.rst index a84c8875..714d10c7 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 diff --git a/docs/ide/sublimetext.rst b/docs/ide/sublimetext.rst index feaa5f3a..7e58b2fc 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 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..46323421 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 diff --git a/docs/index.rst b/docs/index.rst index 3b95e020..13be0abd 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 diff --git a/docs/installation.rst b/docs/installation.rst index a74cca4e..53dd81ca 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 diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index 1c0e5354..7f619bcb 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 diff --git a/docs/librarymanager/creating.rst b/docs/librarymanager/creating.rst index 2fe3dbbd..5d150f16 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 diff --git a/docs/librarymanager/index.rst b/docs/librarymanager/index.rst index 8a935663..5e2327d4 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 diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst index e833687b..8744cafb 100644 --- a/docs/librarymanager/ldf.rst +++ b/docs/librarymanager/ldf.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/atmelavr.rst b/docs/platforms/atmelavr.rst index 52bcb584..0c5faa9a 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 diff --git a/docs/platforms/atmelavr_extra.rst b/docs/platforms/atmelavr_extra.rst index 754de6e0..7d97a4d8 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 diff --git a/docs/platforms/atmelsam.rst b/docs/platforms/atmelsam.rst index 12cbc41a..8bc92bbc 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 diff --git a/docs/platforms/creating_board.rst b/docs/platforms/creating_board.rst index df3ab04a..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 diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index 8233fe06..90f14517 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 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..9bf44d69 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 diff --git a/docs/platforms/espressif.rst b/docs/platforms/espressif.rst index 56ffbc43..fca7b8ab 100644 --- a/docs/platforms/espressif.rst +++ b/docs/platforms/espressif.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/espressif_extra.rst b/docs/platforms/espressif_extra.rst index 65d7356a..b6315b4e 100644 --- a/docs/platforms/espressif_extra.rst +++ b/docs/platforms/espressif_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/freescalekinetis.rst b/docs/platforms/freescalekinetis.rst index 13e60daf..aba52b24 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 diff --git a/docs/platforms/index.rst b/docs/platforms/index.rst index f7f68146..cdfa1003 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 diff --git a/docs/platforms/intel_arc32.rst b/docs/platforms/intel_arc32.rst index c4863e5c..3127fd76 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 diff --git a/docs/platforms/lattice_ice40.rst b/docs/platforms/lattice_ice40.rst index 4a836ed3..fd54c760 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 diff --git a/docs/platforms/linux_arm.rst b/docs/platforms/linux_arm.rst index 56783765..0b69a2d3 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 diff --git a/docs/platforms/linux_i686.rst b/docs/platforms/linux_i686.rst index 583ad151..fb1f3dd7 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 diff --git a/docs/platforms/linux_x86_64.rst b/docs/platforms/linux_x86_64.rst index d770b2e8..445eb691 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 diff --git a/docs/platforms/microchippic32.rst b/docs/platforms/microchippic32.rst index 51c92e8e..dc5db46a 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 diff --git a/docs/platforms/native.rst b/docs/platforms/native.rst index 68fd805b..a4174222 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 diff --git a/docs/platforms/nordicnrf51.rst b/docs/platforms/nordicnrf51.rst index fff500b3..75fd69d8 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 diff --git a/docs/platforms/nordicnrf51_extra.rst b/docs/platforms/nordicnrf51_extra.rst index beab99ce..b77d8629 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 diff --git a/docs/platforms/nxplpc.rst b/docs/platforms/nxplpc.rst index 2c94410f..c733fa3e 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 diff --git a/docs/platforms/siliconlabsefm32.rst b/docs/platforms/siliconlabsefm32.rst index c4829f08..c1ccc8a5 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 diff --git a/docs/platforms/ststm32.rst b/docs/platforms/ststm32.rst index fb1acfa4..6edea8b9 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 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..80e92de9 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 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..b807d4b1 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 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..88b960b1 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 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/unit_testing.rst b/docs/platforms/unit_testing.rst index 809eb76c..316c17ba 100644 --- a/docs/platforms/unit_testing.rst +++ b/docs/platforms/unit_testing.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/windows_x86.rst b/docs/platforms/windows_x86.rst index 6f904a0b..690c955b 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 diff --git a/docs/projectconf.rst b/docs/projectconf.rst index d4866ec3..439ced3d 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 diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 10ebd14e..f6d8600b 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 diff --git a/docs/userguide/cmd_boards.rst b/docs/userguide/cmd_boards.rst index 8083e8bb..a4b0eae9 100644 --- a/docs/userguide/cmd_boards.rst +++ b/docs/userguide/cmd_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 diff --git a/docs/userguide/cmd_ci.rst b/docs/userguide/cmd_ci.rst index 785f2e0d..283744c6 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 diff --git a/docs/userguide/cmd_init.rst b/docs/userguide/cmd_init.rst index 716ed155..6605d9a0 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 diff --git a/docs/userguide/cmd_run.rst b/docs/userguide/cmd_run.rst index 6d2696de..c5b75ea3 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 diff --git a/docs/userguide/cmd_serialports.rst b/docs/userguide/cmd_serialports.rst index 963046b1..882a5f02 100644 --- a/docs/userguide/cmd_serialports.rst +++ b/docs/userguide/cmd_serialports.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/userguide/cmd_settings.rst b/docs/userguide/cmd_settings.rst index 24d592d3..04be4260 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 diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst index 0749f6ec..c42bda6c 100644 --- a/docs/userguide/cmd_test.rst +++ b/docs/userguide/cmd_test.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/userguide/cmd_update.rst b/docs/userguide/cmd_update.rst index d27c80dd..137b8172 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 diff --git a/docs/userguide/cmd_upgrade.rst b/docs/userguide/cmd_upgrade.rst index bc61fd0d..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 diff --git a/docs/userguide/index.rst b/docs/userguide/index.rst index 856ebda2..05ada62a 100644 --- a/docs/userguide/index.rst +++ b/docs/userguide/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 diff --git a/docs/userguide/lib/cmd_install.rst b/docs/userguide/lib/cmd_install.rst index ddfef32b..c43122c0 100644 --- a/docs/userguide/lib/cmd_install.rst +++ b/docs/userguide/lib/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 diff --git a/docs/userguide/lib/cmd_list.rst b/docs/userguide/lib/cmd_list.rst index fb2be037..db521e2b 100644 --- a/docs/userguide/lib/cmd_list.rst +++ b/docs/userguide/lib/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 diff --git a/docs/userguide/lib/cmd_register.rst b/docs/userguide/lib/cmd_register.rst index 54ec524d..08911f64 100644 --- a/docs/userguide/lib/cmd_register.rst +++ b/docs/userguide/lib/cmd_register.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/userguide/lib/cmd_search.rst b/docs/userguide/lib/cmd_search.rst index 0502b340..4bc5d0ea 100644 --- a/docs/userguide/lib/cmd_search.rst +++ b/docs/userguide/lib/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 diff --git a/docs/userguide/lib/cmd_show.rst b/docs/userguide/lib/cmd_show.rst index 9ee69da4..b1f09e95 100644 --- a/docs/userguide/lib/cmd_show.rst +++ b/docs/userguide/lib/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 diff --git a/docs/userguide/lib/cmd_uninstall.rst b/docs/userguide/lib/cmd_uninstall.rst index 5df77eca..a465ad17 100644 --- a/docs/userguide/lib/cmd_uninstall.rst +++ b/docs/userguide/lib/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 diff --git a/docs/userguide/lib/cmd_update.rst b/docs/userguide/lib/cmd_update.rst index 4e47ac9f..aea28cf0 100644 --- a/docs/userguide/lib/cmd_update.rst +++ b/docs/userguide/lib/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 diff --git a/docs/userguide/lib/index.rst b/docs/userguide/lib/index.rst index f6aed45b..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 diff --git a/docs/userguide/platforms/cmd_install.rst b/docs/userguide/platforms/cmd_install.rst index 11563c3c..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 diff --git a/docs/userguide/platforms/cmd_list.rst b/docs/userguide/platforms/cmd_list.rst index c4e19756..9aacba4c 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 diff --git a/docs/userguide/platforms/cmd_search.rst b/docs/userguide/platforms/cmd_search.rst index e377b631..00a3f63a 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 diff --git a/docs/userguide/platforms/cmd_show.rst b/docs/userguide/platforms/cmd_show.rst index 9d02d1f9..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 diff --git a/docs/userguide/platforms/cmd_uninstall.rst b/docs/userguide/platforms/cmd_uninstall.rst index 5066a9c6..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 diff --git a/docs/userguide/platforms/cmd_update.rst b/docs/userguide/platforms/cmd_update.rst index b225fcb3..581c2c35 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 diff --git a/docs/userguide/platforms/index.rst b/docs/userguide/platforms/index.rst index cc113e86..b9402f61 100644 --- a/docs/userguide/platforms/index.rst +++ b/docs/userguide/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 diff --git a/docs/what-is-platformio.rst b/docs/what-is-platformio.rst index f7849078..13fd7a2b 100644 --- a/docs/what-is-platformio.rst +++ b/docs/what-is-platformio.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/examples b/examples index 3b8f997b..dc677cf2 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 3b8f997b6e69879f1b935087e988290046a3fc84 +Subproject commit dc677cf233990929fea1cf36338094837cc5d518 diff --git a/platformio/__init__.py b/platformio/__init__.py index 031e0d08..c972b724 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.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. diff --git a/platformio/__main__.py b/platformio/__main__.py index e60429be..f1d22bd9 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.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. diff --git a/platformio/app.py b/platformio/app.py index 7b7d1635..268462d0 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. 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 0e75f873..05823c66 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.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. 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 index 6d8a2be0..95d5816b 100644 --- a/platformio/builder/tools/pioar.py +++ b/platformio/builder/tools/pioar.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/piolib.py b/platformio/builder/tools/piolib.py index e50436d3..35fba8cd 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.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. diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 87f0a9e7..d2364b79 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.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. diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 521ecdec..807f525d 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.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. diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index d4fce7c7..a93f1d78 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.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/pioupload.py b/platformio/builder/tools/pioupload.py index aac85f57..c098f40e 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.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. diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index e4875e15..ff048daf 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.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. diff --git a/platformio/commands/__init__.py b/platformio/commands/__init__.py index 5466a0e8..95899c71 100644 --- a/platformio/commands/__init__.py +++ b/platformio/commands/__init__.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. diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 07b800a0..c116a8ba 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.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. diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index b7b1fe32..e9a92984 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.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. diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 00c0bf03..6497f765 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.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. diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index aacf0fc6..67c8ff59 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.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. diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 9a6d7704..fd72f402 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.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. diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 56dab189..c662e012 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.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. diff --git a/platformio/commands/serialports.py b/platformio/commands/serialports.py index 19b69ddb..4371b15c 100644 --- a/platformio/commands/serialports.py +++ b/platformio/commands/serialports.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/settings.py b/platformio/commands/settings.py index 43be3c8d..34e460d3 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. diff --git a/platformio/commands/test.py b/platformio/commands/test.py index 31811afd..3b16d7a6 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.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. diff --git a/platformio/commands/update.py b/platformio/commands/update.py index 7fabeb21..d97ae99d 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.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. diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 3440fe89..ddac25c1 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.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. diff --git a/platformio/downloader.py b/platformio/downloader.py index 891e7bf5..bce15dea 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. diff --git a/platformio/exception.py b/platformio/exception.py index 50da0265..7064b34e 100644 --- a/platformio/exception.py +++ b/platformio/exception.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. 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 f59ed98b..093508f7 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. diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 78407ab5..3fc980ac 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.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. diff --git a/platformio/managers/__init__.py b/platformio/managers/__init__.py index 5466a0e8..95899c71 100644 --- a/platformio/managers/__init__.py +++ b/platformio/managers/__init__.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. diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index 7a1fd221..a34a196b 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.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. diff --git a/platformio/managers/package.py b/platformio/managers/package.py index ac481866..0b57520d 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.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. diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 9855746c..fbfc0af3 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.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. diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 48ca79ab..f7c06102 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. diff --git a/platformio/unpacker.py b/platformio/unpacker.py index ab8955cd..1011fe4c 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. diff --git a/platformio/util.py b/platformio/util.py index 879adb12..8a389717 100644 --- a/platformio/util.py +++ b/platformio/util.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. diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index da0f9316..0d3af892 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.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. 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..8b42e242 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. @@ -134,7 +134,7 @@ 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 @@ -241,7 +241,7 @@ 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 @@ -367,7 +367,7 @@ Packages 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 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 index fcf5581c..6effd7ea 100644 --- a/scripts/mbed_to_package.py +++ b/scripts/mbed_to_package.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/setup.py b/setup.py index c1511504..4c309883 100644 --- a/setup.py +++ b/setup.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. diff --git a/tests/commands/test_boards.py b/tests/commands/test_boards.py index be537c15..71f4ebd8 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. diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index 1605bba0..9c8c1189 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. diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index 220ff632..ed4fc603 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. diff --git a/tests/commands/test_platform.py b/tests/commands/test_platform.py index 2379ec16..ec618a90 100644 --- a/tests/commands/test_platform.py +++ b/tests/commands/test_platform.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/tests/commands/test_settings.py b/tests/commands/test_settings.py index b1403e39..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. diff --git a/tests/commands/test_update.py b/tests/commands/test_update.py index c78e55b6..27eb8c9d 100644 --- a/tests/commands/test_update.py +++ b/tests/commands/test_update.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. diff --git a/tests/conftest.py b/tests/conftest.py index ca5b70f9..8483d8b9 100644 --- a/tests/conftest.py +++ b/tests/conftest.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. diff --git a/tests/test_examples.py b/tests/test_examples.py index f953feab..959d974b 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. diff --git a/tests/test_managers.py b/tests/test_managers.py index abed10a1..f41c31a1 100644 --- a/tests/test_managers.py +++ b/tests/test_managers.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. diff --git a/tests/test_pkgmanifest.py b/tests/test_pkgmanifest.py index 62b1b9d6..476666a0 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. diff --git a/tox.ini b/tox.ini index 71717e00..da496e8f 100644 --- a/tox.ini +++ b/tox.ini @@ -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. From 87d0ead203d694780c568713d8a5dfd1ca9b6c69 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 23:38:20 +0300 Subject: [PATCH 104/119] Format code with pep8 style --- .style.yapf | 2 + Makefile | 7 + platformio/__init__.py | 11 +- platformio/__main__.py | 16 +- platformio/app.py | 29 ++-- platformio/builder/tools/pioar.py | 4 +- platformio/builder/tools/piomisc.py | 33 ++-- platformio/builder/tools/pioplatform.py | 4 +- platformio/builder/tools/piotest.py | 24 +-- platformio/builder/tools/pioupload.py | 3 +- platformio/builder/tools/platformio.py | 46 +++--- platformio/commands/boards.py | 30 ++-- platformio/commands/ci.py | 48 +++--- platformio/commands/init.py | 82 +++++----- platformio/commands/run.py | 80 +++++----- platformio/commands/serialports.py | 190 ++++++++++++++++-------- platformio/commands/settings.py | 25 ++-- platformio/commands/test.py | 59 ++++---- platformio/commands/update.py | 4 +- platformio/commands/upgrade.py | 60 ++++---- platformio/downloader.py | 3 +- platformio/ide/projectgenerator.py | 26 ++-- platformio/maintenance.py | 102 +++++++------ platformio/telemetry.py | 15 +- platformio/unpacker.py | 7 +- platformio/util.py | 45 +++--- setup.py | 5 - 27 files changed, 514 insertions(+), 446 deletions(-) create mode 100644 .style.yapf diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 00000000..0a658196 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,2 @@ +[style] +blank_line_before_nested_class_or_def = true \ No newline at end of file diff --git a/Makefile b/Makefile index d9f0aeb3..2117e072 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,13 @@ lint: isort: isort -rc ./platformio + isort -rc ./tests + isort -rc ./scripts + +yapf: + yapf --recursive --in-place platformio/ + +before-commit: isort yapf pylint clean-docs: rm -rf docs/_build diff --git a/platformio/__init__.py b/platformio/__init__.py index c972b724..469a4e79 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -18,12 +18,10 @@ VERSION = (3, 0, "0.dev18") __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 and MBED compatible. Ready for Cloud compiling.") __url__ = "http://platformio.org" __author__ = "Ivan Kravets" @@ -35,7 +33,6 @@ __copyright__ = "Copyright 2014-2016 Ivan Kravets" __apiurl__ = "http://api.platformio.org" __apiip__ = "198.7.57.247" - 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") diff --git a/platformio/__main__.py b/platformio/__main__.py index f1d22bd9..08679523 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -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) @@ -57,11 +57,15 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904 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): diff --git a/platformio/app.py b/platformio/app.py index 268462d0..3bacc180 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -49,28 +49,23 @@ DEFAULT_SETTINGS = { "value": False }, "enable_telemetry": { - "description": ( - "Telemetry service (Yes/No)"), + "description": + ("Telemetry service (Yes/No)"), "value": True }, "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)"), + "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)"), "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): @@ -108,8 +103,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() diff --git a/platformio/builder/tools/pioar.py b/platformio/builder/tools/pioar.py index 95d5816b..d530892a 100644 --- a/platformio/builder/tools/pioar.py +++ b/platformio/builder/tools/pioar.py @@ -43,7 +43,7 @@ def generate(env): env.Replace( _huge_sources_hook=_huge_sources_hook, - ARCOM=env.get("ARCOM", "").replace( - "$SOURCES", "${_huge_sources_hook(SOURCES)}")) + ARCOM=env.get("ARCOM", "").replace("$SOURCES", + "${_huge_sources_hook(SOURCES)}")) return env diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index d2364b79..b4f4735e 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -25,15 +25,12 @@ from platformio import util class InoToCPPConverter(object): - PROTOTYPE_RE = re.compile( - r"""^( + PROTOTYPE_RE = re.compile(r"""^( (\s*[a-z_\d]+\*?){1,2} # return type (\s+[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)[^\)]*\)" @@ -66,20 +63,18 @@ class InoToCPPConverter(object): split_pos = item['match'].start() break - match_ptrs = re.search( - self.PROTOPTRS_TPLRE % ("|".join(prototype_names)), - contents[:split_pos], - re.M - ) + 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.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('#line %d "%s"' % + (contents.count("\n", 0, split_pos) + 2, + file_path.replace("\\", "/"))) result.append(contents[split_pos:].strip()) return result @@ -106,8 +101,8 @@ class InoToCPPConverter(object): result.append('#line 1 "%s"' % file_path.replace("\\", "/")) if is_first and prototypes: - result += self.append_prototypes( - file_path, contents, prototypes) + result += self.append_prototypes(file_path, contents, + prototypes) else: result.append(contents) is_first = False @@ -187,9 +182,7 @@ def DumpIDEData(env): if env['PIOPLATFORM'] == "atmelavr": defines.append( "__AVR_%s__" % env.BoardConfig().get("build.mcu").upper() - .replace("ATMEGA", "ATmega") - .replace("ATTINY", "ATtiny") - ) + .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny")) return defines LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS" @@ -257,8 +250,8 @@ def GetActualLDScript(env): return path if script: - env.Exit("Error: Could not find '%s' LD script in LDPATH '%s'" % ( - script, env.subst("$LIBPATH"))) + env.Exit("Error: Could not find '%s' LD script in LDPATH '%s'" % + (script, env.subst("$LIBPATH"))) return None diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 807f525d..2cec0992 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -89,9 +89,7 @@ def LoadPioPlatform(env, variables): 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") - ) + env.Replace(LDSCRIPT_PATH=board_config.get("build.ldscript")) def exists(_): diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index a93f1d78..3789e73f 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -28,7 +28,6 @@ FRAMEWORK_PARAMETERS = { "serial_begin": "Serial.begin(9600)", "serial_end": "Serial.end()" }, - "mbed": { "framework": "mbed.h", "serial_obj": "Serial pc(USBTX, USBRX);", @@ -37,7 +36,6 @@ FRAMEWORK_PARAMETERS = { "serial_begin": "pc.baud(9600)", "serial_end": "" }, - "energia": { "framework": "Energia.h", "serial_obj": "", @@ -52,19 +50,14 @@ FRAMEWORK_PARAMETERS = { def ProcessTest(env): env.Append( CPPDEFINES=[ - "UNIT_TEST", - "UNITY_INCLUDE_CONFIG_H" + "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.PioPlatform().get_package_dir("tool-unity")) env.Prepend(LIBS=[unitylib]) test_dir = env.subst("$PROJECTTEST_DIR") @@ -75,8 +68,7 @@ def ProcessTest(env): src_filter += " +<%s%s>" % (env['PIOTEST'], sep) return env.CollectBuildFiles( - "$BUILDTEST_DIR", test_dir, src_filter=src_filter, duplicate=False - ) + "$BUILDTEST_DIR", test_dir, src_filter=src_filter, duplicate=False) def GenerateOutputReplacement(env, destination_dir): @@ -124,11 +116,11 @@ void output_complete(void) framework = env.subst("$PIOFRAMEWORK").lower() if framework not in FRAMEWORK_PARAMETERS: - env.Exit( - "Error: %s framework doesn't support testing feature!" % framework) + env.Exit("Error: %s framework doesn't support testing feature!" % + framework) else: - data = Template(TEMPLATECPP).substitute( - FRAMEWORK_PARAMETERS[framework]) + data = Template(TEMPLATECPP).substitute(FRAMEWORK_PARAMETERS[ + framework]) tmp_file = join(destination_dir, "output_export.cpp") with open(tmp_file, "w") as f: diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index c098f40e..65d80b79 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -120,8 +120,7 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument "\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"): diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index ff048daf..0db54cfd 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -32,18 +32,14 @@ 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 if "BOARD" in env and "build.extra_flags" in env.BoardConfig(): @@ -55,7 +51,8 @@ def BuildProgram(env): if env.get("PIOFRAMEWORK"): env.BuildFrameworks([ - f.lower().strip() for f in env['PIOFRAMEWORK'].split(",")]) + f.lower().strip() for f in env['PIOFRAMEWORK'].split(",") + ]) # restore PIO macros if it was deleted by framework _append_pio_macros() @@ -66,18 +63,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")) @@ -96,14 +87,11 @@ def BuildProgram(env): env.Append(PIOBUILDFILES=env.ProcessTest()) if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: - env.Exit( - "Error: Nothing to build. Please put your source code files " - "to '%s' folder" % env.subst("$PROJECTSRC_DIR")) + env.Exit("Error: Nothing to build. Please put your source code files " + "to '%s' folder" % env.subst("$PROJECTSRC_DIR")) program = env.Program( - join("$BUILD_DIR", env.subst("$PROGNAME")), - env['PIOBUILDFILES'] - ) + join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES']) if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS): env.AddPostAction(program, env.CheckUploadSize) @@ -210,8 +198,11 @@ def VariantDirWrap(env, variant_dir, src_dir, duplicate=False): env.VariantDir(variant_dir, src_dir, duplicate) -def CollectBuildFiles(env, variant_dir, src_dir, - src_filter=None, duplicate=False): +def CollectBuildFiles(env, + variant_dir, + src_dir, + src_filter=None, + duplicate=False): sources = [] variants = [] @@ -239,9 +230,8 @@ def BuildFrameworks(env, frameworks): return if "BOARD" not in env: - env.Exit( - "Please specify `board` in `platformio.ini` to use " - "with '%s' framework" % ", ".join(frameworks)) + env.Exit("Please specify `board` in `platformio.ini` to use " + "with '%s' framework" % ", ".join(frameworks)) board_frameworks = env.BoardConfig().get("frameworks", []) if frameworks == ["platformio"]: diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index c116a8ba..572e39a3 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -48,15 +48,21 @@ def cli(query, installed, 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("ID", 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 board in sorted(pboards, key=lambda b: b['id']): if query: - search_data = "%s %s" % ( - board['id'], json.dumps(board).lower()) + search_data = "%s %s" % (board['id'], + json.dumps(board).lower()) if query.lower() not in search_data.lower(): continue @@ -71,11 +77,15 @@ def cli(query, installed, json_output): # pylint: disable=R0912 else: ram_size = "%dB" % ram_size - 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'])) + 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 _get_boards(installed=False): diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index e9a92984..401b00ff 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -55,19 +55,37 @@ def validate_path(ctx, param, value): # pylint: disable=W0613 @click.argument("src", nargs=-1, callback=validate_path) @click.option("-l", "--lib", multiple=True, callback=validate_path) @click.option("--exclude", multiple=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( + "-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( + "--project-conf", + type=click.Path( + exists=True, + file_okay=True, + dir_okay=False, + readable=True, + resolve_path=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, + verbose): if not src: src = getenv("PLATFORMIO_CI_SRC", "").split(":") @@ -102,9 +120,8 @@ def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913 finally: if not keep_build_dir: rmtree( - build_dir, onerror=lambda action, name, exc: - (chmod(name, stat.S_IWRITE), remove(name)) - ) + build_dir, + onerror=lambda action, name, exc: (chmod(name, stat.S_IWRITE), remove(name))) def _clean_dir(dirpath): @@ -113,10 +130,7 @@ def _clean_dir(dirpath): def _copy_contents(dst_dir, contents): - items = { - "dirs": set(), - "files": set() - } + items = {"dirs": set(), "files": set()} for path in contents: if isdir(path): diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 6497f765..7d9fb2ed 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -37,24 +37,35 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613 assert not unknown_boards return value except AssertionError: - raise click.BadParameter( - "%s. Please search for the board ID 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("-b", "--board", multiple=True, metavar="ID", - callback=validate_boards) -@click.option("--ide", - type=click.Choice(ProjectGenerator.get_supported_ides())) +@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("--enable-auto-uploading", is_flag=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, + enable_auto_uploading, + env_prefix): if project_dir == getcwd(): click.secho("\nThe current working directory", fg="yellow", nl=False) @@ -63,18 +74,20 @@ 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.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.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")) + click.style( + "lib", fg="cyan")) if (app.get_setting("enable_prompts") and not click.confirm("Do you want to continue?")): @@ -83,10 +96,8 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 init_base_project(project_dir) if board: - fill_project_envs( - ctx, project_dir, board, - enable_auto_uploading, env_prefix, ide is not None - ) + fill_project_envs(ctx, project_dir, board, enable_auto_uploading, + env_prefix, ide is not None) if ide: if not board: @@ -102,8 +113,7 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 "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" - ) + fg="yellow") pg = ProjectGenerator(project_dir, ide, board[0]) pg.generate() @@ -116,8 +126,7 @@ 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): @@ -132,8 +141,9 @@ def get_first_board(project_dir): def init_base_project(project_dir): if not util.is_platformio_project(project_dir): - copyfile(join(util.get_source_dir(), "projectconftpl.ini"), - join(project_dir, "platformio.ini")) + 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") @@ -275,8 +285,8 @@ def init_cvs_ignore(project_dir): def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals - ctx, project_dir, board_ids, enable_auto_uploading, - env_prefix, force_download): + ctx, project_dir, board_ids, enable_auto_uploading, env_prefix, + force_download): installed_boards = PlatformManager().get_installed_boards() content = [] used_boards = [] @@ -291,8 +301,8 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals for id_ in board_ids: manifest = None - for boards in ( - installed_boards, PlatformManager.get_registered_boards()): + for boards in (installed_boards, + PlatformManager.get_registered_boards()): for b in boards: if b['id'] == id_: manifest = b @@ -329,10 +339,10 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals def _install_dependent_platforms(ctx, platforms): installed_platforms = [ - p['name'] for p in PlatformManager().get_installed()] + p['name'] for p in PlatformManager().get_installed() + ] if set(platforms) <= set(installed_platforms): return ctx.invoke( cli_platform_install, - platforms=list(set(platforms) - set(installed_platforms)) - ) + platforms=list(set(platforms) - set(installed_platforms))) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index c662e012..9f4043e0 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -33,14 +33,26 @@ from platformio.managers.platform import PlatformFactory @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=False, dir_okay=True, - writable=True, resolve_path=True)) +@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("-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, # pylint: disable=R0913,R0914 + environment, + target, + upload_port, + project_dir, + verbose, + disable_auto_clean): assert check_project_envs(project_dir, environment) with util.cd(project_dir): # clean obsolete .pioenvs dir @@ -59,7 +71,8 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 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(): @@ -71,9 +84,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 @@ -86,8 +100,8 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 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, verbose) results.append(ep.process()) if not all(results): @@ -96,10 +110,7 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 class EnvironmentProcessor(object): - REMAPED_OPTIONS = { - "FRAMEWORK": "PIOFRAMEWORK", - "PLATFORM": "PIOPLATFORM" - } + REMAPED_OPTIONS = {"FRAMEWORK": "PIOFRAMEWORK", "PLATFORM": "PIOPLATFORM"} RENAMED_OPTIONS = { "INSTALL_LIBS": "LIB_INSTALL", @@ -107,8 +118,13 @@ class EnvironmentProcessor(object): "LIB_USE": "LIB_FORCE" } - def __init__(self, cmd_ctx, name, options, # pylint: disable=R0913 - targets, upload_port, verbose): + def __init__(self, # pylint: disable=R0913 + cmd_ctx, + name, + options, + targets, + upload_port, + verbose): self.cmd_ctx = cmd_ctx self.name = name self.options = self._validate_options(options) @@ -121,21 +137,21 @@ class EnvironmentProcessor(object): 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()]) - )) + 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) result = self._run() is_error = result['returncode'] != 0 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) + 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 @@ -148,10 +164,8 @@ class EnvironmentProcessor(object): 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" - ) + "`%s` instead." % (k, self.RENAMED_OPTIONS[_k].lower()), + fg="yellow") k = self.RENAMED_OPTIONS[_k].lower() result[k] = v return result @@ -249,12 +263,10 @@ def check_project_envs(project_dir, environments): if not config.sections(): raise exception.ProjectEnvsNotAvailable() - known = set([s[4:] for s in config.sections() - if s.startswith("env:")]) + 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)) + raise exception.UnknownEnvNames(", ".join(unknown), ", ".join(known)) return True diff --git a/platformio/commands/serialports.py b/platformio/commands/serialports.py index 4371b15c..a42e59f6 100644 --- a/platformio/commands/serialports.py +++ b/platformio/commands/serialports.py @@ -46,41 +46,72 @@ def serialports_list(json_output): 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") + @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(): @@ -107,47 +138,78 @@ if int(PYSERIAL_VERSION[0]) == 3: default_port=kwargs['port'], default_baudrate=kwargs['baud'], default_rts=kwargs['rts'], - default_dtr=kwargs['dtr'] - ) + 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) + @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") + @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:] diff --git a/platformio/commands/settings.py b/platformio/commands/settings.py index 34e460d3..478ed527 100644 --- a/platformio/commands/settings.py +++ b/platformio/commands/settings.py @@ -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 index 3b16d7a6..3f9ae9c3 100644 --- a/platformio/commands/test.py +++ b/platformio/commands/test.py @@ -32,9 +32,16 @@ from platformio.managers.platform import PlatformFactory @click.option("--environment", "-e", multiple=True, metavar="") @click.option("--skip", 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( + "-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) @click.pass_context def cli(ctx, environment, skip, upload_port, project_dir, verbose): @@ -85,16 +92,17 @@ def cli(ctx, environment, skip, upload_port, project_dir, verbose): elif status is None: status_str = click.style("IGNORED", fg="yellow") - click.echo("test:%s/env:%s\t%s" % ( - click.style(testname, fg="yellow"), - click.style(envname, fg="cyan"), - status_str), err=status is False) + click.echo( + "test:%s/env:%s\t%s" % (click.style( + testname, fg="yellow"), click.style( + envname, fg="cyan"), status_str), + err=status is False) - print_header("[%s] Took %.2f seconds" % ( - (click.style("PASSED", fg="green", bold=True) if passed - else click.style("FAILED", fg="red", bold=True)), - time() - start_time - ), is_error=not passed) + print_header( + "[%s] Took %.2f seconds" % ((click.style( + "PASSED", fg="green", bold=True) if passed else click.style( + "FAILED", fg="red", bold=True)), time() - start_time), + is_error=not passed) if not passed: raise exception.ReturnErrorCode() @@ -122,41 +130,42 @@ class TestProcessor(object): return self._run_hardware_test() def _progress(self, text, is_error=False): - print_header("[test::%s] %s" % ( - click.style(self.test_name, fg="yellow", bold=True), - text - ), is_error=is_error) + print_header( + "[test::%s] %s" % (click.style( + self.test_name, fg="yellow", bold=True), text), + is_error=is_error) click.echo() def _build_or_upload(self, target): if self.test_name != "*": self.cmd_ctx.meta['piotest'] = self.test_name return self.cmd_ctx.invoke( - cmd_run, project_dir=self.options['project_dir'], + cmd_run, + project_dir=self.options['project_dir'], upload_port=self.options['upload_port'], verbose=self.options['verbose'], environment=[self.env_name], - target=target - ) + target=target) def _run_hardware_test(self): click.echo("If you don't see any output for the first 10 secs, " "please reset board (press reset button)") click.echo() - ser = serial.Serial(self.get_serial_port(), self.SERIAL_BAUDRATE, - timeout=self.SERIAL_TIMEOUT) + ser = serial.Serial( + self.get_serial_port(), + self.SERIAL_BAUDRATE, + timeout=self.SERIAL_TIMEOUT) passed = True while True: line = ser.readline().strip() if not line: continue if line.endswith(":PASS"): - click.echo("%s\t%s" % ( - line[:-5], click.style("PASSED", fg="green"))) + click.echo("%s\t%s" % (line[:-5], click.style( + "PASSED", fg="green"))) elif ":FAIL:" in line: passed = False - click.echo("%s\t%s" % ( - line, click.style("FAILED", fg="red"))) + click.echo("%s\t%s" % (line, click.style("FAILED", fg="red"))) else: click.echo(line) if all([l in line for l in ("Tests", "Failures", "Ignored")]): diff --git a/platformio/commands/update.py b/platformio/commands/update.py index d97ae99d..422ac3d9 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.py @@ -19,8 +19,8 @@ from platformio.commands.platform import platform_update as cmd_platform_update from platformio.managers.lib import LibraryManager -@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", diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index ddac25c1..9a8f8dbf 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -22,26 +22,22 @@ import requests 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(): 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 = 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"] - ) + cmds = (["pip", "install", "--upgrade", + "https://github.com/platformio/platformio/archive/develop.zip" + if to_develop else "platformio"], ["platformio", "--version"]) cmd = None r = None @@ -63,21 +59,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 ----------------- @@ -86,11 +80,13 @@ 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(): @@ -107,11 +103,9 @@ def get_latest_version(): 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 = 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() @@ -129,9 +123,7 @@ def get_develop_latest_version(): def get_pypi_latest_version(): - r = requests.get( - "https://pypi.python.org/pypi/platformio/json", - headers=util.get_request_defheaders() - ) + 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 bce15dea..e91f75db 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -41,7 +41,8 @@ class FileDownloader(object): 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) diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 093508f7..762dfbc4 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -59,19 +59,14 @@ class ProjectGenerator(object): @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" + "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")]) @@ -80,8 +75,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('{"') @@ -125,8 +120,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 = "" @@ -161,13 +155,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/maintenance.py b/platformio/maintenance.py index 3fc980ac..0f959a23 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -56,8 +56,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): @@ -100,8 +102,7 @@ class Upgrader(object): continue os.remove(join(boards_dir, item)) for key, value in data.items(): - with open(join(boards_dir, "%s.json" % key), - "w") as f: + with open(join(boards_dir, "%s.json" % key), "w") as f: json.dump(value, f, sort_keys=True, indent=2) # re-install PlatformIO 2.0 development platforms @@ -120,8 +121,7 @@ def after_upgrade(ctx): if last_version == "0.0.0": app.set_state_item("last_version", __version__) else: - click.secho("Please wait while upgrading PlatformIO ...", - fg="yellow") + click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") u = Upgrader(last_version, __version__) if u.run(ctx): @@ -132,11 +132,15 @@ def after_upgrade(ctx): for manifest in pm.get_installed(): pm.update(manifest['name'], "^" + manifest['version']) - click.secho("PlatformIO has been successfully upgraded to %s!\n" % - __version__, fg="green") + 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__)) + telemetry.on_event( + category="Auto", + action="Upgrade", + label="%s > %s" % (last_version, __version__)) else: raise exception.UpgradeError("Auto upgrading...") click.echo("") @@ -144,29 +148,24 @@ def after_upgrade(ctx): # 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") - )) + 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") - )) + 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("- %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("") @@ -191,12 +190,14 @@ def check_platformio_upgrade(): 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) @@ -235,20 +236,29 @@ 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 --global" if what == "libraries" else "platform"), - 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( + "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") diff --git a/platformio/telemetry.py b/platformio/telemetry.py index f7c06102..964cc707 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -210,8 +210,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 @@ -233,11 +232,7 @@ def on_command(): def measure_ci(): - event = { - "category": "CI", - "action": "NoName", - "label": None - } + event = {"category": "CI", "action": "NoName", "label": None} envmap = { "APPVEYOR": {"label": getenv("APPVEYOR_REPO_NAME")}, @@ -258,11 +253,7 @@ def measure_ci(): def measure_caller(calller_id): calller_id = str(calller_id)[:20].lower() - event = { - "category": "Caller", - "action": "Misc", - "label": calller_id - } + event = {"category": "Caller", "action": "Misc", "label": calller_id} if calller_id in (["atom", "vim"] + ProjectGenerator.get_supported_ides()): event['action'] = "IDE" on_event(**event) diff --git a/platformio/unpacker.py b/platformio/unpacker.py index 1011fe4c..67ca78a7 100644 --- a/platformio/unpacker.py +++ b/platformio/unpacker.py @@ -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 8a389717..eeb02caf 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -81,7 +81,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 +121,7 @@ def singleton(cls): if cls not in _instances: _instances[cls] = cls(*args, **kwargs) return _instances[cls] + return get_instance @@ -162,10 +162,8 @@ def _get_projconf_option_dir(name, default=None): 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: @@ -234,10 +232,8 @@ URL=http://docs.platformio.org/en/stable/projectconf.html#envs-dir 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 load_project_config(project_dir=None): @@ -259,17 +255,12 @@ 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" - ) + shell=system() == "Windows") default.update(kwargs) kwargs = default @@ -344,9 +335,8 @@ 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} @memoized @@ -364,7 +354,7 @@ def get_api_result(path, params=None, data=None, skipdns=False): url = __apiurl__ if skipdns: url = "http://%s" % __apiip__ - headers['host'] = __apiurl__[__apiurl__.index("://")+3:] + headers['host'] = __apiurl__[__apiurl__.index("://") + 3:] try: if data: @@ -390,8 +380,8 @@ def get_api_result(path, params=None, data=None, skipdns=False): "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() @@ -401,8 +391,8 @@ def get_api_result(path, params=None, data=None, skipdns=False): @memoized def _lookup_frameworks(): frameworks = {} - frameworks_path = join( - get_source_dir(), "builder", "scripts", "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")] @@ -412,8 +402,8 @@ def _lookup_frameworks(): fcontent = f.read() assert '"""' in fcontent _doc_start = fcontent.index('"""') + 3 - fdoc = fcontent[ - _doc_start:fcontent.index('"""', _doc_start)].strip() + 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], @@ -446,8 +436,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: diff --git a/setup.py b/setup.py index 4c309883..29a759d9 100644 --- a/setup.py +++ b/setup.py @@ -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__, @@ -29,9 +27,6 @@ install_requires = [ "pyserial<4" ] -if sys.version_info < (2, 7, 0): - install_requires[-1] = "pyserial<3" - setup( name=__title__, version=__version__, From 941c7ffd07115b219bb0c95fd20fb576f2d8159d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Aug 2016 23:40:04 +0300 Subject: [PATCH 105/119] Remove Python 2.6 code --- platformio/__init__.py | 2 +- platformio/commands/upgrade.py | 2 -- platformio/ide/projectgenerator.py | 6 +----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 469a4e79..e06d38ef 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev18") +VERSION = (3, 0, "0.dev19") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 9a8f8dbf..93f82e6c 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -43,8 +43,6 @@ 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 762dfbc4..ecd2f868 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -63,11 +63,7 @@ class ProjectGenerator(object): 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 = [normpath(sys.executable), "-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']]) From d27c31a389899b966ee1968313195cba77dd7ce0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 4 Aug 2016 00:55:07 +0300 Subject: [PATCH 106/119] Formatter: allow multiline lambdas --- .style.yapf | 3 ++- platformio/commands/ci.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.style.yapf b/.style.yapf index 0a658196..7bc85964 100644 --- a/.style.yapf +++ b/.style.yapf @@ -1,2 +1,3 @@ [style] -blank_line_before_nested_class_or_def = true \ No newline at end of file +blank_line_before_nested_class_or_def = true +allow_multiline_lambdas = true diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index 401b00ff..886c9506 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -121,7 +121,8 @@ def cli(ctx, # pylint: disable=R0913 if not keep_build_dir: rmtree( build_dir, - onerror=lambda action, name, exc: (chmod(name, stat.S_IWRITE), remove(name))) + onerror=lambda action, name, exc: (chmod(name, stat.S_IWRITE), + remove(name))) def _clean_dir(dirpath): From dad8f9d80e5be18ae0768c6f1aeeecf648ef6fcd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 13:10:27 +0300 Subject: [PATCH 107/119] Show valid text when "Checking" packages version --- platformio/managers/package.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 0b57520d..21769fce 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -492,8 +492,10 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): manifest = self.load_manifest(installed_dir) click.echo( - "Updating %s @ %s: \t" % (click.style( - manifest['name'], fg="cyan"), manifest['version']), + "%s %s @ %s: \t" % ("Checking" + if only_check else "Updating", click.style( + manifest['name'], fg="cyan"), + manifest['version']), nl=False) manifest_path = self.get_manifest_path(installed_dir) if manifest_path.endswith(self.VCS_MANIFEST_NAME): From e9ed55b6e91298d47b9a8e69ecc45ec636fe12fc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 13:51:28 +0300 Subject: [PATCH 108/119] Improve updating of development platforms --- Makefile | 3 +-- platformio/__init__.py | 2 +- platformio/managers/package.py | 1 + platformio/managers/platform.py | 16 +++++++++------- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 2117e072..51b3d166 100644 --- a/Makefile +++ b/Makefile @@ -5,12 +5,11 @@ lint: isort: isort -rc ./platformio isort -rc ./tests - isort -rc ./scripts yapf: yapf --recursive --in-place platformio/ -before-commit: isort yapf pylint +before-commit: isort yapf lint clean-docs: rm -rf docs/_build diff --git a/platformio/__init__.py b/platformio/__init__.py index e06d38ef..8948d92b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev19") +VERSION = (3, 0, "0.dev20") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 21769fce..3f111d9d 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -522,6 +522,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): 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( diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index fbfc0af3..aae99081 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -43,7 +43,8 @@ class PlatformManager(BasePkgManager): return "platform.json" def install(self, # pylint: disable=too-many-arguments,arguments-differ - name, requirements=None, with_packages=None, + name, requirements=None, quiet=False, + trigger_event=True, 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)) @@ -52,12 +53,14 @@ class PlatformManager(BasePkgManager): self.cleanup_packages(p.packages.keys()) return True - def uninstall( # pylint: disable=arguments-differ - self, name, requirements=None): + 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) - self.cleanup_packages(p.packages.keys()) + # 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 @@ -67,7 +70,6 @@ class PlatformManager(BasePkgManager): 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): @@ -137,13 +139,13 @@ class PlatformFactory(object): @classmethod def newPlatform(cls, name, requirements=None): - if not requirements and "@" in name: - name, requirements = name.rsplit("@", 1) 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_installed_dir(name, requirements) From c1178277caa130742a9c64c8b29ccc81f3341186 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 16:04:10 +0300 Subject: [PATCH 109/119] Print coverage report to terminal --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index a3866532..172bb4c5 100644 --- a/tox.ini +++ b/tox.ini @@ -68,4 +68,4 @@ deps = pytest pytest-cov commands = - py.test --cov=platformio --cov-report xml --ignore=tests/test_examples.py --ignore=tests/test_pkgmanifest.py -v tests + py.test --cov=platformio --cov-report term --cov-report xml --ignore=tests/test_examples.py --ignore=tests/test_pkgmanifest.py -v tests From bf727d6905f6dee471a51aaea31bef772adaca53 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 16:23:39 +0300 Subject: [PATCH 110/119] Update article links --- docs/articles.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/articles.rst b/docs/articles.rst index 7acd3e5a..30ef007f 100644 --- a/docs/articles.rst +++ b/docs/articles.rst @@ -38,18 +38,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 `_ From 39542c4ef209e592ef8679706b3d81c09f0bc6c9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 17:02:39 +0300 Subject: [PATCH 111/119] Improve platform manager when VCS is used --- platformio/managers/package.py | 49 +++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 3f111d9d..19c4a1a3 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -109,12 +109,7 @@ class PkgInstallerMixin(object): VCS_MANIFEST_NAME = ".piopkgmanager.json" - 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 + def get_vcs_manifest_path(self, pkg_dir): for item in os.listdir(pkg_dir): if not isdir(join(pkg_dir, item)): continue @@ -122,13 +117,27 @@ class PkgInstallerMixin(object): 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, pkg_dir): - manifest_path = self.get_manifest_path(pkg_dir) - if manifest_path: - manifest = util.load_json(manifest_path) + def load_manifest(self, path): + pkg_dir = path + if isdir(path): + path = self.get_manifest_path(path) + else: + pkg_dir = dirname(pkg_dir) + if isfile(path) and path.endswith(self.VCS_MANIFEST_NAME): + pkg_dir = dirname(pkg_dir) + if path: + manifest = util.load_json(path) manifest['__pkg_dir'] = pkg_dir return manifest return None @@ -401,8 +410,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): "%s @ %s is not installed" % (name, requirements or "*"), fg="yellow") return - manifest_path = self.get_manifest_path(installed_dir) - if manifest_path.endswith(self.VCS_MANIFEST_NAME): + if self.get_vcs_manifest_path(installed_dir): return False manifest = self.load_manifest(installed_dir) return manifest['version'] != self.get_latest_repo_version( @@ -490,19 +498,24 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): fg="yellow") return - manifest = self.load_manifest(installed_dir) + is_vcs_pkg = False + if self.get_vcs_manifest_path(installed_dir): + is_vcs_pkg = True + manifest_path = self.get_vcs_manifest_path(installed_dir) + else: + manifest_path = self.get_manifest_path(installed_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']), + name, fg="cyan"), manifest['version']), nl=False) - manifest_path = self.get_manifest_path(installed_dir) - if manifest_path.endswith(self.VCS_MANIFEST_NAME): + if is_vcs_pkg: if only_check: click.echo("[%s]" % (click.style("Skip", fg="yellow"))) return - click.echo("[%s]" % (click.style("Checking", fg="yellow"))) + click.echo("[%s]" % (click.style("VCS", fg="yellow"))) vcs = VCSClientFactory.newClient(installed_dir, manifest['url']) if not vcs.can_be_updated: click.secho( From 4fc0ab0649cc73ade41c9e0e26cf59b1f3ad5346 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 17:39:32 +0300 Subject: [PATCH 112/119] Fix updating from VCS --- platformio/managers/package.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 19c4a1a3..ea1f6321 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -129,14 +129,15 @@ class PkgInstallerMixin(object): 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 isfile(path) and path.endswith(self.VCS_MANIFEST_NAME): - 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 From 6970c95acabbe24ec7bcb0bd46865bd65e7f77df Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 17:59:10 +0300 Subject: [PATCH 113/119] Fix command lib test --- tests/commands/test_lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index ed4fc603..994417a4 100644 --- a/tests/commands/test_lib.py +++ b/tests/commands/test_lib.py @@ -84,7 +84,7 @@ def test_global_lib_show(clirunner, validate_cliresult, isolated_pio_home): def test_global_lib_update(clirunner, validate_cliresult, isolated_pio_home): result = clirunner.invoke(cli, ["-g", "update"]) validate_cliresult(result) - assert all([s in result.output for s in ("Up-to-date", "Checking")]) + assert all([s in result.output for s in ("[Up-to-date]", "[VCS]")]) def test_global_lib_uninstall(clirunner, validate_cliresult, From c64354ebcc93859933d65997f2c710d764d11b72 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 18:20:09 +0300 Subject: [PATCH 114/119] Add PlatformIO Plus info --- HISTORY.rst | 10 ++++++---- docs/librarymanager/ldf.rst | 6 +++--- docs/platforms/unit_testing.rst | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 327f32e6..2dd9c227 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,11 @@ PlatformIO 3.0 3.0.0 (2016-??-??) ~~~~~~~~~~~~~~~~~~ +* PlatformIO Plus + + + `Unit Testing `__ for Embedded + (`issue #408 `_) + * Decentralized Development Platforms + Development platform manifest "platform.json" and @@ -19,9 +24,6 @@ PlatformIO 3.0 + Embedded Board compatibility with more than one development platform (`issue #456 `_) -* `Unit Testing `__ for Embedded - (`issue #408 `_) - * Library Manager 3.0 + `Semantic Versioning `__ for library commands and @@ -41,7 +43,7 @@ PlatformIO 3.0 * New Intelligent Library Build System + `Library Dependency Finder `__ - that interprets C Preprocessor conditional macros with deep search behavior + 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 diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst index 8744cafb..8c9c32a9 100644 --- a/docs/librarymanager/ldf.rst +++ b/docs/librarymanager/ldf.rst @@ -133,11 +133,11 @@ This mode can be changed using :ref:`projectconf_lib_compat_mode` option in .. _ldf_c_cond_syntax: -C Preprocessor conditional syntax ---------------------------------- +C/C++ Preprocessor conditional syntax +------------------------------------- In spite of the fact that Library Dependency Finder is written in pure Python, -it interprets (emulates) `C Preprocessor conditional syntax `_ +it interprets (emulates) `C/C++ Preprocessor conditional syntax `_ (``#ifdef``, ``if``, ``defined``, ``else``, and ``elif``) without calling ``gcc -E``. For example, diff --git a/docs/platforms/unit_testing.rst b/docs/platforms/unit_testing.rst index 316c17ba..5e6555a5 100644 --- a/docs/platforms/unit_testing.rst +++ b/docs/platforms/unit_testing.rst @@ -14,7 +14,7 @@ Unit Testing ============ -.. versionadded:: 3.0 +.. versionadded:: 3.0 (PlatformIO Plus) `Unit Testing (wiki) `_ is a software testing method by which individual units of source code, sets From db267513ca9f194c9ebdd2f64405549c4bbde5a7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 18:43:20 +0300 Subject: [PATCH 115/119] Implement custom "rmtree"; resolve issue with Windows and .git --- platformio/__init__.py | 2 +- platformio/commands/ci.py | 16 ++++++---------- platformio/commands/run.py | 5 ++--- platformio/managers/package.py | 12 ++++++------ platformio/util.py | 11 +++++++++++ tests/test_examples.py | 7 +++---- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 8948d92b..d3eaf0e4 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev20") +VERSION = (3, 0, "0.dev21") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index 886c9506..c7da3943 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -12,16 +12,15 @@ # 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 @@ -119,14 +118,11 @@ def cli(ctx, # pylint: disable=R0913 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) @@ -165,7 +161,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/run.py b/platformio/commands/run.py index 9f4043e0..cdc8d944 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -16,7 +16,6 @@ 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 @@ -234,14 +233,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) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index ea1f6321..9b8cdc4f 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -15,7 +15,7 @@ import json import os from os.path import basename, dirname, isdir, isfile, islink, join -from shutil import copyfile, copytree, rmtree +from shutil import copyfile, copytree from tempfile import mkdtemp import click @@ -159,7 +159,7 @@ class PkgInstallerMixin(object): copytree(item_path, join(pkg_dir, item), symlinks=True) # remove not used contents while True: - rmtree(root) + util.rmtree_(root) root = dirname(root) if root == pkg_dir: break @@ -205,7 +205,7 @@ class PkgInstallerMixin(object): if isfile(url): self.unpack(url, tmp_dir) else: - rmtree(tmp_dir) + util.rmtree_(tmp_dir) copytree(url, tmp_dir) elif url.startswith(("http://", "https://")): dlpath = self.download(url, tmp_dir, sha1) @@ -228,7 +228,7 @@ class PkgInstallerMixin(object): pkg_dir = self._install_from_tmp_dir(tmp_dir, requirements) finally: if isdir(tmp_dir): - rmtree(tmp_dir) + util.rmtree_(tmp_dir) return pkg_dir def _install_from_tmp_dir(self, tmp_dir, requirements=None): @@ -267,7 +267,7 @@ class PkgInstallerMixin(object): # remove previous/not-satisfied package if isdir(pkg_dir): - rmtree(pkg_dir) + util.rmtree_(pkg_dir) os.rename(tmp_dir, pkg_dir) assert isdir(pkg_dir) return pkg_dir @@ -478,7 +478,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): if islink(installed_dir): os.unlink(installed_dir) else: - rmtree(installed_dir) + util.rmtree_(installed_dir) click.echo("[%s]" % click.style("OK", fg="green")) diff --git a/platformio/util.py b/platformio/util.py index eeb02caf..cd87103c 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -17,12 +17,14 @@ 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) from platform import system, uname +from shutil import rmtree from threading import Thread from platformio import __apiip__, __apiurl__, __version__, exception @@ -454,3 +456,12 @@ def where_is_program(program, envpath=None): 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/tests/test_examples.py b/tests/test_examples.py index 959d974b..bfe428d9 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -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): @@ -38,9 +37,9 @@ def pytest_generate_tests(metafunc): @pytest.mark.examples def test_run(platformio_setup, 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: From 098653aac7e253211cbb0d57b373797aec814689 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Aug 2016 18:52:24 +0300 Subject: [PATCH 116/119] Better explanation with dependencies --- docs/librarymanager/ldf.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst index 8c9c32a9..c3dd7504 100644 --- a/docs/librarymanager/ldf.rst +++ b/docs/librarymanager/ldf.rst @@ -61,12 +61,12 @@ 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 - dependent libraries. Builds only the libraries that are specified in + dependencies. Builds only the libraries that are specified in manifests (:ref:`library_config`, ``module.json``) or in the :ref:`projectconf`. * ``1`` - parses ALL C/C++ source code of the project and follows only by nested includes/chain (``#include ...``) from the libraries. * ``2`` - **default** - parses ALL C/C++ source code of the project and parses - ALL C/C++ source code of the each dependent library (recursively). + ALL C/C++ source code of the each dependency (recursively). This mode can be changed using :ref:`projectconf_lib_ldf_mode` option in :ref:`projectconf`. @@ -110,7 +110,7 @@ A difference between ``1`` and ``2`` modes. For example, there are 2 libraries: 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 dependent libraries will not be parsed. + continues until all dependencies will not be parsed. .. _ldf_compat_mode: From 80c7a8d1cebb9e4eacce626e7b196d5b9f6471d0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 8 Aug 2016 14:00:01 +0300 Subject: [PATCH 117/119] Warn about unknown options in project configuration file // Resolve #740 --- platformio/builder/main.py | 2 +- platformio/commands/run.py | 58 +++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 05823c66..5bbabd15 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -96,7 +96,7 @@ DefaultEnvironment( env = DefaultEnvironment() if env.GetOption("silent"): - print "Use `-v, --verbose` option to enable verbose mode" + print "Verbose mode can be enabled via `-v, --verbose` option" Progress(env.ProgressHandler) # decode common variables diff --git a/platformio/commands/run.py b/platformio/commands/run.py index cdc8d944..180d01a9 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -52,7 +52,6 @@ def cli(ctx, # pylint: disable=R0913,R0914 project_dir, verbose, disable_auto_clean): - assert check_project_envs(project_dir, environment) with util.cd(project_dir): # clean obsolete .pioenvs dir if not disable_auto_clean: @@ -66,6 +65,9 @@ def cli(ctx, # pylint: disable=R0913,R0914 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 = [ @@ -109,13 +111,17 @@ def cli(ctx, # pylint: disable=R0913,R0914 class EnvironmentProcessor(object): - REMAPED_OPTIONS = {"FRAMEWORK": "PIOFRAMEWORK", "PLATFORM": "PIOPLATFORM"} + 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_force", "lib_ignore", + "lib_extra_dirs", "lib_ldf_mode", "lib_compat_mode", "piotest") - RENAMED_OPTIONS = { - "INSTALL_LIBS": "LIB_INSTALL", - "IGNORE_LIBS": "LIB_IGNORE", - "LIB_USE": "LIB_FORCE" - } + REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"} + + RENAMED_OPTIONS = {"lib_use": "lib_force"} def __init__(self, # pylint: disable=R0913 cmd_ctx, @@ -126,7 +132,7 @@ class EnvironmentProcessor(object): 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 = verbose @@ -141,6 +147,7 @@ class EnvironmentProcessor(object): ["%s: %s" % (k, v) for k, v in self.options.iteritems()]))) click.secho("-" * terminal_width, bold=True) + self.options = self._validate_options(self.options) result = self._run() is_error = result['returncode'] != 0 @@ -157,15 +164,20 @@ class EnvironmentProcessor(object): 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()), + "`%s` instead." % (k, self.RENAMED_OPTIONS[k]), + fg="yellow") + k = self.RENAMED_OPTIONS[k] + # warn about unknown options + if k not in self.KNOWN_OPTIONS: + click.secho( + "Warning! Ignore unknown `%s` option from `[env:]` section" + % k, fg="yellow") - k = self.RENAMED_OPTIONS[_k].lower() result[k] = v return result @@ -174,9 +186,8 @@ class EnvironmentProcessor(object): if self.upload_port: variables['upload_port'] = self.upload_port for k, v in self.options.items(): - if k.upper() in self.REMAPED_OPTIONS: - k = self.REMAPED_OPTIONS[k.upper()] - 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 @@ -256,9 +267,22 @@ def print_header(label, is_error=False): click.echo("%s %s %s" % (half_line, label, half_line), err=is_error) -def check_project_envs(project_dir, environments): - config = util.load_project_config(project_dir) +def check_project_defopts(config): + if not config.has_section("platformio"): + return True + known = ("home_dir", "lib_dir", "libdeps_dir", "src_dir", "env_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() From 0b749c3888e0c08934c69199564315bfe8c28d5d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 8 Aug 2016 14:00:23 +0300 Subject: [PATCH 118/119] Warn about unknown options in project configuration file // Resolve #740 --- HISTORY.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2dd9c227..395e28be 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -67,7 +67,9 @@ PlatformIO 3.0 (`issue #721 `_) * Added ``license`` field to `library.json `__ (`issue #522 `_) -* Stopped Supporting Python 2.6 +* Warn about unknown options in project configuration file ``platformio.ini`` + (`issue #740 `_) +* Stopped supporting Python 2.6 PlatformIO 2.0 From 65e0daa06dde68e409cd43bf8b7256f48283f9a4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 8 Aug 2016 16:03:17 +0300 Subject: [PATCH 119/119] Project dependencies per build environment using "lib_deps" option // Resolve #413 --- HISTORY.rst | 4 +- docs/envvars.rst | 4 ++ docs/librarymanager/ldf.rst | 8 ++-- docs/projectconf.rst | 59 ++++++++++++++++++++---------- docs/userguide/lib/cmd_install.rst | 3 +- platformio/__init__.py | 2 +- platformio/commands/run.py | 49 ++++++++++++++++--------- 7 files changed, 85 insertions(+), 44 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 395e28be..9ee0df5c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -26,10 +26,12 @@ PlatformIO 3.0 * 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 global or custom + + Multiple library storages: Project's Local, PlatformIO's Global or Custom (`issue #475 `_) + Install library by name (`issue #414 `_) diff --git a/docs/envvars.rst b/docs/envvars.rst index 771f043e..5931e391 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -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`. diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst index c3dd7504..bd5889ff 100644 --- a/docs/librarymanager/ldf.rst +++ b/docs/librarymanager/ldf.rst @@ -30,6 +30,7 @@ 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` @@ -43,12 +44,13 @@ Library Dependency Finder has controls that can be set up in :ref:`projectconf`: Storage ------- -There are different storages/folders where Library Dependency Finder looks for -libraries. These folders/path have priority and LDF operates in the next order: +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_piolibdeps_dir` - project dependencies storage used by +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. diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 439ced3d..09c8f35f 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -102,17 +102,17 @@ Then in ``src/main.c`` you should use: PlatformIO will find your libraries automatically, configure preprocessor's include paths and build them. -.. _projectconf_pio_piolibdeps_dir: +.. _projectconf_pio_libdeps_dir: -``piolibdeps_dir`` -^^^^^^^^^^^^^^^^^^ +``libdeps_dir`` +^^^^^^^^^^^^^^^ -Internal storage where :ref:`librarymanager` will install project dependencies. -A default value is ``.piolibdeps`` that means that folder is located in the root of -project. +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_PIOLIBDEPS_DIR`. +:envvar:`PLATFORMIO_LIBDEPS_DIR`. .. _projectconf_pio_src_dir: @@ -639,21 +639,40 @@ Library options .. contents:: :local: -``lib_install`` -^^^^^^^^^^^^^^^ +.. _projectconf_lib_deps: -Specify dependent libraries which should be installed before environment -process. The only library IDs are allowed. Multiple libraries can be passed -using comma ``,`` sign. +``lib_deps`` +^^^^^^^^^^^^ -You can obtain library IDs using :ref:`cmd_lib_search` command. +Specify project dependencies that should be installed automatically to +:ref:`projectconf_pio_libdeps_dir` before an environment process. +Multiple dependencies are allowed (multi-lines). + +**Valid forms** + +.. code-block:: ini + + [env:***] + 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 = + 1 + PubSubClient + Json@~5.6,!=5.4 + https://github.com/gioblu/PJON.git@v2.0 + https://github.com/me-no-dev/ESPAsyncTCP.git .. _projectconf_lib_force: @@ -663,12 +682,12 @@ Example: .. seealso:: Please make sure to read :ref:`ldf` guide first. -Force Library Dependency Finder to depend on the specified libraries if -they even are not included in the project source code. Also, these -libraries will be processed in the first order. +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 +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 ``,`` separator. diff --git a/docs/userguide/lib/cmd_install.rst b/docs/userguide/lib/cmd_install.rst index c43122c0..6f007bbe 100644 --- a/docs/userguide/lib/cmd_install.rst +++ b/docs/userguide/lib/cmd_install.rst @@ -38,6 +38,7 @@ Usage # [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 @@ -47,7 +48,7 @@ Usage 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 = (name it should have locally) platformio lib [STORAGE_OPTIONS] install ("tag" can be commit, branch or tag) Description diff --git a/platformio/__init__.py b/platformio/__init__.py index d3eaf0e4..706fe860 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev21") +VERSION = (3, 0, "0.dev22") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 180d01a9..3309cf07 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -111,13 +111,14 @@ def cli(ctx, # pylint: disable=R0913,R0914 class EnvironmentProcessor(object): - 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_force", "lib_ignore", - "lib_extra_dirs", "lib_ldf_mode", "lib_compat_mode", "piotest") + 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", "piotest") REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"} @@ -141,10 +142,18 @@ class EnvironmentProcessor(object): 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()]))) + 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) self.options = self._validate_options(self.options) @@ -212,8 +221,15 @@ class EnvironmentProcessor(object): # install dependent libraries if "lib_install" in self.options: - _autoinstall_libs(self.cmd_ctx, self.options['lib_install'], - self.verbose) + _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 d.strip() + ], self.verbose) try: p = PlatformFactory.newPlatform(self.options['platform']) @@ -225,15 +241,12 @@ class EnvironmentProcessor(object): return p.run(build_vars, build_targets, self.verbose) -def _autoinstall_libs(ctx, libids_list, verbose=False): +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=[int(l.strip()) for l in libids_list.split(",")], - quiet=not verbose) + ctx.invoke(cmd_lib_install, libraries=libraries, quiet=not verbose) def _clean_pioenvs_dir(pioenvs_dir):