• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2025 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.
13import("//build/ohos.gni")
14
15declare_args() {
16  taihe_file_path = "$root_out_dir/taihe"
17  taihe_toolchain_path = "//prebuilts/taihe/ohos/linux-x86_64/taihe"
18}
19
20template("ohos_taihe") {
21  assert(defined(invoker.taihe_generated_file_path),
22         "please provide taihe_generated_file_path for taihec")
23  forward_variables_from(invoker, [ "taihe_generated_file_path" ])
24
25  action(target_name) {
26    script = "${taihe_toolchain_path}/bin/taihec"
27    args = [
28      rebase_path("${taihe_toolchain_path}/lib/taihe/stdlib/taihe.platform.ani.taihe"),
29      "-I",
30      rebase_path("$taihe_file_path", root_build_dir),
31      "-O",
32      rebase_path("$taihe_generated_file_path", root_build_dir),
33      "-G",
34      "cpp-author",
35      "ani-bridge",
36    ]
37    deps = invoker.deps
38    outputs = [ "$taihe_generated_file_path/src/taihe.platform.ani.abi.c" ]
39    outputs += invoker.outputs
40  }
41}
42
43template("copy_taihe_idl") {
44  assert(defined(invoker.sources), "please provide sources for copy")
45  ohos_copy(target_name) {
46    sources = invoker.sources
47    outputs = [ "$taihe_file_path/{{source_file_part}}" ]
48    if (defined(invoker.external_deps)) {
49      external_deps = invoker.external_deps
50    }
51    if (defined(invoker.deps)) {
52      deps = invoker.deps
53    }
54  }
55}
56
57template("taihe_shared_library") {
58  ohos_shared_library(target_name) {
59    forward_variables_from(invoker,
60                           "*",
61                           [
62                             "sources",
63                             "external_deps",
64                             "include_dirs",
65                           ])
66    include_dirs = [
67      "$taihe_generated_file_path/include",
68      "$taihe_toolchain_path/include",
69    ]
70    if (defined(invoker.include_dirs)) {
71      include_dirs += invoker.include_dirs
72    }
73
74    sources = [
75      "$taihe_toolchain_path/src/taihe/runtime/object.cpp",
76      "$taihe_toolchain_path/src/taihe/runtime/runtime.cpp",
77      "$taihe_toolchain_path/src/taihe/runtime/string.cpp",
78    ]
79    sources += invoker.sources
80
81    external_deps = [
82      "runtime_core:ani",
83      "runtime_core:libarkruntime",
84    ]
85    if (defined(invoker.external_deps)) {
86      external_deps += invoker.external_deps
87    }
88  }
89}
90