• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-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("//arkcompiler/ets_runtime/js_runtime_config.gni")
15import("//build/ohos.gni")
16
17# Triggered only when the SDK is compiled
18if (is_standard_system) {
19  # Avoid conditional judgment branches caused by dynamic library suffixes.
20  dylib_suffix = ""
21  if (is_mac) {
22    dylib_suffix = ".dylib"
23  } else if (is_mingw) {
24    dylib_suffix = ".dll"
25  } else if (is_linux) {
26    dylib_suffix = ".so"
27  }
28
29  if (is_mingw) {
30    ohos_copy("copy_ark_aot_compiler_library_win") {
31      deps = []
32      sources = []
33
34      # Add executable "ark_aot_compiler"
35      deps +=
36          [ "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler" ]
37      ark_aot_compiler_path = get_label_info(
38              "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler",
39              "root_out_dir")
40      sources += [
41        "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler.exe",
42      ]
43
44      # Add executable "profdump"
45      deps += [ "$js_root/ecmascript/pgo_profiler/prof_dump:profdump" ]
46      prof_dump_path =
47          get_label_info("$js_root/ecmascript/pgo_profiler/prof_dump:profdump",
48                         "root_out_dir")
49      sources += [ "$prof_dump_path/arkcompiler/ets_runtime/profdump.exe" ]
50
51      # Add dynamic library "hilog"
52      hilog_path = get_label_info("$hilog_root:libhilog", "root_out_dir")
53      deps += [ "$hilog_root:libhilog" ]
54      sources += [ "${hilog_path}/hiviewdfx/hilog/libhilog${dylib_suffix}" ]
55
56      # Add dynamic library "icu"
57      icu_path =
58          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
59      deps += [
60        "//third_party/icu/icu4c:shared_icui18n",
61        "//third_party/icu/icu4c:shared_icuuc",
62      ]
63      sources += [
64        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
65        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
66      ]
67
68      # Add dynamic library "libsec_shared"
69      sec_path =
70          get_label_info("//third_party/bounds_checking_function:libsec_shared",
71                         "root_out_dir")
72      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
73      sources += [
74        sec_path +
75            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
76      ]
77
78      # Add dynamic library "libshared_libz"
79      external_deps = [ "zlib:shared_libz" ]
80
81      # Set the output directory for all dynamic libraries.
82      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/bin/{{source_file_part}}" ]
83      module_source_dir =
84          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/bin/"
85      module_install_name = ""
86      part_name = "ets_runtime"
87      subsystem_name = "arkcompiler"
88    }
89
90    ohos_copy("copy_ark_aot_builtins_win") {
91      deps = []
92      sources = []
93
94      # Add lib_ark_builtins
95      sources += [
96        "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts",
97      ]
98
99      # Set the output directory
100      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/aot/src/{{source_file_part}}" ]
101      module_source_dir =
102          target_out_dir +
103          "/ets/build-tools/ets-loader/bin/ark/build-win/aot/src/"
104      module_install_name = ""
105    }
106  } else if (is_linux) {
107    ohos_copy("copy_ark_aot_compiler_library") {
108      deps = []
109      sources = []
110
111      # Add executable "ark_aot_compiler"
112      deps +=
113          [ "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler" ]
114      ark_aot_compiler_path = get_label_info(
115              "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler",
116              "root_out_dir")
117      sources +=
118          [ "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler" ]
119
120      # Add executable "profdump"
121      deps += [ "$js_root/ecmascript/pgo_profiler/prof_dump:profdump" ]
122      prof_dump_path =
123          get_label_info("$js_root/ecmascript/pgo_profiler/prof_dump:profdump",
124                         "root_out_dir")
125      sources += [ "$prof_dump_path/arkcompiler/ets_runtime/profdump" ]
126
127      # Add dynamic library "hilog"
128      hilog_path = get_label_info("$hilog_root:libhilog_linux", "root_out_dir")
129      deps += [ "$hilog_root:libhilog_linux" ]
130      sources +=
131          [ "${hilog_path}/hiviewdfx/hilog/libhilog_linux${dylib_suffix}" ]
132
133      # Add dynamic library "icu"
134      icu_path =
135          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
136      deps += [
137        "//third_party/icu/icu4c:shared_icui18n",
138        "//third_party/icu/icu4c:shared_icuuc",
139      ]
140      sources += [
141        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
142        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
143      ]
144
145      # Add dynamic library "libsec_shared"
146      sec_path =
147          get_label_info("//third_party/bounds_checking_function:libsec_shared",
148                         "root_out_dir")
149      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
150      sources += [
151        sec_path +
152            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
153      ]
154
155      # Add dynamic library "libshared_libz"
156      external_deps = [ "zlib:shared_libz" ]
157
158      # Set the output directory for all dynamic libraries.
159      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/bin/{{source_file_part}}" ]
160      module_source_dir =
161          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/bin/"
162      module_install_name = ""
163      part_name = "ets_runtime"
164      subsystem_name = "arkcompiler"
165    }
166    ohos_copy("copy_ark_aot_builtins") {
167      deps = []
168      sources = []
169
170      # Add lib_ark_builtins
171      sources += [
172        "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts",
173      ]
174
175      # Set the output directory
176      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/aot/src/{{source_file_part}}" ]
177      module_source_dir =
178          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/aot/src/"
179      module_install_name = ""
180    }
181  } else if (is_mac) {
182    # Both x86_64 and arm64 are supported
183    ohos_copy("copy_ark_aot_compiler_library_darwin") {
184      deps = []
185      sources = []
186
187      # Add executable "ark_aot_compiler"
188      deps += [ "$js_root/ecmascript/compiler:ark_aot_compiler" ]
189      ark_aot_compiler_path =
190          get_label_info("$js_root/ecmascript/compiler:ark_aot_compiler",
191                         "root_out_dir")
192      sources +=
193          [ "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler" ]
194
195      # Add dynamic library "icu"
196      icu_path =
197          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
198      deps += [
199        "//third_party/icu/icu4c:shared_icui18n",
200        "//third_party/icu/icu4c:shared_icuuc",
201      ]
202      sources += [
203        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
204        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
205      ]
206
207      # Add dynamic library "libsec_shared"
208      sec_path =
209          get_label_info("//third_party/bounds_checking_function:libsec_shared",
210                         "root_out_dir")
211      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
212      sources += [
213        sec_path +
214            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
215      ]
216
217      # Add dynamic library "libshared_libz"
218      external_deps = [ "zlib:shared_libz" ]
219
220      # Add dynamic library "hilog"
221      hilog_path = get_label_info("$hilog_root:libhilog", "root_out_dir")
222      deps += [ "$hilog_root:libhilog" ]
223      sources += [ "${hilog_path}/hiviewdfx/hilog/libhilog${dylib_suffix}" ]
224
225      # Set the output directory for all dynamic libraries.
226      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/bin/{{source_file_part}}" ]
227      module_source_dir =
228          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/bin/"
229      module_install_name = ""
230      part_name = "ets_runtime"
231      subsystem_name = "arkcompiler"
232    }
233
234    ohos_copy("copy_ark_aot_builtins_mac") {
235      deps = []
236      sources = []
237
238      # Add lib_ark_builtins
239      sources += [ "../ts_types/lib_ark_builtins.d.ts" ]
240
241      # Set the output directory
242      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/aot/src/{{source_file_part}}" ]
243      module_source_dir =
244          target_out_dir +
245          "/ets/build-tools/ets-loader/bin/ark/build-mac/aot/src/"
246      module_install_name = ""
247      part_name = "ets_runtime"
248      subsystem_name = "arkcompiler"
249    }
250  }
251}
252