aboutsummaryrefslogtreecommitdiff
path: root/tools/build.py
blob: ec71fc8745995012fc7360cc309ac0424602741d (plain)
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
import argparse
import os
import os.path
import subprocess
import sys

parser = argparse.ArgumentParser()
parser.add_argument('-a', '--arch', choices=['x86', 'x64'],
                    default='x64', help='specify target cpu architecture')
parser.add_argument('-c', '--config', choices=['Debug', 'Release'],
                    required=True, help='specify build configuration')
args = parser.parse_args()


project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))


def build_cru_ui():
    os.chdir(project_root)

    os.environ['PreferredToolArchitecture'] = 'x64'  # use vs x64 toolchain

    generater_vs_arch_map = {
        'x86': 'Win32',
        'x64': 'x64'
    }

    subprocess.run('cmake -S . -B build -G "Visual Studio 15 2017" -A {arch}'
                   .format(arch=generater_vs_arch_map[args.arch]),
                   stdout=sys.stdout, stderr=sys.stderr)

    subprocess.run('cmake --build build --target ALL_BUILD --config {config}'.format(config=args.config),
                   stdout=sys.stdout, stderr=sys.stderr)


build_cru_ui()