-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_server.py
More file actions
46 lines (35 loc) · 1.47 KB
/
Copy pathbuild_server.py
File metadata and controls
46 lines (35 loc) · 1.47 KB
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
#!/usr/bin/env python3
# SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
"""Build the Python web dashboard (C-ABI shared library + server + web assets).
Usage: python build_server.py
Assembles a ready-to-run folder (the shared library next to hardware_monitor_server.py and
web/). On Windows the matching signed PawnIO module is installed alongside so CPU
temperature/power work with no extra steps. Then just:
cd <dist> && python hardware_monitor_server.py # http://127.0.0.1:8000
"""
import os
import shutil
import sys
from build_common import cmake_build, find_output, install_pawnio
def main():
build_dir = cmake_build("webserver", "webserver/build")
dist = os.path.join(build_dir, "dist")
lib = find_output(
build_dir,
["hardware_monitor_cpp_c.dll", "libhardware_monitor_cpp_c.so", "libhardware_monitor_cpp_c.dylib"],
)
if not lib:
print("[x] The shared library was not produced.", file=sys.stderr)
return 1
# Multi-config generators (e.g. Visual Studio) drop the library into a
# config subfolder; make sure it sits directly next to hardware_monitor_server.py.
os.makedirs(dist, exist_ok=True)
if os.path.dirname(lib) != dist:
shutil.copy2(lib, dist)
install_pawnio(dist)
print("\n[+] Web dashboard build complete.")
print(f" folder : {dist}")
print(f" run : cd \"{dist}\" && python hardware_monitor_server.py")
return 0
if __name__ == "__main__":
sys.exit(main())