1# Copyright (c) 2021-2024 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("//arkcompiler/runtime_core/static_core/ark_config.gni")
15import("$ark_root/plugins/plugins.gni")
16
17if (ark_standalone_build) {
18  import("$build_root/ark.gni")
19} else {
20  import("//build/ohos.gni")
21}
22
23config("arklinker_public_config") {
24  include_dirs = [
25    "$ark_root/libpandabase",
26    "$ark_root/libpandafile",
27  ]
28}
29
30arklinker_sources = [
31  "linker.cpp",
32  "linker_code_parser_context.cpp",
33  "linker_context.cpp",
34  "linker_context_misc.cpp",
35]
36
37arklinker_configs = [
38  "$ark_root:ark_config",
39  "$ark_root/libpandabase:arkbase_public_config",
40  "$ark_root/libpandafile:arkfile_public_config",
41]
42
43ohos_shared_library("arklinker") {
44  sources = arklinker_sources
45
46  include_dirs = [
47    "$ark_root/libpandabase",
48    "$ark_root/libpandafile",
49    "$target_gen_dir",
50  ]
51
52  configs = arklinker_configs
53
54  deps = [
55    "$ark_root/libpandabase:libarktsbase",
56    "$ark_root/libpandafile:libarktsfile",
57  ]
58
59  external_deps = [ sdk_libc_secshared_dep ]
60
61  output_extension = "so"
62  if (is_mingw) {
63    output_extension = "dll"
64  }
65  part_name = ark_part_name
66  subsystem_name = "$ark_subsystem_name"
67}
68
69ark_gen_file("link_options_h") {
70  template_file = "$ark_root/templates/options/options.h.erb"
71  data = [ "options.yaml" ]
72  api = [ "$ark_root/templates/common.rb" ]
73  output_file = "$target_gen_dir/panda_gen_options/generated/link_options.h"
74}
75
76ohos_executable("ark_link") {
77  sources = [ "link.cpp" ]
78
79  include_dirs = [
80    "$target_gen_dir",
81    "$target_gen_dir/panda_gen_options",
82    "$ark_root_gen_dir/libpandabase",
83  ]
84
85  configs = [
86    "$ark_root:ark_config",
87    "$ark_root/static_linker:arklinker_public_config",
88    "$ark_root/libpandabase:arkbase_public_config",
89    "$ark_root/libpandafile:arkfile_public_config",
90  ]
91
92  deps = [
93    ":arklinker",
94    ":link_options_h",
95    "$ark_root/libpandabase:libarktsbase",
96  ]
97
98  libs = platform_libs
99  ldflags = platform_ldflags
100
101  install_enable = true
102  part_name = ark_part_name
103  subsystem_name = "$ark_subsystem_name"
104}
105