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("//build/ohos_var.gni") 17import("//foundation/arkui/ace_engine/ace_config.gni") 18if (sdk_build_public) { 19 import("//out/sdk-public/public_interface/sdk-js/interface_config.gni") 20} else { 21 import("//interface/sdk-js/interface_config.gni") 22} 23 24ets_loader_lib_dir = 25 get_label_info(":build_ets_loader_library", "target_out_dir") + "/lib" 26ets_loader_declarations_dir = get_label_info(":build_ets_loader_library", 27 "target_out_dir") + "/declarations" 28ets_loader_component_config_file = 29 get_label_info(":build_ets_loader_library", "target_out_dir") + 30 "/component_config.json" 31ets_loader_form_config_file = 32 get_label_info(":build_ets_loader_library", "target_out_dir") + 33 "/form_config.json" 34ets_sysResource = get_label_info(":build_ets_sysResource", "target_out_dir") + 35 "/sysResource.js" 36ets_loader_kit_configs_dir = get_label_info(":build_ets_loader_library", 37 "target_out_dir") + "/kit_configs" 38 39action("build_ets_loader_library") { 40 deps = [ 41 ":components", 42 ":form_components", 43 ":install_arkguard_tsc", 44 ":server", 45 ] 46 script = "build_ets_loader_library.py" 47 depfile = "$target_gen_dir/$target_name.d" 48 outputs = [ 49 ets_loader_lib_dir, 50 ets_loader_declarations_dir, 51 ets_loader_component_config_file, 52 ets_loader_form_config_file, 53 ets_loader_kit_configs_dir, 54 ] 55 56 _ets_loader_dir = "compiler" 57 if (is_standard_system) { 58 _ace_config_dir = "compiler" 59 } else { 60 _ace_config_dir = "//prebuilts/ace-toolkit/ets-loader/compiler" 61 } 62 _declarations_file_dir = "//interface/sdk-js/api/@internal/component/ets" 63 _kit_configs_file_dir = "//interface/sdk-js/kits" 64 _kit_apis_file_dir = "//interface/sdk-js/api" 65 _arkts_apis_file_dir = "//interface/sdk-js/arkts" 66 isPublic = "false" 67 if (sdk_build_public) { 68 _declarations_file_dir = 69 "//out/sdk-public/public_interface/sdk-js/api/@internal/component/ets" 70 _kit_configs_file_dir = "//out/sdk-public/public_interface/sdk-js/kits" 71 _kit_apis_file_dir = "//out/sdk-public/public_interface/sdk-js/api" 72 _arkts_apis_file_dir = "//out/sdk-public/public_interface/sdk-js/arkts" 73 isPublic = "true" 74 } 75 76 _babel_js = _ace_config_dir + "/node_modules/@babel/cli/bin/babel.js" 77 _babel_config_js = _ace_config_dir + "/babel.config.js" 78 _uglify_source_js = _ace_config_dir + "/uglify-source.js" 79 _build_declarations_file_js = _ace_config_dir + "/build_declarations_file.js" 80 _build_kit_configs_file_js = _ace_config_dir + "/build_kitConfigs_file.js" 81 82 inputs = [ 83 _babel_config_js, 84 _babel_js, 85 _uglify_source_js, 86 _build_declarations_file_js, 87 _build_kit_configs_file_js, 88 ] 89 90 nodejs_path = "//prebuilts/build-tools/common/nodejs/current/bin/node" 91 92 args = [ 93 "--depfile", 94 rebase_path(depfile, root_build_dir), 95 "--node", 96 rebase_path(nodejs_path, root_build_dir), 97 "--babel-js", 98 rebase_path(_babel_js, root_build_dir), 99 "--ets-loader-src-dir", 100 rebase_path(_ets_loader_dir + "/src", root_build_dir), 101 "--babel-config-js", 102 rebase_path(_babel_config_js, root_build_dir), 103 "--uglify-source-js", 104 rebase_path(_uglify_source_js, root_build_dir), 105 "--output-dir", 106 rebase_path(ets_loader_lib_dir, root_build_dir), 107 "--declarations-file-dir", 108 rebase_path(_declarations_file_dir, root_build_dir), 109 "--build-declarations-file-js", 110 rebase_path(_build_declarations_file_js, root_build_dir), 111 "--output-declarations-dir", 112 rebase_path(ets_loader_declarations_dir, root_build_dir), 113 "--output-component-config-file", 114 rebase_path(ets_loader_component_config_file, root_build_dir), 115 "--output-form-config-file", 116 rebase_path(ets_loader_form_config_file, root_build_dir), 117 "--kit-configs-file-dir", 118 rebase_path(_kit_configs_file_dir, root_build_dir), 119 "--build-kit-configs-file-js", 120 rebase_path(_build_kit_configs_file_js, root_build_dir), 121 "--output-kit-configs-dir", 122 rebase_path(ets_loader_kit_configs_dir, root_build_dir), 123 "--kit-apis-file-dir", 124 rebase_path(_kit_apis_file_dir, root_build_dir), 125 "--arkts-apis-file-dir", 126 rebase_path(_arkts_apis_file_dir, root_build_dir), 127 "--build-public-sdk", 128 isPublic, 129 ] 130} 131 132action("build_ets_sysResource") { 133 if (is_standard_system) { 134 script = "//developtools/ace_ets2bundle/generateSysResource.py" 135 } else { 136 script = "//foundation/ace/huawei_proprietary/tools/ets-loader/generateSysResource.py" 137 } 138 outputs = [ ets_sysResource ] 139 140 _id_defined_json = "//base/global/system_resources/systemres/main/resources/base/element/id_defined.json" 141 inputs = [ _id_defined_json ] 142 143 args = [ 144 "--input-json", 145 rebase_path(_id_defined_json, root_build_dir), 146 "--output-js", 147 rebase_path(ets_sysResource, root_build_dir), 148 ] 149} 150 151ets_loader_sources = [ 152 "compiler/compile_plugin.js", 153 "compiler/main.js", 154 "compiler/node_modules", 155 "compiler/npm-install.js", 156 "compiler/package-lock.json", 157 "compiler/package.json", 158 "compiler/rollup.config.js", 159 "compiler/tsconfig.esm.json", 160 "compiler/tsconfig.json", 161 "compiler/webpack.config.js", 162] 163 164ohos_copy("ets_loader") { 165 deps = [ 166 ":build_ets_loader_library", 167 ":install_arkguard_tsc", 168 ] 169 sources = ets_loader_sources 170 deps += [ ":build_ets_sysResource" ] 171 sources += [ ets_sysResource ] 172 173 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 174 module_source_dir = target_out_dir + "/$target_name" 175 module_install_name = "" 176} 177 178ohos_copy("ets_loader_component_config") { 179 deps = [ ":build_ets_loader_library" ] 180 sources = [ ets_loader_component_config_file ] 181 182 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 183 module_source_dir = target_out_dir + "/$target_name" 184 module_install_name = "" 185} 186 187ohos_copy("ets_loader_form_config") { 188 deps = [ ":build_ets_loader_library" ] 189 sources = [ ets_loader_form_config_file ] 190 191 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 192 module_source_dir = target_out_dir + "/$target_name" 193 module_install_name = "" 194} 195 196ohos_copy("ets_loader_library") { 197 deps = [ ":build_ets_loader_library" ] 198 sources = [ ets_loader_lib_dir ] 199 outputs = [ target_out_dir + "/$target_name" ] 200 module_source_dir = target_out_dir + "/$target_name" 201 module_install_name = "" 202} 203 204ohos_copy("ets_loader_kit_configs") { 205 deps = [ ":build_ets_loader_library" ] 206 sources = [ ets_loader_kit_configs_dir ] 207 outputs = [ target_out_dir + "/$target_name" ] 208 module_source_dir = target_out_dir + "/$target_name" 209 module_install_name = "" 210} 211 212ohos_copy("components") { 213 sources = [ "compiler/components" ] 214 outputs = [ target_out_dir + "/$target_name" ] 215 module_source_dir = target_out_dir + "/$target_name" 216 module_install_name = "" 217} 218 219ohos_copy("form_components") { 220 sources = [ "compiler/form_components" ] 221 outputs = [ target_out_dir + "/$target_name" ] 222 module_source_dir = target_out_dir + "/$target_name" 223 module_install_name = "" 224} 225 226ohos_copy("server") { 227 sources = [ "compiler/server" ] 228 outputs = [ target_out_dir + "/$target_name" ] 229 module_source_dir = target_out_dir + "/$target_name" 230 module_install_name = "" 231} 232 233ohos_copy("codegen") { 234 sources = [ "compiler/codegen" ] 235 outputs = [ target_out_dir + "/$target_name" ] 236 module_source_dir = target_out_dir + "/$target_name" 237 module_install_name = "" 238} 239 240ohos_copy("ets_loader_declaration") { 241 deps = [ ":build_ets_loader_library" ] 242 sources = [ ets_loader_declarations_dir ] 243 outputs = [ target_out_dir + "/$target_name" ] 244 module_source_dir = target_out_dir + "/$target_name" 245 module_install_name = "" 246} 247 248ohos_copy("ets_loader_ark") { 249 deps = [ 250 ":build_ets_loader_library", 251 ":install_arkguard_tsc", 252 ] 253 sources = ets_loader_sources 254 deps += [ ":build_ets_sysResource" ] 255 sources += [ ets_sysResource ] 256 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 257} 258 259ohos_copy("ets_loader_ark_lib") { 260 deps = [ 261 ":build_ets_loader_library", 262 ":ets_loader_ark", 263 ] 264 sources = [ ets_loader_lib_dir ] 265 outputs = [ target_out_dir + "/ets_loader_ark/lib" ] 266} 267 268ohos_copy("ets_loader_ark_declaration") { 269 deps = [ 270 ":build_ets_loader_library", 271 ":ets_loader_ark", 272 ] 273 sources = [ ets_loader_declarations_dir ] 274 outputs = [ target_out_dir + "/ets_loader_ark/declarations" ] 275} 276 277ohos_copy("ets_loader_ark_components") { 278 deps = [ 279 ":build_ets_loader_library", 280 ":ets_loader_ark", 281 ] 282 sources = [ "compiler/components" ] 283 outputs = [ target_out_dir + "/ets_loader_ark/components" ] 284} 285 286ohos_copy("ets_loader_ark_form_components") { 287 deps = [ 288 ":build_ets_loader_library", 289 ":ets_loader_ark", 290 ] 291 sources = [ "compiler/form_components" ] 292 outputs = [ target_out_dir + "/ets_loader_ark/form_components" ] 293} 294 295ohos_copy("ets_loader_ark_server") { 296 deps = [ 297 ":build_ets_loader_library", 298 ":ets_loader_ark", 299 ] 300 sources = [ "compiler/server" ] 301 outputs = [ target_out_dir + "/ets_loader_ark/server" ] 302} 303 304ohos_copy("ets_loader_ark_codegen") { 305 deps = [ 306 ":build_ets_loader_library", 307 ":ets_loader_ark", 308 ] 309 sources = [ "compiler/codegen" ] 310 outputs = [ target_out_dir + "/ets_loader_ark/codegen" ] 311} 312 313ohos_copy("ohos_declaration_ets_ark") { 314 deps = [] 315 if (sdk_build_public) { 316 deps += [ "//out/sdk-public/public_interface/sdk-js:ohos_declaration_ets" ] 317 } else { 318 deps += [ "//interface/sdk-js:ohos_declaration_ets" ] 319 } 320 321 sources = [ root_out_dir + "/ohos_declaration/ohos_declaration_ets" ] 322 323 outputs = [ target_out_dir + "/../api" ] 324} 325 326ohos_copy("ets_loader_ark_hap") { 327 sources = common_api_src 328 deps = [ 329 ":ets_loader_ark", 330 ":ets_loader_ark_codegen", 331 ":ets_loader_ark_components", 332 ":ets_loader_ark_declaration", 333 ":ets_loader_ark_form_components", 334 ":ets_loader_ark_lib", 335 ":ets_loader_ark_server", 336 ":ohos_declaration_ets_ark", 337 ] 338 outputs = [ target_out_dir + "/../../developtools/api/{{source_file_part}}" ] 339 module_install_name = "" 340} 341 342typescript_dir = get_label_info("//third_party/typescript:build_typescript", 343 "target_out_dir") 344 345action("install_arkguard_tsc") { 346 deps = [ 347 "//arkcompiler/ets_frontend/arkguard:build_arkguard", 348 "//third_party/typescript:build_typescript", 349 ] 350 script = "install_arkguard_tsc.py" 351 args = [ 352 rebase_path("${typescript_dir}/ohos-typescript-4.9.5-r4.tgz"), 353 rebase_path( 354 "${root_out_dir}/obj/arkcompiler/ets_frontend/arkguard/arkguard-1.1.3.tgz"), 355 rebase_path("//developtools/ace_ets2bundle/compiler"), 356 current_os, 357 ] 358 outputs = [ "${target_out_dir}/${target_name}.stamp" ] 359} 360