From dd1c1e8d0b1794163d0b7affbae3870c6686a234 Mon Sep 17 00:00:00 2001 From: lee Date: Thu, 9 Mar 2023 15:17:02 +0800 Subject: [PATCH] build skia as shared lib Signed-off-by: lee --- build/glfw/BUILD.gn | 14 +++++++- build/harfbuzz/BUILD.gn | 4 +-- build/skia/BUILD.gn | 71 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 7 deletions(-) diff --git a/build/glfw/BUILD.gn b/build/glfw/BUILD.gn index dd4864c9..a9b0a6ce 100644 --- a/build/glfw/BUILD.gn +++ b/build/glfw/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -139,6 +139,18 @@ template("flutter_platform_glfw") { "$flutter_root/engine/flutter/shell/platform/common/cpp/public", ] + if (platform == "linux") { + libs = [ "GL" ] + } else if (platform == "windows") { + libs = [ "opengl32" ] + } else if (platform == "mac") { + if (defined(enable_gn_2021)) { + frameworks = [ "OpenGL.framework" ] + } else { + libs = [ "OpenGL.framework" ] + } + } + deps = [ ":flutter_embedder_with_symbol_prefix_$platform", ":flutter_platform_common_client_wrapper", diff --git a/build/harfbuzz/BUILD.gn b/build/harfbuzz/BUILD.gn index dcc80e16..dd30b3d9 100644 --- a/build/harfbuzz/BUILD.gn +++ b/build/harfbuzz/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -20,7 +20,6 @@ config("libharfbuzz_compile_flags") { "-std=c++14", "-fno-exceptions", "-fno-rtti", - "-fvisibility-inlines-hidden", "-Os", ] @@ -33,7 +32,6 @@ config("libharfbuzz_compile_flags") { "-gline-tables-only", "-funwind-tables", "-Wno-unused-parameter", - "-fvisibility=hidden", ] include_dirs = [ diff --git a/build/skia/BUILD.gn b/build/skia/BUILD.gn index c6c56f5b..aed9f69f 100644 --- a/build/skia/BUILD.gn +++ b/build/skia/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -111,11 +111,21 @@ template("make_skia_deps") { ] sources = [ "$flutter_root/skia/src/utils/SkParsePath.cpp" ] + } else if ((platform == "linux" || platform == "mac" || + platform == "windows") && + defined(config.enable_rosen_backend) && + config.enable_rosen_backend) { + public_configs = [ + ":skia_config", + ":harfbuzz_config", + ] + public_deps = [ ":skia_shared" ] } else { public_configs = [ ":skia_config", ":harfbuzz_config", ] + configs = [ ":skia_visibility_hidden_config" ] deps = [ ":ace_fontmgr_$platform", @@ -170,6 +180,57 @@ foreach(item, ace_platforms) { # Skia main target config end # ------------------------------------------------ +ohos_shared_library("skia_shared") { + platform = current_os + if (current_os == "mingw") { + platform = "windows" + } + part_name = flutter_part + subsystem_name = flutter_subsystem + public_configs = [ + ":skia_config", + ":harfbuzz_config", + ] + + deps = [ + ":ace_fontmgr_$platform", + ":ace_gif", + ":ace_gpu_$platform", + ":ace_heif", + ":ace_jpeg", + ":ace_pdf_$platform", + ":ace_png_$platform", + ":ace_skcms", + ":ace_skia_core_$platform", + ":ace_skia_opts_$platform", + ":ace_svg_model_$platform", + ":ace_typeface_freetype", + ":ace_webp", + ":ace_xml", + ":make_third_party_skia_include_dir", + "$ace_flutter_engine_root/freetype:ace_libfreetype2", + "$ace_flutter_engine_root/harfbuzz:ace_libharfbuzz_$platform", + "$ace_flutter_engine_root/icu:ace_libicu_$platform", + "$ace_flutter_engine_root/libjpeg:ace_libjpeg", + "$ace_flutter_engine_root/libpng:ace_libpng", + "$ace_flutter_engine_root/libwebp:ace_libwebp", + "$ace_flutter_engine_root/sfntly:ace_libsfntly_$platform", + ] + + if (defined(disable_gpu) && disable_gpu) { + deps -= [ ":ace_gpu_$platform" ] + } else { + public_deps = [ "//foundation/graphic/graphic_2d:libgl" ] + } + + public_configs += [ + ":ace_svg_model_config", + ":skia_deps_include_config", + ] + + deps += [ "//third_party/bounds_checking_function:libsec_shared" ] +} + # ------------------------------------------------ # Skia common config begin # ------------------------------------------------ @@ -184,6 +245,12 @@ config("skia_deps_include_config") { ] } +config("skia_visibility_hidden_config") { + cflags_cc = [ "-fvisibility-inlines-hidden" ] + + cflags = [ "-fvisibility=hidden" ] +} + ace_skia_common_ccflags = [ "-std=c++14", "-fno-exceptions", @@ -202,7 +269,6 @@ ace_skia_common_ccflags = [ "-Wno-suggest-override", "-Wno-psabi", "-Wno-four-char-constants", - "-fvisibility-inlines-hidden", "-Os", "-DSKIA_DLL", ] @@ -267,7 +333,6 @@ ace_skia_common_cflags = [ "-Wno-tautological-value-range-compare", "-Wno-suggest-override", "-Wno-reserved-identifier", - "-fvisibility=hidden", "-Os", "-DSKIA_DLL", ] -- Gitee