• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("//foundation/communication/dsoftbus/dsoftbus.gni")
15
16cflags = [
17  "-DENABLE_USER_LOG",
18  "-DDFINDER_SAVE_DEVICE_LIST",
19  "-DNSTACKX_EXTEND_BUSINESSDATA",
20  "-DNSTACKX_DFINDER_HIDUMP",
21]
22
23if (defined(board_toolchain_type)) {
24  if (board_toolchain_type != "iccarm") {
25    cflags += [ "-Wall" ]
26  }
27} else {
28  cflags += [ "-Wall" ]
29}
30
31include_dirs = []
32
33if (dsoftbus_standard_feature_dfinder_support_multi_nif) {
34  cflags += [ "-DDFINDER_SUPPORT_MULTI_NIF" ]
35}
36
37if (defined(ohos_lite)) {
38  if (ohos_kernel_type == "liteos_m") {
39    import("//build/lite/config/component/lite_component.gni")
40    config("dfinder_interface") {
41      include_dirs = [ "interface" ]
42    }
43    static_library("nstackx_ctrl") {
44      sources = [
45        "core/json_payload.c",
46        "core/mini_discover/coap_adapter.c",
47        "core/mini_discover/coap_app.c",
48        "core/mini_discover/coap_discover.c",
49        "core/nstackx_common.c",
50        "core/nstackx_database.c",
51        "core/nstackx_device.c",
52        "core/nstackx_dfinder_hidump.c",
53        "core/nstackx_dfinder_hievent.c",
54        "core/nstackx_dfinder_log.c",
55        "core/nstackx_statistics.c",
56      ]
57      include_dirs = [
58        "include",
59        "include/mini_discover",
60        "//third_party/cJSON",
61        "../nstackx_util/interface",
62        "../nstackx_util/platform/liteos",
63      ]
64      defines = [
65        "NSTACKX_WITH_LITEOS",
66        "LWIP_LITEOS_A_COMPAT",
67        "_GNU_SOURCE",
68        "DFINDER_USE_MINI_NSTACKX",
69        "DFINDER_SAVE_DEVICE_LIST",
70        "NSTACKX_WITH_LITEOS_M",
71      ]
72      public_configs = [ ":dfinder_interface" ]
73      deps = [ "../nstackx_util:nstackx_util.open" ]
74      if (board_toolchain_type != "iccarm") {
75        cflags += [
76          "-Wall",
77          "-std=c99",
78        ]
79        cflags_cc = cflags
80      } else {
81        include_dirs += [
82          "//kernel/liteos_m/components/net/lwip-2.1/porting/include",
83          "//third_party/lwip/src/include",
84        ]
85        cflags += [
86          "--diag_suppress",
87          "Pa181",
88        ]
89      }
90    }
91  } else {
92    import("//build/lite/config/component/lite_component.gni")
93    config("dfinder_interface") {
94      include_dirs = [ "interface" ]
95    }
96    shared_library("nstackx_ctrl") {
97      sources = [
98        "core/coap_discover/coap_app.c",
99        "core/coap_discover/coap_client.c",
100        "core/coap_discover/coap_discover.c",
101        "core/json_payload.c",
102        "core/nstackx_common.c",
103        "core/nstackx_database.c",
104        "core/nstackx_device.c",
105        "core/nstackx_dfinder_hidump.c",
106        "core/nstackx_dfinder_hievent.c",
107        "core/nstackx_dfinder_log.c",
108        "core/nstackx_dfinder_mgt_msg_log.c",
109        "core/nstackx_smartgenius.c",
110        "core/nstackx_statistics.c",
111      ]
112      ctrl_include = [
113        "../nstackx_util/interface",
114        "interface",
115        "include",
116        "include/coap_discover",
117        "//third_party/libcoap/include",
118        "//third_party/cJSON",
119      ]
120      include_dirs += ctrl_include
121      public_configs = [ ":dfinder_interface" ]
122      deps = [
123        "../nstackx_util:nstackx_util.open",
124        "//build/lite/config/component/cJSON:cjson_shared",
125        "//third_party/bounds_checking_function:libsec_shared",
126        "//third_party/libcoap:libcoap",
127      ]
128      if (ohos_kernel_type == "liteos_a") {
129        defines = [
130          "NSTACKX_WITH_LITEOS",
131          "LWIP_LITEOS_A_COMPAT",
132          "DFINDER_SAVE_DEVICE_LIST",
133        ]
134      } else if (ohos_kernel_type == "linux") {
135        defines = [ "DFINDER_SAVE_DEVICE_LIST" ]
136      }
137      cflags += [
138        "-fPIC",
139        "-std=c99",
140        "-DDFINDER_MGT_MSG_LOG",
141      ]
142      cflags_cc = cflags
143      ldflags = [
144        "-Wl,-z,relro,-z,now",
145        "-s",
146        "-fPIC",
147      ]
148    }
149  }
150} else {
151  import("//build/ohos.gni")
152
153  config("dfinder_interface") {
154    include_dirs = [ "interface" ]
155  }
156  ohos_shared_library("nstackx_ctrl") {
157    cflags += [ "-DDFINDER_MGT_MSG_LOG" ]
158    cflags_cc = cflags
159    sources = [
160      "core/coap_discover/coap_app.c",
161      "core/coap_discover/coap_client.c",
162      "core/coap_discover/coap_discover.c",
163      "core/json_payload.c",
164      "core/nstackx_common.c",
165      "core/nstackx_database.c",
166      "core/nstackx_device.c",
167      "core/nstackx_dfinder_hidump.c",
168      "core/nstackx_dfinder_hievent.c",
169      "core/nstackx_dfinder_log.c",
170      "core/nstackx_dfinder_mgt_msg_log.c",
171      "core/nstackx_smartgenius.c",
172      "core/nstackx_statistics.c",
173    ]
174    include_dirs += [
175      "//third_party/bounds_checking_function/include",
176      "../nstackx_util/platform/unix",
177    ]
178    ctrl_include = [
179      "../nstackx_util/interface",
180      "interface",
181      "include",
182      "include/coap_discover",
183      "//third_party/libcoap/include",
184      "//third_party/cJSON",
185    ]
186    include_dirs += ctrl_include
187    public_configs = [ ":dfinder_interface" ]
188    deps = [
189      "../nstackx_util:nstackx_util.open",
190      "//third_party/bounds_checking_function:libsec_shared",
191      "//third_party/cJSON:cjson",
192      "//third_party/libcoap:libcoap",
193    ]
194    subsystem_name = "communication"
195    part_name = "dsoftbus"
196  }
197}
198