Compare commits
No commits in common. "7351c8d46adfee940242cbc284581db340f681d9" and "4c54da6e34fa632a76963ed015e069ea8e032fb1" have entirely different histories.
7351c8d46a
...
4c54da6e34
|
@ -2,15 +2,13 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
import re
|
|
||||||
import configparser
|
|
||||||
from time import sleep as delay
|
|
||||||
|
|
||||||
|
|
||||||
# Get the current directory
|
# Get the current directory
|
||||||
|
@ -32,68 +30,37 @@ os.makedirs(release_folder)
|
||||||
|
|
||||||
# Get the current Git branch name
|
# Get the current Git branch name
|
||||||
git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip()
|
git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip()
|
||||||
commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode().strip()[:10]
|
|
||||||
|
|
||||||
# If arguments are supplied, build the environments that match the arguments
|
# Build the PlatformIO project
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
|
# If arguments are supplied, build the environments that match the arguments
|
||||||
environments = sys.argv[1:]
|
environments = sys.argv[1:]
|
||||||
|
for environment in environments:
|
||||||
# If no argument are supplied, build all environments listed in platformio.ini
|
subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment], cwd=current_dir)
|
||||||
|
|
||||||
|
# Iterate over the subfolders in the firmware folder
|
||||||
|
for subfolder in os.listdir(firmware_folder):
|
||||||
|
subfolder_path = os.path.join(firmware_folder, subfolder)
|
||||||
|
|
||||||
|
# Check if the subfolder matches the environment argument
|
||||||
|
if subfolder == environment:
|
||||||
|
# Check if the subfolder contains a firmware.bin file
|
||||||
|
firmware_file = os.path.join(subfolder_path, 'firmware.bin')
|
||||||
|
if os.path.isfile(firmware_file):
|
||||||
|
# Move the firmware.bin file to the release folder with the Git branch name appended
|
||||||
|
new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin")
|
||||||
|
shutil.move(firmware_file, new_file_name)
|
||||||
else:
|
else:
|
||||||
environments = []
|
# If no argument is supplied, build all environments
|
||||||
with open(os.path.join(current_dir, 'platformio.ini')) as f:
|
subprocess.run([f'{platformio_path}/platformio.exe', 'run'], cwd=current_dir)
|
||||||
|
|
||||||
# Iterate over the lines in platformio.ini
|
|
||||||
for line in f.readlines():
|
|
||||||
|
|
||||||
# Check if the line contains the string "env:"
|
|
||||||
if '[env:' in line:
|
|
||||||
|
|
||||||
# Extract the environment using regular expressions
|
|
||||||
environment = re.search(r'\[env:(.*?)\]', line).group(1)
|
|
||||||
|
|
||||||
# Add the environment to the list of environments
|
|
||||||
environments.append(environment)
|
|
||||||
|
|
||||||
# Remove old platformio.ini file from firmware folder if it exists
|
|
||||||
if os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')):
|
|
||||||
os.remove(os.path.join(firmware_folder, 'platformio.ini'))
|
|
||||||
|
|
||||||
# Copy the platformio.ini file to the firmware folder
|
|
||||||
shutil.copyfile(os.path.join(current_dir, 'platformio.ini'), os.path.join(firmware_folder, 'platformio.ini'))
|
|
||||||
|
|
||||||
# Check that the file is copied correctly
|
|
||||||
if not os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')):
|
|
||||||
raise Exception('platformio.ini file not copied correctly')
|
|
||||||
|
|
||||||
# Read the platformio.ini file
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.read(os.path.join(firmware_folder, 'platformio.ini'))
|
|
||||||
|
|
||||||
# Add firmware version to build_flags in platformio.ini
|
|
||||||
for environment in environments:
|
|
||||||
if 'build_flags' not in config[f'env:{environment}']:
|
|
||||||
config[f'env:{environment}']['build_flags'] = f'-DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"'
|
|
||||||
else:
|
|
||||||
config[f'env:{environment}']['build_flags'] = config[f'env:{environment}']['build_flags'] + f' -DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"'
|
|
||||||
|
|
||||||
# if argument is not supplied, build all environments listed in platformio.ini
|
|
||||||
if len(sys.argv) == 1:
|
|
||||||
subprocess.run([f'{platformio_path}/platformio.exe', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir)
|
|
||||||
|
|
||||||
for environment in environments:
|
|
||||||
if(len(sys.argv) > 1):
|
|
||||||
subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir)
|
|
||||||
|
|
||||||
# Iterate over the subfolders in the firmware folder
|
# Iterate over the subfolders in the firmware folder
|
||||||
for subfolder in os.listdir(firmware_folder):
|
for subfolder in os.listdir(firmware_folder):
|
||||||
subfolder_path = os.path.join(firmware_folder, subfolder)
|
subfolder_path = os.path.join(firmware_folder, subfolder)
|
||||||
|
|
||||||
# Check if the subfolder matches the environment argument
|
# Check if the subfolder contains a firmware.bin file
|
||||||
if subfolder == environment:
|
firmware_file = os.path.join(subfolder_path, 'firmware.bin')
|
||||||
# Check if the subfolder contains a firmware.bin file
|
if os.path.isfile(firmware_file):
|
||||||
firmware_file = os.path.join(subfolder_path, 'firmware.bin')
|
# Move the firmware.bin file to the release folder with the Git branch name appended
|
||||||
if os.path.isfile(firmware_file):
|
new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin")
|
||||||
# Move the firmware.bin file to the release folder with the Git branch name and commit hash appended
|
shutil.move(firmware_file, new_file_name)
|
||||||
new_file_name = os.path.join(release_folder, f"{git_branch}_{subfolder}_{commit_hash}.bin")
|
|
||||||
shutil.move(firmware_file, new_file_name)
|
|
||||||
|
|
|
@ -395,11 +395,6 @@ void ota_begin()
|
||||||
otabuffer+=ota_part2_1+"IP Address"+ota_part2_2+IP.toString()+ota_part2_3;
|
otabuffer+=ota_part2_1+"IP Address"+ota_part2_2+IP.toString()+ota_part2_3;
|
||||||
otabuffer+=ota_part2_1+"MAC Address"+ota_part2_2+ETH.macAddress()+ota_part2_3;
|
otabuffer+=ota_part2_1+"MAC Address"+ota_part2_2+ETH.macAddress()+ota_part2_3;
|
||||||
otabuffer+=ota_part2_1+"Device"+ota_part2_2+ESPMEGA_REV+ota_part2_3;
|
otabuffer+=ota_part2_1+"Device"+ota_part2_2+ESPMEGA_REV+ota_part2_3;
|
||||||
#ifdef FW_VERSION
|
|
||||||
otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+FW_VERSION+ota_part2_3;
|
|
||||||
#else
|
|
||||||
otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+"Out of Tree"+ota_part2_3;
|
|
||||||
#endif
|
|
||||||
otabuffer+=ota_part2_1+"BMS Server"+ota_part2_2+MQTT_SERVER.toString()+ota_part2_3;
|
otabuffer+=ota_part2_1+"BMS Server"+ota_part2_2+MQTT_SERVER.toString()+ota_part2_3;
|
||||||
otabuffer+=ota_part2_1+"BMS Endpoint"+ota_part2_2+String(MQTT_BASE_TOPIC)+ota_part2_3;
|
otabuffer+=ota_part2_1+"BMS Endpoint"+ota_part2_2+String(MQTT_BASE_TOPIC)+ota_part2_3;
|
||||||
otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2;
|
otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2;
|
||||||
|
|
Loading…
Reference in New Issue