• 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
14DSOFTBUS_ROOT_PATH = "./../../.."
15import("$DSOFTBUS_ROOT_PATH/core/common/dfx/dsoftbus_dfx.gni")
16import("$DSOFTBUS_ROOT_PATH/dsoftbus.gni")
17
18NSTACKX_ROOT = "$DSOFTBUS_ROOT_PATH/components/nstackx"
19cflags = [ "-DENABLE_USER_LOG" ]
20if (dsoftbus_feature_ifname_prefix) {
21  cflags += [ "-DETH_DEV_NAME_PRE=\"br\"" ]
22}
23if (defined(ohos_lite)) {
24  import("//build/lite/config/component/lite_component.gni")
25  if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m") {
26    config("nstackx_util_header") {
27      include_dirs = [
28        "interface",
29        "platform/liteos",
30      ]
31    }
32  } else if (ohos_kernel_type == "linux") {
33    config("nstackx_util_header") {
34      include_dirs = [
35        "interface",
36        "platform/unix",
37      ]
38    }
39  }
40  if (ohos_kernel_type == "liteos_m") {
41    static_library("nstackx_util.open") {
42      cflags += [
43        "-D_GNU_SOURCE",
44        "-DNSTACKX_WITH_LITEOS",
45        "-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS",
46        "-DLWIP_LITEOS_A_COMPAT",
47        "-DMBEDTLS_INCLUDED",
48        "-DNSTACKX_WITH_LITEOS_M",
49        "-DENABLE_USER_LOG",
50      ]
51      if (board_toolchain_type != "iccarm") {
52        cflags += [ "-Wall" ]
53      }
54      cflags_cc = cflags
55      include_dirs = [
56        "include",
57        "interface",
58        "platform/liteos",
59        "$NSTACKX_ROOT/nstackx_core/",
60        "//third_party/bounds_checking_function/include/",
61        "$hilog_lite_include_path",
62        "$utils_lite_include_path",
63      ]
64      sources = [
65        "core/nstackx_event.c",
66        "core/nstackx_log.c",
67        "core/nstackx_socket.c",
68        "core/nstackx_timer.c",
69      ]
70
71      sources += [
72        "core/nstackx_getopt.c",
73        "platform/liteos/sys_dev.c",
74        "platform/liteos/sys_epoll.c",
75        "platform/liteos/sys_event.c",
76        "platform/liteos/sys_log.c",
77        "platform/liteos/sys_socket.c",
78        "platform/liteos/sys_timer.c",
79        "platform/liteos/sys_util.c",
80      ]
81
82      public_configs = [ ":nstackx_util_header" ]
83    }
84  } else {
85    shared_library("nstackx_util.open") {
86      if (ohos_kernel_type == "liteos_a") {
87        cflags += [
88          "-Wall",
89          "-D_GNU_SOURCE",
90          "-DNSTACKX_WITH_LITEOS",
91          "-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS",
92          "-DLWIP_LITEOS_A_COMPAT",
93          "-DMBEDTLS_INCLUDED",
94          "-DENABLE_USER_LOG",
95        ]
96        cflags_cc = cflags
97        include_dirs = [
98          "include",
99          "interface",
100          "platform/liteos",
101          "$NSTACKX_ROOT/nstackx_core/",
102          "//third_party/bounds_checking_function/include/",
103          "$hilog_lite_include_path",
104          "$utils_lite_include_path",
105        ]
106        sources = [
107          "core/nstackx_dev.c",
108          "core/nstackx_event.c",
109          "core/nstackx_getopt.c",
110          "core/nstackx_log.c",
111          "core/nstackx_mbedtls.c",
112          "core/nstackx_socket.c",
113          "core/nstackx_timer.c",
114          "core/nstackx_util.c",
115          "platform/liteos/sys_dev.c",
116          "platform/liteos/sys_epoll.c",
117          "platform/liteos/sys_event.c",
118          "platform/liteos/sys_log.c",
119          "platform/liteos/sys_socket.c",
120          "platform/liteos/sys_timer.c",
121          "platform/liteos/sys_util.c",
122        ]
123        deps = [
124          "$hilog_lite_deps_path",
125          "//third_party/bounds_checking_function:libsec_shared",
126          "//third_party/mbedtls",
127        ]
128      } else if (ohos_kernel_type == "linux") {
129        cflags += [
130          "-Wall",
131          "-DNSTACKX_WITH_HMOS_LINUX",
132          "-DMBEDTLS_INCLUDED",
133          "-DENABLE_USER_LOG",
134        ]
135        cflags_cc = cflags
136        include_dirs = [
137          "include",
138          "interface",
139          "platform/unix",
140          "$NSTACKX_ROOT/nstackx_core/",
141          "//third_party/bounds_checking_function/include/",
142          "$hilog_lite_include_path",
143          "$utils_lite_include_path",
144        ]
145        sources = [
146          "core/nstackx_dev.c",
147          "core/nstackx_event.c",
148          "core/nstackx_getopt.c",
149          "core/nstackx_log.c",
150          "core/nstackx_mbedtls.c",
151          "core/nstackx_socket.c",
152          "core/nstackx_timer.c",
153          "core/nstackx_util.c",
154          "platform/unix/sys_dev.c",
155          "platform/unix/sys_epoll.c",
156          "platform/unix/sys_event.c",
157          "platform/unix/sys_log.c",
158          "platform/unix/sys_socket.c",
159          "platform/unix/sys_timer.c",
160          "platform/unix/sys_util.c",
161        ]
162        deps = [
163          "$hilog_lite_deps_path",
164          "//third_party/mbedtls",
165          "//third_party/mbedtls:mbedtls_shared",
166        ]
167      }
168      public_configs = [ ":nstackx_util_header" ]
169    }
170  }
171} else {
172  import("//build/ohos.gni")
173
174  config("nstackx_util_header") {
175    include_dirs = [
176      "interface",
177      "platform/unix",
178    ]
179  }
180
181  ohos_shared_library("nstackx_util.open") {
182    sanitize = {
183      cfi = true
184      cfi_cross_dso = true
185      debug = false
186    }
187    branch_protector_ret = "pac_ret"
188
189    cflags += [
190      "-DMBEDTLS_INCLUDED",
191      "-DNSTACKX_WITH_HMOS_LINUX",
192      "-DENABLE_USER_LOG",
193    ]
194    if (defined(board_toolchain_type)) {
195      if (board_toolchain_type != "iccarm") {
196        cflags += [ "-Wall" ]
197      }
198    } else {
199      cflags += [ "-Wall" ]
200    }
201    cflags_cc = cflags
202    include_dirs = [
203      "include",
204      "interface",
205      "platform/unix",
206      "$NSTACKX_ROOT/nstackx_core/",
207      "//commonlibrary/c_utils/base/include/",
208      "//third_party/bounds_checking_function/include",
209      "//base/hiviewdfx/hilog/interfaces/native/innerkits/",
210    ]
211    sources = [
212      "core/nstackx_dev.c",
213      "core/nstackx_event.c",
214      "core/nstackx_getopt.c",
215      "core/nstackx_log.c",
216      "core/nstackx_mbedtls.c",
217      "core/nstackx_socket.c",
218      "core/nstackx_timer.c",
219      "core/nstackx_util.c",
220      "platform/unix/sys_dev.c",
221      "platform/unix/sys_epoll.c",
222      "platform/unix/sys_event.c",
223      "platform/unix/sys_log.c",
224      "platform/unix/sys_socket.c",
225      "platform/unix/sys_timer.c",
226      "platform/unix/sys_util.c",
227    ]
228
229    deps = [
230      "//third_party/bounds_checking_function:libsec_shared",
231      "//third_party/mbedtls",
232    ]
233    external_deps = [ "hilog:libhilog" ]
234    public_configs = [ ":nstackx_util_header" ]
235    innerapi_tags = [ "platformsdk_indirect" ]
236    part_name = "dsoftbus"
237    subsystem_name = "communication"
238  }
239}
240