mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 15:39:26 +08:00
72 lines
1.3 KiB
Python
72 lines
1.3 KiB
Python
import os
|
|
import subprocess
|
|
from copy import deepcopy
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class Package:
|
|
pkg_name: str
|
|
triplets: str
|
|
|
|
|
|
ANDROID_PLATFORM_PACKAGES = [
|
|
"cpp-httplib",
|
|
"jsoncpp",
|
|
"spdlog",
|
|
"cxxopts",
|
|
]
|
|
|
|
ANDROID_PLATFORM_TRIPLETS = [
|
|
"android-x64",
|
|
"android-x86",
|
|
"android-arm64-v8a",
|
|
"android-armeabi-v7a-neon",
|
|
# "android-armeabi-v7a",
|
|
# "android-armeabi",
|
|
]
|
|
|
|
VCPKG_EXE = "vcpkg"
|
|
|
|
PACKAGE_INSTALL_DIR = "./vcpkgs"
|
|
|
|
VCPKG_TRIPLETS_OVERLAY = "./triplets"
|
|
|
|
NDK_ROOT = "E:/ndk"
|
|
|
|
VCPKG_ENV = {
|
|
"VCPKG_BINARY_SOURCES": "clear",
|
|
"ANDROID_NDK_HOME": NDK_ROOT,
|
|
}
|
|
|
|
|
|
def get_pkgs(pkgs, triplet):
|
|
return [Package(i, triplet) for i in pkgs]
|
|
|
|
|
|
def vcpkg_install(pkgs):
|
|
cmd = [
|
|
VCPKG_EXE,
|
|
"install",
|
|
"--clean-packages-after-build",
|
|
"--clean-buildtrees-after-build",
|
|
f"--overlay-triplets={VCPKG_TRIPLETS_OVERLAY}",
|
|
f"--x-install-root={PACKAGE_INSTALL_DIR}",
|
|
"--recurse",
|
|
*[f"{i.pkg_name}:{i.triplets}" for i in pkgs]
|
|
]
|
|
env = deepcopy(dict(os.environ))
|
|
env.update(VCPKG_ENV)
|
|
subprocess.run(cmd, env=env)
|
|
|
|
|
|
def main():
|
|
pkgs = []
|
|
for android_triplets in ANDROID_PLATFORM_TRIPLETS:
|
|
pkgs.extend(get_pkgs(ANDROID_PLATFORM_PACKAGES, android_triplets))
|
|
vcpkg_install(pkgs)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|