1# Copyright (c) 2021-2023 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("//foundation/arkui/ace_engine/ace_config.gni") 16import("//third_party/flutter/flutter_config.gni") 17 18config("flutter_glfw_config") { 19 visibility = [ ":*" ] 20 include_dirs = [ 21 "$flutter_root/engine/flutter/shell/platform/common/cpp/public", 22 "$flutter_root/engine/flutter/shell/platform/glfw/public", 23 ] 24} 25 26ohos_source_set("flutter_platform_common_client_wrapper") { 27 part_name = flutter_part 28 subsystem_name = flutter_subsystem 29 sources = [ 30 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/engine_method_result.cc", 31 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/standard_codec.cc", 32 ] 33 34 public = [ 35 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/basic_message_channel.h", 36 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h", 37 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/encodable_value.h", 38 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/engine_method_result.h", 39 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/message_codec.h", 40 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_call.h", 41 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h", 42 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_codec.h", 43 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_result.h", 44 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h", 45 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h", 46 ] 47 48 defines = [ "FLUTTER_DESKTOP_LIBRARY" ] 49} 50 51template("flutter_embedder_with_symbol_prefix") { 52 forward_variables_from(invoker, "*") 53 ohos_source_set(target_name) { 54 part_name = flutter_part 55 subsystem_name = flutter_subsystem 56 defines += invoker.defines 57 defines += [ "FLUTTER_API_SYMBOL_PREFIX=Embedder" ] 58 cflags_cc += invoker.cflags_cc 59 60 public_configs = [ 61 "$ace_flutter_engine_root:flutter_config", 62 "$ace_flutter_engine_root/icu:icu_config_$platform", 63 ] 64 65 sources = [ 66 # Ability Cross-platform Environment(ACE) override 67 "$flutter_root/engine/flutter/shell/platform/embedder/ace_embedder.cc", 68 "$flutter_root/engine/flutter/shell/platform/embedder/ace_embedder_engine.cc", 69 "$flutter_root/engine/flutter/shell/platform/embedder/ace_platform_view_embedder.cc", 70 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_external_texture_gl.cc", 71 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_external_view_embedder.cc", 72 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_platform_message_response.cc", 73 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_render_target.cc", 74 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface.cc", 75 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface_gl.cc", 76 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface_software.cc", 77 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_task_runner.cc", 78 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_thread_host.cc", 79 "$flutter_root/engine/flutter/shell/platform/embedder/vsync_waiter_embedder.cc", 80 ] 81 82 deps = [ 83 "$ace_flutter_engine_root:third_party_flutter_engine_$platform", 84 "$ace_flutter_engine_root/skia:ace_skia_$platform", 85 ] 86 } 87} 88 89foreach(item, ace_platforms) { 90 flutter_embedder_with_symbol_prefix( 91 "flutter_embedder_with_symbol_prefix_" + item.name) { 92 platform = item.name 93 defines = [] 94 cflags_cc = [] 95 config = { 96 } 97 98 if (defined(item.config)) { 99 config = item.config 100 } 101 102 if (defined(config.defines)) { 103 defines = config.defines 104 } 105 106 if (defined(config.cflags_cc)) { 107 cflags_cc = config.cflags_cc 108 } 109 } 110} 111 112template("flutter_platform_glfw") { 113 forward_variables_from(invoker, "*") 114 ohos_source_set(target_name) { 115 part_name = flutter_part 116 subsystem_name = flutter_subsystem 117 defines += invoker.defines 118 defines += [ "FLUTTER_DESKTOP_LIBRARY" ] 119 cflags_cc += invoker.cflags_cc 120 121 public_configs = [ 122 "$ace_flutter_engine_root:flutter_config", 123 "$ace_flutter_engine_root/icu:icu_config_$platform", 124 ":flutter_glfw_config", 125 ] 126 127 sources = [ 128 "$flutter_root/engine/flutter/shell/platform/glfw/glfw_event_loop.cc", 129 130 # Ability Cross-platform Environment(ACE) override 131 "$flutter_root/engine/flutter/shell/platform/glfw/flutter_glfw.cc", 132 ] 133 134 # GLFW client wrapper build 135 public = [ "$flutter_root/engine/flutter/shell/platform/glfw/client_wrapper/include/flutter/flutter_window.h" ] 136 137 include_dirs = [ 138 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter", 139 "$flutter_root/engine/flutter/shell/platform/common/cpp/public", 140 ] 141 142 if (platform == "linux") { 143 libs = [ "GL" ] 144 } else if (platform == "windows") { 145 libs = [ "opengl32" ] 146 } else if (platform == "mac") { 147 if (defined(enable_gn_2021)) { 148 frameworks = [ "OpenGL.framework" ] 149 } else { 150 libs = [ "OpenGL.framework" ] 151 } 152 } 153 154 deps = [ 155 ":flutter_embedder_with_symbol_prefix_$platform", 156 ":flutter_platform_common_client_wrapper", 157 ] 158 159 # wait for glfw enabled in standard system 160 if (!is_standard_system || use_mingw_win || use_mac || use_linux) { 161 deps += [ "$flutter_root/glfw:glfw" ] 162 } 163 } 164} 165 166foreach(item, ace_platforms) { 167 platform = item.name 168 if (platform == "windows" || platform == "mac" || platform == "linux") { 169 flutter_platform_glfw("flutter_glfw_preview_" + item.name) { 170 platform = item.name 171 defines = [] 172 cflags_cc = [] 173 config = { 174 } 175 176 if (defined(item.config)) { 177 config = item.config 178 } 179 180 if (defined(config.defines)) { 181 defines = config.defines 182 } 183 184 if (defined(config.cflags_cc)) { 185 cflags_cc = config.cflags_cc 186 } 187 } 188 } 189} 190