forked from bear-on-the-job/arcdps_healing_stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_dependency_versions.py
50 lines (39 loc) · 1.51 KB
/
get_dependency_versions.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
import os
import subprocess
from typing import List, NamedTuple
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
VCPKG_ROOT = "/local/vcpkg/"
VCPKG_PATH = os.path.join(VCPKG_ROOT, "vcpkg")
TRIPLET = "x64-linux"
MANIFEST_ROOT = SCRIPT_DIR
INSTALL_ROOT = os.path.join(MANIFEST_ROOT, "vcpkg_installed", TRIPLET)
VERSIONS_FILE = os.path.join(SCRIPT_DIR, "evtc_rpc_server", "linux_versions_auto.h")
class DependencyInfo(NamedTuple):
name: str
version: str
description: str
def get_dependency_versions() -> List[DependencyInfo]:
vcpkg_output = subprocess.run(
[VCPKG_PATH, "list", "--x-wait-for-lock", "--triplet", TRIPLET, "--vcpkg-root", VCPKG_ROOT, "--x-manifest-root", MANIFEST_ROOT, "--x-install-root", INSTALL_ROOT],
capture_output=True, universal_newlines=True)
assert vcpkg_output.returncode == 0
res = []
for line in vcpkg_output.stdout.splitlines():
split = line.split()
# Features are shown as separate entries but do not have versions, skip them
if "[" in split[0]:
continue
res.append(DependencyInfo(
name=split[0],
version=split[1],
description=split[2] if len(split) >= 3 else ""))
return res
def generate_versions_file(deps: List[DependencyInfo]):
longest_dep_name = max([len(dep.name) for dep in deps])
with open(VERSIONS_FILE, "w") as file:
file.write("#pragma once\n")
file.write("#define DEPENDENCY_VERSIONS ")
for dep in deps:
file.write("\\\n")
file.write(f"\"{dep.name: <{longest_dep_name}} {dep.version}\\n\"")
generate_versions_file(get_dependency_versions())