Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@
'libunwind-except'
]

# Variant builds that we want to support for cetain ports
# Variant builds that we want to support for certain ports
# TODO: It would be nice if the ports themselves could specify the variants that they
# support.
PORT_VARIANTS = {
'regal-mt': ('regal', {'USE_PTHREADS': 1}),
'harfbuzz-mt': ('harfbuzz', {'USE_PTHREADS': 1}),
'sdl2-mt': ('sdl2', {'USE_PTHREADS': 1}),
'icu-mt': ('icu', {'USE_PTHREADS': 1}),
'sdl2_mixer_mp3': ('sdl2_mixer', {'SDL2_MIXER_FORMATS': ["mp3"]}),
'sdl2_mixer_none': ('sdl2_mixer', {'SDL2_MIXER_FORMATS': []}),
'sdl2_image_png': ('sdl2_image', {'SDL2_IMAGE_FORMATS': ["png"]}),
Expand Down
13 changes: 13 additions & 0 deletions tests/other/test_pthread_icu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <thread>
#include <iostream>
#include <unicode/unistr.h>

// Test that code using both pthread and icu compiles.
int main () {
std::thread([] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know we are not yet consistent, but we are trying to use a consistent style these days which involves 2-space indentation (we have a .clang-format file if you want to just use that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Can I recommend mentioning the existence of a style convention in Contributing or Developer's Guide?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes we should do that.

std::string str;
icu::UnicodeString ustr("Hello world!");
ustr.toUTF8String(str);
std::cout << str << std::endl;
}).detach();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to .join here since emscripten doesn't handling the case where the main application thread exits while other threads are still running.

Probably best to use PROXY_TO_PTHREAD and drop PTHREAD_POOL_SIZE_STRICT

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add newline and EOF

4 changes: 4 additions & 0 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -11125,6 +11125,10 @@ def test_pthread_out_err(self):
self.set_setting('EXIT_RUNTIME')
self.do_other_test('test_pthread_out_err.c')

@node_pthreads
def test_icu_mt(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you name the test the same as the file, i.e def test_pthread_icu?

self.do_smart_test(test_file('other/test_pthread_icu.cpp'), emcc_args=['-pthread', '-sUSE_ICU', '-sPTHREAD_POOL_SIZE_STRICT=4', '-sEXIT_RUNTIME'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like do_other_test (like the test above) should suffice.


# unistd tests

def test_unistd_confstr(self):
Expand Down
25 changes: 16 additions & 9 deletions tools/ports/icu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
VERSION = '68_2'
HASH = '12c3db5966c234c94e7918fb8acc8bd0838edc36a620f3faa788e7ff27b06f1aa431eb117401026e3963622b9323212f444b735d5c9dd3d0b82d772a4834b993'

libname_libicu_common = 'libicu_common.a'
libname_libicu_stubdata = 'libicu_stubdata.a'
libname_libicu_i18n = 'libicu_i18n.a'
libname_libicu_common = 'libicu_common'
libname_libicu_stubdata = 'libicu_stubdata'
libname_libicu_i18n = 'libicu_i18n'


def needed(settings):
return settings.USE_ICU


def get_lib_name(base_name, settings):
return base_name + ('-mt' if settings.USE_PTHREADS else '') + '.a'


def get(ports, settings, shared):
url = 'https://github.com/unicode-org/icu/releases/download/%s/icu4c-%s-src.zip' % (TAG, VERSION)
ports.fetch_project('icu', url, 'icu', sha512hash=HASH)
Expand Down Expand Up @@ -48,6 +52,9 @@ def build_lib(lib_output, lib_src, other_includes, build_flags):
# CXXFLAGS
'-std=c++11'
]
if settings.USE_PTHREADS:
additional_build_flags.append('-pthread')

ports.build_port(lib_src, lib_output, other_includes, build_flags + additional_build_flags)

# creator for libicu_common
Expand All @@ -71,16 +78,16 @@ def create_libicu_i18n(lib_output):
build_lib(lib_output, lib_src, other_includes, ['-DU_I18N_IMPLEMENTATION=1'])

return [
shared.Cache.get_lib(libname_libicu_common, create_libicu_common), # this also prepares the build
shared.Cache.get_lib(libname_libicu_stubdata, create_libicu_stubdata),
shared.Cache.get_lib(libname_libicu_i18n, create_libicu_i18n)
shared.Cache.get_lib(get_lib_name(libname_libicu_common, settings), create_libicu_common), # this also prepares the build
shared.Cache.get_lib(get_lib_name(libname_libicu_stubdata, settings), create_libicu_stubdata),
shared.Cache.get_lib(get_lib_name(libname_libicu_i18n, settings), create_libicu_i18n)
]


def clear(ports, settings, shared):
shared.Cache.erase_lib(libname_libicu_common)
shared.Cache.erase_lib(libname_libicu_stubdata)
shared.Cache.erase_lib(libname_libicu_i18n)
shared.Cache.erase_lib(get_lib_name(libname_libicu_common, settings))
shared.Cache.erase_lib(get_lib_name(libname_libicu_stubdata, settings))
shared.Cache.erase_lib(get_lib_name(libname_libicu_i18n, settings))


def process_args(ports):
Expand Down