-
Notifications
You must be signed in to change notification settings - Fork 647
/
Copy pathnanopb.py
executable file
·76 lines (60 loc) · 1.52 KB
/
nanopb.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
import os
import shutil
from upstream_utils import Lib, copy_to, walk_if
nanopb_sources = set(
[
"pb_encode.c",
"pb_decode.c",
"pb_common.c",
]
)
nanopb_headers = set(
[
"pb.h",
"pb_encode.h",
"pb_decode.h",
"pb_common.h",
]
)
nanopb_generator = set(
[
"pb.h",
"pb_encode.h",
"pb_decode.h",
"pb_common.h",
]
)
def copy_upstream_src(wpilib_root):
wpiutil = os.path.join(wpilib_root, "wpiutil")
# Delete old install
for d in [
"src/main/native/thirdparty/nanopb/src",
"src/main/native/thirdparty/nanopb/include",
"src/main/native/thirdparty/nanopb/generator",
]:
shutil.rmtree(os.path.join(wpiutil, d), ignore_errors=True)
# Copy nanopb source files into allwpilib
copy_to(
nanopb_sources,
os.path.join(wpiutil, "src/main/native/thirdparty/nanopb/src"),
rename_c_to_cpp=True,
)
# Copy nanopb header files into allwpilib
copy_to(
nanopb_headers,
os.path.join(wpiutil, "src/main/native/thirdparty/nanopb/include"),
)
generator_files = walk_if("generator", lambda dp, f: True)
copy_to(
generator_files,
os.path.join(wpiutil, "src/main/native/thirdparty/nanopb"),
)
def main():
name = "nanopb"
url = "https://github.com/nanopb/nanopb"
tag = "0.4.9"
nanopb = Lib(name, url, tag, copy_upstream_src)
nanopb.main()
if __name__ == "__main__":
main()