Skip to content

Commit 7c40ac0

Browse files
committed
added dependency script
1 parent 9aeb965 commit 7c40ac0

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/libraries.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
33
"git_url": "https://github.com/vinniefalco/DSPFilters.git",
4-
"subdir": "shared/DSPFilters"
4+
"root_dir": "shared/DSPFilters"
55
}
66
]

src/update_dependencies.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This script does not need to be edited manually
2+
3+
from pathlib import Path
4+
import json
5+
import os
6+
import sys
7+
import shutil
8+
9+
with open("libraries.json", "r") as file:
10+
libraries = json.load(file)
11+
12+
# change CWD to Arduino libraries folder
13+
arduino_lib_path = os.path.join(Path.home(), "Documents", "Arduino", "libraries")
14+
print(f"Changing working directory to {arduino_lib_path}")
15+
os.chdir(arduino_lib_path)
16+
17+
for library in libraries:
18+
repo_name = library["git_url"].split("/")[-1].replace(".git", "")
19+
if Path(repo_name).exists():
20+
shutil.rmtree(repo_name)
21+
22+
os.system(f"git clone {library["git_url"]}")
23+
os.chdir(os.path.join(arduino_lib_path, repo_name))
24+
if not os.path.exists(library["root_dir"]):
25+
print(f"Error: Subdirectory {library["root_dir"]} does not exist.")
26+
sys.exit(1)
27+
else:
28+
os.system(f"git sparse-checkout set --no-cone {library["root_dir"]}")
29+
shutil.copytree(library["root_dir"], os.getcwd(), dirs_exist_ok=True)
30+
shutil.rmtree(library["root_dir"].split("/")[0])
31+
print(f"Moved {library["root_dir"]} to be the root of {repo_name}")

0 commit comments

Comments
 (0)