Skip to content

Commit

Permalink
Target: Erase and Upload (#48)
Browse files Browse the repository at this point in the history
* Target: Erase Flash and Upload
* zopfli
* "version": "2022.12.1"
  • Loading branch information
Jason2866 authored Dec 22, 2022
1 parent bbb1759 commit 7ba31d4
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
51 changes: 50 additions & 1 deletion builder/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
http://arduino.cc/en/Reference/HomePage
"""

import subprocess
import json
import semantic_version
from os.path import join
from SCons.Script import DefaultEnvironment, SConscript

from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript
from platformio.package.version import pepver_to_semver

env = DefaultEnvironment()

Expand All @@ -46,3 +51,47 @@
SConscript(
join(DefaultEnvironment().PioPlatform().get_package_dir(
"framework-arduinoespressif32"), "tools", "platformio-build.py"))

def install_python_deps():
def _get_installed_pip_packages():
result = {}
packages = {}
pip_output = subprocess.check_output(
[env.subst("$PYTHONEXE"), "-m", "pip", "list", "--format=json"]
)
try:
packages = json.loads(pip_output)
except:
print("Warning! Couldn't extract the list of installed Python packages.")
return {}
for p in packages:
result[p["name"]] = pepver_to_semver(p["version"])

return result

deps = {
"zopfli": ">=0.2.2"
}

installed_packages = _get_installed_pip_packages()
packages_to_install = []
for package, spec in deps.items():
if package not in installed_packages:
packages_to_install.append(package)
else:
version_spec = semantic_version.Spec(spec)
if not version_spec.match(installed_packages[package]):
packages_to_install.append(package)

if packages_to_install:
env.Execute(
env.VerboseAction(
(
'"$PYTHONEXE" -m pip install -U --force-reinstall '
+ " ".join(['"%s%s"' % (p, deps[p]) for p in packages_to_install])
),
"Installing Python dependencies",
)
)

install_python_deps()
15 changes: 15 additions & 0 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,21 @@ def __fetch_fs_size(target, source, env):
env.AddPlatformTarget(
"uploadfsota", target_firm, upload_actions, "Upload Filesystem Image OTA")

#
# Target: Erase Flash and Upload
#

env.AddPlatformTarget(
"erase_upload",
target_firm,
[
env.VerboseAction(env.AutodetectUploadPort, "Looking for serial port..."),
env.VerboseAction("$ERASECMD", "Erasing..."),
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
],
"Erase Flash and Upload",
)

#
# Target: Erase Flash
#
Expand Down
2 changes: 1 addition & 1 deletion platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "git",
"url": "https://github.com/tasmota/platform-espressif32.git"
},
"version": "2022.12.0",
"version": "2022.12.1",
"frameworks": {
"arduino": {
"script": "builder/frameworks/arduino.py"
Expand Down

0 comments on commit 7ba31d4

Please sign in to comment.