1# Copyright (c) 2021-2022 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("//foundation/arkui/ace_engine/ace_config.gni") 15 16source_set("ace_resource") { 17 include_dirs = [ "//third_party/bounds_checking_function/include" ] 18 19 # add resource file here 20 sources = [ 21 "ace_res_config.cpp", 22 "ace_res_key_parser.cpp", 23 "data_provider_manager.cpp", 24 "internal_resource.cpp", 25 "shared_image_manager.cpp", 26 ] 27 if (current_os == "mac" || current_os == "mingw" || current_os == "ios" || 28 current_os == "linux" || current_os == "android") { 29 deps = [ ":binary_resource_mac_and_windows" ] 30 sources -= [ "internal_resource.cpp" ] 31 sources += [ "internal_resource_previewer.cpp" ] 32 } else { 33 deps = [ ":binary_resource" ] 34 } 35 configs += [ "$ace_root:ace_config" ] 36 37 if (current_os == "mingw") { 38 cflags_cc = [ "-std=c++17" ] 39 } 40} 41 42source_set("binary_resource") { 43 deps = [ ":objcopy_resource" ] 44 ace_resource_dir = 45 get_label_info(":binary_resource($current_toolchain)", "target_out_dir") 46 sources = [ 47 "$ace_resource_dir/entry.o", 48 "$ace_resource_dir/errorcode.o", 49 "$ace_resource_dir/indexletter_bar.o", 50 ] 51} 52 53source_set("binary_resource_mac_and_windows") { 54 deps = [ ":objcopy_resource_mac_and_windows" ] 55 ace_resource_dir = 56 get_label_info(":binary_resource($current_toolchain)", "target_out_dir") 57 sources = [ 58 "$ace_resource_dir/entry.c", 59 "$ace_resource_dir/errorcode.c", 60 "$ace_resource_dir/indexletter_bar.c", 61 ] 62} 63 64action_foreach("objcopy_resource") { 65 # add resource file here 66 sources = [ 67 "binary/i18n/entry.json", 68 "binary/i18n/errorcode.json", 69 "binary/indexletter_bar.json", 70 ] 71 72 ace_resource_dir = 73 get_label_info(":binary_resource($current_toolchain)", "target_out_dir") 74 75 outputs = [ "$ace_resource_dir/{{source_name_part}}.o" ] 76 77 objcopy_tool = objcopy_default 78 script = "$ace_root/build/tools/run_objcopy.py" 79 if (target_cpu == "x86_64") { 80 objcopy_tool = objcopy_x86_64 81 } 82 83 args = [ 84 "--objcopy", 85 rebase_path("$objcopy_tool"), 86 "--input", 87 "{{source}}", 88 "--output", 89 rebase_path("$ace_resource_dir/") + "{{source_name_part}}.o", 90 "--arch", 91 current_cpu, 92 ] 93} 94 95action_foreach("objcopy_resource_mac_and_windows") { 96 # add resource file here 97 sources = [ 98 "binary/i18n/entry.json", 99 "binary/i18n/errorcode.json", 100 "binary/indexletter_bar.json", 101 ] 102 103 ace_resource_dir = 104 get_label_info(":binary_resource($current_toolchain)", "target_out_dir") 105 106 outputs = [ "$ace_resource_dir/{{source_name_part}}.c" ] 107 108 script = "$ace_root/build/tools/build_resource_to_bytecode.py" 109 out_target = rebase_path("$ace_resource_dir/") + "{{source_name_part}}.c" 110 111 args = [ 112 "--input", 113 "{{source}}", 114 "--output", 115 out_target, 116 ] 117} 118