1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 07:13:24 +03:00
vimr/third-party/builder.py

77 lines
2.4 KiB
Python
Raw Normal View History

2020-08-21 09:59:40 +03:00
from dataclasses import dataclass
from string import Template
from config import Config, Target
2020-08-21 09:59:40 +03:00
from utils.shell import shell
@dataclass(frozen=True)
class Builder:
config: Config
2020-08-21 09:59:40 +03:00
download_command: Template
extract_command: Template
2020-08-21 09:59:40 +03:00
make_command: Template
build_universal_and_install_command: Template
2020-08-21 09:59:40 +03:00
def download(self):
cmd = self.download_command.substitute(dict(version=self.config.version))
print(cmd)
shell(cmd, cwd=self.config.working_directory)
def extract(self, target: Target):
cmd = self.extract_command.substitute(
dict(
target=target.value,
version=self.config.version,
)
)
print(cmd)
shell(cmd, cwd=self.config.working_directory)
def make(self, target: Target):
2020-08-21 09:59:40 +03:00
cmd = self.make_command.substitute(
dict(
target=target.value,
cflags=self.config.target_specific_full_cflags(target),
deployment_target=self.config.target_specific_deployment_target(target),
install_path=self.config.target_specific_install_path(target),
2020-11-15 11:24:07 +03:00
host=self.config.target_specific_host(target),
2020-08-21 09:59:40 +03:00
)
)
print(cmd)
shell(cmd, cwd=self.config.working_directory)
def build_universal_and_install(self):
cmd = self.build_universal_and_install_command.substitute(
2020-08-21 09:59:40 +03:00
dict(
install_lib_path=self.config.install_path_lib,
install_include_path=self.config.install_path_include,
arm64_lib_path=self.config.target_specific_install_path(Target.arm64).joinpath(
"lib"
),
arm64_include_path=self.config.target_specific_install_path(Target.arm64).joinpath(
"include"
),
x86_64_lib_path=self.config.target_specific_install_path(Target.x86_64).joinpath(
"lib"
),
2020-08-21 09:59:40 +03:00
)
)
print(cmd)
shell(cmd, cwd=self.config.working_directory)
def build(self):
self.config.clean_install_paths()
self.config.ensure_paths_exist()
self.download()
self.extract(Target.arm64)
self.make(Target.arm64)
self.extract(Target.x86_64)
self.make(Target.x86_64)
self.build_universal_and_install()