1# Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved.
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/graphic/graphic_2d/graphic_config.gni")
16effect_root = "$graphic_2d_root/rosen/modules/effect"
17effect_ndk_include_dir =
18    "$graphic_2d_root/rosen/modules/effect/effect_ndk/include"
19effect_ndk_src_dir = "$graphic_2d_root/rosen/modules/effect/effect_ndk/src"
20
21config("export_config") {
22  include_dirs = [ "$effect_ndk_include_dir" ]
23}
24
25template("effect_ndk_source_set") {
26  forward_variables_from(invoker, "*")
27
28  ohos_source_set(target_name) {
29    defines += invoker.defines
30    cflags_cc = []
31
32    sanitize = {
33      cfi = true
34      cfi_cross_dso = true
35      cfi_vcall_icall_only = true
36      debug = false
37    }
38
39    external_deps = [
40      "c_utils:utils",
41      "hilog:libhilog",
42      "image_framework:image",
43    ]
44
45    public_deps = [
46      "$effect_root//skia_effectChain:skeffectchain",
47      "$effect_root/color_picker:color_picker",
48    ]
49    public_external_deps = [ "jsoncpp:jsoncpp" ]
50
51    configs = [ ":export_config" ]
52    sources = [
53      "$effect_ndk_src_dir/effect_filter.cpp",
54      "$effect_ndk_src_dir/filter/filter.cpp",
55    ]
56
57    if (is_arkui_x) {
58      defines += [ "CROSS_PLATFORM" ]
59    }
60    if (rs_enable_gpu) {
61      defines += [ "RS_ENABLE_GPU" ]
62    }
63    if (is_emulator) {
64      defines += [ "ROSEN_EMULATOR" ]
65    }
66
67    include_dirs = [
68      "$graphic_2d_root/rosen/modules/render_service_base/include",
69      "$graphic_2d_root/modules/2d_graphics/include",
70    ]
71
72    if (platform == "ohos" || platform == "ohos_ng") {
73      defines += [ "OHOS_PLATFORM" ]
74      external_deps += [
75        "bounds_checking_function:libsec_static",
76        "image_framework:pixelmap",
77        "image_framework:pixelmap_ndk",
78      ]
79      deps = [ "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base" ]
80      cflags = [ "-fstack-protector-strong" ]
81      cflags_cc += [ "-fstack-protector-strong" ]
82    } else {
83      deps = []
84      cflags = [ "-std=c++17" ]
85
86      if (!is_arkui_x) {
87        deps += [ "$rosen_root/modules/platform:hilog" ]
88      }
89    }
90    part_name = "graphic_2d"
91    subsystem_name = "graphic"
92  }
93}
94
95effect_ndk_source_set("effect_ndk_source_ohos") {
96  platform = "ohos"
97  defines = []
98}
99
100ohos_shared_library("native_effect_ndk") {
101  sanitize = {
102    cfi = true
103    cfi_cross_dso = true
104    cfi_vcall_icall_only = true
105    debug = false
106  }
107  platform = current_os
108  if (platform == "mingw") {
109    platform = "windows"
110  }
111  public_configs = [ ":export_config" ]
112
113  if (platform == "ohos") {
114    deps = [ "$effect_root/effect_ndk:effect_ndk_source_ohos" ]
115    symlink_target_name = [ "libnative_effect.so" ]
116    innerapi_tags = [ "ndk" ]
117  }
118  part_name = "graphic_2d"
119  subsystem_name = "graphic"
120}
121