Skip to content
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

[recipes] Update freetype & add zlib support #2068

Merged
merged 1 commit into from
Mar 30, 2020
Merged
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
33 changes: 25 additions & 8 deletions pythonforandroid/recipes/freetype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FreetypeRecipe(Recipe):
https://sourceforge.net/projects/freetype/files/freetype2/2.5.3/
"""

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

Expand All @@ -35,9 +35,6 @@ def get_recipe_env(self, arch=None, with_harfbuzz=False):
'harfbuzz', self.ctx
).get_build_dir(arch.arch)
freetype_install = join(self.get_build_dir(arch.arch), 'install')
env['CFLAGS'] = ' '.join(
[env['CFLAGS'], '-DFT_CONFIG_OPTION_USE_HARFBUZZ']
)
Comment on lines -38 to -40
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this macro because it's already defined with the latest version of freetype, and, if we keep it, will throw a warning during the compilation


env['HARFBUZZ_CFLAGS'] = '-I{harfbuzz} -I{harfbuzz}/src'.format(
harfbuzz=harfbuzz_build
Expand All @@ -48,6 +45,19 @@ def get_recipe_env(self, arch=None, with_harfbuzz=False):
freetype=freetype_install, harfbuzz=harfbuzz_build
)
)

# android's zlib support
zlib_lib_path = join(self.ctx.ndk_platform, 'usr', 'lib')
zlib_includes = join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include')

def add_flag_if_not_added(flag, env_key):
if flag not in env[env_key]:
env[env_key] += flag

add_flag_if_not_added(' -I' + zlib_includes, 'CFLAGS')
add_flag_if_not_added(' -L' + zlib_lib_path, 'LDFLAGS')
add_flag_if_not_added(' -lz', 'LDLIBS')

return env

def build_arch(self, arch, with_harfbuzz=False):
Expand All @@ -66,14 +76,17 @@ def build_arch(self, arch, with_harfbuzz=False):
config_args = {
'--host={}'.format(arch.command_prefix),
'--prefix={}'.format(prefix_path),
'--without-zlib',
'--without-bzip2',
'--with-png=no',
}
if not harfbuzz_in_recipes:
info('Build freetype (without harfbuzz)')
config_args = config_args.union(
{'--disable-static', '--enable-shared', '--with-harfbuzz=no'}
{'--disable-static',
'--enable-shared',
'--with-harfbuzz=no',
'--with-zlib=yes',
}
)
elif not with_harfbuzz:
info('Build freetype for First time (without harfbuzz)')
Expand All @@ -82,12 +95,16 @@ def build_arch(self, arch, with_harfbuzz=False):
# symbols/functions, so we avoid to have two freetype shared
# libraries which will be confusing and harder to link with them
config_args = config_args.union(
{'--disable-shared', '--with-harfbuzz=no'}
{'--disable-shared', '--with-harfbuzz=no', '--with-zlib=no'}
)
else:
info('Build freetype for Second time (with harfbuzz)')
config_args = config_args.union(
{'--disable-static', '--enable-shared', '--with-harfbuzz=yes'}
{'--disable-static',
'--enable-shared',
'--with-harfbuzz=yes',
'--with-zlib=yes',
}
)
info('Configure args are:\n\t-{}'.format('\n\t-'.join(config_args)))

Expand Down