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