-
Notifications
You must be signed in to change notification settings - Fork 149
/
SConscript.py
50 lines (38 loc) · 1.26 KB
/
SConscript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# matth-x/MicroOcpp
# Copyright Matthias Akstaller 2019 - 2024
# MIT License
# NOTE: This SConscript is still WIP. It has thankfully been contributed from a project using SCons,
# not necessarily considering full reusability in other projects though.
# Use this file as a starting point for writing your own SCons integration. And as always, any
# contributions are highly welcome!
Import("env", "ARDUINOJSON_DIR")
import os, pathlib
def getAllDirs(root_dir):
dir_list = []
for root, subfolders, files in os.walk(root_dir.abspath):
dir_list.append(Dir(root))
return dir_list
SOURCE_DIR = Dir(".").srcnode()
source_dirs = getAllDirs(SOURCE_DIR.Dir("src"))
source_dirs += getAllDirs(ARDUINOJSON_DIR.Dir("src"))
source_files = []
for folder in source_dirs:
source_files += folder.glob("*.cpp")
env["CPPPATH"].append(folder)
compiled_objects = []
for source_file in source_files:
obj = env.Object(
target = pathlib.Path(source_file.path).stem
+ ".o",
source=source_file,
)
compiled_objects.append(obj)
libmicroocpp = env.StaticLibrary(
target='libmicroocpp',
source=sorted(compiled_objects)
)
exports = {
'library': libmicroocpp,
'CPPPATH': source_dirs.copy()
}
Return("exports")