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