# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") import("//build/ohos.gni") import("//build/ohos/ace/ace.gni") import("//commonlibrary/ets_utils/ets_utils_config.gni") import("//foundation/arkui/ace_engine/ace_config.gni") import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni") container_names = [ "arraylist", "deque", "queue", "vector", "linkedlist", "list", "stack", "struct", "treemap", "treeset", "hashmap", "hashset", "lightweightmap", "lightweightset", "plainarray", ] # compile .ts to .js. action("build_js_ts") { script = "${ets_util_path}/js_util_module/container/build_ts_js.py" outFile_Path = target_out_dir + "/" + current_cpu args = [ "--dst-file", rebase_path(target_out_dir + "/"), "--out-filePath", rebase_path(outFile_Path), "--relative-path", rebase_path("//", root_build_dir), ] outputs = [] foreach(item, container_names) { dep = target_out_dir + "/js_" + item + ".js" outputs += [ dep ] } } config("container_config") { cflags_cc = [ "-std=c++17", "-Wno-deprecated-declarations", ] } # libs template("container_lib") { forward_variables_from(invoker, "*") name = target_name base_output_path = get_label_info(":js_" + name, "target_out_dir") gen_obj("js_" + name) { input = "$target_out_dir/js_" + name + ".js" if (use_mac || use_mingw_win || use_ios || use_linux) { js_container_obj_path = base_output_path + name + ".c" } else { js_container_obj_path = base_output_path + name + ".o" } output = js_container_obj_path snapshot_dep = [ ":build_js_ts" ] } # compile .js to .abc. es2abc_gen_abc("gen_" + name + "_abc") { extra_visibility = [ ":*" ] src_js = rebase_path(target_out_dir + "/js_" + name + ".js") dst_file = rebase_path(target_out_dir + "/" + name + ".abc") in_puts = [ target_out_dir + "/js_" + name + ".js" ] out_puts = [ target_out_dir + "/" + name + ".abc" ] extra_args = [ "--module" ] extra_dependencies = [ ":build_js_ts" ] } abc_output_path = get_label_info(":" + name + "_abc", "target_out_dir") gen_obj(name + "_abc") { input = "$target_out_dir/" + name + ".abc" if (use_mac || use_mingw_win || use_ios || use_linux) { arraylist_abc_obj_path = abc_output_path + "/" + name + "_abc.c" } else { arraylist_abc_obj_path = abc_output_path + "/" + name + "_abc.o" } output = arraylist_abc_obj_path snapshot_dep = [ ":gen_" + target_name ] } ohos_source_set(name + "_static") { include_dirs = [ "//third_party/node/src", "//commonlibrary/ets_utils/js_util_module/container/" + name, ] sources = [ name + "/native_module_" + name + ".cpp" ] dep_abc = ":gen_obj_src_" + name + "_abc" dep_js = ":gen_obj_src_js_" + name deps = [ "$container_root:gen_obj_src_js_" + name ] deps += [ dep_abc ] deps += [ dep_js ] if (is_arkui_x) { include_dirs += [ "$napi_root/interfaces/kits", "$plugins_root/hilog/include", "$plugins_root/interfaces", ] deps += [ "$plugins_root/libs/icu:icu_${target_os}", "$plugins_root/libs/napi:napi_${target_os}", "$plugins_root/libs/securec:sec_${target_os}", ] if (target_os == "android") { defines = [ "ANDROID_PLATFORM" ] } } else { external_deps = [ "hilog:libhilog", "napi:ace_napi", ] } configs = [ ":container_config" ] subsystem_name = "commonlibrary" part_name = "ets_utils" } ohos_shared_library(name) { deps = [ ":${name}_static" ] subsystem_name = "commonlibrary" part_name = "ets_utils" relative_install_dir = "module/util" } } container_libs = [] foreach(item, container_names) { container_lib(item) { } if (is_arkui_x) { dep = ":" + item + "_static" } else { dep = ":" + item } container_libs += [ dep ] } group("container_packages") { public_deps = container_libs } foreach(name, container_names) { group(name + "_packages") { if (is_arkui_x) { deps = [ ":" + name + "_static" ] } else { deps = [ ":" + name ] } } }