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/arkui/ace_engine/ace_config.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 = [ 56 "$ace_flutter_engine_root:flutter_config", 57 "$ace_flutter_engine_root/icu:icu_config_$platform", 58 ] 59 60 sources = [ 61 # Ability Cross-platform Environment(ACE) override 62 "$flutter_root/engine/flutter/shell/platform/embedder/ace_embedder.cc", 63 "$flutter_root/engine/flutter/shell/platform/embedder/ace_embedder_engine.cc", 64 "$flutter_root/engine/flutter/shell/platform/embedder/ace_platform_view_embedder.cc", 65 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_external_texture_gl.cc", 66 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_external_view_embedder.cc", 67 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_platform_message_response.cc", 68 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_render_target.cc", 69 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface.cc", 70 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface_gl.cc", 71 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_surface_software.cc", 72 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_task_runner.cc", 73 "$flutter_root/engine/flutter/shell/platform/embedder/embedder_thread_host.cc", 74 "$flutter_root/engine/flutter/shell/platform/embedder/vsync_waiter_embedder.cc", 75 ] 76 77 deps = [ 78 "$ace_flutter_engine_root:third_party_flutter_engine_$platform", 79 "$ace_flutter_engine_root/skia:ace_skia_$platform", 80 ] 81 } 82} 83 84foreach(item, ace_platforms) { 85 flutter_embedder_with_symbol_prefix( 86 "flutter_embedder_with_symbol_prefix_" + item.name) { 87 platform = item.name 88 defines = [] 89 cflags_cc = [] 90 config = { 91 } 92 93 if (defined(item.config)) { 94 config = item.config 95 } 96 97 if (defined(config.defines)) { 98 defines = config.defines 99 } 100 101 if (defined(config.cflags_cc)) { 102 cflags_cc = config.cflags_cc 103 } 104 } 105} 106 107template("flutter_platform_glfw") { 108 forward_variables_from(invoker, "*") 109 ohos_source_set(target_name) { 110 defines += invoker.defines 111 defines += [ "FLUTTER_DESKTOP_LIBRARY" ] 112 cflags_cc += invoker.cflags_cc 113 114 public_configs = [ 115 "$ace_flutter_engine_root:flutter_config", 116 "$ace_flutter_engine_root/icu:icu_config_$platform", 117 ":flutter_glfw_config", 118 ] 119 120 sources = [ 121 "$flutter_root/engine/flutter/shell/platform/glfw/glfw_event_loop.cc", 122 123 # Ability Cross-platform Environment(ACE) override 124 "$flutter_root/engine/flutter/shell/platform/glfw/flutter_glfw.cc", 125 ] 126 127 # GLFW client wrapper build 128 public = [ "$flutter_root/engine/flutter/shell/platform/glfw/client_wrapper/include/flutter/flutter_window.h" ] 129 130 include_dirs = [ 131 "$flutter_root/engine/flutter/shell/platform/common/cpp/client_wrapper/include/flutter", 132 "$flutter_root/engine/flutter/shell/platform/common/cpp/public", 133 ] 134 135 deps = [ 136 ":flutter_embedder_with_symbol_prefix_$platform", 137 ":flutter_platform_common_client_wrapper", 138 ] 139 140 # wait for glfw enabled in standard system 141 if (!is_standard_system || use_mingw_win || use_mac) { 142 deps += [ "//third_party/glfw:glfw_$platform" ] 143 } 144 } 145} 146 147foreach(item, ace_platforms) { 148 platform = item.name 149 if (platform == "windows" || platform == "mac") { 150 flutter_platform_glfw("flutter_glfw_preview_" + item.name) { 151 platform = item.name 152 defines = [] 153 cflags_cc = [] 154 config = { 155 } 156 157 if (defined(item.config)) { 158 config = item.config 159 } 160 161 if (defined(config.defines)) { 162 defines = config.defines 163 } 164 165 if (defined(config.cflags_cc)) { 166 cflags_cc = config.cflags_cc 167 } 168 } 169 } 170} 171