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