1# Copyright (c) 2024 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("//build/ohos.gni")
15import("//foundation/ability/ability_runtime/ability_runtime.gni")
16import("//foundation/ability/ability_runtime/cj_environment/cj_environment.gni")
17
18config("cj_rt_public_config") {
19  include_dirs = [
20    "include",
21    "${ability_runtime_path}/cj_environment/interfaces/inner_api",
22  ]
23  defines = cj_config.common_defines
24}
25
26ohos_shared_library("cj_environment") {
27  branch_protector_ret = "pac_ret"
28
29  cflags_cc = [
30    "-std=c++17",
31    "-fvisibility=hidden",
32    "-fdata-sections",
33    "-ffunction-sections",
34  ]
35
36  public_configs = [ ":cj_rt_public_config" ]
37
38  sanitize = {
39    cfi = true
40    cfi_cross_dso = true
41    debug = false
42  }
43
44  sources = [ "src/cj_environment.cpp" ]
45
46  defines = []
47
48  external_deps = [
49    "c_utils:utils",
50    "hilog:libhilog",
51  ]
52
53  if (current_os == "ohos") {
54    sources += [ "src/dynamic_loader_ohos.cpp" ]
55    external_deps += [ "eventhandler:libeventhandler" ]
56    defines += [ "WITH_EVENT_HANDLER" ]
57  } else if (current_os == "linux") {
58    sources += [ "src/dynamic_loader_linux.cpp" ]
59  } else if (current_os == "mingw") {
60    sources += [ "src/dynamic_loader_win.cpp" ]
61  } else {
62    assert("unsupport platform: ${current_os}")
63  }
64
65  innerapi_tags = [ "platformsdk" ]
66  part_name = "ability_runtime"
67  subsystem_name = "ability"
68}
69