Files
Alex Wolf d317eb03a0
Code Generation / Code Generation (push) Failing after 8s
Static Checks / Static Checks (push) Failing after 3s
Compare file templates with file names / template-check (push) Has been cancelled
Push LVGL release to Espressif Component Service / upload_components (push) Has been cancelled
PlatformIO Publish / build (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify GDB constants are up-to-date / verify-gdb-consts (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Create Release / Create Release (push) Has been cancelled
Import lvgl (vendor @ 066d8db)
2026-07-31 02:41:18 -04:00

66 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import sys
# Argument enhancement: to only run `astyle` on a specified directory, to
# only include changed source code, these arguments have been added. If
# run with no arguments, all the normal directories are examined as before:
# - /demos/
# - /examples/
# - /src/
# - /tests/
#
# Args:
# If ANY args are specified, ONLY run `astyle` on the specified directories.
# Any combination can be specified.
include_demos = True
include_examples = True
include_src = True
include_tests = True
args = sys.argv[1:]
# Have any args been specified?
if args:
include_demos = False
include_examples = False
include_src = False
include_tests = False
for arg in args:
if arg == "demos":
include_demos = True
elif arg == "examples":
include_examples = True
elif arg == "src":
include_src = True
elif arg == "tests":
include_tests = True
else:
print(f'Argument [{arg}] not recognized.')
print('Usage:')
print(' python code-format.py [dir [dir ...]]')
print(' where: dir can be demos, examples, src or tests.')
exit(1)
script_dir = os.path.realpath(__file__)
script_dir = os.path.dirname(script_dir)
cfg_file = os.path.join(script_dir, 'code-format.cfg')
if include_demos:
print("\nFormatting demos")
os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../demos/*.c,*.cpp,*.h"')
if include_examples:
print("\nFormatting examples")
os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../examples/*.c,*.cpp,*.h"')
if include_src:
print("\nFormatting src")
os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../src/*.c,*.cpp,*.h"')
if include_tests:
print("\nFormatting tests")
os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../tests/*.c,*.cpp,*.h"')