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