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