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