• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 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")
15
16idl_root = "//foundation/ability/idl_tool"
17idl_build_deps = ""
18idl_out_root = ""
19
20build_root = "//build"
21toolchain_linux = "$build_root/toolchain/linux:clang_x64"
22if (host_cpu == "arm64") {
23  toolchain_mac = "$build_root/toolchain/mac:clang_arm64"
24} else {
25  toolchain_mac = "$build_root/toolchain/mac:clang_x64"
26}
27toolchain_win = "$build_root/toolchain/mingw:mingw_x86_64"
28
29if (host_toolchain == toolchain_mac) {
30  idl_out_root = get_label_info("$idl_root:idl($toolchain_mac)", "root_out_dir")
31  idl_build_deps = [ "$idl_root:idl($toolchain_mac)" ]
32} else if (host_toolchain == toolchain_win) {
33  idl_out_root = get_label_info("$idl_root:idl($toolchain_win)", "root_out_dir")
34  idl_build_deps = [ "$idl_root:idl($toolchain_win)" ]
35} else {
36  idl_out_root =
37      get_label_info("$idl_root:idl($toolchain_linux)", "root_out_dir")
38  idl_build_deps = [ "$idl_root:idl($toolchain_linux)" ]
39}
40
41idl_build_path = idl_out_root + "/ability/idl_tool"
42
43template("idl_gen_interface") {
44  assert(defined(invoker.src_idl), "src-idl is required!")
45  assert(defined(invoker.dst_file), "dst-file is required!")
46
47  action("$target_name") {
48    deps = idl_build_deps
49    script = "${idl_root}/scripts/idl.py"
50    args = [
51      "--src-idl",
52      invoker.src_idl,
53      "--dst-path",
54      rebase_path("${target_gen_dir}"),
55      "--idl-tool-path",
56      rebase_path("${idl_build_path}"),
57    ]
58    if (defined(invoker.log_domainid)) {
59      args += [
60        "--log-domainid",
61        invoker.log_domainid,
62      ]
63    }
64    if (defined(invoker.log_tag)) {
65      args += [
66        "--log-tag",
67        invoker.log_tag,
68      ]
69    }
70    if (defined(invoker.hitrace)) {
71      args += [
72        "--hitrace",
73        invoker.hitrace,
74      ]
75    }
76    outputs = string_split(invoker.dst_file, ",")
77  }
78}
79