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