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