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/ohos.gni") 15import("//foundation/arkui/ace_engine/ace_config.gni") 16 17prebuilt_js_api_mock_path = 18 get_label_info(":gen_snapshot_jsmock", "target_out_dir") + 19 "/dist/jsMockSystemPlugin.js" 20 21mock_root = "." 22 23action("gen_node_modules") { 24 script = "./prebuild_env.sh" 25 args = [] 26 inputs = [ 27 "package.json", 28 "package-lock.json", 29 ] 30 outputs = [ "$root_out_dir/automock/node_modules" ] 31} 32 33action("gen_snapshot_jsmock") { 34 script = "$mock_root/js_framework_build.sh" 35 js_framework_mock_generate = "$mock_root/mock-generate" 36 is_mac = "false" 37 is_preview_engine = "false" 38 if (use_mingw_win || use_mac || use_linux) { 39 is_preview_engine = "true" 40 } 41 use_mac = host_os == "mac" 42 43 node_modules = "//prebuilts/build-tools/common/js-framework/node_modules" 44 nodejs_path = "//prebuilts/build-tools/common/nodejs/current" 45 if (use_mac) { 46 is_mac = "true" 47 } else { 48 is_mac = "false" 49 } 50 51 buildfile_jsmock = "$mock_root/build_jsmock_system_plugin.js" 52 53 package_file = "$mock_root/mock-generate/package.json" 54 tsconfig = "$mock_root/mock-generate/tsconfig.json" 55 eslint = "$mock_root/mock-generate/.eslintrc" 56 babel = "$mock_root/mock-generate/.babelrc" 57 api_input_path = "//interface/sdk-js/api" 58 59 args = [ 60 rebase_path(buildfile_jsmock, root_build_dir), 61 rebase_path(nodejs_path, root_build_dir), 62 rebase_path(node_modules, root_build_dir), 63 rebase_path(package_file, root_build_dir), 64 rebase_path(tsconfig, root_build_dir), 65 rebase_path(eslint, root_build_dir), 66 rebase_path(target_out_dir, root_build_dir), 67 is_mac, 68 rebase_path("//prebuilts", root_build_dir), 69 rebase_path(api_input_path), 70 rebase_path(js_framework_mock_generate, root_build_dir), 71 is_preview_engine, 72 rebase_path(babel, root_build_dir), 73 ] 74 75 inputs = [ 76 # config of compiler 77 "./mock-generate/.eslintrc", 78 "build_jsmock_system_plugin.js", 79 "./mock-generate/tsconfig.json", 80 ] 81 outputs = [ prebuilt_js_api_mock_path ] 82} 83