@@ -588,14 +588,10 @@ def add_flags(cls, ext):
588
588
else :
589
589
src_path = Path ('build' , f'freetype-{ LOCAL_FREETYPE_VERSION } ' )
590
590
# Statically link to the locally-built freetype.
591
- # This is certainly broken on Windows.
592
591
ext .include_dirs .insert (0 , str (src_path / 'include' ))
593
- if sys .platform == 'win32' :
594
- libfreetype = 'libfreetype.lib'
595
- else :
596
- libfreetype = 'libfreetype.a'
597
592
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' )))
599
595
ext .define_macros .append (('FREETYPE_BUILD_TYPE' , 'local' ))
600
596
601
597
def do_custom_build (self , env ):
@@ -617,11 +613,9 @@ def do_custom_build(self, env):
617
613
dirname = f'freetype-{ LOCAL_FREETYPE_VERSION } ' ,
618
614
)
619
615
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 ():
625
619
return # Bail out because we have already built FreeType.
626
620
627
621
print (f"Building freetype in { src_path } " )
@@ -669,13 +663,6 @@ def do_custom_build(self, env):
669
663
subprocess .check_call ([make ], env = env , cwd = src_path )
670
664
else : # compilation on windows
671
665
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'
679
666
base_path = Path (
680
667
f"build/freetype-{ LOCAL_FREETYPE_VERSION } /builds/windows"
681
668
)
@@ -726,6 +713,10 @@ def do_custom_build(self, env):
726
713
str (dest ),
727
714
])
728
715
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" )
729
720
# Freetype 2.10.0+ support static builds.
730
721
msbuild_config = (
731
722
"Release Static"
@@ -738,18 +729,16 @@ def do_custom_build(self, env):
738
729
f"/p:Configuration={ msbuild_config } ;"
739
730
f"Platform={ msbuild_platform } " ])
740
731
# Move to the corresponding Unix build path.
741
- ( src_path / "objs" / ".libs" ) .mkdir ()
732
+ libfreetype . parent .mkdir ()
742
733
# Be robust against change of FreeType version.
743
734
lib_paths = Path (src_path / "objs" ).rglob ('freetype*.lib' )
744
735
# Select FreeType library for required platform
745
736
lib_path , = [
746
737
p for p in lib_paths
747
738
if msbuild_platform in p .resolve ().as_uri ()
748
739
]
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 )
753
742
754
743
755
744
class Qhull (SetupPackage ):
0 commit comments