14514f5e3Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
24514f5e3Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
34514f5e3Sopenharmony_ci# you may not use this file except in compliance with the License.
44514f5e3Sopenharmony_ci# You may obtain a copy of the License at
54514f5e3Sopenharmony_ci#
64514f5e3Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
74514f5e3Sopenharmony_ci#
84514f5e3Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
94514f5e3Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
104514f5e3Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114514f5e3Sopenharmony_ci# See the License for the specific language governing permissions and
124514f5e3Sopenharmony_ci# limitations under the License.
134514f5e3Sopenharmony_ci
144514f5e3Sopenharmony_ciimport("//arkcompiler/ets_runtime/js_runtime_config.gni")
154514f5e3Sopenharmony_ciimport("//build/ohos.gni")
164514f5e3Sopenharmony_ci
174514f5e3Sopenharmony_ci# Triggered only when the SDK is compiled
184514f5e3Sopenharmony_ciif (is_standard_system) {
194514f5e3Sopenharmony_ci  # Avoid conditional judgment branches caused by dynamic library suffixes.
204514f5e3Sopenharmony_ci  dylib_suffix = ""
214514f5e3Sopenharmony_ci  if (is_mac) {
224514f5e3Sopenharmony_ci    dylib_suffix = ".dylib"
234514f5e3Sopenharmony_ci  } else if (is_mingw) {
244514f5e3Sopenharmony_ci    dylib_suffix = ".dll"
254514f5e3Sopenharmony_ci  } else if (is_linux) {
264514f5e3Sopenharmony_ci    dylib_suffix = ".so"
274514f5e3Sopenharmony_ci  }
284514f5e3Sopenharmony_ci
294514f5e3Sopenharmony_ci  if (is_mingw) {
304514f5e3Sopenharmony_ci    ohos_copy("copy_ark_aot_compiler_library_win") {
314514f5e3Sopenharmony_ci      deps = []
324514f5e3Sopenharmony_ci      sources = []
334514f5e3Sopenharmony_ci
344514f5e3Sopenharmony_ci      # Add executable "ark_aot_compiler"
354514f5e3Sopenharmony_ci      deps +=
364514f5e3Sopenharmony_ci          [ "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler" ]
374514f5e3Sopenharmony_ci      ark_aot_compiler_path = get_label_info(
384514f5e3Sopenharmony_ci              "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler",
394514f5e3Sopenharmony_ci              "root_out_dir")
404514f5e3Sopenharmony_ci      sources += [
414514f5e3Sopenharmony_ci        "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler.exe",
424514f5e3Sopenharmony_ci      ]
434514f5e3Sopenharmony_ci
444514f5e3Sopenharmony_ci      # Add executable "profdump"
454514f5e3Sopenharmony_ci      deps += [ "$js_root/ecmascript/pgo_profiler/prof_dump:profdump" ]
464514f5e3Sopenharmony_ci      prof_dump_path =
474514f5e3Sopenharmony_ci          get_label_info("$js_root/ecmascript/pgo_profiler/prof_dump:profdump",
484514f5e3Sopenharmony_ci                         "root_out_dir")
494514f5e3Sopenharmony_ci      sources += [ "$prof_dump_path/arkcompiler/ets_runtime/profdump.exe" ]
504514f5e3Sopenharmony_ci
514514f5e3Sopenharmony_ci      # Add dynamic library "hilog"
524514f5e3Sopenharmony_ci      hilog_path = get_label_info("$hilog_root:libhilog", "root_out_dir")
534514f5e3Sopenharmony_ci      deps += [ "$hilog_root:libhilog" ]
544514f5e3Sopenharmony_ci      sources += [ "${hilog_path}/hiviewdfx/hilog/libhilog${dylib_suffix}" ]
554514f5e3Sopenharmony_ci
564514f5e3Sopenharmony_ci      # Add dynamic library "icu"
574514f5e3Sopenharmony_ci      icu_path =
584514f5e3Sopenharmony_ci          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
594514f5e3Sopenharmony_ci      deps += [
604514f5e3Sopenharmony_ci        "//third_party/icu/icu4c:shared_icui18n",
614514f5e3Sopenharmony_ci        "//third_party/icu/icu4c:shared_icuuc",
624514f5e3Sopenharmony_ci      ]
634514f5e3Sopenharmony_ci      sources += [
644514f5e3Sopenharmony_ci        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
654514f5e3Sopenharmony_ci        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
664514f5e3Sopenharmony_ci      ]
674514f5e3Sopenharmony_ci
684514f5e3Sopenharmony_ci      # Add dynamic library "libsec_shared"
694514f5e3Sopenharmony_ci      sec_path =
704514f5e3Sopenharmony_ci          get_label_info("//third_party/bounds_checking_function:libsec_shared",
714514f5e3Sopenharmony_ci                         "root_out_dir")
724514f5e3Sopenharmony_ci      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
734514f5e3Sopenharmony_ci      sources += [
744514f5e3Sopenharmony_ci        sec_path +
754514f5e3Sopenharmony_ci            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
764514f5e3Sopenharmony_ci      ]
774514f5e3Sopenharmony_ci
784514f5e3Sopenharmony_ci      # Add dynamic library "libshared_libz"
794514f5e3Sopenharmony_ci      zlib_path =
804514f5e3Sopenharmony_ci          get_label_info("//third_party/zlib:shared_libz", "root_out_dir")
814514f5e3Sopenharmony_ci      deps += [ "//third_party/zlib:shared_libz" ]
824514f5e3Sopenharmony_ci      sources +=
834514f5e3Sopenharmony_ci          [ zlib_path + "/thirdparty/zlib/libshared_libz${dylib_suffix}" ]
844514f5e3Sopenharmony_ci
854514f5e3Sopenharmony_ci      # Set the output directory for all dynamic libraries.
864514f5e3Sopenharmony_ci      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/bin/{{source_file_part}}" ]
874514f5e3Sopenharmony_ci      module_source_dir =
884514f5e3Sopenharmony_ci          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/bin/"
894514f5e3Sopenharmony_ci      module_install_name = ""
904514f5e3Sopenharmony_ci      part_name = "ets_runtime"
914514f5e3Sopenharmony_ci      subsystem_name = "arkcompiler"
924514f5e3Sopenharmony_ci    }
934514f5e3Sopenharmony_ci
944514f5e3Sopenharmony_ci    ohos_copy("copy_ark_aot_builtins_win") {
954514f5e3Sopenharmony_ci      deps = []
964514f5e3Sopenharmony_ci      sources = []
974514f5e3Sopenharmony_ci
984514f5e3Sopenharmony_ci      # Add lib_ark_builtins
994514f5e3Sopenharmony_ci      sources += [
1004514f5e3Sopenharmony_ci        "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts",
1014514f5e3Sopenharmony_ci      ]
1024514f5e3Sopenharmony_ci
1034514f5e3Sopenharmony_ci      # Set the output directory
1044514f5e3Sopenharmony_ci      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-win/aot/src/{{source_file_part}}" ]
1054514f5e3Sopenharmony_ci      module_source_dir =
1064514f5e3Sopenharmony_ci          target_out_dir +
1074514f5e3Sopenharmony_ci          "/ets/build-tools/ets-loader/bin/ark/build-win/aot/src/"
1084514f5e3Sopenharmony_ci      module_install_name = ""
1094514f5e3Sopenharmony_ci    }
1104514f5e3Sopenharmony_ci  } else if (is_linux) {
1114514f5e3Sopenharmony_ci    ohos_copy("copy_ark_aot_compiler_library") {
1124514f5e3Sopenharmony_ci      deps = []
1134514f5e3Sopenharmony_ci      sources = []
1144514f5e3Sopenharmony_ci
1154514f5e3Sopenharmony_ci      # Add executable "ark_aot_compiler"
1164514f5e3Sopenharmony_ci      deps +=
1174514f5e3Sopenharmony_ci          [ "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler" ]
1184514f5e3Sopenharmony_ci      ark_aot_compiler_path = get_label_info(
1194514f5e3Sopenharmony_ci              "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler",
1204514f5e3Sopenharmony_ci              "root_out_dir")
1214514f5e3Sopenharmony_ci      sources +=
1224514f5e3Sopenharmony_ci          [ "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler" ]
1234514f5e3Sopenharmony_ci
1244514f5e3Sopenharmony_ci      # Add executable "profdump"
1254514f5e3Sopenharmony_ci      deps += [ "$js_root/ecmascript/pgo_profiler/prof_dump:profdump" ]
1264514f5e3Sopenharmony_ci      prof_dump_path =
1274514f5e3Sopenharmony_ci          get_label_info("$js_root/ecmascript/pgo_profiler/prof_dump:profdump",
1284514f5e3Sopenharmony_ci                         "root_out_dir")
1294514f5e3Sopenharmony_ci      sources += [ "$prof_dump_path/arkcompiler/ets_runtime/profdump" ]
1304514f5e3Sopenharmony_ci
1314514f5e3Sopenharmony_ci      # Add dynamic library "hilog"
1324514f5e3Sopenharmony_ci      hilog_path = get_label_info("$hilog_root:libhilog_linux", "root_out_dir")
1334514f5e3Sopenharmony_ci      deps += [ "$hilog_root:libhilog_linux" ]
1344514f5e3Sopenharmony_ci      sources +=
1354514f5e3Sopenharmony_ci          [ "${hilog_path}/hiviewdfx/hilog/libhilog_linux${dylib_suffix}" ]
1364514f5e3Sopenharmony_ci
1374514f5e3Sopenharmony_ci      # Add dynamic library "icu"
1384514f5e3Sopenharmony_ci      icu_path =
1394514f5e3Sopenharmony_ci          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
1404514f5e3Sopenharmony_ci      deps += [
1414514f5e3Sopenharmony_ci        "//third_party/icu/icu4c:shared_icui18n",
1424514f5e3Sopenharmony_ci        "//third_party/icu/icu4c:shared_icuuc",
1434514f5e3Sopenharmony_ci      ]
1444514f5e3Sopenharmony_ci      sources += [
1454514f5e3Sopenharmony_ci        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
1464514f5e3Sopenharmony_ci        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
1474514f5e3Sopenharmony_ci      ]
1484514f5e3Sopenharmony_ci
1494514f5e3Sopenharmony_ci      # Add dynamic library "libsec_shared"
1504514f5e3Sopenharmony_ci      sec_path =
1514514f5e3Sopenharmony_ci          get_label_info("//third_party/bounds_checking_function:libsec_shared",
1524514f5e3Sopenharmony_ci                         "root_out_dir")
1534514f5e3Sopenharmony_ci      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
1544514f5e3Sopenharmony_ci      sources += [
1554514f5e3Sopenharmony_ci        sec_path +
1564514f5e3Sopenharmony_ci            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
1574514f5e3Sopenharmony_ci      ]
1584514f5e3Sopenharmony_ci
1594514f5e3Sopenharmony_ci      # Add dynamic library "libshared_libz"
1604514f5e3Sopenharmony_ci      zlib_path =
1614514f5e3Sopenharmony_ci          get_label_info("//third_party/zlib:shared_libz", "root_out_dir")
1624514f5e3Sopenharmony_ci      deps += [ "//third_party/zlib:shared_libz" ]
1634514f5e3Sopenharmony_ci      sources +=
1644514f5e3Sopenharmony_ci          [ zlib_path + "/thirdparty/zlib/libshared_libz${dylib_suffix}" ]
1654514f5e3Sopenharmony_ci
1664514f5e3Sopenharmony_ci      # Set the output directory for all dynamic libraries.
1674514f5e3Sopenharmony_ci      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/bin/{{source_file_part}}" ]
1684514f5e3Sopenharmony_ci      module_source_dir =
1694514f5e3Sopenharmony_ci          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/bin/"
1704514f5e3Sopenharmony_ci      module_install_name = ""
1714514f5e3Sopenharmony_ci      part_name = "ets_runtime"
1724514f5e3Sopenharmony_ci      subsystem_name = "arkcompiler"
1734514f5e3Sopenharmony_ci    }
1744514f5e3Sopenharmony_ci    ohos_copy("copy_ark_aot_builtins") {
1754514f5e3Sopenharmony_ci      deps = []
1764514f5e3Sopenharmony_ci      sources = []
1774514f5e3Sopenharmony_ci
1784514f5e3Sopenharmony_ci      # Add lib_ark_builtins
1794514f5e3Sopenharmony_ci      sources += [
1804514f5e3Sopenharmony_ci        "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts",
1814514f5e3Sopenharmony_ci      ]
1824514f5e3Sopenharmony_ci
1834514f5e3Sopenharmony_ci      # Set the output directory
1844514f5e3Sopenharmony_ci      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/aot/src/{{source_file_part}}" ]
1854514f5e3Sopenharmony_ci      module_source_dir =
1864514f5e3Sopenharmony_ci          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build/aot/src/"
1874514f5e3Sopenharmony_ci      module_install_name = ""
1884514f5e3Sopenharmony_ci    }
1894514f5e3Sopenharmony_ci  } else if (is_mac) {
1904514f5e3Sopenharmony_ci    # Both x86_64 and arm64 are supported
1914514f5e3Sopenharmony_ci    ohos_copy("copy_ark_aot_compiler_library_darwin") {
1924514f5e3Sopenharmony_ci      deps = []
1934514f5e3Sopenharmony_ci      sources = []
1944514f5e3Sopenharmony_ci
1954514f5e3Sopenharmony_ci      # Add executable "ark_aot_compiler"
1964514f5e3Sopenharmony_ci      deps += [ "$js_root/ecmascript/compiler:ark_aot_compiler" ]
1974514f5e3Sopenharmony_ci      ark_aot_compiler_path =
1984514f5e3Sopenharmony_ci          get_label_info("$js_root/ecmascript/compiler:ark_aot_compiler",
1994514f5e3Sopenharmony_ci                         "root_out_dir")
2004514f5e3Sopenharmony_ci      sources +=
2014514f5e3Sopenharmony_ci          [ "$ark_aot_compiler_path/arkcompiler/ets_runtime/ark_aot_compiler" ]
2024514f5e3Sopenharmony_ci
2034514f5e3Sopenharmony_ci      # Add dynamic library "icu"
2044514f5e3Sopenharmony_ci      icu_path =
2054514f5e3Sopenharmony_ci          get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
2064514f5e3Sopenharmony_ci      deps += [
2074514f5e3Sopenharmony_ci        "//third_party/icu/icu4c:shared_icui18n",
2084514f5e3Sopenharmony_ci        "//third_party/icu/icu4c:shared_icuuc",
2094514f5e3Sopenharmony_ci      ]
2104514f5e3Sopenharmony_ci      sources += [
2114514f5e3Sopenharmony_ci        "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
2124514f5e3Sopenharmony_ci        "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
2134514f5e3Sopenharmony_ci      ]
2144514f5e3Sopenharmony_ci
2154514f5e3Sopenharmony_ci      # Add dynamic library "libsec_shared"
2164514f5e3Sopenharmony_ci      sec_path =
2174514f5e3Sopenharmony_ci          get_label_info("//third_party/bounds_checking_function:libsec_shared",
2184514f5e3Sopenharmony_ci                         "root_out_dir")
2194514f5e3Sopenharmony_ci      deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
2204514f5e3Sopenharmony_ci      sources += [
2214514f5e3Sopenharmony_ci        sec_path +
2224514f5e3Sopenharmony_ci            "/thirdparty/bounds_checking_function/libsec_shared${dylib_suffix}",
2234514f5e3Sopenharmony_ci      ]
2244514f5e3Sopenharmony_ci
2254514f5e3Sopenharmony_ci      # Add dynamic library "libshared_libz"
2264514f5e3Sopenharmony_ci      zlib_path =
2274514f5e3Sopenharmony_ci          get_label_info("//third_party/zlib:shared_libz", "root_out_dir")
2284514f5e3Sopenharmony_ci      deps += [ "//third_party/zlib:shared_libz" ]
2294514f5e3Sopenharmony_ci      sources +=
2304514f5e3Sopenharmony_ci          [ zlib_path + "/thirdparty/zlib/libshared_libz${dylib_suffix}" ]
2314514f5e3Sopenharmony_ci
2324514f5e3Sopenharmony_ci      # Add dynamic library "hilog"
2334514f5e3Sopenharmony_ci      hilog_path = get_label_info("$hilog_root:libhilog", "root_out_dir")
2344514f5e3Sopenharmony_ci      deps += [ "$hilog_root:libhilog" ]
2354514f5e3Sopenharmony_ci      sources += [ "${hilog_path}/hiviewdfx/hilog/libhilog${dylib_suffix}" ]
2364514f5e3Sopenharmony_ci
2374514f5e3Sopenharmony_ci      # Set the output directory for all dynamic libraries.
2384514f5e3Sopenharmony_ci      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/bin/{{source_file_part}}" ]
2394514f5e3Sopenharmony_ci      module_source_dir =
2404514f5e3Sopenharmony_ci          target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/bin/"
2414514f5e3Sopenharmony_ci      module_install_name = ""
2424514f5e3Sopenharmony_ci      part_name = "ets_runtime"
2434514f5e3Sopenharmony_ci      subsystem_name = "arkcompiler"
2444514f5e3Sopenharmony_ci    }
2454514f5e3Sopenharmony_ci
2464514f5e3Sopenharmony_ci    ohos_copy("copy_ark_aot_builtins_mac") {
2474514f5e3Sopenharmony_ci      deps = []
2484514f5e3Sopenharmony_ci      sources = []
2494514f5e3Sopenharmony_ci
2504514f5e3Sopenharmony_ci      # Add lib_ark_builtins
2514514f5e3Sopenharmony_ci      sources += [ "../ts_types/lib_ark_builtins.d.ts" ]
2524514f5e3Sopenharmony_ci
2534514f5e3Sopenharmony_ci      # Set the output directory
2544514f5e3Sopenharmony_ci      outputs = [ target_out_dir + "/ets/build-tools/ets-loader/bin/ark/build-mac/aot/src/{{source_file_part}}" ]
2554514f5e3Sopenharmony_ci      module_source_dir =
2564514f5e3Sopenharmony_ci          target_out_dir +
2574514f5e3Sopenharmony_ci          "/ets/build-tools/ets-loader/bin/ark/build-mac/aot/src/"
2584514f5e3Sopenharmony_ci      module_install_name = ""
2594514f5e3Sopenharmony_ci      part_name = "ets_runtime"
2604514f5e3Sopenharmony_ci      subsystem_name = "arkcompiler"
2614514f5e3Sopenharmony_ci    }
2624514f5e3Sopenharmony_ci  }
2634514f5e3Sopenharmony_ci}
264