浏览代码

embed icudtl.dat into dll

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
3a82d3ae
共有 8 个文件被更改,包括 78 次插入4 次删除
  1. 8
      engine/Build.bee.cs
  2. 5
      engine/README.md
  3. 2
      engine/src/shell/common/shell.cc
  4. 1
      engine/src/shell/platform/embedder/embedder.cc
  5. 2
      engine/src/shell/platform/embedder/embedder.h
  6. 12
      engine/src/shell/platform/unity/uiwidgets_panel.cc
  7. 42
      engine/src/shell/common/switches.cc
  8. 10
      engine/src/shell/common/switches.h

8
engine/Build.bee.cs


"src/shell/common/shell_io_manager.h",
"src/shell/common/surface.cc",
"src/shell/common/surface.h",
"src/shell/common/switches.cc",
"src/shell/common/switches.h",
"src/shell/common/thread_host.cc",
"src/shell/common/thread_host.h",
"src/shell/common/vsync_waiter.cc",

},
OutputName = {c => $"libUIWidgets{(c.CodeGen == CodeGen.Debug ? "_d" : "")}"},
};
np.Libraries.Add(new BagOfObjectFilesLibrary(
new NPath[]{
skiaRoot+"out/Debug/icudtl.o"
}));
np.CompilerSettings().Add(c => c.WithCppLanguageVersion(CppLanguageVersion.Cpp17));
np.IncludeDirectories.Add("third_party");

builtNP.DeployTo("../Samples/UIWidgetsSamples_2019_4/Assets/Plugins/x86_64");
}
CopyTool.Instance().Setup(new NPath("../Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/").Combine("icudtl.dat"), new NPath("").Combine(skiaRoot, "out/Debug/icudtl.dat"));
return np;
}

5
engine/README.md


```
Ignore this error: "lld-link: error: could not open 'EGL': no such file or directory"
convert icudtl.dat to object file
```
cd out/Debug
ld -r -b binary -o .\icudtl.o .\icudtl.dat
```
### Build flutter fml
1. Setting up the Engine development environment

2
engine/src/shell/common/shell.cc


if (settings.icu_initialization_required) {
if (settings.icu_data_path.length() > 0) {
uiwidgets::icu::InitializeICU(settings.icu_data_path);
} else {
uiwidgets::icu::InitializeICUFromMapping(settings.icu_mapper());
}
}
});

1
engine/src/shell/platform/embedder/embedder.cc


Settings settings; // = SettingsFromCommandLine(command_line);
settings.icu_data_path = icu_data_path;
settings.icu_mapper = args->icu_mapper;
settings.assets_path = args->assets_path;
settings.task_observer_add = [task_observer_add = args->task_observer_add,

2
engine/src/shell/platform/embedder/embedder.h


#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "src/common/settings.h"
#if defined(__cplusplus)
extern "C" {

size_t struct_size;
const char* assets_path;
const char* icu_data_path;
uiwidgets::MappingCallback icu_mapper;
int command_line_argc;
const char* const* command_line_argv;
UIWidgetsPlatformMessageCallback platform_message_callback;

12
engine/src/shell/platform/unity/uiwidgets_panel.cc


#include "lib/ui/window/viewport_metrics.h"
#include "runtime/mono_api.h"
#include "shell/platform/embedder/embedder_engine.h"
#include "src/shell/common/switches.h"
#include "uiwidgets_system.h"
namespace uiwidgets {

args.struct_size = sizeof(UIWidgetsProjectArgs);
args.assets_path = streaming_assets_path;
std::string icu_path = std::string(streaming_assets_path) + "/icudtl.dat";
args.icu_data_path = icu_path.c_str();
// std::string icu_path = std::string(streaming_assets_path) + "/icudtl.dat";
// args.icu_data_path = icu_path.c_str();
args.icu_mapper = GetICUStaticMapping;
// std::string icu_symbol_prefix = "_binary_icudtl_dat_start";
// std::string native_lib_path =
// "pathtodll/Plugins/x86_64/libUIWidgets_d.dll"; args.icu_mapper =
// [icu_symbol_prefix, native_lib_path] {
// return GetSymbolMapping(icu_symbol_prefix, native_lib_path);
// };
args.command_line_argc = 0;
args.command_line_argv = nullptr;

42
engine/src/shell/common/switches.cc


#include "switches.h"
#include <cstdint>
namespace uiwidgets {
extern "C" uint8_t _binary_icudtl_dat_start[];
extern "C" uint8_t _binary_icudtl_dat_end[];
std::unique_ptr<fml::Mapping> GetICUStaticMapping() {
return std::make_unique<fml::NonOwnedMapping>(
_binary_icudtl_dat_start,
_binary_icudtl_dat_end - _binary_icudtl_dat_start);
}
std::unique_ptr<fml::Mapping> GetSymbolMapping(std::string symbol_prefix,
std::string native_lib_path) {
const uint8_t* mapping;
intptr_t size;
auto lookup_symbol = [&mapping, &size, symbol_prefix](
const fml::RefPtr<fml::NativeLibrary>& library) {
mapping = library->ResolveSymbol((symbol_prefix + "_start").c_str());
size = reinterpret_cast<intptr_t>(
library->ResolveSymbol((symbol_prefix + "_size").c_str()));
};
fml::RefPtr<fml::NativeLibrary> library =
fml::NativeLibrary::CreateForCurrentProcess();
lookup_symbol(library);
if (!(mapping && size)) {
// Symbol lookup for the current process fails on some devices. As a
// fallback, try doing the lookup based on the path to the Flutter library.
library = fml::NativeLibrary::Create(native_lib_path.c_str());
lookup_symbol(library);
}
FML_CHECK(mapping && size) << "Unable to resolve symbols: " << symbol_prefix;
return std::make_unique<fml::NonOwnedMapping>(mapping, size);
}
} // namespace uiwidgets

10
engine/src/shell/common/switches.h


#pragma once
#include <flutter/fml/memory/ref_counted.h>
#include "flutter/fml/mapping.h"
namespace uiwidgets {
std::unique_ptr<fml::Mapping> GetICUStaticMapping();
std::unique_ptr<fml::Mapping> GetSymbolMapping(std::string symbol_prefix,
std::string native_lib_path);
} // namespace uiwidgets
正在加载...
取消
保存