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
14import("//build/ohos.gni")
15import("./../uhdf.gni")
16
17hdf_framework_path = "./../../../framework"
18hdf_interfaces_path = "./../../../interfaces"
19hdf_uhdf_path = "./.."
20
21config("libhdf_host_public_config") {
22  visibility = [ ":*" ]
23
24  include_dirs = [
25    "$hdf_interfaces_path/inner_api/core",
26    "$hdf_interfaces_path/inner_api/osal/shared",
27    "$hdf_interfaces_path/inner_api/host/shared",
28    "$hdf_interfaces_path/inner_api/host/uhdf",
29  ]
30}
31if (defined(ohos_lite)) {
32  group("libhdf_host") {
33    deps = []
34  }
35} else {
36  ohos_shared_library("libhdf_host") {
37    defines = [ "__USER__" ]
38
39    if (target_cpu == "arm64" || target_cpu == "x86_64") {
40      defines += [ "__ARCH64__" ]
41    }
42
43    public_configs = [ ":libhdf_host_public_config" ]
44    include_dirs = [
45      "$hdf_framework_path/core/manager/include",
46      "$hdf_framework_path/core/host/include",
47      "$hdf_framework_path/core/shared/include",
48      "$hdf_framework_path/utils/include",
49      "$hdf_uhdf_path/include/host",
50      "$hdf_uhdf_path/shared/include",
51      "$hdf_uhdf_path/manager/include",
52      "$hdf_uhdf_path/security/include",
53      "$hdf_uhdf_path/utils/include",
54      "$hdf_uhdf_path/osal/include",
55      "include",
56    ]
57
58    sources = [
59      "$hdf_framework_path/core/host/src/devhost_service.c",
60      "$hdf_framework_path/core/host/src/devmgr_service_clnt.c",
61      "$hdf_framework_path/core/host/src/devsvc_manager_clnt.c",
62      "$hdf_framework_path/core/host/src/hdf_device.c",
63      "$hdf_framework_path/core/host/src/hdf_device_node.c",
64      "$hdf_framework_path/core/host/src/hdf_device_object.c",
65      "$hdf_framework_path/core/host/src/hdf_device_token.c",
66      "$hdf_framework_path/core/host/src/hdf_load_vdi.c",
67      "$hdf_framework_path/core/host/src/hdf_observer_record.c",
68      "$hdf_framework_path/core/host/src/hdf_power_manager.c",
69      "$hdf_framework_path/core/host/src/hdf_service_observer.c",
70      "$hdf_framework_path/core/host/src/hdf_service_subscriber.c",
71      "$hdf_framework_path/core/host/src/power_state_token.c",
72      "$hdf_framework_path/core/manager/src/hdf_host_info.c",
73      "$hdf_framework_path/core/shared/src/hdf_device_info.c",
74      "$hdf_framework_path/core/shared/src/hdf_object_manager.c",
75      "$hdf_framework_path/core/shared/src/hdf_service_record.c",
76      "$hdf_framework_path/utils/src/hdf_task_queue.c",
77      "$hdf_uhdf_path/host/src/devhost_dump.c",
78      "$hdf_uhdf_path/host/src/devhost_object_config.c",
79      "$hdf_uhdf_path/host/src/devhost_service_full.c",
80      "$hdf_uhdf_path/host/src/devhost_service_stub.c",
81      "$hdf_uhdf_path/host/src/device_service_stub.c",
82      "$hdf_uhdf_path/host/src/device_token_stub.c",
83      "$hdf_uhdf_path/host/src/devmgr_service_proxy.c",
84      "$hdf_uhdf_path/host/src/devsvc_manager_proxy.c",
85      "$hdf_uhdf_path/host/src/driver_loader_full.c",
86      "$hdf_uhdf_path/host/src/hdf_device_thread.c",
87      "$hdf_uhdf_path/host/src/hdf_devsvc_manager_clnt.c",
88      "$hdf_uhdf_path/host/src/hdf_pm_reg.c",
89      "$hdf_uhdf_path/shared/src/dev_attribute_serialize.c",
90      "$hdf_uhdf_path/shared/src/hcb_config_entry.c",
91    ]
92
93    if (is_standard_system) {
94      deps = [
95        "../ipc:libhdf_ipc_adapter",
96        "../utils:libhdf_utils",
97      ]
98      external_deps = [
99        "c_utils:utils",
100        "hilog:libhilog",
101      ]
102    } else {
103      external_deps = [ "hilog:libhilog" ]
104    }
105
106    install_images = [ chipset_base_dir ]
107    subsystem_name = "hdf"
108    part_name = "hdf_core"
109  }
110
111  ohos_executable("hdf_devhost") {
112    include_dirs = [
113      "$hdf_framework_path/core/manager/include",
114      "$hdf_framework_path/core/host/include",
115      "$hdf_framework_path/core/shared/include",
116      "$hdf_framework_path/utils/include",
117      "$hdf_uhdf_path/include/host",
118      "$hdf_uhdf_path/shared/include",
119      "$hdf_uhdf_path/manager/include",
120      "$hdf_uhdf_path/osal/include",
121      "$hdf_interfaces_path/inner_api/core",
122      "include",
123    ]
124
125    sources = [ "devhost.c" ]
126
127    if (is_standard_system) {
128      deps = [
129        "../host:libhdf_host",
130        "../ipc:libhdf_ipc_adapter",
131        "../utils:libhdf_utils",
132      ]
133      external_deps = [
134        "c_utils:utils",
135        "hilog:libhilog",
136        "init:libbegetutil",
137      ]
138    } else {
139      external_deps = [ "hilog:libhilog" ]
140    }
141
142    # Ensure that the maximum page size is 4096 and the load section is aligned
143    ldflags = [
144      "-Wl,-z,max-page-size=4096",
145      "-Wl,-z,separate-code",
146    ]
147
148    install_enable = true
149    install_images = [ chipset_base_dir ]
150    subsystem_name = "hdf"
151    part_name = "hdf_core"
152  }
153}
154