Skip to content

Simplify FreeType Windows build. #11248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2018
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
3 changes: 2 additions & 1 deletion setup_external_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def zip_extract(zip_file, target):
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
Expand All @@ -68,4 +69,4 @@ def prepare_build_cmd(build_cmd, **kwargs):
VCVARSALL = candidate

return build_cmd.format(
vcvarsall=VCVARSALL, xXX='x64' if X64 else 'x86', **kwargs)
vcvarsall=VCVARSALL, xXX=xXX, **kwargs)
36 changes: 18 additions & 18 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,23 +1122,15 @@ def do_custom_build(self):
subprocess.check_call(["make"], env=env, cwd=src_path)
else:
# compilation on windows
FREETYPE_BUILD_CMD = """\
call "%ProgramFiles%\\Microsoft SDKs\\Windows\\v7.0\\Bin\\SetEnv.Cmd" /Release /{xXX} /xp
FREETYPE_BUILD_CMD = r"""
call "%ProgramFiles%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.Cmd" ^
/Release /{xXX} /xp
call "{vcvarsall}" {xXX}
set MSBUILD=C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe
rd /S /Q %FREETYPE%\\objs
%MSBUILD% %FREETYPE%\\builds\\windows\\{vc20xx}\\freetype.sln /t:Clean;Build /p:Configuration="{config}";Platform={WinXX}
echo Build completed, moving result"
:: move to the "normal" path for the unix builds...
mkdir %FREETYPE%\\objs\\.libs
:: REMINDER: fix when changing the version
copy %FREETYPE%\\objs\\{vc20xx}\\{xXX}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
if errorlevel 1 (
rem This is a py27 version, which has a different location for the lib file :-/
copy %FREETYPE%\\objs\\win32\\{vc20xx}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
)
set MSBUILD=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
%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
from setup_external_compile import fixproj, prepare_build_cmd, VS2010, X64, xXX
# Note: freetype has no build profile for 2014, so we don't bother...
vc = 'vc2010' if VS2010 else 'vc2008'
WinXX = 'x64' if X64 else 'Win32'
Expand All @@ -1147,13 +1139,21 @@ def do_custom_build(self):
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')
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'))

os.environ['FREETYPE'] = src_path
subprocess.check_call([cmdfile], shell=True)
shutil.rmtree(str(Path(src_path, "objs")), ignore_errors=True)
subprocess.check_call([os.path.abspath(cmdfile)],
shell=True, cwd=src_path)
# Move to the corresponding Unix build path.
Path(src_path, "objs/.libs").mkdir()
# Be robust against change of FreeType version.
lib_path, = (Path(src_path, "objs", vc, xXX)
.glob("freetype*.lib"))
shutil.copy2(str(lib_path),
str(Path(src_path, "objs/.libs/libfreetype.lib")))


class FT2Font(SetupPackage):
Expand Down