1# Copyright (c) 2021 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 17prebuilt_js_path = get_label_info(":gen_snapshot", "target_out_dir") + 18 "/dist/strip.native.min.js" 19prebuilt_js_api_mock_path = get_label_info(":gen_snapshot", "target_out_dir") + 20 "/dist/jsMockSystemPlugin.js" 21 22action("gen_node_modules") { 23 script = "//third_party/jsframework/prebuild_env.sh" 24 args = [] 25 inputs = [ 26 "package.json", 27 "package-lock.json", 28 ] 29 outputs = [ "$root_out_dir/jsframework/node_modules" ] 30} 31 32action("gen_snapshot") { 33 script = "//third_party/jsframework/js_framework_build.sh" 34 35 js_framework = "//third_party/jsframework/runtime" 36 js_framework_mock_generate = "//third_party/jsframework/mock-generate" 37 is_mac = "false" 38 use_mac = host_os == "mac" 39 40 if (is_standard_system || is_cross_platform_build) { 41 node_modules = "//prebuilts/build-tools/common/js-framework/node_modules" 42 if (use_mac) { 43 nodejs_path = 44 "//prebuilts/build-tools/common/nodejs/node-v12.18.4-darwin-x64" 45 is_mac = "true" 46 } else { 47 nodejs_path = 48 "//prebuilts/build-tools/common/nodejs/node-v12.18.4-linux-x64" 49 is_mac = "false" 50 } 51 } else { 52 node_modules = "//prebuilts/ace-toolkit/js-framework/node_modules" 53 if (use_mac) { 54 nodejs_path = "//prebuilts/ace-toolkit/nodejs/node-v12.18.4-darwin-x64" 55 is_mac = "true" 56 } else { 57 nodejs_path = "//prebuilts/ace-toolkit/nodejs/node-v12.18.4-linux-x64" 58 is_mac = "false" 59 } 60 } 61 62 buildfile_jsmock = "//third_party/jsframework/build_jsmock_system_plugin.js" 63 buildfile_native_min = "//third_party/jsframework/build_strip_native_min.js" 64 65 package_file = "//third_party/jsframework/package.json" 66 tsconfig = "//third_party/jsframework/tsconfig.json" 67 eslint = "//third_party/jsframework/.eslintrc" 68 babel = "//third_party/jsframework/.babelrc" 69 test_file = "//third_party/jsframework/test" 70 css_what = "//third_party/css-what" 71 72 args = [ 73 rebase_path(buildfile_jsmock, root_build_dir), 74 rebase_path(nodejs_path, root_build_dir), 75 rebase_path(js_framework, root_build_dir), 76 rebase_path(node_modules, root_build_dir), 77 rebase_path(package_file, root_build_dir), 78 rebase_path(tsconfig, root_build_dir), 79 rebase_path(eslint, root_build_dir), 80 rebase_path(test_file, root_build_dir), 81 rebase_path(target_out_dir, root_build_dir), 82 rebase_path(babel, root_build_dir), 83 is_mac, 84 rebase_path("//prebuilts", root_build_dir), 85 rebase_path(buildfile_native_min, root_build_dir), 86 rebase_path(css_what, root_build_dir), 87 rebase_path(js_framework_mock_generate, root_build_dir), 88 ] 89 90 inputs = [ 91 # app 92 "runtime/main/app/App.ts", 93 "runtime/main/app/bundle.ts", 94 "runtime/main/app/helper.ts", 95 "runtime/main/app/index.ts", 96 "runtime/main/app/map.ts", 97 98 # plugin 99 "runtime/main/extend/dpi/Dpi.ts", 100 "runtime/main/extend/dpi/index.ts", 101 "runtime/main/extend/i18n/I18n.ts", 102 "runtime/main/extend/i18n/index.ts", 103 "runtime/main/extend/mediaquery/mediaQuery.ts", 104 "runtime/main/extend/mediaquery/pluginMediaQuery.ts", 105 "runtime/main/extend/mediaquery/plugins.ts", 106 107 # manage event 108 "runtime/main/manage/event/bridge.ts", 109 "runtime/main/manage/event/callbackIntercept.ts", 110 "runtime/main/manage/event/CallbackManager.ts", 111 "runtime/main/manage/event/TaskCenter.ts", 112 113 # manage instance 114 "runtime/main/manage/instance/life.ts", 115 "runtime/main/manage/instance/misc.ts", 116 "runtime/main/manage/instance/register.ts", 117 118 # vdom 119 "runtime/main/model/compiler.ts", 120 "runtime/main/model/directive.ts", 121 "runtime/main/model/domHelper.ts", 122 "runtime/main/model/events.ts", 123 "runtime/main/model/index.ts", 124 "runtime/main/model/pageLife.ts", 125 "runtime/main/model/selector.ts", 126 "runtime/main/model/vmOptions.ts", 127 128 # page 129 "runtime/main/page/api/Differ.ts", 130 "runtime/main/page/api/index.ts", 131 "runtime/main/page/api/misc.ts", 132 "runtime/main/page/entry/bundle.ts", 133 "runtime/main/page/entry/init.ts", 134 "runtime/main/page/Image.ts", 135 "runtime/main/page/index.ts", 136 "runtime/main/page/Page.ts", 137 "runtime/main/page/register.ts", 138 139 # third reactivity 140 "runtime/main/reactivity/array.js", 141 "runtime/main/reactivity/dep.js", 142 "runtime/main/reactivity/object.js", 143 "runtime/main/reactivity/observer.js", 144 "runtime/main/reactivity/state.js", 145 "runtime/main/reactivity/watcher.js", 146 147 # third util 148 "runtime/main/util/index.js", 149 "runtime/main/util/props.js", 150 "runtime/main/util/shared.js", 151 152 # framework expose 153 "runtime/main/config.ts", 154 "runtime/main/index.ts", 155 156 # preparation of init framework 157 "runtime/preparation/index.ts", 158 "runtime/preparation/init.ts", 159 "runtime/preparation/methods.ts", 160 "runtime/preparation/service.ts", 161 162 # utils 163 "runtime/utils/index.ts", 164 "runtime/utils/utils.ts", 165 166 # vdom 167 "runtime/vdom/Comment.ts", 168 "runtime/vdom/Document.ts", 169 "runtime/vdom/DocumentElement.ts", 170 "runtime/vdom/Element.ts", 171 "runtime/vdom/index.ts", 172 "runtime/vdom/NativeElementClassFactory.ts", 173 "runtime/vdom/Node.ts", 174 175 # global 176 "runtime/lib.d.ts", 177 178 # config of compiler 179 ".babelrc", 180 ".eslintrc", 181 "build_jsmock_system_plugin.js", 182 "build_strip_native_min.js", 183 "tsconfig.json", 184 "tslint.json", 185 ] 186 outputs = [ 187 prebuilt_js_path, 188 prebuilt_js_api_mock_path, 189 ] 190} 191 192if (!is_standard_system && !is_cross_platform_build) { 193 import("$v8_root/gni/snapshot_toolchain.gni") 194 195 v8_snapshot_bin_path = get_label_info(":v8_snapshot_bin", "target_out_dir") + 196 "/strip.native.min.js.bin" 197 v8_snapshot_obj_path = get_label_info(":v8_snapshot_bin", "target_out_dir") + 198 "/strip.native.min.js.o" 199 200 action("gen_snapshot_bin") { 201 visibility = [ ":*" ] # Only targets in this file can depend on this. 202 203 deps = [ ":gen_snapshot" ] 204 deps += [ "$v8_root:mksnapshot($v8_snapshot_toolchain)" ] 205 206 script = "$v8_root/tools/run.sh" 207 208 args = [ 209 rebase_path("${aosp_libs_dir}/ndk/libcxx/linux_x86") + ":" + 210 rebase_path("${aosp_libs_dir}/ndk/libcxx/linux_x86_64"), 211 rebase_path( 212 get_label_info("$v8_root:mksnapshot($v8_snapshot_toolchain)", 213 "root_out_dir") + "/arkui/ace_engine_full/mksnapshot"), 214 rebase_path(prebuilt_js_path), 215 "--startup_blob=" + rebase_path(v8_snapshot_bin_path), 216 "--turbo_instruction_scheduling", 217 ] 218 219 inputs = [ prebuilt_js_path ] 220 outputs = [ v8_snapshot_bin_path ] 221 } 222 223 ohos_prebuilt_etc("v8_snapshot_bin") { 224 deps = [ ":gen_snapshot_bin" ] 225 source = v8_snapshot_bin_path 226 part_name = "ace_engine_full" 227 } 228 229 action("gen_snapshot_obj") { 230 visibility = [ ":*" ] # Only targets in this file can depend on this. 231 232 if (use_mingw_win) { 233 objcopy_tool = objcopy_mingw 234 script = "$flutter_root/engine/flutter/sky/tools/objcopy_pc_mac.py" 235 } else if (use_mac) { 236 objcopy_tool = objcopy_clang 237 script = "$flutter_root/engine/flutter/sky/tools/objcopy_pc_mac.py" 238 } else if (target_cpu == "x86_64") { 239 objcopy_tool = objcopy_x86_64 240 script = "$flutter_root/engine/flutter/sky/tools/objcopy.py" 241 } else { 242 objcopy_tool = objcopy_aarch64 243 script = "$flutter_root/engine/flutter/sky/tools/objcopy.py" 244 } 245 246 args = [ 247 "--objcopy", 248 rebase_path(objcopy_tool), 249 "--input", 250 rebase_path(v8_snapshot_bin_path), 251 "--output", 252 rebase_path(v8_snapshot_obj_path), 253 "--arch", 254 current_cpu, 255 ] 256 257 deps = [ ":gen_snapshot_bin" ] 258 259 inputs = [ v8_snapshot_bin_path ] 260 outputs = [ v8_snapshot_obj_path ] 261 } 262 263 source_set("v8_snapshot_obj") { 264 sources = [ v8_snapshot_obj_path ] 265 deps = [ ":gen_snapshot_obj" ] 266 } 267} 268 269import("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni") 270ark_abc_path = 271 get_label_info(":ark_build", "target_out_dir") + "/strip.native.min.abc" 272 273ts2abc_gen_abc("ark_jsf") { 274 extra_visibility = [ ":*" ] # Only targets in this file can depend on this 275 extra_dependencies = [ ":gen_snapshot" ] 276 277 src_js = rebase_path(prebuilt_js_path) 278 dst_file = rebase_path(ark_abc_path) 279 280 in_puts = [ prebuilt_js_path ] 281 out_puts = [ ark_abc_path ] 282} 283 284ohos_prebuilt_etc("ark_build") { 285 deps = [ ":ark_jsf" ] 286 source = ark_abc_path 287 if (!is_cross_platform_build) { 288 part_name = "ace_engine" 289 } 290} 291