1# Copyright (c) 2021 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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") 15import("//build/ohos.gni") 16import("//build/ohos/ace/ace.gni") 17import("//commonlibrary/ets_utils/ets_utils_config.gni") 18import("//foundation/arkui/ace_engine/ace_config.gni") 19import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni") 20 21container_names = [ 22 "arraylist", 23 "deque", 24 "queue", 25 "vector", 26 "linkedlist", 27 "list", 28 "stack", 29 "struct", 30 "treemap", 31 "treeset", 32 "hashmap", 33 "hashset", 34 "lightweightmap", 35 "lightweightset", 36 "plainarray", 37] 38 39# compile .ts to .js. 40action("build_js_ts") { 41 script = "${ets_util_path}/js_util_module/container/build_ts_js.py" 42 outFile_Path = target_out_dir + "/" + current_cpu 43 args = [ 44 "--dst-file", 45 rebase_path(target_out_dir + "/"), 46 "--out-filePath", 47 rebase_path(outFile_Path), 48 "--relative-path", 49 rebase_path("//", root_build_dir), 50 ] 51 52 outputs = [] 53 foreach(item, container_names) { 54 dep = target_out_dir + "/js_" + item + ".js" 55 outputs += [ dep ] 56 } 57} 58 59config("container_config") { 60 cflags_cc = [ 61 "-std=c++17", 62 "-Wno-deprecated-declarations", 63 ] 64} 65 66# libs 67template("container_lib") { 68 forward_variables_from(invoker, "*") 69 70 name = target_name 71 base_output_path = get_label_info(":js_" + name, "target_out_dir") 72 gen_obj("js_" + name) { 73 input = "$target_out_dir/js_" + name + ".js" 74 if (use_mac || use_mingw_win || use_ios || use_linux) { 75 js_container_obj_path = base_output_path + name + ".c" 76 } else { 77 js_container_obj_path = base_output_path + name + ".o" 78 } 79 output = js_container_obj_path 80 snapshot_dep = [ ":build_js_ts" ] 81 } 82 83 # compile .js to .abc. 84 es2abc_gen_abc("gen_" + name + "_abc") { 85 extra_visibility = [ ":*" ] 86 src_js = rebase_path(target_out_dir + "/js_" + name + ".js") 87 dst_file = rebase_path(target_out_dir + "/" + name + ".abc") 88 in_puts = [ target_out_dir + "/js_" + name + ".js" ] 89 out_puts = [ target_out_dir + "/" + name + ".abc" ] 90 extra_args = [ "--module" ] 91 extra_dependencies = [ ":build_js_ts" ] 92 } 93 94 abc_output_path = get_label_info(":" + name + "_abc", "target_out_dir") 95 gen_obj(name + "_abc") { 96 input = "$target_out_dir/" + name + ".abc" 97 if (use_mac || use_mingw_win || use_ios || use_linux) { 98 arraylist_abc_obj_path = abc_output_path + "/" + name + "_abc.c" 99 } else { 100 arraylist_abc_obj_path = abc_output_path + "/" + name + "_abc.o" 101 } 102 output = arraylist_abc_obj_path 103 snapshot_dep = [ ":gen_" + target_name ] 104 } 105 106 ohos_source_set(name + "_static") { 107 branch_protector_ret = "pac_ret" 108 sanitize = { 109 cfi = true 110 cfi_cross_dso = true 111 debug = false 112 } 113 include_dirs = [ 114 "//third_party/node/src", 115 "//commonlibrary/ets_utils/js_util_module/container/" + name, 116 ets_util_path, 117 ] 118 119 sources = [ name + "/native_module_" + name + ".cpp" ] 120 121 dep_abc = ":gen_obj_src_" + name + "_abc" 122 dep_js = ":gen_obj_src_js_" + name 123 deps = [ "$container_root:gen_obj_src_js_" + name ] 124 deps += [ dep_abc ] 125 deps += [ dep_js ] 126 127 if (is_arkui_x) { 128 include_dirs += [ 129 "$napi_root/interfaces/kits", 130 "$plugins_root/hilog/include", 131 "$plugins_root/interfaces", 132 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 133 ] 134 135 deps += [ 136 "$plugins_root/libs/icu:icu_${target_os}", 137 "$plugins_root/libs/napi:napi_${target_os}", 138 "$plugins_root/libs/securec:sec_${target_os}", 139 ] 140 141 if (target_os == "android") { 142 defines = [ "ANDROID_PLATFORM" ] 143 } 144 } else { 145 external_deps = [ 146 "hilog:libhilog", 147 "napi:ace_napi", 148 ] 149 } 150 151 configs = [ ":container_config" ] 152 153 subsystem_name = "commonlibrary" 154 part_name = "ets_utils" 155 } 156 ohos_shared_library(name) { 157 branch_protector_ret = "pac_ret" 158 sanitize = { 159 cfi = true 160 cfi_cross_dso = true 161 debug = false 162 } 163 deps = [ ":${name}_static" ] 164 external_deps = [ "hilog:libhilog" ] 165 subsystem_name = "commonlibrary" 166 part_name = "ets_utils" 167 relative_install_dir = "module/util" 168 } 169} 170 171container_libs = [] 172foreach(item, container_names) { 173 container_lib(item) { 174 } 175 if (is_arkui_x) { 176 dep = ":" + item + "_static" 177 } else { 178 dep = ":" + item 179 } 180 container_libs += [ dep ] 181} 182 183group("container_packages") { 184 public_deps = container_libs 185} 186 187foreach(name, container_names) { 188 group(name + "_packages") { 189 if (is_arkui_x) { 190 deps = [ ":" + name + "_static" ] 191 } else { 192 deps = [ ":" + name ] 193 } 194 } 195} 196