Get ICU working on Emscripten builds (build is massive for now, shrink it later)
This commit is contained in:
parent
525da85f51
commit
da6b245a9b
6 changed files with 29 additions and 17 deletions
|
|
@ -131,6 +131,8 @@ if(WIN32)
|
|||
endif()
|
||||
|
||||
# Get libraries
|
||||
find_package(ICU REQUIRED)
|
||||
|
||||
if(LINK_SKIA_MANUALLY)
|
||||
set(SKIA_INCLUDE "modules/skia" CACHE PATH "Path to Skia root directory")
|
||||
set(SKIA_LIB_PATH "modules/skia/out/Static" CACHE PATH "Path to Skia libs")
|
||||
|
|
@ -149,6 +151,7 @@ if(NOT EMSCRIPTEN)
|
|||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
|
||||
find_package(LibDataChannel REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(harfbuzz REQUIRED)
|
||||
else()
|
||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-static)
|
||||
endif()
|
||||
|
|
@ -197,8 +200,8 @@ if(EMSCRIPTEN)
|
|||
target_link_options(infinipaint PRIVATE -O3)
|
||||
endif()
|
||||
|
||||
target_compile_options(infinipaint PRIVATE -Wall -sUSE_ICU=1 -sUSE_HARFBUZZ=1 -fdiagnostics-color -sUSE_SDL=0 -include functional -fexceptions)
|
||||
target_link_options(infinipaint PRIVATE --emrun -sUSE_ICU=1 -sUSE_HARFBUZZ=1 -sUSE_SDL=0 -sFULL_ES2 -sUSE_WEBGL2=1 -sFETCH --embed-file data -sALLOW_MEMORY_GROWTH -sEXPORTED_RUNTIME_METHODS=ccall -sEXPORTED_FUNCTIONS=[_main,_malloc,_free] -sMAXIMUM_MEMORY=4GB -sSINGLE_FILE -lidbfs.js -fexceptions)
|
||||
target_compile_options(infinipaint PRIVATE -Wall -sUSE_HARFBUZZ=1 -fdiagnostics-color -sUSE_SDL=0 -include functional -fexceptions)
|
||||
target_link_options(infinipaint PRIVATE --emrun -sUSE_HARFBUZZ=1 -sUSE_SDL=0 -sFULL_ES2 -sUSE_WEBGL2=1 -sFETCH --embed-file data -sALLOW_MEMORY_GROWTH=1 -sEXPORTED_RUNTIME_METHODS=ccall -sEXPORTED_FUNCTIONS=[_main,_malloc,_free] -sMAXIMUM_MEMORY=4GB -sSINGLE_FILE -lidbfs.js -sINITIAL_MEMORY=67108864 -fexceptions)
|
||||
if(EMSCRIPTEN_SINGLE_HTML_FILE)
|
||||
target_link_options(infinipaint PRIVATE --shell-file emscripteninstall/singlefilereleaseshell.html)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
|
@ -276,7 +279,11 @@ if((NOT EMSCRIPTEN) AND (NOT APPLE))
|
|||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(infinipaint SDL3::SDL3 zstd::libzstd_static)
|
||||
target_link_libraries(infinipaint SDL3::SDL3 zstd::libzstd_static icu::icu)
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
target_link_libraries(infinipaint harfbuzz::harfbuzz)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
add_subdirectory(deps/datachannel-wasm EXCLUDE_FROM_ALL)
|
||||
|
|
|
|||
|
|
@ -425,10 +425,7 @@ class ConanSkia(ConanFile):
|
|||
self.requires("expat/[>=2.5.0]")
|
||||
|
||||
if self.options.use_icu and self.options.use_system_icu and self.options.use_conan_icu:
|
||||
if self.settings.os == "Emscripten":
|
||||
self.requires("icu/[74.2]")
|
||||
else:
|
||||
self.requires("icu/[>=74.2]")
|
||||
self.requires("icu/[>=77.1]")
|
||||
|
||||
if (self.options.use_libpng_decode or self.options.use_libpng_encode) and self.options.use_system_libpng and self.options.use_conan_libpng:
|
||||
self.requires("libpng/[>=1.6.32]")
|
||||
|
|
|
|||
|
|
@ -42,12 +42,10 @@ class CompressorRecipe(ConanFile):
|
|||
"use_system_zlib":False,
|
||||
"enable_svg": True,
|
||||
"enable_skottie": False,
|
||||
"enable_skunicode": True,
|
||||
"enable_skshaper": True,
|
||||
"enable_bentleyottmann": True, # for some reason, setting this to False results in an error when creating the project
|
||||
"enable_skparagraph": True,
|
||||
"use_freetype": True
|
||||
})
|
||||
self.requires("harfbuzz/11.4.1")
|
||||
|
||||
|
||||
if self.settings.os == "Linux":
|
||||
|
|
@ -70,7 +68,8 @@ class CompressorRecipe(ConanFile):
|
|||
self.requires("libcurl/8.15.0")
|
||||
|
||||
self.requires("zstd/1.5.7")
|
||||
|
||||
self.requires("icu/[>=77.1]")
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires("cmake/3.27.0")
|
||||
|
||||
|
|
|
|||
BIN
data/icudt77l.dat
Executable file
BIN
data/icudt77l.dat
Executable file
Binary file not shown.
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "CollabTextBoxShaper.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <include/core/SkFont.h>
|
||||
#include <include/core/SkFontMetrics.h>
|
||||
#include <include/core/SkFontMgr.h>
|
||||
|
|
@ -12,15 +14,12 @@
|
|||
#include <include/core/SkTextBlob.h>
|
||||
#include <include/core/SkTypes.h>
|
||||
#include <include/private/base/SkTFitsIn.h>
|
||||
#include <modules/skshaper/include/SkShaper.h>
|
||||
#include <src/base/SkUTF.h>
|
||||
|
||||
#include <modules/skshaper/include/SkShaper.h>
|
||||
#include <modules/skshaper/include/SkShaper_harfbuzz.h>
|
||||
#include <modules/skshaper/include/SkShaper_skunicode.h>
|
||||
#include <modules/skshaper/include/SkShaper_factory.h>
|
||||
|
||||
#include <modules/skunicode/include/SkUnicode.h>
|
||||
|
||||
#include <modules/skunicode/include/SkUnicode_icu.h>
|
||||
|
||||
#include <cfloat>
|
||||
|
|
@ -288,8 +287,7 @@ CollabTextBox::ShapeResult CollabTextBox::shape(const char* utf8Text,
|
|||
//shaper = SkShaper::MakePrimitive();
|
||||
//#else
|
||||
shaper = SkShapers::HB::ShaperDrivenWrapper(unicode, fontMgr);
|
||||
//#endif
|
||||
|
||||
//#endi
|
||||
SkASSERT(shaper);
|
||||
|
||||
float height = font.getSpacing();
|
||||
|
|
|
|||
11
src/main.cpp
11
src/main.cpp
|
|
@ -101,6 +101,9 @@ extern "C"
|
|||
}
|
||||
#endif
|
||||
|
||||
#include <unicode/udata.h>
|
||||
std::string icudt; // Put this in global space so that it isn't deallocated
|
||||
|
||||
struct MainStruct {
|
||||
#ifdef USE_BACKEND_VULKAN
|
||||
#ifdef USE_SKIA_BACKEND_GANESH
|
||||
|
|
@ -385,6 +388,14 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
|||
listOfFilesToOpenFromCommand.emplace_back(std::filesystem::canonical(std::filesystem::path(argv[i])));
|
||||
switch_cwd();
|
||||
|
||||
UErrorCode uerr = U_ZERO_ERROR;
|
||||
icudt = read_file_to_string("data/icudt77l.dat");
|
||||
udata_setCommonData((void *) icudt.data(), &uerr);
|
||||
if (U_FAILURE(uerr)) {
|
||||
char* errorName = const_cast<char*>(u_errorName(uerr));
|
||||
std::cout << errorName << std::endl;
|
||||
}
|
||||
|
||||
MainStruct* mSPtr = new MainStruct;
|
||||
*appstate = (void*)mSPtr;
|
||||
MainStruct& mS = *mSPtr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue