mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-01 09:12:00 +08:00

* Update WebSocket library * Update SSDP library * Update TFT_eSPI library * Update EspLuaEngine library * Update SDFat library * Change to pioarduino * Make ESP3DMessageFIFO and ESP3DMessage more thread safe * Fix sanity checks for BT * Add some C6 support * Refactor ethernet code * Split Ethernet Sta / WiFi sta ESP Commands and settings * Simplify wait and wdtFeed code * Set C3 with 4MB by default in platformio.ini * Apply Disable brown out only on ESP32 to avoid crash e.g:ESP32S3 * Add missing entries in platformio.ini
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
#!/usr/bin/python
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
def format_sources():
|
|
"""
|
|
Formats the source code files in the ESP3D project using clang-format with Google style.
|
|
|
|
This script recursively searches for C, C++, H, and INO files in the ESP3D project directory
|
|
and its subdirectories. It then applies the clang-format tool to each file, using the Google
|
|
style for formatting.
|
|
|
|
Note: Make sure you have clang-format installed and available in your system's PATH.
|
|
|
|
Returns:
|
|
None
|
|
"""
|
|
# Base directory of the script
|
|
script_path = os.path.abspath(__file__)
|
|
|
|
# Extract dir path
|
|
script_dir = os.path.dirname(script_path)
|
|
|
|
# Build path of sources dir: ../esp3d
|
|
src_dir = os.path.abspath(os.path.normpath(os.path.join(script_dir, '..', 'src')))
|
|
examples_dir = os.path.abspath(os.path.normpath(os.path.join(script_dir, '..', 'examples')))
|
|
|
|
# Parse all c, h, cpp, and ino files in all directories and subdirectories
|
|
file_paths = []
|
|
for base_dir in [src_dir, examples_dir]:
|
|
for root, dirs, files in os.walk(base_dir):
|
|
for file in files:
|
|
if file.endswith(('.c', '.cpp', '.h', '.ino')):
|
|
file_path = os.path.join(root, file)
|
|
file_paths.append(os.path.abspath(os.path.normpath(file_path)))
|
|
|
|
# Now format all files one by one with clang-format
|
|
for file_path in file_paths:
|
|
tmpPath = '"' + file_path + '"'
|
|
print("Formatting " + tmpPath, end="")
|
|
try:
|
|
command = ['clang-format', '-i', '--style=Google', file_path]
|
|
subprocess.run(command, check=False)
|
|
print(" => Ok")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f'=> Error: {e}')
|
|
|
|
# Call the format_sources function to format the source code
|
|
format_sources()
|