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:extensionkit_native",
49    "ability_runtime:napi_base_context",
50    "ability_runtime:wantagent_innerkits",
51    "bundle_framework:appexecfwk_base",
52    "bundle_framework:appexecfwk_core",
53    "c_utils:utils",
54    "common_event_service:cesfwk_innerkits",
55    "hilog:libhilog",
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:extensionkit_native",
98    "ability_runtime:napi_base_context",
99    "ability_runtime:wantagent_innerkits",
100    "bundle_framework:appexecfwk_base",
101    "bundle_framework:appexecfwk_core",
102    "c_utils:utils",
103    "common_event_service:cesfwk_innerkits",
104    "hilog:libhilog",
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      "ipc:ipc_single",
147      "napi:ace_napi",
148      "napi:cj_bind_ffi",
149      "napi:cj_bind_native",
150      "samgr:samgr_proxy",
151    ]
152    sources = [ "cj/background_task_mgr/background_task_mgr_ffi.cpp" ]
153  } else {
154    defines += [ "PREVIEWER" ]
155    sources = [ "cj/background_task_mgr/background_task_mock.cpp" ]
156    external_deps = [ "napi:cj_bind_ffi" ]
157  }
158
159  if (current_os == "ohos") {
160    defines += [ "OHOS_PLATFORM" ]
161  }
162
163  if (current_os == "mingw") {
164    defines += [ "WINDOWS_PLATFORM" ]
165  }
166
167  innerapi_tags = [ "platformsdk" ]
168  subsystem_name = "resourceschedule"
169  part_name = "background_task_mgr"
170}
171
172ohos_shared_library("transient_task") {
173  sanitize = {
174    cfi = true
175    cfi_cross_dso = true
176    debug = false
177  }
178
179  branch_protector_ret = "pac_ret"
180
181  output_extension = "so"
182  include_dirs = [ "$bgtaskmgr_root_path/interfaces/kits/c/include" ]
183
184  sources =
185      [ "$bgtaskmgr_root_path/interfaces/kits/c/src/transient_task_api.cpp" ]
186
187  cflags = [
188    "-fstack-protector-strong",
189    "-D_FORTIFY_SOURCE=2",
190    "-O2",
191  ]
192
193  cflags_cc = [
194    "-fstack-protector-strong",
195    "-D_FORTIFY_SOURCE=2",
196    "-O2",
197  ]
198
199  deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits" ]
200
201  external_deps = [
202    "ability_base:want",
203    "ability_runtime:ability_context_native",
204    "ability_runtime:abilitykit_native",
205    "ability_runtime:napi_base_context",
206    "ability_runtime:wantagent_innerkits",
207    "bundle_framework:appexecfwk_base",
208    "c_utils:utils",
209    "common_event_service:cesfwk_innerkits",
210    "hilog:libhilog",
211    "ipc:ipc_single",
212    "napi:ace_napi",
213    "napi:cj_bind_ffi",
214    "napi:cj_bind_native",
215    "samgr:samgr_proxy",
216  ]
217
218  subsystem_name = "resourceschedule"
219  part_name = "background_task_mgr"
220  relative_install_dir = "ndk"
221}
222