From 9230e6df9bc79e6c4a21d225fbd8ea10f7aac277 Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Mon, 11 Dec 2023 21:28:09 +0800 Subject: [PATCH] feat(script): allow to run code-format.py outside of script/ (#4975) Signed-off-by: Xu Xingliang --- scripts/code-format.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/code-format.py b/scripts/code-format.py index 91c0128d9..6fe30caff 100755 --- a/scripts/code-format.py +++ b/scripts/code-format.py @@ -2,14 +2,18 @@ import os +script_dir = os.path.realpath(__file__) +script_dir = os.path.dirname(script_dir) +cfg_file = os.path.join(script_dir, 'code-format.cfg') + print("\nFormatting demos") -os.system('astyle --options=code-format.cfg --recursive "../demos/*.c,*.h"') +os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../demos/*.c,*.h"') print("\nFormatting examples") -os.system('astyle --options=code-format.cfg --recursive "../examples/*.c,*.h"') +os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../examples/*.c,*.h"') print("Formatting src") -os.system('astyle --options=code-format.cfg --recursive "../src/*.c,*.h"') +os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../src/*.c,*.h"') print("\nFormatting tests") -os.system('astyle --options=code-format.cfg --recursive "../tests/*.c,*.h"') +os.system(f'astyle --options={cfg_file} --recursive "{script_dir}/../tests/*.c,*.h"')