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("//build/ohos/ace/ace.gni") 16import("//foundation/arkui/ace_engine/ace_config.gni") 17 18ace_loader_lib_dir = 19 get_label_info(":build_ace_loader_library", "target_out_dir") + "/lib" 20 21action("build_ace_loader_library") { 22 script = "build_ace_loader_library.py" 23 depfile = "$target_gen_dir/$target_name.d" 24 outputs = [ ace_loader_lib_dir ] 25 26 _ace_loader_dir = "ace-loader" 27 28 _module_source_js = _ace_loader_dir + "/module-source.js" 29 30 _parse5_project_dir = "//third_party/parse5/packages/parse5" 31 32 if (is_standard_system) { 33 _ace_config_dir = "ace-loader" 34 } else { 35 _ace_config_dir = "//prebuilts/ace-toolkit/ace-loader/linux-x64" 36 } 37 _babel_js = _ace_config_dir + "/node_modules/@babel/cli/bin/babel.js" 38 _babel_config_js = _ace_config_dir + "/babel.config.js" 39 _uglify_source_js = _ace_config_dir + "/uglify-source.js" 40 _tsc_js = _parse5_project_dir + "/node_modules/typescript/bin/tsc" 41 42 inputs = [ 43 _babel_config_js, 44 _babel_js, 45 _tsc_js, 46 _module_source_js, 47 _uglify_source_js, 48 ] 49 50 nodejs_path = "//prebuilts/build-tools/common/nodejs/current/bin/node" 51 52 args = [ 53 "--depfile", 54 rebase_path(depfile, root_build_dir), 55 "--node", 56 rebase_path(nodejs_path, root_build_dir), 57 "--babel-js", 58 rebase_path(_babel_js, root_build_dir), 59 "--ace-loader-src-dir", 60 rebase_path(_ace_loader_dir + "/src", root_build_dir), 61 "--babel-config-js", 62 rebase_path(_babel_config_js, root_build_dir), 63 "--tsc-js", 64 rebase_path(_tsc_js, root_build_dir), 65 "--parse5-project", 66 rebase_path(_parse5_project_dir, root_build_dir), 67 "--parse5-output-dir", 68 rebase_path(_parse5_project_dir + "/dist/cjs", root_build_dir), 69 "--module-source-js", 70 rebase_path(_module_source_js, root_build_dir), 71 "--uglify-source-js", 72 rebase_path(_uglify_source_js, root_build_dir), 73 "--output-dir", 74 rebase_path(ace_loader_lib_dir, root_build_dir), 75 ] 76} 77 78ace_loader_sources = [ 79 "ace-loader/.npmignore", 80 "ace-loader/babel.config.js", 81 "ace-loader/index.js", 82 "ace-loader/main.product.js", 83 "ace-loader/node_modules", 84 "ace-loader/npm-install.js", 85 "ace-loader/package-lock.json", 86 "ace-loader/package.json", 87 "ace-loader/sample", 88 "ace-loader/webpack.lite.config.js", 89 "ace-loader/webpack.rich.config.js", 90] 91 92ohos_copy("ace_loader") { 93 sources = ace_loader_sources 94 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 95 module_source_dir = target_out_dir + "/$target_name/" 96 module_install_name = "" 97 license_file = "//third_party/parse5/LICENSE" 98} 99 100ohos_copy("ace_loader_library") { 101 deps = [ ":build_ace_loader_library" ] 102 sources = [ ace_loader_lib_dir ] 103 outputs = [ target_out_dir + "/$target_name" ] 104 module_source_dir = target_out_dir + "/$target_name" 105 module_install_name = "" 106 license_file = "//third_party/weex-loader/NOTICE" 107} 108 109# copy previewer 110ohos_copy("previewer_copy") { 111 if (host_os == "mac") { 112 sources = [ "//prebuilts/previewer/darwin/previewer" ] 113 } else { 114 if ("${current_os}_${current_cpu}" == "mingw_x86_64") { 115 sources = [ "//prebuilts/previewer/windows/previewer" ] 116 } else { 117 sources = [ "//prebuilts/previewer/linux/previewer" ] 118 } 119 } 120 outputs = [ target_out_dir + "/{{source_file_part}}" ] 121 module_source_dir = target_out_dir + "/previewer/" 122 module_install_name = "" 123} 124 125ace_loader_ark_dir = 126 get_label_info(":ace_loader", "target_out_dir") + "/ace_loader_ark" 127ohos_copy("ace_loader_ark") { 128 sources = ace_loader_sources 129 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 130 license_file = "//third_party/parse5/LICENSE" 131} 132 133ohos_copy("ace_loader_ark_hap") { 134 deps = [ 135 ":ace_loader", 136 ":ace_loader_ark", 137 ":build_ace_loader_library", 138 "//developtools/ace_ets2bundle:ets_loader_ark_hap", 139 ] 140 sources = [ ace_loader_lib_dir ] 141 outputs = [ ace_loader_ark_dir + "/lib" ] 142 license_file = "//third_party/parse5/LICENSE" 143} 144