Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 3 additions & 42 deletions setup_external_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,15 @@
- VS 2010, 64 bit -- Windows SDK v7.1
"""

import sys
import platform
import os
import glob
import shutil
import zipfile
import tarfile
import distutils.msvc9compiler as msvc

def fixproj(project_file, bit_target):
"""
:param bit_target: one of 'Win32' or 'x64'
"""
with open(project_file, 'r') as fd:
content = '\n'.join(line.strip() for line in fd if line.strip())
content = content.replace('Win32', bit_target).replace('x64', bit_target)
with open(project_file, 'w') as fd:
fd.write(content)

def tar_extract(tar_file, target):
with tarfile.open(tar_file, 'r:gz') as tgz:
tgz.extractall(target)

def zip_extract(zip_file, target):
with zipfile.ZipFile(zip_file) as zf:
zf.extractall(target)

# Configuration selection & declaration:
DEPSSRC = os.path.join(os.path.dirname(os.path.normpath(__file__)),
'deps_source')
DEPSBUILD = os.path.join(os.path.dirname(os.path.normpath(__file__)), 'build')
X64 = platform.architecture()[0] == '64bit'
PYVER = sys.version_info[:2]
VS2010 = PYVER >= (3, 3)
xXX = 'x64' if X64 else 'x86'
# If not VS2010, then use VS2008

VCVARSALL = None

def prepare_build_cmd(build_cmd, **kwargs):
global VCVARSALL
VCVARSALL = msvc.find_vcvarsall(10.0)
if VCVARSALL == None:
candidate = msvc.find_vcvarsall(10.0 if VS2010 else 9.0)
if candidate == None:
raise RuntimeError('Microsoft VS {} required'
.format('2010' if VS2010 else '2008'))
else:
VCVARSALL = candidate

return build_cmd.format(
vcvarsall=VCVARSALL, xXX=xXX, **kwargs)
raise RuntimeError('Microsoft VS 2010 required')
return build_cmd.format(vcvarsall=VCVARSALL, xXX=xXX, **kwargs)
10 changes: 3 additions & 7 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,19 +1132,15 @@ def do_custom_build(self):
%MSBUILD% "builds\windows\{vc20xx}\freetype.sln" ^
/t:Clean;Build /p:Configuration="{config}";Platform={WinXX}
"""
from setup_external_compile import fixproj, prepare_build_cmd, VS2010, X64, xXX
from setup_external_compile import prepare_build_cmd, X64, xXX
# Note: freetype has no build profile for 2014, so we don't bother...
vc = 'vc2010' if VS2010 else 'vc2008'
vc = 'vc2010'
WinXX = 'x64' if X64 else 'Win32'
# This is only false for py2.7, even on py3.5...
if not VS2010:
fixproj(os.path.join(src_path, 'builds', 'windows', vc, 'freetype.sln'), WinXX)
fixproj(os.path.join(src_path, 'builds', 'windows', vc, 'freetype.vcproj'), WinXX)

cmdfile = os.path.join("build", "build_freetype.cmd")
with open(cmdfile, 'w') as cmd:
cmd.write(prepare_build_cmd(FREETYPE_BUILD_CMD, vc20xx=vc, WinXX=WinXX,
config='Release' if VS2010 else 'LIB Release'))
config='Release'))

shutil.rmtree(str(Path(src_path, "objs")), ignore_errors=True)
subprocess.check_call([os.path.abspath(cmdfile)],
Expand Down