From 5493cbecd1cb5ee71f19e2edefa829300425e492 Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Fri, 9 Feb 2024 10:28:29 +0100 Subject: [PATCH] made the cpp file script platform independant --- py_scripts/make_cpp_files.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/py_scripts/make_cpp_files.py b/py_scripts/make_cpp_files.py index 389c629..405468d 100644 --- a/py_scripts/make_cpp_files.py +++ b/py_scripts/make_cpp_files.py @@ -1,5 +1,16 @@ import os +import shutil + +ARDUINO_FILE_EXTENSION = ".ino" +TARGET_FILE_EXTENSION = ".cpp" +EXAMPLE_FOLDER = "examples" # Create a .cpp file for all the .ino files in the examples dir (CAUTION: will overwrite existing) print("PRE_SCRIPT: Copying .ino file contents to .cpp files.") -os.system(f'find examples -type f -name "*.ino" -exec bash -c \'for file; do cp "$file" "$(dirname "$file")/$(basename "$file" .ino).cpp"; done\' _ {{}} +') +for e in os.listdir(EXAMPLE_FOLDER): + if os.path.isdir(f"{EXAMPLE_FOLDER}/{e}") and os.path.isfile(f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}"): + arduino_file =f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}" + cpp_file = f"{EXAMPLE_FOLDER}/{e}/{e}{TARGET_FILE_EXTENSION}" + shutil.copyfile(arduino_file, cpp_file) + print(f'\tcopied {arduino_file} to {cpp_file}') +print("\t>> Done.")