From a1a04fa14b9de4f0093d489b0e4429af915167de Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 4 Jul 2018 16:15:47 +0200 Subject: [PATCH] More simplifications to FreeType setup on Windows. - VS2010 is now always True -> perform constant folding. - Remove unused fixproj, tar_extract, zip_extract, DEPSSRC, DEPSBUILD, PYVER. - prepare_build_cmd is only called once so no need to cache VCVARSALL. - Remove unused imports. --- setup_external_compile.py | 45 +++------------------------------------ setupext.py | 10 +++------ 2 files changed, 6 insertions(+), 49 deletions(-) diff --git a/setup_external_compile.py b/setup_external_compile.py index 4ee60120f1b9..40f5e8f4aa89 100644 --- a/setup_external_compile.py +++ b/setup_external_compile.py @@ -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) diff --git a/setupext.py b/setupext.py index 4c48fcdee630..752ef3246cae 100644 --- a/setupext.py +++ b/setupext.py @@ -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)],