• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022 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("//foundation/arkui/ace_engine/ace_config.gni")
16
17install_path = "SADialog"
18template("gen_sa_dialog_js") {
19  forward_variables_from(invoker, "*")
20
21  action("build_dialog_js") {
22    if (use_mac) {
23      nodejs_path =
24          "//prebuilts/build-tools/common/nodejs/node-v12.18.4-darwin-x64/bin"
25    } else {
26      nodejs_path =
27          "//prebuilts/build-tools/common/nodejs/node-v12.18.4-linux-x64/bin"
28    }
29    project_path = invoker.project_path
30    script = "//foundation/arkui/ace_engine/build/tools/build_js.py"
31    outputs = [
32      target_out_dir + "/default/app.js",
33      target_out_dir + "/default/pages/index/index.js",
34      target_out_dir + "/default/manifest.json",
35    ]
36
37    if (defined(i18n_files)) {
38      foreach(i18n_file, i18n_files) {
39        outputs += [ target_out_dir + "/default/" + i18n_file ]
40      }
41    }
42
43    if (defined(common_files)) {
44      foreach(common_file, common_files) {
45        outputs += [ target_out_dir + "/default/" + common_file ]
46      }
47    }
48
49    args = [
50      rebase_path(project_path, root_build_dir),
51      rebase_path(target_out_dir, root_build_dir),
52      rebase_path(nodejs_path, root_build_dir),
53      rebase_path("//developtools/ace_js2bundle", root_build_dir),
54      rebase_path("//interface", root_build_dir),
55      rebase_path("//third_party/parse5", root_build_dir),
56      rebase_path("//third_party/weex-loader", root_build_dir),
57    ]
58  }
59
60  ohos_prebuilt_etc("dialog_js_files_app") {
61    deps = [ ":build_dialog_js" ]
62    relative_install_dir = "$install_path/$dialog_name"
63    source = target_out_dir + "/default/app.js"
64  }
65
66  ohos_prebuilt_etc("dialog_js_files_index") {
67    deps = [ ":build_dialog_js" ]
68    relative_install_dir = "$install_path/$dialog_name/pages/index"
69    source = target_out_dir + "/default/pages/index/index.js"
70  }
71
72  if (defined(i18n_files)) {
73    foreach(i18n_file, i18n_files) {
74      name = string_replace(i18n_file, "/", "_")
75      ohos_prebuilt_etc("dialog_js_files_$name") {
76        deps = [ ":build_dialog_js" ]
77        relative_install_dir = "$install_path/$dialog_name/i18n"
78        source = target_out_dir + "/default/$i18n_file"
79      }
80    }
81  }
82
83  if (defined(common_files)) {
84    foreach(common_file, common_files) {
85      name = string_replace(common_file, "/", "_")
86      ohos_prebuilt_etc("dialog_js_files_$name") {
87        deps = [ ":build_dialog_js" ]
88        relative_install_dir = "$install_path/$dialog_name/common"
89        source = target_out_dir + "/default/$common_file"
90      }
91    }
92  }
93
94  ohos_prebuilt_etc("dialog_js_files_manifest") {
95    deps = [ ":build_dialog_js" ]
96    relative_install_dir = "$install_path/$dialog_name"
97    source = target_out_dir + "/default/manifest.json"
98  }
99
100  group(target_name) {
101    deps = [
102      ":dialog_js_files_app",
103      ":dialog_js_files_index",
104      ":dialog_js_files_manifest",
105    ]
106    if (defined(i18n_files)) {
107      foreach(i18n_file, i18n_files) {
108        name = string_replace(i18n_file, "/", "_")
109        deps += [ ":dialog_js_files_$name" ]
110      }
111    }
112    if (defined(common_files)) {
113      foreach(common_file, common_files) {
114        name = string_replace(common_file, "/", "_")
115        deps += [ ":dialog_js_files_$name" ]
116      }
117    }
118  }
119}
120