Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
with_env_modify,
)

from tools import building, cache, response_file, shared, utils, webassembly
from tools import building, cache, ports, response_file, shared, utils, webassembly
from tools.building import get_building_env
from tools.cmdline import options
from tools.link import binary_encode
Expand Down Expand Up @@ -2753,6 +2753,17 @@ def test_sdl3_ttf(self):
self.emcc(test_file('browser/test_sdl3_ttf.c'), args=['-Wno-experimental', '-sUSE_SDL=3', '-sUSE_SDL_TTF=3'])
self.emcc(test_file('browser/test_sdl3_ttf.c'), args=['-Wno-experimental', '--use-port=sdl3', '--use-port=sdl3_ttf'])

@requires_network
def test_sdl_ttf_parent_cache_lock(self):
# Verify that building sdl2_ttf while holding the cache lock (as a parent process does)
# succeeds even if libharfbuzz.a is not yet present in the cache.
shared.cache.erase_lib('libharfbuzz.a')
shared.cache.erase_lib('libSDL2_ttf.a')
self.set_setting('USE_SDL', 2)
self.set_setting('USE_SDL_TTF', 2)
with shared.cache.lock('test_sdl_ttf_parent_cache_lock'):
ports.get_port_by_name('sdl2_ttf').get(ports.Ports, settings, shared)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd rather find a way to test this from outside using embuilder and/or emcc rather then using the internal API like this.


@requires_network
def test_contrib_ports(self):
# Verify that contrib ports can be used (using the only contrib port available ATM, but can be replaced
Expand Down
1 change: 1 addition & 0 deletions tools/ports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def clear_project_build(name):
def write_file(filename, contents):
if os.path.exists(filename) and utils.read_file(filename) == contents:
return
utils.safe_ensure_dirs(os.path.dirname(filename))
utils.write_file(filename, contents)

@staticmethod
Expand Down
9 changes: 7 additions & 2 deletions tools/ports/sdl2_ttf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ def get(ports, settings, shared):
def create(final):
src_root = ports.get_dir('sdl2_ttf', 'SDL_ttf-' + TAG)
ports.install_headers(src_root, target='SDL2')
flags = ['-DTTF_USE_HARFBUZZ=1', '-sUSE_SDL=2', '-sUSE_FREETYPE', '-sUSE_HARFBUZZ']
includes = [
ports.get_include_dir('SDL2'),
ports.get_include_dir('freetype2'),
ports.get_include_dir('harfbuzz'),
]
flags = ['-DTTF_USE_HARFBUZZ=1']
if settings.PTHREADS:
flags += ['-pthread']
ports.build_port(src_root, final, 'sdl2_ttf', flags=flags, srcs=['SDL_ttf.c'])
ports.build_port(src_root, final, 'sdl2_ttf', includes=includes, flags=flags, srcs=['SDL_ttf.c'])

return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]

Expand Down
10 changes: 8 additions & 2 deletions tools/ports/sdl3_ttf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ def get(ports, settings, shared):
def create(final):
src_root = ports.get_dir('sdl3_ttf', 'SDL_ttf-' + TAG)
ports.install_header_dir(os.path.join(src_root, 'include'), target='.')
flags = ['-Wno-experimental', '-DTTF_USE_HARFBUZZ=1', '-sUSE_SDL=3', '-sUSE_FREETYPE', '-sUSE_HARFBUZZ']
includes = [
ports.get_include_dir(),
ports.get_include_dir('SDL3'),
ports.get_include_dir('freetype2'),
ports.get_include_dir('harfbuzz'),
]
flags = ['-Wno-experimental', '-DTTF_USE_HARFBUZZ=1']
if settings.PTHREADS:
flags += ['-pthread']

Expand All @@ -40,7 +46,7 @@ def create(final):
'src/SDL_ttf.c',
]

ports.build_port(src_root, final, 'sdl3_ttf', flags=flags, srcs=srcs)
ports.build_port(src_root, final, 'sdl3_ttf', includes=includes, flags=flags, srcs=srcs)

return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]

Expand Down
Loading