• 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(
53              "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_windows",
54              "root_out_dir")
55      deps += [
56        "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_windows",
57      ]
58      sources += [
59        "${hilog_path}/hiviewdfx/hilog_native/libhilog_windows${dylib_suffix}",
60      ]
61
62      # Add dynamic library "icu"
63      icu_path =
64          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
65      deps += [
66        "//third_party/icu/icu4c:shared_icui18n",
67        "//third_party/icu/icu4c:shared_icuuc",
68      ]
69      sources += [
70        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
71        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
72      ]
73
74      # Add dynamic library "libsec_shared"
75      sec_path =
76          get_label_info("//third_party/bounds_checking_function:libsec_shared",
77                         "root_out_dir")
78      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
79      sources += [
80        sec_path +
81            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
82      ]
83
84      # Add dynamic library "libshared_libz"
85      zlib_path =
86          get_label_info("//third_party/zlib:shared_libz", "root_out_dir")
87      deps += [ "//third_party/zlib:shared_libz" ]
88      sources +=
89          [ zlib_path + "/thirdparty/zlib/libshared_libz${dylib_suffix}" ]
90
91      # Set the output directory for all dynamic libraries.
92      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/bin/{{source_file_part}}" ]
93      module_source_dir =
94          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/bin/"
95      module_install_name = ""
96    }
97
98    ohos_copy("copy_ark_aot_builtins_win") {
99      deps = []
100      sources = []
101
102      # Add lib_ark_builtins
103      sources += [
104        "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts",
105      ]
106
107      # Set the output directory
108      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/aot/src/{{source_file_part}}" ]
109      module_source_dir =
110          target_out_dir +
111          "/ets/build-tools/ets-loader/bin/ark/build-win/aot/src/"
112      module_install_name = ""
113      part_name = "ets_runtime"
114      subsystem_name = "arkcompiler"
115    }
116  } else if (is_linux) {
117    ohos_copy("copy_ark_aot_compiler_library") {
118      deps = []
119      sources = []
120
121      # Add executable "ark_aot_compiler"
122      deps +=
123          [ "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler" ]
124      ark_aot_compiler_path = get_label_info(
125              "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler",
126              "root_out_dir")
127      sources +=
128          [ "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler" ]
129
130      # Add executable "profdump"
131      deps += [ "$js_root/ecmascript/pgo_profiler/prof_dump:profdump" ]
132      prof_dump_path =
133          get_label_info("$js_root/ecmascript/pgo_profiler/prof_dump:profdump",
134                         "root_out_dir")
135      sources += [ "$prof_dump_path/arkcompiler/ets_runtime/profdump" ]
136
137      # Add dynamic library "hilog"
138      hilog_path = get_label_info(
139              "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_linux",
140              "root_out_dir")
141      deps += [
142        "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_linux",
143      ]
144      sources += [
145        "${hilog_path}/hiviewdfx/hilog_native/libhilog_linux${dylib_suffix}",
146      ]
147
148      # Add dynamic library "icu"
149      icu_path =
150          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
151      deps += [
152        "//third_party/icu/icu4c:shared_icui18n",
153        "//third_party/icu/icu4c:shared_icuuc",
154      ]
155      sources += [
156        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
157        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
158      ]
159
160      # Add dynamic library "libsec_shared"
161      sec_path =
162          get_label_info("//third_party/bounds_checking_function:libsec_shared",
163                         "root_out_dir")
164      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
165      sources += [
166        sec_path +
167            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
168      ]
169
170      # Add dynamic library "libshared_libz"
171      zlib_path =
172          get_label_info("//third_party/zlib:shared_libz", "root_out_dir")
173      deps += [ "//third_party/zlib:shared_libz" ]
174      sources +=
175          [ zlib_path + "/thirdparty/zlib/libshared_libz${dylib_suffix}" ]
176
177      # Set the output directory for all dynamic libraries.
178      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/bin/{{source_file_part}}" ]
179      module_source_dir =
180          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/bin/"
181      module_install_name = ""
182      part_name = "ets_runtime"
183      subsystem_name = "arkcompiler"
184    }
185    ohos_copy("copy_ark_aot_builtins") {
186      deps = []
187      sources = []
188
189      # Add lib_ark_builtins
190      sources += [
191        "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts",
192      ]
193
194      # Set the output directory
195      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/aot/src/{{source_file_part}}" ]
196      module_source_dir =
197          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/aot/src/"
198      module_install_name = ""
199    }
200  } else if (is_mac) {
201    # Both x86_64 and arm64 are supported
202    ohos_copy("copy_ark_aot_compiler_library_darwin") {
203      deps = []
204      sources = []
205
206      # Add executable "ark_aot_compiler"
207      deps += [ "$js_root/ecmascript/compiler:ark_aot_compiler" ]
208      ark_aot_compiler_path =
209          get_label_info("$js_root/ecmascript/compiler:ark_aot_compiler",
210                         "root_out_dir")
211      sources +=
212          [ "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler" ]
213
214      # Add dynamic library "icu"
215      icu_path =
216          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
217      deps += [
218        "//third_party/icu/icu4c:shared_icui18n",
219        "//third_party/icu/icu4c:shared_icuuc",
220      ]
221      sources += [
222        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
223        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
224      ]
225
226      # Add dynamic library "libsec_shared"
227      sec_path =
228          get_label_info("//third_party/bounds_checking_function:libsec_shared",
229                         "root_out_dir")
230      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
231      sources += [
232        sec_path +
233            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
234      ]
235
236      # Add dynamic library "libshared_libz"
237      zlib_path =
238          get_label_info("//third_party/zlib:shared_libz", "root_out_dir")
239      deps += [ "//third_party/zlib:shared_libz" ]
240      sources +=
241          [ zlib_path + "/thirdparty/zlib/libshared_libz${dylib_suffix}" ]
242
243      # Add dynamic library "hilog"
244      hilog_path = get_label_info(
245              "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_mac",
246              "root_out_dir")
247      deps +=
248          [ "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_mac" ]
249      sources +=
250          [ "${hilog_path}/hiviewdfx/hilog_native/libhilog_mac${dylib_suffix}" ]
251
252      # Set the output directory for all dynamic libraries.
253      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/bin/{{source_file_part}}" ]
254      module_source_dir =
255          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/bin/"
256      module_install_name = ""
257      part_name = "ets_runtime"
258      subsystem_name = "arkcompiler"
259    }
260
261    ohos_copy("copy_ark_aot_builtins_mac") {
262      deps = []
263      sources = []
264
265      # Add lib_ark_builtins
266      sources += [ "../ts_types/lib_ark_builtins.d.ts" ]
267
268      # Set the output directory
269      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/aot/src/{{source_file_part}}" ]
270      module_source_dir =
271          target_out_dir +
272          "/ets/build-tools/ets-loader/bin/ark/build-mac/aot/src/"
273      module_install_name = ""
274      part_name = "ets_runtime"
275      subsystem_name = "arkcompiler"
276    }
277  }
278}
279