• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2025 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
14if (defined(ohos_lite)) {
15  import("//build/lite/config/component/lite_component.gni")
16} else {
17  import("//build/ohos.gni")
18}
19import("//foundation/distributedhardware/device_manager/device_manager.gni")
20
21if (defined(ohos_lite)) {
22  if (ohos_kernel_type == "linux") {
23    shared_library("devicemanagerjson") {
24      include_dirs = [
25        "include",
26        "${common_path}/include",
27      ]
28
29      if (use_nlohmann_json) {
30        include_dirs += [ "//third_party/json/include" ]
31      } else {
32        include_dirs += [ "//third_party/cJSON" ]
33      }
34
35      if (use_nlohmann_json) {
36        sources = [ "src/json_object_nlohmannjson.cpp" ]
37      } else {
38        sources = [ "src/json_object_cjson.cpp" ]
39      }
40
41      defines = [
42        "HI_LOG_ENABLE",
43        "DH_LOG_TAG=\"devicemanagerjson\"",
44        "LOG_DOMAIN=0xD004110",
45      ]
46
47      deps = [ "${hilog_path}:hilog_shared" ]
48    }
49  }
50} else {
51  config("cflags_config") {
52    cflags = [
53      "-Werror",
54      "-fPIC",
55      "-fstack-protector-strong",
56      "-ffunction-sections",
57      "-fdata-sections",
58      "-Oz",
59      "-flto",
60    ]
61    ldflags = [ "-flto" ]
62  }
63
64  ohos_shared_library("devicemanagerjson") {
65    branch_protector_ret = "pac_ret"
66
67    include_dirs = [
68      "include",
69      "${common_path}/include",
70    ]
71
72    sanitize = {
73      cfi = true
74      cfi_cross_dso = true
75      debug = false
76    }
77
78    cflags = [
79      "-Werror",
80      "-fPIC",
81      "-fstack-protector-strong",
82    ]
83
84    ldflags = [
85      "-Wl,-z,relro",
86      "-Wl,-z,now",
87    ]
88
89    configs = [ ":cflags_config" ]
90
91    if (use_nlohmann_json) {
92      sources = [ "src/json_object_nlohmannjson.cpp" ]
93    } else {
94      sources = [ "src/json_object_cjson.cpp" ]
95    }
96
97    defines = [
98      "HI_LOG_ENABLE",
99      "DH_LOG_TAG=\"devicemanagerjson\"",
100      "LOG_DOMAIN=0xD004110",
101    ]
102
103    deps = []
104
105    external_deps = [ "hilog:libhilog" ]
106
107    if (use_nlohmann_json) {
108      external_deps += [ "json:nlohmann_json_static" ]
109    } else {
110      external_deps += [ "cJSON:cjson" ]
111    }
112
113    subsystem_name = "distributedhardware"
114
115    part_name = "device_manager"
116  }
117}
118