1# Copyright (c) 2021-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/arkui/ace_engine/ace_config.gni")
16
17# Common config for Ability Cross-platform Environment(ACE) source
18config("ace_config") {
19  include_dirs = [
20    "$ace_root",
21    "$ace_root/frameworks",
22    "$root_out_dir/arkui/framework",
23  ]
24
25  if (use_hilog) {
26    include_dirs += [ "$hilog_root/interfaces/native/innerkits/include" ]
27  }
28
29  if (is_ohos_standard_system && !use_mingw_win && !use_mac && !use_linux) {
30    include_dirs += [ "$ace_root/adapter/ohos/services/uiservice/include" ]
31  }
32  defines = ace_common_defines
33
34  if (is_wearable_product) {
35    defines += ace_wearable_defines
36  }
37
38  if (is_ivi_product) {
39    defines += ace_ivi_defines
40  }
41
42  cflags = [
43    "-fvisibility=hidden",
44    "-fdata-sections",
45    "-ffunction-sections",
46    "-Wno-non-c-typedef-for-linkage",
47    "-Os",
48    "-Werror=return-stack-address",
49  ]
50
51  if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64") &&
52      enhanced_opt) {
53    if (ace_engine_feature_enable_pgo) {
54      cflags += [
55        "-fprofile-use=" + rebase_path(
56                "${ace_engine_feature_pgo_path}/libace_compatible.profdata",
57                root_build_dir),
58        "-Wno-error=backend-plugin",
59        "-Wno-profile-instr-out-of-date",
60        "-Wno-profile-instr-unprofiled",
61      ]
62    }
63    if (ace_engine_feature_enable_atomic) {
64      cflags += [ "-moutline-atomics" ]
65    }
66  }
67
68  cflags_cc = [
69    "-fvisibility-inlines-hidden",
70    "-Wno-non-c-typedef-for-linkage",
71    "-Os",
72  ]
73
74  if (use_mingw_win) {
75    cflags_cc += [ "-std=c++17" ]
76    defines += [ "_USE_MATH_DEFINES" ]
77  }
78
79  if (use_linux) {
80    cflags_cc += [ "-std=c++17" ]
81    defines += [ "_USE_MATH_DEFINES" ]
82  }
83
84  ldflags = []
85  if (ace_engine_feature_enable_coverage) {
86    cflags += [ "--coverage" ]
87    ldflags += [ "--coverage" ]
88  }
89}
90
91config("ace_test_config") {
92  visibility = [ ":*" ]
93  visibility += [
94    "//foundation/arkui/ace_engine/build/*",
95    "//foundation/arkui/ace_engine/frameworks/bridge/test/unittest/*",
96    "//foundation/arkui/ace_engine/frameworks/core/*",
97    "//foundation/arkui/ace_engine/test/fuzztest/*",
98    "//foundation/arkui/ace_engine/test/unittest/*",
99  ]
100  include_dirs = [
101    "$ace_root",
102    "$ace_root/frameworks",
103    "$root_out_dir/arkui/framework",
104  ]
105
106  cflags_cc = []
107  defines = ace_common_defines
108
109  if (is_ohos_standard_system && !use_mingw_win && !use_mac && !use_linux) {
110    include_dirs += [ "$ace_root/adapter/ohos/services/uiservice/include" ]
111
112    cflags_cc += [
113      "-Wno-thread-safety-attributes",
114      "-Wno-thread-safety-analysis",
115      "-Wno-non-c-typedef-for-linkage",
116    ]
117    defines += [ "OHOS_STANDARD_SYSTEM" ]
118  }
119
120  if (!is_ohos_standard_system) {
121    defines += [ "ENABLE_NATIVE_VIEW" ]
122  }
123
124  defines += [ "OHOS_PLATFORM" ]
125
126  if (is_wearable_product) {
127    defines += ace_wearable_defines
128  }
129
130  cflags = [
131    "-fvisibility=hidden",
132    "-fdata-sections",
133    "-ffunction-sections",
134  ]
135
136  cflags_cc += [ "-fvisibility-inlines-hidden" ]
137  ldflags = [ "-Wl,-gc-sections" ]
138
139  if (ace_engine_feature_enable_coverage) {
140    cflags += [ "--coverage" ]
141    ldflags += [ "--coverage" ]
142  }
143}
144
145config("ace_coverage_config") {
146  cflags = []
147  ldflags = []
148  if (ace_engine_feature_enable_coverage) {
149    cflags += [ "--coverage" ]
150    ldflags += [ "--coverage" ]
151  }
152}
153