Skip to content

Commit c4d4148

Browse files
opacamzworkb
authored andcommitted
[recipes] Update freetype & add zlib support (kivy#2068)
1 parent e898440 commit c4d4148

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

pythonforandroid/recipes/freetype/__init__.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FreetypeRecipe(Recipe):
2424
https://sourceforge.net/projects/freetype/files/freetype2/2.5.3/
2525
"""
2626

27-
version = '2.5.5'
27+
version = '2.10.1'
2828
url = 'http://download.savannah.gnu.org/releases/freetype/freetype-{version}.tar.gz' # noqa
2929
built_libraries = {'libfreetype.so': 'objs/.libs'}
3030

@@ -35,9 +35,6 @@ def get_recipe_env(self, arch=None, with_harfbuzz=False):
3535
'harfbuzz', self.ctx
3636
).get_build_dir(arch.arch)
3737
freetype_install = join(self.get_build_dir(arch.arch), 'install')
38-
env['CFLAGS'] = ' '.join(
39-
[env['CFLAGS'], '-DFT_CONFIG_OPTION_USE_HARFBUZZ']
40-
)
4138

4239
env['HARFBUZZ_CFLAGS'] = '-I{harfbuzz} -I{harfbuzz}/src'.format(
4340
harfbuzz=harfbuzz_build
@@ -48,6 +45,19 @@ def get_recipe_env(self, arch=None, with_harfbuzz=False):
4845
freetype=freetype_install, harfbuzz=harfbuzz_build
4946
)
5047
)
48+
49+
# android's zlib support
50+
zlib_lib_path = join(self.ctx.ndk_platform, 'usr', 'lib')
51+
zlib_includes = join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include')
52+
53+
def add_flag_if_not_added(flag, env_key):
54+
if flag not in env[env_key]:
55+
env[env_key] += flag
56+
57+
add_flag_if_not_added(' -I' + zlib_includes, 'CFLAGS')
58+
add_flag_if_not_added(' -L' + zlib_lib_path, 'LDFLAGS')
59+
add_flag_if_not_added(' -lz', 'LDLIBS')
60+
5161
return env
5262

5363
def build_arch(self, arch, with_harfbuzz=False):
@@ -66,14 +76,17 @@ def build_arch(self, arch, with_harfbuzz=False):
6676
config_args = {
6777
'--host={}'.format(arch.command_prefix),
6878
'--prefix={}'.format(prefix_path),
69-
'--without-zlib',
7079
'--without-bzip2',
7180
'--with-png=no',
7281
}
7382
if not harfbuzz_in_recipes:
7483
info('Build freetype (without harfbuzz)')
7584
config_args = config_args.union(
76-
{'--disable-static', '--enable-shared', '--with-harfbuzz=no'}
85+
{'--disable-static',
86+
'--enable-shared',
87+
'--with-harfbuzz=no',
88+
'--with-zlib=yes',
89+
}
7790
)
7891
elif not with_harfbuzz:
7992
info('Build freetype for First time (without harfbuzz)')
@@ -82,12 +95,16 @@ def build_arch(self, arch, with_harfbuzz=False):
8295
# symbols/functions, so we avoid to have two freetype shared
8396
# libraries which will be confusing and harder to link with them
8497
config_args = config_args.union(
85-
{'--disable-shared', '--with-harfbuzz=no'}
98+
{'--disable-shared', '--with-harfbuzz=no', '--with-zlib=no'}
8699
)
87100
else:
88101
info('Build freetype for Second time (with harfbuzz)')
89102
config_args = config_args.union(
90-
{'--disable-static', '--enable-shared', '--with-harfbuzz=yes'}
103+
{'--disable-static',
104+
'--enable-shared',
105+
'--with-harfbuzz=yes',
106+
'--with-zlib=yes',
107+
}
91108
)
92109
info('Configure args are:\n\t-{}'.format('\n\t-'.join(config_args)))
93110

0 commit comments

Comments
 (0)