1# Copyright (c) 2021-2022 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("../../resmgr.gni")
16
17# source code for win.
18is_win = "${current_os}_${current_cpu}" == "mingw_x86_64"
19
20# source code for linux.
21is_linux = "${current_os}_${current_cpu}" == "linux_x64"
22
23# source code for mac.
24is_mac = "${current_os}_${current_cpu}" == "mac_x64" ||
25         "${current_os}_${host_cpu}" == "mac_arm64"
26
27config("resmgr_config") {
28  include_dirs = [
29    "include",
30    "../../interfaces/inner_api/include",
31  ]
32}
33
34manager_sources = [
35  "src/hap_manager.cpp",
36  "src/hap_resource.cpp",
37  "src/hap_resource_manager.cpp",
38  "src/locale_matcher.cpp",
39  "src/res_config_impl.cpp",
40  "src/res_desc.cpp",
41  "src/res_locale.cpp",
42  "src/resource_manager.cpp",
43  "src/resource_manager_ext_mgr.cpp",
44  "src/resource_manager_impl.cpp",
45  "src/system_resource_manager.cpp",
46  "src/theme_pack_config.cpp",
47  "src/theme_pack_manager.cpp",
48  "src/theme_pack_resource.cpp",
49  "src/utils/hap_parser.cpp",
50  "src/utils/psue_manager.cpp",
51  "src/utils/string_utils.cpp",
52  "src/utils/utils.cpp",
53]
54
55config("resmgr_public_config") {
56  visibility = [ ":*" ]
57
58  include_dirs = [ "../../interfaces/inner_api/include" ]
59
60  if (resource_management_support_icu) {
61    defines = [ "SUPPORT_GRAPHICS" ]
62  }
63}
64
65config("global_resmgr_all_deps_config") {
66  include_dirs = [ "../../interfaces/inner_api/include" ]
67}
68
69config("rawfile_public_config") {
70  include_dirs = [
71    "./include",
72    "../../interfaces/native/resource/include",
73  ]
74}
75
76ohos_shared_library("global_resmgr") {
77  sources = manager_sources
78
79  sources += [ "../../dfx/hisysevent_adapter/hisysevent_adapter.cpp" ]
80
81  defines = [ "CONFIG_HILOG" ]
82
83  configs = [ ":resmgr_config" ]
84
85  version_script = "libresmgr.versionscript"
86
87  include_dirs = [ "../../dfx/hisysevent_adapter" ]
88
89  public_configs = [
90    ":resmgr_public_config",
91    ":global_resmgr_all_deps_config",
92  ]
93
94  external_deps = [
95    "ability_base:extractortool",
96    "bounds_checking_function:libsec_shared",
97    "cJSON:cjson",
98    "hilog:libhilog",
99    "hisysevent:libhisysevent",
100    "hitrace:hitrace_meter",
101    "init:libbegetutil",
102    "zlib:shared_libz",
103  ]
104
105  if (resource_management_support_icu) {
106    external_deps += [ "icu:shared_icui18n" ]
107    public_external_deps = [ "icu:shared_icuuc" ]
108  }
109
110  branch_protector_ret = "pac_ret"
111  sanitize = {
112    boundary_sanitize = true
113    cfi = true
114    cfi_cross_dso = true
115    debug = false
116    integer_overflow = true
117    ubsan = true
118  }
119  subsystem_name = "global"
120  innerapi_tags = [
121    "platformsdk_indirect",
122    "sasdk",
123  ]
124  part_name = "resource_management"
125}
126
127ohos_shared_library("global_resmgr_win") {
128  if (resource_management_support_icu) {
129    defines = [
130      "__WINNT__",
131      "__EXPORT_MGR__",
132      "__IDE_PREVIEW__",
133    ]
134    cflags = [
135      "-std=c++17",
136      "-Wno-ignored-attributes",
137    ]
138
139    sources = manager_sources
140
141    configs = [ ":resmgr_config" ]
142
143    public_configs = [ ":resmgr_public_config" ]
144
145    external_deps = [
146      "bounds_checking_function:libsec_shared",
147      "cJSON:cjson_static",
148      "icu:static_icui18n",
149      "zlib:libz",
150    ]
151    public_external_deps = [ "icu:static_icuuc" ]
152
153    libs = [ "shlwapi" ]
154  }
155  subsystem_name = "global"
156  part_name = "resource_management"
157}
158
159group("win_resmgr") {
160  if (is_win && resource_management_support_icu) {
161    public_deps = [ ":global_resmgr_win" ]
162  }
163}
164
165ohos_shared_library("global_resmgr_mac") {
166  if (resource_management_support_icu) {
167    defines = [ "__IDE_PREVIEW__" ]
168    cflags = [
169      "-std=c++17",
170      "-Wno-ignored-attributes",
171    ]
172
173    sources = manager_sources
174
175    configs = [ ":resmgr_config" ]
176
177    public_configs = [ ":resmgr_public_config" ]
178
179    if (host_os == "mac") {
180      external_deps = [
181        "bounds_checking_function:libsec_static",
182        "cJSON:cjson_static",
183        "icu:static_icui18n",
184        "zlib:libz",
185      ]
186      public_external_deps = [ "icu:static_icuuc" ]
187    }
188  }
189  subsystem_name = "global"
190  part_name = "resource_management"
191}
192
193group("mac_resmgr") {
194  if (is_mac && resource_management_support_icu) {
195    public_deps = [ ":global_resmgr_mac" ]
196  }
197}
198
199ohos_shared_library("global_resmgr_linux") {
200  if (resource_management_support_icu) {
201    defines = [
202      "__IDE_PREVIEW__",
203      "__LINUX__",
204    ]
205    cflags = [
206      "-std=c++17",
207      "-Wno-ignored-attributes",
208    ]
209
210    sources = manager_sources
211
212    configs = [ ":resmgr_config" ]
213
214    public_configs = [ ":resmgr_public_config" ]
215
216    external_deps = [
217      "bounds_checking_function:libsec_shared",
218      "cJSON:cjson_static",
219      "icu:shared_icui18n",
220      "zlib:shared_libz",
221    ]
222    public_external_deps = [ "icu:shared_icuuc" ]
223  }
224  subsystem_name = "global"
225  part_name = "resource_management"
226}
227
228group("linux_resmgr") {
229  if (is_linux && resource_management_support_icu) {
230    deps = [ ":global_resmgr_linux" ]
231  }
232}
233
234ohos_shared_library("librawfile") {
235  output_name = "rawfile"
236  public_configs = [ ":rawfile_public_config" ]
237  sources = [ "src/raw_file_manager.cpp" ]
238
239  defines = [ "CONFIG_HILOG" ]
240
241  include_dirs = [
242    "./include",
243    "../../interfaces/native/resource/include",
244    "../../interfaces/inner_api/include",
245    "../../interfaces/js/innerkits/core/include",
246  ]
247
248  cflags = [ "-Wno-error=inconsistent-missing-override" ]
249
250  deps = [ ":global_resmgr" ]
251
252  external_deps = [
253    "ability_base:configuration",
254    "bundle_framework:appexecfwk_base",
255    "cJSON:cjson_static",
256    "c_utils:utils",
257    "hilog:libhilog",
258    "napi:ace_napi",
259  ]
260
261  if (resource_management_support_icu) {
262    external_deps += [ "icu:shared_icuuc" ]
263  }
264
265  stack_protector_ret = true
266  sanitize = {
267    boundary_sanitize = true
268    cfi = true
269    cfi_cross_dso = true
270    debug = false
271    integer_overflow = true
272    ubsan = true
273  }
274  subsystem_name = "global"
275  part_name = "resource_management"
276}
277
278ohos_shared_library("ohresmgr") {
279  public_configs = [ ":rawfile_public_config" ]
280  sources = [ "src/native_resource_manager.cpp" ]
281  output_extension = "so"
282  output_name = "ohresmgr"
283
284  defines = [ "CONFIG_HILOG" ]
285
286  include_dirs = [
287    "./include",
288    "../../interfaces/native/resource/include",
289    "../../interfaces/inner_api/include",
290    "../../interfaces/js/innerkits/core/include",
291  ]
292
293  cflags = [ "-Wno-error=inconsistent-missing-override" ]
294
295  deps = [ ":global_resmgr" ]
296
297  external_deps = [
298    "ability_base:configuration",
299    "ace_engine:ace_ndk",
300    "ace_engine:drawable_descriptor",
301    "bundle_framework:appexecfwk_base",
302    "cJSON:cjson_static",
303    "c_utils:utils",
304    "hilog:libhilog",
305    "napi:ace_napi",
306  ]
307
308  stack_protector_ret = true
309  sanitize = {
310    boundary_sanitize = true
311    cfi = true
312    cfi_cross_dso = true
313    debug = false
314    integer_overflow = true
315    ubsan = true
316  }
317  innerapi_tags = [ "ndk" ]
318  subsystem_name = "global"
319  part_name = "resource_management"
320}
321