This repository has been archived by the owner on Jan 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_libs.py
executable file
·79 lines (64 loc) · 2.46 KB
/
install_libs.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
77
78
79
#!/usr/bin/env python3
import logging
import os
import platform
import shutil
import subprocess
import sys
from distutils import dir_util
from pathlib import Path
VCPKG_COMMIT = "eafe9ebcdf191ad0fff98c0f060000edb208318d"
VCPKG_LIBS = [
"doctest",
"cxxopts",
"fmt",
"glad",
"glfw3",
"spdlog",
"tinyfiledialogs",
"x265",
]
def is_win():
return platform.system() == "Windows"
def install_vcpkg():
logging.info("installing vcpkg")
if (Path("vcpkg") / ".git").exists():
logging.warning("vcpkg seems already installed, trying to update")
subprocess.check_call(["git", "-C", "vcpkg", "reset", "--hard"])
subprocess.check_call(["git", "-C", "vcpkg", "clean", "-df"])
if subprocess.check_output(["git", "-C", "vcpkg", "rev-parse", "HEAD"]).decode()[:-1] == VCPKG_COMMIT:
logging.warning("vcpkg seems already up-to-date, skipping")
return
subprocess.check_call(["git", "-C", "vcpkg", "fetch", "-p"])
else:
subprocess.check_call(["git", "clone", "https://github.com/Microsoft/vcpkg.git"])
subprocess.check_call(["git", "-C", "vcpkg", "checkout", VCPKG_COMMIT])
if is_win():
subprocess.check_call([str(Path("vcpkg") / "bootstrap-vcpkg.bat"), "-disableMetrics"])
else:
subprocess.check_call([str(Path("vcpkg") / "bootstrap-vcpkg.sh"), "-disableMetrics", "-useSystemBinaries"])
def install_vcpkg_packages():
logging.info("installing vcpkg libs")
dir_util.copy_tree("vcpkg_config", "vcpkg")
triplet = "x64-windows" if is_win() else "x64-linux"
vcpkg_exe = str(Path("vcpkg") / "vcpkg")
subprocess.check_call([vcpkg_exe, "install", "--triplet", triplet] + VCPKG_LIBS)
subprocess.check_call([vcpkg_exe, "upgrade", "--no-dry-run"])
def cleanup_vcpkg():
logging.info("cleaning up vcpkg")
vcpkg_path = Path("vcpkg")
shutil.rmtree(vcpkg_path / "buildtrees", True)
shutil.rmtree(vcpkg_path / "packages", True)
for file in (vcpkg_path / "downloads").glob("*"):
if file.is_file():
file.unlink()
if __name__ == "__main__":
logging.basicConfig(datefmt="%H:%M:%S",
format="[%(asctime)s][%(levelname)s] %(message)s",
level=logging.DEBUG,
stream=sys.stderr)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
logging.info(f"detected platform: {platform.system()}")
install_vcpkg()
install_vcpkg_packages()
cleanup_vcpkg()