@@ -588,14 +588,10 @@ def add_flags(cls, ext):
588588 else :
589589 src_path = Path ('build' , f'freetype-{ LOCAL_FREETYPE_VERSION } ' )
590590 # Statically link to the locally-built freetype.
591- # This is certainly broken on Windows.
592591 ext .include_dirs .insert (0 , str (src_path / 'include' ))
593- if sys .platform == 'win32' :
594- libfreetype = 'libfreetype.lib'
595- else :
596- libfreetype = 'libfreetype.a'
597592 ext .extra_objects .insert (
598- 0 , str (src_path / 'objs' / '.libs' / libfreetype ))
593+ 0 , str ((src_path / 'objs/.libs/libfreetype' ).with_suffix (
594+ '.lib' if sys .platform == 'win32' else '.a' )))
599595 ext .define_macros .append (('FREETYPE_BUILD_TYPE' , 'local' ))
600596
601597 def do_custom_build (self , env ):
@@ -617,11 +613,9 @@ def do_custom_build(self, env):
617613 dirname = f'freetype-{ LOCAL_FREETYPE_VERSION } ' ,
618614 )
619615
620- if sys .platform == 'win32' :
621- libfreetype = 'libfreetype.lib'
622- else :
623- libfreetype = 'libfreetype.a'
624- if (src_path / 'objs' / '.libs' / libfreetype ).is_file ():
616+ libfreetype = (src_path / "objs/.libs/libfreetype" ).with_suffix (
617+ ".lib" if sys .platform == "win32" else ".a" )
618+ if libfreetype .is_file ():
625619 return # Bail out because we have already built FreeType.
626620
627621 print (f"Building freetype in { src_path } " )
@@ -669,13 +663,6 @@ def do_custom_build(self, env):
669663 subprocess .check_call ([make ], env = env , cwd = src_path )
670664 else : # compilation on windows
671665 shutil .rmtree (src_path / "objs" , ignore_errors = True )
672- is_x64 = platform .architecture ()[0 ] == '64bit'
673- if platform .machine () == 'ARM64' :
674- msbuild_platform = 'ARM64'
675- elif is_x64 :
676- msbuild_platform = 'x64'
677- else :
678- msbuild_platform = 'Win32'
679666 base_path = Path (
680667 f"build/freetype-{ LOCAL_FREETYPE_VERSION } /builds/windows"
681668 )
@@ -726,6 +713,10 @@ def do_custom_build(self, env):
726713 str (dest ),
727714 ])
728715 msbuild_path = dest .read_text ()
716+ msbuild_platform = (
717+ "ARM64" if platform .machine () == "ARM64" else
718+ "x64" if platform .architecture ()[0 ] == "64bit" else
719+ "Win32" )
729720 # Freetype 2.10.0+ support static builds.
730721 msbuild_config = (
731722 "Release Static"
@@ -738,18 +729,16 @@ def do_custom_build(self, env):
738729 f"/p:Configuration={ msbuild_config } ;"
739730 f"Platform={ msbuild_platform } " ])
740731 # Move to the corresponding Unix build path.
741- ( src_path / "objs" / ".libs" ) .mkdir ()
732+ libfreetype . parent .mkdir ()
742733 # Be robust against change of FreeType version.
743734 lib_paths = Path (src_path / "objs" ).rglob ('freetype*.lib' )
744735 # Select FreeType library for required platform
745736 lib_path , = [
746737 p for p in lib_paths
747738 if msbuild_platform in p .resolve ().as_uri ()
748739 ]
749- print (
750- f"Copying { lib_path } to { src_path } /objs/.libs/libfreetype.lib"
751- )
752- shutil .copy2 (lib_path , src_path / "objs/.libs/libfreetype.lib" )
740+ print (f"Copying { lib_path } to { libfreetype } " )
741+ shutil .copy2 (lib_path , libfreetype )
753742
754743
755744class Qhull (SetupPackage ):
0 commit comments