refac `UPLOAD` no build (#18277)

This commit is contained in:
Jason2866 2023-03-27 11:46:40 +02:00 committed by GitHub
parent 9c01c3f6a0
commit 50dfd30148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -14,6 +14,7 @@ import sys
from os.path import isfile, join from os.path import isfile, join
from enum import Enum from enum import Enum
import os import os
import tasmotapiolib
import subprocess import subprocess
import shutil import shutil
@ -327,13 +328,11 @@ def upload_factory(*args, **kwargs):
esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py") esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py")
upload_speed = join(str(board.get("upload.speed", "115200"))) upload_speed = join(str(board.get("upload.speed", "115200")))
upload_port = join(env.get("UPLOAD_PORT", "none")) upload_port = join(env.get("UPLOAD_PORT", "none"))
cur_env = (env["PIOENV"]) target_firm = join(env.subst("$PROJECT_DIR"),tasmotapiolib.get_final_bin_path(env).with_suffix(".bin" if mcu == "esp8266" else (".factory.bin")))
firm_name = cur_env + "%s" % (".bin" if mcu == "esp8266" else (".factory.bin"))
target_firm = join(env.subst("$PROJECT_DIR"), "build_output","firmware",firm_name)
if "none" in upload_port: if "none" in upload_port:
env.AutodetectUploadPort() env.AutodetectUploadPort()
upload_port = join(env.get("UPLOAD_PORT", "none")) upload_port = join(env.get("UPLOAD_PORT", "none"))
if "tasmota" in cur_env: if "tasmota" in target_firm:
esptoolpy_flags = [ esptoolpy_flags = [
"--chip", mcu, "--chip", mcu,
"--port", upload_port, "--port", upload_port,

View File

@ -9,6 +9,7 @@
Import("env") Import("env")
import os import os
import tasmotapiolib
from os.path import isfile, join from os.path import isfile, join
import shutil import shutil
from SCons.Script import COMMAND_LINE_TARGETS from SCons.Script import COMMAND_LINE_TARGETS
@ -16,19 +17,19 @@ from SCons.Script import COMMAND_LINE_TARGETS
board_config = env.BoardConfig() board_config = env.BoardConfig()
if "nobuild" in COMMAND_LINE_TARGETS: if "nobuild" in COMMAND_LINE_TARGETS:
if not os.path.isfile(join(env.subst("$BUILD_DIR"),"firmware.bin")): prog_name = join(env.subst("$BUILD_DIR"),"firmware.bin")
if not os.path.isfile(prog_name):
#print ("No firmware in path:",join(env.subst("$BUILD_DIR"))) #print ("No firmware in path:",join(env.subst("$BUILD_DIR")))
env.CleanProject() env.CleanProject()
cur_env = (env["PIOENV"]) cur_env = (env["PIOENV"])
firm_name = cur_env + ".bin" firm_name = cur_env + ".bin"
source_firm = join(env.subst("$PROJECT_DIR"), "build_output","firmware",firm_name) source_firm = tasmotapiolib.get_final_bin_path(env)
if not os.path.exists(join(env.subst("$BUILD_DIR"))): if not os.path.exists(join(env.subst("$BUILD_DIR"))):
os.makedirs(join(env.subst("$BUILD_DIR"))) os.makedirs(join(env.subst("$BUILD_DIR")))
if os.path.isfile(source_firm): if os.path.isfile(source_firm):
shutil.copy(source_firm, join(env.subst("$BUILD_DIR"))) shutil.copy(source_firm, join(env.subst("$BUILD_DIR")))
target_ren = join(env.subst("$BUILD_DIR"), firm_name) target_ren = join(env.subst("$BUILD_DIR"), firm_name)
renamed = join(env.subst("$BUILD_DIR"), "firmware.bin") os.rename(target_ren, prog_name)
os.rename(target_ren, renamed)
if env["PIOPLATFORM"] != "espressif32": if env["PIOPLATFORM"] != "espressif32":
framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif8266") framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif8266")