浏览代码

Merge pull request #108 from Unity-Technologies/siyaoH/1.17/windows

Siyao h/1.17/windows
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
23f66e81
共有 3 个文件被更改,包括 208 次插入64 次删除
  1. 135
      engine/Build.bee.cs
  2. 133
      engine/README.md
  3. 4
      engine/src/shell/platform/unity/windows/unity_surface_manager.cc

135
engine/Build.bee.cs


np.Libraries.Add(c => IsWindows(c), new BagOfObjectFilesLibrary(
new NPath[]{
skiaRoot + "/third_party/externals/icu/flutter/icudtl.o"
flutterRoot + "/third_party/icu/flutter/icudtl.o"
}));
np.CompilerSettings().Add(c => c.WithCppLanguageVersion(CppLanguageVersion.Cpp17));
np.CompilerSettings().Add(c => IsMac(c), c => c.WithCustomFlags(new []{"-Wno-c++11-narrowing"}));

{
SetupRadidJson(np);
// TODO: fix warning, there are some type mismatches
var ignoreWarnigs = new string[] { "4244", "4267", "5030", "4101", "4996", "4359", "4018", "4091", "4722", "4312", "4838", "4172", "4005", "4311", "4477" };
np.CompilerSettings().Add(c => IsWindows(c), s => s.WithWarningPolicies(ignoreWarnigs.Select((code) => new WarningAndPolicy(code, WarningPolicy.Silent)).ToArray()));
np.Defines.Add(c => IsMac(c), new []
{
//lib flutter

"ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC"
});
np.IncludeDirectories.Add(c => IsWindows(c), new NPath[] {
".",
"third_party",
"src",
flutterRoot,
flutterRoot + "/third_party/rapidjson/include",
flutterRoot +"/third_party/angle/include",
skiaRoot,
flutterRoot + "/flutter/third_party/txt/src",
flutterRoot + "/third_party/harfbuzz/src",
flutterRoot + "/third_party/icu/source/common",
flutterRoot + "/third_party/icu/source/common",
flutterRoot + "/third_party/icu/source/i18n",
});
np.CompilerSettings().Add(c => IsWindows(c), c => c.WithCustomFlags(new [] {
"-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING",
"-DUSE_OPENSSL=1",
"-D__STD_C",
"-D_CRT_RAND_S",
"-D_CRT_SECURE_NO_DEPRECATE",
"-D_HAS_EXCEPTIONS=0",
"-D_SCL_SECURE_NO_DEPRECATE",
"-DWIN32_LEAN_AND_MEAN",
"-DNOMINMAX",
"-D_ATL_NO_OPENGL",
"-D_WINDOWS",
"-DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS",
"-DNTDDI_VERSION=0x06030000",
"-DPSAPI_VERSION=1",
"-DWIN32",
"-D_SECURE_ATL",
"-D_USING_V110_SDK71_",
"-D_UNICODE",
"-DUNICODE",
"-D_WIN32_WINNT=0x0603",
"-DWINVER=0x0603",
"-D_DEBUG",
"-DU_USING_ICU_NAMESPACE=0",
"-DU_ENABLE_DYLOAD=0",
"-DUSE_CHROMIUM_ICU=1",
"-DU_STATIC_IMPLEMENTATION",
"-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
"-DUCHAR_TYPE=wchar_t",
"-DFLUTTER_RUNTIME_MODE_DEBUG=1",
"-DFLUTTER_RUNTIME_MODE_PROFILE=2",
"-DFLUTTER_RUNTIME_MODE_RELEASE=3",
"-DFLUTTER_RUNTIME_MODE_JIT_RELEASE=4",
"-DFLUTTER_RUNTIME_MODE=1",
"-DFLUTTER_JIT_RUNTIME=1",
"-DSK_ENABLE_SPIRV_VALIDATION",
"-D_CRT_SECURE_NO_WARNINGS",
"-D_HAS_EXCEPTIONS=0",
"-DWIN32_LEAN_AND_MEAN",
"-DNOMINMAX",
"-DSK_GAMMA_APPLY_TO_A8",
"-DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
// TODO: fix this by update txt_lib build setting, reference: https://github.com/microsoft/vcpkg/issues/12123
// "-DGR_TEST_UTILS=1",
"-DSKIA_IMPLEMENTATION=1",
"-DSK_GL",
"-DSK_ENABLE_DUMP_GPU",
"-DSK_SUPPORT_PDF",
"-DSK_CODEC_DECODES_JPEG",
"-DSK_ENCODE_JPEG",
"-DSK_SUPPORT_XPS",
"-DSK_ENABLE_ANDROID_UTILS",
"-DSK_USE_LIBGIFCODEC",
"-DSK_HAS_HEIF_LIBRARY",
"-DSK_CODEC_DECODES_PNG",
"-DSK_ENCODE_PNG",
"-DSK_ENABLE_SKSL_INTERPRETER",
"-DSK_CODEC_DECODES_WEBP",
"-DSK_ENCODE_WEBP",
"-DSK_XML",
"-DLIBEGL_IMPLEMENTATION",
"-D_CRT_SECURE_NO_WARNINGS",
"-D_HAS_EXCEPTIONS=0",
"-DWIN32_LEAN_AND_MEAN",
"-DNOMINMAX",
"-DANGLE_ENABLE_ESSL",
"-DANGLE_ENABLE_GLSL",
"-DANGLE_ENABLE_HLSL",
"-DANGLE_ENABLE_OPENGL",
"-DEGL_EGLEXT_PROTOTYPES",
"-DGL_GLEXT_PROTOTYPES",
"-DANGLE_ENABLE_D3D11",
"-DANGLE_ENABLE_D3D9",
"-DGL_APICALL=",
"-DGL_API=",
"-DEGLAPI=",
"/FS",
"/MTd",
"/Od",
"/Ob0",
"/RTC1",
"/Zi",
"/WX",
"/std:c++17",
"/GR-",
}));
np.CompilerSettings().Add(c => IsMac(c), c => c.WithCustomFlags(new[] {
"-MD",
"-MF",

"-fvisibility-inlines-hidden",
}));
var windowsSkiaBuild = skiaRoot + "/out/Debug";
np.Libraries.Add(IsWindows, c =>
{
return new PrecompiledLibrary[]
{
new StaticLibrary(flutterRoot+"/out/host_debug_unopt/obj/flutter/third_party/txt/txt_lib.lib"),
new StaticLibrary(windowsSkiaBuild+"/libEGL.dll.lib"),
new StaticLibrary(windowsSkiaBuild+"/libGLESv2.dll.lib"),
new SystemLibrary("Opengl32.lib"),
new SystemLibrary("User32.lib"),
new SystemLibrary("Rpcrt4.lib"),
};
});
np.SupportFiles.Add(c => IsWindows(c), new [] {
new DeployableFile(windowsSkiaBuild + "/libEGL.dll"),
new DeployableFile(windowsSkiaBuild + "/libEGL.dll.pdb"),
new DeployableFile(windowsSkiaBuild + "/libGLESv2.dll"),
new DeployableFile(windowsSkiaBuild + "/libGLESv2.dll.pdb"),
}
);
np.Libraries.Add(IsMac, c => {
return new PrecompiledLibrary[]
{

133
engine/README.md


## How to Build (Windows)
### Build Skia
1. Install depot_tools
### Install depot_tools
2. Clone the skia Repo
```
git clone https://skia.googlesource.com/skia.git
cd skia
git checkout chrome/m85
python2 tools/git-sync-deps
```
3. Install LLVM
https://clang.llvm.org/get_started.html
4. Build skia
```
bin/gn gen out/Debug
```
Update out/Debug/args.gn with the following content:
```
clang_win = "C:\Program Files\LLVM"
win_vc = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
cc = "clang"
cxx = "clang++"
is_debug = true
skia_use_angle = true
skia_use_egl = true
extra_cflags = [
"/MTd",
"-I../../third_party/externals/angle2/include",
]
```
```
ninja -C out/Debug -k 0
```
Ignore this error: "lld-link: error: could not open 'EGL': no such file or directory"
convert icudtl.dat to object file in skia
```
cd SkiaRoot/third_party/externals/icu/flutter/
ld -r -b binary -o icudtl.o icudtl.dat
```
### Build flutter fml
### Build flutter txt
1. Setting up the Engine development environment

Apply the following diff:
```
diff --git a/fml/BUILD.gn b/fml/BUILD.gn
index 9b5626e78..da1322ce5 100644
--- a/fml/BUILD.gn
+++ b/fml/BUILD.gn
@@ -295,3 +295,10 @@ executable("fml_benchmarks") {
"//flutter/runtime:libdart",
--- a/third_party/txt/BUILD.gn
+++ b/third_party/txt/BUILD.gn
@@ -141,6 +141,7 @@ source_set("txt") {
"//third_party/harfbuzz",
"//third_party/icu",
"//third_party/skia",
+ "//third_party/skia/modules/skottie",
deps = [
@@ -339,3 +340,10 @@ executable("txt_benchmarks") {
deps += [ "//third_party/skia/modules/skparagraph" ]
}
+static_library("fml_lib") {
+static_library("txt_lib") {
+ "//flutter/fml",
+ ":txt",
update `out\host_debug_unopt\args.gn`
```
skia_use_angle = true
skia_use_egl = true
```
update skia
```
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -524,6 +524,7 @@ optional("gpu") {
if (skia_use_gl) {
public_defines += [ "SK_GL" ]
+ include_dirs = [ "//third_party/angle/include" ]
if (is_android) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
```
ninja -C .\out\host_debug_unopt\ flutter/fml:fml_lib
ninja -C out\host_debug_unopt flutter/third_party/txt:txt_lib
### Create symbolic
### Build Skia
1. Install LLVM
cmd
https://clang.llvm.org/get_started.html
2. Build skia
cd <uiwidigets_dir>\engine
cd third_party   \\ create the directory if not exists
mklink /D skia <SKIA_ROOT>
cd $FLUTTER_ROOT/third_party/skia
python2 tools/git-sync-deps
bin/gn gen out/Debug
```
Update out/Debug/args.gn with the following content:
```
clang_win = "C:\Program Files\LLVM/third_party/skia"
win_vc = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
cc = "clang"
cxx = "clang++"
is_debug = true
skia_use_angle = true
skia_use_egl = true
extra_cflags = [
"/MTd",
"-I../../third_party/externals/angle2/include",
]
Flutter engine txt include skia header in this pattern 'third_party/skia/*', so without symbolic, the txt lib will include skia
header file in flutter engine, instead of headers in skia repo.
```
ninja -C out/Debug -k 0
```
Ignore this error: "lld-link: error: could not open 'EGL': no such file or directory"
convert icudtl.dat to object file in flutter
```
cd flutterRoot/third_party/icu/flutter/
ld -r -b binary -o icudtl.o icudtl.dat
```
### Build Engine

4
engine/src/shell/platform/unity/windows/unity_surface_manager.cc


EGLint displayAttribs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE,
EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE,
// EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE,
EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE,
// EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE,
adapter_desc.AdapterLuid.LowPart,
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,

正在加载...
取消
保存