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