Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/ports/sdl2_ttf.py
4130 views
1
# Copyright 2015 The Emscripten Authors. All rights reserved.
2
# Emscripten is available under two separate licenses, the MIT license and the
3
# University of Illinois/NCSA Open Source License. Both these licenses can be
4
# found in the LICENSE file.
5
6
TAG = 'release-2.20.2' # Latest as of 21 February 2023
7
HASH = '8a625d29bef2ab7cbfe2143136a303c0fdb066ecd802d6c725de1b73ad8b056908cb524fe58f38eaee9f105471d2af50bbcb17911d46506dbcf573db218b3685'
8
9
deps = ['freetype', 'sdl2', 'harfbuzz']
10
11
variants = {'sdl2_ttf-mt': {'PTHREADS': 1}}
12
13
14
def needed(settings):
15
return settings.USE_SDL_TTF == 2
16
17
18
def get_lib_name(settings):
19
return 'libSDL2_ttf' + ('-mt' if settings.PTHREADS else '') + '.a'
20
21
22
def get(ports, settings, shared):
23
ports.fetch_project('sdl2_ttf', f'https://github.com/libsdl-org/SDL_ttf/archive/{TAG}.zip', sha512hash=HASH)
24
25
def create(final):
26
src_root = ports.get_dir('sdl2_ttf', 'SDL_ttf-' + TAG)
27
ports.install_headers(src_root, target='SDL2')
28
flags = ['-DTTF_USE_HARFBUZZ=1', '-sUSE_SDL=2', '-sUSE_FREETYPE', '-sUSE_HARFBUZZ']
29
if settings.PTHREADS:
30
flags += ['-pthread']
31
ports.build_port(src_root, final, 'sdl2_ttf', flags=flags, srcs=['SDL_ttf.c'])
32
33
return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]
34
35
36
def clear(ports, settings, shared):
37
shared.cache.erase_lib(get_lib_name(settings))
38
39
40
def process_dependencies(settings):
41
settings.USE_SDL = 2
42
settings.USE_FREETYPE = 1
43
settings.USE_HARFBUZZ = 1
44
45
46
def process_args(ports):
47
return ['-DTTF_USE_HARFBUZZ=1']
48
49
50
def show():
51
return 'sdl2_ttf (-sUSE_SDL_TTF=2 or --use-port=sdl2_ttf; zlib license)'
52
53