1# Copyright (c) 2023 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/config/components/ets_frontend/es2abc_config.gni") 15import("//build/ohos.gni") 16import("//foundation/arkui/ace_engine/ace_config.gni") 17import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni") 18 19prebuilt_js_api_mock_path = 20 get_label_info(":gen_snapshot_jsmock", "target_out_dir") + 21 "/dist/jsMockSystemPlugin.js" 22 23mock_root = "." 24 25action("gen_node_modules") { 26 script = "./prebuild_env.sh" 27 args = [] 28 inputs = [ 29 "package.json", 30 "package-lock.json", 31 ] 32 outputs = [ "$root_out_dir/automock/node_modules" ] 33} 34 35action("gen_snapshot_jsmock") { 36 script = "$mock_root/js_framework_build.sh" 37 js_framework_mock_generate = "$mock_root/mock-generate" 38 is_mac = "false" 39 is_preview_engine = "false" 40 if (use_mingw_win || use_mac || use_linux) { 41 is_preview_engine = "true" 42 } 43 use_mac = host_os == "mac" 44 45 node_modules = "//prebuilts/build-tools/common/js-framework/node_modules" 46 nodejs_path = "//prebuilts/build-tools/common/nodejs/current" 47 if (use_mac) { 48 is_mac = "true" 49 } else { 50 is_mac = "false" 51 } 52 53 buildfile_jsmock = "$mock_root/build_jsmock_system_plugin.js" 54 55 package_file = "$mock_root/mock-generate/package.json" 56 tsconfig = "$mock_root/mock-generate/tsconfig.json" 57 eslint = "$mock_root/mock-generate/.eslintrc" 58 babel = "$mock_root/mock-generate/.babelrc" 59 api_input_path = "//interface/sdk-js/api" 60 61 args = [ 62 rebase_path(buildfile_jsmock, root_build_dir), 63 rebase_path(nodejs_path, root_build_dir), 64 rebase_path(node_modules, root_build_dir), 65 rebase_path(package_file, root_build_dir), 66 rebase_path(tsconfig, root_build_dir), 67 rebase_path(eslint, root_build_dir), 68 rebase_path(target_out_dir, root_build_dir), 69 is_mac, 70 rebase_path("//prebuilts", root_build_dir), 71 rebase_path(api_input_path), 72 rebase_path(js_framework_mock_generate, root_build_dir), 73 is_preview_engine, 74 rebase_path(babel, root_build_dir), 75 ] 76 77 inputs = [ 78 # config of compiler 79 "./mock-generate/.eslintrc", 80 "build_jsmock_system_plugin.js", 81 "./mock-generate/tsconfig.json", 82 ] 83 outputs = [ prebuilt_js_api_mock_path ] 84} 85 86es2abc_gen_abc("gen_abc_js_mock") { 87 js_mock_path = get_label_info(":gen_snapshot_jsmock", "target_out_dir") + 88 "/dist/jsMockSystemPlugin.js" 89 src_js = rebase_path(js_mock_path) 90 dst_file = rebase_path(target_out_dir + "/jsMockSystemPlugin.abc") 91 in_puts = [ js_mock_path ] 92 out_puts = [ target_out_dir + "/jsMockSystemPlugin.abc" ] 93 extra_dependencies = [ ":gen_snapshot_jsmock" ] 94} 95 96gen_obj("js_mock_abc") { 97 input = get_label_info(":gen_abc_js_mock", "target_out_dir") + 98 "/jsMockSystemPlugin.abc" 99 100 if (is_mac || is_mingw || is_linux) { 101 output = target_out_dir + "/js_mock_abc.c" 102 } else { 103 output = target_out_dir + "/js_mock_abc.o" 104 } 105 106 snapshot_dep = [ ":gen_abc_js_mock" ] 107} 108