• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  nodejs_path = "//prebuilts/build-tools/common/nodejs/current/bin/node"
47
48  args = [
49    "--depfile",
50    rebase_path(depfile, root_build_dir),
51    "--node",
52    rebase_path(nodejs_path, root_build_dir),
53    "--babel-js",
54    rebase_path(_babel_js, root_build_dir),
55    "--ace-loader-src-dir",
56    rebase_path(_ace_loader_dir + "/src", root_build_dir),
57    "--babel-config-js",
58    rebase_path(_babel_config_js, root_build_dir),
59    "--module-source-js",
60    rebase_path(_module_source_js, root_build_dir),
61    "--uglify-source-js",
62    rebase_path(_uglify_source_js, root_build_dir),
63    "--output-dir",
64    rebase_path(ace_loader_lib_dir, root_build_dir),
65  ]
66}
67
68ace_loader_sources = [
69  "ace-loader/.npmignore",
70  "ace-loader/babel.config.js",
71  "ace-loader/index.js",
72  "ace-loader/main.product.js",
73  "ace-loader/node_modules",
74  "ace-loader/npm-install.js",
75  "ace-loader/package-lock.json",
76  "ace-loader/package.json",
77  "ace-loader/sample",
78  "ace-loader/webpack.lite.config.js",
79  "ace-loader/webpack.rich.config.js",
80]
81
82ohos_copy("ace_loader") {
83  sources = ace_loader_sources
84  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
85  module_source_dir = target_out_dir + "/$target_name/"
86  module_install_name = ""
87}
88
89ohos_copy("ace_loader_library") {
90  deps = [ ":build_ace_loader_library" ]
91  sources = [ ace_loader_lib_dir ]
92  outputs = [ target_out_dir + "/$target_name" ]
93  module_source_dir = target_out_dir + "/$target_name"
94  module_install_name = ""
95}
96
97# copy previewer
98ohos_copy("previewer_copy") {
99  if (host_os == "mac") {
100    sources = [ "//prebuilts/previewer/darwin/previewer" ]
101  } else {
102    if ("${current_os}_${current_cpu}" == "mingw_x86_64") {
103      sources = [ "//prebuilts/previewer/windows/previewer" ]
104    } else {
105      sources = [ "//prebuilts/previewer/linux/previewer" ]
106    }
107  }
108  outputs = [ target_out_dir + "/{{source_file_part}}" ]
109  module_source_dir = target_out_dir + "/previewer/"
110  module_install_name = ""
111}
112
113ace_loader_ark_dir =
114    get_label_info(":ace_loader", "target_out_dir") + "/ace_loader_ark"
115ohos_copy("ace_loader_ark") {
116  sources = ace_loader_sources
117  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
118  license_file = "//third_party/parse5/LICENSE"
119}
120
121ohos_copy("ace_loader_ark_hap") {
122  deps = [
123    ":ace_loader",
124    ":ace_loader_ark",
125    ":build_ace_loader_library",
126    "//developtools/ace_ets2bundle:ets_loader_ark_hap",
127  ]
128  sources = [ ace_loader_lib_dir ]
129  outputs = [ ace_loader_ark_dir + "/lib" ]
130}
131