Browse Source

PIO: remove -ota envs, handle OTA condition in extra script (#2099)

* PIO: remove -ota envs, handle OTA condition in extra script
* Tweak ESPURNA_BOARD variable
* Support git and latest in ota script
* Handle ESPURNA_FLAGS too
* Try to handle env and projenv in pylint
* Add deprecation comment about -ota envs
* regen arduino.h
mcspr-patch-1
Max Prokhorov 4 years ago
committed by GitHub
parent
commit
a4d4231ae0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 635 additions and 968 deletions
  1. +1
    -0
      code/.gitignore
  2. +7
    -5
      code/espurna/config/arduino.h
  3. +30
    -4
      code/ota.py
  4. +58
    -949
      code/platformio.ini
  5. +461
    -0
      code/platformio_ota.ini
  6. +12
    -0
      code/scripts/espurna_utils/__init__.py
  7. +10
    -0
      code/scripts/espurna_utils/flags.py
  8. +15
    -2
      code/scripts/pio_main.py
  9. +41
    -8
      code/scripts/pio_pre.py

+ 1
- 0
code/.gitignore View File

@ -11,3 +11,4 @@ custom.h
.vscode/launch.json .vscode/launch.json
.pio .pio
libraries/ libraries/
espurna/espurna.ino.cpp

+ 7
- 5
code/espurna/config/arduino.h View File

@ -24,11 +24,11 @@
//#define AVATTO_NAS_WR01W //#define AVATTO_NAS_WR01W
//#define BESTEK_MRJ1011 //#define BESTEK_MRJ1011
//#define BH_ONOFRE //#define BH_ONOFRE
//#define BLITZWOLF_BWSHP5
//#define BLITZWOLF_BWSHPX //#define BLITZWOLF_BWSHPX
//#define BLITZWOLF_BWSHPX_V23 //#define BLITZWOLF_BWSHPX_V23
//#define BLITZWOLF_BWSHP5
//#define DELTACO_SH_LEXXW
//#define DELTACO_SH_LEXXRGB //#define DELTACO_SH_LEXXRGB
//#define DELTACO_SH_LEXXW
//#define DELTACO_SH_P01 //#define DELTACO_SH_P01
//#define DELTACO_SH_P03USB //#define DELTACO_SH_P03USB
//#define DIGOO_NX_SP202 //#define DIGOO_NX_SP202
@ -48,13 +48,13 @@
//#define GBLIFE_RGBW_SOCKET //#define GBLIFE_RGBW_SOCKET
//#define GENERIC_8CH //#define GENERIC_8CH
//#define GENERIC_AG_L4 //#define GENERIC_AG_L4
//#define GENERIC_E14
//#define GENERIC_ECH1560 //#define GENERIC_ECH1560
//#define GENERIC_ESP01S_DHT11_V10 //#define GENERIC_ESP01S_DHT11_V10
//#define GENERIC_ESP01S_DS18B20_V10 //#define GENERIC_ESP01S_DS18B20_V10
//#define GENERIC_ESP01S_RELAY_V40 //#define GENERIC_ESP01S_RELAY_V40
//#define GENERIC_ESP01S_RGBLED_V10 //#define GENERIC_ESP01S_RGBLED_V10
//#define GENERIC_GU10 //#define GENERIC_GU10
//#define GENERIC_E14
//#define GENERIC_V9261F //#define GENERIC_V9261F
//#define GIZWITS_WITTY_CLOUD //#define GIZWITS_WITTY_CLOUD
//#define GOSUND_WS1 //#define GOSUND_WS1
@ -105,16 +105,17 @@
//#define LINGAN_SWA1 //#define LINGAN_SWA1
//#define LINKSPRITE_LINKNODE_R4 //#define LINKSPRITE_LINKNODE_R4
//#define LITESUN_LA_WF3 //#define LITESUN_LA_WF3
//#define LOHAS_E27_9W
//#define LOHAS_E26_A19 //#define LOHAS_E26_A19
//#define TECKIN_SB53
//#define LOHAS_E27_9W
//#define LOMBEX_LUX_NOVA2_TUNABLE_WHITE //#define LOMBEX_LUX_NOVA2_TUNABLE_WHITE
//#define LOMBEX_LUX_NOVA2_WHITE_COLOR //#define LOMBEX_LUX_NOVA2_WHITE_COLOR
//#define LSC_SMART_LED_LIGHT_STRIP
//#define LUANI_HVIO //#define LUANI_HVIO
//#define LYASI_LIGHT //#define LYASI_LIGHT
//#define MAGICHOME_LED_CONTROLLER //#define MAGICHOME_LED_CONTROLLER
//#define MAGICHOME_LED_CONTROLLER_20 //#define MAGICHOME_LED_CONTROLLER_20
//#define MAGICHOME_ZJ_ESPM_5CH_B_13 //#define MAGICHOME_ZJ_ESPM_5CH_B_13
//#define MAGICHOME_ZJ_LB_RGBWW_L
//#define MAGICHOME_ZJ_WFMN_A_11 //#define MAGICHOME_ZJ_WFMN_A_11
//#define MAGICHOME_ZJ_WFMN_B_11 //#define MAGICHOME_ZJ_WFMN_B_11
//#define MAGICHOME_ZJ_WFMN_C_11 //#define MAGICHOME_ZJ_WFMN_C_11
@ -136,6 +137,7 @@
//#define PSH_WIFI_SENSOR //#define PSH_WIFI_SENSOR
//#define SMARTLIFE_MINI_SMART_SOCKET //#define SMARTLIFE_MINI_SMART_SOCKET
//#define STM_RELAY //#define STM_RELAY
//#define TECKIN_SB53
//#define TECKIN_SP20 //#define TECKIN_SP20
//#define TECKIN_SP21 //#define TECKIN_SP21
//#define TECKIN_SP22_V14 //#define TECKIN_SP22_V14


+ 30
- 4
code/ota.py View File

@ -14,6 +14,7 @@ import re
import shutil import shutil
import socket import socket
import subprocess import subprocess
import functools
import sys import sys
import time import time
@ -21,7 +22,7 @@ import zeroconf
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
__version__ = (0, 4)
__version__ = (0, 4, 1)
DESCRIPTION = "ESPurna OTA Manager v{}".format(".".join(str(x) for x in __version__)) DESCRIPTION = "ESPurna OTA Manager v{}".format(".".join(str(x) for x in __version__))
DISCOVERY_TIMEOUT = 10 DISCOVERY_TIMEOUT = 10
@ -312,10 +313,21 @@ def run(device, env):
def parse_commandline_args(): def parse_commandline_args():
parser = argparse.ArgumentParser(description=DESCRIPTION) parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument( parser.add_argument(
"-c", "--core", help="flash ESPurna core", action="store_true", default=False
"-c",
"--core",
help="Use ESPurna core configuration",
action="store_true",
default=False,
)
parser.add_argument(
"-f", "--flash", help="Flash device", action="store_true", default=False
) )
parser.add_argument( parser.add_argument(
"-f", "--flash", help="flash device", action="store_true", default=False
"-a",
"--arduino-core",
help="Arduino ESP8266 Core version",
default="2_3_0",
choices=["2_3_0", "latest", "git"],
) )
parser.add_argument("-o", "--flags", help="extra flags", default="") parser.add_argument("-o", "--flags", help="extra flags", default="")
parser.add_argument("-p", "--password", help="auth password", default="") parser.add_argument("-p", "--password", help="auth password", default="")
@ -386,6 +398,20 @@ def discover_devices(args):
return devices return devices
@functools.lru_cache(maxsize=None)
def get_platformio_env(arduino_core, size):
# todo: eventually 2_3_0 is dropped
# todo: naming
env_prefix = "esp8266"
if not size in [1, 2, 4]:
raise ValueError(
"Board memory size can only be one of: 1 for 1M, 2 for 2M, 4 for 4M"
)
if arduino_core != "2_3_0":
env_prefix = "{}-{}".format(env_prefix, arduino_core)
return "{env_prefix}-{size:d}m-ota".format(env_prefix=env_prefix, size=size)
def main(args): def main(args):
print() print()
@ -431,7 +457,7 @@ def main(args):
if args.core: if args.core:
board["flags"] = "-DESPURNA_CORE " + board["flags"] board["flags"] = "-DESPURNA_CORE " + board["flags"]
env = "esp8266-{:d}m-ota".format(board["size"])
env = get_platformio_env(args.arduino_core, board["size"])
# Summary # Summary
print() print()


+ 58
- 949
code/platformio.ini
File diff suppressed because it is too large
View File


+ 461
- 0
code/platformio_ota.ini View File

@ -0,0 +1,461 @@
# ------------------------------------------------------------------------------
# Backwards compatibility for -ota envs
# Since 1.14.2, any env: section will use ESPURNA_... contents
# ------------------------------------------------------------------------------
[env:wemos-d1mini-relayshield-ota]
extends = env:wemos-d1mini-relayshield
[env:nodemcu-lolin-ota]
extends = env:nodemcu-lolin
[env:tinkerman-espurna-h06-ota]
extends = env:tinkerman-espurna-h06
[env:tinkerman-espurna-h08-ota]
extends = env:tinkerman-espurna-h08
[env:foxel-lightfox-dual-ota]
extends = env:foxel-lightfox-dual
[env:itead-sonoff-basic-ota]
extends = env:itead-sonoff-basic
[env:itead-sonoff-basic-dht-ota]
extends = env:itead-sonoff-basic-dht
[env:itead-sonoff-rf-ota]
extends = env:itead-sonoff-rf
[env:itead-sonoff-mini-ota]
extends = env:itead-sonoff-mini
[env:itead-sonoff-th-ota]
extends = env:itead-sonoff-th
[env:itead-sonoff-pow-ota]
extends = env:itead-sonoff-pow
[env:itead-sonoff-pow-r2-ota]
extends = env:itead-sonoff-pow-r2
[env:itead-sonoff-dual-ota]
extends = env:itead-sonoff-dual
[env:itead-sonoff-dual-r2-ota]
extends = env:itead-sonoff-dual-r2
[env:itead-sonoff-4ch-ota]
extends = env:itead-sonoff-4ch
[env:itead-sonoff-4ch-pro-ota]
extends = env:itead-sonoff-4ch-pro
[env:itead-sonoff-touch-ota]
extends = env:itead-sonoff-touch
[env:itead-sonoff-b1-ota]
extends = env:itead-sonoff-b1
[env:itead-sonoff-t1-1ch-ota]
extends = env:itead-sonoff-t1-1ch
[env:itead-sonoff-t1-2ch-ota]
extends = env:itead-sonoff-t1-2ch
[env:itead-sonoff-t1-3ch-ota]
extends = env:itead-sonoff-t1-3ch
[env:itead-sonoff-led-ota]
extends = env:itead-sonoff-led
[env:itead-sonoff-rfbridge-ota]
extends = env:itead-sonoff-rfbridge
[env:itead-sonoff-rfbridge-direct-ota]
extends = env:itead-sonoff-rfbridge-direct
[env:itead-slampher-ota]
extends = env:itead-slampher
[env:itead-s20-ota]
extends = env:itead-s20
[env:itead-1ch-inching-ota]
extends = env:itead-1ch-inching
[env:itead-motor-ota]
extends = env:itead-motor
[env:itead-sonoff-sv-ota]
extends = env:itead-sonoff-sv
[env:itead-sonoff-s31-ota]
extends = env:itead-sonoff-s31
[env:itead-sonoff-s31-lite-ota]
extends = env:itead-sonoff-s31-lite
[env:itead-sonoff-ifan02-ota]
extends = env:itead-sonoff-ifan02
[env:electrodragon-wifi-iot-ota]
extends = env:electrodragon-wifi-iot
[env:workchoice-ecoplug-ota]
extends = env:workchoice-ecoplug
[env:jangoe-wifi-relay-nc-ota]
extends = env:jangoe-wifi-relay-nc
[env:jangoe-wifi-relay-no-ota]
extends = env:jangoe-wifi-relay-no
[env:openenergymonitor-mqtt-relay-ota]
extends = env:openenergymonitor-mqtt-relay
[env:jorgegarcia-wifi-relays-ota]
extends = env:jorgegarcia-wifi-relays
[env:aithinker-ai-light-ota]
extends = env:aithinker-ai-light
[env:lyasi-rgb-light-ota]
extends = env:lyasi-rgb-light
[env:magichome-led-controller-ota]
extends = env:magichome-led-controller
[env:magichome-led-controller-20-ota]
extends = env:magichome-led-controller-20
[env:magichome-zj-wfmn-a-11-ota]
extends = env:magichome-zj-wfmn-a-11
[env:magichome-zj-wfmn-b-11-ota]
extends = env:magichome-zj-wfmn-b-11
[env:magichome-zj-espm-5ch-b-13-ota]
extends = env:magichome-zj-espm-5ch-b-13
[env:magichome-zj-lb-rgbww-l-ota]
extends = env:magichome-zj-lb-rgbww-l
[env:magichome-zj-wfmn-c-11-ota]
extends = env:magichome-zj-wfmn-c-11
[env:huacanxing-h801-ota]
extends = env:huacanxing-h801
[env:huacanxing-h802-ota]
extends = env:huacanxing-h802
[env:arilux-al-lc01-ota]
extends = env:arilux-al-lc01
[env:arilux-al-lc02-ota]
extends = env:arilux-al-lc02
[env:arilux-al-lc02-v14-ota]
extends = env:arilux-al-lc02-v14
[env:arilux-al-lc06-ota]
extends = env:arilux-al-lc06
[env:arilux-al-lc11-ota]
extends = env:arilux-al-lc11
[env:arilux-e27-ota]
extends = env:arilux-e27
[env:itead-bnsz01-ota]
extends = env:itead-bnsz01
[env:wion-50055-ota]
extends = env:wion-50055
[env:exs-wifi-relay-v31-ota]
extends = env:exs-wifi-relay-v31
[env:exs-wifi-relay-v50-ota]
extends = env:exs-wifi-relay-v50
[env:wemos-v9261f-ota]
extends = env:wemos-v9261f
[env:esp01-v9261f-ota]
extends = env:esp01-v9261f
[env:wemos-ech1560-ota]
extends = env:wemos-ech1560
[env:esp01-ech1560-ota]
extends = env:esp01-ech1560
[env:mancavemade-esplive-ota]
extends = env:mancavemade-esplive
[env:intermittech-quinled-ota]
extends = env:intermittech-quinled
[env:xenon-sm-pw702u-ota]
extends = env:xenon-sm-pw702u
[env:iselector-sm-pw702-ota]
extends = env:iselector-sm-pw702
[env:authometion-lyt8266-ota]
extends = env:authometion-lyt8266
[env:kmc-70011-ota]
extends = env:kmc-70011
[env:yjzk-switch-1ch-ota]
extends = env:yjzk-switch-1ch
[env:yjzk-switch-2ch-ota]
extends = env:yjzk-switch-2ch
[env:yjzk-switch-3ch-ota]
extends = env:yjzk-switch-3ch
[env:gizwits-witty-cloud-ota]
extends = env:gizwits-witty-cloud
[env:euromate-wifi-stecker-shuko-ota]
extends = env:euromate-wifi-stecker-shuko
[env:euromate-wifi-stecker-shuko-v2-ota]
extends = env:euromate-wifi-stecker-shuko-v2
[env:tonbux-powerstrip02-ota]
extends = env:tonbux-powerstrip02
[env:lingan-swa1-ota]
extends = env:lingan-swa1
[env:stm-relay-ota]
extends = env:stm-relay
[env:heygo-hy02-ota]
extends = env:heygo-hy02
[env:maxcio-wus002s-ota]
extends = env:maxcio-wus002s
[env:maxcio-wde004-ota]
extends = env:maxcio-wde004
[env:yidian-xsssa05-ota]
extends = env:yidian-xsssa05
[env:oukitel-p1-ota]
extends = env:oukitel-p1
[env:tonbux-xsssa01-ota]
extends = env:tonbux-xsssa01
[env:tonbux-xsssa06-ota]
extends = env:tonbux-xsssa06
[env:green-esp8266relay-ota]
extends = env:green-esp8266relay
[env:ike-espike-ota]
extends = env:ike-espike
[env:arniex-swifitch-ota]
extends = env:arniex-swifitch
[env:zhilde-eu44-w-ota]
extends = env:zhilde-eu44-w
[env:luani-hvio-ota]
extends = env:luani-hvio
[env:avatto-power-plug-wifi-ota]
extends = env:avatto-power-plug-wifi
[env:neo-coolcam-power-plug-wifi-ota]
extends = env:neo-coolcam-power-plug-wifi
[env:deltaco-sh-p01-ota]
extends = env:deltaco-sh-p01
[env:deltaco-sh-p03usb-ota]
extends = env:deltaco-sh-p03usb
[env:deltaco-sh-lexxw-ota]
extends = env:deltaco-sh-lexxw
[env:deltaco-sh-lexxrgb-ota]
extends = env:deltaco-sh-lexxrgb
[env:estink-wifi-power-strip-ota]
extends = env:estink-wifi-power-strip
[env:iwoole-led-table-lamp-ota]
extends = env:iwoole-led-table-lamp
[env:lombex-lux-nova2-tunable-white-ota]
extends = env:lombex-lux-nova2-tunable-white
[env:lombex-lux-nova2-white-color-ota]
extends = env:lombex-lux-nova2-white-color
[env:generic-esp01s-relay-40-ota]
extends = env:generic-esp01s-relay-40
[env:generic-esp01s-relay-40-inv-ota]
extends = env:generic-esp01s-relay-40-inv
[env:generic-esp01s-rgbled-10-ota]
extends = env:generic-esp01s-rgbled-10
[env:generic-esp01s-dht11-10-ota]
extends = env:generic-esp01s-dht11-10
[env:generic-esp01s-ds18b20-10-ota]
extends = env:generic-esp01s-ds18b20-10
[env:heltec-touch-relay-ota]
extends = env:heltec-touch-relay
[env:allnet-4duino-iot-wlan-relais-ota]
extends = env:allnet-4duino-iot-wlan-relais
[env:tonbux-mosquito-killer-ota]
extends = env:tonbux-mosquito-killer
[env:pilotak-esp-din-v1-ota]
extends = env:pilotak-esp-din-v1
[env:nodemcu-geiger-ota]
extends = env:nodemcu-geiger
[env:blitzwolf-bwshpx-ota]
extends = env:blitzwolf-bwshpx
[env:blitzwolf-bwshpx-v23-ota]
extends = env:blitzwolf-bwshpx-v23
[env:blitzwolf-bwshp5-ota]
extends = env:blitzwolf-bwshp5
[env:teckin-sp21-ota]
extends = env:teckin-sp21
[env:teckin-sp22-v14-ota]
extends = env:teckin-sp22-v14
[env:gosund-ws1-ota]
extends = env:gosund-ws1
[env:digoo-nx-sp202-ota]
extends = env:digoo-nx-sp202
[env:tflag-nx-smx00-ota]
extends = env:tflag-nx-smx00
[env:homecube-16a-ota]
extends = env:homecube-16a
[env:bh-onofre-ota]
extends = env:bh-onofre
[env:generic-ag-l4-ota]
extends = env:generic-ag-l4
[env:lohas-e27-9w-ota]
extends = env:lohas-e27-9w
[env:lohas-e26-a19-ota]
extends = env:lohas-e26-a19
[env:teckin-sb53-ota]
extends = env:teckin-sb53
[env:allterco-shelly1-ota]
extends = env:allterco-shelly1
[env:allterco-shelly2-ota]
extends = env:allterco-shelly2
[env:allterco-shelly1pm-ota]
extends = env:allterco-shelly1pm
[env:allterco-shelly25-ota]
extends = env:allterco-shelly25
[env:xiaomi-smart-desk-lamp-ota]
extends = env:xiaomi-smart-desk-lamp
[env:phyx-esp12-rgb-ota]
extends = env:phyx-esp12-rgb
[env:bestek-mrj1011-ota]
extends = env:bestek-mrj1011
[env:gblife-rgbw-socket-ota]
extends = env:gblife-rgbw-socket
[env:smartlife-mini-smart-socket-ota]
extends = env:smartlife-mini-smart-socket
[env:hama-wifi-steckdose-00176533-ota]
extends = env:hama-wifi-steckdose-00176533
[env:teckin-sp20-ota]
extends = env:teckin-sp20
[env:litesun-la-wf3-ota]
extends = env:litesun-la-wf3
[env:generic-gu10-ota]
extends = env:generic-gu10
[env:generic-e14-ota]
extends = env:generic-e14
[env:nexete-a19-ota]
extends = env:nexete-a19
[env:psh-wifi-plug-ota]
extends = env:psh-wifi-plug
[env:psh-rgbw-controller-ota]
extends = env:psh-rgbw-controller
[env:psh-wifi-sensor-ota]
extends = env:psh-wifi-sensor
[env:jinvoo-valve-sm-aw713-ota]
extends = env:jinvoo-valve-sm-aw713
[env:etekcity-esw01-usa-ota]
extends = env:etekcity-esw01-usa
[env:fs-uap1-ota]
extends = env:fs-uap1
[env:muvit-io-miobulb001-ota]
extends = env:muvit-io-miobulb001
[env:hykker-smart-home-power-plug-ota]
extends = env:hykker-smart-home-power-plug
[env:kogan-smarter-home-plug-w-pow-ota]
extends = env:kogan-smarter-home-plug-w-pow
[env:lsc-smart-led-light-strip-ota]
extends = env:lsc-smart-led-light-strip
[env:linksprite-linknode-r4-ota]
extends = env:linksprite-linknode-r4
[env:ehomediy-wt02-ota]
extends = env:ehomediy-wt02
[env:ehomediy-wt03-ota]
extends = env:ehomediy-wt03

+ 12
- 0
code/scripts/espurna_utils/__init__.py View File

@ -25,3 +25,15 @@ from .ldscripts import ldscripts_inject_libpath
from .lwip import lwip_inject_patcher from .lwip import lwip_inject_patcher
from .postmortem import dummy_ets_printf from .postmortem import dummy_ets_printf
from .git import app_inject_revision from .git import app_inject_revision
from .flags import app_inject_flags
__all__ = [
"check_cppcheck",
"check_printsize",
"remove_float_support",
"ldscripts_inject_libpath",
"lwip_inject_patcher",
"dummy_ets_printf",
"app_inject_revision",
"app_inject_flags",
]

+ 10
- 0
code/scripts/espurna_utils/flags.py View File

@ -0,0 +1,10 @@
def app_inject_flags(projenv):
# in theory, could be something different from a single cppdefine, keeping separate from flags below
board = projenv.get("ESPURNA_BOARD", "")
if board:
projenv.Append(CPPDEFINES=[board])
# only CPPDEFINES make sense here, since we should not change any others
flags = projenv.get("ESPURNA_FLAGS", "")
if flags:
projenv.MergeFlags({"CPPDEFINES": projenv.ParseFlags(flags)["CPPDEFINES"]})

+ 15
- 2
code/scripts/pio_main.py View File

@ -1,4 +1,13 @@
# Run this script every time building an env:
# coding=utf-8
# pylint: dummy-variables-rgx='(_+[a-zA-Z0-9]*?$)|dummy|env|projenv'
#
# Original extra_scripts.py
# Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#
# ldscripts, lwip patching, updated postmortem flags and git support
# Copyright (C) 2019-2020 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
# Run this script every time building an env AFTER platform-specific code is loaded
from espurna_utils import ( from espurna_utils import (
check_printsize, check_printsize,
@ -6,7 +15,8 @@ from espurna_utils import (
ldscripts_inject_libpath, ldscripts_inject_libpath,
lwip_inject_patcher, lwip_inject_patcher,
app_inject_revision, app_inject_revision,
dummy_ets_printf
dummy_ets_printf,
app_inject_flags,
) )
Import("env", "projenv") Import("env", "projenv")
@ -37,3 +47,6 @@ lwip_inject_patcher(env)
# when using git, add -DAPP_REVISION=(git-commit-hash) # when using git, add -DAPP_REVISION=(git-commit-hash)
app_inject_revision(projenv) app_inject_revision(projenv)
# handle OTA board and flags here, since projenv is not available in pre-scripts
app_inject_flags(projenv)

+ 41
- 8
code/scripts/pio_pre.py View File

@ -1,3 +1,14 @@
# coding=utf-8
# pylint: dummy-variables-rgx='(_+[a-zA-Z0-9]*?$)|dummy|env'
#
# Original extra_scripts.py
# Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#
# ldscripts, lwip patching, updated postmortem flags and git support
# Copyright (C) 2019-2020 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
# Run this script every time building an env BEFORE platform-specific code is loaded
from __future__ import print_function from __future__ import print_function
Import("env") Import("env")
@ -6,15 +17,24 @@ import os
import sys import sys
from SCons.Script import ARGUMENTS
TRAVIS = os.environ.get("TRAVIS") TRAVIS = os.environ.get("TRAVIS")
PIO_PLATFORM = env.PioPlatform() PIO_PLATFORM = env.PioPlatform()
CONFIG = env.GetProjectConfig() CONFIG = env.GetProjectConfig()
VERBOSE = "1" == ARGUMENTS.get("PIOVERBOSE", "0")
class ExtraScriptError(Exception): class ExtraScriptError(Exception):
pass pass
def log(message, verbose=False, file=sys.stderr):
if verbose or VERBOSE:
print(message, file=file)
# Most portable way, without depending on platformio internals # Most portable way, without depending on platformio internals
def subprocess_libdeps(lib_deps, storage=None, silent=True): def subprocess_libdeps(lib_deps, storage=None, silent=True):
import subprocess import subprocess
@ -46,7 +66,7 @@ def library_manager_libdeps(lib_deps, storage=None):
for lib in lib_deps: for lib in lib_deps:
if manager.get_package_dir(*manager.parse_pkg_uri(lib)): if manager.get_package_dir(*manager.parse_pkg_uri(lib)):
continue continue
print("installing: {}".format(lib), file=sys.stderr)
log("installing: {}".format(lib))
manager.install(lib) manager.install(lib)
@ -68,14 +88,27 @@ def get_shared_libdeps_dir(section, name):
def ensure_platform_updated(): def ensure_platform_updated():
try: try:
if PIO_PLATFORM.are_outdated_packages(): if PIO_PLATFORM.are_outdated_packages():
print("updating platform packages", file=sys.stderr)
log("updating platform packages")
PIO_PLATFORM.update_packages() PIO_PLATFORM.update_packages()
except Exception: except Exception:
print(
"Warning: no connection, cannot check for outdated packages",
file=sys.stderr,
)
log("Warning: no connection, cannot check for outdated packages", verbose=True)
# handle OTA uploads
# using env instead of ini to fix platformio ini changing hash on every change
env.Append(
ESPURNA_BOARD=os.environ.get("ESPURNA_BOARD", ""),
ESPURNA_AUTH=os.environ.get("ESPURNA_AUTH", ""),
ESPURNA_FLAGS=os.environ.get("ESPURNA_FLAGS", "")
)
ESPURNA_OTA_PORT = os.environ.get("ESPURNA_IP")
if ESPURNA_OTA_PORT:
env.Replace(UPLOAD_PROTOCOL="espota")
env.Replace(UPLOAD_PORT=ESPURNA_OTA_PORT)
env.Replace(UPLOAD_FLAGS="--auth=$ESPURNA_AUTH")
else:
env.Replace(UPLOAD_PROTOCOL="esptool")
# latest toolchain is still optional with PIO (TODO: recheck after 2.6.0!) # latest toolchain is still optional with PIO (TODO: recheck after 2.6.0!)
# also updates arduino core git to the latest master commit # also updates arduino core git to the latest master commit
@ -88,9 +121,9 @@ if TRAVIS and (
if os.environ.get("ESPURNA_PIO_SHARED_LIBRARIES"): if os.environ.get("ESPURNA_PIO_SHARED_LIBRARIES"):
if TRAVIS: if TRAVIS:
storage = None storage = None
print("using global library storage", file=sys.stderr)
log("using global library storage")
else: else:
storage = get_shared_libdeps_dir("common", "shared_libdeps_dir") storage = get_shared_libdeps_dir("common", "shared_libdeps_dir")
print("using shared library storage: ", storage, file=sys.stderr)
log("using shared library storage: {}".format(storage))
subprocess_libdeps(env.GetProjectOption("lib_deps"), storage) subprocess_libdeps(env.GetProjectOption("lib_deps"), storage)

Loading…
Cancel
Save