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