123b3eb3cSopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd.
223b3eb3cSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
323b3eb3cSopenharmony_ci# you may not use this file except in compliance with the License.
423b3eb3cSopenharmony_ci# You may obtain a copy of the License at
523b3eb3cSopenharmony_ci#
623b3eb3cSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
723b3eb3cSopenharmony_ci#
823b3eb3cSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
923b3eb3cSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1023b3eb3cSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1123b3eb3cSopenharmony_ci# See the License for the specific language governing permissions and
1223b3eb3cSopenharmony_ci# limitations under the License.
1323b3eb3cSopenharmony_ci
1423b3eb3cSopenharmony_ciimport("//build/ohos.gni")
1523b3eb3cSopenharmony_ciimport("//foundation/arkui/ace_engine/ace_config.gni")
1623b3eb3cSopenharmony_ciimport("//foundation/arkui/ace_engine/interfaces/napi/kits/napi_lib.gni")
1723b3eb3cSopenharmony_ci
1823b3eb3cSopenharmony_ci# Build libace static library
1923b3eb3cSopenharmony_citemplate("libace_static") {
2023b3eb3cSopenharmony_ci  forward_variables_from(invoker, "*")
2123b3eb3cSopenharmony_ci
2223b3eb3cSopenharmony_ci  ohos_source_set(target_name) {
2323b3eb3cSopenharmony_ci    if (current_os == "ohos") {
2423b3eb3cSopenharmony_ci      sanitize = {
2523b3eb3cSopenharmony_ci        integer_overflow = true
2623b3eb3cSopenharmony_ci        boundary_sanitize = true
2723b3eb3cSopenharmony_ci        debug = ace_sanitize_debug
2823b3eb3cSopenharmony_ci      }
2923b3eb3cSopenharmony_ci    }
3023b3eb3cSopenharmony_ci
3123b3eb3cSopenharmony_ci    deps = [ "$ace_root/frameworks/base:ace_base_$platform" ]
3223b3eb3cSopenharmony_ci    external_deps = []
3323b3eb3cSopenharmony_ci    if (use_mingw_win || use_mac || use_linux) {
3423b3eb3cSopenharmony_ci      external_deps += [
3523b3eb3cSopenharmony_ci        "icu:shared_icui18n",
3623b3eb3cSopenharmony_ci        "icu:shared_icuuc",
3723b3eb3cSopenharmony_ci      ]
3823b3eb3cSopenharmony_ci    }
3923b3eb3cSopenharmony_ci
4023b3eb3cSopenharmony_ci    if (platform == "ohos_ng" || is_arkui_x) {
4123b3eb3cSopenharmony_ci      deps += [
4223b3eb3cSopenharmony_ci        "$ace_root/frameworks/bridge:framework_bridge_ng_$platform",
4323b3eb3cSopenharmony_ci        "$ace_root/frameworks/core:ace_core_ng_$platform",
4423b3eb3cSopenharmony_ci      ]
4523b3eb3cSopenharmony_ci    } else if (platform == "ohos" && !is_asan) {
4623b3eb3cSopenharmony_ci      deps += [
4723b3eb3cSopenharmony_ci        "$ace_root/frameworks/bridge:framework_bridge_$platform",
4823b3eb3cSopenharmony_ci        "$ace_root/frameworks/core:ace_core_$platform",
4923b3eb3cSopenharmony_ci      ]
5023b3eb3cSopenharmony_ci
5123b3eb3cSopenharmony_ci      # add napi lib to libace.z.so for auto load in old generation mode
5223b3eb3cSopenharmony_ci      foreach(module, common_napi_libs) {
5323b3eb3cSopenharmony_ci        target_names = []
5423b3eb3cSopenharmony_ci        prefix_dir = []
5523b3eb3cSopenharmony_ci        module_path = []
5623b3eb3cSopenharmony_ci        module_name = []
5723b3eb3cSopenharmony_ci
5823b3eb3cSopenharmony_ci        target_names = string_split(module, "/")
5923b3eb3cSopenharmony_ci        prefix_dir = target_names[0]
6023b3eb3cSopenharmony_ci        if (prefix_dir != module) {
6123b3eb3cSopenharmony_ci          module_path = target_names[1]
6223b3eb3cSopenharmony_ci        } else {
6323b3eb3cSopenharmony_ci          module_path = prefix_dir
6423b3eb3cSopenharmony_ci        }
6523b3eb3cSopenharmony_ci        module_name = string_replace(module_path, "_", "")
6623b3eb3cSopenharmony_ci
6723b3eb3cSopenharmony_ci        # prompt and promptaction uses same sourcefile, remove it in static compile
6823b3eb3cSopenharmony_ci        if (module_name != "prompt") {
6923b3eb3cSopenharmony_ci          deps += [ "$ace_root/interfaces/napi/kits/${module_path}:${module_name}_static_${platform}" ]
7023b3eb3cSopenharmony_ci        }
7123b3eb3cSopenharmony_ci      }
7223b3eb3cSopenharmony_ci    } else {
7323b3eb3cSopenharmony_ci      deps += [
7423b3eb3cSopenharmony_ci        "$ace_root/frameworks/bridge:framework_bridge_$platform",
7523b3eb3cSopenharmony_ci        "$ace_root/frameworks/core:ace_core_$platform",
7623b3eb3cSopenharmony_ci      ]
7723b3eb3cSopenharmony_ci    }
7823b3eb3cSopenharmony_ci
7923b3eb3cSopenharmony_ci    if (defined(config.platform_deps)) {
8023b3eb3cSopenharmony_ci      deps += config.platform_deps
8123b3eb3cSopenharmony_ci    }
8223b3eb3cSopenharmony_ci
8323b3eb3cSopenharmony_ci    # build-in ark js engine for preview
8423b3eb3cSopenharmony_ci    if (defined(config.use_build_in_js_engine) &&
8523b3eb3cSopenharmony_ci        config.use_build_in_js_engine && defined(config.ark_engine)) {
8623b3eb3cSopenharmony_ci      if (platform == "ohos_ng" || is_arkui_x) {
8723b3eb3cSopenharmony_ci        deps += [ "$ace_root/frameworks/bridge/declarative_frontend:declarative_js_engine_ng_ark_$platform" ]
8823b3eb3cSopenharmony_ci      } else {
8923b3eb3cSopenharmony_ci        deps += [
9023b3eb3cSopenharmony_ci          "$ace_root/frameworks/bridge/declarative_frontend:declarative_js_engine_ark_$platform",
9123b3eb3cSopenharmony_ci          "$ace_root/frameworks/bridge/js_frontend/engine:js_engine_ark_$platform",
9223b3eb3cSopenharmony_ci        ]
9323b3eb3cSopenharmony_ci      }
9423b3eb3cSopenharmony_ci    }
9523b3eb3cSopenharmony_ci    configs = [ "$ace_root:ace_coverage_config" ]
9623b3eb3cSopenharmony_ci    if (use_hilog) {
9723b3eb3cSopenharmony_ci      external_deps += [ "hilog:libhilog" ]
9823b3eb3cSopenharmony_ci    }
9923b3eb3cSopenharmony_ci    part_name = ace_engine_part
10023b3eb3cSopenharmony_ci    subsystem_name = ace_engine_subsystem
10123b3eb3cSopenharmony_ci  }
10223b3eb3cSopenharmony_ci}
10323b3eb3cSopenharmony_ci
10423b3eb3cSopenharmony_ci# build platform engine sources
10523b3eb3cSopenharmony_citemplate("ace_bridge_engine") {
10623b3eb3cSopenharmony_ci  forward_variables_from(invoker, "*")
10723b3eb3cSopenharmony_ci
10823b3eb3cSopenharmony_ci  ohos_shared_library(target_name) {
10923b3eb3cSopenharmony_ci    configs = [ "$ace_root:ace_coverage_config" ]
11023b3eb3cSopenharmony_ci    deps = []
11123b3eb3cSopenharmony_ci
11223b3eb3cSopenharmony_ci    assert(defined(platform) && (platform == "ohos" || platform == "ohos_ng"),
11323b3eb3cSopenharmony_ci           "Only ohos need separated engine lib")
11423b3eb3cSopenharmony_ci
11523b3eb3cSopenharmony_ci    if (use_hilog) {
11623b3eb3cSopenharmony_ci      external_deps = [ "hilog:libhilog" ]
11723b3eb3cSopenharmony_ci    }
11823b3eb3cSopenharmony_ci    if (build_type == "engine") {
11923b3eb3cSopenharmony_ci      if (use_js_debug) {
12023b3eb3cSopenharmony_ci        deps += [ "$ace_root/frameworks/bridge/js_frontend/engine:js_engine_${engine_name}_debug_$platform" ]
12123b3eb3cSopenharmony_ci      } else {
12223b3eb3cSopenharmony_ci        deps += [ "$ace_root/frameworks/bridge/js_frontend/engine:js_engine_${engine_name}_$platform" ]
12323b3eb3cSopenharmony_ci      }
12423b3eb3cSopenharmony_ci    } else if (build_type == "engine_declarative") {
12523b3eb3cSopenharmony_ci      deps += [ "$ace_root/frameworks/bridge/declarative_frontend:declarative_js_engine_${engine_name}_$platform" ]
12623b3eb3cSopenharmony_ci    } else if (build_type == "engine_pa") {
12723b3eb3cSopenharmony_ci      deps += [ "$ace_root/${pa_engine_path}/engine:js_pa_engine_${engine_name}_$platform" ]
12823b3eb3cSopenharmony_ci    }
12923b3eb3cSopenharmony_ci
13023b3eb3cSopenharmony_ci    subsystem_name = ace_engine_subsystem
13123b3eb3cSopenharmony_ci    part_name = ace_engine_part
13223b3eb3cSopenharmony_ci  }
13323b3eb3cSopenharmony_ci}
134