2025-01-07 16:49:18 +03:00
|
|
|
|
Import("env")
|
2024-11-22 22:45:10 +03:00
|
|
|
|
import json
|
|
|
|
|
|
import os
|
|
|
|
|
|
import shutil
|
|
|
|
|
|
from sys import platform
|
|
|
|
|
|
|
2025-01-07 16:49:18 +03:00
|
|
|
|
pio_home = env.subst("$PROJECT_CORE_DIR")
|
2025-01-07 17:02:35 +03:00
|
|
|
|
print("PLATFORMIO_DIR" + pio_home)
|
2025-01-07 16:49:18 +03:00
|
|
|
|
|
2024-11-22 22:45:10 +03:00
|
|
|
|
if platform == "linux" or platform == "linux2":
|
|
|
|
|
|
# linux
|
2025-01-07 16:49:18 +03:00
|
|
|
|
#devkitm = '/home/rise/.platformio/platforms/espressif32/boards/esp32-c6-devkitm-1.json'
|
|
|
|
|
|
#devkitc = '/home/rise/.platformio/platforms/espressif32/boards/esp32-c6-devkitc-1.json'
|
|
|
|
|
|
devkitm = pio_home + '/platforms/espressif32/boards/esp32-c6-devkitm-1.json'
|
|
|
|
|
|
devkitc = pio_home + '/platforms/espressif32/boards/esp32-c6-devkitc-1.json'
|
2024-11-22 22:45:10 +03:00
|
|
|
|
else:
|
|
|
|
|
|
# windows
|
2025-01-07 16:49:18 +03:00
|
|
|
|
devkitm = pio_home + '\\platforms\\espressif32\\boards\\esp32-c6-devkitm-1.json'
|
|
|
|
|
|
devkitc = pio_home + '\\platforms\\espressif32\\boards\\esp32-c6-devkitc-1.json'
|
2024-11-22 22:45:10 +03:00
|
|
|
|
|
|
|
|
|
|
def add_arduino_to_frameworks(file_name):
|
2024-11-27 01:00:43 +03:00
|
|
|
|
try:
|
|
|
|
|
|
with open(file_name, 'r+') as f:
|
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
frameworks = data['frameworks']
|
|
|
|
|
|
if 'arduino' not in frameworks:
|
|
|
|
|
|
frameworks.insert(frameworks.index('espidf') + 1, 'arduino')
|
|
|
|
|
|
data['frameworks'] = frameworks
|
|
|
|
|
|
f.seek(0)
|
|
|
|
|
|
json.dump(data, f, indent=4)
|
|
|
|
|
|
f.truncate()
|
2025-01-07 17:02:35 +03:00
|
|
|
|
print(f"Файл изменён, ОК! {file_name}")
|
2024-11-27 01:00:43 +03:00
|
|
|
|
else:
|
|
|
|
|
|
print(f"Arduino already exists in {file_name}")
|
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
|
print("Файл не найден или не удается открыть")
|
2024-11-22 22:45:10 +03:00
|
|
|
|
|
|
|
|
|
|
if os.path.exists(devkitm) and os.path.exists(devkitc):
|
|
|
|
|
|
add_arduino_to_frameworks(devkitm)
|
|
|
|
|
|
add_arduino_to_frameworks(devkitc)
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("One or both files do not exist.")
|