Skip to content

Commit

Permalink
made the cpp file script platform independant
Browse files Browse the repository at this point in the history
  • Loading branch information
qfisch committed Feb 9, 2024
1 parent ba30b1c commit 5493cbe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion py_scripts/make_cpp_files.py
Original file line number Diff line number Diff line change
@@ -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.")

0 comments on commit 5493cbe

Please sign in to comment.