-
Notifications
You must be signed in to change notification settings - Fork 6
/
build-helpers.py
26 lines (21 loc) · 1.13 KB
/
build-helpers.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
import glob, os, shutil, subprocess, sys, tempfile
from os.path import abspath, basename, dirname, join
from subprocess import run
# Retrieve the absolute paths to the source and destination directories
rootDir = dirname(abspath(__file__))
sourceDir = join(rootDir, 'helpers')
binDir = join(rootDir, 'dlldiag', 'bin')
# Build our helper executables for each supported architecture
for architecture in ['x86', 'x64']:
# Create a temporary directory to hold the build
with tempfile.TemporaryDirectory() as tempDir:
# Perform the build
cmakeArchitecture = 'Win32' if architecture == 'x86' else architecture
run(['cmake', '-A', cmakeArchitecture, sourceDir], cwd=tempDir)
run(['cmake', '--build', '.', '--config', 'Release'], cwd=tempDir)
# Copy each of the built executables to the appropriate destination directory
targetDir = join(binDir, architecture)
for executable in glob.glob(join(tempDir, 'Release', '*.exe')):
destExecutable = join(targetDir, basename(executable))
print('\n[BUILD-HELPERS.PY] Copy {} => {}\n'.format(executable, destExecutable), file=sys.stderr, flush=True)
shutil.copy2(executable, destExecutable)