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      cfi = true
127      cfi_cross_dso = true
128      debug = false
129    }
130    branch_protector_ret = "pac_ret"
131
132    cflags = [
133      "-Wall",
134      "-DNSTACKX_WITH_HMOS_LINUX",
135      "-DDFILE_ENABLE_HIDUMP",
136      "-DENABLE_USER_LOG",
137      "-DSSL_AND_CRYPTO_INCLUDED",
138    ]
139    cflags_cc = cflags
140    include_dirs = [
141      "include",
142      "interface",
143      "$NSTACKX_ROOT/nstackx_congestion/interface/",
144      "$NSTACKX_ROOT/nstackx_core",
145      "$NSTACKX_ROOT/nstackx_util/interface",
146      "$NSTACKX_ROOT/nstackx_util/platform/unix",
147    ]
148    sources = [
149      "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_dfile.c",
150      "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_dfile_session.c",
151      "$NSTACKX_ROOT/nstackx_core/platform/unix/dfile/sys_file_manager.c",
152      "core/nstackx_dfile.c",
153      "core/nstackx_dfile_config.c",
154      "core/nstackx_dfile_control.c",
155      "core/nstackx_dfile_dfx.c",
156      "core/nstackx_dfile_frame.c",
157      "core/nstackx_dfile_log.c",
158      "core/nstackx_dfile_mp.c",
159      "core/nstackx_dfile_retransmission.c",
160      "core/nstackx_dfile_send.c",
161      "core/nstackx_dfile_session.c",
162      "core/nstackx_dfile_transfer.c",
163      "core/nstackx_file_list.c",
164      "core/nstackx_file_manager.c",
165      "core/nstackx_file_manager_client.c",
166    ]
167    deps = [
168      "$NSTACKX_ROOT/nstackx_congestion:nstackx_congestion.open",
169      "$NSTACKX_ROOT/nstackx_util:nstackx_util.open",
170    ]
171    external_deps = [
172      "bounds_checking_function:libsec_shared",
173      "openssl:libcrypto_shared",
174    ]
175    if (is_standard_system) {
176      external_deps += [ "c_utils:utils" ]
177    }
178    innerapi_tags = [ "platformsdk_indirect" ]
179    part_name = "dsoftbus"
180    subsystem_name = "communication"
181  }
182}
183