• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("//foundation/arkui/ace_engine/ace_config.gni")
16import("//foundation/arkui/ace_engine/build/ace_lib.gni")
17
18# generate libace_engine and libace_debug targets
19foreach(item, ace_platforms) {
20  platform = item.name
21  engine_config = {
22  }
23  engine_config = item.config
24  support_engines = []
25  support_engines = engine_config.js_engines
26
27  # generate libace_static lib
28  libace_static("libace_static_" + item.name) {
29    platform = item.name
30    config = {
31    }
32
33    if (defined(item.config)) {
34      config = item.config
35    }
36  }
37
38  # generate separated libace_engine lib
39  if (current_os == "ohos") {
40    build_in_engine = defined(engine_config.use_build_in_js_engine) &&
41                      engine_config.use_build_in_js_engine
42    foreach(engine, support_engines) {
43      if (!build_in_engine) {
44        # generate libace_engine
45        ace_bridge_engine("libace_engine_${engine.engine_name}_${platform}") {
46          platform = item.name
47          engine_name = engine.engine_name
48          build_type = "engine"
49          use_js_debug = false
50        }
51
52        # generate libace_engine_debug
53        if (defined(engine.have_debug) && engine.have_debug) {
54          ace_bridge_engine(
55              "libace_engine_${engine.engine_name}_debug_${platform}") {
56            platform = item.name
57            engine_name = engine.engine_name
58            build_type = "engine"
59            use_js_debug = true
60          }
61        }
62
63        # generate libace_engine_declarative
64        ace_bridge_engine(
65            "libace_engine_declarative_${engine.engine_name}_${platform}") {
66          platform = item.name
67          engine_name = engine.engine_name
68          build_type = "engine_declarative"
69        }
70      }
71
72      # generate libace_engine_pa
73      if (defined(engine_config.js_pa_support) && engine_config.js_pa_support &&
74          platform != "ohos_ng") {
75        ace_bridge_engine("libace_engine_pa_${engine.engine_name}") {
76          platform = item.name
77          engine_name = engine.engine_name
78          build_type = "engine_pa"
79          pa_engine_path = engine_config.pa_engine_path
80        }
81      }
82    }
83  }
84}
85
86# Config for reduceing eh_frame section on aosp platform to save rom size.
87config("reduce_eh_frame_config") {
88  if (!use_mingw_win && !use_mac && !use_linux) {
89    cflags = [
90      "-fno-unwind-tables",
91      "-fomit-frame-pointer",
92    ]
93    cflags_cc = cflags
94  }
95}
96
97config("ace_engine_public_config") {
98  if (use_hilog) {
99    defines = [ "USE_HILOG" ]
100  }
101}
102
103config("lto_link_config") {
104  if (enable_lto_O0) {
105    ldflags = [ "-Wl,--lto-O0" ]
106  } else {
107    ldflags = [ "-Wl,--lto-O2" ]
108  }
109  if (ace_engine_feature_enable_pgo && enable_enhanced_opt) {
110    ldflags += [
111      "-Wl,-mllvm,-force-sched-model=${ace_engine_feature_sched_model}",
112      "-Wl,-Bsymbolic",
113    ]
114    if (ace_engine_feature_enable_codemerge && !is_asan) {
115      ldflags += [
116        "-Wl,-plugin-opt=-split-machine-functions",
117        "-Wl,-mllvm",
118        "-Wl,-fixup-unconditional-branch-unsafely",
119        "-Wl,--no-create-thunks-introduced-by-mfs",
120        "-Wl,-mllvm",
121        "-Wl,-mfs-psi-cutoff=999500",
122        "-Wl,-z",
123        "-Wl,keep-text-section-prefix",
124        "-Wl,--symbol-ordering-file=" +
125            rebase_path("${ace_engine_feature_pgo_path}/libace_compatible.txt",
126                        root_build_dir),
127        "-Wl,--no-warn-symbol-ordering",
128      ]
129    }
130    if (ace_engine_feature_enable_inst_prefetch && target_cpu == "arm64") {
131      ldflags += [
132        "-Wl,-mllvm,--aarch64-enable-inst-prefetch",
133        "-Wl,-mllvm,--mir-cachemiss-profile-l2i=" + rebase_path(
134                "${ace_engine_feature_pgo_path}/afdo/libace_compatible.z-l2i.afdo",
135                root_build_dir),
136      ]
137    }
138  }
139}
140
141ohos_shared_library("libace_compatible") {
142  public_configs = [
143    ":ace_engine_public_config",
144    "$ace_root/interfaces/inner_api/ace_kit:ace_kit_config",
145  ]
146  external_deps = []
147  if (use_hilog) {
148    external_deps += [ "hilog:libhilog" ]
149  }
150  deps = [ "$ace_root/interfaces/inner_api/ace_kit:ace_kit" ]
151  if (is_ohos) {
152    sanitize = {
153      integer_overflow = true
154      boundary_sanitize = true
155      debug = ace_sanitize_debug
156    }
157    deps += [ "$ace_root/build:libace_static_ohos" ]
158    deps += [ "$ace_root/adapter/ohos/services/etc:ace_engine_param" ]
159    version_script = "libace.map"
160    innerapi_tags = [ "platformsdk" ]
161    configs = [ "$ace_root:ace_coverage_config" ]
162    if (is_clang && (target_cpu == "arm" || target_cpu == "arm64") &&
163        enhanced_opt) {
164      configs += [ ":lto_link_config" ]
165    }
166  } else if (use_mingw_win) {
167    deps += [ "$ace_root/build:libace_static_windows" ]
168  } else if (use_mac) {
169    deps += [ "$ace_root/build:libace_static_mac" ]
170  } else if (use_linux) {
171    deps += [ "$ace_root/build:libace_static_linux" ]
172  }
173  public_external_deps = external_deps
174  part_name = ace_engine_part
175  subsystem_name = ace_engine_subsystem
176}
177
178if (!is_asan) {
179  ohos_shared_library("libace") {
180    external_deps = []
181    if (use_hilog) {
182      external_deps += [ "hilog:libhilog" ]
183    }
184    deps = [ "$ace_root/interfaces/inner_api/ace_kit:ace_kit" ]
185    if (is_ohos) {
186      sanitize = {
187        integer_overflow = true
188        boundary_sanitize = true
189        debug = ace_sanitize_debug
190      }
191      deps += [ "$ace_root/build:libace_static_ohos_ng" ]
192      version_script = "libace.map"
193      innerapi_tags = [ "platformsdk" ]
194      configs = [ "$ace_root:ace_coverage_config" ]
195    } else if (use_mingw_win) {
196      deps += [ "$ace_root/build:libace_static_windows" ]
197    } else if (use_mac) {
198      deps += [ "$ace_root/build:libace_static_mac" ]
199    } else if (use_linux) {
200      deps += [ "$ace_root/build:libace_static_linux" ]
201    }
202    public_external_deps = external_deps
203    part_name = ace_engine_part
204    subsystem_name = ace_engine_subsystem
205  }
206} else {
207  group("libace") {
208    # fake target for asan
209  }
210}
211