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