• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2023 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
14DSOFTBUS_ROOT_PATH = "./../../.."
15import("$DSOFTBUS_ROOT_PATH/dsoftbus.gni")
16
17# basic compilation options
18
19if (dsoftbus_feature_inner_coap) {
20  cflags = [
21    "-DENABLE_USER_LOG",
22    "-DNSTACKX_EXTEND_BUSINESSDATA",
23    "-DDFINDER_SAVE_DEVICE_LIST",
24    "-DDFINDER_SUPPORT_SET_SCREEN_STATUS",
25    "-DDFINDER_DISTINGUISH_ACTIVE_PASSIVE_DISCOVERY",
26  ]
27
28  # configure cflags based on build toolchain type
29  if (defined(board_toolchain_type)) {
30    if (board_toolchain_type != "iccarm") {
31      cflags += [ "-Wall" ]
32    }
33  } else {
34    cflags += [ "-Wall" ]
35  }
36
37  base_src = [
38    "core/json_payload.c",
39    "core/nstackx_common.c",
40    "core/nstackx_device.c",
41    "core/nstackx_device_local.c",
42    "core/nstackx_device_remote.c",
43    "core/nstackx_dfinder_log.c",
44  ]
45
46  base_include_dirs = [
47    "interface",
48    "include",
49    "../nstackx_util/interface",
50  ]
51
52  # mini platform
53  if (defined(ohos_lite) && ohos_kernel_type == "liteos_m") {
54    mini_diff_src = [
55      "core/mini_discover/coap_adapter.c",
56      "core/mini_discover/coap_app.c",
57      "core/mini_discover/coap_discover.c",
58      "core/nstackx_statistics.c",
59      "core/nstackx_dfinder_hievent.c",
60    ]
61    mini_diff_include_dirs = [
62      "include/mini_discover",
63      "../nstackx_util/platform/liteos",
64    ]
65    cflags += [
66      "-DNSTACKX_WITH_LITEOS",
67      "-DNSTACKX_WITH_LITEOS_M",
68      "-DLWIP_LITEOS_A_COMPAT",
69      "-D_GNU_SOURCE",
70      "-DDFINDER_USE_MINI_NSTACKX",
71    ]
72  }
73
74  # standard and small platform
75  if (!defined(ohos_lite) ||
76      (defined(ohos_lite) && ohos_kernel_type != "liteos_m")) {
77    standard_small_diff_src = [
78      "core/coap_discover/coap_app.c",
79      "core/coap_discover/coap_client.c",
80      "core/coap_discover/coap_discover.c",
81      "core/nstackx_dfinder_hidump.c",
82      "core/nstackx_dfinder_mgt_msg_log.c",
83      "core/nstackx_dfinder_hievent.c",
84      "core/nstackx_statistics.c",
85      "core/nstackx_smartgenius.c",
86    ]
87    standard_small_diff_include_dirs = [ "include/coap_discover" ]
88    cflags += [
89      "-DDFINDER_MGT_MSG_LOG",
90      "-DNSTACKX_DFINDER_HIDUMP",
91    ]
92  }
93}
94
95config("nstackx_ctrl_interface") {
96  include_dirs = [ "interface" ]
97}
98
99if (defined(ohos_lite)) {
100  if (ohos_kernel_type == "liteos_m") {
101    import("//build/lite/config/component/lite_component.gni")
102    static_library("nstackx_ctrl") {
103      if (!dsoftbus_feature_inner_coap) {
104        sources = [ "core/nstackx_common_virtual.c" ]
105        include_dirs = [
106          "interface",
107          "../nstackx_util/interface",
108        ]
109      } else {
110        sources = base_src
111        sources += mini_diff_src
112        include_dirs = base_include_dirs
113        include_dirs += mini_diff_include_dirs
114        include_dirs += [ "//third_party/cJSON" ]
115        if (board_toolchain_type != "iccarm") {
116          cflags += [ "-std=c99" ]
117          cflags_cc = cflags
118        } else {
119          cflags += [
120            "--diag_suppress",
121            "Pa181",
122          ]
123          include_dirs += [
124            "//kernel/liteos_m/components/net/lwip-2.1/porting/include",
125            "//third_party/lwip/src/include",
126          ]
127        }
128      }
129      deps = [ "../nstackx_util:nstackx_util.open" ]
130      public_configs = [ ":nstackx_ctrl_interface" ]
131    }
132  } else {
133    import("//build/lite/config/component/lite_component.gni")
134    shared_library("nstackx_ctrl") {
135      if (!dsoftbus_feature_inner_coap) {
136        sources = [ "core/nstackx_common_virtual.c" ]
137        include_dirs = [
138          "interface",
139          "../nstackx_util/interface",
140        ]
141        deps = [ "../nstackx_util:nstackx_util.open" ]
142        public_configs = [ ":nstackx_ctrl_interface" ]
143      } else {
144        sources = base_src
145        sources += standard_small_diff_src
146        include_dirs = base_include_dirs
147        include_dirs += standard_small_diff_include_dirs
148        public_configs = [ ":nstackx_ctrl_interface" ]
149        deps = [
150          "../nstackx_util:nstackx_util.open",
151          "//build/lite/config/component/cJSON:cjson_shared",
152        ]
153        external_deps = [
154          "bounds_checking_function:libsec_shared",
155          "libcoap:libcoap",
156        ]
157        if (ohos_kernel_type == "liteos_a") {
158          cflags += [
159            "-DNSTACKX_WITH_LITEOS",
160            "-DLWIP_LITEOS_A_COMPAT",
161          ]
162        }
163        cflags += [
164          "-fPIC",
165          "-std=c99",
166          "-DNSTACKX_DFINDER_HIDUMP",
167        ]
168        cflags_cc = cflags
169        ldflags = [
170          "-Wl,-z,relro,-z,now",
171          "-s",
172          "-fPIC",
173        ]
174      }
175    }
176  }
177} else {
178  import("//build/ohos.gni")
179  ohos_shared_library("nstackx_ctrl") {
180    sanitize = {
181      ubsan = true
182      integer_overflow = true
183      boundary_sanitize = true
184      cfi = true
185      cfi_cross_dso = true
186      debug = false
187    }
188    branch_protector_ret = "pac_ret"
189
190    if (!dsoftbus_feature_inner_coap) {
191      sources = [ "core/nstackx_common_virtual.c" ]
192      include_dirs = [
193        "interface",
194        "../nstackx_util/interface",
195      ]
196      deps = [ "../nstackx_util:nstackx_util.open" ]
197      public_configs = [ ":nstackx_ctrl_interface" ]
198    } else {
199      cflags += [
200        "-DDFINDER_MGT_MSG_LOG",
201        "-DNSTACKX_DFINDER_HIDUMP",
202      ]
203      cflags_cc = cflags
204      sources = base_src
205      sources += standard_small_diff_src
206      include_dirs = base_include_dirs
207      include_dirs += standard_small_diff_include_dirs
208      include_dirs += [ "../nstackx_util/platform/unix" ]
209      public_configs = [ ":nstackx_ctrl_interface" ]
210      deps = [ "../nstackx_util:nstackx_util.open" ]
211      external_deps = [
212        "bounds_checking_function:libsec_shared",
213        "cJSON:cjson",
214        "libcoap:libcoap",
215      ]
216    }
217    subsystem_name = "communication"
218    innerapi_tags = [ "platformsdk_indirect" ]
219    part_name = "dsoftbus"
220  }
221}
222