1# Copyright (c) 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("//build/ohos.gni")
15import("//foundation/resourceschedule/background_task_mgr/bgtaskmgr.gni")
16
17cflags = []
18
19config("bgtaskmgr_public_config") {
20  include_dirs = [ "napi/include" ]
21}
22
23ohos_shared_library("backgroundtaskmanager") {
24  branch_protector_ret = "pac_ret"
25  sanitize = {
26    cfi = true
27    cfi_cross_dso = true
28    debug = false
29  }
30  sources = [
31    "napi/src/bg_continuous_task_napi_module.cpp",
32    "napi/src/cancel_suspend_delay.cpp",
33    "napi/src/common.cpp",
34    "napi/src/efficiency_resources_operation.cpp",
35    "napi/src/get_remaining_delay_time.cpp",
36    "napi/src/init.cpp",
37    "napi/src/request_suspend_delay.cpp",
38  ]
39
40  public_configs = [ ":bgtaskmgr_public_config" ]
41
42  deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits" ]
43
44  external_deps = [
45    "ability_base:want",
46    "ability_runtime:ability_context_native",
47    "ability_runtime:abilitykit_native",
48    "ability_runtime:napi_base_context",
49    "ability_runtime:wantagent_innerkits",
50    "bundle_framework:appexecfwk_base",
51    "bundle_framework:appexecfwk_core",
52    "c_utils:utils",
53    "common_event_service:cesfwk_innerkits",
54    "hilog:libhilog",
55    "hitrace:hitrace_meter",
56    "ipc:ipc_single",
57    "napi:ace_napi",
58    "samgr:samgr_proxy",
59  ]
60
61  defines = []
62  if (background_task_mgr_jsstack) {
63    defines += [ "SUPPORT_JSSTACK" ]
64    external_deps += [ "hiview:libxpower_event_js" ]
65  }
66
67  relative_install_dir = "module"
68  subsystem_name = "resourceschedule"
69  part_name = "background_task_mgr"
70}
71
72ohos_shared_library("backgroundtaskmanager_napi") {
73  branch_protector_ret = "pac_ret"
74  sanitize = {
75    cfi = true
76    cfi_cross_dso = true
77    debug = false
78  }
79  sources = [
80    "napi/src/bg_continuous_task_napi_module.cpp",
81    "napi/src/cancel_suspend_delay.cpp",
82    "napi/src/common.cpp",
83    "napi/src/efficiency_resources_operation.cpp",
84    "napi/src/get_remaining_delay_time.cpp",
85    "napi/src/init_bgtaskmgr.cpp",
86    "napi/src/request_suspend_delay.cpp",
87  ]
88
89  public_configs = [ ":bgtaskmgr_public_config" ]
90
91  deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits" ]
92
93  external_deps = [
94    "ability_base:want",
95    "ability_runtime:ability_context_native",
96    "ability_runtime:abilitykit_native",
97    "ability_runtime:napi_base_context",
98    "ability_runtime:wantagent_innerkits",
99    "bundle_framework:appexecfwk_base",
100    "bundle_framework:appexecfwk_core",
101    "c_utils:utils",
102    "common_event_service:cesfwk_innerkits",
103    "hilog:libhilog",
104    "hitrace:hitrace_meter",
105    "ipc:ipc_single",
106    "napi:ace_napi",
107    "samgr:samgr_proxy",
108  ]
109
110  defines = []
111  if (background_task_mgr_jsstack) {
112    defines += [ "SUPPORT_JSSTACK" ]
113    external_deps += [ "hiview:libxpower_event_js" ]
114  }
115
116  relative_install_dir = "module/resourceschedule"
117  subsystem_name = "resourceschedule"
118  part_name = "background_task_mgr"
119}
120
121ohos_shared_library("cj_background_task_mgr_ffi") {
122  sanitize = {
123    cfi = true
124    cfi_cross_dso = true
125    debug = false
126  }
127
128  include_dirs = [ "../innerkits/include" ]
129
130  if (!defined(defines)) {
131    defines = []
132  }
133
134  if (product_name != "ohos-sdk") {
135    deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits" ]
136    external_deps = [
137      "ability_base:want",
138      "ability_runtime:ability_context_native",
139      "ability_runtime:abilitykit_native",
140      "ability_runtime:napi_base_context",
141      "ability_runtime:wantagent_innerkits",
142      "bundle_framework:appexecfwk_base",
143      "c_utils:utils",
144      "common_event_service:cesfwk_innerkits",
145      "hilog:libhilog",
146      "hitrace:hitrace_meter",
147      "ipc:ipc_single",
148      "napi:ace_napi",
149      "napi:cj_bind_ffi",
150      "napi:cj_bind_native",
151      "samgr:samgr_proxy",
152    ]
153    sources = [ "cj/background_task_mgr/background_task_mgr_ffi.cpp" ]
154  } else {
155    defines += [ "PREVIEWER" ]
156    sources = [ "cj/background_task_mgr/background_task_mock.cpp" ]
157    external_deps = [ "napi:cj_bind_ffi" ]
158  }
159
160  if (current_os == "ohos") {
161    defines += [ "OHOS_PLATFORM" ]
162  }
163
164  if (current_os == "mingw") {
165    defines += [ "WINDOWS_PLATFORM" ]
166  }
167
168  innerapi_tags = [ "platformsdk" ]
169  subsystem_name = "resourceschedule"
170  part_name = "background_task_mgr"
171}
172
173ohos_shared_library("transient_task") {
174  sanitize = {
175    cfi = true
176    cfi_cross_dso = true
177    debug = false
178  }
179
180  branch_protector_ret = "pac_ret"
181
182  output_extension = "so"
183  include_dirs = [ "$bgtaskmgr_root_path/interfaces/kits/c/include" ]
184
185  sources =
186      [ "$bgtaskmgr_root_path/interfaces/kits/c/src/transient_task_api.cpp" ]
187
188  cflags = [
189    "-fstack-protector-strong",
190    "-D_FORTIFY_SOURCE=2",
191    "-O2",
192  ]
193
194  cflags_cc = [
195    "-fstack-protector-strong",
196    "-D_FORTIFY_SOURCE=2",
197    "-O2",
198  ]
199
200  deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits" ]
201
202  external_deps = [
203    "ability_base:want",
204    "ability_runtime:ability_context_native",
205    "ability_runtime:abilitykit_native",
206    "ability_runtime:napi_base_context",
207    "ability_runtime:wantagent_innerkits",
208    "bundle_framework:appexecfwk_base",
209    "c_utils:utils",
210    "common_event_service:cesfwk_innerkits",
211    "hilog:libhilog",
212    "hitrace:hitrace_meter",
213    "ipc:ipc_single",
214    "napi:ace_napi",
215    "napi:cj_bind_ffi",
216    "napi:cj_bind_native",
217    "samgr:samgr_proxy",
218  ]
219
220  subsystem_name = "resourceschedule"
221  part_name = "background_task_mgr"
222  relative_install_dir = "ndk"
223}
224