• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021-2024 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("//base/security/device_auth/deps_adapter/deviceauth_hals.gni")
15import("//build/ohos.gni")
16import("deviceauth.gni")
17
18config("deviceauth_config") {
19  include_dirs = [ "//base/security/device_auth/interfaces/inner_api" ]
20}
21include_dirs = inc_path + hals_inc_path
22if (os_level == "mini" || os_level == "small") {
23  static_library("deviceauth") {
24    public_configs = [ ":deviceauth_config" ]
25    include_dirs += [
26      "//third_party/cJSON",
27      "//commonlibrary/utils_lite/include",
28      "//third_party/bounds_checking_function/include",
29      "//foundation/communication/dsoftbus/interfaces/kits/common",
30      "//foundation/communication/dsoftbus/interfaces/kits/transport",
31      "//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
32      "${dev_frameworks_path}/inc/hiview_adapter",
33    ]
34    sources = deviceauth_files
35    sources += identity_service_mock_files
36    defines = [ "HILOG_ENABLE" ]
37    defines += deviceauth_defines
38
39    sources += identity_manager_files
40    include_dirs += identity_manager_inc
41
42    deps = [
43      "${deps_adapter_path}:${hal_module_name}",
44      "//build/lite/config/component/cJSON:cjson_shared",
45      "//commonlibrary/utils_lite:utils",
46    ]
47    if (device_auth_enable_soft_bus_channel) {
48      deps += [ "//foundation/communication/dsoftbus/sdk:softbus_client" ]
49    }
50    if (enable_extend_plugin) {
51      defines += [ "DEV_AUTH_PLUGIN_ENABLE" ]
52      if (os_level == "mini") {
53        sources += [
54          "${dev_frameworks_path}/src/plugin_adapter/static_plugin_adapter.c",
55        ]
56      } else {
57        sources += [
58          "${dev_frameworks_path}/src/plugin_adapter/dynamic_plugin_adapter.c",
59          "${dev_frameworks_path}/src/plugin_adapter/ext_part/account_lifecycle_plugin/account_lifecycle_plugin_proxy.c",
60          "${dev_frameworks_path}/src/plugin_adapter/ext_part/ext_part_proxy.c",
61        ]
62      }
63    }
64    if (board_toolchain_type == "iccarm" && os_level == "mini") {
65      cflags = [
66        "--diag_suppress",
67        "Pe546,Pe223,Pe111,Pe188",
68      ]
69    } else {
70      cflags = build_flags
71    }
72    cflags += [
73      "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}",
74      "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}",
75    ]
76    if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") {
77      include_dirs +=
78          [ "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog" ]
79      deps += [
80        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
81        "//third_party/bounds_checking_function:libsec_shared",
82      ]
83    } else {
84      include_dirs +=
85          [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite" ]
86      deps += [ "//base/hiviewdfx/hilog_lite/frameworks/mini:hilog_lite" ]
87    }
88  }
89
90  if (os_level == "mini") {
91    group("deviceauth_sdk") {
92    }
93    group("deviceauth_service") {
94    }
95  }
96
97  if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") {
98    executable("deviceauth_service") {
99      include_dirs += [
100        "//third_party/cJSON",
101        "//commonlibrary/utils_lite/include",
102        "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
103        "//third_party/bounds_checking_function/include",
104        "${frameworks_path}/inc/lite",
105        "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr",
106        "${dev_frameworks_path}/inc/hiview_adapter",
107      ]
108
109      sources = deviceauth_ipc_files
110      sources += [
111        "${frameworks_path}/src/ipc_service_common.c",
112        "${frameworks_path}/src/ipc_service_lite.c",
113        "${frameworks_path}/src/lite/ipc_service_init.c",
114      ]
115
116      defines = [ "HILOG_ENABLE" ]
117      if (ohos_kernel_type == "linux") {
118        defines += [ "__LINUX__" ]
119      }
120      ldflags = [ "-pthread" ]
121
122      deps = [
123        ":deviceauth",
124        "${deps_adapter_path}:${hal_module_name}",
125        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
126        "//build/lite/config/component/cJSON:cjson_shared",
127        "//commonlibrary/utils_lite:utils",
128        "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
129        "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
130        "//third_party/bounds_checking_function:libsec_shared",
131      ]
132    }
133
134    shared_library("deviceauth_sdk") {
135      public_configs = [ ":deviceauth_config" ]
136      include_dirs += [
137        "//third_party/cJSON",
138        "//commonlibrary/utils_lite/include",
139        "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
140        "//third_party/bounds_checking_function/include",
141        "${frameworks_path}/inc/lite",
142        "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include",
143        "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr",
144        "${dev_frameworks_path}/inc/hiview_adapter",
145      ]
146
147      sources = deviceauth_ipc_files
148      sources += [ "${frameworks_path}/src/ipc_sdk.c" ]
149
150      defines = [ "HILOG_ENABLE" ]
151      if (ohos_kernel_type == "linux") {
152        defines += [ "__LINUX__" ]
153      }
154      cflags = build_flags
155      cflags += [ "-fPIC" ]
156
157      deps = [
158        "${deps_adapter_path}:${hal_module_name}",
159        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
160        "//commonlibrary/utils_lite:utils",
161        "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
162        "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
163        "//third_party/bounds_checking_function:libsec_shared",
164      ]
165    }
166  }
167} else {
168  ohos_static_library("deviceauth") {
169    subsystem_name = "security"
170    part_name = "device_auth"
171    include_dirs += [
172      "${frameworks_path}/inc/standard",
173      "${dev_frameworks_path}/inc/hiview_adapter",
174      "${dev_frameworks_path}/inc/permission_adapter",
175    ]
176
177    if (support_os_account) {
178      include_dirs += [ "${dev_frameworks_path}/inc/account_subscriber" ]
179      include_dirs += [ "${dev_frameworks_path}/inc/sa_subscriber" ]
180      include_dirs += [ "${dev_frameworks_path}/inc/net_observer" ]
181    }
182
183    sources = deviceauth_files
184    if (support_os_account) {
185      sources += account_subscriber_files
186      sources += sa_subscriber_files
187      sources += net_observer_files
188    }
189    sources += permission_adapter_files
190    sources += identity_service_files
191    sources += hiview_adapter_files
192    defines = deviceauth_defines
193    defines += [ "HILOG_ENABLE" ]
194    defines += [ "DEV_AUTH_HIVIEW_ENABLE" ]
195    defines += [ "DEV_AUTH_PERMISSION_ENABLE" ]
196    defines += [ "DEV_AUTH_IS_ENABLE" ]
197    cflags = build_flags
198    cflags += [
199      "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}",
200      "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}",
201    ]
202    if (target_cpu == "arm") {
203      cflags += [ "-DBINDER_IPC_32BIT" ]
204    }
205    if (enable_extend_plugin) {
206      defines += [ "DEV_AUTH_PLUGIN_ENABLE" ]
207      sources += [
208        "${dev_frameworks_path}/src/plugin_adapter/dynamic_plugin_adapter.c",
209        "${dev_frameworks_path}/src/plugin_adapter/ext_part/account_lifecycle_plugin/account_lifecycle_plugin_proxy.c",
210        "${dev_frameworks_path}/src/plugin_adapter/ext_part/ext_part_proxy.c",
211      ]
212    }
213
214    sources += identity_manager_files
215    include_dirs += identity_manager_inc
216
217    branch_protector_ret = "pac_ret"
218    sanitize = {
219      cfi = true
220      cfi_cross_dso = true
221      integer_overflow = true
222      boundary_sanitize = true
223      ubsan = true
224      debug = false
225    }
226
227    deps = [ "${deps_adapter_path}:${hal_module_name}" ]
228
229    external_deps = [
230      "access_token:libaccesstoken_sdk",
231      "bounds_checking_function:libsec_shared",
232      "cJSON:cjson",
233      "c_utils:utils",
234      "dsoftbus:softbus_client",
235      "hilog:libhilog",
236      "hisysevent:libhisysevent",
237      "hitrace:hitrace_meter",
238    ]
239    if (support_os_account) {
240      external_deps += [
241        "ability_base:want",
242        "common_event_service:cesfwk_innerkits",
243        "ipc:ipc_single",
244        "json:nlohmann_json_static",
245        "netmanager_base:net_conn_manager_if",
246        "os_account:os_account_innerkits",
247        "samgr:samgr_proxy",
248      ]
249    }
250  }
251
252  ohos_prebuilt_etc("pre_deviceauth_service") {
253    source = "${deviceauth_path}/services/deviceauth_service.cfg"
254    relative_install_dir = "init"
255    subsystem_name = "security"
256    part_name = "device_auth"
257  }
258
259  ohos_shared_library("deviceauth_sdk") {
260    subsystem_name = "security"
261    part_name = "device_auth"
262    innerapi_tags = [ "platformsdk" ]
263    version_script = "device_auth.map"
264    public_configs = [ ":deviceauth_config" ]
265
266    include_dirs += [
267      "${frameworks_path}/inc/standard",
268      "${dev_frameworks_path}/inc/permission_adapter",
269      "${dev_frameworks_path}/inc/hiview_adapter",
270    ]
271
272    sources = deviceauth_ipc_files
273    sources += permission_adapter_files
274    sources += [ "${frameworks_path}/src/ipc_sdk.c" ]
275    sources += [ "${frameworks_path}/src/identity_service_ipc_sdk.c" ]
276
277    defines = [
278      "__LINUX__",
279      "HILOG_ENABLE",
280    ]
281    defines += [ "DEV_AUTH_IS_ENABLE" ]
282    cflags = build_flags
283    cflags += [ "-fPIC" ]
284    if (target_cpu == "arm") {
285      cflags += [ "-DBINDER_IPC_32BIT" ]
286    }
287
288    branch_protector_ret = "pac_ret"
289    sanitize = {
290      cfi = true
291      cfi_cross_dso = true
292      integer_overflow = true
293      boundary_sanitize = true
294      ubsan = true
295      debug = false
296    }
297
298    deps = [ "${deps_adapter_path}:${hal_module_name}" ]
299
300    external_deps = [
301      "access_token:libaccesstoken_sdk",
302      "bounds_checking_function:libsec_shared",
303      "cJSON:cjson",
304      "c_utils:utils",
305      "hilog:libhilog",
306      "hisysevent:libhisysevent",
307      "hitrace:hitrace_meter",
308      "init:libbegetutil",
309      "ipc:ipc_single",
310      "samgr:samgr_proxy",
311    ]
312  }
313
314  ohos_shared_library("deviceauth_service") {
315    subsystem_name = "security"
316    part_name = "device_auth"
317    version_script = "device_auth.map"
318    public_configs = [ ":deviceauth_config" ]
319    branch_protector_ret = "pac_ret"
320
321    sanitize = {
322      cfi = true
323      cfi_cross_dso = true
324      integer_overflow = true
325      boundary_sanitize = true
326      ubsan = true
327      debug = false
328    }
329
330    cflags = build_flags
331    cflags += [ "-fPIC" ]
332    if (target_cpu == "arm") {
333      cflags += [ "-DBINDER_IPC_32BIT" ]
334    }
335
336    include_dirs += [
337      "${frameworks_path}/inc",
338      "${frameworks_path}/inc/standard",
339      "${dev_frameworks_path}/inc/permission_adapter",
340      "${dev_frameworks_path}/inc/hiview_adapter",
341    ]
342
343    defines = [ "HILOG_ENABLE" ]
344    defines += [ "DEV_AUTH_HIVIEW_ENABLE" ]
345    defines += [ "DEV_AUTH_SERVICE_BUILD" ]
346    defines += [ "DEV_AUTH_IS_ENABLE" ]
347
348    if (use_musl) {
349      if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
350        defines += [ "DEV_AUTH_USE_JEMALLOC" ]
351      }
352    }
353
354    sources = deviceauth_ipc_files
355    sources += [ "${frameworks_path}/src/deviceauth_sa.cpp" ]
356    sources += [ "${frameworks_path}/src/ipc_service_common.c" ]
357
358    deps = [
359      ":deviceauth",
360      ":pre_deviceauth_service",
361      "${deps_adapter_path}:${hal_module_name}",
362    ]
363
364    external_deps = [
365      "bounds_checking_function:libsec_shared",
366      "cJSON:cjson",
367      "c_utils:utils",
368      "hilog:libhilog",
369      "init:libbegetutil",
370      "ipc:ipc_core",
371      "ipc:ipc_single",
372      "safwk:system_ability_fwk",
373      "samgr:samgr_proxy",
374    ]
375  }
376}
377