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/config/components/sdk/interface.gni") 15import("//build/ohos.gni") 16import("//build/ohos/ace/ace.gni") 17import("//build/ohos_var.gni") 18if (!defined(is_arkui_x) || !is_arkui_x) { 19 import("//build/templates/bpf/ohos_bpf_config.gni") 20} 21import("//build/templates/cxx/prebuilt.gni") 22 23ets_loader_lib_dir = 24 get_label_info(":build_ets_loader_library", "target_out_dir") + "/lib" 25ets_loader_declarations_dir = get_label_info(":build_ets_loader_library", 26 "target_out_dir") + "/declarations" 27ets_loader_component_config_file = 28 get_label_info(":build_ets_loader_library", "target_out_dir") + 29 "/component_config.json" 30ets_loader_form_config_file = 31 get_label_info(":build_ets_loader_library", "target_out_dir") + 32 "/form_config.json" 33ets_loader_build_config_file = 34 get_label_info(":build_ets_loader_library", "target_out_dir") + 35 "/build_config.json" 36ets_sysResource = get_label_info(":build_ets_sysResource", "target_out_dir") + 37 "/sysResource.js" 38ets_loader_kit_configs_dir = get_label_info(":build_ets_loader_library", 39 "target_out_dir") + "/kit_configs" 40ets_component_dep = "sdk:ets_component" 41if (defined(is_arkui_x) && is_arkui_x) { 42 ets_component_dep = "//interface/sdk-js:ets_component" 43} 44ets_component_out_dir = get_label_info(ets_component_dep, "target_out_dir") 45 46action("build_ets_loader_library") { 47 deps = [ 48 ":components", 49 ":form_components", 50 ":insight_intents", 51 ":install_arkguard_tsc_declgen", 52 ":server", 53 ] 54 if (defined(is_arkui_x) && is_arkui_x) { 55 deps += [ 56 "//interface/sdk-js:bundle_arkts", 57 "//interface/sdk-js:bundle_kits", 58 "//interface/sdk-js:ets_component", 59 "//interface/sdk-js:ets_internal_api", 60 "//interface/sdk-js:ohos_declaration_ets", 61 ] 62 } else { 63 external_deps = [ 64 "sdk:bundle_arkts_etc", 65 "sdk:bundle_kits_etc", 66 "sdk:ets_component_etc", 67 "sdk:ets_internal_api_etc", 68 "sdk:ohos_declaration_ets_api", 69 ] 70 } 71 script = "build_ets_loader_library.py" 72 depfile = "$target_gen_dir/$target_name.d" 73 outputs = [ 74 ets_loader_lib_dir, 75 ets_loader_declarations_dir, 76 ets_loader_component_config_file, 77 ets_loader_form_config_file, 78 ets_loader_kit_configs_dir, 79 ets_loader_build_config_file, 80 ] 81 82 _ets_loader_dir = "compiler" 83 if (is_standard_system) { 84 _ace_config_dir = "compiler" 85 } else { 86 _ace_config_dir = "//prebuilts/ace-toolkit/ets-loader/compiler" 87 } 88 _declarations_file_dir = ets_component_out_dir + "/${sdk_type}/ets_component" 89 _kit_configs_file_dir = ets_component_out_dir + "/${sdk_type}/bundle_kits" 90 _kit_apis_file_dir = 91 root_out_dir + "/ohos_declaration/${sdk_type}/ohos_declaration_ets" 92 _arkts_apis_file_dir = ets_component_out_dir + "/${sdk_type}/bundle_arkts" 93 94 _babel_js = _ace_config_dir + "/node_modules/@babel/cli/bin/babel.js" 95 _babel_config_js = _ace_config_dir + "/babel.config.js" 96 _uglify_source_js = _ace_config_dir + "/uglify-source.js" 97 _copy_json_files_js = _ace_config_dir + "/copy_json_files.js" 98 _build_declarations_file_js = _ace_config_dir + "/build_declarations_file.js" 99 _build_kit_configs_file_js = _ace_config_dir + "/build_kitConfigs_file.js" 100 101 inputs = [ 102 _babel_config_js, 103 _babel_js, 104 _uglify_source_js, 105 _copy_json_files_js, 106 _build_declarations_file_js, 107 _build_kit_configs_file_js, 108 ] 109 110 nodejs_path = "//prebuilts/build-tools/common/nodejs/current/bin/node" 111 112 args = [ 113 "--depfile", 114 rebase_path(depfile, root_build_dir), 115 "--node", 116 rebase_path(nodejs_path, root_build_dir), 117 "--babel-js", 118 rebase_path(_babel_js, root_build_dir), 119 "--ets-loader-src-dir", 120 rebase_path(_ets_loader_dir + "/src", root_build_dir), 121 "--babel-config-js", 122 rebase_path(_babel_config_js, root_build_dir), 123 "--uglify-source-js", 124 rebase_path(_uglify_source_js, root_build_dir), 125 "--output-dir", 126 rebase_path(ets_loader_lib_dir, root_build_dir), 127 "--copy-json-files-js", 128 rebase_path(_copy_json_files_js, root_build_dir), 129 "--copy-src-dir", 130 rebase_path(_ets_loader_dir + "/src", root_build_dir), 131 "--copy-dest-dir", 132 rebase_path(ets_loader_lib_dir, root_build_dir), 133 "--declarations-file-dir", 134 rebase_path(_declarations_file_dir, root_build_dir), 135 "--build-declarations-file-js", 136 rebase_path(_build_declarations_file_js, root_build_dir), 137 "--output-declarations-dir", 138 rebase_path(ets_loader_declarations_dir, root_build_dir), 139 "--output-component-config-file", 140 rebase_path(ets_loader_component_config_file, root_build_dir), 141 "--output-form-config-file", 142 rebase_path(ets_loader_form_config_file, root_build_dir), 143 "--output-build-config-file", 144 rebase_path(ets_loader_build_config_file, root_build_dir), 145 "--kit-configs-file-dir", 146 rebase_path(_kit_configs_file_dir, root_build_dir), 147 "--build-kit-configs-file-js", 148 rebase_path(_build_kit_configs_file_js, root_build_dir), 149 "--output-kit-configs-dir", 150 rebase_path(ets_loader_kit_configs_dir, root_build_dir), 151 "--kit-apis-file-dir", 152 rebase_path(_kit_apis_file_dir, root_build_dir), 153 "--arkts-apis-file-dir", 154 rebase_path(_arkts_apis_file_dir, root_build_dir), 155 "--build-public-sdk", 156 "${sdk_build_public}", 157 "--sdk-build-arkts", 158 "${sdk_build_arkts}", 159 ] 160} 161 162action("build_ets_sysResource") { 163 if (is_standard_system) { 164 script = "//developtools/ace_ets2bundle/generateSysResource.py" 165 } else { 166 script = "//foundation/ace/huawei_proprietary/tools/ets-loader/generateSysResource.py" 167 } 168 outputs = [ ets_sysResource ] 169 170 _id_defined_json = "//base/global/system_resources/systemres/main/resources/base/element/id_defined.json" 171 inputs = [ _id_defined_json ] 172 173 args = [ 174 "--input-json", 175 rebase_path(_id_defined_json, root_build_dir), 176 "--output-js", 177 rebase_path(ets_sysResource, root_build_dir), 178 ] 179} 180 181main_sources = "compiler/main.js" 182if (sdk_build_arkts) { 183 main_sources = "compiler/src/interop/main.js" 184} 185 186ets_loader_sources = [ 187 "compiler/compile_plugin.js", 188 "compiler/config/obfuscateWhiteList.json5", 189 "compiler/config/stmgmtWhiteList.json", 190 "compiler/node_modules", 191 "compiler/npm-install.js", 192 "compiler/package-lock.json", 193 "compiler/package.json", 194 "compiler/rollup.config.js", 195 "compiler/tsconfig.esm.json", 196 "compiler/tsconfig.json", 197 "compiler/webpack.config.js", 198 main_sources, 199] 200 201ohos_copy("ets_loader") { 202 deps = [ 203 ":build_ets_loader_library", 204 ":install_arkguard_tsc_declgen", 205 ] 206 sources = ets_loader_sources 207 deps += [ ":build_ets_sysResource" ] 208 sources += [ ets_sysResource ] 209 210 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 211 module_source_dir = target_out_dir + "/$target_name" 212 module_install_name = "" 213} 214 215ohos_copy("ets_loader_component_config") { 216 deps = [ ":build_ets_loader_library" ] 217 sources = [ 218 ets_loader_build_config_file, 219 ets_loader_component_config_file, 220 ] 221 222 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 223 module_source_dir = target_out_dir + "/$target_name" 224 module_install_name = "" 225} 226 227ohos_copy("ets_loader_form_config") { 228 deps = [ ":build_ets_loader_library" ] 229 sources = [ ets_loader_form_config_file ] 230 231 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 232 module_source_dir = target_out_dir + "/$target_name" 233 module_install_name = "" 234} 235 236ohos_copy("ets_loader_library") { 237 deps = [ ":build_ets_loader_library" ] 238 sources = [ ets_loader_lib_dir ] 239 outputs = [ target_out_dir + "/$target_name" ] 240 module_source_dir = target_out_dir + "/$target_name" 241 module_install_name = "" 242} 243 244ohos_copy("ets_loader_kit_configs") { 245 deps = [ ":build_ets_loader_library" ] 246 sources = [ ets_loader_kit_configs_dir ] 247 outputs = [ target_out_dir + "/$target_name" ] 248 module_source_dir = target_out_dir + "/$target_name" 249 module_install_name = "" 250} 251 252ohos_copy("components") { 253 sources = [ "compiler/components" ] 254 outputs = [ target_out_dir + "/$target_name" ] 255 module_source_dir = target_out_dir + "/$target_name" 256 module_install_name = "" 257} 258 259ohos_copy("form_components") { 260 sources = [ "compiler/form_components" ] 261 outputs = [ target_out_dir + "/$target_name" ] 262 module_source_dir = target_out_dir + "/$target_name" 263 module_install_name = "" 264} 265 266ohos_copy("insight_intents") { 267 sources = [ "compiler/insight_intents" ] 268 outputs = [ target_out_dir + "/$target_name" ] 269 module_source_dir = target_out_dir + "/$target_name" 270 module_install_name = "" 271} 272 273ohos_copy("server") { 274 sources = [ "compiler/server" ] 275 outputs = [ target_out_dir + "/$target_name" ] 276 module_source_dir = target_out_dir + "/$target_name" 277 module_install_name = "" 278} 279 280ohos_copy("codegen") { 281 sources = [ "compiler/codegen" ] 282 outputs = [ target_out_dir + "/$target_name" ] 283 module_source_dir = target_out_dir + "/$target_name" 284 module_install_name = "" 285} 286 287ohos_copy("ets_loader_declaration") { 288 deps = [ ":build_ets_loader_library" ] 289 sources = [ ets_loader_declarations_dir ] 290 outputs = [ target_out_dir + "/$target_name" ] 291 module_source_dir = target_out_dir + "/$target_name" 292 module_install_name = "" 293} 294 295ohos_copy("ets_loader_ark") { 296 deps = [ 297 ":build_ets_loader_library", 298 ":install_arkguard_tsc_declgen", 299 ] 300 sources = ets_loader_sources 301 deps += [ ":build_ets_sysResource" ] 302 sources += [ ets_sysResource ] 303 outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] 304} 305 306ohos_copy("ets_loader_ark_lib") { 307 deps = [ 308 ":build_ets_loader_library", 309 ":ets_loader_ark", 310 ] 311 sources = [ ets_loader_lib_dir ] 312 outputs = [ target_out_dir + "/ets_loader_ark/lib" ] 313} 314 315ohos_copy("ets_loader_ark_declaration") { 316 deps = [ 317 ":build_ets_loader_library", 318 ":ets_loader_ark", 319 ] 320 sources = [ ets_loader_declarations_dir ] 321 outputs = [ target_out_dir + "/ets_loader_ark/declarations" ] 322} 323 324ohos_copy("ets_loader_ark_components") { 325 deps = [ 326 ":build_ets_loader_library", 327 ":ets_loader_ark", 328 ] 329 sources = [ "compiler/components" ] 330 outputs = [ target_out_dir + "/ets_loader_ark/components" ] 331} 332 333ohos_copy("ets_loader_ark_form_components") { 334 deps = [ 335 ":build_ets_loader_library", 336 ":ets_loader_ark", 337 ] 338 sources = [ "compiler/form_components" ] 339 outputs = [ target_out_dir + "/ets_loader_ark/form_components" ] 340} 341 342ohos_copy("ets_loader_ark_insight_intents") { 343 deps = [ 344 ":build_ets_loader_library", 345 ":ets_loader_ark", 346 ] 347 sources = [ "compiler/insight_intents" ] 348 outputs = [ target_out_dir + "/ets_loader_ark/insight_intents" ] 349} 350 351ohos_copy("ets_loader_ark_server") { 352 deps = [ 353 ":build_ets_loader_library", 354 ":ets_loader_ark", 355 ] 356 sources = [ "compiler/server" ] 357 outputs = [ target_out_dir + "/ets_loader_ark/server" ] 358} 359 360ohos_copy("ets_loader_ark_codegen") { 361 deps = [ 362 ":build_ets_loader_library", 363 ":ets_loader_ark", 364 ] 365 sources = [ "compiler/codegen" ] 366 outputs = [ target_out_dir + "/ets_loader_ark/codegen" ] 367} 368 369ohos_prebuilt_etc("ets_loader_ark_hap") { 370 source = "OAT.xml" 371 deps = [ ":ets_loader_ark_hap_inner" ] 372 install_enable = false 373 part_name = "ace_ets2bundle" 374 subsystem_name = "developtools" 375} 376 377ohos_copy("ohos_declaration_ets_ark") { 378 if (defined(is_arkui_x) && is_arkui_x) { 379 deps = [ "//interface/sdk-js:ohos_declaration_ets" ] 380 sources = 381 [ root_out_dir + "/ohos_declaration/${sdk_type}/ohos_declaration_ets" ] 382 383 } else { 384 external_deps = [ "sdk:ohos_declaration_ets_api" ] 385 ets_ark_path = get_label_info("sdk:ohos_declaration_ets_api", 386 "target_out_dir") + "/../api" 387 sources = [ ets_ark_path ] 388 } 389 outputs = [ target_out_dir + "/../api" ] 390} 391 392group("ets_loader_ark_hap_inner") { 393 deps = [ 394 ":ets_loader_ark", 395 ":ets_loader_ark_codegen", 396 ":ets_loader_ark_components", 397 ":ets_loader_ark_declaration", 398 ":ets_loader_ark_form_components", 399 ":ets_loader_ark_insight_intents", 400 ":ets_loader_ark_lib", 401 ":ets_loader_ark_server", 402 ":ohos_declaration_ets_ark", 403 ] 404} 405 406typescript_dir = get_label_info("//third_party/typescript:build_typescript", 407 "target_out_dir") 408 409action("install_arkguard_tsc_declgen") { 410 external_deps = [ 411 "ets_frontend:build_arkguard_etc", 412 "runtime_core:build_declgen_etc", 413 "typescript:build_typescript_etc", 414 ] 415 script = "install_arkguard_tsc_declgen.py" 416 args = [ 417 rebase_path("${typescript_dir}/ohos-typescript-4.9.5-r4.tgz"), 418 rebase_path( 419 "${root_out_dir}/obj/arkcompiler/ets_frontend/arkguard/arkguard-1.1.3.tgz"), 420 rebase_path("//developtools/ace_ets2bundle/compiler"), 421 current_os, 422 rebase_path( 423 "${root_out_dir}/obj/arkcompiler/runtime_core/static_core/plugins/ets/tools/declgen_ts2sts/panda-declgen-1.0.0.tgz"), 424 ] 425 outputs = [ "${target_out_dir}/${target_name}.stamp" ] 426} 427