1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 11:35:35 +03:00
vimr/third-party/builder.py
2020-09-05 12:46:17 +02:00

49 lines
1.4 KiB
Python

from dataclasses import dataclass
from string import Template
from config import Config
from utils.shell import shell
@dataclass(frozen=True)
class Builder:
config: Config
download_command: Template
make_command: Template
copy_command: Template
def download(self):
cmd = self.download_command.substitute(dict(version=self.config.version))
print(cmd)
shell(cmd, cwd=self.config.working_directory)
def make(self):
cmd = self.make_command.substitute(
dict(
cflags=self.config.target_specific_full_cflags,
deployment_target=self.config.target_specific_deployment_target,
install_path=self.config.target_specific_install_path,
)
)
print(cmd)
shell(cmd, cwd=self.config.working_directory)
def copy_to_install_path(self):
cmd = self.copy_command.substitute(
dict(
target_specific_install_path=self.config.target_specific_install_path,
install_include_path=self.config.install_path_include,
install_lib_path=self.config.install_path_lib,
)
)
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.make()
self.copy_to_install_path()