Files
rt-thread/bsp/renesas/tools/startup_check.py
CYFS 88d0eb0080
Some checks failed
ToolsCI / Tools (push) Has been cancelled
AutoTestCI / components/cpp11 (push) Has been cancelled
AutoTestCI / kernel/atomic (push) Has been cancelled
AutoTestCI / kernel/atomic/riscv64 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11 (push) Has been cancelled
AutoTestCI / kernel/atomic_c11/riscv64 (push) Has been cancelled
AutoTestCI / kernel/device (push) Has been cancelled
AutoTestCI / kernel/ipc (push) Has been cancelled
AutoTestCI / kernel/irq (push) Has been cancelled
AutoTestCI / kernel/mem (push) Has been cancelled
AutoTestCI / kernel/mem/riscv64 (push) Has been cancelled
AutoTestCI / kernel/thread (push) Has been cancelled
AutoTestCI / kernel/timer (push) Has been cancelled
AutoTestCI / rtsmart/aarch64 (push) Has been cancelled
AutoTestCI / rtsmart/arm (push) Has been cancelled
AutoTestCI / rtsmart/riscv64 (push) Has been cancelled
AutoTestCI / components/utest (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
[bsp][renesas]add EK-RA2A1 support #10610
2025-08-24 17:27:05 +08:00

71 lines
2.3 KiB
Python

import subprocess
import sys
import os
def check_git_exists():
try:
# Check if Git is installed
subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError:
return False
return True
def install_git():
if sys.version_info[0] == 2:
version_cmd = subprocess.call
else:
version_cmd = subprocess.run
# Install Git based on the operating system type
system = sys.platform.lower()
if "linux" in system:
version_cmd(["sudo", "apt-get", "install", "git"])
elif "darwin" in system:
version_cmd(["brew", "install", "git"])
elif "win" in system:
print("Please manually install Git and ensure it is added to the system PATH.")
sys.exit(1)
def check_file_changes(filepath):
# Use Git to check the file status
result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, _ = result.communicate()
# Return True if the file has changes
return bool(out.decode('utf-8'))
def revert_to_original(filepath):
# Use Git to revert the file to its original state
subprocess.call(["git", "checkout", filepath])
def startup_check():
file_path = os.getcwd() + "/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c"
python_executable = 'python' if sys.version_info[0] == 2 else 'python3'
# Check if Git is installed, if not, try to install it
if not check_git_exists():
print("Git not detected, attempting to install...")
install_git()
# Check if Git is installed after the installation attempt
if not check_git_exists():
print("Git installation failed. Please manually install Git and add it to the system PATH.")
sys.exit(1)
# Check if the file has changes
if check_file_changes(file_path):
# If changes are detected, revert the file to its original state
revert_to_original(file_path)
# else:
# print "File {file_path} is unchanged."
# rm bsp_linker_info.h
file_to_remove = "bsp_linker_info.h"
if os.path.exists(file_to_remove):
print(f"Removing {file_to_remove} before build...")
os.remove(file_to_remove)
if __name__ == "__main__":
startup_check()