1# Copyright (c) 2022 Huawei Device Co., Ltd.. All rights reserved. 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/graphic/graphic_2d/ace_platforms.gni") 16 17config("flutter_glfw_config") { 18 visibility = [ ":*" ] 19 include_dirs = [ 20 "$flutter_root/engine/flutter/shell/platform/common/cpp/public", 21 "$flutter_root/engine/flutter/shell/platform/glfw/public", 22 ] 23} 24 25ohos_source_set("flutter_platform_common_client_wrapper") { 26 sources = [ 27 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/engine_method_result.cc", 28 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/standard_codec.cc", 29 ] 30 31 public = [ 32 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/basic_message_channel.h", 33 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h", 34 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/encodable_value.h", 35 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/engine_method_result.h", 36 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/message_codec.h", 37 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_call.h", 38 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h", 39 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_codec.h", 40 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_result.h", 41 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h", 42 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h", 43 ] 44 45 defines = [ "FLUTTER_DESKTOP_LIBRARY" ] 46} 47 48template("flutter_embedder_with_symbol_prefix") { 49 forward_variables_from(invoker, "*") 50 ohos_source_set(target_name) { 51 defines += invoker.defines 52 defines += [ "FLUTTER_API_SYMBOL_PREFIX=Embedder" ] 53 cflags_cc += invoker.cflags_cc 54 55 public_configs = [ "$ace_flutter_engine_root/icu:icu_config_$platform" ] 56 57 sources = [ 58 # Ability Cross-platform Environment(ACE) override 59 "$flutter_root/engine/flutter/shell/platform/embedder/ace_embedder.cc", 60 "$flutter_root/engine/flutter/shell/platform/embedder/ace_embedder_engine.cc", 61 "$flutter_root/engine/flutter/shell/platform/embedder/ace_platform_view_embedder.cc", 62 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_external_texture_gl.cc", 63 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_external_view_embedder.cc", 64 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_platform_message_response.cc", 65 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_render_target.cc", 66 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface.cc", 67 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface_gl.cc", 68 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface_software.cc", 69 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_task_runner.cc", 70 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_thread_host.cc", 71 "$flutter_root/engine/flutter/shell/platform/embedder/vsync_waiter_embedder.cc", 72 ] 73 74 deps = [ 75 "$ace_flutter_engine_root:third_party_flutter_engine_$platform", 76 "$ace_flutter_engine_root/skia:ace_skia_$platform", 77 ] 78 } 79} 80 81foreach(item, ace_platforms) { 82 flutter_embedder_with_symbol_prefix( 83 "flutter_embedder_with_symbol_prefix_" + item.name) { 84 platform = item.name 85 defines = [] 86 cflags_cc = [] 87 config = { 88 } 89 90 if (defined(item.config)) { 91 config = item.config 92 } 93 94 if (defined(config.defines)) { 95 defines = config.defines 96 } 97 98 if (defined(config.cflags_cc)) { 99 cflags_cc = config.cflags_cc 100 } 101 } 102} 103 104template("flutter_platform_glfw") { 105 forward_variables_from(invoker, "*") 106 ohos_source_set(target_name) { 107 defines += invoker.defines 108 defines += [ "FLUTTER_DESKTOP_LIBRARY" ] 109 cflags_cc += invoker.cflags_cc 110 111 public_configs = [ 112 "$ace_flutter_engine_root/icu:icu_config_$platform", 113 ":flutter_glfw_config", 114 ] 115 116 sources = [ 117 "$flutter_root/engine/flutter/shell/platform/glfw/glfw_event_loop.cc", 118 119 # Ability Cross-platform Environment(ACE) override 120 "$flutter_root/engine/flutter/shell/platform/glfw/flutter_glfw.cc", 121 ] 122 123 # GLFW client wrapper build 124 public = [ "$flutter_root/engine/flutter/shell/platform/glfw/client_wrapper/include/flutter/flutter_window.h" ] 125 126 include_dirs = [ 127 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter", 128 "$flutter_root/engine/flutter/shell/platform/common/cpp/public", 129 ] 130 131 deps = [ 132 ":flutter_embedder_with_symbol_prefix_$platform", 133 ":flutter_platform_common_client_wrapper", 134 ] 135 136 # wait for glfw enabled in standard system 137 if (!is_standard_system || use_mingw_win || use_mac) { 138 deps += [ "//third_party/glfw:glfw_$platform" ] 139 } 140 } 141} 142 143foreach(item, ace_platforms) { 144 platform = item.name 145 if (platform == "windows" || platform == "mac") { 146 flutter_platform_glfw("flutter_glfw_preview_" + item.name) { 147 platform = item.name 148 defines = [] 149 cflags_cc = [] 150 config = { 151 } 152 153 if (defined(item.config)) { 154 config = item.config 155 } 156 157 if (defined(config.defines)) { 158 defines = config.defines 159 } 160 161 if (defined(config.cflags_cc)) { 162 cflags_cc = config.cflags_cc 163 } 164 } 165 } 166} 167