1# Copyright (c) 2021-2024 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/runtime_core/static_core/ark_config.gni") 15import("$ark_root/plugins/plugins.gni") 16 17if (ark_standalone_build) { 18 import("$build_root/ark.gni") 19} else { 20 import("//build/ohos.gni") 21} 22 23config("arklinker_public_config") { 24 include_dirs = [ 25 "$ark_root/libpandabase", 26 "$ark_root/libpandafile", 27 ] 28} 29 30arklinker_sources = [ 31 "linker.cpp", 32 "linker_code_parser_context.cpp", 33 "linker_context.cpp", 34 "linker_context_misc.cpp", 35] 36 37arklinker_configs = [ 38 "$ark_root:ark_config", 39 "$ark_root/libpandabase:arkbase_public_config", 40 "$ark_root/libpandafile:arkfile_public_config", 41] 42 43ohos_shared_library("arklinker") { 44 sources = arklinker_sources 45 46 include_dirs = [ 47 "$ark_root/libpandabase", 48 "$ark_root/libpandafile", 49 "$target_gen_dir", 50 ] 51 52 configs = arklinker_configs 53 54 deps = [ 55 "$ark_root/libpandabase:libarktsbase", 56 "$ark_root/libpandafile:libarktsfile", 57 ] 58 59 if (is_mingw || is_win) { 60 deps += [ 61 "$ark_root/libpandabase:libarktsbase_frontend_static", 62 "$ark_root/libpandafile:libarktsfile_frontend_static", 63 ] 64 } 65 66 external_deps = [ sdk_libc_secshared_dep ] 67 68 output_extension = "so" 69 if (is_mingw || is_win) { 70 output_extension = "dll" 71 } 72 part_name = ark_part_name 73 subsystem_name = "$ark_subsystem_name" 74} 75 76ark_gen_file("link_options_h") { 77 template_file = "$ark_root/templates/options/options.h.erb" 78 data = [ "options.yaml" ] 79 api = [ "$ark_root/templates/common.rb" ] 80 output_file = "$target_gen_dir/panda_gen_options/generated/link_options.h" 81} 82 83ohos_static_library("arklinker_static") { 84 sources = arklinker_sources 85 86 include_dirs = [ 87 "$ark_root/libpandabase", 88 "$ark_root/libpandafile", 89 "$target_gen_dir", 90 ] 91 92 configs = arklinker_configs 93 94 deps = [ 95 "$ark_root/libpandabase:libarktsbase_frontend_static", 96 "$ark_root/libpandafile:libarktsfile_frontend_static", 97 ] 98 external_deps = [ sdk_libc_secshared_dep ] 99 100 part_name = "runtime_core" 101 subsystem_name = "arkcompiler" 102} 103 104ohos_executable("ark_link") { 105 sources = [ "link.cpp" ] 106 107 include_dirs = [ 108 "$target_gen_dir", 109 "$target_gen_dir/panda_gen_options", 110 "$ark_root_gen_dir/libpandabase", 111 ] 112 113 configs = [ 114 "$ark_root:ark_config", 115 "$ark_root/static_linker:arklinker_public_config", 116 "$ark_root/libpandabase:arkbase_public_config", 117 "$ark_root/libpandafile:arkfile_public_config", 118 ] 119 120 deps = [ 121 ":arklinker_static", 122 ":link_options_h", 123 ] 124 external_deps = [ sdk_libc_secshared_dep ] 125 126 if (target_os != "win" && target_os != "mingw" && target_os != "winuwp") { 127 if (is_linux) { 128 deps += [ "$ark_root/plugins/ets:etsstdlib_copy_linux" ] 129 } else if (is_mingw || is_win) { 130 deps += [ "$ark_root/plugins/ets:etsstdlib_copy_windows" ] 131 } 132 } 133 134 libs = platform_libs 135 ldflags = platform_ldflags 136 137 install_enable = true 138 part_name = ark_part_name 139 subsystem_name = "$ark_subsystem_name" 140} 141 142group("static_linker") { 143 deps = [ 144 ":ark_link", 145 ":arklinker", 146 ] 147} 148