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"
18if (defined(ohos_lite)) {
19  import("//build/lite/config/component/lite_component.gni")
20  config("dfile_lite_config") {
21    cflags = [
22      "-Wall",
23      "-fno-lto",
24      "-D_GNU_SOURCE",
25      "-DNSTACKX_WITH_LITEOS",
26      "-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS",
27      "-DLWIP_LITEOS_A_COMPAT",
28      "-DMBEDTLS_INCLUDED",
29      "-DDFILE_ENABLE_HIDUMP",
30    ]
31    cflags_cc = cflags
32  }
33
34  config("dfile_linux_config") {
35    cflags = [
36      "-Wall",
37      "-fno-lto",
38      "-DNSTACKX_WITH_HMOS_LINUX",
39      "-DMBEDTLS_INCLUDED",
40      "-DENABLE_USER_LOG",
41    ]
42    cflags_cc = cflags
43  }
44  shared_library("nstackx_dfile.open") {
45    if (ohos_kernel_type == "liteos_a") {
46      configs += [ ":dfile_lite_config" ]
47      include_dirs = [
48        "include",
49        "interface",
50        "$NSTACKX_ROOT/nstackx_congestion/interface/",
51        "$NSTACKX_ROOT/nstackx_core",
52        "$NSTACKX_ROOT/nstackx_util/interface",
53        "$NSTACKX_ROOT/nstackx_util/platform/liteos",
54      ]
55      sources = [
56        "$NSTACKX_ROOT/nstackx_core/platform/liteos/dfile/sys_dfile.c",
57        "$NSTACKX_ROOT/nstackx_core/platform/liteos/dfile/sys_dfile_session.c",
58        "$NSTACKX_ROOT/nstackx_core/platform/liteos/dfile/sys_file_manager.c",
59        "core/nstackx_dfile.c",
60        "core/nstackx_dfile_config.c",
61        "core/nstackx_dfile_control.c",
62        "core/nstackx_dfile_dfx.c",
63        "core/nstackx_dfile_frame.c",
64        "core/nstackx_dfile_log.c",
65        "core/nstackx_dfile_mp.c",
66        "core/nstackx_dfile_retransmission.c",
67        "core/nstackx_dfile_send.c",
68        "core/nstackx_dfile_session.c",
69        "core/nstackx_dfile_transfer.c",
70        "core/nstackx_file_list.c",
71        "core/nstackx_file_manager.c",
72        "core/nstackx_file_manager_client.c",
73      ]
74      deps = [
75        "$NSTACKX_ROOT/nstackx_congestion:nstackx_congestion.open",
76        "$NSTACKX_ROOT/nstackx_util:nstackx_util.open",
77      ]
78      external_deps = [
79        "bounds_checking_function:libsec_shared",
80        "mbedtls:mbedtls_shared",
81      ]
82    } else if (ohos_kernel_type == "linux") {
83      configs += [ ":dfile_linux_config" ]
84      include_dirs = [
85        "include",
86        "interface",
87        "$NSTACKX_ROOT/nstackx_congestion/interface/",
88        "$NSTACKX_ROOT/nstackx_core",
89        "$NSTACKX_ROOT/nstackx_util/interface",
90        "$NSTACKX_ROOT/nstackx_util/platform/unix",
91      ]
92      sources = [
93        "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_dfile.c",
94        "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_dfile_session.c",
95        "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_file_manager.c",
96        "core/nstackx_dfile.c",
97        "core/nstackx_dfile_config.c",
98        "core/nstackx_dfile_control.c",
99        "core/nstackx_dfile_dfx.c",
100        "core/nstackx_dfile_frame.c",
101        "core/nstackx_dfile_log.c",
102        "core/nstackx_dfile_mp.c",
103        "core/nstackx_dfile_retransmission.c",
104        "core/nstackx_dfile_send.c",
105        "core/nstackx_dfile_session.c",
106        "core/nstackx_dfile_transfer.c",
107        "core/nstackx_file_list.c",
108        "core/nstackx_file_manager.c",
109        "core/nstackx_file_manager_client.c",
110      ]
111      deps = [
112        "$NSTACKX_ROOT/nstackx_congestion:nstackx_congestion.open",
113        "$NSTACKX_ROOT/nstackx_util:nstackx_util.open",
114      ]
115      external_deps = [
116        "bounds_checking_function:libsec_shared",
117        "mbedtls:mbedtls_shared",
118      ]
119    }
120  }
121} else {
122  import("//build/ohos.gni")
123
124  ohos_shared_library("nstackx_dfile.open") {
125    sanitize = {
126      ubsan = true
127      integer_overflow = true
128      boundary_sanitize = true
129      cfi = true
130      cfi_cross_dso = true
131      debug = false
132    }
133    branch_protector_ret = "pac_ret"
134
135    cflags = [
136      "-Wall",
137      "-DNSTACKX_WITH_HMOS_LINUX",
138      "-DDFILE_ENABLE_HIDUMP",
139      "-DENABLE_USER_LOG",
140      "-DSSL_AND_CRYPTO_INCLUDED",
141    ]
142    cflags_cc = cflags
143    include_dirs = [
144      "include",
145      "interface",
146      "$NSTACKX_ROOT/nstackx_congestion/interface/",
147      "$NSTACKX_ROOT/nstackx_core",
148      "$NSTACKX_ROOT/nstackx_util/interface",
149      "$NSTACKX_ROOT/nstackx_util/platform/unix",
150    ]
151    sources = [
152      "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_dfile.c",
153      "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_dfile_session.c",
154      "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_file_manager.c",
155      "core/nstackx_dfile.c",
156      "core/nstackx_dfile_config.c",
157      "core/nstackx_dfile_control.c",
158      "core/nstackx_dfile_dfx.c",
159      "core/nstackx_dfile_frame.c",
160      "core/nstackx_dfile_log.c",
161      "core/nstackx_dfile_mp.c",
162      "core/nstackx_dfile_retransmission.c",
163      "core/nstackx_dfile_send.c",
164      "core/nstackx_dfile_session.c",
165      "core/nstackx_dfile_transfer.c",
166      "core/nstackx_file_list.c",
167      "core/nstackx_file_manager.c",
168      "core/nstackx_file_manager_client.c",
169    ]
170    deps = [
171      "$NSTACKX_ROOT/nstackx_congestion:nstackx_congestion.open",
172      "$NSTACKX_ROOT/nstackx_util:nstackx_util.open",
173    ]
174    external_deps = [
175      "bounds_checking_function:libsec_shared",
176      "openssl:libcrypto_shared",
177    ]
178    if (is_standard_system) {
179      external_deps += [ "c_utils:utils" ]
180    }
181    innerapi_tags = [ "platformsdk_indirect" ]
182    part_name = "dsoftbus"
183    subsystem_name = "communication"
184  }
185}
186